From 6fe78df37258e5b461c1e900c25e37e8baf86a55 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Wed, 30 Sep 2026 10:59:07 +0530 Subject: [PATCH 1/2] Fixed: Unable to unselect property type after disabling it --- .../classes/HotelPropertyType.php | 2 +- .../controllers/admin/AdminAddHotelController.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelPropertyType.php b/modules/hotelreservationsystem/classes/HotelPropertyType.php index cbe87d79b..6dee4e0a1 100644 --- a/modules/hotelreservationsystem/classes/HotelPropertyType.php +++ b/modules/hotelreservationsystem/classes/HotelPropertyType.php @@ -68,7 +68,7 @@ class HotelPropertyType extends ObjectModel $cacheKey = 'HotelPropertyType::getPropertyTypes'.$idLang.'_'.(int) $active; if (!Cache::isStored($cacheKey)) { - $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hptl.`name` + $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hpt.`active`, hptl.`name` FROM `'._DB_PREFIX_.'htl_property_type` hpt LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl ON (hpt.`id_htl_property_type` = hptl.`id_htl_property_type` diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 7dd1b3c52..d9ed1c4b4 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -229,12 +229,21 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['PS_MAX_CHECKOUT_OFFSET'] = (int) Configuration::get('PS_MAX_CHECKOUT_OFFSET'); $smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET'); $smartyVars['WK_ORDER_REFUND_ALLOWED'] = Configuration::get('WK_ORDER_REFUND_ALLOWED'); - $hotelPropertyTypes = HotelPropertyType::getPropertyTypes($this->context->language->id); - $smartyVars['hotel_property_types_info'] = $hotelPropertyTypes; + $hotelPropertyTypes = HotelPropertyType::getPropertyTypes($this->context->language->id, false); $selectedHotelPropertyType = Tools::getValue('id_property_type'); if (!$selectedHotelPropertyType && isset($hotelBranchInfo)) { $selectedHotelPropertyType = $hotelBranchInfo->id_property_type; } + // Remove inactive property types from the list. While editing a hotel, keep the currently assigned one even if it is disabled + foreach ($hotelPropertyTypes as $key => $propertyType) { + if (!$propertyType['active'] + && (!isset($idHotel) || (int) $propertyType['id_property_type'] != (int) $selectedHotelPropertyType) + ) { + unset($hotelPropertyTypes[$key]); + } + } + $hotelPropertyTypes = array_values($hotelPropertyTypes); + $smartyVars['hotel_property_types_info'] = $hotelPropertyTypes; $smartyVars['selected_hotel_property_type'] = (int) $selectedHotelPropertyType; $smartyVars['tourism_tax_collection_type'] = (int) $this->object->tourism_tax_collection_type; $smartyVars['use_tourism_tax'] = (int) Configuration::get('QLO_USE_TOURISM_TAX'); From 6919a16b563a96bc5fa6e350994b12f81629c0e6 Mon Sep 17 00:00:00 2001 From: amit sharma Date: Mon, 5 Oct 2026 16:01:31 +0530 Subject: [PATCH 2/2] Fixed: review changes Co-authored-by: Name --- .../classes/HotelPropertyType.php | 2 +- .../admin/AdminAddHotelController.php | 13 +----- .../AdminHotelPropertyTypesController.php | 46 +++++++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelPropertyType.php b/modules/hotelreservationsystem/classes/HotelPropertyType.php index 6dee4e0a1..cbe87d79b 100644 --- a/modules/hotelreservationsystem/classes/HotelPropertyType.php +++ b/modules/hotelreservationsystem/classes/HotelPropertyType.php @@ -68,7 +68,7 @@ class HotelPropertyType extends ObjectModel $cacheKey = 'HotelPropertyType::getPropertyTypes'.$idLang.'_'.(int) $active; if (!Cache::isStored($cacheKey)) { - $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hpt.`active`, hptl.`name` + $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hptl.`name` FROM `'._DB_PREFIX_.'htl_property_type` hpt LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl ON (hpt.`id_htl_property_type` = hptl.`id_htl_property_type` diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index d9ed1c4b4..7dd1b3c52 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -229,21 +229,12 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['PS_MAX_CHECKOUT_OFFSET'] = (int) Configuration::get('PS_MAX_CHECKOUT_OFFSET'); $smartyVars['PS_MIN_BOOKING_OFFSET'] = (int) Configuration::get('PS_MIN_BOOKING_OFFSET'); $smartyVars['WK_ORDER_REFUND_ALLOWED'] = Configuration::get('WK_ORDER_REFUND_ALLOWED'); - $hotelPropertyTypes = HotelPropertyType::getPropertyTypes($this->context->language->id, false); + $hotelPropertyTypes = HotelPropertyType::getPropertyTypes($this->context->language->id); + $smartyVars['hotel_property_types_info'] = $hotelPropertyTypes; $selectedHotelPropertyType = Tools::getValue('id_property_type'); if (!$selectedHotelPropertyType && isset($hotelBranchInfo)) { $selectedHotelPropertyType = $hotelBranchInfo->id_property_type; } - // Remove inactive property types from the list. While editing a hotel, keep the currently assigned one even if it is disabled - foreach ($hotelPropertyTypes as $key => $propertyType) { - if (!$propertyType['active'] - && (!isset($idHotel) || (int) $propertyType['id_property_type'] != (int) $selectedHotelPropertyType) - ) { - unset($hotelPropertyTypes[$key]); - } - } - $hotelPropertyTypes = array_values($hotelPropertyTypes); - $smartyVars['hotel_property_types_info'] = $hotelPropertyTypes; $smartyVars['selected_hotel_property_type'] = (int) $selectedHotelPropertyType; $smartyVars['tourism_tax_collection_type'] = (int) $this->object->tourism_tax_collection_type; $smartyVars['use_tourism_tax'] = (int) Configuration::get('QLO_USE_TOURISM_TAX'); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php index 43f5d249c..d3485a680 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php @@ -57,6 +57,17 @@ class AdminHotelPropertyTypesController extends ModuleAdminController $this->addRowAction('edit'); $this->addRowAction('delete'); $this->bulk_actions = array( + 'enableSelection' => array( + 'text' => $this->l('Enable selected'), + 'icon' => 'icon-power-off text-success', + ), + 'disableSelection' => array( + 'text' => $this->l('Disable selected'), + 'icon' => 'icon-power-off text-danger', + ), + 'divider' => array( + 'text' => 'divider', + ), 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), @@ -157,6 +168,13 @@ class AdminHotelPropertyTypesController extends ModuleAdminController $this->display = $idPropertyType ? 'edit' : 'add'; + if (!$this->errors && !Tools::getValue('active') && $idPropertyType) { + $objPropertyType = new HotelPropertyType((int) $idPropertyType); + if (Validate::isLoadedObject($objPropertyType) && $objPropertyType->active && $objPropertyType->isUsed()) { + $this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.'); + } + } + if (!$this->errors) { parent::postProcess(); } @@ -165,6 +183,34 @@ class AdminHotelPropertyTypesController extends ModuleAdminController } } + public function processStatus() + { + $object = $this->loadObject(); + if (Validate::isLoadedObject($object) && $object->active && $object->isUsed()) { + $this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.'); + + return false; + } + + return parent::processStatus(); + } + + protected function processBulkDisableSelection() + { + if (is_array($this->boxes) && !empty($this->boxes)) { + foreach ($this->boxes as $idPropertyType) { + $object = new HotelPropertyType((int) $idPropertyType); + if (Validate::isLoadedObject($object) && $object->isUsed()) { + $this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.'); + + return false; + } + } + } + + return parent::processBulkDisableSelection(); + } + public function processDelete() { $object = $this->loadObject();