diff --git a/app/Controllers/Complaint.php b/app/Controllers/Complaint.php index e66f2cb..e2870a4 100644 --- a/app/Controllers/Complaint.php +++ b/app/Controllers/Complaint.php @@ -29,9 +29,18 @@ class Complaint extends BaseController { if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } try { + + $data = [ + "name" => $this->request->getPost('name'), + "labour_charge" => $this->request->getPost('labour_charge'), + "cgst" => $this->request->getPost('tax')/2, + "sgst" => $this->request->getPost('tax')/2, + "tax" => $this->request->getPost('tax') + ]; + if (!$complaint_id) { $ComplaintModel = new ComplaintModel(); - $data = $this->request->getPost(); + // $data = $this->request->getPost(); $inserted = $ComplaintModel->insert($data); if ($inserted) { $result = $data; @@ -42,7 +51,7 @@ class Complaint extends BaseController } } else { $ComplaintModel = new ComplaintModel(); - $data = $this->request->getPost(); + // $data = $this->request->getPost(); $updated = $ComplaintModel->update($complaint_id,$data); if ($updated) { $result = $data; diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php index 92c026c..16705fa 100644 --- a/app/Controllers/Service.php +++ b/app/Controllers/Service.php @@ -151,7 +151,7 @@ class Service extends BaseController 'category' => $this->request->getPost('category'), 'product_id' => json_encode($this->request->getPost('product_id')), 'cgst' => $tax, - 'igst' => $tax, + 'sgst' => $tax, 'tax' => $this->request->getPost('tax'), 'labour_cost' => $this->request->getPost('labour_cost'), 'price' => $this->request->getPost('price'), diff --git a/app/Models/ComplaintModel.php b/app/Models/ComplaintModel.php index c427d0d..ffe05d6 100644 --- a/app/Models/ComplaintModel.php +++ b/app/Models/ComplaintModel.php @@ -5,5 +5,5 @@ class ComplaintModel extends Model { protected $table = 'complaints'; protected $primaryKey = 'complaint_id'; - protected $allowedFields = ['complaint_id','name','labour_charge','isactive']; + protected $allowedFields = ['complaint_id','name','labour_charge','cgst','sgst','tax','isactive']; } \ No newline at end of file diff --git a/app/Models/ServiceModel.php b/app/Models/ServiceModel.php index ed9c9b4..9d9d86b 100644 --- a/app/Models/ServiceModel.php +++ b/app/Models/ServiceModel.php @@ -5,7 +5,7 @@ class ServiceModel extends Model { protected $table = 'services'; protected $primaryKey = 'service_id'; - protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','igst','price','tax','description','makes_id','models_id','product_id','sub_service_id','isactive']; + protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','description','makes_id','models_id','product_id','sub_service_id','isactive']; public function getTax() diff --git a/app/Models/ServicesModel.php b/app/Models/ServicesModel.php index 41f982b..e628efc 100644 --- a/app/Models/ServicesModel.php +++ b/app/Models/ServicesModel.php @@ -5,7 +5,7 @@ class ServicesModel extends Model { protected $table = 'services'; protected $primaryKey = 'service_id'; - protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','igst','purchase_cost','description','isactive']; + protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive']; } \ No newline at end of file diff --git a/app/Views/complaint_list.php b/app/Views/complaint_list.php index e4dafe6..e65474c 100644 --- a/app/Views/complaint_list.php +++ b/app/Views/complaint_list.php @@ -70,6 +70,16 @@ +
+ + +
@@ -88,6 +98,7 @@ var formData = { name: $('#name').val(), labour_charge: $('#labour_charge').val(), + tax: $('#tax').val() }; var complaint_id = $('#complaint_id').val(); if (!complaint_id) { @@ -124,6 +135,17 @@ $('#complaint_id').val(response.complaint[0].complaint_id); $('#name').val(response.complaint[0].name); $('#labour_charge').val(response.complaint[0].labour_charge); + + var tax = parseFloat(response.complaint[0].cgst) + parseFloat(response.complaint[0].sgst); + var selectElement = document.getElementById('tax'); + var options = selectElement.options; + for (var i = 0; i < options.length; i++) { + if (parseInt(options[i].value) === tax) { + options[i].selected = true; + break; + } + } + }, error: function(xhr, status, error) { // Handle error response here diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index 4e86a29..f3a7355 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -439,13 +439,11 @@ var product = services.find(function(item) { return item.service_id == productId; }); - console.log("3333333"); - console.log(product); var cgst = parseFloat(product.cgst); - var igst = parseFloat(product.igst); + var sgst = parseFloat(product.sgst); // Calculate total tax by adding CGST and SGST - var tax = cgst + igst; + var tax = cgst + sgst; $(row).find('.item-tax-service').val(tax.toFixed(2)); } diff --git a/app/Views/service_form.php b/app/Views/service_form.php index b5f7e63..c8a5f8f 100644 --- a/app/Views/service_form.php +++ b/app/Views/service_form.php @@ -99,8 +99,8 @@