diff --git a/app/controllers/Admin/Admin.php b/app/controllers/Admin/Admin.php index fdb1560..cb8e653 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 38146cc..d9ce948 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 185d439..c7b9e6e 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 66a865d..385edb0 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 0000000..b8286c1 --- /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 2c56110..b20f900 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 6b34aed..ea7ad8c 100644 --- a/app/views/navbar/admin-navbar.php +++ b/app/views/navbar/admin-navbar.php @@ -6,7 +6,7 @@