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 @@
-
+
-
-
@@ -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 = `
|
-
+ |
|