From 897be6596dcf95f73d2d6514cf72212e0fa943aa Mon Sep 17 00:00:00 2001 From: SandaliGunawardena Date: Thu, 25 Apr 2024 08:40:47 +0530 Subject: [PATCH] admin-numbers --- app/controllers/Admin/Admin.php | 8 +- app/controllers/Admin/Charts.php | 36 ++- app/controllers/Admin/Dashboard.php | 30 ++- app/controllers/Admin/Item.php | 2 +- app/models/AdminStats.php | 79 ++++++ app/views/admin/chart.view.php | 25 +- app/views/admin/complains.view.php | 2 +- .../admin/components/complainlist.view.php | 45 ---- app/views/admin/customer.view.php | 2 +- app/views/admin/dashboard.view.php | 87 ++++++- app/views/admin/guides.view.php | 2 +- app/views/admin/item.view.php | 11 +- app/views/admin/layout/sidebar.php | 20 +- app/views/admin/rentalServices.view.php | 2 +- app/views/admin/tips.view.php | 240 +++++++++--------- app/views/navbar/admin-navbar.php | 20 +- public/assets/scss/wl/dashboard/_button.scss | 12 +- 17 files changed, 408 insertions(+), 215 deletions(-) create mode 100644 app/models/AdminStats.php diff --git a/app/controllers/Admin/Admin.php b/app/controllers/Admin/Admin.php index fdb15600..cb8e6531 100755 --- a/app/controllers/Admin/Admin.php +++ b/app/controllers/Admin/Admin.php @@ -2,6 +2,12 @@ echo "This is the index page"; +Class Admin{ +use Controller; +// public function getRentalCount + +} + +?> -?> \ No newline at end of file diff --git a/app/controllers/Admin/Charts.php b/app/controllers/Admin/Charts.php index 38146cc9..d9ce9480 100755 --- a/app/controllers/Admin/Charts.php +++ b/app/controllers/Admin/Charts.php @@ -1,15 +1,39 @@ view('admin/chart'); + // } + + public function item(string $a = '', string $b = '', string $c = ''): void + { $this->view('admin/chart'); } - public function item(string $a = '', string $b = '', string $c = ''):void { - $this->view('admin/chart'); - }} + public function index(string $a = '', string $b = '', string $c = ''): void + { + + $stats = new AdminStatsModel; + $data['rentalServices'] = $stats->getRentalServiceCount(); + + $stats = new AdminStatsModel; + $data['customers'] = $stats->getCustomerCount(); + $stats = new AdminStatsModel; + $data['guides'] = $stats->getGuideCount(); -?> \ No newline at end of file + $stats = new AdminStatsModel; + $data['tips'] = $stats->getTipsCount(); + + $stats = new AdminStatsModel; + $data['rentComplaints'] = $stats->getRentComplainsCount(); + + $stats = new AdminStatsModel; + $data['orders'] = $stats->getOrdersCount(); + + $this->view('admin/chart', $data); + } +} diff --git a/app/controllers/Admin/Dashboard.php b/app/controllers/Admin/Dashboard.php index 185d439b..c7b9e6e7 100755 --- a/app/controllers/Admin/Dashboard.php +++ b/app/controllers/Admin/Dashboard.php @@ -1,12 +1,30 @@ view('admin/dashboard'); - } -} + public function index(string $a = '', string $b = '', string $c = ''): void + { + + $stats = new AdminStatsModel; + $data['rentalServices'] = $stats->getRentalServiceCount(); + + $stats = new AdminStatsModel; + $data['customers'] = $stats->getCustomerCount(); + + $stats = new AdminStatsModel; + $data['guides'] = $stats->getGuideCount(); + $stats = new AdminStatsModel; + $data['tips'] = $stats->getTipsCount(); -?> \ No newline at end of file + $stats = new AdminStatsModel; + $data['rentComplaints'] = $stats->getRentComplainsCount(); + + $stats = new AdminStatsModel; + $data['orders'] = $stats->getOrdersCount(); + + $this->view('admin/dashboard', $data); + } +} diff --git a/app/controllers/Admin/Item.php b/app/controllers/Admin/Item.php index 66a865d8..385edb0b 100755 --- a/app/controllers/Admin/Item.php +++ b/app/controllers/Admin/Item.php @@ -11,7 +11,7 @@ public function index(string $a = '', string $b = '', string $c = ''): void $data['items'] = $item->findAll(); //show($data); - $this->view('admin/item', $data); + $this->view('admin/rentalServices', $data); } public function item(string $a = '', string $b = '', string $c = ''): void diff --git a/app/models/AdminStats.php b/app/models/AdminStats.php new file mode 100644 index 00000000..b8286c16 --- /dev/null +++ b/app/models/AdminStats.php @@ -0,0 +1,79 @@ +setTable('rental_services'); + $q->count()->where("status", "accepted"); + + + return $this->query($q->getQuery(), $q->getData()); + } + + public function getCustomerCount() + { + + $q = new QueryBuilder(); + + $q->setTable('customers'); + $q->count(); + + + return $this->query($q->getQuery(), $q->getData()); + } + + public function getGuideCount() + { + + $q = new QueryBuilder(); + + $q->setTable('guides'); + $q->count(); + + + return $this->query($q->getQuery(), $q->getData()); + } + + public function getTipsCount() + { + + $q = new QueryBuilder(); + + $q->setTable('tips'); + $q->count(); + + + return $this->query($q->getQuery(), $q->getData()); + } + + public function getRentComplainsCount() + { + + $q = new QueryBuilder(); + + $q->setTable('rent_return_complaints'); + $q->count(); + + + return $this->query($q->getQuery(), $q->getData()); + } + + public function getOrdersCount() + { + + $q = new QueryBuilder(); + + $q->setTable('rent'); + $q->count(); + + + return $this->query($q->getQuery(), $q->getData()); + } +} diff --git a/app/views/admin/chart.view.php b/app/views/admin/chart.view.php index 2c561108..b20f900c 100755 --- a/app/views/admin/chart.view.php +++ b/app/views/admin/chart.view.php @@ -1,6 +1,6 @@ + document.getElementById("update-form").addEventListener('submit', function(event) { + // event.preventDefault(); + // Handle update form submission logic + // ... + // Close the update modal after submission if successful + updateModal.style.display = "none"; + }); + - \ No newline at end of file + ?> \ No newline at end of file diff --git a/app/views/navbar/admin-navbar.php b/app/views/navbar/admin-navbar.php index 6b34aedd..ea7ad8c0 100644 --- a/app/views/navbar/admin-navbar.php +++ b/app/views/navbar/admin-navbar.php @@ -6,7 +6,7 @@