From d1fe31630c5d24289ee2c775317450ae136a800c Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 28 Jan 2025 04:44:49 +0000 Subject: [PATCH] cubiccentimeter changes --- app/Controllers/Complaint.php | 24 +++++++++---- app/Models/ComplaintModel.php | 11 +++++- app/Views/complaint_list.php | 65 ++++++++++++++++++++++++++++------- 3 files changed, 80 insertions(+), 20 deletions(-) diff --git a/app/Controllers/Complaint.php b/app/Controllers/Complaint.php index cf206fc..0df4ae3 100755 --- a/app/Controllers/Complaint.php +++ b/app/Controllers/Complaint.php @@ -20,8 +20,10 @@ class Complaint extends BaseController if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } $ComplaintModel = new ComplaintModel(); $complaint = $ComplaintModel->findAll(); + $cubiccentimeter = $ComplaintModel->getCubicCentimeterName(); $data['complaint']=$complaint; + $data['cubiccentimeter']=$cubiccentimeter; return view('complaint_list',$data); } @@ -30,14 +32,21 @@ class Complaint extends BaseController if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } try { $name = $this->request->getPost('name'); + $cubic_centimeter_id = $this->request->getPost('cubic_centimeter_id'); + // echo $cubic_centimeter_id; die; $ComplaintModel = new ComplaintModel(); - if ($complaint_id>0) { - $complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1]) - ->where('complaint_id !=', $complaint_id) - ->findAll(); - } else { - $complaint = $ComplaintModel->where(['name' => $name, 'isactive' => 1])->findAll(); - } + $conditions = ['name' => $name, 'isactive' => 1]; + + if ($cubic_centimeter_id) { + $conditions['cubic_centimeter_id'] = $cubic_centimeter_id; + } + + if ($complaint_id > 0) { + $ComplaintModel->where('complaint_id !=', $complaint_id); + } + + $complaint = $ComplaintModel->where($conditions)->findAll(); + if (!empty($complaint)) { $result = "Name Already Exist"; return $this->respond(['status' => 'failed','code' => 404,'data' => $result], 200); @@ -50,6 +59,7 @@ class Complaint extends BaseController "cgst" => $this->request->getPost('tax')/2, "sgst" => $this->request->getPost('tax')/2, "tax" => $this->request->getPost('tax'), + "cubic_centimeter_id" => $this->request->getPost('cubic_centimeter_id') ? $this->request->getPost('cubic_centimeter_id') : 0, ]; if (!$complaint_id) { diff --git a/app/Models/ComplaintModel.php b/app/Models/ComplaintModel.php index 9fb8d8e..208c69d 100755 --- a/app/Models/ComplaintModel.php +++ b/app/Models/ComplaintModel.php @@ -5,5 +5,14 @@ class ComplaintModel extends Model { protected $table = 'complaints'; protected $primaryKey = 'complaint_id'; - protected $allowedFields = ['complaint_id','business_id','name','labour_charge','cgst','sgst','tax','labour_cost_with_tax','isactive']; + protected $allowedFields = ['complaint_id','business_id','name','labour_charge','cgst','sgst','tax','labour_cost_with_tax','isactive','cubic_centimeter_id']; + + public function getCubicCentimeterName() + { + return $this->db->table('cubic_centimeter') + ->select('cubic_centimeter.*') + ->where('cubic_centimeter.isactive', 1) + ->get() + ->getResultArray(); + } } \ No newline at end of file diff --git a/app/Views/complaint_list.php b/app/Views/complaint_list.php index 9d7020a..96f25de 100755 --- a/app/Views/complaint_list.php +++ b/app/Views/complaint_list.php @@ -32,9 +32,18 @@ $color = ''; if($value['isactive'] == 0){ $color ='red'; - }?> - - + } + $cubiccentimeter_name = ''; // Default to empty if no match + // Loop through $cubiccentimeter to find a match + foreach ($cubiccentimeter as $cc) { + if ($cc['id'] == $value['cubic_centimeter_id']) { + $cubiccentimeter_name = ' ( '.$cc['value'].' )'; // Get the name of the matching cubiccentimeter + break; + } + } + ?> + + @@ -81,6 +90,15 @@ +
+ + +
@@ -111,27 +129,41 @@