diff --git a/app/controllers/API/Complaints.php b/app/controllers/API/Complaints.php index 27858400..044cef10 100644 --- a/app/controllers/API/Complaints.php +++ b/app/controllers/API/Complaints.php @@ -29,4 +29,16 @@ public function resolveComplaint(string $a = ''): void $response = new JSONResponse; $response->statusCode(200)->success(true)->data(['complaint_id' => $a])->send(); } + + public function cancelCustomerComplaint(string $a = '', string $b = '', string $c = ''): void + { + + $complaint = new RentComplaintModel; + $complaint->cancelComplaint($a); + + $response = new JSONResponse; + $response->statusCode(200)->data(['complaint_id' => $a])->send(); + } + + } diff --git a/app/controllers/Complaints.php b/app/controllers/Complaints.php index a1bb3afc..862f9f57 100644 --- a/app/controllers/Complaints.php +++ b/app/controllers/Complaints.php @@ -110,7 +110,7 @@ public function rentComplaints(string $a = '', string $b = '', string $c = ''):v $rentcomplaint = new RentComplaintModel; $data = ['customer_id' => UserMiddleware::getUser()['id']]; $data['complaints'] = $rentcomplaint->getComplaintsByCustomer($data); - show ($data['complaints']); + // show ($data['complaints']); $this->view('customer/components/customercomplaintlist', $data); } @@ -122,7 +122,7 @@ public function rentComplaint(string $a = '', string $b = '', string $c = ''):vo $rent = new RentModel; $data['rentitems'] = $rent->getItemListbyRentId($data['complaint']->rent_id); - show($data); + // show($data); $this->view('customer/components/customercomplaints', $data); } diff --git a/app/controllers/_404.php b/app/controllers/_404.php index 58500916..24f88077 100755 --- a/app/controllers/_404.php +++ b/app/controllers/_404.php @@ -5,7 +5,7 @@ class _404{ public function index(){ http_response_code(404); - echo "Controller not found"; + $this->view('404'); } } diff --git a/app/models/RentComplaint.php b/app/models/RentComplaint.php index efd2b2b0..574f10a0 100644 --- a/app/models/RentComplaint.php +++ b/app/models/RentComplaint.php @@ -3,12 +3,14 @@ class RentComplaintModel { use Model; - protected string $table = 'rent_return_complaints'; + protected string $table = 'rent_complaint'; protected array $allowedColumns = [ 'rent_id', + 'complaint_no', 'title', 'description', + 'created_at', 'status' ]; @@ -30,36 +32,44 @@ public function resolveComplaint($id) //$table $this->update($id, ['status' => 'resolved']); } - public function getComplaints(array $data) - { + public function getComplaints(array $data) { return $this->where($data); } - public function getComplaintsByCustomer(array $data) - { + public function getComplaintsByCustomer(array $data) { $q = new QueryBuilder; $q->setTable('rent_complaint'); $q->select('rent.customer_id as customer_id, rent.id as rent_id, complaint_no as complaint_no, rent_complaint.status as status, rent_complaint.description as description, rent_complaint.created_at as created_at') - ->join('rent', 'rent_complaint.rent_id', 'rent.id') - ->where('rent.customer_id', $data['customer_id']); + ->join('rent', 'rent_complaint.rent_id','rent.id') + ->where('rent.customer_id', $data['customer_id']) + ->orderBy('rent_complaint.created_at', 'DESC'); return $this->query($q->getQuery(), $q->getData()); } - - public function getRentComplaint($id) - { + + public function getRentComplaint($id) { $q = new QueryBuilder; $q->setTable('rent_complaint'); $q->select('rent_complaint.complaint_no as complaint_no, rent.id as rent_id,rent.created_at as rent_date, rent.customer_id as customer_id, rent.paid_amount as paid_amount, rent.created_at as paid_date, rent.start_date as start_date, rent.end_date as end_date, - rent.status as rent_status, rent.total as total_amount,rental_services.id as rental_id, rental_services.name as rental_name, rental_services.mobile as rental_mobile, - rent_complaint.title as title, rent_complaint.description as description, rent_complaint.created_at as created_at, rent_complaint.status as status') - ->join('rent', 'rent_complaint.rent_id', 'rent.id') - ->join('rental_services', 'rent.rentalservice_id', 'rental_services.id') - ->where('rent_complaint.complaint_no', $id); - + rent.status as rent_status, rent.total as total_amount,rental_services.id as rental_id, rental_services.name as rental_name, rental_services.mobile as rental_mobile, + rent_complaint.title as title, rent_complaint.description as description, rent_complaint.created_at as created_at, rent_complaint.status as status') + ->join('rent','rent_complaint.rent_id', 'rent.id') + ->join('rental_services', 'rent.rentalservice_id','rental_services.id') + ->where('rent_complaint.complaint_no', $id); + return $this->query($q->getQuery(), $q->getData()); + } + + public function cancelComplaint($id){ + // show($id); + // return $this->update($id, ['status' => 'cancelled'], 'complaint_no'); + $q = new QueryBuilder; + $q->setTable('rent_complaint'); + $q->update(['status' => 'cancelled'])->where('complaint_no', $id); return $this->query($q->getQuery(), $q->getData()); } + + } diff --git a/app/views/404.view.php b/app/views/404.view.php index 8037c559..6e9e252b 100755 --- a/app/views/404.view.php +++ b/app/views/404.view.php @@ -1,5 +1,14 @@ -