diff --git a/classes/Product.php b/classes/Product.php index fc962d3c0..9c6278c3f 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -1073,9 +1073,6 @@ class ProductCore extends ObjectModel if (!$this->deleteServiceInfo()) { return false; } - } else { - $objHotelRoomTypeBedType = new HotelRoomTypeBedType(); - $objHotelRoomTypeBedType->deleteRoomTypeBedTypes(false, $this->id); } Hook::exec('actionProductDelete', array('id_product' => (int)$this->id, 'product' => $this)); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index d2819efca..113ce24ce 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -3307,7 +3307,7 @@ class AdminImportControllerCore extends AdminController Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_image`'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_access`'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_booking_detail`'); - Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_features`'); + Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_amenities`'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_cart_booking_data`'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_branch_refund_rules`'); Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'htl_order_restrict_date`'); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 0ee742f96..f2aa3f43e 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -1206,16 +1206,16 @@ class AdminProductsControllerCore extends AdminController $selectedAmenities = array_map('intval', $selectedAmenities); $selectedAmenities = array_values(array_unique(array_filter($selectedAmenities))); - if (!Db::getInstance()->delete('htl_room_type_features', '`id_product` = '.$idProduct)) { + if (!Db::getInstance()->delete('htl_room_type_amenities', '`id_product` = '.$idProduct)) { return false; } foreach ($selectedAmenities as $idAmenity) { - if (!Db::getInstance()->insert('htl_room_type_features', array( + if (!Db::getInstance()->insert('htl_room_type_amenities', array( 'id_product' => $idProduct, - 'feature_id' => (int) $idAmenity, - 'date_add' => date('Y-m-d H:i:s'), - 'date_upd' => date('Y-m-d H:i:s'), + 'amenity_id' => (int) $idAmenity, + 'date_add' => date('Y-m-d H:i:s'), + 'date_upd' => date('Y-m-d H:i:s'), ))) { return false; } @@ -1234,8 +1234,8 @@ class AdminProductsControllerCore extends AdminController protected function getSelectedRoomTypeAmenityIds($idProduct) { $selectedAmenities = Db::getInstance()->executeS( - 'SELECT `feature_id` - FROM `'._DB_PREFIX_.'htl_room_type_features` + 'SELECT `amenity_id` + FROM `'._DB_PREFIX_.'htl_room_type_amenities` WHERE `id_product` = '.(int) $idProduct ); @@ -1243,7 +1243,7 @@ class AdminProductsControllerCore extends AdminController return array(); } - return array_map('intval', array_column($selectedAmenities, 'feature_id')); + return array_map('intval', array_column($selectedAmenities, 'amenity_id')); } /** @@ -1257,10 +1257,10 @@ class AdminProductsControllerCore extends AdminController { $selectedAmenityRows = array(); foreach ($this->getSelectedRoomTypeAmenityIds($idProduct) as $selectedAmenityId) { - $selectedAmenityRows[] = array('feature_id' => $selectedAmenityId); + $selectedAmenityRows[] = array('amenity_id' => $selectedAmenityId); } - $objHotelFeatures = new HotelFeatures(); + $objHotelFeatures = new HotelAmenities(); $roomTypeAmenities = $objHotelFeatures->HotelBranchSelectedFeaturesArray( $selectedAmenityRows, $this->context->language->id diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index ac47c445f..44c97ca33 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -38,7 +38,7 @@ class AdminSearchControllerCore extends AdminController 'AdminOrderRefundRules' => 1, 'AdminRoomTypeGlobalDemand' => 1, 'AdminGroups' => 1, - 'AdminHotelFeatures' => 1, + 'AdminHotelAmenities' => 1, 'AdminCustomers' => 1, 'AdminAddHotel' => 1, 'AdminNormalProducts' => 1, @@ -430,9 +430,9 @@ class AdminSearchControllerCore extends AdminController public function searchHotelFeatures() { - if (class_exists('HotelFeatures')) { - if (isset($this->controllerAccess['AdminHotelFeatures']) && $this->controllerAccess['AdminHotelFeatures']) { - $objHotelFeatures = new HotelFeatures(); + if (class_exists('HotelAmenities')) { + if (isset($this->controllerAccess['AdminHotelAmenities']) && $this->controllerAccess['AdminHotelAmenities']) { + $objHotelFeatures = new HotelAmenities(); if ($hotelFeatures = $objHotelFeatures->searchByName($this->query, $this->context->language->id)) { $features = array(); foreach ($hotelFeatures as $key => $hotelFeature) { @@ -939,9 +939,9 @@ class AdminSearchControllerCore extends AdminController $helper->identifier = 'id'; $helper->actions = array('edit', 'view'); $helper->show_toolbar = false; - $helper->table = 'htl_features'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminHotelFeatures', false); - $helper->token = Tools::getAdminTokenLite('AdminHotelFeatures'); + $helper->table = 'htl_amenities'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminHotelAmenities', false); + $helper->token = Tools::getAdminTokenLite('AdminHotelAmenities'); if ($this->_list['hotel_features']) { $view = $helper->generateList($this->_list['hotel_features'], $this->fields_list['hotel_features']); diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 582344f7d..462cc4012 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -236,7 +236,6 @@ class CategoryControllerCore extends FrontController } } - $feat_img_dir = _PS_IMG_.'rf/'; $ratting_img = _MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icons-sprite.png'; $this->context->smarty->assign(array( 'warning_num' => $warning_num, @@ -249,7 +248,7 @@ class CategoryControllerCore extends FrontController 'display_all_room_types' => $displayAllRoomsTypes, 'id_hotel' => $id_hotel, 'currency' => $currency, - 'feat_img_dir' => $feat_img_dir, + 'amenity_img_dir' => _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/', 'ratting_img' => $ratting_img, )); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index a679f55f4..f9750d6c1 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -350,8 +350,8 @@ class ProductControllerCore extends FrontController if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) { foreach ($obj_hotel_feaures_ids as $key => $value) { - $obj_htl_ftr = new HotelFeatures(); - $htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']); + $obj_htl_ftr = new HotelAmenities(); + $htl_info = $obj_htl_ftr->getFeatureInfoById($value['amenity_id']); $htl_features[] = $htl_info['name']; } } @@ -411,6 +411,7 @@ class ProductControllerCore extends FrontController $roomDynamicFeatures = $this->getRoomDynamicFeatures($this->product->id); $roomDynamicAmenities = $this->getRoomDynamicAmenities($this->product->id); + $hotelDynamicAmenities = $this->getHotelDynamicAmenities($hotel_id); $this->context->smarty->assign( array( @@ -440,6 +441,8 @@ class ProductControllerCore extends FrontController 'hotel_features' => $htl_features, 'room_dynamic_features' => $roomDynamicFeatures, 'room_dynamic_amenities' => $roomDynamicAmenities, + 'hotel_dynamic_amenities' => $hotelDynamicAmenities, + 'amenity_img_dir' => _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/', 'hotel_image_link' => $hotelImageLink, 'hotel_has_images' => (bool) HotelImage::getCover($hotel_id), 'order_date_restrict' => $order_date_restrict, @@ -595,7 +598,7 @@ class ProductControllerCore extends FrontController $result = array(); foreach ($features as $feature) { $result[] = array( - 'name' => $feature['feature_name'], + 'name' => $feature['feature_name'], 'value' => $feature['feature_value'], ); } @@ -603,30 +606,34 @@ class ProductControllerCore extends FrontController return $result; } - /** - * Get assigned dynamic room amenities for the room detail page. - * - * @param int $idProduct - * - * @return array - */ protected function getRoomDynamicAmenities($idProduct) { $amenities = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT hfl.`name` - FROM `'._DB_PREFIX_.'htl_room_type_features` hrtf - INNER JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hrtf.`feature_id` AND hfl.`id_lang` = '.(int) $this->context->language->id.') - INNER JOIN `'._DB_PREFIX_.'htl_features` hf ON (hf.`id` = hrtf.`feature_id`) - WHERE hrtf.`id_product` = '.(int) $idProduct.' - ORDER BY hf.`position` ASC, hfl.`name` ASC' + SELECT ha.`id`, ha.`logo_type`, ha.`logo`, hal.`name` + FROM `'._DB_PREFIX_.'htl_room_type_amenities` hrta + INNER JOIN `'._DB_PREFIX_.'htl_amenities` ha ON (ha.`id` = hrta.`amenity_id`) + INNER JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = hrta.`amenity_id` AND hal.`id_lang` = '.(int) $this->context->language->id.') + WHERE hrta.`id_product` = '.(int) $idProduct.' AND ha.`active` = 1 + ORDER BY ha.`position` ASC, hal.`name` ASC' ); - if (!$amenities) { - return array(); - } + return $amenities ?: array(); + } - return $amenities; + protected function getHotelDynamicAmenities($idHotel) + { + $amenities = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' + SELECT ha.`id`, ha.`logo_type`, ha.`logo`, hal.`name` + FROM `'._DB_PREFIX_.'htl_branch_amenities` hba + INNER JOIN `'._DB_PREFIX_.'htl_amenities` ha ON (ha.`id` = hba.`amenity_id`) + INNER JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = hba.`amenity_id` AND hal.`id_lang` = '.(int) $this->context->language->id.') + WHERE hba.`id_hotel` = '.(int) $idHotel.' AND ha.`active` = 1 + ORDER BY ha.`position` ASC, hal.`name` ASC' + ); + + return $amenities ?: array(); } public function assignRoomServiceProductVars() diff --git a/img/rf/1.jpg b/img/rf/1.jpg index 9d820ba43..722d4ec53 100644 Binary files a/img/rf/1.jpg and b/img/rf/1.jpg differ diff --git a/img/rf/2.jpg b/img/rf/2.jpg index ed46f7fff..5f78f92f7 100644 Binary files a/img/rf/2.jpg and b/img/rf/2.jpg differ diff --git a/img/rf/3.jpg b/img/rf/3.jpg index d5f91bdbf..b4803e566 100644 Binary files a/img/rf/3.jpg and b/img/rf/3.jpg differ diff --git a/img/rf/4.jpg b/img/rf/4.jpg index 05c7251eb..45e63101b 100644 Binary files a/img/rf/4.jpg and b/img/rf/4.jpg differ diff --git a/img/rf/5.jpg b/img/rf/5.jpg index 33236f769..c0149e50c 100644 Binary files a/img/rf/5.jpg and b/img/rf/5.jpg differ diff --git a/img/rf/6.jpg b/img/rf/6.jpg index 6f057b5a9..620dcccb1 100644 Binary files a/img/rf/6.jpg and b/img/rf/6.jpg differ diff --git a/img/rf/7.jpg b/img/rf/7.jpg index bd7203ed1..632435172 100644 Binary files a/img/rf/7.jpg and b/img/rf/7.jpg differ diff --git a/modules/hotelreservationsystem/classes/HotelAmenities.php b/modules/hotelreservationsystem/classes/HotelAmenities.php new file mode 100644 index 000000000..28ea3ff85 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelAmenities.php @@ -0,0 +1,259 @@ + 'htl_amenities', + 'primary' => 'id', + 'multilang' => true, + 'fields' => array( + 'parent_feature_id' => array('type' => self::TYPE_INT, 'required' => true), + 'position' => array('type' => self::TYPE_INT), + 'active' => array('type' => self::TYPE_INT, 'required' => true), + 'is_featured' => array('type' => self::TYPE_INT), + 'logo_type' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), + 'logo' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + // lang fields + 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'required' => true), + ), + ); + + protected $webserviceParameters = array( + 'objectsNodeName' => 'hotel_amenities', + 'objectNodeName' => 'hotel_amenity', + 'fields' => array(), + ); + + public function delete() + { + if ($id = $this->id) { + Db::getInstance()->delete('htl_branch_amenities', '`amenity_id` = '.(int)$id); + Db::getInstance()->delete('htl_room_type_amenities', '`amenity_id` = '.(int)$id); + $imgFile = dirname(__FILE__).'/../views/img/hotel_amenities/'.(int)$id.'.jpg'; + if (file_exists($imgFile)) { + unlink($imgFile); + } + return parent::delete(); + } + return false; + } + + /** + * Return all categories (parent_feature_id = 0) with their child amenities. + * + * @param int $idLang + * @return array|false + */ + public function getAllAmenitiesTree($idLang = 0) + { + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + $result = array(); + $parents = Db::getInstance()->executeS( + 'SELECT ha.`id`, ha.`position`, hal.`name` + FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = ha.`id` AND hal.`id_lang` = '.(int)$idLang.') + WHERE ha.`parent_feature_id` = 0 + ORDER BY ha.`position` ASC' + ); + + if ($parents) { + foreach ($parents as $parent) { + $result[$parent['id']] = array( + 'id' => $parent['id'], + 'name' => $parent['name'], + 'position' => $parent['position'], + 'children' => array(), + ); + + $children = Db::getInstance()->executeS( + 'SELECT ha.`id`, ha.`active`, ha.`logo_type`, ha.`logo`, hal.`name` + FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = ha.`id` AND hal.`id_lang` = '.(int)$idLang.') + WHERE ha.`parent_feature_id` = '.(int)$parent['id'] + ); + + if ($children) { + $result[$parent['id']]['children'] = $children; + } + } + } + + return $result ?: false; + } + + /** + * Returns all amenity categories with children, marking which children are selected for a hotel. + * + * @param array $branchAmenities rows from htl_branch_amenities for a hotel + * @param int $idLang + * @return array|false + */ + public function HotelBranchSelectedFeaturesArray($branchAmenities, $idLang = 0) + { + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + $result = array(); + $parents = Db::getInstance()->executeS( + 'SELECT ha.`id`, hal.`name` + FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = ha.`id` AND hal.`id_lang` = '.(int)$idLang.') + WHERE ha.`parent_feature_id` = 0' + ); + + if ($parents) { + foreach ($parents as $parent) { + $result[$parent['id']]['name'] = $parent['name']; + $children = Db::getInstance()->executeS( + 'SELECT ha.`id`, hal.`name` + FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = ha.`id` AND hal.`id_lang` = '.(int)$idLang.') + WHERE ha.`parent_feature_id` = '.(int)$parent['id'] + ); + + if ($children) { + foreach ($children as $child) { + $selected = 0; + if ($branchAmenities) { + foreach ($branchAmenities as $row) { + if ($child['id'] == $row['amenity_id']) { + $selected = 1; + break; + } + } + } + $child['selected'] = $selected; + $result[$parent['id']]['children'][] = $child; + } + } + } + } + + return $result ?: false; + } + + /** + * @param int $id + * @param int $idLang + * @return array|false + */ + public function getFeatureInfoById($id, $idLang = 0) + { + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + return Db::getInstance()->getRow( + 'SELECT ha.`id`, hal.`name` + FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON (hal.`id` = ha.`id` AND hal.`id_lang` = '.(int)$idLang.') + WHERE ha.`id` = '.(int)$id + ); + } + + /** + * @param int $parentId + * @return array|false + */ + public function getChildFeaturesByParentFeatureId($parentId) + { + return Db::getInstance()->executeS( + 'SELECT `id` FROM `'._DB_PREFIX_.'htl_amenities` WHERE `parent_feature_id` = '.(int)$parentId + ); + } + + /** + * Delete a category and all its child amenities. + * + * @param int $deleteId + * @return bool + */ + public function deleteHotelFeatures($deleteId) + { + $rows = Db::getInstance()->executeS( + 'SELECT `id` FROM `'._DB_PREFIX_.'htl_amenities` + WHERE `parent_feature_id` = '.(int)$deleteId.' OR `id` = '.(int)$deleteId + ); + + if ($rows) { + foreach ($rows as $row) { + $obj = new HotelAmenities((int)$row['id']); + $obj->delete(); + } + } + + return true; + } + + /** + * @param string $query + * @param int $idLang + * @return array|false + */ + public function searchByName($query, $idLang = false) + { + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + return Db::getInstance()->executeS( + 'SELECT ha.*, hal.* FROM `'._DB_PREFIX_.'htl_amenities` ha + LEFT JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal ON hal.`id` = ha.`id` + WHERE hal.`name` LIKE \'%'.pSQL($query).'%\' + AND hal.`id_lang` = '.(int)$idLang + ); + } + + /** + * Return image path for amenity logo stored in views/img/hotel_amenities/. + * + * @param int $id + * @return string + */ + public static function getAmenityImagePath($id) + { + return _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/'.(int)$id.'.jpg'; + } +} diff --git a/modules/hotelreservationsystem/classes/HotelBedType.php b/modules/hotelreservationsystem/classes/HotelBedType.php deleted file mode 100644 index ee5707eca..000000000 --- a/modules/hotelreservationsystem/classes/HotelBedType.php +++ /dev/null @@ -1,82 +0,0 @@ - 'htl_bed_type', - 'primary' => 'id_bed_type', - 'multilang' => true, - 'fields' => array( - 'length' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'), - 'width' => array('type' => self::TYPE_FLOAT, 'validate' => 'isUnsignedFloat'), - // lang fields - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128), - ), - ); - - public function getAllBedTypes($idLang) - { - if (!$this->hasLegacyBedTypeTables()) { - return array(); - } - - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - $sql = 'SELECT hbt.*, hbtl.`name` FROM `'._DB_PREFIX_.$this->table.'` hbt - LEFT JOIN `'._DB_PREFIX_.$this->table.'_lang` hbtl ON hbt.`id_bed_type` = hbtl.`id_bed_type` - WHERE 1 AND hbtl.`id_lang` ='.(int) $idLang; - - return Db::getInstance()->executeS($sql); - } - - public function delete() - { - if (!$this->hasLegacyBedTypeTables()) { - return true; - } - - $objHotelRoomTypeBedType = new HotelRoomTypeBedType(); - $objHotelRoomTypeBedType->deleteRoomTypeBedTypes($this->id); - - return parent::delete(); - } - - /** - * Checks whether the deprecated bed type schema still exists. - * - * @return bool - */ - protected function hasLegacyBedTypeTables() - { - return (bool) Db::getInstance()->getValue( - 'SHOW TABLES LIKE \'' . pSQL(_DB_PREFIX_.$this->table) . '\'' - ); - } -} diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 8bdbbfdeb..1fdc8a3aa 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1700,11 +1700,26 @@ class HotelBookingDetail extends ObjectModel if (!$only_search_data) { if (!empty($bookingData)) { foreach ($bookingData['rm_data'] as $key => $value) { - $product_feature = Product::getFrontFeaturesStatic($context->language->id, $value['id_product']); + // featured amenities for display in room type list + $product_feature = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' + SELECT ha.`id`, ha.`logo_type`, ha.`logo`, hal.`name` + FROM `'._DB_PREFIX_.'htl_room_type_amenities` hrta + INNER JOIN `'._DB_PREFIX_.'htl_amenities` ha ON ha.`id` = hrta.`amenity_id` + INNER JOIN `'._DB_PREFIX_.'htl_amenities_lang` hal + ON hal.`id` = hrta.`amenity_id` AND hal.`id_lang` = '.(int)$context->language->id.' + WHERE hrta.`id_product` = '.(int)$value['id_product'].' + AND ha.`is_featured` = 1 AND ha.`active` = 1 + ORDER BY ha.`position` ASC + '); + if (!$product_feature) { + $product_feature = array(); + } + // PS core features used by the amenities filter block $prod_amen = array(); if (!empty($amenities) && $amenities) { $prod_amen = $amenities; - foreach ($product_feature as $a_key => $a_val) { + $psFeatures = Product::getFrontFeaturesStatic($context->language->id, $value['id_product']); + foreach ($psFeatures as $a_val) { if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) { unset($prod_amen[$pa_key]); if (empty($prod_amen)) { diff --git a/modules/hotelreservationsystem/classes/HotelBranchAmenities.php b/modules/hotelreservationsystem/classes/HotelBranchAmenities.php new file mode 100644 index 000000000..10513ee98 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelBranchAmenities.php @@ -0,0 +1,70 @@ + 'htl_branch_amenities', + 'primary' => 'id', + 'fields' => array( + 'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'amenity_id' => array('type' => self::TYPE_INT), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), + ), + ); + + /** + * @param int $idHotel + * @return bool + */ + public function deleteBranchFeaturesByHotelId($idHotel) + { + return Db::getInstance()->delete('htl_branch_amenities', '`id_hotel` = '.(int)$idHotel); + } + + /** + * @param int $idHotel + * @param array $amenities array of amenity IDs + * @return bool + */ + public function assignFeaturesToHotel($idHotel, $amenities) + { + if ($amenities) { + foreach ($amenities as $amenityId) { + $obj = new HotelBranchAmenities(); + $obj->id_hotel = (int)$idHotel; + $obj->amenity_id = (int)$amenityId; + $obj->save(); + } + } + return true; + } +} diff --git a/modules/hotelreservationsystem/classes/HotelBranchFeatures.php b/modules/hotelreservationsystem/classes/HotelBranchFeatures.php deleted file mode 100644 index 9892de05d..000000000 --- a/modules/hotelreservationsystem/classes/HotelBranchFeatures.php +++ /dev/null @@ -1,69 +0,0 @@ - 'htl_branch_features', - 'primary' => 'id', - 'fields' => array( - 'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'feature_id' => array('type' => self::TYPE_STRING), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - )); - - /** - * [deleteBranchFeaturesByHotelId : For deleting features of a hotel by hotel id] - * @param [int] $idHotel [Hotel's id , which hotel's features to be deleted] - * @return [Boolean] [true if deleted or false if no deleted] - */ - public function deleteBranchFeaturesByHotelId($idHotel) - { - return Db::getInstance()->delete('htl_branch_features', '`id_hotel` = '.(int) $idHotel); - } - - /** - * [assignFeaturesToHotel : For assigning Hotel features to a hotel] - * @param [int] $idHotel [Hotel's id , To which features to be assigned] - * @param [Array] $features [array of features to be assigned to the hotel] - * @return [Boolean] [true] - */ - public function assignFeaturesToHotel($idHotel, $features) - { - if ($features) { - foreach ($features as $feature) { - $obj_htl_features = new HotelBranchFeatures(); - $obj_htl_features->id_hotel = $idHotel; - $obj_htl_features->feature_id = $feature; - $obj_htl_features->save(); - } - } - return true; - } -} diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index b4fb0ada8..19b5e6208 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -506,7 +506,7 @@ class HotelBranchInformation extends ObjectModel $sql = 'SELECT hbi.`id`, hbl.`hotel_name` FROM `'._DB_PREFIX_.'htl_branch_info` hbi LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hbl.`id` = hbi.`id` AND hbl.`id_lang` = '.(int)$idLang.') - WHERE hbi.`id` NOT IN (SELECT DISTINCT id_hotel FROM `'._DB_PREFIX_.'htl_branch_features`)'; + WHERE hbi.`id` NOT IN (SELECT DISTINCT id_hotel FROM `'._DB_PREFIX_.'htl_branch_amenities`)'; return Db::getInstance()->executeS($sql); } @@ -521,7 +521,7 @@ class HotelBranchInformation extends ObjectModel public function getFeaturesOfHotelByHotelId($id_hotel) { return Db::getInstance()->executeS( - 'SELECT feature_id FROM `'._DB_PREFIX_.'htl_branch_features` WHERE id_hotel='.(int)$id_hotel + 'SELECT amenity_id FROM `'._DB_PREFIX_.'htl_branch_amenities` WHERE id_hotel='.(int)$id_hotel ); } @@ -802,7 +802,7 @@ class HotelBranchInformation extends ObjectModel } } } - $objHotelfeatures = new HotelBranchFeatures(); + $objHotelfeatures = new HotelBranchAmenities(); $objHotelImage = new HotelImage(); if (!$objHotelfeatures->deleteBranchFeaturesByHotelId($idHotel)) { $contextController->errors[] = $this->moduleInstance->l( @@ -1007,8 +1007,8 @@ class HotelBranchInformation extends ObjectModel public function getWsHotelFeatures() { return Db::getInstance()->executeS( - 'SELECT `feature_id` as `id` FROM `'._DB_PREFIX_.'htl_branch_features` WHERE `id_hotel` = '.(int)$this->id. - ' ORDER BY `feature_id` ASC' + 'SELECT `amenity_id` as `id` FROM `'._DB_PREFIX_.'htl_branch_amenities` WHERE `id_hotel` = '.(int)$this->id. + ' ORDER BY `amenity_id` ASC' ); } @@ -1016,12 +1016,12 @@ class HotelBranchInformation extends ObjectModel public function setWsHotelFeatures($branchFeatures) { Db::getInstance()->execute(' - DELETE FROM `'._DB_PREFIX_.'htl_branch_features` + DELETE FROM `'._DB_PREFIX_.'htl_branch_amenities` WHERE `id_hotel` = '.(int)$this->id ); foreach ($branchFeatures as $feature) { - Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_branch_features` (`id_hotel`, `feature_id`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int)$feature['id'].', NOW(), NOW())'); + Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'htl_branch_amenities` (`id_hotel`, `amenity_id`, `date_add`, `date_upd`) VALUES ('.(int)$this->id.', '.(int)$feature['id'].', NOW(), NOW())'); } return true; diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index be3cabc94..9291255b8 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -1534,7 +1534,7 @@ class HotelCartBookingData extends ObjectModel $objCartBooking = new self(); $objRoomType = new HotelRoomType(); $objHotelBranch = new HotelBranchInformation(); - $objHtlFeatures = new HotelFeatures(); + $objHtlFeatures = new HotelAmenities(); $objCartBookingData = new HotelCartBookingData(); $objRoomDemands = new HotelRoomTypeDemand(); $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); @@ -1612,7 +1612,7 @@ class HotelCartBookingData extends ObjectModel if ($hotelFeaureIds = $objHotelBranch->getFeaturesOfHotelByHotelId($roomDetail['id_hotel'])) { $hotelFeatures = array(); foreach ($hotelFeaureIds as $value) { - $htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id']); + $htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['amenity_id']); if ($htlFeatureInfo = $objHtlFeatures->getFeatureInfoById($value['feature_id'])) { $hotelFeatures[] = $htlFeatureInfo['name']; } diff --git a/modules/hotelreservationsystem/classes/HotelFeatures.php b/modules/hotelreservationsystem/classes/HotelFeatures.php deleted file mode 100644 index dc219551b..000000000 --- a/modules/hotelreservationsystem/classes/HotelFeatures.php +++ /dev/null @@ -1,228 +0,0 @@ - 'htl_features', - 'primary' => 'id', - 'multilang' => true, - 'fields' => array( - 'parent_feature_id' => array('type' => self::TYPE_INT, 'required' => true), - 'position' => array('type' => self::TYPE_INT), - 'active' => array('type' => self::TYPE_INT, 'required' => true), - 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), - //lang fields - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'required' => true), - ) - ); - - protected $webserviceParameters = array( - 'objectsNodeName' => 'hotel_features', - 'objectNodeName' => 'hotel_feature', - 'fields' => array(), - ); - - public function delete() - { - if ($id = $this->id) { - if (Db::getInstance()->delete('htl_branch_features', '`feature_id` = '.(int) $id)) { - return parent::delete(); - } - } - return false; - } - - /** - * [getFeatureInfoById :: To get feature in formation by its id] - * @param [int] $id [description] - * @return [false | array] [Returns false if no data found otherwise returns array of the information of the - * feature] - */ - public function getFeatureInfoById($id, $idLang = 0) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - return Db::getInstance()->getRow( - 'SELECT hf.`id` , hfl.`name` - FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.') - WHERE hf.`id`='.(int) $id - ); - } - - /** - * [HotelAllCommonFeaturesArray :: To get array of all hotel features information according to parents feature and - * children features under parent feature] - * @return [boolean] [If data found returns array of all common features as parent then children under this parent] - */ - public function HotelAllCommonFeaturesArray($idLang = 0) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - $result = array(); - if ($parentFeatures = Db::getInstance()->executeS( - 'SELECT hf.`id`, hf.`position`, hfl.`name` - FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.') - WHERE hf.`parent_feature_id`=0 order by position' - )) { - foreach ($parentFeatures as $value) { - $result[$value['id']]['name'] = $value['name']; - $result[$value['id']]['id'] = $value['id']; - $result[$value['id']]['position'] = $value['position']; - if ($childFeatures = Db::getInstance()->executeS( - 'SELECT hf.`id`, hfl.`name` - FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.') - WHERE hf.`parent_feature_id`='.(int) $value['id'] - )) { - foreach ($childFeatures as $value1) { - $result[$value['id']]['children'][] = $value1; - } - } - } - } - if (!$result) { - return false; - } - return $result; - } - - /** - * [deleteHotelFeatures :: Deletes the feature which id is $deleteId and also delete all the child features which - * parent id is $deleteId] - * @param [int] $deleteId [id(primary_key) of the htl_features table] - * @return [boolean] [true if deleted otherwise false] - */ - public function deleteHotelFeatures($deleteId, $deleteOnlyChilds = 0) - { - $sql = 'SELECT `id` FROM `'._DB_PREFIX_.'htl_features` WHERE `parent_feature_id`='.(int) $deleteId; - - if (!$deleteOnlyChilds) { - $sql .= ' OR `id`='.(int) $deleteId; - } - if ($idsToDetele = Db::getInstance()->executeS($sql)) { - foreach ($idsToDetele as $value) { - $objHotelFeatures = new HotelFeatures($value['id']); - $objHotelFeatures->delete(); - } - } - return true; - } - - /** - * [HotelBranchSelectedFeaturesArray :: To get array of all hotel features information according to parents and - * children including which child features are selected for a hotel] - * @param [array] $htl_features [array containing information of the features of a hotel] - * @return [boolean] [If data found returns array of all common features as parent then children under this parent - * and also set an index in the array that defines whether the child feature is selected for the hotel or not] - */ - public function HotelBranchSelectedFeaturesArray($htl_features, $idLang = 0) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - $result = array(); - if ($parentFeatures = Db::getInstance()->executeS( - 'SELECT hf.`id`, hfl.`name` - FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.') - WHERE hf.`parent_feature_id`=0' - )) { - foreach ($parentFeatures as $value) { - $result[$value['id']]['name'] = $value['name']; - if ($childFeatures = Db::getInstance()->executeS( - 'SELECT hf.`id`, hfl.`name` - FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON (hfl.`id` = hf.`id` AND hfl.`id_lang` = '.(int)$idLang.') - WHERE hf.`parent_feature_id`='.(int) $value['id'] - )) { - foreach ($childFeatures as $value1) { - $flag =0; - if ($htl_features) { - foreach ($htl_features as $ftr) { - if ($value1['id'] == $ftr['feature_id']) { - $flag = 1; - } - } - } - if ($flag) { - $value1['selected'] = 1; - } else { - $value1['selected'] = 0; - } - - $result[$value['id']]['children'][] = $value1; - } - } - } - } - if (!$result) { - return false; - } - return $result; - } - - public function getChildFeaturesByParentFeatureId($parent_feature_id) - { - return Db::getInstance()->executeS( - 'SELECT `id` FROM `'._DB_PREFIX_.'htl_features` WHERE `parent_feature_id`='.(int)$parent_feature_id - ); - } - - public function updateHotelFeatureInfoByParentFeatureId($parent_feature_id, $update_params) - { - return Db::getInstance()->update('htl_features', $update_params, 'id='.(int) $parent_feature_id); - } - - public function searchByName($query, $idLang = false) - { - if (!$idLang) { - $idLang = Context::getContext()->language->id; - } - - return Db::getInstance()->executeS( - 'SELECT hf.*, hfl.* FROM `'._DB_PREFIX_.'htl_features` hf - LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl - ON hfl.`id` = hf.`id` - WHERE hfl.`name` LIKE \'%'.pSQL($query).'%\' - AND hfl.`id_lang`='.(int) $idLang - ); - } -} diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 28126125b..8f18f522c 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -977,9 +977,11 @@ class HotelHelper ); // lang fields $languages = Language::getLanguages(false); + $imgDir = dirname(__FILE__).'/../views/img/hotel_amenities/'; $i = 1; + $childCounter = 0; foreach ($parent_features_arr as $key => $value) { - $obj_feature = new HotelFeatures(); + $obj_feature = new HotelAmenities(); foreach ($languages as $lang) { if (isset($value['name'][$lang['iso_code']])) { $obj_feature->name[$lang['id_lang']] = $value['name'][$lang['iso_code']]; @@ -994,7 +996,8 @@ class HotelHelper $obj_feature->save(); $parent_feature_id = $obj_feature->id; foreach ($value['features'] as $val) { - $obj_feature = new HotelFeatures(); + ++$childCounter; + $obj_feature = new HotelAmenities(); foreach ($languages as $lang) { if (isset($val[$lang['iso_code']])) { $obj_feature->name[$lang['id_lang']] = $val[$lang['iso_code']]; @@ -1002,9 +1005,18 @@ class HotelHelper $obj_feature->name[$lang['id_lang']] = $val['en']; } } - $obj_feature->active = 1; + $obj_feature->active = 1; $obj_feature->parent_feature_id = $parent_feature_id; $obj_feature->save(); + + $srcImg = $imgDir.'_default/'.$childCounter.'.jpg'; + if (file_exists($srcImg)) { + if (ImageManager::resize($srcImg, $imgDir.$obj_feature->id.'.jpg')) { + $obj_feature->logo_type = 'image'; + $obj_feature->logo = $obj_feature->id.'.jpg'; + $obj_feature->save(); + } + } } ++$i; } @@ -1192,138 +1204,6 @@ class HotelHelper ); } - public function createHotelDefaultBedTypes() - { - $htlBedTypes = array( - array( - 'length' => '6.25', - 'width' => '3.16', - 'name' => array( - 'en' => 'Twin Bed', - 'nl' => 'Eenpersoonsbed', - 'fr' => 'Lit simple', - 'de' => 'Einzelbett', - 'ru' => 'Односпальная кровать', - 'es' => 'Cama individual', - ), - ), - array( - 'length' => '6.66', - 'width' => '3.16', - 'name' => array( - 'en' => 'Twin XL Bed', - 'nl' => 'Eenpersoonsbed XL', - 'fr' => 'Lit simple XL', - 'de' => 'Einzelbett XL', - 'ru' => 'Односпальная кровать XL', - 'es' => 'Cama individual XL', - ), - ), - array( - 'length' => '6.25', - 'width' => '4.5', - 'name' => array( - 'en' => 'Full Bed', - 'nl' => 'Tweepersoonsbed', - 'fr' => 'Lit double', - 'de' => 'Doppelbett', - 'ru' => 'Двуспальная кровать', - 'es' => 'Cama doble', - ), - ), - array( - 'length' => '6.66', - 'width' => '5', - 'name' => array( - 'en' => 'Queen Bed', - 'nl' => 'Queen size bed', - 'fr' => 'Lit Queen', - 'de' => 'Queen-Size-Bett', - 'ru' => 'Кровать Queen Size', - 'es' => 'Cama Queen', - ), - ), - array( - 'length' => '6.66', - 'width' => '6.33', - 'name' => array( - 'en' => 'King Bed', - 'nl' => 'King size bed', - 'fr' => 'Lit King', - 'de' => 'King-Size-Bett', - 'ru' => 'Кровать King Size', - 'es' => 'Cama King', - ), - ), - array( - 'length' => '7', - 'width' => '6', - 'name' => array( - 'en' => 'California King Bed', - 'nl' => 'California King bed', - 'fr' => 'Lit California King', - 'de' => 'California King-Bett', - 'ru' => 'Калифорнийская кровать King Size', - 'es' => 'Cama California King', - ), - ), - array( - 'length' => '6.25', - 'width' => '3.16', - 'name' => array( - 'en' => 'Bunk Bed', - 'nl' => 'Stapelbed', - 'fr' => 'Lit superposé', - 'de' => 'Etagenbett', - 'ru' => 'Двухъярусная кровать', - 'es' => 'Litera', - ), - ), - array( - 'length' => '6.25', - 'width' => '4.5', - 'name' => array( - 'en' => 'Sofa Bed', - 'nl' => 'Slaapbank', - 'fr' => 'Canapé-lit', - 'de' => 'Schlafsofa', - 'ru' => 'Диван-кровать', - 'es' => 'Sofá cama', - ), - ), - array( - 'length' => '6.66', - 'width' => '5', - 'name' => array( - 'en' => 'Murphy Bed', - 'nl' => 'Inklapbed', - 'fr' => 'Lit escamotable', - 'de' => 'Klappbett', - 'ru' => 'Откидная кровать', - 'es' => 'Cama abatible', - ), - ), - ); - - $languages = Language::getLanguages(true); - foreach ($htlBedTypes as $htlBedType) { - $objBedType = new HotelBedType(); - foreach ($languages as $lang) { - if (isset($htlBedType['name'][$lang['iso_code']])) { - $objBedType->name[$lang['id_lang']] = $htlBedType['name'][$lang['iso_code']]; - } else { - $objBedType->name[$lang['id_lang']] = $htlBedType['name']['en']; - } - - $objBedType->width = $htlBedType['width']; - $objBedType->length = $htlBedType['length']; - $objBedType->save(); - } - } - - return true; - } - public static function getPsProducts($id_lang, $start = 0, $limit = 0, $booking_product = null) { $sql = 'SELECT p.`id_product`, pl.`name`, p.`booking_product` @@ -1764,9 +1644,9 @@ class HotelHelper { $branch_ftr_ids = array(1, 2, 4, 7, 8, 9, 11, 12, 14, 16, 17, 18, 21); foreach ($branch_ftr_ids as $value_ftr) { - $htl_ftr_obj = new HotelBranchFeatures(); - $htl_ftr_obj->id_hotel = $id_hotel; - $htl_ftr_obj->feature_id = $value_ftr; + $htl_ftr_obj = new HotelBranchAmenities(); + $htl_ftr_obj->id_hotel = $id_hotel; + $htl_ftr_obj->amenity_id = $value_ftr; $htl_ftr_obj->save(); } } diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 86260185f..47f4ddcdf 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -91,37 +91,40 @@ class HotelReservationSystemDb PRIMARY KEY (`id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_branch_features` ( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_branch_amenities` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_hotel` int(10) unsigned NOT NULL, - `feature_id` int(10) unsigned NOT NULL, + `amenity_id` int(10) unsigned NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_features` ( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_room_type_amenities` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_product` int(10) unsigned NOT NULL, - `feature_id` int(10) unsigned NOT NULL, + `amenity_id` int(10) unsigned NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id`), KEY `id_product` (`id_product`), - KEY `feature_id` (`feature_id`) + KEY `amenity_id` (`amenity_id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features` ( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenities` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `parent_feature_id` int(10) unsigned NOT NULL, `position` int(10) unsigned NOT NULL, `active` int(2) NOT NULL DEFAULT '0', + `is_featured` tinyint(1) NOT NULL DEFAULT '0', + `logo_type` varchar(10) NOT NULL DEFAULT 'icon', + `logo` varchar(255) NOT NULL DEFAULT '', `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", - "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_features_lang` ( + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenities_lang` ( `id` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `name` varchar(255) NOT NULL, @@ -584,10 +587,10 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_branch_info`, `'._DB_PREFIX_.'htl_branch_info_lang`, `'._DB_PREFIX_.'htl_image`, - `'._DB_PREFIX_.'htl_branch_features`, - `'._DB_PREFIX_.'htl_room_type_features`, - `'._DB_PREFIX_.'htl_features`, - `'._DB_PREFIX_.'htl_features_lang`, + `'._DB_PREFIX_.'htl_branch_amenities`, + `'._DB_PREFIX_.'htl_room_type_amenities`, + `'._DB_PREFIX_.'htl_amenities`, + `'._DB_PREFIX_.'htl_amenities_lang`, `'._DB_PREFIX_.'htl_cart_booking_data`, `'._DB_PREFIX_.'htl_booking_detail`, `'._DB_PREFIX_.'htl_booking_document`, diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeBedType.php b/modules/hotelreservationsystem/classes/HotelRoomTypeBedType.php deleted file mode 100644 index 67c05c114..000000000 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeBedType.php +++ /dev/null @@ -1,124 +0,0 @@ - 'htl_room_type_bed_type', - 'primary' => 'id_room_type_bed_type', - 'fields' => array( - 'id_bed_type' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - ), - ); - - public function getRoomTypeBedTypes($idProduct) - { - if (!$this->hasLegacyBedTypeTable()) { - return array(); - } - - $sql = 'SELECT * FROM `'._DB_PREFIX_.$this->table.'` - WHERE `id_product` ='.(int) $idProduct; - - return Db::getInstance()->executeS($sql); - } - - public function updateRoomTypeBedTypes($idBedTypes, $idProduct) - { - if (!$this->hasLegacyBedTypeTable()) { - return true; - } - - $res = true; - if ($roomTypeBedTypes = $this->getRoomTypeBedTypes($idProduct)) { - $roomTypeBedTypes = array_column($roomTypeBedTypes, 'id_room_type_bed_type', 'id_bed_type'); - } - - if ($idBedTypes) { - foreach ($idBedTypes as $idBedType) { - // If room type bed type mapping already exits no need to update it. - if (isset($roomTypeBedTypes[$idBedType])) { - unset($roomTypeBedTypes[$idBedType]); - } else { - $objHotelRoomTypeBedType = new self(); - $objHotelRoomTypeBedType->id_product = $idProduct; - $objHotelRoomTypeBedType->id_bed_type = $idBedType; - $res &=$objHotelRoomTypeBedType->save(); - } - } - } - - // Removing the non selected bed types. - if ($roomTypeBedTypes) { - $res &= $this->deleteRoomTypeBedTypesById($roomTypeBedTypes); - } - - return $res; - } - - public function deleteRoomTypeBedTypesById($idRoomTypeBedTypes) - { - if (!$this->hasLegacyBedTypeTable()) { - return true; - } - - $res = true; - if ($idRoomTypeBedTypes) { - foreach ($idRoomTypeBedTypes as $idRoomTypeBedType) { - $objHotelRoomTypeBedType = new self($idRoomTypeBedType); - $res &= $objHotelRoomTypeBedType->delete(); - } - } - - return $res; - } - - public function deleteRoomTypeBedTypes($idBedType = false, $idProduct = false) - { - if (!$this->hasLegacyBedTypeTable()) { - return true; - } - - return Db::getInstance()->delete( - $this->table, - ' 1 '.($idBedType ? ' AND `id_bed_type`='.(int) $idBedType : '').($idProduct ? ' AND `id_product`='.(int) $idProduct : '') - ); - } - - /** - * Checks whether the deprecated room-type bed mapping table still exists. - * - * @return bool - */ - protected function hasLegacyBedTypeTable() - { - return (bool) Db::getInstance()->getValue( - 'SHOW TABLES LIKE \'' . pSQL(_DB_PREFIX_.$this->table) . '\'' - ); - } - -} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index a2b513676..d39082032 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -176,7 +176,7 @@ class AdminAddHotelController extends ModuleAdminController } $smartyVars['order_restrict_date_info'] = HotelOrderRestrictDate::getDataByHotelId($idHotel); - $objHotelFeatures = new HotelFeatures(); + $objHotelFeatures = new HotelAmenities(); $hotelFeatures = $this->object->getFeaturesOfHotelByHotelId($this->object->id); if ($features = $objHotelFeatures->HotelBranchSelectedFeaturesArray($hotelFeatures)) { foreach ($features as $idFeature => $feature) { @@ -802,7 +802,7 @@ class AdminAddHotelController extends ModuleAdminController $objHotelOrderRestrictDate->save(); - $objHotelFeatures = new HotelBranchFeatures(); + $objHotelFeatures = new HotelBranchAmenities(); $objHotelFeatures->deleteBranchFeaturesByHotelId($idHotel); if (!$objHotelFeatures->assignFeaturesToHotel($idHotel, $hotelFeatures)) { $this->errors[] = $this->l('Some problem occurred while assigning features to the hotel.'); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelAmenitiesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelAmenitiesController.php new file mode 100644 index 000000000..b7ce98843 --- /dev/null +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelAmenitiesController.php @@ -0,0 +1,355 @@ +bootstrap = true; + $this->table = 'htl_amenities'; + $this->className = 'HotelAmenities'; + $this->identifier = 'id'; + $this->toolbar_title = $this->l('Manage Amenities'); + + parent::__construct(); + + $this->display = 'view'; + } + + public function initToolbar() + { + parent::initToolbar(); + + if ($this->display == 'view') { + $this->page_header_toolbar_btn['add_category'] = array( + 'href' => self::$currentIndex.'&addhtl_amenities&token='.$this->token, + 'desc' => $this->l('Add new Amenity Category'), + 'imgclass' => 'new', + ); + } + } + + public function initContent() + { + if (Tools::isSubmit('addhtl_amenities') || Tools::isSubmit('updatehtl_amenities') + || Tools::isSubmit('addhtl_amenity_item') || Tools::isSubmit('updatehtl_amenity_item') + ) { + $this->display = 'edit'; + } + + $this->initTabModuleList(); + $this->initToolbar(); + $this->initPageHeaderToolbar(); + + if ($this->display == 'edit') { + $this->content = $this->renderForm(); + } else { + $this->content = $this->renderView(); + } + + $this->context->smarty->assign(array( + 'content' => $this->content, + 'url_post' => self::$currentIndex.'&token='.$this->token, + 'show_page_header_toolbar' => $this->show_page_header_toolbar, + 'page_header_toolbar_title' => $this->page_header_toolbar_title, + 'page_header_toolbar_btn' => $this->page_header_toolbar_btn, + )); + } + + public function renderView() + { + $obj = new HotelAmenities(); + $this->context->smarty->assign(array( + 'amenities_tree' => $obj->getAllAmenitiesTree(), + 'img_base_url' => $this->module->getPathUri().self::IMG_DIR, + 'current_index' => self::$currentIndex, + 'token' => $this->token, + 'admin_link' => Context::getContext()->link->getAdminLink('AdminHotelAmenities'), + )); + + return parent::renderView(); + } + + public function renderForm() + { + $languages = Language::getLanguages(false); + $defaultLang = (int)Configuration::get('PS_LANG_DEFAULT'); + $adminLink = Context::getContext()->link->getAdminLink('AdminHotelAmenities'); + + if (Tools::isSubmit('addhtl_amenity_item') || Tools::isSubmit('updatehtl_amenity_item')) { + $idAmenity = (int)Tools::getValue('id'); + $idCategory = (int)Tools::getValue('id_category'); + $amenity = array(); + + if ($idAmenity) { + $obj = new HotelAmenities($idAmenity); + if (Validate::isLoadedObject($obj)) { + $idCategory = (int)$obj->parent_feature_id; + $amenity = array( + 'id' => $obj->id, + 'parent_feature_id' => $idCategory, + 'active' => (int)$obj->active, + 'is_featured' => (int)$obj->is_featured, + 'logo_type' => $obj->logo_type, + 'logo' => $obj->logo, + 'name' => is_array($obj->name) ? $obj->name : array(), + ); + } + } + + $imgPath = $this->module->getLocalPath().self::IMG_DIR.$idAmenity.'.jpg'; + $imgUrl = ($idAmenity && file_exists($imgPath)) + ? $this->module->getPathUri().self::IMG_DIR.$idAmenity.'.jpg' + : false; + + $this->context->smarty->assign(array( + 'languages' => $languages, + 'default_lang_id' => $defaultLang, + 'amenity' => $amenity, + 'id_category' => $idCategory, + 'existing_img' => $imgUrl, + 'current_index' => self::$currentIndex, + 'token' => $this->token, + 'admin_link' => $adminLink, + )); + + return $this->context->smarty->createTemplate( + $this->module->getLocalPath().'views/templates/admin/hotel_amenities/helpers/form/amenity_form.tpl' + )->fetch(); + } + + // category form (add or edit) + $idCategory = (int)Tools::getValue('id'); + $category = array(); + + if ($idCategory) { + $obj = new HotelAmenities($idCategory); + if (Validate::isLoadedObject($obj)) { + $category = array( + 'id' => $obj->id, + 'position' => $obj->position, + 'name' => is_array($obj->name) ? $obj->name : array(), + ); + } + } + + $this->context->smarty->assign(array( + 'languages' => $languages, + 'default_lang_id' => $defaultLang, + 'category' => $category, + 'current_index' => self::$currentIndex, + 'token' => $this->token, + 'admin_link' => $adminLink, + )); + + return $this->context->smarty->createTemplate( + $this->module->getLocalPath().'views/templates/admin/hotel_amenities/helpers/form/category_form.tpl' + )->fetch(); + } + + public function postProcess() + { + if (Tools::isSubmit('submitHtlCategory')) { + $idCategory = (int)Tools::getValue('id'); + $pos = (int)Tools::getValue('position'); + $languages = Language::getLanguages(false); + $defaultLang = (int)Configuration::get('PS_LANG_DEFAULT'); + + if (!$pos || !Validate::isUnsignedInt($pos)) { + $this->errors[] = $this->l('Position is invalid.'); + } + + $nameDefault = trim(Tools::getValue('cat_name_'.$defaultLang)); + if (!$nameDefault) { + $this->errors[] = $this->l('Category name is required in default language.'); + } elseif (!Validate::isGenericName($nameDefault)) { + $this->errors[] = $this->l('Category name is invalid.'); + } + + if (count($this->errors)) { + $this->display = 'edit'; + return; + } + + $obj = $idCategory ? new HotelAmenities($idCategory) : new HotelAmenities(); + foreach ($languages as $lang) { + $val = trim(Tools::getValue('cat_name_'.$lang['id_lang'])); + $obj->name[$lang['id_lang']] = $val ?: $nameDefault; + } + $obj->parent_feature_id = 0; + $obj->position = $pos; + $obj->active = 1; + + if (!$obj->save()) { + $this->errors[] = $this->l('Error saving category.'); + $this->display = 'edit'; + return; + } + + Tools::redirectAdmin(self::$currentIndex.'&conf='.($idCategory ? 4 : 3).'&token='.$this->token); + return; + } + + if (Tools::isSubmit('submitHtlAmenityItem')) { + $idAmenity = (int)Tools::getValue('id'); + $idCategory = (int)Tools::getValue('id_category'); + $active = (int)Tools::getValue('active'); + $isFeatured = (int)Tools::getValue('is_featured'); + $logoType = Tools::getValue('logo_type'); + $languages = Language::getLanguages(false); + $defaultLang = (int)Configuration::get('PS_LANG_DEFAULT'); + + if (!$idCategory) { + $this->errors[] = $this->l('Category is required.'); + } + + $nameDefault = trim(Tools::getValue('amenity_name_'.$defaultLang)); + if (!$nameDefault) { + $this->errors[] = $this->l('Amenity name is required in default language.'); + } elseif (!Validate::isGenericName($nameDefault)) { + $this->errors[] = $this->l('Amenity name is invalid.'); + } + + $logoValue = ''; + if ($logoType === 'icon') { + $logoValue = trim(Tools::getValue('logo_icon')); + if (!$logoValue) { + $this->errors[] = $this->l('Icon class is required.'); + } elseif (!Validate::isGenericName(str_replace('-', ' ', $logoValue))) { + $this->errors[] = $this->l('Icon name is invalid.'); + } + } else { + $hasUpload = isset($_FILES['logo_image']) && !empty($_FILES['logo_image']['tmp_name']); + $hasExisting = $idAmenity && file_exists($this->module->getLocalPath().self::IMG_DIR.$idAmenity.'.jpg'); + if (!$hasUpload && !$hasExisting) { + $this->errors[] = $this->l('Please upload an image for this amenity.'); + } + } + + if (count($this->errors)) { + $this->display = 'edit'; + return; + } + + $obj = $idAmenity ? new HotelAmenities($idAmenity) : new HotelAmenities(); + foreach ($languages as $lang) { + $val = trim(Tools::getValue('amenity_name_'.$lang['id_lang'])); + $obj->name[$lang['id_lang']] = $val ?: $nameDefault; + } + $obj->parent_feature_id = $idCategory; + $obj->active = $active; + $obj->is_featured = $isFeatured; + $obj->logo_type = ($logoType === 'icon') ? 'icon' : 'image'; + $obj->logo = ($logoType === 'icon') ? $logoValue : $obj->logo; + + if (!$obj->save()) { + $this->errors[] = $this->l('Error saving amenity.'); + $this->display = 'edit'; + return; + } + + if ($logoType === 'icon') { + $imgFile = $this->module->getLocalPath().self::IMG_DIR.$obj->id.'.jpg'; + if (file_exists($imgFile)) { + unlink($imgFile); + } + } + + if ($logoType === 'image' && isset($_FILES['logo_image']) && $_FILES['logo_image']['tmp_name']) { + $imgFile = $_FILES['logo_image']; + if ($error = ImageManager::validateUpload($imgFile, Tools::getMaxUploadSize())) { + $this->errors[] = $error; + } else { + $imgDir = $this->module->getLocalPath().self::IMG_DIR; + if (!is_dir($imgDir)) { + mkdir($imgDir, 0755, true); + } + if (ImageManager::resize($imgFile['tmp_name'], $imgDir.$obj->id.'.jpg')) { + $obj->logo = $obj->id.'.jpg'; + $obj->save(); + } else { + $this->errors[] = $this->l('Error uploading amenity image.'); + } + } + } + + if (count($this->errors)) { + $this->display = 'edit'; + return; + } + + Tools::redirectAdmin(self::$currentIndex.'&conf='.($idAmenity ? 4 : 3).'&token='.$this->token); + return; + } + + if (empty($this->errors)) { + parent::postProcess(); + } + } + + public function ajaxProcessDeleteCategory() + { + $response = array('status' => false); + + if ($this->tabAccess['delete']) { + $obj = new HotelAmenities(); + if ($obj->deleteHotelFeatures((int)Tools::getValue('id_category'))) { + $response['status'] = true; + } else { + $response['msg'] = $this->l('Error deleting category.'); + } + } else { + $response['msg'] = $this->l('You do not have permission to delete.'); + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessDeleteAmenityItem() + { + $response = array('status' => false); + + if ($this->tabAccess['delete']) { + $obj = new HotelAmenities((int)Tools::getValue('id_amenity')); + if (Validate::isLoadedObject($obj) && $obj->delete()) { + $response['status'] = true; + } else { + $response['msg'] = $this->l('Error deleting amenity.'); + } + } else { + $response['msg'] = $this->l('You do not have permission to delete.'); + } + + $this->ajaxDie(json_encode($response)); + } + + public function setMedia() + { + parent::setMedia(); + $this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js'); + $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'); + } +} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php deleted file mode 100644 index 85133052a..000000000 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php +++ /dev/null @@ -1,235 +0,0 @@ -bootstrap = true; - $this->table = 'htl_bed_type'; - $this->className = 'HotelBedType'; - $this->identifier = 'id_bed_type'; - $this->context = Context::getContext(); - $this->lang = true; - - parent::__construct(); - - $this->_new_list_header_design = true; - // field options for global fields - $this->fields_options = array( - 'global' => array( - 'title' => $this->l('Dimension Unit Setting'), - 'icon' => 'icon-cogs', - 'fields' => array( - 'WK_DIMENSION_UNIT' => array( - 'title' => $this->l('Dimension Unit'), - 'type' => 'textLang', - 'lang' => true, - 'required' => true, - 'validation' => 'isGenericName', - 'hint' => $this->l('Enter a dimension unit for the bed types.') - ), - ), - 'submit' => array('title' => $this->l('Save')) - ), - ); - - $this->addRowAction('edit'); - $this->addRowAction('delete'); - $this->bulk_actions = array( - 'delete' => array( - 'text' => $this->l('Delete selected'), - 'confirm' => $this->l('Delete selected items?'), - 'icon' => 'icon-trash' - ) - ); - } - - public function initContent() - { - parent::initContent(); - // to customize the view as per our requirements - if ($this->display != 'add' && $this->display != 'edit') { - $this->content = $this->renderOptions(); - $this->content .= $this->renderList(); - $this->context->smarty->assign('content', $this->content); - } - } - - public function initPageHeaderToolbar() - { - if (!$this->display || $this->display == 'list') { - $this->page_header_toolbar_btn['new_product'] = array( - 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, - 'desc' => $this->l('Add new', null, null, false), - 'icon' => 'process-icon-new' - ); - } - - parent::initPageHeaderToolbar(); - } - - public function initToolbar() - { - $this->toolbar_btn = array(); - } - - public function renderList() - { - // added here instead of the constructor since the dimension unit will be update afer post processs. - $this->fields_list = array( - 'id_bed_type' => array( - 'title' => $this->l('ID'), - 'align' => 'center', - ), - 'name' => array( - 'title' => $this->l('Name'), - 'align' => 'center', - ), - 'width' => array( - 'title' => $this->l('Width'), - 'align' => 'center', - 'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id) - ), - 'length' => array( - 'title' => $this->l('Lenght'), - 'align' => 'center', - 'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id) - ), - ); - return parent::renderList(); - } - - public function renderForm() - { - if (!$this->loadObject(true)) { - return; - } - - $this->fields_form = array( - 'legend' => array( - 'title' => $this->l('Bed Type'), - 'icon' => 'icon-bed' - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Bed Type Name'), - 'name' => 'name', - 'required' => true, - 'col' => 4, - 'lang' => true, - 'hint' => $this->l('Enter the name of Bed type.') - ), - array( - 'type' => 'text', - 'label' => $this->l('Width'), - 'name' => 'width', - 'required' => true, - 'col' => 4, - 'hint' => $this->l('Enter the width of the Bed type in ').Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id), - 'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id), - ), - array( - 'type' => 'text', - 'label' => $this->l('Length'), - 'name' => 'length', - 'col' => 4, - 'required' => true, - 'hint' => $this->l('Enter the length of the Bed type in ').Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id), - 'suffix' => Configuration::get('WK_DIMENSION_UNIT', $this->context->language->id), - ), - ), - 'submit' => array( - 'title' => $this->l('Save') - ), - 'buttons' => array( - 'save-and-stay' => array( - 'title' => $this->l('Save and stay'), - 'name' => 'submitAdd'.$this->table.'AndStay', - 'type' => 'submit', - 'class' => 'btn btn-default pull-right', - 'icon' => 'process-icon-save', - ), - ), - ); - - return parent::renderForm(); - } - - public function beforeUpdateOptions() - { - $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); - $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); - $languages = Language::getLanguages(false); - if (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId)) - && Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId) - ) { - $this->errors[] = $this->l('Default dimension unit is required at least in ').$objDefaultLanguage['name']; - } else { - foreach ($languages as $lang) { - if (Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']) - && (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang'])) - || !Validate::isGenericName(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']))) - ) { - $this->errors[] = $this->l('Invalid dimension unit in ').$lang['name']; - } - - if (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']))) { - $_POST['WK_DIMENSION_UNIT_'.$lang['id_lang']] = Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId); - } - } - } - } - - public function processSave() - { - if (!$this->loadObject(true)) { - return; - } - - $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); - $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); - $languages = Language::getLanguages(false); - if (!trim(Tools::getValue('name_'.$defaultLangId))) { - $this->errors[] = $this->l('Bed type name is required at least in ').$objDefaultLanguage['name']; - } else { - foreach ($languages as $lang) { - if (trim(Tools::getValue('name_'.$lang['id_lang'])) && !Validate::isGenericName(Tools::getValue('name_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid bed type name in ').$lang['name']; - } - } - } - - if (!(float) Tools::getValue('width')) { - $this->errors[] = $this->l('The width field is required'); - } - - if (!(float) Tools::getValue('length')) { - $this->errors[] = $this->l('The length field is required'); - } - - return parent::processSave(); - } - -} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php deleted file mode 100644 index 994511b33..000000000 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php +++ /dev/null @@ -1,321 +0,0 @@ -bootstrap = true; - $this->table = 'htl_features'; - $this->className = 'HotelFeatures'; - $this->identifier = 'id'; - $this->toolbar_title = $this->l('Manage Hotel Features'); - - parent::__construct(); - $this->display = 'view'; - } - - public function initToolbar() - { - parent::initToolbar(); - - $this->page_header_toolbar_btn['addfeatures'] = array( - 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token, - 'desc' => $this->l('Add new Features'), - 'imgclass' => 'new' - ); - } - - public function renderView() - { - $objHotelFeatures = new HotelFeatures(); - $featuresList = $objHotelFeatures->HotelAllCommonFeaturesArray(); - $this->context->smarty->assign('features_list', $featuresList); - return parent::renderView(); - } - - public function renderForm() - { - if (!$this->loadObject(true)) { - return; - } - - $smartyVars = array(); - //lang vars - $languages = Language::getLanguages(false); - $currentLangId = $this->default_form_language ? $this->default_form_language : Configuration::get('PS_LANG_DEFAULT'); - $currentLang = Language::getLanguage((int) $currentLangId); - $smartyVars['languages'] = $languages; - $smartyVars['currentLang'] = $currentLang; - $smartyVars['ps_img_dir'] = _PS_IMG_.'l/'; - if ($id = $this->object->id) { - $smartyVars['edit'] = 1; - if (Validate::isLoadedObject($objFeatures = new HotelFeatures($id))) { - $featureInfo = (array) $objFeatures; - if ($childFeatures = $objFeatures->getChildFeaturesByParentFeatureId($id)) { - $featureInfo['child_features'] = array(); - foreach ($childFeatures as $value) { - $objChildFeatures = new HotelFeatures($value['id']); - $featureInfo['child_features'][] = (array) $objChildFeatures; - } - } - $smartyVars['featureInfo'] = $featureInfo; - } - } - $this->context->smarty->assign($smartyVars); - Media::addJsDef( - array( - 'currentLang' => $currentLang, - 'languages' => $languages, - 'img_dir_l' => _PS_IMG_.'l/', - ) - ); - $this->fields_form = array( - 'submit' => array( - 'title' => $this->l('Save') - ) - ); - return parent::renderForm(); - } - - public function postProcess() - { - if (!$this->loadObject(true)) { - return; - } - - if (Tools::isSubmit('submitHtlFeatures') || Tools::isSubmit('submitHtlFeaturesAndStay')) { - $conf = 3; - if ($parentFeatureId = Tools::getValue('id')) { - $conf = 4; - } - - $pos = Tools::getValue('position'); - - $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); - $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); - $languages = Language::getLanguages(false); - - if (empty($pos) || !Validate::isUnsignedInt($pos)) { - $this->errors[] = $this->l('Position is Invalid.'); - } - - if (!trim(Tools::getValue('parent_ftr_name_'.$defaultLangId))) { - $this->errors[] = $this->l('Parent feature name is required at least in '). - $objDefaultLanguage['name']; - } elseif (!Validate::isGenericName(Tools::getValue('parent_ftr_name_'.$defaultLangId))) { - $this->errors[] = $this->l('Parent feature name is invalid.'); - } else { - foreach ($languages as $lang) { - // validate non required fields - if (trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) { - if (!Validate::isGenericName(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid parent feature name in ').$lang['name']; - } - } - } - } - if ($childFeaturesDefLang = Tools::getValue('child_features_'.$defaultLangId)) { - foreach ($childFeaturesDefLang as $kChild => $childftr) { - if (!trim($childftr)) { - $this->errors[] = $this->l('Child features name is required at least in '). - $objDefaultLanguage['name']; - } elseif (!Validate::isGenericName($childftr)) { - $this->errors[] = $this->l('Child features name is invalid : ').$childftr; - } else { - foreach ($languages as $lang) { - if ($childFtrLang = Tools::getValue('child_features_'.$lang['id_lang'])) { - if (!Validate::isGenericName($childFtrLang[$kChild])) { - $this->errors[] = $this->l('Invalid child feature name in ').$lang['name']. - ' : '.$childFtrLang[$kChild]; - } - } - } - } - } - } else { - $this->errors[] = $this->l('Please add atleast one Child features.'); - } - - if (!count($this->errors)) { - if (isset($parentFeatureId) && $parentFeatureId) { - $objHotelFeatures = new HotelFeatures($parentFeatureId); - $childFeatureIds = Tools::getValue('child_feature_id'); - foreach ($languages as $lang) { - if (!trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'parent_ftr_name_'.$defaultLangId - ); - } else { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'parent_ftr_name_'.$lang['id_lang'] - ); - } - } - $objHotelFeatures->active = 1; - $objHotelFeatures->position = $pos; - $objHotelFeatures->parent_feature_id = 0; - $objHotelFeatures->save(); - - if ($childFeaturesDefLang) { - // get previous child features of the parent feature - if ($childFeaturesInfo = $objHotelFeatures->getChildFeaturesByParentFeatureId( - $parentFeatureId - )) { - $prevChildIds = array(); - foreach ($childFeaturesInfo as $row) { - $prevChildIds[] = $row['id']; - } - } - $usedFeatures = array(); - foreach ($childFeaturesDefLang as $key => $childftr) { - $objHotelFeatures = new HotelFeatures(); - // We will only create new child features other wise edit the previous child feature - if ($prevChildIds - && isset($childFeatureIds[$key]) - && in_array($childFeatureIds[$key], $prevChildIds) - ) { - $objHotelFeatures = new HotelFeatures($childFeatureIds[$key]); - // enter child feature id in the used child feature - $usedFeatures[] = $childFeatureIds[$key]; - } - foreach ($languages as $lang) { - if (!trim(Tools::getValue('child_features_'.$lang['id_lang'])[$key])) { - $objHotelFeatures->name[$lang['id_lang']] = $childftr; - } else { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'child_features_'.$lang['id_lang'] - )[$key]; - } - } - $objHotelFeatures->active = 1; - $objHotelFeatures->parent_feature_id = $parentFeatureId; - $objHotelFeatures->save(); - } - // delete the child features which are not used now - $notUsedChilds = array_diff($prevChildIds, $usedFeatures); - if ($notUsedChilds = array_diff($prevChildIds, $usedFeatures)) { - foreach ($notUsedChilds as $value) { - if ($value) { - $objHotelFeatures = new HotelFeatures($value); - $objHotelFeatures->delete(); - } - } - } - if (Tools::isSubmit('submitHtlFeaturesAndStay')) { - Tools::redirectAdmin( - self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table. - '&conf='.$conf.'&token='.$this->token - ); - } else { - Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token); - } - } else { - $this->errors[] = $this->l('Some error has been occurred while saving features.'); - } - } else { - $objHotelFeatures = new HotelFeatures(); - foreach ($languages as $lang) { - if (!trim(Tools::getValue('parent_ftr_name_'.$lang['id_lang']))) { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'parent_ftr_name_'.$defaultLangId - ); - } else { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'parent_ftr_name_'.$lang['id_lang'] - ); - } - } - $objHotelFeatures->active = 1; - $objHotelFeatures->position = $pos; - $objHotelFeatures->parent_feature_id = 0; - $objHotelFeatures->save(); - if ($parentFeatureId = $objHotelFeatures->id) { - if ($childFeaturesDefLang) { - foreach ($childFeaturesDefLang as $key => $childftr) { - $objHotelFeatures = new HotelFeatures(); - foreach ($languages as $lang) { - if (!trim(Tools::getValue('child_features_'.$lang['id_lang'])[$key])) { - $objHotelFeatures->name[$lang['id_lang']] = $childftr; - } else { - $objHotelFeatures->name[$lang['id_lang']] = Tools::getValue( - 'child_features_'.$lang['id_lang'] - )[$key]; - } - } - $objHotelFeatures->active = 1; - $objHotelFeatures->parent_feature_id = $parentFeatureId; - $objHotelFeatures->save(); - } - if (Tools::isSubmit('submitHtlFeaturesAndStay')) { - Tools::redirectAdmin( - self::$currentIndex.'&id='.(int) $parentFeatureId.'&update'.$this->table. - '&conf='.$conf.'&token='.$this->token - ); - } else { - Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token); - } - } - } else { - $this->errors[] = $this->l('Some error has been occurred while saving features.'); - } - } - } - if ($parentFeatureId) { - $this->display = 'edit'; - } else { - $this->display = 'add'; - } - } - - if (empty($this->errors) || $this->ajax) { - parent::postProcess(); - } - } - - public function ajaxProcessDeleteFeature() - { - $response = array('status' => false); - if ($this->tabAccess['delete']) { - $idFeature = Tools::getValue('feature_id'); - $objHotelFeatures = new HotelFeatures(); - if ($objHotelFeatures->deleteHotelFeatures($idFeature)) { - $response['status'] = true; - } else { - $response['msg'] = $this->l('Some error occurred while deleting feature. Please try again.'); - } - } else { - $response['msg'] = $this->l('You do not have the permission to delete this.'); - } - - $this->ajaxDie(json_encode($response)); - } - - public function setMedia() - { - parent::setMedia(); - - $this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js'); - $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'); - } -} diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index e8a7cc909..ed624dc4a 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -26,8 +26,8 @@ require_once 'classes/HotelRoomType.php'; require_once 'classes/HotelRoomInformation.php'; require_once 'classes/HotelBranchInformation.php'; require_once 'classes/HotelImage.php'; -require_once 'classes/HotelFeatures.php'; -require_once 'classes/HotelBranchFeatures.php'; +require_once 'classes/HotelAmenities.php'; +require_once 'classes/HotelBranchAmenities.php'; require_once 'classes/HotelBookingDetail.php'; require_once 'classes/HotelCartBookingData.php'; require_once 'classes/HotelAdvancedPayment.php'; @@ -47,8 +47,6 @@ require_once 'classes/HotelRoomTypeRestrictionDateRange.php'; require_once 'classes/HotelRoomDisableDates.php'; require_once 'classes/HotelBranchRefundRules.php'; -require_once 'classes/HotelBedType.php'; -require_once 'classes/HotelRoomTypeBedType.php'; // linked products require_once 'classes/RoomTypeServiceProduct.php'; diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index e93e65719..404d3a665 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -48,7 +48,7 @@ class HotelReservationSystem extends Module $resources = array( 'hotels' => array('description' => 'Hotel Branch Information','class' => 'HotelBranchInformation'), 'hotel_room_types' => array('description' => 'Hotel room types','class' => 'HotelRoomType'), - 'hotel_features' => array('description' => 'The hotel features','class' => 'HotelFeatures'), + 'hotel_amenities' => array('description' => 'The hotel amenities', 'class' => 'HotelAmenities'), 'hotel_refund_rules' => array('description' => 'The hotel refund rules','class' => 'HotelOrderRefundRules'), 'hotel_rooms' => array('description' => 'The hotel rooms','class' => 'HotelRoomInformation'), 'feature_prices' => array('description' => 'Feature prices', 'class' => 'HotelRoomTypeFeaturePricing'), @@ -507,7 +507,7 @@ class HotelReservationSystem extends Module $langTables = array( 'htl_room_type_feature_pricing', 'htl_branch_info', - 'htl_features', + 'htl_amenities', 'htl_room_type_global_demand', 'htl_room_type_global_demand_advance_option', 'htl_order_refund_rules', @@ -553,7 +553,7 @@ class HotelReservationSystem extends Module $this->installTab('AdminHotelReservationSystemManagement', 'Hotel Reservation System'); $this->installTab('AdminAddHotel', 'Manage Hotel', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminHotelRoomsBooking', 'Book Now', 'AdminHotelReservationSystemManagement'); - $this->installTab('AdminHotelFeatures', 'Manage Amenities', 'AdminHotelReservationSystemManagement'); + $this->installTab('AdminHotelAmenities', 'Manage Amenities', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminOrderRefundRules', 'Manage Order Refund Rules', 'AdminHotelReservationSystemManagement'); $this->installTab('AdminOrderRefundRequests', 'Manage Order Refund Requests', 'AdminHotelReservationSystemManagement'); diff --git a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/index.php b/modules/hotelreservationsystem/views/img/hotel_amenities/index.php similarity index 100% rename from modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/index.php rename to modules/hotelreservationsystem/views/img/hotel_amenities/index.php diff --git a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl deleted file mode 100644 index c5b09363c..000000000 --- a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/form/form.tpl +++ /dev/null @@ -1,102 +0,0 @@ -{* -* NOTICE OF LICENSE -* -* This source file is subject to the Open Software License version 3.0 -* that is bundled with this package in the file LICENSE.md -* It is also available through the world-wide-web at this URL: -* https://opensource.org/license/osl-3-0-php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to support@qloapps.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to a newer -* versions in the future. If you wish to customize this module for your needs -* please refer to https://store.webkul.com/customisation-guidelines for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul -* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 -*} - -
- {if isset($edit)} - - {/if} -
-
- {l s='Assign Features' mod='hotelreservationsystem'} -
- {if isset($hotels) && $hotels} -
-
- {if isset($edit)} - - - {else} - -
- -
- {/if} -
-
- {if isset($features_list) && $features_list} - {assign var=i value=1} - {foreach from=$features_list item=value} -
-
-   {l s={$value.name} mod='hotelreservationsyatem'} -
- - - {if isset($value.children) && $value.children} - {foreach from=$value.children item=val} - - - - - {/foreach} - {/if} - -
- {l s={$val.name} mod='hotelreservationsyatem'} - - -
-
-
-
- {assign var=i value=$i+1} - {/foreach} - {/if} - - {else} -
- {l s='No hotel found to assign features.' mod='hotelreservationsystem'} -
- {/if} -
-
\ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/amenity_form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/amenity_form.tpl new file mode 100644 index 000000000..b60014ae2 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/amenity_form.tpl @@ -0,0 +1,218 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +
+
+ {if isset($amenity.id) && $amenity.id} + {l s='Edit Amenity' mod='hotelreservationsystem'} + {else} + {l s='Add New Amenity' mod='hotelreservationsystem'} + {/if} +
+
+
+ + + {if isset($amenity.id) && $amenity.id} + + + {else} + + {/if} + +
+ +
+ {if $languages|count > 1} +
+ {/if} + {foreach from=$languages item=language} + {if $languages|count > 1} +
+
+ {/if} + + {if $languages|count > 1} +
+
+ + +
+
+ {/if} + {/foreach} + {if $languages|count > 1} +
+ {/if} +
+
+ +
+ +
+ + + + + + + +
+
+ +
+ +
+ + + + + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ {if $existing_img} +
+ +
+ {/if} + +
+ + + + + +
+

