diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1aedcc5..6cb9828 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -89,6 +89,7 @@ $routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoi // $routes->post("save_vehicle", "Jobcard::save_vehicle"); $routes->get("download_jobcard/(:any)", "Jobcard::download_jobcard/$1"); $routes->get("download_os", "Jobcard::download_os"); +$routes->get("individual_download_os/(:any)", "Jobcard::individual_download_os/$1"); $routes->post("getServices", "Jobcard::getServices"); //End Job Card // diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 9d39914..90b2f7b 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -30,6 +30,7 @@ class Jobcard extends BaseController public $BikemakeModel; public $BusinessModel; public $JobcardModel; + public $JobcardOSModel; public $BranchModel; public function __construct() { @@ -39,6 +40,7 @@ class Jobcard extends BaseController $this->BikemakeModel = new BikemakeModel(); $this->BusinessModel = new BusinessModel(); $this->JobcardModel = new JobcardModel(); + $this->JobcardOSModel = new JobcardOSModel(); $this->BranchModel = new BranchModel(); } @@ -52,6 +54,8 @@ class Jobcard extends BaseController $jobs=$JobcardModel->getJobCardsWithProductsAndService($this->session->get('logged_user_branch_id'), $data); $data['jobs']=$jobs; $data['logged_user_role'] = $this->session->get('logged_user_role'); + // echo "
";
+ // print_r($data);die;
return view('jobs_list',$data);
}
@@ -79,6 +83,7 @@ class Jobcard extends BaseController
public function download_jobcard_invoice($job_card_id)
{
$data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id);
+ // print_r($data['vehicle']);die;
$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();
@@ -116,7 +121,7 @@ class Jobcard extends BaseController
$discount = ($data['job_card'][0]['is_rework'] == 1) ? 0 : $data['job_card'][0]['discount'] ;
$amt_with_tax = $totalAmount + ($totalAmount * $totalTax / 100);
- $totalAmount = ($amt_with_tax - $discount) / (1 + ($totalTax/100));
+ $totalAmount = ($amt_with_tax - (float)$discount) / (1 + ($totalTax/100));
// Create single output array
$labour_data[0] = [
"product_name" => "Labour Cost",
@@ -219,54 +224,166 @@ class Jobcard extends BaseController
$JobcardProductModel = new JobcardProductModel();
$outsource = $this->JobcardModel->download_os($this->session->get('logged_user_branch_id'));
- foreach ($outsource as &$value) {
- $products = [];
- $product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
- $product = $JobcardProductModel->select('job_card_product.job_card_product_id,job_card_product.product_id,job_card_product.qty,products.product_name as pname')
- ->join('products', 'products.product_id = job_card_product.product_id')
- ->whereIn('job_card_product.job_card_product_id', $product_ids)->find();
-
- foreach ($product as $pr_value) {
- array_push($products,$pr_value);
+ if (count($outsource) > 0) {
+
+ foreach ($outsource as &$value) {
+ $products = [];
+ $product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
+ $product = $JobcardProductModel->select('job_card_product.job_card_product_id,job_card_product.product_id,job_card_product.qty,products.product_name as pname')
+ ->join('products', 'products.product_id = job_card_product.product_id')
+ ->whereIn('job_card_product.job_card_product_id', $product_ids)->find();
+
+ foreach ($product as $pr_value) {
+ array_push($products,$pr_value);
+ }
+ $value['products'] = $products;
+ }
+
+ $groupedJobs = [];
+
+ // Iterate over each job
+ foreach ($outsource as $job) {
+ $jobCardId = $job['job_card_id'];
+
+ // Check if the job_card_id already exists in $groupedJobs
+ if (!isset($groupedJobs[$jobCardId])) {
+ // If not, initialize an array for that job_card_id with all details except 'name'
+ $groupedJobs[$jobCardId] = $job;
+ // Remove the 'name' key and initialize 'names' array
+ unset($groupedJobs[$jobCardId]['name']);
+ $groupedJobs[$jobCardId]['names'] = [];
}
- $value['products'] = $products;
+ // Add the name to the 'names' array
+ $groupedJobs[$jobCardId]['names'][] = $job['name'];
+ }
+
+ usort($groupedJobs, function($a, $b) {
+ return strtotime($a['delivery_date']) - strtotime($b['delivery_date']);
+ });
+
+
+ $data['outsource'] = $groupedJobs;
+
+ // 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('');
+
+ // echo "";
+ // print_r($data);die;
+ // Generate the PDF content (HTML) with data
+ $html = view('outsourcing_template', $data);
+ // echo $html;die;
+ // Load HTML into the mPDF instance
+ $mpdf->WriteHTML($html);
+
+ // Output the PDF to the browser for download
+ $mpdf->Output('OS_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+
+ }else{
+ return redirect()->with('download_os', 'No Out Source')->back();
}
- $data['outsource'] = $outsource;
+ }
- // 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',
- ]);
+ public function individual_download_os($job_card_id){
+ $JobcardProductModel = new JobcardProductModel();
+ $outsource = $this->JobcardOSModel->individual_download_os($job_card_id);
-
-
- $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('outsourcing_template', $data);
- // echo $html;die;
- // Load HTML into the mPDF instance
- $mpdf->WriteHTML($html);
-
- // Output the PDF to the browser for download
- $mpdf->Output('OS_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+ if (count($outsource) > 0) {
+
+ foreach ($outsource as &$value) {
+ $products = [];
+ $product_ids = !empty(json_decode($value['product_id'], true)) ? json_decode($value['product_id'], true) : [0];
+ $product = $JobcardProductModel->select('job_card_product.job_card_product_id,job_card_product.product_id,job_card_product.qty,products.product_name as pname')
+ ->join('products', 'products.product_id = job_card_product.product_id')
+ ->whereIn('job_card_product.job_card_product_id', $product_ids)->find();
+
+ foreach ($product as $pr_value) {
+ array_push($products,$pr_value);
+ }
+ $value['products'] = $products;
+ }
+
+ $groupedJobs = [];
+
+ // Iterate over each job
+ foreach ($outsource as $job) {
+ $jobCardId = $job['job_card_id'];
+
+ // Check if the job_card_id already exists in $groupedJobs
+ if (!isset($groupedJobs[$jobCardId])) {
+ // If not, initialize an array for that job_card_id with all details except 'name'
+ $groupedJobs[$jobCardId] = $job;
+ // Remove the 'name' key and initialize 'names' array
+ unset($groupedJobs[$jobCardId]['name']);
+ $groupedJobs[$jobCardId]['names'] = [];
+ }
+ // Add the name to the 'names' array
+ $groupedJobs[$jobCardId]['names'][] = $job['name'];
+ }
+
+ usort($groupedJobs, function($a, $b) {
+ return strtotime($a['delivery_date']) - strtotime($b['delivery_date']);
+ });
+
+
+ $data['outsource'] = $groupedJobs;
+
+ // 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('');
+
+ // echo "";
+ // print_r($data);die;
+ // Generate the PDF content (HTML) with data
+ $html = view('outsourcing_template', $data);
+ // echo $html;die;
+ // Load HTML into the mPDF instance
+ $mpdf->WriteHTML($html);
+
+ // Output the PDF to the browser for download
+ $mpdf->Output('OS_' . date('Y-m-d H-i-s') . '.pdf', 'D');
+ }else{
+ return redirect()->with('msg', 'failed')->back();
+ }
}
diff --git a/app/Controllers/Model.php b/app/Controllers/Model.php
index 39c629f..6f7b03f 100644
--- a/app/Controllers/Model.php
+++ b/app/Controllers/Model.php
@@ -74,6 +74,7 @@ class Model extends BaseController
if (!$model_id) {
try {
+ $data['business_id'] = $this->session->get('logged_user_business_id');
$inserted = $BikemodelsModel->insert($data);
} catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
diff --git a/app/Models/JobcardModel.php b/app/Models/JobcardModel.php
index a4f8379..e23223b 100644
--- a/app/Models/JobcardModel.php
+++ b/app/Models/JobcardModel.php
@@ -15,8 +15,9 @@ class JobcardModel extends Model
public function getJobCardsWithProductsAndService($logged_user_branch_id,$data)
{
- $this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count, vehicle.reg_no');
+ $this->select('job_card.*, COUNT(job_card_product.job_card_id) AS product_count,COUNT(job_card_os.job_card_id) AS os_count, vehicle.reg_no');
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id', 'left');
+ $this->join('job_card_os', 'job_card_os.job_card_id = job_card.job_card_id', 'left');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
$this->groupBy('job_card.job_card_id');
$this->where('job_card.isactive', 1);
@@ -149,7 +150,7 @@ class JobcardModel extends Model
job_card_os.job_card_id,job_card_os.os_id,job_card_os.product_id,
out_source.name,
vehicle.reg_no, vehicle.make, vehicle.colour,vehicle.model,
- make.make as bike_name, model.model_name as bike_modal_name'
+ make.make as bike_name, model.model_name as bike_modal_name,job_card.delivery_date'
);
// $this->from('job_card');
$this->join('job_card_os', 'job_card_os.job_card_id = job_card.job_card_id');
@@ -166,6 +167,8 @@ class JobcardModel extends Model
return $this->findAll();
}
+
+
}
\ No newline at end of file
diff --git a/app/Models/jobcardOSModel.php b/app/Models/jobcardOSModel.php
index a8e7773..0edcdc5 100644
--- a/app/Models/jobcardOSModel.php
+++ b/app/Models/jobcardOSModel.php
@@ -6,4 +6,27 @@ class JobcardOSModel extends Model
protected $table = 'job_card_os';
protected $primaryKey = 'job_card_os_id';
protected $allowedFields = ['job_card_os_id','job_card_id','os_id', 'labour_cost','product_id', 'qty', 'tax', 'amount','isactive'];
+
+ public function individual_download_os($job_card_id)
+ {
+ $this->select('
+ job_card.job_card_id, job_card.created_at, job_card.branch_id, job_card.isactive, job_card.vehicle_id,
+ job_card_os.job_card_id AS job_card_os_job_card_id, job_card_os.os_id, job_card_os.product_id,
+ out_source.name,
+ vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model,
+ make.make AS bike_name, model.model_name AS bike_modal_name, job_card.delivery_date
+ ');
+ $this->join('job_card', 'job_card.job_card_id = job_card_os.job_card_id');
+ $this->join('out_source', 'out_source.id = job_card_os.os_id', 'left');
+ $this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
+ $this->join('make', 'make.make_id = vehicle.make', 'left');
+ $this->join('model', 'model.model_id = vehicle.model', 'left');
+ $this->where('job_card_os.job_card_id', $job_card_id);
+ $this->where('job_card_os.is_active', 1);
+ $this->orderBy('job_card.job_card_id', 'DESC');
+
+ return $this->findAll();
+ }
+
+
}
\ No newline at end of file
diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php
index 465f1ac..b534914 100644
--- a/app/Views/bike_model_list.php
+++ b/app/Views/bike_model_list.php
@@ -41,13 +41,19 @@
-
-
-
-
-
-
-
+
+
@@ -120,25 +126,27 @@
$('tbody').html('');
- $.each(response.model_list, function(index, item) {
+ response.model_list.forEach(function(item) {
var row = '' +
- '' + item.model_name + ' ' +
+ '' + item.model_name + ' ' +
'';
- if (item.isactive == 1) {
- row += 'Active';
- } else if (item.isactive == 0) {
- row += 'Inactive';
- }
-
- row += ' ';
-
- row += '';
- // Check the isactive status and set the icon color accordingly
if (item.isactive == 1) {
- row += '';
+ row += 'Active';
} else if (item.isactive == 0) {
- row += '';
+ row += 'Inactive';
+ }
+
+ row += ' ' +
+ ' ';
@@ -147,7 +155,7 @@
$('tbody').append(row);
});
}
- window.location.reload();
+ // window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
@@ -180,10 +188,10 @@
if (response.status == "success") {
$('tbody').html('');
- $.each(response.data, function(index, item) {
+ response.data.forEach(function(item) {
var row = '' +
- '' + item.model_name + ' ' +
- '';
+ ' ' + item.model_name + ' ' +
+ '';
if (item.isactive == 1) {
row += 'Active';
@@ -191,21 +199,23 @@
row += 'Inactive';
}
- row += ' ';
+ row += ' ' +
+ ' ';
- row += ' ';
-
- // Append the row to the tbody
- $('tbody').append(row);
- });
+ // Append the row to the tbody
+ $('tbody').append(row);
+ });
}
},
error: function(xhr, status, error) {
diff --git a/app/Views/client_list.php b/app/Views/client_list.php
index f32b96f..21dcb8a 100644
--- a/app/Views/client_list.php
+++ b/app/Views/client_list.php
@@ -40,8 +40,15 @@
= $value['mobile_no']; ?>
= $value['email']; ?>
- " class="edit-button">
- " class="delete-button">
+
+
+
diff --git a/app/Views/complaint_list.php b/app/Views/complaint_list.php
index e3d35d0..c7ceb47 100644
--- a/app/Views/complaint_list.php
+++ b/app/Views/complaint_list.php
@@ -43,8 +43,14 @@
-
- " class="delete-button">
+
+
diff --git a/app/Views/invoice_pdf_template_jobcard.php b/app/Views/invoice_pdf_template_jobcard.php
index 425ba37..23515ed 100644
--- a/app/Views/invoice_pdf_template_jobcard.php
+++ b/app/Views/invoice_pdf_template_jobcard.php
@@ -250,8 +250,13 @@ p {
-
+
+
+
+
+
diff --git a/app/Views/jobs_list.php b/app/Views/jobs_list.php
index 46a3cf0..6d3bcec 100644
--- a/app/Views/jobs_list.php
+++ b/app/Views/jobs_list.php
@@ -1,4 +1,6 @@
+
+
+
+
+
@@ -63,7 +71,15 @@
= $value['reg_no']; ?>
= $value['client_name']; ?>
= $value['client_mobile_no']; ?>
= $value['total']; ?>
- = ($value['is_rework'] == 1) ? 'Rework/'.$value['status'] :$value['status']; ?>
+ = ($value['is_rework'] == 1) ? 'Rework/'.$value['status'] :$value['status']; ?>
@@ -79,6 +95,10 @@
" class="dropdown-item edit-button">Rework
+
+ 0) { ?>
+ " class="dropdown-item edit-button">Out Source
+
@@ -142,4 +162,16 @@
"ordering": false
});
});
-
\ No newline at end of file
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/make_list.php b/app/Views/make_list.php
index 653a336..ea59e4d 100644
--- a/app/Views/make_list.php
+++ b/app/Views/make_list.php
@@ -42,19 +42,24 @@
-
+
@@ -290,10 +295,11 @@
if (response.status == "success") {
$('tbody').html('');
- $.each(response.data, function(index, item) {
+ // Assuming `items` is an array containing your data
+ response.data.forEach(function(item) {
var row = '' +
- '' + item.make + ' ' +
- '';
+ ' ' + item.make + ' ' +
+ '';
if (item.isactive == 1) {
row += 'Active';
@@ -301,24 +307,26 @@
row += 'Inactive';
}
- row += ' ';
+ row += ' ' +
+ ' ';
+ row += '';
// Append the row to the tbody
$('tbody').append(row);
});
+
}
},
error: function(xhr, status, error) {
diff --git a/app/Views/manufacturer_list.php b/app/Views/manufacturer_list.php
index b8069f2..814e098 100644
--- a/app/Views/manufacturer_list.php
+++ b/app/Views/manufacturer_list.php
@@ -34,11 +34,17 @@
-
+
- " class="view-list-button" title="Model List" style="margin-left: 16px;">
-
-
+
diff --git a/app/Views/outsourcing_list.php b/app/Views/outsourcing_list.php
index 29d8c08..526c9a8 100644
--- a/app/Views/outsourcing_list.php
+++ b/app/Views/outsourcing_list.php
@@ -42,8 +42,13 @@
-
- " class="delete-button">
+
diff --git a/app/Views/outsourcing_template.php b/app/Views/outsourcing_template.php
index 9f3332b..912bf7c 100644
--- a/app/Views/outsourcing_template.php
+++ b/app/Views/outsourcing_template.php
@@ -3,6 +3,8 @@