diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 7fd1d0b3f..39e805901 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -569,11 +569,9 @@ class HotelBranchInformation extends ObjectModel return Db::getInstance()->executeS($sql); } - public function getAllHotels($activeOnly = false) + public function getAllHotels() { - return Db::getInstance()->executeS( - 'SELECT * FROM `'._DB_PREFIX_.'htl_branch_info` hbi'.($activeOnly ? ' WHERE hbi.`active` = 1' : '') - ); + return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_branch_info`'); } //Overrided ObjectModet::update() to update all the dependencies of the hotel diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 868dc10e3..1be7d39f3 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -29,6 +29,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $this->context = Context::getContext(); parent::__construct(); + + $objHotelBranchInformation = new HotelBranchInformation(); + $hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1); + // filter hotels as per accessed hotels + $hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1); + + if ($hotelBranchesInfo) { + $this->initCart(); + } } public function initCart() @@ -82,24 +91,14 @@ class AdminHotelRoomsBookingController extends ModuleAdminController return $objCart; } - public function initProcess() - { - parent::initProcess(); - - $objHotelBranchInformation = new HotelBranchInformation(); - $activeHotels = $objHotelBranchInformation->getAllHotels(true); - - if ($activeHotels) { - $this->initCart(); - } - } - public function postProcess() { $objHotelBranchInformation = new HotelBranchInformation(); - $activeHotels = $objHotelBranchInformation->getAllHotels(true); + $hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1); + // filter hotels as per accessed hotels + $hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1); - if ($activeHotels) { + if ($hotelBranchesInfo) { if (Tools::getValue('date_from')) { $date_from = Tools::getValue('date_from'); } else { @@ -292,14 +291,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController public function renderView() { $objHotelBranchInformation = new HotelBranchInformation(); - $activeHotels = $objHotelBranchInformation->getAllHotels(true); + $hotelBranchesInfo = $objHotelBranchInformation->hotelBranchesInfo(false, 1); + // filter hotels as per accessed hotels + $hotelBranchesInfo = HotelBranchInformation::filterDataByHotelAccess($hotelBranchesInfo, $this->context->employee->id_profile, 1); - $this->tpl_view_vars['has_active_hotels'] = $activeHotels; - if ($activeHotels) { + if ($hotelBranchesInfo) { $this->tpl_view_vars['id_cart'] = $this->context->cart->id; $this->tpl_view_vars['id_guest'] = $this->context->cookie->id_guest; $this->initSearchFormData(); - if (count($this->tpl_view_vars['hotel_list'])) { + if (count($hotelBranchesInfo)) { if ($this->booking_product) { $this->assignRoomBookingForm(); } else { diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl index fced83d7a..b57a7e9d3 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/view.tpl @@ -1,5 +1,5 @@