diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index e5c7f96..864987b 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -54,6 +54,27 @@ class Jobcard extends BaseController return view('jobs_list',$data); } + public function getCurrentFinancialYear() { + // Get the current month and year + $currentMonth = date('n'); + $currentYear = date('Y'); + + // Determine the start date of the financial year + if ($currentMonth >= 4) { + $startYear = $currentYear; + } else { + $startYear = $currentYear - 1; + } + + // Determine the end date of the financial year + $endYear = $startYear + 1; + + // Format the financial year string + $financialYear = $startYear . '/' . substr($endYear, -2); + + return $financialYear; + } + public function download_jobcard_invoice($job_card_id) { $data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id); @@ -67,9 +88,10 @@ class Jobcard extends BaseController if($data['job_card'][0]['inv_no'] == '') { /** GENERATE INV NO */ - $uniqueId = sprintf('%06d', mt_rand(0, 999999)); - $date = date('Ymdhms'); - $invoiceNumber = 'INV' . '-' . $date . $uniqueId; + $count = $this->JobcardModel->where('status', 'Paid')->countAllResults(); + $formattedCount = str_pad($count+1, 5, '0', STR_PAD_LEFT); + $currentFinancialYear = $this->getCurrentFinancialYear(); + $invoiceNumber = 'MECH-' . $currentFinancialYear. '/' . $formattedCount; $this->JobcardModel->update($job_card_id,['inv_no' => $invoiceNumber]); $data['job_card'][0]['inv_no'] = $invoiceNumber; } @@ -130,7 +152,7 @@ class Jobcard extends BaseController // Generate the PDF content (HTML) with data $html = view('invoice_pdf_template_jobcard', $data); -echo $html;die; +// echo $html;die; // Load HTML into the mPDF instance $mpdf->WriteHTML($html); diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 544a93c..fe841cd 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -424,7 +424,7 @@ public function delete_sales_product() $vehicleData = $VehicleModel->where('vehicle_id',$id)->first(); // If insertion succeeds, return success response - return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.','vehicleData'=>$vehicleData]); + return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.','vehicleData'=>$vehicleData, 'vehicle_id' => $id]); } else { // If insertion fails, return error response return $this->response->setJSON(['success' => false, 'message' => 'Failed to save client.']); diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index a0daa28..f386c03 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -72,8 +72,8 @@
- - + +
@@ -176,21 +176,12 @@
- +
-

Terms & Condition :


-
-
- - -
-
@@ -267,7 +258,7 @@
- +
@@ -429,7 +420,7 @@ $(document).ready(async function() { function editlabourcost(data,cls) { total_wih_tax = parseInt(data.labour_cost) + (parseInt(data.labour_cost) * (data.tax / 100)); total_tax_amt = total_wih_tax - parseInt(data.labour_cost); - var newRow = '' + + var newRow = '' + '' + '' + '' + @@ -452,7 +443,7 @@ $(document).ready(async function() { console.log(total_wih_tax); total_tax_amt = total_wih_tax - ( parseInt(product.amount) * product.qty); var newRow = ` - + ' + '' + @@ -1051,11 +1071,21 @@ $(document).ready(async function() { productarray = ; console.log(productarray); } - var newRow = '' + @@ -1077,14 +1107,27 @@ $(document).ready(async function() { $('#addService').click(function() { if ($('#vehicle_name').val()) { - servicearray = ; - // console.log(servicearray); + + selected_pr = []; + $('tr.service_class').each(function() { + var rowProductid = $(this).find('.service').val(); + selected_pr.push(rowProductid); + }); + + if(servicearray.length == 0) + { + servicearray = ; + } + console.log(servicearray); var newRow = ' ' + @@ -1120,13 +1163,22 @@ $(document).ready(async function() { }); $('#addcomplaint').click(function() { + selected_pr = []; + $('tr.complaint_class').each(function() { + var rowProductid = $(this).find('.complaint').val(); + selected_pr.push(rowProductid); + }); + complaint = ; var newRow = ' ' + @@ -1166,12 +1218,12 @@ $(document).ready(async function() { $('#addCustomComplaint').click(function() { complaint = ; - var newRow = ' ' + + var newRow = ' ' + '' + '' + '' + '' + - '' + + '' + '' + '' + '
'+ @@ -1193,7 +1245,7 @@ $(document).ready(async function() { '' + '' + '' + - '' + + '' + '' + '' + ''; @@ -1431,8 +1483,21 @@ $(document).ready(async function() { var ifStatementCondition = "createclientName !== '' && createclientMobile !== '' && createclientType !== '' && reg_no !== '' && model !== '' && make !== ''"; } + if(createclientMobile) { + var clientArray = ; + console.log(clientArray); + var mobileIdExists = clientArray.some(function(client) { + return client.mobile_no.trim() === createclientMobile.trim(); + }); + + if(mobileIdExists) { + toastr.warning("Mobile Number Already Added!"); + return; + } + } if (reg_no) { + $('#saveVehcileBtn').prop('disabled', true); $.ajax({ url: '', // URL to your controller method for fetching models type: 'POST', @@ -1442,6 +1507,7 @@ $(document).ready(async function() { if (response) { $('#reg_no').val(""); toastr.warning("Register Number Already Added!"); + $('#saveVehcileBtn').prop('disabled', false); }else{ if( eval(ifStatementCondition) ){ @@ -1465,20 +1531,24 @@ $(document).ready(async function() { if (response.success) { $('#addVehicleModal').modal('hide'); toastr.success("Vehicle saved successfully!"); + localStorage.setItem('vehicle_id',response.vehicle_id) window.location.reload(); } else { toastr.warning("Failed to save vehicle. Please try again"); + $('#saveVehcileBtn').prop('disabled', false); } }, error: function(xhr, status, error) { console.error('Error occurred while saving vehicle:', error); toastr.warning("Failed to save vehicle. Please try again"); + $('#saveVehcileBtn').prop('disabled', false); } }); }else{ toastr.warning("Please Fill All Data"); + $('#saveVehcileBtn').prop('disabled', false); } } @@ -1499,6 +1569,7 @@ $(document).ready(async function() { }); }); +