diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 79dd85e..310f51e 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -84,7 +84,7 @@ $routes->post("add_jobs", "Jobcard::add_jobs"); $routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1"); $routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1"); // $routes->post("delete_sales_product", "Jobcard::delete_sales_product"); -// $routes->get("download_invoice/(:any)", "Jobcard::download_invoice/$1"); +$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1"); // $routes->post("save_vehicle", "Jobcard::save_vehicle"); $routes->post("getServices", "Jobcard::getServices"); //End Job Card // diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index d695bea..41e59fa 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -70,9 +70,11 @@ class Business extends BaseController 'business_name' => $this->request->getPost('businessname'), 'email' => $this->request->getPost('email'), 'address' => $this->request->getPost('address'), + 'gstno' => $this->request->getPost('gstno'), 'mobile' => $this->request->getPost('mobile'), 'city' => $this->request->getPost('city'), 'state' => $this->request->getPost('state'), + 'code' => $this->request->getPost('code'), 'postal_code' => $this->request->getPost('postalcode'), 'country' => $this->request->getPost('country'), 'isactive' => 1 // Assuming this is a default value or handled separately diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 97e386a..3466b72 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -1,7 +1,7 @@ session = session(); $this->BikemodelsModel = new BikemodelsModel(); $this->BikemakeModel = new BikemakeModel(); + $this->BusinessModel = new BusinessModel(); + $this->JobcardModel = new JobcardModel(); } @@ -46,6 +51,51 @@ class Jobcard extends BaseController return view('jobs_list',$data); } + public function download_jobcard_invoice($job_card_id) + { + $data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id); + $bus_id = $this->session->get('logged_user_business_id'); + $data['job_card'] = $this->JobcardModel->where('job_card_id',$job_card_id)->findAll(); + $data['company_address'] = $this->BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll(); + $data['job_card_products'] = $this->JobcardModel->get_jobcard_products_details($job_card_id); + + // echo json_encode($data['job_card_products']);die; + + + // Create an mPDF object + $mpdf = new Mpdf([ + 'mode' => '', + 'format' => 'A5', + 'default_font_size' => 0, + 'default_font' => '', + + // 'margin_right' => 1, + 'margin_top' => 6, + 'margin_bottom' => 6, + 'margin_header' => 6, + 'margin_footer' =>-30, + 'orientation' => 'P', + ]); + + + + $mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true; + // Set PDF properties + $mpdf->SetTitle('Invoice'); + // $mpdf->SetAuthor($data[0]->branch_name); + $mpdf->SetCreator(''); + + + // Generate the PDF content (HTML) with data + $html = view('invoice_pdf_template', $data); + echo $html;die; + // Load HTML into the mPDF instance + $mpdf->WriteHTML($html); + + // Output the PDF to the browser for download + $mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D'); + } + public function new_jobcard($job_card_id) { @@ -474,73 +524,6 @@ class Jobcard extends BaseController return redirect()->to('job_card_index'); } - public function download_invoice($sales_order_id) - { - // echo "hello"; die; - // Fetch the invoice data based on $invoice_id - $model = new SalesOrderModel(); - $data = $model->getSalesPdf($sales_order_id); - - $items = $model->getSalesOrderProductsForPdf($sales_order_id); - - - - // print_r($items);die(); - - // print_r($invoiceItems);die(); - - // Create an mPDF object - $mpdf = new Mpdf([ - 'mode' => '', - 'format' => 'A5', - 'default_font_size' => 0, - 'default_font' => '', - - // 'margin_right' => 1, - 'margin_top' => 6, - 'margin_bottom' => 6, - 'margin_header' => 6, - 'margin_footer' =>-30, - 'orientation' => 'P', - ]); - - - - $mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true; - // Set PDF properties - $mpdf->SetTitle('Invoice'); - $mpdf->SetAuthor($data[0]->branch_name); - $mpdf->SetCreator(''); - - - - // Generate the PDF content (HTML) - if ($data[0]->status === 'Draft') { - // Set the watermark text and options - $mpdf->SetWatermarkText('Draft'); - $mpdf->showWatermarkText = true; - } - if ($data[0]->status === 'Cancelled') { - // Set the watermark text and options - $mpdf->SetWatermarkText('Cancelled'); - $mpdf->showWatermarkText = true; - } - if ($data[0]->status === 'Void') { - // Set the watermark text and options - $mpdf->SetWatermarkText('Void'); - $mpdf->showWatermarkText = true; - } - - - // Generate the PDF content (HTML) with data - $html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items]); - // echo $html;die; - // Load HTML into the mPDF instance - $mpdf->WriteHTML($html); - - // Output the PDF to the browser for download - $mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D'); - } public function save_vehicle(){ diff --git a/app/Models/BusinessModel.php b/app/Models/BusinessModel.php index a6db278..9c35a56 100644 --- a/app/Models/BusinessModel.php +++ b/app/Models/BusinessModel.php @@ -5,7 +5,7 @@ class BusinessModel extends Model { protected $table = 'business'; protected $primaryKey = 'business_id'; - protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address','city','state','postal_code','country','isactive']; + protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address', 'gstno','city','state', 'code','postal_code','country','isactive']; public function getBusinessById($business_id) { return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray(); diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php index 3f5ecb3..1a2a564 100644 --- a/app/Models/JobcardModel.php +++ b/app/Models/JobcardModel.php @@ -56,5 +56,26 @@ class JobcardModel extends Model $this ->where('job_card.branch_id',$logged_user_branch_id); return $this->findAll(); } + + public function get_jobcard_vehicle_details($job_id) + { + $this->select('job_card.job_card_id, job_card.order_number, job_card.vehicle_id as jobcard_vehicle_id, vehicle.*, make.make as bike_company, model.model_name as bike_name'); + $this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id'); + $this->join('make', 'make.make_id = vehicle.make'); + $this->join('model', 'model.model_id = vehicle.model'); + $this->where('job_card.job_card_id', $job_id); + $this->where('job_card.isactive', 1); + return $this->findAll(); + } + + public function get_jobcard_products_details($job_id) + { + $this->select('job_card_product.*, job_card_product.tax, products.product_name, products.per'); + $this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id'); + $this->join('products', 'products.product_id = job_card_product.product_id'); + $this->where('job_card_product.is_active', 1); + $this->where('job_card_product.job_card_id', $job_id); + return $this->findAll(); + } } \ No newline at end of file diff --git a/app/Views/business_form.php b/app/Views/business_form.php index 91c9bdd..db5acbd 100644 --- a/app/Views/business_form.php +++ b/app/Views/business_form.php @@ -41,6 +41,10 @@
| - THE MECHANIC - - - | -|
|
- = $value->company_address ?>, = $value->company_mobile_no ?> - |
+
+
+ THE MECHANIC + Buyer (Bill To) + = $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'] ?>, |
+
| order_number) ? 'Order # ' . $value->order_number : 'Invoice # ' . $value->invoice_number; ?> | -|
|---|---|
| Date : = date('d-m-Y', strtotime($value->created_at)) ?> | - -
| Invoice No. | +1657 | +
| Bike Name | += $vehicle[0]['bike_company'].' '.$vehicle[0]['bike_name'] ?> | +
| Color | += $vehicle[0]['colour'] ?> | +
| Bie Number | += $vehicle[0]['reg_no'] ?> | +
| Contact Number | += $vehicle[0]['mobile_no'] ?> | +
| Job Card Number | += $vehicle[0]['order_number'] ?> | +
| Dated | += (new DateTime($vehicle[0]['created_at']))->format('d/m/Y') ?> | +
| Delivery Date | +04/06/2024 | +
| Mode of Payment | +Online | +
| Billing Address | - -
|---|
|
-
-
- = $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." ." ?> - - - |
-
-
| S no | +Description Of Goods | +Taxable Value | +Quantity | +Per | +GST | +CGST Amount | +SGST Amount | +Total Tax | +Total | +
|---|---|---|---|---|---|---|---|---|---|
| S.no | -Item Name | - -MRP | -Qty | - -Total | -|||||
| - = $serialNumber++; ?> - | - -= $item->product_name ?> | -₹= number_format($item->net_price, 2, '.', ',') ?> | -= $item->qty ?> | - - - -₹= number_format($item->amount, 2, '.', ',') ?> | -
| + = $serialNumber++; ?> + | += $item['product_name'] ?> | += $item['amount'] ?> | += $item['qty'] ?> | +nos | += $item['tax'] ?>% | += ($item['amount'] * ($item['tax'] / 2) / 100) ?> | += ($item['amount'] * ($item['tax'] / 2) / 100) ?> | += ($item['amount'] * $item['tax'] / 100) ?> | += ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?> | + +
| Subtotal : ₹= number_format($value->subtotal, 2, '.', ',') ?> | -|||||||||
| Tax : ₹= number_format($value->tax, 2, '.', ',') ?> | -|||||||||
| Total : ₹= number_format($value->total, 2, '.', ',') ?> | -|||||||||
| Paid : ₹= number_format($value->total_amount, 2, '.', ',') ?> | -+ | Total Taxable Value | += $job_card[0]['tax'] ?> | + +||||||
| + | CGST | += $job_card[0]['tax'] ?> | +|||||||
| + | SGST | += $job_card[0]['tax'] ?> | +|||||||
| + | Total | += $job_card[0]['total'] ?> | +|||||||
| Amount Chargeable (in words) | +|||||||||
= $value->terms_condition;?>
- -