diff --git a/app/controllers/API/Complaints.php b/app/controllers/API/Complaints.php
index 7fae409..2785840 100644
--- a/app/controllers/API/Complaints.php
+++ b/app/controllers/API/Complaints.php
@@ -1,20 +1,32 @@
-view('rental/complaints');
}
- public function cancelComplaint(string $a = '', string $b = '', string $c = ''):void {
+ public function cancelComplaint(string $a = '', string $b = '', string $c = ''): void
+ {
+
+ $complaint = new RentReturnComplaintModel;
+ $complaint->cancelComplaint($a);
+
+ $response = new JSONResponse;
+ $response->statusCode(200)->data(['complaint_id' => $a])->send();
+ }
- $complaint = new RentReturnComplaintModel;
- $complaint->cancelComplaint($a);
+ public function resolveComplaint(string $a = ''): void
+ {
- $response = new JSONResponse;
- $response->statusCode(200)->data(['complaint_id' => $a])->send();
+ $complaint = new RentComplaintModel;
+ $complaint->resolveComplaint($a);
+ $response = new JSONResponse;
+ $response->statusCode(200)->success(true)->data(['complaint_id' => $a])->send();
}
-}
\ No newline at end of file
+}
diff --git a/app/models/RentComplaint.php b/app/models/RentComplaint.php
index 65a0b37..f370779 100644
--- a/app/models/RentComplaint.php
+++ b/app/models/RentComplaint.php
@@ -1,24 +1,35 @@
allowedColumns);
- }, ARRAY_FILTER_USE_KEY);
+class RentComplaintModel
+{
+ use Model;
+
+ protected string $table = 'rent_return_complaints';
+
+ protected array $allowedColumns = [
+ 'rent_id',
+ 'title',
+ 'description',
+ 'status'
+ ];
+
+ public function createComplaint($data)
+ {
+ $data = array_filter($data, function ($key) {
+ return in_array($key, $this->allowedColumns);
+ }, ARRAY_FILTER_USE_KEY);
+
+ $this->insert($data);
+ }
- $this->insert($data);
- }
+ public function resolveComplaint($id)
+ {
+ // $data = array_filter($data, function ($key) {
+ // return in_array($key, $this->allowedColumns);
+ // }, ARRAY_FILTER_USE_KEY);
+ //$table
+ $this->update($id, ['status' => 'resolved']);
+ }
public function getComplaints(array $data) {
return $this->where($data);
}
@@ -33,6 +44,10 @@ public function getComplaintsByCustomer(array $data) {
return $this->query($q->getQuery(), $q->getData());
}
- }
-?>
\ No newline at end of file
+
+ public function getComplaints(array $data)
+ {
+ return $this->where($data);
+ }
+}
diff --git a/app/views/admin/complains.view.php b/app/views/admin/complains.view.php
index 91797d9..00f910d 100644
--- a/app/views/admin/complains.view.php
+++ b/app/views/admin/complains.view.php
@@ -177,7 +177,6 @@ function getComplaints(status, user = "customer") {
-
$(document).on('click', '#cancel-complaint-confirm', function() {
var complaintId = $(this).attr('data-id');
$.ajax({
@@ -203,6 +202,37 @@ function getComplaints(status, user = "customer") {
}
});
});
+
+
+
+
+
+ $(document).on('click', '#resolve-complaint', function() {
+ var complaintId = $(this).closest('.complaint').attr('data-id');
+ $('#resolve-complaint-confirm').attr('data-id', complaintId);
+ $('#resolve-complaint-modal').css('display', 'block');
+ });
+
+ $(document).on('click', '#resolve-complaint-confirm', function() {
+ var complaintId = $(this).attr('data-id');
+ $.ajax({
+ headers: {
+ 'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
+ },
+ url: '= ROOT_DIR ?>/api/complaints/resolveComplaint/' + complaintId,
+ type: 'GET',
+ success: function(response) {
+ console.log(response);
+ var id = response.data.complaint_id;
+ $('#complaint-card[data-id="' + id + '"]').remove();
+ $('#cancel-complaint-modal').css('display', 'none');
+ getComplaints('pending');
+ },
+ error: function(err) {
+ console.log(err);
+ }
+ });
+ });
diff --git a/app/views/admin/components/complainlist.view.php b/app/views/admin/components/complainlist.view.php
index ba26a6e..788df4f 100644
--- a/app/views/admin/components/complainlist.view.php
+++ b/app/views/admin/components/complainlist.view.php
@@ -34,7 +34,7 @@
status == 'pending') {
?>
-
+
@@ -105,6 +105,18 @@
+
+
+ ×
+
Resolve Complaint
+
Are you sure you want to resolve this complaint?
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/customer.view.php b/app/views/admin/customer.view.php
index 3b5d9de..70a33a7 100755
--- a/app/views/admin/customer.view.php
+++ b/app/views/admin/customer.view.php
@@ -24,12 +24,12 @@
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/admin/tips.view.php b/app/views/admin/tips.view.php
index 33cf957..7df8a5b 100644
--- a/app/views/admin/tips.view.php
+++ b/app/views/admin/tips.view.php
@@ -10,9 +10,13 @@
+
+
+
+