diff --git a/app/controllers/Admin/Tips.php b/app/controllers/Admin/Tips.php index 7897dfd..2d45a11 100644 --- a/app/controllers/Admin/Tips.php +++ b/app/controllers/Admin/Tips.php @@ -39,7 +39,10 @@ public function delete(string $a = '', string $b = '', string $c = ''): void // show($b); // show($c); $tips = new TipsModel(); + // show($tips->first(['id' => $a])); + $tips->delete($a, 'id'); + redirect('admin/tips'); } diff --git a/app/controllers/MyOrders.php b/app/controllers/MyOrders.php index 4d3a92a..388c3fa 100644 --- a/app/controllers/MyOrders.php +++ b/app/controllers/MyOrders.php @@ -9,8 +9,15 @@ public function index(string $a = '', string $b = '', string $c = ''):void { AuthorizationMiddleware::authorize(['customer']); + + $tips = new TipsModel(); + $data['tips'] = $tips->findAll(); + + // randomly select 1 tip + $data['tip'] = $data['tips'][array_rand($data['tips'])]; + // show($data['tip']); - $this->view('customer/orders'); + $this->view('customer/orders', $data); } public function list(string $a = '', string $b = '', string $c = ''):void { diff --git a/app/views/admin/tips.view.php b/app/views/admin/tips.view.php index f868360..be93f90 100644 --- a/app/views/admin/tips.view.php +++ b/app/views/admin/tips.view.php @@ -90,7 +90,7 @@
@@ -128,10 +128,20 @@ function openUpdateModal(name, email, id) { document.getElementById("updated-title").value = name; document.getElementById("updated-description").value = email; document.getElementById("tip-id").value = id; - document.getElementById("delete-tip").href = "/admin/tips/delete/" + id; + document.getElementById("delete-tip").setAttribute('key', id); updateModal.style.display = "block"; } + $(document).on('click','#delete-tip',function(e){ +e.preventDefault(); + var id = $(this).attr('key'); + console.log(id); + // goto the delete route + window.location.href = "/admin/tips/delete/" + id; + }); + + + // Event listener for add button click addButton.addEventListener('click', function() { openAddModal(); diff --git a/app/views/customer/orders.view.php b/app/views/customer/orders.view.php index d6ab9de..d97a360 100644 --- a/app/views/customer/orders.view.php +++ b/app/views/customer/orders.view.php @@ -9,7 +9,17 @@description; ?>
+Are you sure you want to cancel this complaint?