From e299b4bd41a036f36e4fa19b6c611fec19e06217 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 14 May 2024 15:10:40 +0530 Subject: [PATCH] Fixed: The incorrect information on the KPIs in the AdminProductController --- controllers/admin/AdminProductsController.php | 12 ++++---- controllers/admin/AdminStatsController.php | 29 +++++++++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 7123dbbf4..089d56c9c 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2458,7 +2458,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Occupied Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=occupied_rooms'; - $helper->tooltip = $this->l('The current count of rooms that are currently occupied by guests.', null, null, false); + $helper->tooltip = $this->l('The count of rooms that are currently occupied by guests.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2468,7 +2468,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Vacant Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=vacant_rooms'; - $helper->tooltip = $this->l('The count of rooms that are currently unoccupied and available for booking.', null, null, false); + $helper->tooltip = $this->l('The count of rooms that are either booked but currently unoccupied or available for booking', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2478,7 +2478,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Booked Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=booked_rooms'; - $helper->tooltip = $this->l('The number of rooms that are currently booked but not yet occupied.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that are currently booked and unoccupied.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2488,7 +2488,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Disabled Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_rooms'; - $helper->tooltip = $this->l('The number of rooms that are currently disabled.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that are currently disabled.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2498,7 +2498,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Online Bookable Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=online_bookable_rooms'; - $helper->tooltip = $this->l('The total number of rooms that can be booked only using website.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that can be booked directly from the front office.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2508,7 +2508,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Offline Bookable Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=offline_bookable_rooms'; - $helper->tooltip = $this->l('The number of rooms that can be booked either through website or offline channels (e.g., phone or in-person).', null, null, false); + $helper->tooltip = $this->l('The total number of rooms available for booking through the back office.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 2de11a362..1d3e4a721 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -850,15 +850,16 @@ class AdminStatsControllerCore extends AdminStatsTabController break; case 'occupied_rooms': - $value = AdminStatsController::getOccupiedRooms(0); + $value = AdminStatsController::getCurrentlyOccupiedRooms(0); break; case 'vacant_rooms': - $totalAvailableRooms = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, 0); - $totalAvailableRooms = $totalAvailableRooms[strtotime(date('Y-m-d'))]; - $totalOccupiedRooms = AdminStatsController::getOccupiedRooms(0); - $value = $totalAvailableRooms - $totalOccupiedRooms; + $totalUnAvailRooms = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, 0); + $totalUnAvailRooms = $totalUnAvailRooms[strtotime(date('Y-m-d'))]; + $totalRooms = AdminStatsController::getTotalRooms(0); + $totalOccupiedRooms = AdminStatsController::getCurrentlyOccupiedRooms(0); + $value = $totalRooms - ($totalUnAvailRooms + $totalOccupiedRooms); break; @@ -1810,6 +1811,24 @@ class AdminStatsControllerCore extends AdminStatsTabController return $result; } + public static function getCurrentlyOccupiedRooms($idHotel = null) + { + $sql = 'SELECT COUNT(DISTINCT hbd.`id_room`) + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'htl_room_information` hri + ON (hri.`id` = hbd.`id_room`) + LEFT JOIN `'._DB_PREFIX_.'product` p + ON (p.`id_product` = hri.`id_product`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`is_cancelled` = 0 + AND ("'.pSQL(date('Y-m-d')).'" BETWEEN hbd.`date_from` AND hbd.`date_to`) + AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN. + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); + + return Db::getInstance()->getValue($sql); + } + /** * Returns the number of rooms that have been booked but not checked-in yet. */