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 @@
+
+ + +
@@ -49,6 +53,10 @@
+
+ + +
diff --git a/app/Views/invoice_pdf_template.php b/app/Views/invoice_pdf_template.php index 4f41616..46caa11 100644 --- a/app/Views/invoice_pdf_template.php +++ b/app/Views/invoice_pdf_template.php @@ -143,148 +143,131 @@ p { - - - - - - + + +
- THE MECHANIC - - -
-

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

- -

company_mobile_no ?>

-
+

THE MECHANIC
+ ,
+ GSTNO: '.$value['gstno'] ?>
+ State Name: '.$value['state'].', code'.$value['code'] ?>
+ Contact: '.$value['postal_code'] ?>
+ Email: '.$value['email'] ?>

+
+ Buyer (Bill To)
+

,
+ GSTNO: ' ?>
+ State Name: '.$job_card[0]['billing_state'] ?>
+ Place of Supply: '.$value['state'] ?>

+
- - - - - - - - - - - +
order_number) ? 'Order # ' . $value->order_number : 'Invoice # ' . $value->invoice_number; ?>
Date : created_at)) ?>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Invoice No.1657
Bike Name
Color
Bie Number
Contact Number
Job Card Number
Datedformat('d/m/Y') ?>
Delivery Date04/06/2024
Mode of PaymentOnline
- - - - - - - - - -
Billing Address
- - - client_name ?>
- billing_address != '' ? $value->billing_address." ,
" : ''; ?> - billing_city ?> billing_state." "?> - billing_postal_code!=0): ?> - billing_postal_code ?>
- - mobile_no." ." ?> - - -
-

- + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - -status === 'Approved'): ?> - - - - - + + + + + + + + + + + + + + + + + + + + + + +
+ + nos%
Subtotal :   ₹subtotal, 2, '.', ',') ?>
Tax :   ₹tax, 2, '.', ',') ?>
Total :   ₹total, 2, '.', ',') ?>
Paid :   ₹total_amount, 2, '.', ',') ?>
Total Taxable Value
CGST
SGST
Total
Amount Chargeable (in words)
-
- -
- - -
- - -

terms_condition;?>

- -
- - - - - - - - - + diff --git a/app/Views/jobs_list.php b/app/Views/jobs_list.php index a34d837..36a9acc 100644 --- a/app/Views/jobs_list.php +++ b/app/Views/jobs_list.php @@ -79,7 +79,7 @@ " class="edit-button"> - " class="edit-button"> + " class="edit-button"> " class="delete-button">