diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index adb1c3e..ad3825f 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -87,6 +87,7 @@ $routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
+$routes->get("download_jobcard/(:any)", "Jobcard::download_jobcard/$1");
$routes->post("getServices", "Jobcard::getServices");
//End Job Card //
diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php
index 393f0c2..c9ed40f 100644
--- a/app/Controllers/Jobcard.php
+++ b/app/Controllers/Jobcard.php
@@ -160,6 +160,55 @@ class Jobcard extends BaseController
}
+ public function download_jobcard($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->BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->where('business_id', $bus_id)->where('isactive', 1)->findAll();
+ $data['job_card_products'] = $this->JobcardModel->get_jobcard_products_details($job_card_id);
+ $data['service'] = $this->JobcardModel->get_jobcard_service($job_card_id);
+ $complaint = $this->JobcardModel->get_jobcard_complaint($job_card_id);
+ $customcomplaint = $this->JobcardModel->get_jobcard_custom_complaint($job_card_id);
+ $data['complaint'] = array_merge($complaint,$customcomplaint);
+
+
+ // 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('jobcard_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('JC_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+
+ }
+
public function new_jobcard($job_card_id)
{
diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php
index aabf995..3f63340 100644
--- a/app/Controllers/Products.php
+++ b/app/Controllers/Products.php
@@ -329,7 +329,8 @@ class Products extends BaseController
// Check if both make and model are provided
if (!empty($make) && !empty($model)) {
$data = [
- 'make' => $make
+ 'make' => $make,
+ 'business_id' => $this->session->get('logged_user_business_id'),
];
// Insert the make into the database
@@ -339,6 +340,7 @@ class Products extends BaseController
$modelData = [
'model_name' => $model,
'make_id' => $make_id,
+ 'business_id' => $this->session->get('logged_user_business_id'),
];
// Insert the model into the database
diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php
index 59f3cc1..54fd5b0 100644
--- a/app/Models/JobcardModel.php
+++ b/app/Models/JobcardModel.php
@@ -100,7 +100,7 @@ class JobcardModel extends Model
public function get_jobcard_custom_complaint($job_id)
{
- $this->select('job_card.*, job_card_custom_complaint.*, job_card_custom_complaint.name as product_name, job_card_custom_complaint.labour_cost as labour_amount');
+ $this->select('job_card.*, job_card_custom_complaint.*, job_card_custom_complaint.complaint_name as product_name, job_card_custom_complaint.labour_cost as labour_amount');
$this->join('job_card_custom_complaint', 'job_card_custom_complaint.job_card_id = job_card.job_card_id');
$this->where('job_card.isactive', 1);
$this->where('job_card.job_card_id', $job_id);
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 028473c..183eaee 100644
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -3,6 +3,9 @@
@@ -423,7 +435,7 @@ $(document).ready(async function() {
' | ' +
' | ' +
' | ' +
- ' | ' +
+ ' | ' +
' | ' +
' | ' +
'';
@@ -665,6 +677,53 @@ $(window).on('load', function() {
updateCalculations();
});
+ function updateItemAmounts(discount) {
+ var amt = 0;
+ $('.lab_amt').each(function() {
+ amt = Number($(this).val());
+ if(discount > amt) {
+ discount = discount - amt;
+ $(this).val(0).change();
+ }
+ else {
+ amt = amt - discount;
+ $(this).val(amt).change();
+ return false;
+ }
+ });
+ }
+
+ var tableData;
+ var initial = 0;
+ // Update item amounts on change of discount
+ $('#applyDiscountBtn').on('click', function() {
+
+ if($('#dt_amount').val() != '' && $('#dt_amount').val() > 0 && $('#grandtotal').val() > 0) {
+ if(initial == 0) {
+ tableData = $('#productItemTable tbody').html();;
+ initial++;
+ }
+
+ var discount = parseFloat($('#dt_amount').val());
+
+ $('#refreshDiscountBtn').prop('disabled', false);
+ $('#dt_amount').prop('disabled', true);
+ $(this).prop('disabled', true);
+ updateItemAmounts(discount);
+ }
+ });
+
+ $('#refreshDiscountBtn').prop('disabled', true);
+ $('#refreshDiscountBtn').on('click', function() {
+ $('#productItemTable tbody').empty();
+ $('#productItemTable tbody').append(tableData);
+
+ $('#refreshDiscountBtn').prop('disabled', true);
+ $('#dt_amount').val(0);
+ $('#dt_amount').prop('disabled', false);
+ $('#applyDiscountBtn').prop('disabled', false);
+ });
+
$(document).on('keyup change', '#discout_amount', function() {
amount = $(this).val();
tax = $(this).closest('tr').find('.item-tax').val();
@@ -1012,7 +1071,7 @@ $(window).on('load', function() {
' | ' +
' | ' +
' | ' +
- ' | ' +
+ ' | ' +
' | ' +
' | ' +
'';
@@ -1330,7 +1389,7 @@ $(window).on('load', function() {
' | ' +
' | ' +
' | ' +
- ' | ' +
+ ' | ' +
' | ' +
' | ' +
'';
diff --git a/app/Views/jobcard_pdf_template.php b/app/Views/jobcard_pdf_template.php
new file mode 100644
index 0000000..ef4fd00
--- /dev/null
+++ b/app/Views/jobcard_pdf_template.php
@@ -0,0 +1,332 @@
+
+
+
+
+
+
+
+
+ | DATE: = (new DateTime($vehicle[0]['created_at']))->format('d/m/Y') ?> |
+ JOB CARD |
+ JOB NO: = $vehicle[0]['order_number'] ?> |
+
+
+
+
+
+ |
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/Views/service_form.php b/app/Views/service_form.php
index c23c5f8..d0e1629 100644
--- a/app/Views/service_form.php
+++ b/app/Views/service_form.php
@@ -76,10 +76,9 @@