diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 3466b72..eaff82c 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -52,14 +52,41 @@ class Jobcard extends BaseController } 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; + $productdata = $this->JobcardModel->get_jobcard_products_details($job_card_id); + echo json_encode($productdata);die; + + $servicedata = $this->JobcardModel->get_jobcard_service($job_card_id); + $complaintdata = $this->JobcardModel->get_jobcard_complaint($job_card_id); + $labourcost = array_merge($servicedata, $complaintdata); + /** CALCULATE LABOURCOST WITH TAX */ + $totalAmount = 0; + $totalTax = 0; + + // Calculate total amount and total tax + foreach ($labourcost as $product) { + $totalAmount += $product["labour_amount"]; + $totalTax += $product["labour_amount"] * ($product["tax"] / 100); + } + + // Calculate total + $total = $totalAmount + $totalTax; + + // Create single output array + $labour_data[0] = [ + "product_name" => "Labour Cost", + "qty" => 1, + "tax" => number_format($totalTax, 2), + "custom_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; // Create an mPDF object @@ -87,7 +114,7 @@ class Jobcard extends BaseController // Generate the PDF content (HTML) with data - $html = view('invoice_pdf_template', $data); + $html = view('invoice_pdf_template_jobcard', $data); echo $html;die; // Load HTML into the mPDF instance $mpdf->WriteHTML($html); diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 70c7841..5f111ff 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -35,7 +35,7 @@ class Products extends BaseController return view('product_list',$data); } else { $ProductModel = new ProductModel(); - $products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); + $products = $ProductModel->get_products($this->session->get('logged_user_branch_id')); $data['products']=$products; $data['manufacturer_id'] = $manufacturer_id; diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php index 1a2a564..aff855a 100644 --- a/app/Models/JobcardModel.php +++ b/app/Models/JobcardModel.php @@ -70,12 +70,46 @@ class JobcardModel extends Model public function get_jobcard_products_details($job_id) { - $this->select('job_card_product.*, job_card_product.tax, products.product_name, products.per'); + $this->select('job_card_product.*, 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(); } + + public function get_jobcard_service($job_id) + { + $this->select('job_card.*, job_card_service.*, services.service_name as product_name, services.labour_cost as labour_amount'); + $this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id'); + $this->join('services', 'services.service_id = job_card_service.service_id'); + $this->where('job_card.isactive', 1); + $this->where('job_card.job_card_id', $job_id); + return $this->findAll(); + } + + public function get_jobcard_complaint($job_id) + { + $this->select('job_card.*, job_card_complaint.*, complaints.name as product_name, complaints.labour_charge as labour_amount'); + $this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id'); + $this->join('complaints', 'complaints.complaint_id = job_card_complaint.complaint_id'); + $this->where('job_card.isactive', 1); + $this->where('job_card.job_card_id', $job_id); + return $this->findAll(); + } + + public function get_jobcard_labourcost($job_id) + { + $this->select('job_card.*, job_card_service.job_card_id, job_card_service.service_id, job_card_complaint.job_card_id, job_card_complaint.complaint_id, services.labour_cost, complaints.labour_charge,services.tax ,complaints.tax, services.labour_cost, complaints.labour_charge'); + $this->join('job_card_service', 'job_card_service.job_card_id = job_card.job_card_id'); + $this->join('services', 'services.service_id = job_card_service.service_id'); + $this->join('job_card_complaint', 'job_card_complaint.job_card_id = job_card.job_card_id'); + $this->join('complaints', 'complaints.complaint_id = job_card_complaint.complaint_id'); + $this->where('job_card.isactive', 1); + $this->where('job_card.job_card_id', $job_id); + return $this->findAll(); + } + + } \ No newline at end of file diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index c672b12..e73a393 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -28,5 +28,14 @@ class ProductModel extends Model } } + public function get_products($branch_id) + { + $this->select('products.*, manufacturer.manufacturer_name'); + $this->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id'); + $this->where('products.branch_id', $branch_id); + return $this->findAll(); + } + + } ?> \ 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 46caa11..0c0130f 100644 --- a/app/Views/invoice_pdf_template_jobcard.php +++ b/app/Views/invoice_pdf_template_jobcard.php @@ -230,30 +230,30 @@ p { - + nos % - - - - + + + + Total Taxable Value - + CGST - + SGST - + diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index d3b1abf..5e6c3a3 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -417,7 +417,7 @@ $(document).ready(async function() { '' + '' + '' + - '' + + '' + '' + '' + ''; @@ -799,7 +799,7 @@ $(document).ready(async function() { '' + '' + '' + - '' + + '' + '' + '' + ''; @@ -1037,7 +1037,7 @@ $(document).ready(async function() { '' + '' + '' + - '' + + '' + '' + '' + ''; diff --git a/app/Views/product_list.php b/app/Views/product_list.php index ec9af96..42e8a75 100644 --- a/app/Views/product_list.php +++ b/app/Views/product_list.php @@ -25,13 +25,14 @@ - + @@ -47,8 +48,8 @@ + - @@ -75,4 +76,53 @@ - \ No newline at end of file + + + \ No newline at end of file
SKU Id Product NameManufacturer Name Category Unit Price Qty in Stock