diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 15e5236..bd83905 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -81,6 +81,7 @@ $routes->get("new_sale/(:any)", "Sales::new_sale/$1");
$routes->get("delete_sale/(:any)", "Sales::delete_sale/$1");
$routes->post("delete_sales_product", "Sales::delete_sales_product");
$routes->get("download_invoice/(:any)", "Sales::download_invoice/$1");
+$routes->get("preview_invoice/(:any)", "Sales::preview_invoice/$1");
$routes->post("save_vehicle", "Sales::save_vehicle");
$routes->post("getProducts", "Sales::getProducts");
//end salle order//
diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php
index d359936..1bc2a2e 100755
--- a/app/Controllers/Jobcard.php
+++ b/app/Controllers/Jobcard.php
@@ -134,17 +134,20 @@ class Jobcard extends BaseController
$totalAmount = ($amt_with_tax - (float)$discount) / (1 + ($totalTax/100));
// Create single output array
$labour_data[0] = [
- "product_name" => "Labour Cost",
- "qty" => 1,
+ "name" => "Labour Cost",
+ "qty" => "-",
+ "per" => "-",
"tax" => number_format($totalTax, 2),
- "custom_amount" => number_format($totalAmount, 2),
+ "amount" => number_format($totalAmount, 2),
"custom_tax" => number_format($totalTax, 2),
"custom_total" => number_format($total, 2)
];
$data['job_card_products'] = array_merge($productdata, $labour_data);
- // echo json_encode($complaintdata);die;
- $html = view('invoice_pdf_template_jobcard', $data);
- return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
+
+
+
+ $html = view('invoice_pdf_template_jobcard', $data);
+ return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
@@ -195,10 +198,11 @@ class Jobcard extends BaseController
$totalAmount = ($amt_with_tax - (float)$discount) / (1 + ($totalTax/100));
// Create single output array
$labour_data[0] = [
- "product_name" => "Labour Cost",
- "qty" => 1,
+ "name" => "Labour Cost",
+ "qty" => '-',
+ "per" => '-',
"tax" => number_format($totalTax, 2),
- "custom_amount" => number_format($totalAmount, 2),
+ "amount" => number_format($totalAmount, 2),
"custom_tax" => number_format($totalTax, 2),
"custom_total" => number_format($total, 2)
];
@@ -208,7 +212,7 @@ class Jobcard extends BaseController
// Create an mPDF object
$mpdf = new Mpdf([
'mode' => '',
- 'format' => 'A5',
+ 'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index 8b3f285..598da70 100755
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -12,9 +12,11 @@ use App\Models\VehicleModel;
use App\Models\BusinessModel;
use App\Models\BranchModel;
use Mpdf\Mpdf;
+use CodeIgniter\API\ResponseTrait;
class Sales extends BaseController
{
public $session;
+ use ResponseTrait;
protected $BikemodelsModel;
protected $BikemakeModel;
public function __construct()
@@ -336,18 +338,18 @@ class Sales extends BaseController
$BusinessModel = new BusinessModel();
$BikemodelsModel = new BikemodelsModel();
$BikemakeModel = new BikemakeModel();
- $data = $model->getSalesPdf($sales_order_id);
- $bus_id = $this->session->get('logged_user_business_id');
- $branch = $BranchModel->where('branch_id', $data[0]->branch_id)->first();
- $business = $BusinessModel->where('business_id', $branch['business_id'])->first();
- $vehicle = $VehicleModel->where('vehicle_id',$data[0]->vehicle_id)->first();
- $bike_model = $BikemodelsModel->where('model_id',$vehicle['model'])->first();
- $bike_make = $BikemakeModel->where('make_id', $vehicle['make'])->first();
- $items = $model->getSalesOrderProductsForPdf($sales_order_id);
+ $data['sales'] = $model->getSalesPdf($sales_order_id);
+ $data['branch'] = $BranchModel->where('branch_id', $data['sales'][0]->branch_id)->first();
+ $data['vehicle'] = $VehicleModel->select('vehicle.reg_no,vehicle.colour,vehicle.email,vehicle.mobile_no,vehicle.year_of_manufacturing, make.make as make_name, model.model_name')
+ ->join('model', 'model.model_id = vehicle.model', 'left')
+ ->join('make', 'make.make_id = vehicle.make', 'left')
+ ->where('vehicle.vehicle_id', $data['sales'][0]->vehicle_id)
+ ->first();
+ $data['items'] = $model->getSalesOrderProductsForPdf($sales_order_id);
$mpdf = new Mpdf([
'mode' => '',
- 'format' => 'A5',
+ 'format' => 'A4',
'default_font_size' => 0,
'default_font' => '',
// 'margin_right' => 1,
@@ -361,35 +363,62 @@ class Sales extends BaseController
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Invoice');
- $mpdf->SetAuthor($data[0]->branch_name);
+ $mpdf->SetAuthor($data['sales'][0]->branch_name);
$mpdf->SetCreator('');
// Generate the PDF content (HTML)
- if ($data[0]->status === 'Draft') {
+ if ($data['sales'][0]->status === 'Draft') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Draft');
$mpdf->showWatermarkText = true;
}
- if ($data[0]->status === 'Cancelled') {
+ if ($data['sales'][0]->status === 'Cancelled') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Cancelled');
$mpdf->showWatermarkText = true;
}
- if ($data[0]->status === 'Void') {
+ if ($data['sales'][0]->status === 'Void') {
// Set the watermark text and options
$mpdf->SetWatermarkText('Void');
$mpdf->showWatermarkText = true;
}
- // return view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
+
// Generate the PDF content (HTML) with data
- $html = view('invoice_pdf_template', ['sales' => $data,'saleOrderCount' => $saleOrderCount,'items'=>$items,'branch'=>$branch, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
+ $html = view('invoice_pdf_template', $data);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
date_default_timezone_set('Asia/Kolkata');
// Output the PDF to the browser for download
- $mpdf->Output($data[0]->order_number .'_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+ $mpdf->Output($data['sales'][0]->order_number .'_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+ }
+
+
+ public function preview_invoice($sales_order_id)
+ {
+
+
+ // Fetch the invoice data based on $invoice_id
+ $model = new SalesOrderModel();
+ $saleOrderCount = count($model->where('status','Paid')->findAll());
+ $VehicleModel = new VehicleModel();
+ $BranchModel = new BranchModel();
+ $BusinessModel = new BusinessModel();
+ $BikemodelsModel = new BikemodelsModel();
+ $BikemakeModel = new BikemakeModel();
+ $data['sales'] = $model->getSalesPdf($sales_order_id);
+ $data['branch'] = $BranchModel->where('branch_id', $data['sales'][0]->branch_id)->first();
+ $data['vehicle'] = $VehicleModel->select('vehicle.reg_no,vehicle.colour,vehicle.email,vehicle.mobile_no,vehicle.year_of_manufacturing, make.make as make_name, model.model_name')
+ ->join('model', 'model.model_id = vehicle.model', 'left')
+ ->join('make', 'make.make_id = vehicle.make', 'left')
+ ->where('vehicle.vehicle_id', $data['sales'][0]->vehicle_id)
+ ->first();
+ $data['items'] = $model->getSalesOrderProductsForPdf($sales_order_id);
+
+
+ $html = view('invoice_pdf_template', $data);
+ return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
}
diff --git a/app/Models/SalesOrderModel.php b/app/Models/SalesOrderModel.php
index 69da91f..8c898a8 100755
--- a/app/Models/SalesOrderModel.php
+++ b/app/Models/SalesOrderModel.php
@@ -13,7 +13,7 @@ class SalesOrderModel extends Model
->join('branches as B','B.branch_id = sales_order.branch_id','left')
->select('sales_order.*')
- ->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no_1,B.contact_2 as company_mobile_no_2')
+ ->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no_1,B.contact_2 as company_mobile_no_2,B.gstno as company_gstno')
->get()
->getResult();
diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php
old mode 100755
new mode 100644
index 62130d3..af1a156
--- a/app/Views/invoice_pdf_template.php
+++ b/app/Views/invoice_pdf_template.php
@@ -1,307 +1,182 @@
-
-
-
-
-
-
-
-
-
- Tax Invoice
-
-
-
-
-
-
-
- |
- = $business['business_name'] ?>
-
-
- |
-
-
- |
- = $value->company_address ?>,
- = $value->company_city ?>,
- = $value->company_state ?>
- = $value->company_postal_code ?>.
-
-
-
- |
-
-
- |
- GSTIN:
- State Name: , Code:
- Contact : ,
- Email :
- Buyer (Bill To)
-
- |
-
-
-
-
-
-
-
- |
-
-
-
-
-
- | Invoice No. | = $initials ."/".$yearRange."/" . $saleOrderCount+1 ?> |
-
-
- | Date | = date('Y-m-d', strtotime($sales[0]->created_at)) ?> |
-
-
- | Bike Make & Model | |
-
-
- | Colour | |
-
-
- | Register Number | |
-
-
- | Contact Number | |
-
-
- | Sale Order No | = $sales[0]->order_number ?> |
-
-
- | Payment Mode | = (isset($sales[0]->mode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?> |
-
-
-
- |
-
+
+
+
+ | INVOICE |
+ |
+  |
+
+
+
+
+
+
+
+ | |
+ |
+ = $sales[0]->company_address; ?>, |
+
+
+ | |
+ |
+ = $sales[0]->company_city; ?>,= $sales[0]->company_state; ?>-= $sales[0]->company_postal_code; ?> |
+
+
+ | |
+ |
+ Mobile: = $sales[0]->company_mobile_no_1; ?> |
+
+
+ |
+ |
+ GSTIN: = $sales[0]->company_gstno; ?> |
+
+
-
-
-
-
-
- = $value->client_name ?>
- = $value->billing_address != '' ? $value->billing_address." , " : ''; ?>
- = $value->billing_city ?> = $value->billing_state." "?>
- billing_postal_code!=0): ?>
- = $value->billing_postal_code ?>
-
- = $value->mobile_no." ." ?>
-
+
+
+
+ | Bill To, |
+ |
+ |
+ |
+
+
+ | = $sales[0]->client_name; ?> |
+ Invoice Date: |
+ = date("d-m-Y", strtotime($sales[0]->created_at)); ?> |
+
+
+ | = $sales[0]->billing_address; ?>,= $sales[0]->billing_city; ?>,= $sales[0]->billing_state; ?>-= $sales[0]->billing_postal_code; ?>, |
+ |
+ Payment Mode: |
+ = $sales[0]->mode_of_payment; ?> |
+
+
+ | Mobile: = $sales[0]->mobile_no; ?> |
+ |
+ |
+ |
+
+
+
+
+
+
+
+ | Vehicle No: |
+ = $vehicle['reg_no']; ?> |
+ |
+ Model: |
+ = $vehicle['make_name']; ?> = $vehicle['model_name']; ?> |
+ |
+ Sales No: |
+ = $sales[0]->order_number; ?> |
+
+
+
+
+
+
+
+
+ | No |
+ Description |
+ Rate(₹) |
+ Qty |
+ Per |
+ GST(%) |
+ Total Tax(₹) |
+ Total(₹) |
+
+
+
+
+
+
+ $value)
+ {
+ $subTotal = $subTotal + ($value->net_price * $value->qty);
+ $tax = (($value->net_price * $value->qty) * $value->tax / 100);
+ $subTax = $subTax + $tax;
+ $grandTotal += $value->amount;
+ ?>
+
+
+ | = $key+1; ?> |
+ = $value->product_name; ?> |
+ net_price; ?> |
+ = $value->qty; ?> |
+ = $value->per; ?> |
+ = $value->tax; ?> |
+ |
+ amount, 2, '.', ''); ?> |
+
+
+
+
+
+
+
+
+
+
+
+| |
+Sub Total |
+= $subTotal; ?> |
+
+
+| |
+CGST |
+= number_format($subTax/2, 2, '.', ''); ?> |
+
+
+| |
+SGST |
+= number_format($subTax/2, 2, '.', ''); ?> |
+
+
+| |
+Total |
+= number_format($subTotal+$subTax, 2, '.', ''); ?> |
+
+
+| |
+Discount |
+0.00 |
+
+
+| |
+Grand Total |
+₹ = number_format($grandTotal, 2, '.', ''); ?> |
+
+
+
+
+
+
+
+
+ |
+ S.A Signature:
+
+ |
+ |
+
+ Customer Signature:
+
|
-
-
-
-
-
-
-
\ No newline at end of file
+
+ |
\ No newline at end of file
diff --git a/app/Views/invoice_pdf_template_jobcard.php b/app/Views/invoice_pdf_template_jobcard.php
index 51b601f..ea0e2d1 100755
--- a/app/Views/invoice_pdf_template_jobcard.php
+++ b/app/Views/invoice_pdf_template_jobcard.php
@@ -1,396 +1,181 @@
-
-
-
-
-
-
-
-Tax Invoice
-
-
-
-
-
-
-
-
- |
- THE MECHANIC
- = $value['address'] ?>,
- = 'GST: '.$value['gstno'] ?>
- = 'State: '.$value['state'].', code'.$value['state_code'] ?>
- = 'Contact: '.$value['contact_1'] ?>
- = 'Email: '.$value['email'] ?>
-
- Buyer (Bill To) - = $vehicle[0]['client_name'] ?>
- = $job_card[0]['billing_address'].', '.$job_card[0]['billing_city'].', '.$job_card[0]['billing_state'].', '.$job_card[0]['billing_country'].', '.$job_card[0]['billing_postal_code'] ?>,
- = 'GST: ' ?>
- = 'State: '.$job_card[0]['billing_state'] ?>
- = 'Place of Supply: '.$value['state'] ?>
- |
-
-
-
-
- |
-
-
-
-
-
- | Invoice No. |
- = $job_card[0]['inv_no'] ?> |
-
-
- | Vehicle No |
- = $vehicle[0]['reg_no'] ?> |
-
-
- | Model |
- = $vehicle[0]['bike_company'].' '.$vehicle[0]['bike_name'] ?> |
-
-
- | Color |
- = $vehicle[0]['colour'] ?> |
-
-
- | Contact No |
- = $vehicle[0]['mobile_no'] ?> |
-
-
- | Job Card No |
- = $vehicle[0]['order_number'] ?> |
-
-
- | Date of Receipt |
- = (new DateTime($vehicle[0]['created_at']))->format('d/m/Y') ?> |
-
-
- | Delivery Date |
- format('Y-m-d'));die;
-
- if ($dateTime && $dateTime->format('Y-m-d') == $deliveryDate) {
- echo '' . $dateTime->format('d/m/Y') . ' | ';
- } else {
- echo ' No Date Provided | ';
- }
- } else {
- echo 'No Date Provided | ';
- }
- ?>
-
-
- | Mode of Payment |
-
-
- |
-
-
-
-
- |
-
+
+
+
+ | INVOICE |
+ |
+  |
+
+
+
+
+
+
+ | = $job_card[0]['inv_no']; ?> |
+ |
+ |
+
+
+
+
+
+
+ | |
+ |
+ = $company_address[0]['address']; ?>, |
+
+
+ | |
+ |
+ = $company_address[0]['city']; ?>,= $company_address[0]['state']; ?>-= $company_address[0]['postal_code']; ?> |
+
+
+ | |
+ |
+ Mobile: = $company_address[0]['contact_1']; ?> |
+
+
+ |
+ |
+ GSTIN: = $company_address[0]['gstno']; ?> |
+
+
-
\ No newline at end of file
diff --git a/app/Views/invoice_pdf_template_old.php b/app/Views/invoice_pdf_template_old.php
new file mode 100755
index 0000000..62130d3
--- /dev/null
+++ b/app/Views/invoice_pdf_template_old.php
@@ -0,0 +1,307 @@
+
+
+
+
+
+
+
+
+
+ Tax Invoice
+
+
+
+
+
+
+
+ |
+ = $business['business_name'] ?>
+
+
+ |
+
+
+ |
+ = $value->company_address ?>,
+ = $value->company_city ?>,
+ = $value->company_state ?>
+ = $value->company_postal_code ?>.
+
+
+
+ |
+
+
+ |
+ GSTIN:
+ State Name: , Code:
+ Contact : ,
+ Email :
+ Buyer (Bill To)
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+ | Invoice No. | = $initials ."/".$yearRange."/" . $saleOrderCount+1 ?> |
+
+
+ | Date | = date('Y-m-d', strtotime($sales[0]->created_at)) ?> |
+
+
+ | Bike Make & Model | |
+
+
+ | Colour | |
+
+
+ | Register Number | |
+
+
+ | Contact Number | |
+
+
+ | Sale Order No | = $sales[0]->order_number ?> |
+
+
+ | Payment Mode | = (isset($sales[0]->mode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?> |
+
+
+
+ |
+
+
+
+
+
+
+
+ = $value->client_name ?>
+ = $value->billing_address != '' ? $value->billing_address." , " : ''; ?>
+ = $value->billing_city ?> = $value->billing_state." "?>
+ billing_postal_code!=0): ?>
+ = $value->billing_postal_code ?>
+
+ = $value->mobile_no." ." ?>
+
+
+ |
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index c2ebe21..40212d0 100755
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -635,7 +635,6 @@ $(document).ready(async function() {
'';
$('#productItemTable tbody').append(newRow);
- // $(newRow).insertAfter(tr);
initializeSelect2();
}
@@ -2112,7 +2111,7 @@ $closestTR.remove();
});
function initializeSelect2() {
$('.SelExample').select2({
- width: '249px' // Adjust width as needed
+ width: '249px'
});
}
diff --git a/app/Views/jobs_list.php b/app/Views/jobs_list.php
index 1e4e5b0..513150a 100755
--- a/app/Views/jobs_list.php
+++ b/app/Views/jobs_list.php
@@ -88,10 +88,10 @@
Preview Invoice
- " class="dropdown-item edit-button">Download Invoice
+
Preview Jobcard
- " class="dropdown-item download-button">Download Jobcard
+
" class="dropdown-item edit-button">Rework
@@ -121,7 +121,8 @@
+
\ No newline at end of file
diff --git a/public/assets/css/bootstrap-corporate.css b/public/assets/css/bootstrap-corporate.css
index c25f21b..07079f3 100755
--- a/public/assets/css/bootstrap-corporate.css
+++ b/public/assets/css/bootstrap-corporate.css
@@ -4367,9 +4367,9 @@ a.close.disabled {
.modal-header {
display: flex;
- align-items: flex-start;
+ align-items: center;
justify-content: space-between;
- padding: 1rem 1rem;
+ padding: 5px 5px;
border-bottom: 1px solid #e5e8eb;
border-top-left-radius: 0.2rem;
border-top-right-radius: 0.2rem; }
diff --git a/public/assets/images/Group.png b/public/assets/images/Group.png
new file mode 100644
index 0000000..700e069
Binary files /dev/null and b/public/assets/images/Group.png differ