+ {l s='Please upload a square image. Accepted formats: JPG, PNG, GIF.' mod='hotelreservationsystem'} +

+
+
+ +
+ +
+ +

+ {l s='Refer to the following link for available icons:' mod='hotelreservationsystem'} + https://fontawesome.com/v4/cheatsheet
+ {l s='Note: Replace fa- with icon- in icon name. Example: fa-wifi becomes icon-wifi.' mod='hotelreservationsystem'} +

+
+
+ + +
+
+
+ + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/category_form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/category_form.tpl new file mode 100644 index 000000000..c27743253 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/category_form.tpl @@ -0,0 +1,104 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +
+
+ {if isset($category.id) && $category.id} + {l s='Edit Amenity Category' mod='hotelreservationsystem'} + {else} + {l s='Add New Amenity Category' mod='hotelreservationsystem'} + {/if} +
+
+
+ + {if isset($category.id) && $category.id} + + + {else} + + {/if} + +
+ +
+ {if $languages|count > 1} +
+ {/if} + {foreach from=$languages item=language} + {if $languages|count > 1} +
+
+ {/if} + + {if $languages|count > 1} +
+
+ + +
+
+ {/if} + {/foreach} + {if $languages|count > 1} +
+ {/if} +
+
+ +
+ +
+ +
+
+ + +
+
+
diff --git a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/index.php similarity index 100% rename from modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/helpers/index.php rename to modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/form/index.php diff --git a/modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/index.php similarity index 100% rename from modules/hotelreservationsystem/views/templates/admin/assign_hotel_features/index.php rename to modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/index.php diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/form/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/view/index.php similarity index 100% rename from modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/form/index.php rename to modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/view/index.php diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/view/view.tpl new file mode 100644 index 000000000..ff47720e2 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/helpers/view/view.tpl @@ -0,0 +1,175 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} + +
+
+ {l s='Manage Amenities' mod='hotelreservationsystem'} +
+
+ {if $amenities_tree} + {foreach from=$amenities_tree item=category} +
+
+ +
+ {if isset($category.children) && $category.children} + + + + + + + + + + + {foreach from=$category.children item=amenity} + + + + + + + {/foreach} + +
{l s='Logo' mod='hotelreservationsystem'}{l s='Name' mod='hotelreservationsystem'}{l s='Active' mod='hotelreservationsystem'}{l s='Actions' mod='hotelreservationsystem'}
+ {if $amenity.logo_type == 'icon' && $amenity.logo} + + {elseif $amenity.logo_type == 'image' && $amenity.logo} + {$amenity.name|escape:'htmlall':'UTF-8'} + {else} + — + {/if} + {$amenity.name|escape:'htmlall':'UTF-8'} + + + + + + + {l s='Edit' mod='hotelreservationsystem'} + + +
+ {else} +
+ {l s='No amenities found in this category.' mod='hotelreservationsystem'} + + {l s='Add the first amenity.' mod='hotelreservationsystem'} + +
+ {/if} +
+
+
+ {/foreach} + {else} +
+
+ {l s='No amenity categories found. Start by adding a new category.' mod='hotelreservationsystem'} +
+
+ {/if} +
+
+ +{strip} + {addJsDef delete_url=$admin_link js=1 mod='hotelreservationsystem'} + {addJsDefL name=confirm_delete_msg}{l s='Are you sure you want to delete this? This action cannot be undone.' js=1 mod='hotelreservationsystem'}{/addJsDefL} + {addJsDefL name=error_delete_msg}{l s='An error occurred while deleting. Please try again.' js=1 mod='hotelreservationsystem'}{/addJsDefL} +{/strip} + + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_amenities/index.php similarity index 100% rename from modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/index.php rename to modules/hotelreservationsystem/views/templates/admin/hotel_amenities/index.php diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/form/form.tpl deleted file mode 100644 index 00093b80b..000000000 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/form/form.tpl +++ /dev/null @@ -1,149 +0,0 @@ -{* -* NOTICE OF LICENSE -* -* This source file is subject to the Open Software License version 3.0 -* that is bundled with this package in the file LICENSE.md -* It is also available through the world-wide-web at this URL: -* https://opensource.org/license/osl-3-0-php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to support@qloapps.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to a newer -* versions in the future. If you wish to customize this module for your needs -* please refer to https://store.webkul.com/customisation-guidelines for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul -* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 -*} - -
-
- {if isset($edit) && $edit} -   {l s='Edit Features' mod='hotelreservationsystem'} - {else} -   {l s='Add New Features' mod='hotelreservationsystem'} - {/if} -
-
-
- {if count($languages) > 1} -
- - - - -

{l s='Change language for updating information in multiple language.' mod='hotelreservationsystem'}

-
-
- {/if} -
- -
- {if isset($edit)} - - {/if} - {foreach from=$languages item=language} - {assign var="parent_ftr_name" value="parent_ftr_name_`$language.id_lang`"} - - {/foreach} -
-
-
- -
- -

-
-
-
- -
- -

-
-
- -
-
-
- {if isset($edit) && $edit && isset($featureInfo.child_features) && $featureInfo.child_features} - {foreach from=$featureInfo.child_features item=child_feature} -
- -
- - {foreach from=$languages item=language} - - {/foreach} -
-
- - - -
-
- {/foreach} - {/if} -
-
- - -
- - -{strip} - {addJsDefL name=prnt_ftr_err}{l s='Enter Parent feature name first.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=chld_ftr_err}{l s='Enter at least one child feature.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=chld_ftr_text_err}{l s='Enter child feature name.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=pos_numeric_err}{l s='Position should be numeric.' js=1 mod='hotelreservationsystem'}{/addJsDefL} -{/strip} - -{block name=script} - -{/block} diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/view/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/view/index.php deleted file mode 100644 index 409280877..000000000 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_features/helpers/view/index.php +++ /dev/null @@ -1,32 +0,0 @@ - -
- {l s='Hotel Features' mod='hotelreservationsystem'} -
-
-
- {if $features_list} - {foreach from=$features_list item=value} -
-
-
-
-
- {l s={$value.name} mod='hotelreservationsyatem'} -     {l s='Edit' mod='hotelreservationsystem'} - -
-
-
-
-
-
- {if isset($value.children) && $value.children} - {foreach from=$value.children item=val} -

{l s={$val.name} mod='hotelreservationsyatem'}

- {/foreach} - {/if} -
-
-
- {/foreach} - {else} -
- {l s='No hotel features found. Start adding new features for the hotels.' mod='hotelreservationsystem'} -
- {/if} -
-
- -{strip} - {addJsDef delete_url=$link->getAdminLink('AdminHotelFeatures') js=1 mod='hotelreservationsystem'} - {addJsDefL name=success_delete_msg}{l s='Successfully Deleted.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=error_delete_msg}{l s='Some error occured while deleting feature.Please try again.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=no_feature_warning_txt}{l s='No hotel features found. Start adding new features for the hotels.' js=1 mod='hotelreservationsystem'}{/addJsDefL} - {addJsDefL name=confirm_delete_msg}{l s='Are you sure?' js=1 mod='hotelreservationsystem'}{/addJsDefL} -{/strip} \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_features/index.php b/modules/hotelreservationsystem/views/templates/admin/hotel_features/index.php deleted file mode 100644 index 409280877..000000000 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_features/index.php +++ /dev/null @@ -1,32 +0,0 @@ - {foreach from=$room_v['feature'] key=feat_k item=feat_v} - + {if $feat_v.logo_type == 'icon' && $feat_v.logo} + + {elseif $feat_v.logo_type == 'image' && $feat_v.logo} + + {/if} {/foreach}

{/if} diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl index 562206408..55eeb661d 100644 --- a/themes/hotel-reservation-theme/product.tpl +++ b/themes/hotel-reservation-theme/product.tpl @@ -280,15 +280,47 @@ {/block} {* Block for booking products *} {if isset($id_hotel) && $id_hotel} - {block name='product_info_tab_hotel_features'} + {block name='product_info_tab_room_amenities'} {if isset($room_dynamic_amenities) && $room_dynamic_amenities}
- {l s='Amenities'} + {l s='Room Amenities'}
{foreach from=$room_dynamic_amenities item=amenity} -
o {$amenity.name|escape:'html':'UTF-8'}
+
+ {if $amenity.logo_type == 'icon' && $amenity.logo} + + {elseif $amenity.logo_type == 'image' && $amenity.logo} + {$amenity.name|escape:'html':'UTF-8'} + {/if} + {$amenity.name|escape:'html':'UTF-8'} +
+ {/foreach} +
+
+ {/if} + {/block} + {block name='product_info_tab_hotel_features'} + {if isset($hotel_dynamic_amenities) && $hotel_dynamic_amenities} +
+
+ {l s='Hotel Amenities'} +
+
+ {foreach from=$hotel_dynamic_amenities item=amenity} +
+ {if $amenity.logo_type == 'icon' && $amenity.logo} + + {elseif $amenity.logo_type == 'image' && $amenity.logo} + {$amenity.name|escape:'html':'UTF-8'} + {/if} + {$amenity.name|escape:'html':'UTF-8'} +
{/foreach}