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

- - - - - +
- - - - - - - - - - - - - - - - - -
- - - -
-

company_address ?>,
- company_city ?>, - company_state ?> - company_postal_code ?>.
- - -

-
-
GSTIN:
- State Name: , Code:
- Contact : ,
- Email :

- Buyer (Bill To) -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Invoice No.
Datecreated_at)) ?>
Bike Make & Model
Colour
Register Number
Contact Number
Sale Order No order_number ?>
Payment Modemode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?>
-
+ + + + + + + +
INVOICE 
+ + + + + + + + +
  
+ + + + + + + + + + + + + + + + + + + + + + +
  company_address; ?>,
  company_city; ?>,company_state; ?>-company_postal_code; ?>
  Mobile: company_mobile_no_1; ?>
 GSTIN: company_gstno; ?>
- - - +
- - - client_name ?>
- billing_address != '' ? $value->billing_address." ,
" : ''; ?> - billing_city ?> billing_state." "?> - billing_postal_code!=0): ?> - billing_postal_code ?>
- - mobile_no." ." ?> - + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bill To,   
client_name; ?>   Invoice Date:created_at)); ?>
billing_address; ?>,billing_city; ?>,billing_state; ?>-billing_postal_code; ?>, Payment Mode:mode_of_payment; ?>
Mobile: mobile_no; ?>   
+

 

+ + + + + + + + + + + + + +
 Vehicle No: Model:  Sales No:order_number; ?>
+

 

+ + + + + + + + + + + + + + + + + + + $value) + { + $subTotal = $subTotal + ($value->net_price * $value->qty); + $tax = (($value->net_price * $value->qty) * $value->tax / 100); + $subTax = $subTax + $tax; + $grandTotal += $value->amount; + ?> + + + + + + + + + + + + + + + + +
NoDescriptionRate(₹)QtyPerGST(%)Total Tax(₹)Total(₹)
product_name; ?> net_price; ?>qty; ?>per; ?>tax; ?> amount, 2, '.', ''); ?>
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Sub Total
 CGST
 SGST
 Total
 Discount0.00
 Grand Total₹ 
+

 

+

 

+ + + + + + -
+

  S.A Signature:

+

 

+
  +

  Customer Signature:

+

 



- - - - - - - - - - - - - - - - - - - - - net_price * $item->qty; - $total_taxable_amount += $taxable_amount; - $cgst = ($taxable_amount * $item->tax / 100 ) /2; - $sgst = ($taxable_amount * $item->tax / 100 ) /2; - - $total_CGST += $cgst; - $total_SGST += $sgst; - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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
- ,
- GST: '.$value['gstno'] ?>
- State: '.$value['state'].', code'.$value['state_code'] ?>
- Contact: '.$value['contact_1'] ?>
- Email: '.$value['email'] ?>

-
- Buyer (Bill To) -
-

,
- GST: ' ?>
- State: '.$job_card[0]['billing_state'] ?>
- Place of Supply: '.$value['state'] ?>

-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - format('Y-m-d'));die; - - if ($dateTime && $dateTime->format('Y-m-d') == $deliveryDate) { - echo ''; - } else { - echo ''; - } - } else { - echo ''; - } - ?> - - - - - - -
Invoice No.
Vehicle No
Model
Color
Contact No
Job Card No
Date of Receiptformat('d/m/Y') ?>
Delivery Date' . $dateTime->format('d/m/Y') . ' No Date ProvidedNo Date Provided
Mode of Payment - -
-
-
+ + + + + + + +
INVOICE 
+ + + + + + + + +
  
+ + + + + + + + + + + + + + + + + + + + + + +
  ,
  ,-
  Mobile:
 GSTIN:
- - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + +
Bill To,   
   Invoice Date:
,,-, Payment Mode:
Mobile:    
+

 

+ + + + + + + + + + + + + +
 Vehicle No: Model:  Job Card No:
+

 

+ + - - - + + + + + + + + + - $cgst = ($taxable_amount * $custum_tax / 100 ) /2; - $sgst = ($taxable_amount * $custum_tax / 100 ) /2; - - - }else{ - $taxable_amount = $item['amount'] * $item['qty']; - $custum_tax = (int)$item['tax']; + - $cgst = ($taxable_amount * $custum_tax / 100 ) /2; - $sgst = ($taxable_amount * $custum_tax / 100 ) /2; - } - $total_CGST += $cgst; - $total_SGST += $sgst; - ?> - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
NoDescriptionRate(₹)QtyPerGST(%)Total Tax(₹)Total(₹)
- - + + $value) + { + $subTotal = $subTotal + $value['amount']; + $tax = ($value['amount'] * $value['tax'] / 100); + $subTax = $subTax + $tax; + ?> - $custom_amount = floatval($custom_amount); - - echo $custom_amount * $item['qty']; - - $sub_tot += $custom_amount * $item['qty']; - } - else - { - echo ($item['amount']) * $item['qty']; - $sub_tot += ($item['amount']) * $item['qty']; - } ?>% - - -
Sub Total
 
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Sub Total
 CGST
 SGST
 Total
 Discount0.00
 Grand Total₹ 
+

 

+

 

+ + - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - -
CGST
SGST
Estimate
Discount
Amount Chargeable (in words): - format(round($sub_tot + $tax)); - echo ucfirst($words); - ?> + +

  S.A Signature:

+

 

+
  +

  Customer Signature:

+

 

Declaration:
We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.

**This is computer generated bill and doesn’t require signature

for THE MECHANIC




Authorised Signatory
- - - - - - + \ 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

+ + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + +
+

company_address ?>,
+ company_city ?>, + company_state ?> + company_postal_code ?>.
+ + +

+
+
GSTIN:
+ State Name: , Code:
+ Contact : ,
+ Email :

+ Buyer (Bill To) +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.
Datecreated_at)) ?>
Bike Make & Model
Colour
Register Number
Contact Number
Sale Order No order_number ?>
Payment Modemode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?>
+
+ + + + +
+ + + client_name ?>
+ billing_address != '' ? $value->billing_address." ,
" : ''; ?> + billing_city ?> billing_state." "?> + billing_postal_code!=0): ?> + billing_postal_code ?>
+ + mobile_no." ." ?> + + +


+ + + + + + + + + + + + + + + + + + + + + net_price * $item->qty; + $total_taxable_amount += $taxable_amount; + $cgst = ($taxable_amount * $item->tax / 100 ) /2; + $sgst = ($taxable_amount * $item->tax / 100 ) /2; + + $total_CGST += $cgst; + $total_SGST += $sgst; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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