From 250848c03a53298db3d0245d05805c40a75b7e93 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 13 Apr 2023 15:07:17 +0530 Subject: [PATCH 01/21] fix hotel not adding in profile access --- .../classes/HotelBranchInformation.php | 21 +- .../classes/HotelHelper.php | 22 +- .../AdminHotelRoomsBookingController.php | 16 +- .../hotel_rooms_booking/helpers/view/view.tpl | 340 +++++++++--------- 4 files changed, 203 insertions(+), 196 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 4482606ae..fd5079139 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -134,24 +134,21 @@ class HotelBranchInformation extends ObjectModel $context = Context::getContext(); } + /* Query definition */ + $query = 'REPLACE INTO `'._DB_PREFIX_.'htl_access` (`id_profile`, `id_hotel`, `access`)'; + $query .= ' VALUES '.'(1, '.(int)$idHotel.', 1)'; /* Profile selection */ $profiles = Db::getInstance()->executeS('SELECT `id_profile` FROM '._DB_PREFIX_.'profile WHERE `id_profile` != 1'); if (!$profiles || empty($profiles)) { - return true; - } - /* Query definition */ - $query = 'REPLACE INTO `'._DB_PREFIX_.'htl_access` (`id_profile`, `id_hotel`, `access`)'; - $query .= ' VALUES '.'(1, '.(int)$idHotel.', 1),'; + foreach ($profiles as $profile) { + $access = 0; + if (isset($context->employee->id_profile)) { + $access = ($profile['id_profile'] == $context->employee->id_profile) ? 1 : 0; + } - foreach ($profiles as $profile) { - $access = 0; - if (isset($context->employee->id_profile)) { - $access = ($profile['id_profile'] == $context->employee->id_profile) ? 1 : 0; + $query .= ', ('.(int)$profile['id_profile'].', '.(int)$idHotel.', '.(int)$access.')'; } - - $query .= ' ('.(int)$profile['id_profile'].', '.(int)$idHotel.', '.(int)$access.'),'; } - $query = trim($query, ', '); return Db::getInstance()->execute($query); } diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index b3d60de77..447e95354 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -24,17 +24,17 @@ class HotelHelper { $objModule = new HotelreservationSystem(); $jsVars = array( - 'display_name' => $objModule->l('Display', 'HotelHelper', fasle, true), - 'records_name' => $objModule->l('records per page', 'HotelHelper', fasle, true), - 'no_product' => $objModule->l('No records found', 'HotelHelper', fasle, true), - 'show_page' => $objModule->l('Showing page', 'HotelHelper', fasle, true), - 'show_of' => $objModule->l('of', 'HotelHelper', fasle, true), - 'no_record' => $objModule->l('No records available', 'HotelHelper', fasle, true), - 'filter_from' => $objModule->l('filtered from', 'HotelHelper', fasle, true), - 't_record' => $objModule->l('total records', 'HotelHelper', fasle, true), - 'search_item' => $objModule->l('Search', 'HotelHelper', fasle, true), - 'p_page' => $objModule->l('Previous', 'HotelHelper', fasle, true), - 'n_page' => $objModule->l('Next', 'HotelHelper', fasle, true), + 'display_name' => $objModule->l('Display', 'HotelHelper', false, true), + 'records_name' => $objModule->l('records per page', 'HotelHelper', false, true), + 'no_product' => $objModule->l('No records found', 'HotelHelper', false, true), + 'show_page' => $objModule->l('Showing page', 'HotelHelper', false, true), + 'show_of' => $objModule->l('of', 'HotelHelper', false, true), + 'no_record' => $objModule->l('No records available', 'HotelHelper', false, true), + 'filter_from' => $objModule->l('filtered from', 'HotelHelper', false, true), + 't_record' => $objModule->l('total records', 'HotelHelper', false, true), + 'search_item' => $objModule->l('Search', 'HotelHelper', false, true), + 'p_page' => $objModule->l('Previous', 'HotelHelper', false, true), + 'n_page' => $objModule->l('Next', 'HotelHelper', false, true), ); Media::addJsDef($jsVars); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 54dc1142b..e0c1834ad 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -113,6 +113,8 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 1 ); $id_hotel = reset($htl_info)['id']; + } else { + $id_hotel = 0; } } @@ -280,13 +282,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController 'id_guest' => $this->context->cookie->id_guest, ); $this->initSearchFormData(); - if ($this->booking_product) { - $this->assignRoomBookingForm(); - } else { - $this->assignServiceProductsForm(); - } + if (count($this->tpl_view_vars['hotel_list'])) { + if ($this->booking_product) { + $this->assignRoomBookingForm(); + } else { + $this->assignServiceProductsForm(); + } - $this->initCartData(); + $this->initCartData(); + } return parent::renderView(); } 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 3ec590eba..936793a14 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,109 +1,139 @@
-
-
-
- {l s='Booking Form' mod='hotelreservationsystem'} -
-
-
-
- {*
- -
- -
-
*} -
- -
- - - -
-
-
- -
- - - -
-
-
- -
- - -
-
- {if $is_occupancy_wise_search} -
-