diff --git a/admin/themes/default/template/controllers/order_preferences/helpers/options/options.tpl b/admin/themes/default/template/controllers/order_preferences/helpers/options/options.tpl index 45eb6a349..b9fb5a7b2 100644 --- a/admin/themes/default/template/controllers/order_preferences/helpers/options/options.tpl +++ b/admin/themes/default/template/controllers/order_preferences/helpers/options/options.tpl @@ -100,6 +100,8 @@ }); } {/if} + + changeStandardProductAddressType(); }); {/if} @@ -110,6 +112,5 @@ {/block} diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index 37bd27107..7b0e8764f 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -121,7 +121,7 @@ + data-room-type="{if isset($room_info['id_product'])}{$room_info['id_product']|intval}{/if}"> diff --git a/admin/themes/default/template/controllers/search/helpers/view/view.tpl b/admin/themes/default/template/controllers/search/helpers/view/view.tpl index 2e9059abb..a9619ae01 100644 --- a/admin/themes/default/template/controllers/search/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/search/helpers/view/view.tpl @@ -121,6 +121,19 @@ $(function() { {/if} + {if isset($num_hotel_amenities) && $num_hotel_amenities} +
+

+ {if $num_hotel_amenities == 1} + {l s='1 hotel amenity'} + {else} + {l s='%d hotel amenities' sprintf=$num_hotel_amenities} + {/if} +

+ {$hotel_amenities} +
+ {/if} + {if isset($num_hotel_features) && $num_hotel_features}

diff --git a/classes/Media.php b/classes/Media.php index 58feb76d8..ab9ea2574 100644 --- a/classes/Media.php +++ b/classes/Media.php @@ -45,9 +45,9 @@ class MediaCore 'ui.tabs' => array('fileName' => 'jquery.ui.tabs.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.datepicker' => array('fileName' => 'jquery.ui.datepicker.min.js', 'dependencies' => array('ui.core'), 'theme' => true), 'ui.progressbar' => array('fileName' => 'jquery.ui.progressbar.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), - 'ui.tooltip' => array('fileName' => 'jquery.ui.tooltip.min.js', 'dependencies' => array('ui.core', 'ui.widget','ui.position','effects.core'), 'theme' => true), - 'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget','effects.core'), 'theme' => true), - 'effects.core' => array('fileName' => 'jquery.effects.core.min.js', 'dependencies' => array(), 'theme' => false), + 'ui.tooltip' => array('fileName' => 'jquery.ui.tooltip.min.js', 'dependencies' => array('ui.core', 'ui.widget','ui.position','ui.effect'), 'theme' => true), + 'ui.accordion' => array('fileName' => 'jquery.ui.accordion.min.js', 'dependencies' => array('ui.core', 'ui.widget','ui.effect'), 'theme' => true), + 'ui.effect' => array('fileName' => 'jquery.ui.effect.min.js', 'dependencies' => array(), 'theme' => false), 'effects.blind' => array('fileName' => 'jquery.effects.blind.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.bounce' => array('fileName' => 'jquery.effects.bounce.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.clip' => array('fileName' => 'jquery.effects.clip.min.js', 'dependencies' => array('effects.core'), 'theme' => false), diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 5252400ca..782f01f4a 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -660,11 +660,11 @@ class FrontControllerCore extends Controller } /** - * Renders and outputs maintenance page and ends controller process. + * Redirects a cursed request (e.g. an invalid/expired access token) to page not found and ends controller process. */ public function initCursedPage() { - $this->displayMaintenancePage(); + Tools::redirect($this->context->link->getPageLink('pagenotfound')); } /** diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php index efcb04045..876780463 100644 --- a/controllers/admin/AdminSearchController.php +++ b/controllers/admin/AdminSearchController.php @@ -189,7 +189,6 @@ class AdminSearchControllerCore extends AdminController if (!$searchType) { $this->searchAddress(); - $this->searchHotelFeatures(); $this->searchHotelAmenities(); $this->searchRefundRules(); } @@ -435,6 +434,7 @@ class AdminSearchControllerCore extends AdminController if ($hotelAmenities = $objHotelAmenities->searchByName($this->query, $this->context->language->id)) { $amenities = array(); foreach ($hotelAmenities as $key => $hotelAmenity) { + $amenities[$hotelAmenity['id_amenity']]['id_amenity'] = $hotelAmenity['id_amenity']; $amenities[$hotelAmenity['id_amenity']]['name'] = $hotelAmenity['name']; if ($hotelAmenity['id_parent']) { $amenities[$hotelAmenity['id_amenity']]['id'] = $hotelAmenity['id_parent']; @@ -818,10 +818,10 @@ class AdminSearchControllerCore extends AdminController $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; - $helper->identifier = 'id_customer_message'; - $helper->actions = array('edit'); + $helper->identifier = 'id_customer_thread'; + $helper->actions = array('view'); $helper->show_toolbar = false; - $helper->table = 'feature'; + $helper->table = 'customer_thread'; $helper->currentIndex = $this->context->link->getAdminLink('AdminCustomerThreads', false); $query = trim(Tools::getValue('bo_query')); diff --git a/js/admin/orders.js b/js/admin/orders.js index 193b79b2b..49beadcec 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -25,9 +25,7 @@ var current_product = null; var ajaxQueries = new Array(); -if (typeof jQuery !== 'undefined' && jQuery.effects && !jQuery.effects.effect) { - jQuery.effects.effect = {}; -} + $(document).ready(function() { // Init all events init(); diff --git a/modules/dashguestcycle/dashguestcycle.php b/modules/dashguestcycle/dashguestcycle.php index 6aae1cb46..b7b78eae1 100644 --- a/modules/dashguestcycle/dashguestcycle.php +++ b/modules/dashguestcycle/dashguestcycle.php @@ -110,7 +110,7 @@ class DashGuestCycle extends Module ), array( 'id' => 'box-dgc-guests', - 'color' => 'color1', + 'color' => 'color7', 'title' => $this->l('Guests (Adults/Children)'), 'tooltip' => $this->l('The number of adults and children scheduled to stay today.'), 'value' => $kpiValues['box-dgc-guests'], diff --git a/modules/dashguestcycle/views/css/dashguestcycle.css b/modules/dashguestcycle/views/css/dashguestcycle.css index 7fd58544d..ec97c2d33 100644 --- a/modules/dashguestcycle/views/css/dashguestcycle.css +++ b/modules/dashguestcycle/views/css/dashguestcycle.css @@ -30,41 +30,54 @@ } /* ── KPI row container: strip panel chrome ──────────────────────────────── */ -.kpi-container { +.bootstrap .kpi-container { background: transparent !important; border: none !important; box-shadow: none !important; - padding: 0 0 15px !important; + padding: 0 0 8px !important; + margin-bottom: 0 !important; } .kpi-container .kpis-wrap { flex-wrap: nowrap !important; - overflow-x: auto; - gap: 8px; - margin: 0 !important; + overflow: auto; + margin: -5px !important; + padding-bottom: 10px !important; } .kpi-container .kpis-wrap .kpi-wrap { width: 14.28% !important; min-width: 110px; - padding: 0 !important; + padding: 5px !important; margin-bottom: 0 !important; } .kpi-container .box-stats { + position: relative; height: 80px !important; background: #fff !important; border-radius: 10px !important; - overflow: hidden; font-size: inherit !important; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15) !important; +} + +.kpi-container .box-stats::before { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 10px; + height: 100%; + border-top-left-radius: 10px; + border-bottom-left-radius: 10px; + background: currentColor; } .kpi-container .box-stats .kpi-content { border: none !important; - border-left: 10px solid !important; border-radius: 0 !important; height: 100% !important; - padding: 8px 12px !important; + padding: 8px 12px 8px 20px !important; align-items: center !important; gap: 0 !important; } @@ -110,23 +123,26 @@ display: none !important; } -.kpi-container .box-stats.color1 .kpi-content { border-left-color: #266FFE !important; } -.kpi-container .box-stats.color1 .value { color: #266FFE !important; } +.kpi-container .box-stats.color1 { color: #266FFE !important; } +.kpi-container .box-stats.color1 .value { color: #266FFE !important; } -.kpi-container .box-stats.color2 .kpi-content { border-left-color: #72C3F0 !important; } -.kpi-container .box-stats.color2 .value { color: #72C3F0 !important; } +.kpi-container .box-stats.color2 { color: #72C3F0 !important; } +.kpi-container .box-stats.color2 .value { color: #72C3F0 !important; } -.kpi-container .box-stats.color3 .kpi-content { border-left-color: #56CE56 !important; } -.kpi-container .box-stats.color3 .value { color: #56CE56 !important; } +.kpi-container .box-stats.color3 { color: #56CE56 !important; } +.kpi-container .box-stats.color3 .value { color: #56CE56 !important; } -.kpi-container .box-stats.color4 .kpi-content { border-left-color: #FFC148 !important; } -.kpi-container .box-stats.color4 .value { color: #FFC148 !important; } +.kpi-container .box-stats.color4 { color: #FFC148 !important; } +.kpi-container .box-stats.color4 .value { color: #FFC148 !important; } -.kpi-container .box-stats.color5 .kpi-content { border-left-color: #A569DF !important; } -.kpi-container .box-stats.color5 .value { color: #A569DF !important; } +.kpi-container .box-stats.color5 { color: #A569DF !important; } +.kpi-container .box-stats.color5 .value { color: #A569DF !important; } -.kpi-container .box-stats.color6 .kpi-content { border-left-color: #FF4036 !important; } -.kpi-container .box-stats.color6 .value { color: #FF4036 !important; } +.kpi-container .box-stats.color6 { color: #FF4036 !important; } +.kpi-container .box-stats.color6 .value { color: #FF4036 !important; } + +.kpi-container .box-stats.color7 { color: #FF809E !important; } +.kpi-container .box-stats.color7 .value { color: #FF809E !important; } .kpi-container .actions-wrap { display: none !important; diff --git a/modules/hotelreservationsystem/classes/HotelHeaderImage.php b/modules/hotelreservationsystem/classes/HotelHeaderImage.php new file mode 100644 index 000000000..d9eee4643 --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelHeaderImage.php @@ -0,0 +1,297 @@ + 'htl_header_image', + 'primary' => 'id_header_image', + 'multilang' => true, + 'fields' => array( + 'name' => array('type' => self::TYPE_STRING, 'size' => 512), + 'title' => array('type' => self::TYPE_STRING, 'lang' => true, 'size' => self::TITLE_LIMIT), + 'description' => array('type' => self::TYPE_STRING, 'lang' => true, 'size' => 512), + 'description_color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor', 'size' => 7), + 'description_font_size' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'description_font_weight' => array('type' => self::TYPE_STRING, 'size' => 10), + 'position' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), + 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), + 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), + ), + ); + + public function __construct($id = null, $id_lang = null, $id_shop = null) + { + $this->image_dir = _PS_IMG_DIR_.'hotel_header_media/'; + parent::__construct($id, $id_lang, $id_shop); + } + + /** + * @inheritdoc + */ + public function delete() + { + if (!$this->deleteImageFile() + || !parent::delete() + || !$this->cleanPositions() + ) { + return false; + } + return true; + } + + /** + * Deletes the physical image file from disk. + * + * @return bool + */ + public function deleteImageFile() + { + if (!$this->name) { + return true; + } + $filePath = $this->image_dir.$this->name; + if (file_exists($filePath) && !unlink($filePath)) { + return false; + } + return true; + } + + /** + * Fetches image rows, optionally filtered by active status. + * + * @param int|null $active 1 = active only, 0 = inactive only, null = all + * @param int|null $idLang Language id for title/description; null = context default + * @param bool $withAllLangs true = also include titles[id_lang]/descriptions[id_lang] maps (admin edit forms) + * @return array + */ + public static function getItems($active = 1, $idLang = null, $withAllLangs = false) + { + if (!$idLang) { + $idLang = (int)Context::getContext()->language->id; + } + + if (!$withAllLangs) { + $sql = 'SELECT m.*, IFNULL(ml.`title`, \'\') AS `title`, IFNULL(ml.`description`, \'\') AS `description` + FROM `'._DB_PREFIX_.'htl_header_image` m + LEFT JOIN `'._DB_PREFIX_.'htl_header_image_lang` ml + ON (m.`id_header_image` = ml.`id_header_image` + AND ml.`id_lang` = '.(int)$idLang.')'; + if ($active !== null) { + $sql .= ' WHERE m.`active` = '.(int)$active; + } + $sql .= ' ORDER BY m.`position` ASC'; + return Db::getInstance()->executeS($sql) ?: array(); + } + + $sql = 'SELECT m.*, ml.`id_lang`, IFNULL(ml.`title`, \'\') AS `lang_title`, IFNULL(ml.`description`, \'\') AS `lang_description` + FROM `'._DB_PREFIX_.'htl_header_image` m + LEFT JOIN `'._DB_PREFIX_.'htl_header_image_lang` ml + ON m.`id_header_image` = ml.`id_header_image`'; + if ($active !== null) { + $sql .= ' WHERE m.`active` = '.(int)$active; + } + $sql .= ' ORDER BY m.`position` ASC, ml.`id_lang` ASC'; + + $rows = Db::getInstance()->executeS($sql); + if (!$rows) { + return array(); + } + + $itemsMap = array(); + foreach ($rows as $row) { + $id = (int)$row['id_header_image']; + if (!isset($itemsMap[$id])) { + $itemsMap[$id] = $row; + $itemsMap[$id]['title'] = ''; + $itemsMap[$id]['titles'] = array(); + $itemsMap[$id]['description'] = ''; + $itemsMap[$id]['descriptions'] = array(); + unset($itemsMap[$id]['id_lang'], $itemsMap[$id]['lang_title'], $itemsMap[$id]['lang_description']); + } + if (isset($row['id_lang'])) { + $langId = (int)$row['id_lang']; + $title = $row['lang_title']; + $description = $row['lang_description']; + $itemsMap[$id]['titles'][$langId] = $title; + $itemsMap[$id]['descriptions'][$langId] = $description; + if ($langId === (int)$idLang) { + $itemsMap[$id]['title'] = $title; + $itemsMap[$id]['description'] = $description; + } + } + } + + return array_values($itemsMap); + } + + /** + * Returns the next available position value (MAX + 1). + * + * @return int + */ + public function getHigherPosition() + { + $position = Db::getInstance()->getValue( + 'SELECT MAX(`position`) FROM `'._DB_PREFIX_.'htl_header_image`' + ); + return (is_numeric($position) ? (int)$position : -1) + 1; + } + + /** + * Resequences position values to be contiguous (0-based) after a deletion. + * Uses a single CASE...WHEN UPDATE instead of N individual queries. + * + * @return bool + */ + public function cleanPositions() + { + $items = Db::getInstance()->executeS( + 'SELECT `id_header_image` FROM `'._DB_PREFIX_.'htl_header_image` ORDER BY `position` ASC' + ); + if (!$items) { + return true; + } + $cases = ''; + $ids = array(); + foreach ($items as $i => $item) { + $id = (int)$item['id_header_image']; + $cases .= ' WHEN '.$id.' THEN '.$i; + $ids[] = $id; + } + return (bool)Db::getInstance()->execute( + 'UPDATE `'._DB_PREFIX_.'htl_header_image` + SET `position` = CASE `id_header_image`'.$cases.' END + WHERE `id_header_image` IN ('.implode(',', $ids).')' + ); + } + + /** + * Returns the stored video configuration, or null when no video is set. + * + * @return array|null ['source_type' => 'upload'|'url', 'name' => string] + */ + public static function getVideoConfig() + { + $name = Configuration::get('QLO_HEADER_VIDEO_NAME'); + $sourceType = Configuration::get('QLO_HEADER_VIDEO_SOURCE_TYPE'); + if (!$sourceType || !$name) { + return null; + } + return array('source_type' => $sourceType, 'name' => $name); + } + + /** + * Persists video source type and name/url to Configuration. + * + * @param string $sourceType 'upload' or 'url' + * @param string $name Filename (upload) or full URL (url) + * @return bool + */ + public static function saveVideoConfig($sourceType, $name) + { + return Configuration::updateValue('QLO_HEADER_VIDEO_SOURCE_TYPE', pSQL($sourceType)) + && Configuration::updateValue('QLO_HEADER_VIDEO_NAME', pSQL($name)); + } + + /** + * Clears video configuration and deletes the uploaded file from disk if applicable. + * + * @return bool + */ + public static function deleteVideoConfig() + { + $sourceType = Configuration::get('QLO_HEADER_VIDEO_SOURCE_TYPE'); + $name = Configuration::get('QLO_HEADER_VIDEO_NAME'); + if ($sourceType === 'upload' && $name) { + $filePath = _PS_IMG_DIR_.'hotel_header_media/'.$name; + if (file_exists($filePath)) { + unlink($filePath); + } + } + Configuration::updateValue('QLO_HEADER_VIDEO_SOURCE_TYPE', ''); + Configuration::updateValue('QLO_HEADER_VIDEO_NAME', ''); + return true; + } + + /** + * Creates the upload directory with security controls if it does not exist. + * + * @return bool + */ + public static function createMediaDirectory() + { + $dir = _PS_IMG_DIR_.'hotel_header_media/'; + if (!is_dir($dir) && !mkdir($dir, 0755, true)) { + return false; + } + if (!file_exists($dir.'index.php') && file_exists(_PS_IMG_DIR_.'index.php')) { + copy(_PS_IMG_DIR_.'index.php', $dir.'index.php'); + } + if (!file_exists($dir.'.htaccess')) { + file_put_contents( + $dir.'.htaccess', + "Options -ExecCGI\nAddHandler cgi-script .php .php3 .php4 .php5 .phtml .pl .py .jsp .asp .cgi\nphp_flag engine off\n" + ); + } + return true; + } +} diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index e30a33715..d444480a2 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1069,7 +1069,40 @@ class HotelHelper Configuration::updateValue('WK_TITLE_HEADER_BLOCK', $home_banner_default_title); Configuration::updateValue('WK_CONTENT_HEADER_BLOCK', $home_banner_default_content); - Configuration::updateValue('WK_HOTEL_HEADER_IMAGE', 'hotel_header_image.jpg'); + Configuration::updateValue('QLO_HEADER_MEDIA_TYPE', HotelHeaderImage::MEDIA_TYPE_IMAGE); + Configuration::updateValue('QLO_HEADER_SLIDER_NAV_TYPE', HotelHeaderImage::NAV_TYPE_ARROWS); + Configuration::updateValue('QLO_HEADER_SLIDER_AUTO_PLAY', 1); + Configuration::updateValue('QLO_HEADER_SLIDER_INTERVAL', 5000); + Configuration::updateValue('QLO_HEADER_SLIDER_ANIM_TYPE', HotelHeaderImage::ANIMATION_TYPE_SLIDE); + Configuration::updateValue('QLO_HEADER_CONTENT_ALIGN', HotelHeaderImage::CONTENT_ALIGN_CENTER); + Configuration::updateValue('QLO_HEADER_VIDEO_SOURCE_TYPE', ''); + Configuration::updateValue('QLO_HEADER_VIDEO_NAME', ''); + HotelHeaderImage::createMediaDirectory(); + $defaultImgSrc = _PS_IMG_DIR_.'hotel_header_image.jpg'; + $defaultImgDest = 'default_hotel_header_image.jpg'; + $mediaDir = _PS_IMG_DIR_.'hotel_header_media/'; + if (file_exists($defaultImgSrc) && !file_exists($mediaDir.$defaultImgDest)) { + @copy($defaultImgSrc, $mediaDir.$defaultImgDest); + } + if (file_exists($mediaDir.$defaultImgDest)) { + Db::getInstance()->execute( + 'INSERT INTO `'._DB_PREFIX_.'htl_header_image` + (`name`, `position`, `active`, `date_add`, `date_upd`) + VALUES (\''.pSQL($defaultImgDest).'\', 0, 1, NOW(), NOW())' + ); + $newId = (int)Db::getInstance()->Insert_ID(); + if ($newId) { + foreach (Language::getLanguages(false) as $lang) { + $title = isset($homeBannerTitleLang[$lang['iso_code']]) ? $homeBannerTitleLang[$lang['iso_code']] : $homeBannerTitleLang['en']; + $description = isset($homeBannerContentLang[$lang['iso_code']]) ? $homeBannerContentLang[$lang['iso_code']] : $homeBannerContentLang['en']; + Db::getInstance()->execute( + 'INSERT INTO `'._DB_PREFIX_.'htl_header_image_lang` + (`id_header_image`, `id_lang`, `title`, `description`) + VALUES ('.$newId.', '.(int)$lang['id_lang'].', \''.pSQL($title).'\', \''.pSQL($description).'\')' + ); + } + } + } Configuration::updateValue('WK_ALLOW_ADVANCED_PAYMENT', 1); Configuration::updateValue('WK_ADVANCED_PAYMENT_GLOBAL_MIN_AMOUNT', 10); Configuration::updateValue('WK_ADVANCED_PAYMENT_INC_TAX', 1); @@ -1094,14 +1127,6 @@ class HotelHelper // lang fields $languages = Language::getLanguages(false); - $htlTagLineLang = array( - 'en' => 'A place where comfort and luxury are blended with nature!', - 'nl' => 'Een plek waar comfort en luxe worden gecombineerd met de natuur!', - 'fr' => 'Un endroit où le confort et le luxe se mêlent à la nature!', - 'de' => 'Ein Ort, an dem Komfort und Luxus mit der Natur verschmelzen!', - 'ru' => 'Место, где комфорт и роскошь сочетаются с природой!', - 'es' => '¡Un lugar donde el confort y el lujo se mezclan con la naturaleza!', - ); $htlShortDescLang = array( 'en' => 'We offer elegant rooms, gourmet dining, and attentive service for a memorable stay.', @@ -1120,25 +1145,21 @@ class HotelHelper 'es' => 'ft', ); $WK_HTL_CHAIN_NAME = array(); - $WK_HTL_TAG_LINE = array(); $WK_HTL_SHORT_DESC = array(); $defaultDimensionUnit = array(); foreach ($languages as $lang) { - if (isset($htlTagLineLang[$lang['iso_code']])) { - $WK_HTL_TAG_LINE[$lang['id_lang']] = $htlTagLineLang[$lang['iso_code']]; + if (isset($htlShortDescLang[$lang['iso_code']])) { $WK_HTL_SHORT_DESC[$lang['id_lang']] = $htlShortDescLang[$lang['iso_code']]; $WK_HTL_CHAIN_NAME[$lang['id_lang']] = $homeBannerTitleLang[$lang['iso_code']]; $defaultDimensionUnit[$lang['id_lang']] = $defaultDimensionUnitLang[$lang['iso_code']]; } else { $defaultDimensionUnit[$lang['id_lang']] = $defaultDimensionUnitLang['en']; $WK_HTL_CHAIN_NAME[$lang['id_lang']] = $homeBannerTitleLang['en']; - $WK_HTL_TAG_LINE[$lang['id_lang']] = $htlTagLineLang['en']; $WK_HTL_SHORT_DESC[$lang['id_lang']] = $htlShortDescLang['en']; } } Configuration::updateValue('WK_HTL_CHAIN_NAME', $WK_HTL_CHAIN_NAME); - Configuration::updateValue('WK_HTL_TAG_LINE', $WK_HTL_TAG_LINE); Configuration::updateValue('WK_HTL_SHORT_DESC', $WK_HTL_SHORT_DESC); Configuration::updateValue('WK_DIMENSION_UNIT', $defaultDimensionUnit); diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 377a86f69..27de4e77a 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -452,11 +452,32 @@ class HotelReservationSystemDb `date_upd` datetime NOT NULL, PRIMARY KEY (`id_settings_link`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_header_image` ( + `id_header_image` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(512) NOT NULL, + `description_color` VARCHAR(7) NOT NULL DEFAULT '#ffffff', + `description_font_size` TINYINT(3) UNSIGNED NOT NULL DEFAULT '16', + `description_font_weight` VARCHAR(10) NOT NULL DEFAULT '400', + `position` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1', + `date_add` DATETIME NOT NULL, + `date_upd` DATETIME NOT NULL, + PRIMARY KEY (`id_header_image`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", + "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_header_image_lang` ( + `id_header_image` INT(10) UNSIGNED NOT NULL, + `id_lang` INT(11) NOT NULL, + `title` VARCHAR(512) NOT NULL DEFAULT '', + `description` VARCHAR(512) NOT NULL DEFAULT '', + PRIMARY KEY (`id_header_image`, `id_lang`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", + "INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES (1, 'icon-cogs', 'index.php?controller=AdminHotelGeneralSettings', 0, 0, 1, 1, NOW(), NOW()), (2, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()), (3, 'icon-file-text', 'index.php?controller=AdminAboutHotelBlockSetting', 0, 4, 0, 1, NOW(), NOW()), - (4, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW());", + (4, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW()), + (5, 'icon-picture', 'index.php?controller=AdminHotelHeaderImage', 0, 6, 0, 1, NOW(), NOW());", "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link_lang` ( `id_settings_link` int(10) unsigned NOT NULL, @@ -485,6 +506,11 @@ class HotelReservationSystemDb SELECT 4, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.' FROM `"._DB_PREFIX_."lang` ORDER BY `id_lang`;", + + "INSERT IGNORE INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`) + SELECT 5, `id_lang`, 'Landing Page Header Media', 'Configure and manage header images or videos displayed on the home page.' + FROM `"._DB_PREFIX_."lang` + ORDER BY `id_lang`;", "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_connected_room` ( `id_connected_room` int(11) NOT NULL AUTO_INCREMENT, `id_room` int(11) NOT NULL, @@ -555,6 +581,8 @@ class HotelReservationSystemDb `'._DB_PREFIX_.'htl_access`, `'._DB_PREFIX_.'htl_settings_link`, `'._DB_PREFIX_.'htl_settings_link_lang`, + `'._DB_PREFIX_.'htl_header_image`, + `'._DB_PREFIX_.'htl_header_image_lang`, `'._DB_PREFIX_.'htl_connected_room`' ); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index e2a59d4d5..6159c5e5e 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -1207,7 +1207,7 @@ class AdminAddHotelController extends ModuleAdminController $this->addJqueryUI('ui.sortable'); - $this->addJS(_MODULE_DIR_.$this->module->name.'/views/js/hotelImage.js'); + $this->addJS(_MODULE_DIR_.$this->module->name.'/views/js/admin/qhrs_hotel_image.js'); $this->addJS(_MODULE_DIR_.$this->module->name.'/views/js/HotelReservationAdmin.js'); $this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/HotelReservationAdmin.css'); } diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index 40b356f49..3ed7d150c 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -30,10 +30,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController $this->bootstrap = true; parent::__construct(); - $psImgUrl = $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('WK_HOTEL_HEADER_IMAGE')); - if ($imgExist = (bool)Tools::file_get_contents($psImgUrl)) { - $image = ''; - } $objHotelInfo = new HotelBranchInformation(); if (!$hotelsInfo = $objHotelInfo->hotelBranchesInfo(false, 1)) { $hotelsInfo = array(); @@ -129,21 +125,13 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'title' => $this->l('Website Configuration'), 'fields' => array( 'WK_HTL_CHAIN_NAME' => array( - 'title' => $this->l('Hotel Name'), + 'title' => $this->l('Hotel Brand Name'), 'type' => 'textLang', 'lang' => true, 'required' => true, 'validation' => 'isGenericName', 'hint' => $this->l('Enter Hotel name in case of single hotel or enter your hotels chain name in case of multiple hotels.'), ), - 'WK_HTL_TAG_LINE' => array( - 'title' => $this->l('Hotel Tag Line'), - 'type' => 'textareaLang', - 'lang' => true, - 'required' => true, - 'validation' => 'isGenericName', - 'hint' => $this->l('This will display hotel tag line in hotel page.'), - ), 'WK_HTL_SHORT_DESC' => array( 'title' => $this->l('Hotel Short Description'), 'type' => 'textareaLang', @@ -166,14 +154,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'hint' => $this->l('The year when your hotel site was launched.'), 'type' => 'text', 'class' => 'fixed-width-xxl', - ), - 'WK_HTL_HEADER_IMAGE' => array( - 'title' => $this->l('Header Background Image'), - 'type' => 'file', - 'image' => $imgExist ? $image : false, - 'hint' => $this->l('This image appears as header background image on home page.'), - 'name' => 'WK_HOTEL_HEADER_IMAGE', - 'url' => _PS_IMG_, ), 'WK_DISPLAY_PROPERTIES_LINK_IN_HEADER' => array( 'title' => $this->l('Display Our Properties link in Header'), @@ -571,17 +551,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController } } } - if (!trim(Tools::getValue('WK_HTL_TAG_LINE_'.$defaultLangId))) { - $this->errors[] = $this->l('Hotel tag line is required at least in ').$objDefaultLanguage['name']; - } else { - foreach ($languages as $lang) { - if (trim(Tools::getValue('WK_HTL_TAG_LINE_'.$lang['id_lang']))) { - if (!Validate::isGenericName(Tools::getValue('WK_HTL_TAG_LINE_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid Hotel tag line in ').$lang['name']; - } - } - } - } if (!trim(Tools::getValue('WK_HTL_SHORT_DESC_'.$defaultLangId))) { $this->errors[] = $this->l('Hotel short description is required at least in '). $objDefaultLanguage['name']; @@ -594,24 +563,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController } } } - if ($_FILES['WK_HOTEL_HEADER_IMAGE']['name']) { - if ($error = ImageManager::validateUpload($_FILES['WK_HOTEL_HEADER_IMAGE'], Tools::getMaxUploadSize())) { - $this->errors[] = $error; - } - - if (!count($this->errors)) { - $file_name = 'hotel_header_image_'.time().'.jpg'; - $img_path = _PS_IMG_DIR_.$file_name; - - if (ImageManager::resize($_FILES['WK_HOTEL_HEADER_IMAGE']['tmp_name'], $img_path)) { - $olderHeaderImg = _PS_IMG_DIR_.Configuration::get('WK_HOTEL_HEADER_IMAGE'); - Configuration::updateValue('WK_HOTEL_HEADER_IMAGE', $file_name); - Tools::deleteFile($olderHeaderImg); - } else { - $this->errors[] = $this->l('Some error occured while uoploading image.Please try again.'); - } - } - } if (!Validate::isUnsignedInt(Tools::getValue('WK_ADVANCED_PAYMENT_GLOBAL_MIN_AMOUNT'))) { $this->errors[] = $this->l('Invalid minimum partial payment percentage.'); } elseif (Tools::getValue('WK_ADVANCED_PAYMENT_GLOBAL_MIN_AMOUNT') <= 0) { @@ -661,11 +612,6 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController Tools::getValue('WK_HTL_CHAIN_NAME_'.$defaultLangId) ); } - if (!trim(Tools::getValue('WK_HTL_TAG_LINE_'.$lang['id_lang']))) { - $_POST['WK_HTL_TAG_LINE_'.$lang['id_lang']] = trim( - Tools::getValue('WK_HTL_TAG_LINE_'.$defaultLangId) - ); - } if (!trim(Tools::getValue('WK_HTL_SHORT_DESC_'.$lang['id_lang']))) { $_POST['WK_HTL_SHORT_DESC_'.$lang['id_lang']] = trim( Tools::getValue('WK_HTL_SHORT_DESC_'.$defaultLangId) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelHeaderImageController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelHeaderImageController.php new file mode 100644 index 000000000..e80de7e96 --- /dev/null +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelHeaderImageController.php @@ -0,0 +1,863 @@ +table = 'htl_header_image'; + $this->className = 'HotelHeaderImage'; + $this->bootstrap = true; + $this->identifier = 'id_header_image'; + $this->lang = true; + parent::__construct(); + + $this->bulk_actions = array( + 'delete' => array( + 'text' => $this->l('Delete selected'), + 'confirm' => $this->l('Delete selected images? This cannot be undone.'), + 'icon' => 'icon-trash', + ), + ); + } + + public function initContent() + { + if (!$this->ajax) { + $this->display = 'view'; + } + parent::initContent(); + } + + public function initToolbar() + { + parent::initToolbar(); + $this->page_header_toolbar_title = $this->l('Header Image Configuration'); + unset($this->toolbar_btn['back']); + } + + public function renderView() + { + $this->meta_title = $this->l('Header Image Configuration'); + $mediaType = (int)Tools::getValue('QLO_HEADER_MEDIA_TYPE', (int)(Configuration::get('QLO_HEADER_MEDIA_TYPE') ?: HotelHeaderImage::MEDIA_TYPE_IMAGE)); + $languages = Language::getLanguages(false); + $defaultLangId = (int)Configuration::get('PS_LANG_DEFAULT'); + + $imageItems = HotelHeaderImage::getItems(null, $defaultLangId, true); + $shopId = (int)$this->context->shop->id; + foreach ($imageItems as &$item) { + $item['titles_json'] = json_encode((object)$item['titles']); + $item['descriptions_json'] = json_encode((object)$item['descriptions']); + $srcPath = _PS_IMG_DIR_.'hotel_header_media/'.$item['name']; + $cacheName = 'htl_header_image_mini_'.(int)$item['id_header_image'].'_'.$shopId.'.jpg'; + $item['thumb'] = ImageManager::thumbnail($srcPath, $cacheName, 45, 'jpg', false); + } + unset($item); + + $videoItem = HotelHeaderImage::getVideoConfig(); + $videoMimeType = 'video/mp4'; + if ($videoItem) { + if ($videoItem['source_type'] === 'upload') { + $ext = strtolower(pathinfo($videoItem['name'], PATHINFO_EXTENSION)); + } else { + $urlPath = parse_url($videoItem['name'], PHP_URL_PATH); + $ext = strtolower(pathinfo($urlPath ?: '', PATHINFO_EXTENSION)); + } + $mimeMap = array('mp4' => 'video/mp4', 'webm' => 'video/webm', 'ogg' => 'video/ogg'); + $videoMimeType = isset($mimeMap[$ext]) ? $mimeMap[$ext] : 'video/mp4'; + } + + $sourceType = Tools::getValue('source_type', $videoItem ? $videoItem['source_type'] : 'upload'); + $videoUrlValue = Tools::getValue( + 'video_url', + ($videoItem && $videoItem['source_type'] === 'url') ? $videoItem['name'] : '' + ); + $showVideoUrlPreview = ($sourceType === 'url' && $videoUrlValue && Validate::isAbsoluteUrl($videoUrlValue)); + + Media::addJsDef(array( + 'qloHmCurrentIndex' => self::$currentIndex, + 'qloHmToken' => $this->token, + 'qloHmMediaType' => $mediaType, + 'qloHmMediaTypeImage' => HotelHeaderImage::MEDIA_TYPE_IMAGE, + 'qloHmMediaTypeVideo' => HotelHeaderImage::MEDIA_TYPE_VIDEO, + 'qloHmMaxUpload' => Tools::getMaxUploadSize((int)Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1024 * 1024), + 'qloHmMaxVideoUpload' => Tools::getMaxUploadSize(), + 'qloHmDefaultLangId' => $defaultLangId, + 'qloHmI18n' => array( + 'noFileSelected' => $this->l('Please select at least one image file.'), + 'deleteFailed' => $this->l('Delete failed.'), + 'requestFailed' => $this->l('Request failed.'), + 'imageUploadedSuccess' => $this->l('Image uploaded successfully.'), + 'imageUpdatedSuccess' => $this->l('Image updated successfully.'), + 'uploadFailed' => $this->l('Upload failed.'), + 'updateFailed' => $this->l('Update failed.'), + 'editLabel' => $this->l('Edit'), + 'deleteImageLabel' => $this->l('Delete this image'), + 'fileTooLarge' => $this->l('File exceeds the maximum allowed upload size.'), + ), + )); + + $this->tpl_view_vars = array( + 'mediaType' => $mediaType, + 'imageItems' => $imageItems, + 'videoItem' => $videoItem, + 'videoMimeType' => $videoMimeType, + 'sourceType' => $sourceType, + 'videoUrlValue' => $videoUrlValue, + 'showVideoUrlPreview' => $showVideoUrlPreview, + 'config' => array( + 'QLO_HEADER_MEDIA_TYPE' => $mediaType, + 'QLO_HEADER_SLIDER_NAV_TYPE' => (int)Tools::getValue('QLO_HEADER_SLIDER_NAV_TYPE', (int)(Configuration::get('QLO_HEADER_SLIDER_NAV_TYPE') ?: HotelHeaderImage::NAV_TYPE_ARROWS)), + 'QLO_HEADER_SLIDER_AUTO_PLAY' => (int)Tools::getValue('QLO_HEADER_SLIDER_AUTO_PLAY', (int)Configuration::get('QLO_HEADER_SLIDER_AUTO_PLAY')), + 'QLO_HEADER_SLIDER_INTERVAL' => Tools::getValue('QLO_HEADER_SLIDER_INTERVAL', (int)Configuration::get('QLO_HEADER_SLIDER_INTERVAL') ?: 5000), + 'QLO_HEADER_SLIDER_ANIM_TYPE' => (int)Tools::getValue('QLO_HEADER_SLIDER_ANIM_TYPE', (int)(Configuration::get('QLO_HEADER_SLIDER_ANIM_TYPE') ?: HotelHeaderImage::ANIMATION_TYPE_SLIDE)), + 'QLO_HEADER_CONTENT_ALIGN' => (int)Tools::getValue('QLO_HEADER_CONTENT_ALIGN', (int)(Configuration::get('QLO_HEADER_CONTENT_ALIGN') ?: HotelHeaderImage::CONTENT_ALIGN_CENTER)), + ), + 'languages' => $languages, + 'defaultLangId' => $defaultLangId, + 'imgBaseUrl' => $this->context->link->getMediaLink(_PS_IMG_.'hotel_header_media/'), + 'maxUpload' => Tools::formatBytes(Tools::getMaxUploadSize()), + 'maxImageUpload' => Tools::formatBytes(Tools::getMaxUploadSize((int)Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1024 * 1024)), + 'descriptionLimit' => (int)Configuration::get('PS_SHORT_DESC_LIMIT') ?: Configuration::PS_SHORT_DESC_LIMIT, + 'titleLimit' => HotelHeaderImage::TITLE_LIMIT, + ); + + return parent::renderView(); + } + + public function postProcess() + { + if (Tools::isSubmit('submitHeaderMedia')) { + $this->processSaveSettings(); + } + parent::postProcess(); + } + + protected function processBulkDelete() + { + $ids = Tools::getValue($this->table.'Box', array()); + $activeImages = HotelHeaderImage::getItems(1); + $activeIds = array_column($activeImages, 'id_header_image'); + $activeToDelete = array_intersect(array_map('intval', (array)$ids), array_map('intval', $activeIds)); + + if (count($activeIds) - count($activeToDelete) < 1) { + $this->errors[] = $this->l('At least one active image is required.'); + return; + } + + parent::processBulkDelete(); + } + + protected function processSaveSettings() + { + $mediaType = (int)Tools::getValue('QLO_HEADER_MEDIA_TYPE', HotelHeaderImage::MEDIA_TYPE_IMAGE); + $previousMediaType = (int)Configuration::get('QLO_HEADER_MEDIA_TYPE'); + + if (!in_array($mediaType, array(HotelHeaderImage::MEDIA_TYPE_IMAGE, HotelHeaderImage::MEDIA_TYPE_VIDEO))) { + $this->errors[] = $this->l('Invalid media type selected.'); + return; + } + + $sourceType = Tools::getValue('source_type', 'upload'); + $existingVideo = HotelHeaderImage::getVideoConfig(); + $hasMatchingExistingVideo = ($existingVideo && $existingVideo['source_type'] === $sourceType); + $hasNewVideoFile = isset($_FILES['header_video_file']) && !empty($_FILES['header_video_file']['size']); + $hasNewVideoUrl = ($sourceType === 'url' && trim(Tools::getValue('video_url', '')) !== ''); + + if ($mediaType === HotelHeaderImage::MEDIA_TYPE_VIDEO && !$hasMatchingExistingVideo && !$hasNewVideoFile && !$hasNewVideoUrl) { + $this->errors[] = $this->l('Please upload or link a video before switching the header to Video mode.'); + return; + } + if ($mediaType === HotelHeaderImage::MEDIA_TYPE_IMAGE && !HotelHeaderImage::getItems(1)) { + $this->errors[] = $this->l('Please add at least one active image before switching the header to Image mode.'); + return; + } + $autoPlay = 0; + $interval = 0; + $navType = HotelHeaderImage::NAV_TYPE_ARROWS; + $animType = HotelHeaderImage::ANIMATION_TYPE_SLIDE; + $contentAlign = HotelHeaderImage::CONTENT_ALIGN_CENTER; + + if ($mediaType === HotelHeaderImage::MEDIA_TYPE_IMAGE) { + $autoPlay = (int)(bool)Tools::getValue('QLO_HEADER_SLIDER_AUTO_PLAY', 1); + if ($autoPlay) { + $interval = Tools::getValue('QLO_HEADER_SLIDER_INTERVAL', 5000); + if (!Validate::isUnsignedInt($interval) || (int)$interval < 500) { + $this->errors[] = $this->l('Auto Slide Interval must be at least 500 milliseconds.'); + return; + } + $interval = (int)$interval; + } + + $navType = (int)Tools::getValue('QLO_HEADER_SLIDER_NAV_TYPE', HotelHeaderImage::NAV_TYPE_ARROWS); + if (!in_array($navType, array(HotelHeaderImage::NAV_TYPE_DOTS, HotelHeaderImage::NAV_TYPE_ARROWS, HotelHeaderImage::NAV_TYPE_BOTH))) { + $navType = HotelHeaderImage::NAV_TYPE_ARROWS; + } + $animType = (int)Tools::getValue('QLO_HEADER_SLIDER_ANIM_TYPE', HotelHeaderImage::ANIMATION_TYPE_SLIDE); + if (!in_array($animType, array(HotelHeaderImage::ANIMATION_TYPE_SLIDE, HotelHeaderImage::ANIMATION_TYPE_FADE, HotelHeaderImage::ANIMATION_TYPE_ZOOM, HotelHeaderImage::ANIMATION_TYPE_BLUR))) { + $animType = HotelHeaderImage::ANIMATION_TYPE_SLIDE; + } + $contentAlign = (int)Tools::getValue('QLO_HEADER_CONTENT_ALIGN', HotelHeaderImage::CONTENT_ALIGN_CENTER); + if (!in_array($contentAlign, array(HotelHeaderImage::CONTENT_ALIGN_LEFT, HotelHeaderImage::CONTENT_ALIGN_CENTER, HotelHeaderImage::CONTENT_ALIGN_RIGHT))) { + $contentAlign = HotelHeaderImage::CONTENT_ALIGN_CENTER; + } + } + + if ($mediaType === HotelHeaderImage::MEDIA_TYPE_VIDEO) { + $imagesToDrop = array(); + if ($previousMediaType === HotelHeaderImage::MEDIA_TYPE_IMAGE) { + $imagesToDrop = HotelHeaderImage::getItems(null); + array_shift($imagesToDrop); + } + if ($imagesToDrop && Tools::getValue('confirm_delete_images') !== '1') { + $this->errors[] = $this->l('Switching to Video will delete all images except the one in the first position. Please confirm this action.'); + return; + } + + $this->processSaveVideo(); + + if (!count($this->errors)) { + foreach ($imagesToDrop as $imgData) { + $obj = new HotelHeaderImage((int)$imgData['id_header_image']); + if (Validate::isLoadedObject($obj)) { + $obj->delete(); + } + } + } + } + + if (!count($this->errors)) { + Configuration::updateValue('QLO_HEADER_MEDIA_TYPE', $mediaType); + + if ($mediaType === HotelHeaderImage::MEDIA_TYPE_IMAGE) { + Configuration::updateValue('QLO_HEADER_CONTENT_ALIGN', $contentAlign); + Configuration::updateValue('QLO_HEADER_SLIDER_NAV_TYPE', $navType); + Configuration::updateValue('QLO_HEADER_SLIDER_AUTO_PLAY', $autoPlay); + Configuration::updateValue('QLO_HEADER_SLIDER_ANIM_TYPE', $animType); + if ($autoPlay) { + Configuration::updateValue('QLO_HEADER_SLIDER_INTERVAL', $interval); + } + } + Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); + } + } + + protected function processSaveVideo() + { + $sourceType = Tools::getValue('source_type', 'upload'); + $videoUrl = trim(Tools::getValue('video_url', '')); + $file = isset($_FILES['header_video_file']) ? $_FILES['header_video_file'] : null; + $hasNewFile = ($file && isset($file['error']) && $file['error'] === UPLOAD_ERR_OK && $file['size'] > 0); + $hasNewUrl = ($sourceType === 'url' && $videoUrl !== ''); + + if ($sourceType === 'url' && $videoUrl === '') { + $this->errors[] = $this->l('Please enter a video URL.'); + return; + } + if ($hasNewUrl && !Validate::isAbsoluteUrl($videoUrl)) { + $this->errors[] = $this->l('Please enter a valid video URL.'); + return; + } + if ($hasNewFile) { + $allowedExts = array('mp4', 'webm', 'ogg'); + $allowedMimes = array('video/mp4', 'video/webm', 'video/ogg', 'video/x-matroska'); + $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); + if (!in_array($ext, $allowedExts)) { + $this->errors[] = $this->l('Only .mp4, .webm, and .ogg video formats are allowed.'); + return; + } + if (filesize($file['tmp_name']) > Tools::getMaxUploadSize()) { + $this->errors[] = $this->l('Video file exceeds the maximum allowed upload size.'); + return; + } + if (!function_exists('finfo_open')) { + $this->errors[] = $this->l('Server cannot verify file type. Please enable the fileinfo PHP extension.'); + return; + } + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $detectedMime = finfo_file($finfo, $file['tmp_name']); + finfo_close($finfo); + if (!in_array($detectedMime, $allowedMimes)) { + $this->errors[] = $this->l('Invalid video file type detected.'); + return; + } + } + + if ($hasNewUrl) { + HotelHeaderImage::deleteVideoConfig(); + HotelHeaderImage::saveVideoConfig('url', $videoUrl); + } elseif ($hasNewFile) { + if (!HotelHeaderImage::createMediaDirectory()) { + $this->errors[] = $this->l('Could not create the media directory.'); + return; + } + $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); + do { + $uniqueName = bin2hex(random_bytes(16)).'.'.$ext; + } while (file_exists(_PS_IMG_DIR_.'hotel_header_media/'.$uniqueName)); + if (!move_uploaded_file($file['tmp_name'], _PS_IMG_DIR_.'hotel_header_media/'.$uniqueName)) { + $this->errors[] = $this->l('Failed to save video file.'); + return; + } + HotelHeaderImage::deleteVideoConfig(); + HotelHeaderImage::saveVideoConfig('upload', $uniqueName); + } + } + + public function ajaxProcessUploadImage() + { + $response = array('errors' => array(), 'success' => false); + $file = isset($_FILES['header_image_file']) ? $_FILES['header_image_file'] : null; + + if (!$file || !$file['size']) { + $response['errors'][] = $this->l('No file received.'); + $this->ajaxDie(json_encode($response)); + } + + if ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize((int)Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1024 * 1024))) { + $response['errors'][] = $error; + $this->ajaxDie(json_encode($response)); + } + + if (!HotelHeaderImage::createMediaDirectory()) { + $response['errors'][] = $this->l('Could not create the media directory.'); + $this->ajaxDie(json_encode($response)); + } + + $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); + $isGif = ($ext === 'gif'); + $outExt = $isGif ? 'gif' : 'jpg'; + do { + $uniqueName = bin2hex(random_bytes(16)).'.'.$outExt; + } while (file_exists(_PS_IMG_DIR_.'hotel_header_media/'.$uniqueName)); + + $destPath = _PS_IMG_DIR_.'hotel_header_media/'.$uniqueName; + $saved = $isGif ? (bool)move_uploaded_file($file['tmp_name'], $destPath) : (bool)ImageManager::resize($file['tmp_name'], $destPath); + + if (!$saved) { + $response['errors'][] = $this->l('Failed to save image file.'); + $this->ajaxDie(json_encode($response)); + } + + $titleByLang = array(); + $descriptionByLang = array(); + foreach (Language::getLanguages(false) as $lang) { + $titleByLang[$lang['id_lang']] = trim(Tools::getValue('title_'.$lang['id_lang'], '')); + $descriptionByLang[$lang['id_lang']] = trim(Tools::getValue('description_'.$lang['id_lang'], '')); + } + foreach (array_merge($titleByLang, $descriptionByLang) as $textValue) { + if (!Validate::isGenericName($textValue)) { + if (file_exists($destPath)) { + unlink($destPath); + } + $response['errors'][] = $this->l('Invalid title or description. Characters < > = { } are not allowed.'); + $this->ajaxDie(json_encode($response)); + } + } + foreach ($titleByLang as $titleValue) { + if (Tools::strlen($titleValue) > HotelHeaderImage::TITLE_LIMIT) { + if (file_exists($destPath)) { + unlink($destPath); + } + $response['errors'][] = sprintf($this->l('Title is too long: %d chars max.'), HotelHeaderImage::TITLE_LIMIT); + $this->ajaxDie(json_encode($response)); + } + } + $descriptionLimit = (int)Configuration::get('PS_SHORT_DESC_LIMIT') ?: Configuration::PS_SHORT_DESC_LIMIT; + foreach ($descriptionByLang as $descriptionValue) { + if (Tools::strlen($descriptionValue) > $descriptionLimit) { + if (file_exists($destPath)) { + unlink($destPath); + } + $response['errors'][] = sprintf($this->l('Description is too long: %d chars max.'), $descriptionLimit); + $this->ajaxDie(json_encode($response)); + } + } + + $descriptionColor = Tools::getValue('description_color', '#ffffff'); + if (!preg_match('/^#[0-9a-fA-F]{6}$/', $descriptionColor)) { + $response['errors'][] = $this->l('Invalid description color. Use a 6-digit hex value (e.g. #ffffff).'); + $this->ajaxDie(json_encode($response)); + } + $descriptionFontSize = (int)Tools::getValue('description_font_size', 16); + if ($descriptionFontSize < 8 || $descriptionFontSize > 72) { + $response['errors'][] = $this->l('Description font size must be between 8 and 72 pixels.'); + $this->ajaxDie(json_encode($response)); + } + $descriptionFontWeight = Tools::getValue('description_font_weight', '400'); + if (!in_array($descriptionFontWeight, array('400', '700'))) { + $response['errors'][] = $this->l('Invalid description font weight.'); + $this->ajaxDie(json_encode($response)); + } + + $objImage = new HotelHeaderImage(); + $objImage->name = $uniqueName; + $objImage->position = $objImage->getHigherPosition(); + $objImage->active = (int)(bool)Tools::getValue('active', 1); + $objImage->title = $titleByLang; + $objImage->description = $descriptionByLang; + $objImage->description_color = $descriptionColor; + $objImage->description_font_size = $descriptionFontSize; + $objImage->description_font_weight = $descriptionFontWeight; + + if (!$objImage->save()) { + if (file_exists($destPath)) { + unlink($destPath); + } + $response['errors'][] = $this->l('Failed to save image record.'); + $this->ajaxDie(json_encode($response)); + } + + $defaultLangId = (int)Configuration::get('PS_LANG_DEFAULT'); + $shopId = (int)$this->context->shop->id; + $cacheName = 'htl_header_image_mini_'.(int)$objImage->id.'_'.$shopId.'.jpg'; + $thumb = ImageManager::thumbnail($destPath, $cacheName, 45, 'jpg', true, true); + $this->context->smarty->assign(array( + 'img' => array( + 'id_header_image' => (int)$objImage->id, + 'name' => $uniqueName, + 'thumb' => $thumb, + 'title' => isset($titleByLang[$defaultLangId]) ? $titleByLang[$defaultLangId] : '', + 'titles_json' => json_encode((object)$titleByLang), + 'description' => isset($descriptionByLang[$defaultLangId]) ? $descriptionByLang[$defaultLangId] : '', + 'descriptions_json' => json_encode((object)$descriptionByLang), + 'description_color' => $descriptionColor, + 'description_font_size' => $descriptionFontSize, + 'description_font_weight' => $descriptionFontWeight, + 'active' => (int)$objImage->active, + ), + 'position' => count(HotelHeaderImage::getItems(null)), + 'current' => self::$currentIndex, + 'token' => $this->token, + 'imgBaseUrl' => $this->context->link->getMediaLink(_PS_IMG_.'hotel_header_media/'), + )); + + $response['success'] = true; + $response['data']['image_row'] = $this->context->smarty->fetch( + _PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/hotel_header_image/_partials/htl-header-image-row.tpl' + ); + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessEditImage() + { + $response = array('errors' => array(), 'success' => false); + $id = (int)Tools::getValue('id_header_image'); + + if (!$id) { + $response['errors'][] = $this->l('Invalid item ID.'); + $this->ajaxDie(json_encode($response)); + } + + $objImage = new HotelHeaderImage($id); + if (!Validate::isLoadedObject($objImage)) { + $response['errors'][] = $this->l('Image not found.'); + $this->ajaxDie(json_encode($response)); + } + + $titleByLang = array(); + $descriptionByLang = array(); + foreach (Language::getLanguages(false) as $lang) { + $titleByLang[$lang['id_lang']] = trim(Tools::getValue('title_'.$lang['id_lang'], '')); + $descriptionByLang[$lang['id_lang']] = trim(Tools::getValue('description_'.$lang['id_lang'], '')); + } + foreach ($titleByLang as $titleValue) { + if (!Validate::isGenericName($titleValue)) { + $response['errors'][] = $this->l('Invalid title. Characters < > = { } are not allowed.'); + $this->ajaxDie(json_encode($response)); + } + if (Tools::strlen($titleValue) > HotelHeaderImage::TITLE_LIMIT) { + $response['errors'][] = sprintf($this->l('Title is too long: %d chars max.'), HotelHeaderImage::TITLE_LIMIT); + $this->ajaxDie(json_encode($response)); + } + } + $descriptionLimit = (int)Configuration::get('PS_SHORT_DESC_LIMIT') ?: Configuration::PS_SHORT_DESC_LIMIT; + foreach ($descriptionByLang as $descriptionValue) { + if (Tools::strlen($descriptionValue) > $descriptionLimit) { + $response['errors'][] = sprintf($this->l('Description is too long: %d chars max.'), $descriptionLimit); + $this->ajaxDie(json_encode($response)); + } + } + + $activeVal = Tools::getValue('active'); + if ($activeVal !== false) { + $newActive = (int)(bool)$activeVal; + if ($newActive === 0 && (int)$objImage->active === 1) { + $activeImages = HotelHeaderImage::getItems(1); + if (is_array($activeImages) && count($activeImages) <= 1) { + $response['errors'][] = $this->l('At least one image must remain active.'); + $this->ajaxDie(json_encode($response)); + } + } + $objImage->active = $newActive; + } + + $descriptionColor = Tools::getValue('description_color', $objImage->description_color); + if (!preg_match('/^#[0-9a-fA-F]{6}$/', $descriptionColor)) { + $response['errors'][] = $this->l('Invalid description color. Use a 6-digit hex value (e.g. #ffffff).'); + $this->ajaxDie(json_encode($response)); + } + $descriptionFontSize = (int)Tools::getValue('description_font_size', $objImage->description_font_size); + if ($descriptionFontSize < 8 || $descriptionFontSize > 72) { + $response['errors'][] = $this->l('Description font size must be between 8 and 72 pixels.'); + $this->ajaxDie(json_encode($response)); + } + $descriptionFontWeight = Tools::getValue('description_font_weight', $objImage->description_font_weight); + if (!in_array($descriptionFontWeight, array('400', '700'))) { + $response['errors'][] = $this->l('Invalid description font weight.'); + $this->ajaxDie(json_encode($response)); + } + + $replacementFile = isset($_FILES['header_image_file']) ? $_FILES['header_image_file'] : null; + $hasReplacementFile = ($replacementFile && isset($replacementFile['error']) && $replacementFile['error'] === UPLOAD_ERR_OK && $replacementFile['size'] > 0); + $newImageName = null; + + if ($hasReplacementFile) { + if ($error = ImageManager::validateUpload($replacementFile, Tools::getMaxUploadSize((int)Configuration::get('PS_LIMIT_UPLOAD_IMAGE_VALUE') * 1024 * 1024))) { + $response['errors'][] = $error; + $this->ajaxDie(json_encode($response)); + } + if (!HotelHeaderImage::createMediaDirectory()) { + $response['errors'][] = $this->l('Could not create the media directory.'); + $this->ajaxDie(json_encode($response)); + } + + $ext = strtolower(pathinfo($replacementFile['name'], PATHINFO_EXTENSION)); + $isGif = ($ext === 'gif'); + $outExt = $isGif ? 'gif' : 'jpg'; + do { + $newImageName = bin2hex(random_bytes(16)).'.'.$outExt; + } while (file_exists(_PS_IMG_DIR_.'hotel_header_media/'.$newImageName)); + + $destPath = _PS_IMG_DIR_.'hotel_header_media/'.$newImageName; + $saved = $isGif ? (bool)move_uploaded_file($replacementFile['tmp_name'], $destPath) : (bool)ImageManager::resize($replacementFile['tmp_name'], $destPath); + + if (!$saved) { + $response['errors'][] = $this->l('Failed to save image file.'); + $this->ajaxDie(json_encode($response)); + } + } + + $oldImageName = $objImage->name; + $objImage->title = $titleByLang; + $objImage->description = $descriptionByLang; + $objImage->description_color = $descriptionColor; + $objImage->description_font_size = $descriptionFontSize; + $objImage->description_font_weight = $descriptionFontWeight; + if ($newImageName) { + $objImage->name = $newImageName; + } + if (!$objImage->save()) { + if ($newImageName && file_exists($destPath)) { + unlink($destPath); + } + $response['errors'][] = $this->l('Failed to update image.'); + $this->ajaxDie(json_encode($response)); + } + + if ($newImageName) { + $oldPath = _PS_IMG_DIR_.'hotel_header_media/'.$oldImageName; + if (file_exists($oldPath)) { + unlink($oldPath); + } + } + + $defaultLangId = (int)Configuration::get('PS_LANG_DEFAULT'); + $response['success'] = true; + $response['active'] = (int)$objImage->active; + $response['confirmations'] = $this->l('Image updated successfully.'); + $response['title'] = isset($titleByLang[$defaultLangId]) ? $titleByLang[$defaultLangId] : ''; + $response['titles_json'] = json_encode((object)$titleByLang); + $response['description'] = isset($descriptionByLang[$defaultLangId]) ? $descriptionByLang[$defaultLangId] : ''; + $response['descriptions_json'] = json_encode((object)$descriptionByLang); + $response['description_color'] = $descriptionColor; + $response['description_font_size'] = $descriptionFontSize; + $response['description_font_weight'] = $descriptionFontWeight; + + if ($newImageName) { + $shopId = (int)$this->context->shop->id; + $srcPath = _PS_IMG_DIR_.'hotel_header_media/'.$newImageName; + $cacheName = 'htl_header_image_mini_'.$id.'_'.$shopId.'.jpg'; + $response['thumb'] = ImageManager::thumbnail($srcPath, $cacheName, 45, 'jpg', true, true); + $response['thumb_src'] = $this->context->link->getMediaLink(_PS_IMG_.'hotel_header_media/'.$newImageName).'?'.time(); + } + + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessDeleteMedia() + { + $response = array('errors' => array(), 'success' => false); + $id = (int)Tools::getValue('id_header_image'); + + if (!$id) { + $response['errors'][] = $this->l('Invalid item ID.'); + $this->ajaxDie(json_encode($response)); + } + + $objImage = new HotelHeaderImage($id); + if (!Validate::isLoadedObject($objImage)) { + $response['errors'][] = $this->l('Image not found.'); + $this->ajaxDie(json_encode($response)); + } + + if ($objImage->active) { + $activeImages = HotelHeaderImage::getItems(1); + if (is_array($activeImages) && count($activeImages) <= 1) { + $response['errors'][] = $this->l('At least one active image is required'); + $this->ajaxDie(json_encode($response)); + } + } + + if (!$objImage->delete()) { + $response['errors'][] = $this->l('Unable to delete image.'); + $this->ajaxDie(json_encode($response)); + } + + $response['success'] = true; + $response['confirmations'] = $this->l('Image deleted successfully.'); + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessDeleteVideo() + { + $response = array('errors' => array(), 'success' => false); + + if (!HotelHeaderImage::getVideoConfig()) { + $response['errors'][] = $this->l('No video is currently set.'); + $this->ajaxDie(json_encode($response)); + } + + HotelHeaderImage::deleteVideoConfig(); + $response['success'] = true; + $response['confirmations'] = $this->l('Video deleted successfully.'); + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessToggleImageActive() + { + $response = array('errors' => array(), 'success' => false); + $id = (int)Tools::getValue('id_header_image'); + $active = (int)(bool)Tools::getValue('active'); + + if (!$id) { + $response['errors'][] = $this->l('Invalid item ID.'); + $this->ajaxDie(json_encode($response)); + } + + $objImage = new HotelHeaderImage($id); + if (!Validate::isLoadedObject($objImage)) { + $response['errors'][] = $this->l('Image not found.'); + $this->ajaxDie(json_encode($response)); + } + + if ($active === 0) { + $activeImages = HotelHeaderImage::getItems(1); + if (is_array($activeImages) && count($activeImages) <= 1) { + $response['errors'][] = $this->l('At least one image must remain active.'); + $this->ajaxDie(json_encode($response)); + } + } + + $objImage->active = $active; + if (!$objImage->save()) { + $response['errors'][] = $this->l('Unable to update active status.'); + $this->ajaxDie(json_encode($response)); + } + + $response['success'] = true; + $response['confirmations'] = $this->l('The status has been successfully updated.'); + $this->ajaxDie(json_encode($response)); + } + + public function ajaxProcessSaveImagePositions() + { + $ids = Tools::getValue('image_ids', array()); + if (!is_array($ids)) { + $this->ajaxDie(json_encode(array('success' => false))); + } + + foreach ($ids as $position => $id) { + $objImage = new HotelHeaderImage((int)$id); + if (!Validate::isLoadedObject($objImage)) { + $this->ajaxDie(json_encode(array('success' => false, 'errors' => array($this->l('One or more image IDs are invalid.'))))); + } + $objImage->position = (int)$position; + $objImage->update(); + } + $this->ajaxDie(json_encode(array( + 'success' => true, + 'confirmations' => $this->l('The selected images have successfully been moved.'), + ))); + } + + public function ajaxProcessBulkUpdateImages() + { + $response = array('errors' => array(), 'success' => false); + + $ids = array_values(array_unique(array_filter(array_map('intval', (array)Tools::getValue('id_header_image', array()))))); + if (!$ids) { + $response['errors'][] = $this->l('No images selected.'); + $this->ajaxDie(json_encode($response)); + } + + $activeVal = Tools::getValue('active', ''); + if ($activeVal !== '' && !in_array($activeVal, array('0', '1'))) { + $response['errors'][] = $this->l('Invalid status selected.'); + $this->ajaxDie(json_encode($response)); + } + + if ($activeVal === '0') { + $activeImages = HotelHeaderImage::getItems(1); + $activeIds = array_map('intval', array_column($activeImages, 'id_header_image')); + $activeToDisable = array_intersect($ids, $activeIds); + if (count($activeIds) - count($activeToDisable) < 1) { + $response['errors'][] = $this->l('At least one image must remain active.'); + $this->ajaxDie(json_encode($response)); + } + } + + $updateTitle = (bool)Tools::getValue('update_title', false); + $titleByLang = array(); + if ($updateTitle) { + foreach (Language::getLanguages(false) as $lang) { + $titleByLang[$lang['id_lang']] = trim(Tools::getValue('title_'.$lang['id_lang'], '')); + } + foreach ($titleByLang as $titleValue) { + if (!Validate::isGenericName($titleValue)) { + $response['errors'][] = $this->l('Invalid title. Characters < > = { } are not allowed.'); + $this->ajaxDie(json_encode($response)); + } + if (Tools::strlen($titleValue) > HotelHeaderImage::TITLE_LIMIT) { + $response['errors'][] = sprintf($this->l('Title is too long: %d chars max.'), HotelHeaderImage::TITLE_LIMIT); + $this->ajaxDie(json_encode($response)); + } + } + } + + $updateDescription = (bool)Tools::getValue('update_description', false); + $descriptionByLang = array(); + if ($updateDescription) { + $descriptionLimit = (int)Configuration::get('PS_SHORT_DESC_LIMIT') ?: Configuration::PS_SHORT_DESC_LIMIT; + foreach (Language::getLanguages(false) as $lang) { + $descriptionByLang[$lang['id_lang']] = trim(Tools::getValue('description_'.$lang['id_lang'], '')); + } + foreach ($descriptionByLang as $descriptionValue) { + if (!Validate::isGenericName($descriptionValue)) { + $response['errors'][] = $this->l('Invalid description. Characters < > = { } are not allowed.'); + $this->ajaxDie(json_encode($response)); + } + if (Tools::strlen($descriptionValue) > $descriptionLimit) { + $response['errors'][] = sprintf($this->l('Description is too long: %d chars max.'), $descriptionLimit); + $this->ajaxDie(json_encode($response)); + } + } + } + + $descriptionColor = trim(Tools::getValue('description_color', '')); + if ($descriptionColor !== '' && !preg_match('/^#[0-9a-fA-F]{6}$/', $descriptionColor)) { + $response['errors'][] = $this->l('Invalid description color. Use a 6-digit hex value (e.g. #ffffff).'); + $this->ajaxDie(json_encode($response)); + } + + $descriptionFontSize = (int)Tools::getValue('description_font_size', 0); + if ($descriptionFontSize !== 0 && ($descriptionFontSize < 8 || $descriptionFontSize > 72)) { + $response['errors'][] = $this->l('Description font size must be between 8 and 72 pixels.'); + $this->ajaxDie(json_encode($response)); + } + + $descriptionFontWeight = Tools::getValue('description_font_weight', ''); + if ($descriptionFontWeight !== '' && !in_array($descriptionFontWeight, array('400', '700'))) { + $response['errors'][] = $this->l('Invalid description font weight.'); + $this->ajaxDie(json_encode($response)); + } + + $defaultLangId = (int)Configuration::get('PS_LANG_DEFAULT'); + $updatedRows = array(); + foreach ($ids as $id) { + $objImage = new HotelHeaderImage($id); + if (!Validate::isLoadedObject($objImage)) { + continue; + } + + if ($activeVal !== '') { + $objImage->active = (int)$activeVal; + } + if ($updateTitle) { + $objImage->title = $titleByLang; + } + if ($updateDescription) { + $objImage->description = $descriptionByLang; + } + if ($descriptionColor !== '') { + $objImage->description_color = $descriptionColor; + } + if ($descriptionFontSize !== 0) { + $objImage->description_font_size = $descriptionFontSize; + } + if ($descriptionFontWeight !== '') { + $objImage->description_font_weight = $descriptionFontWeight; + } + $objImage->save(); + + $currentTitles = is_array($objImage->title) ? $objImage->title : array(); + $currentDescriptions = is_array($objImage->description) ? $objImage->description : array(); + $updatedRows[] = array( + 'id' => (int)$objImage->id, + 'active' => (int)$objImage->active, + 'title' => isset($currentTitles[$defaultLangId]) ? $currentTitles[$defaultLangId] : '', + 'titles_json' => json_encode((object)$currentTitles), + 'description' => isset($currentDescriptions[$defaultLangId]) ? $currentDescriptions[$defaultLangId] : '', + 'descriptions_json' => json_encode((object)$currentDescriptions), + 'description_color' => $objImage->description_color, + 'description_font_size' => $objImage->description_font_size, + 'description_font_weight' => $objImage->description_font_weight, + ); + } + + if (!$updatedRows) { + $response['errors'][] = $this->l('No valid images were updated.'); + $this->ajaxDie(json_encode($response)); + } + + $response['success'] = true; + $response['data']['rows'] = $updatedRows; + $response['confirmations'] = $this->l('Selected images updated successfully.'); + $this->ajaxDie(json_encode($response)); + } + + public function setMedia() + { + parent::setMedia(); + $this->addJqueryPlugin('tablednd'); + $this->addJqueryPlugin('colorpicker'); + $adminJsPath = _PS_MODULE_DIR_.'hotelreservationsystem/views/js/admin/qhrs_hotel_header_image_admin.js'; + $this->addJS(_MODULE_DIR_.'hotelreservationsystem/views/js/admin/qhrs_hotel_header_image_admin.js?'.@filemtime($adminJsPath)); + $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'); + $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/admin/qhrs_header_media.css'); + } +} diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 5eda7e134..00de810a6 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -1162,7 +1162,7 @@ public function ajaxProcessGetCalenderData() // add fullcalender plugin $this->addJqueryUI('ui.tooltip', 'base', true); - $this->removeJS(Media::getJqueryUIPath('effects.core', 'base', false), false); + $this->removeJS(Media::getJqueryUIPath('ui.effect', 'base', false), false); $this->addCSS(array(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css')); $this->addCSS(_PS_JS_DIR_.'fullcalendar/main.css'); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php index 81fba0d1a..c2749ccfa 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php @@ -692,7 +692,7 @@ class AdminOrderRefundRequestsController extends ModuleAdminController if ($this->display == 'view') { $this->addJqueryUI('ui.tooltip', 'base', true); - $this->removeJS(Media::getJqueryUIPath('effects.core', 'base', false), false); + $this->removeJS(Media::getJqueryUIPath('ui.effect', 'base', false), false); $this->addJs(_MODULE_DIR_.$this->module->name.'/views/js/admin/wk_refund_request.js'); $this->addCSS(_MODULE_DIR_.$this->module->name.'/views/css/admin/wk_refund_request.css'); diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index 34a0d54bc..d7b44525f 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -56,6 +56,7 @@ require_once 'classes/ServiceProductOption.php'; require_once 'classes/HotelSettingsLink.php'; require_once 'classes/HotelBookingDocument.php'; +require_once 'classes/HotelHeaderImage.php'; // Web services classes require_once 'classes/WebserviceSpecificManagementHotelAri.php'; diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index a1319eab5..fc4006c28 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -71,7 +71,45 @@ class HotelReservationSystem extends Module } } //End - $this->context->controller->addCSS($this->_path.'/views/css/HotelReservationFront.css'); + if (Tools::getValue('controller') == 'index') { + $headerMediaFrontJs = _PS_MODULE_DIR_.'hotelreservationsystem/views/js/qhrs_hotel_header_media_front.js'; + $this->context->controller->addJS($this->_path.'views/js/qhrs_hotel_header_media_front.js?'.@filemtime($headerMediaFrontJs)); + + $mediaTypeInt = (int)(Configuration::get('QLO_HEADER_MEDIA_TYPE') ?: HotelHeaderImage::MEDIA_TYPE_IMAGE); + if ($mediaTypeInt === HotelHeaderImage::MEDIA_TYPE_VIDEO) { + $videoConfig = HotelHeaderImage::getVideoConfig(); + if ($videoConfig) { + $mimeMap = array('mp4' => 'video/mp4', 'webm' => 'video/webm', 'ogg' => 'video/ogg'); + if ($videoConfig['source_type'] === 'upload') { + $ext = strtolower(pathinfo($videoConfig['name'], PATHINFO_EXTENSION)); + } else { + $urlPath = parse_url($videoConfig['name'], PHP_URL_PATH); + $ext = strtolower(pathinfo($urlPath ?: '', PATHINFO_EXTENSION)); + } + $videoConfig['mime_type'] = isset($mimeMap[$ext]) ? $mimeMap[$ext] : 'video/mp4'; + $headerMediaItems = array($videoConfig); + } else { + $headerMediaItems = array(); + } + } else { + $headerMediaItems = HotelHeaderImage::getItems(); + } + $this->context->smarty->assign(array( + 'QLO_HEADER_MEDIA_TYPE' => $mediaTypeInt, + 'QLO_HEADER_MEDIA_TYPE_IMAGE' => HotelHeaderImage::MEDIA_TYPE_IMAGE, + 'QLO_HEADER_MEDIA_TYPE_VIDEO' => HotelHeaderImage::MEDIA_TYPE_VIDEO, + 'WK_HEADER_NAV_TYPE_DOTS' => HotelHeaderImage::NAV_TYPE_DOTS, + 'QLO_HEADER_ANIM_TYPE_SLIDE' => HotelHeaderImage::ANIMATION_TYPE_SLIDE, + 'headerMediaItems' => $headerMediaItems, + 'headerSliderConfig' => array( + 'nav_type' => (int)(Configuration::get('QLO_HEADER_SLIDER_NAV_TYPE') ?: HotelHeaderImage::NAV_TYPE_ARROWS), + 'auto_play' => (int)Configuration::get('QLO_HEADER_SLIDER_AUTO_PLAY'), + 'interval' => (int)Configuration::get('QLO_HEADER_SLIDER_INTERVAL'), + 'anim_type' => (int)(Configuration::get('QLO_HEADER_SLIDER_ANIM_TYPE') ?: HotelHeaderImage::ANIMATION_TYPE_SLIDE), + ), + )); + } + $this->context->controller->addCSS($this->_path.'/views/css/qhrs_header_media.css'); $this->context->controller->addJS($this->_path.'/views/js/HotelReservationFront.js'); } @@ -261,12 +299,19 @@ class HotelReservationSystem extends Module public function hookDisplayAfterHookTop() { if (Tools::getValue('controller') == 'index') { - $this->context->smarty->assign( - array( - 'WK_HTL_CHAIN_NAME' => Configuration::get('WK_HTL_CHAIN_NAME', $this->context->language->id), - 'WK_HTL_TAG_LINE' => Configuration::get('WK_HTL_TAG_LINE', $this->context->language->id), - ) - ); + $headerMediaItems = $this->context->smarty->getTemplateVars('headerMediaItems'); + $firstItem = ($headerMediaItems && !empty($headerMediaItems[0])) ? $headerMediaItems[0] : array(); + $this->context->smarty->assign(array( + 'wkHeaderMediaTitle' => !empty($firstItem['title']) ? $firstItem['title'] : '', + 'wkHeaderMediaDescription' => !empty($firstItem['description']) ? $firstItem['description'] : '', + 'wkDescriptionColor' => !empty($firstItem['description_color']) ? $firstItem['description_color'] : '#ffffff', + 'wkDescriptionFontSize' => !empty($firstItem['description_font_size']) ? (int)$firstItem['description_font_size'] : 16, + 'wkDescriptionFontWeight' => !empty($firstItem['description_font_weight']) ? $firstItem['description_font_weight'] : '400', + 'wkHeaderContentAlign' => (int)(Configuration::get('QLO_HEADER_CONTENT_ALIGN') ?: HotelHeaderImage::CONTENT_ALIGN_CENTER), + 'QLO_HEADER_MEDIA_TYPE' => (int)(Configuration::get('QLO_HEADER_MEDIA_TYPE') ?: HotelHeaderImage::MEDIA_TYPE_IMAGE), + 'QLO_HEADER_MEDIA_TYPE_IMAGE' => HotelHeaderImage::MEDIA_TYPE_IMAGE, + 'QLO_HEADER_MEDIA_TYPE_VIDEO' => HotelHeaderImage::MEDIA_TYPE_VIDEO, + )); return $this->display(__FILE__, 'headerHotelDescBlock.tpl'); } } @@ -414,7 +459,6 @@ class HotelReservationSystem extends Module // update configuration keys $configKeys = array( 'WK_HTL_CHAIN_NAME', - 'WK_HTL_TAG_LINE', 'WK_HTL_SHORT_DESC', ); HotelHelper::updateConfigurationLangKeys($newIdLang, $configKeys); @@ -448,6 +492,7 @@ class HotelReservationSystem extends Module // Controllers without tabs $this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false); $this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false); + $this->installTab('AdminHotelHeaderImage', 'Header Image Configuration', 'AdminHotelConfigurationSetting', false); $this->installTab('AdminBookingDocument', 'Booking Documents', false, false); $this->installTab('AdminHotelImageCategory', 'Hotel Image Category', false, false); @@ -555,9 +600,10 @@ class HotelReservationSystem extends Module 'WK_ROOM_LEFT_WARNING_NUMBER', 'WK_HTL_ESTABLISHMENT_YEAR', 'WK_HTL_CHAIN_NAME', + 'WK_HTL_TAG_LINE', 'WK_TITLE_HEADER_BLOCK', 'WK_CONTENT_HEADER_BLOCK', - 'WK_HTL_HEADER_IMAGE', + 'WK_HOTEL_HEADER_IMAGE', 'WK_ALLOW_ADVANCED_PAYMENT', 'WK_ADVANCED_PAYMENT_GLOBAL_MIN_AMOUNT', 'WK_ADVANCED_PAYMENT_INC_TAX', @@ -567,6 +613,14 @@ class HotelReservationSystem extends Module 'WK_CUSTOMER_SUPPORT_PHONE_NUMBER', 'WK_CUSTOMER_SUPPORT_EMAIL', 'WK_DISPLAY_CONTACT_PAGE_HOTEL_LIST', + 'QLO_HEADER_MEDIA_TYPE', + 'QLO_HEADER_CONTENT_ALIGN', + 'QLO_HEADER_VIDEO_SOURCE_TYPE', + 'QLO_HEADER_VIDEO_NAME', + 'QLO_HEADER_SLIDER_NAV_TYPE', + 'QLO_HEADER_SLIDER_AUTO_PLAY', + 'QLO_HEADER_SLIDER_INTERVAL', + 'QLO_HEADER_SLIDER_ANIM_TYPE', 'QLO_USE_TOURISM_TAX', 'QLO_TOURISM_TAX_GROSSED_UP', ); diff --git a/modules/hotelreservationsystem/views/css/HotelReservationFront.css b/modules/hotelreservationsystem/views/css/HotelReservationFront.css deleted file mode 100644 index b268f77b8..000000000 --- a/modules/hotelreservationsystem/views/css/HotelReservationFront.css +++ /dev/null @@ -1,82 +0,0 @@ -/* ===== headerHotelDescBlock.tpl ===== */ -.header-desc-container { - bottom: 0; - left: 0; - position: absolute; - right: 0; - top: 0; - z-index: -10; - /*height: 100%;*/ -} -.header-desc-wrapper { - display: table; - height: 100%; - width: 100%; -} -.header-desc-primary { - display: table-cell; - vertical-align: middle; - text-align: center; - color: #FFFFFF; -} -.header-desc-welcome{ - font-size: 18px; - font-weight: 300; - margin: 0; -} - -.header-desc-primary hr { - margin-bottom: 10px; -} - -.heasder-desc-hr-first { - width: 42px; - margin-top: 10px; -} - -.header-hotel-name { - font-size: 55px; - font-weight: 400; - margin-top: 5px; - margin-bottom: 25px; -} - -.header-hotel-desc { - font-size: 400; - font-size: 18px; - line-height: 24px; -} - -.heasder-desc-hr-second { - width: 190px; - margin-top: 30px; -} - -@media (max-width: 767px) { -.topSubSecondaryBlock { - margin-top: 0px; } } - -/* ===== headerHotelDescBlock.tpl ===== */ - -.copyRightWrapper { - background-color: #242424; - padding: 30px; -} -.copyRightWrapper p { - color: #868686; - font-size: 16px; - font-weight: 400; - margin: 0; - text-align: center; -} - -.copyRightWrapper { - background-color: #242424; - padding: 30px; - width: 100%; } - .copyRightWrapper .copyRight { - color: #868686; - font-size: 16px; - margin: 0; - text-align: center; - line-height: 23px; } \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/css/admin/qhrs_header_media.css b/modules/hotelreservationsystem/views/css/admin/qhrs_header_media.css new file mode 100644 index 000000000..741193932 --- /dev/null +++ b/modules/hotelreservationsystem/views/css/admin/qhrs_header_media.css @@ -0,0 +1,64 @@ +/** +* 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 +*/ + +.qlo-video-preview-card { + background: #111; + border-radius: 4px; + overflow: hidden; + margin-bottom: 10px; + max-width: 480px; + display: inline-block; + vertical-align: top; + width: 100%; +} + +.qlo-video-preview-player { + display: block; + width: 100%; + max-height: 240px; + background: #000; +} + +.qlo-img-thumb { + width: 120px; + height: 75px; + -o-object-fit: cover; + object-fit: cover; + display: block; +} + +#qlo-image-table tbody tr.qlo-img-row:hover { + background-color: #f9f9f9; +} + +.qlo-img-tagline-cell { + max-width: 220px; + color: #555; + vertical-align: middle !important; +} + +#qlo-img-edit-thumb { + max-width: 160px; + max-height: 100px; + object-fit: cover; + border-radius: 3px; +} diff --git a/modules/hotelreservationsystem/views/css/qhrs_header_media.css b/modules/hotelreservationsystem/views/css/qhrs_header_media.css new file mode 100644 index 000000000..210a4d8d1 --- /dev/null +++ b/modules/hotelreservationsystem/views/css/qhrs_header_media.css @@ -0,0 +1,217 @@ +/** +* 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 +*/ + +.header-ext-dots { + position: absolute; + bottom: 120px; + left: 0; + right: 0; + text-align: center; + z-index: 15; + pointer-events: none; +} +.header-ext-dots .owl-dot { + display: inline-block; + margin: 0 5px; + cursor: pointer; + pointer-events: all; +} +.header-ext-dots .owl-dot span { + display: block; + width: 10px; + height: 10px; + border-radius: 50%; + background: rgba(255, 255, 255, 0.5); + border: 1px solid rgba(255, 255, 255, 0.8); + transition: background 0.25s ease; +} +.header-ext-dots .owl-dot.active span, +.header-ext-dots .owl-dot:hover span { + background: #ffffff; +} + +/* ===== Content alignment (1=left, 2=center, 3=right) ===== */ +.header-align-1 { text-align: left; } +.header-align-2 { text-align: center; } +.header-align-3 { text-align: right; } + +.header-align-1 .heasder-desc-hr-second { margin-left: 0; margin-right: auto; } +.header-align-3 .heasder-desc-hr-second { margin-left: auto; margin-right: 0; } + + +/* ===== headerHotelDescBlock.tpl ===== */ +.header-desc-container { + bottom: 0; + left: 0; + position: absolute; + right: 0; + top: 0; + z-index: -10; + /*height: 100%;*/ +} + +.header-bg-video { + min-height: 100%; +} +.header-desc-wrapper { + display: table; + height: 100%; + width: 100%; +} +.header-desc-primary { + display: table-cell; + vertical-align: middle; + text-align: center; + color: #FFFFFF; +} +.header-desc-primary hr { + margin-bottom: 10px; +} + +.header-hotel-name { + font-size: 55px; + font-weight: 400; + margin-top: 5px; + margin-bottom: 25px; +} + +.header-hotel-desc { + font-size: 400; + font-size: 18px; + line-height: 24px; +} + +.heasder-desc-hr-second { + display: none; +} + +/* Owl carousel slide animation classes */ +.wkFadeOut { animation: wkFadeOut 0.7s forwards; } +.wkFadeIn { animation: wkFadeIn 0.7s forwards; } +.wkZoomOut { animation: wkZoomOut 0.7s forwards; } +.wkZoomIn { animation: wkZoomIn 0.7s forwards; } +.wkBlurOut { animation: wkBlurOut 0.7s forwards; } +.wkBlurIn { animation: wkBlurIn 0.7s forwards; } +.wkSlideOut { animation: wkSlideOut 0.7s forwards; } +.wkSlideIn { animation: wkSlideIn 0.7s forwards; } + +@keyframes wkFadeOut { from { opacity:1; } to { opacity:0; } } +@keyframes wkFadeIn { from { opacity:0; } to { opacity:1; } } +@keyframes wkZoomOut { from { opacity:1; transform:scale(1); } to { opacity:0; transform:scale(1.15); } } +@keyframes wkZoomIn { from { opacity:0; transform:scale(0.88); } to { opacity:1; transform:scale(1); } } +@keyframes wkBlurOut { from { opacity:1; filter:blur(0); } to { opacity:0; filter:blur(10px); } } +@keyframes wkBlurIn { from { opacity:0; filter:blur(10px); } to { opacity:1; filter:blur(0); } } +@keyframes wkSlideOut { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(-60px); } } +@keyframes wkSlideIn { from { opacity:0; transform:translateX(60px); } to { opacity:1; transform:translateX(0); } } + +/* Description slide animation on slide change */ +.js-header-description { + transition: opacity 0.4s ease, transform 0.4s ease; +} +.js-header-description.wk-tagline-out { + opacity: 0; + transform: translateY(-10px); +} +.js-header-description.wk-tagline-in { + opacity: 1; + transform: translateY(0); +} + +.header-media-layer { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: -11; + overflow: hidden; + background-size: cover; + background-position: center center; + background-repeat: no-repeat; +} + +.header-media-layer::after { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1; + pointer-events: none; +} + +.header-media-layer .owl-carousel, +.header-media-layer .owl-stage-outer, +.header-media-layer .owl-stage, +.header-media-layer .owl-item { + height: 100%; +} + +.header-slide-img { + width: 100%; + height: 100%; + background-size: cover; + background-position: center center; + background-repeat: no-repeat; +} + + +.header-media-nav-wrapper { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 15; + pointer-events: none; +} + +.header-media-btn { + position: absolute; + top: 50%; + transform: translateY(-50%); + pointer-events: all; + background: rgba(0, 0, 0, 0.4); + color: #fff; + border: none; + border-radius: 2px; + padding: 8px 14px; + font-size: 20px; + line-height: 1; + cursor: pointer; + transition: background 0.2s; + outline: none; +} + +.header-media-btn:hover { + background: rgba(0, 0, 0, 0.65); + color: #fff; +} + +.js-header-media-prev { + left: 15px; +} + +.js-header-media-next { + right: 15px; +} \ No newline at end of file diff --git a/modules/hotelreservationsystem/views/js/admin/qhrs_hotel_header_image_admin.js b/modules/hotelreservationsystem/views/js/admin/qhrs_hotel_header_image_admin.js new file mode 100644 index 000000000..3f65caad4 --- /dev/null +++ b/modules/hotelreservationsystem/views/js/admin/qhrs_hotel_header_image_admin.js @@ -0,0 +1,682 @@ +/** +* 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 +*/ + +$(document).ready(function () { + + $('#qlo-media-type').on('change', function () { + var type = parseInt($(this).val(), 10); + if (type === qloHmMediaTypeImage) { + $('#qlo-video-settings').hide(); + $('#qlo-image-settings, #qlo-image-panel, #qlo-slider-info').show(); + closeImgForm(); + } else { + closeImgForm(); + $('#qlo-image-settings, #qlo-image-panel, #qlo-slider-info').hide(); + $('#qlo-video-settings').show(); + } + }); + + $('#qlo-header-media-form').on('submit', function (e) { + var newType = parseInt($('#qlo-media-type').val(), 10); + if (newType === qloHmMediaTypeVideo && qloHmMediaType === qloHmMediaTypeImage) { + var imageCount = $('#qlo-image-tbody .qlo-img-row').length; + if (imageCount > 1 && $('#qlo-confirm-delete-images').val() !== '1') { + e.preventDefault(); + $('#qlo-confirm-switch-video-modal').modal('show'); + return false; + } + } + }); + + $('#qlo-confirm-switch-video-btn').on('click', function () { + $('#qlo-confirm-switch-video-modal').modal('hide'); + $('#qlo-confirm-delete-images').val('1'); + $('#qlo-header-media-form')[0].submit(); + }); + + var pendingBulkDeleteForm = null; + var pendingBulkDeleteAction = null; + var editImagePreviewUrl = null; + + function revokeEditImagePreview() { + if (editImagePreviewUrl) { + URL.revokeObjectURL(editImagePreviewUrl); + editImagePreviewUrl = null; + } + } + + $(document).on('click', '.qlo-bulk-delete-images-trigger', function (e) { + e.preventDefault(); + pendingBulkDeleteForm = $(this).closest('form').get(0); + pendingBulkDeleteAction = $(this).data('action'); + $('#qlo-confirm-bulk-delete-modal').modal('show'); + }); + + $('#qlo-confirm-bulk-delete-btn').on('click', function () { + $('#qlo-confirm-bulk-delete-modal').modal('hide'); + if (pendingBulkDeleteForm && pendingBulkDeleteAction) { + sendBulkAction(pendingBulkDeleteForm, pendingBulkDeleteAction); + } + }); + + $(document).on('change', 'input[name="QLO_HEADER_SLIDER_AUTO_PLAY"]', function () { + if ($(this).val() === '1') { + $('#qlo-slide-interval-group').show(200); + } else { + $('#qlo-slide-interval-group').hide(200); + } + }); + + hideOtherLanguage(qloHmDefaultLangId); + + function updateImgFileNameHm(files) { + var names = []; + for (var i = 0; files && i < files.length; i++) { + names.push(files[i].name); + } + $('#qlo-img-form-file-name').val(names.join(', ')); + } + + $('#qlo-img-form-file-selectbutton, #qlo-img-form-file-name').on('click', function () { + $('#qlo-img-form-file').trigger('click'); + }); + + $('#qlo-img-form-file-name').on('dragenter dragover', function (e) { + e.stopPropagation(); + e.preventDefault(); + }); + + $('#qlo-img-form-file-name').on('drop', function (e) { + e.preventDefault(); + var files = e.originalEvent.dataTransfer.files; + document.getElementById('qlo-img-form-file').files = files; + updateImgFileNameHm(files); + }); + + $('#qlo-img-form-file').on('change', function () { + updateImgFileNameHm(this.files); + }); + + $('#qlo-img-edit-file-selectbutton, #qlo-img-edit-file-name').on('click', function () { + $('#qlo-img-edit-file').trigger('click'); + }); + + $('#qlo-img-edit-file').on('change', function () { + var file = this.files && this.files[0] ? this.files[0] : null; + $('#qlo-img-edit-file-name').val(file ? file.name : ''); + + revokeEditImagePreview(); + if (file) { + editImagePreviewUrl = URL.createObjectURL(file); + $('#qlo-img-edit-thumb').attr('src', editImagePreviewUrl); + $('#qlo-img-edit-preview-group').show(); + } + }); + + $(document).on('change', '#qlo-source-type', function () { + if ($(this).val() === 'url') { + $('#qlo-vid-file-wrap').hide(); + $('#qlo-vid-url-wrap').show(); + $('#qlo-current-video-wrap').hide(); + } else { + $('#qlo-vid-file-wrap').show(); + $('#qlo-vid-url-wrap').hide(); + if ($('#qlo-current-video-wrap').length) { + $('#qlo-current-video-wrap').show(); + } + } + }); + + $(document).on('change', '#qlo-video-file-input', function () { + var file = this.files && this.files[0] ? this.files[0] : null; + var $hint = $('.qlo-vid-filename'); + if (file && typeof qloHmMaxVideoUpload !== 'undefined' && qloHmMaxVideoUpload > 0 && file.size > qloHmMaxVideoUpload) { + this.value = ''; + $hint.hide(); + showErrorMessage(qloHmI18n.fileTooLarge); + return; + } + if (file) { + $hint.text(file.name).show(); + } else { + $hint.hide(); + } + }); + + $(document).on('click', '#qlo-vid-file-add-btn', function () { + $('#qlo-video-file-input').trigger('click'); + }); + + var videoUrlMimeMap = { mp4: 'video/mp4', webm: 'video/webm', ogg: 'video/ogg' }; + + $(document).on('input change', '#qlo-video-url-input', function () { + var url = $.trim($(this).val()); + var $wrap = $('#qlo-video-url-preview-wrap'); + var $player = $('#qlo-video-url-preview-player')[0]; + var $source = $('#qlo-video-url-preview-source'); + + if (!/^https?:\/\//i.test(url)) { + $wrap.hide(); + return; + } + + var ext = (url.split('?')[0].split('.').pop() || '').toLowerCase(); + $source.attr('src', url); + $source.attr('type', videoUrlMimeMap[ext] || 'video/mp4'); + if ($player) { $player.load(); } + $wrap.show(); + }); + + $('#qlo-add-image-btn').on('click', function () { + openImgForm('add'); + }); + + $(document).on('click', '.qlo-edit-img', function () { + var $row = $(this).closest('tr.qlo-img-row'); + var id = parseInt($row.data('id'), 10); + var titles = $row.data('titles') || {}; + var descriptions = $row.data('descriptions') || {}; + var isActive = $row.find('.js-toggle-active').hasClass('action-enabled'); + var thumbSrc = $row.attr('data-thumb-src') || ''; + var descColor = $row.attr('data-description-color') || '#ffffff'; + var descFontSize = parseInt($row.attr('data-description-font-size') || 16, 10); + var descFontWeight = $row.attr('data-description-font-weight') || '400'; + openImgForm('edit', id, titles, descriptions, isActive, thumbSrc, descColor, descFontSize, descFontWeight); + }); + + function updateBulkUpdateTriggerState() { + $('#qlo-bulk-update-trigger').attr('disabled', !$('.qlo-img-checkbox:checked').length); + } + + $(document).on('change', '.qlo-img-checkbox', updateBulkUpdateTriggerState); + $('.qlo-select-all-images, .qlo-unselect-all-images').on('click', updateBulkUpdateTriggerState); + + $('#qlo-bulk-update-modal').on('show.bs.modal', function (e) { + if ($(e.relatedTarget).attr('disabled')) { + return false; + } + $('#qlo-bulk-active').val(''); + $('#qlo_bulk_update_title_off').prop('checked', true); + $('#qlo-bulk-title-fields-wrap').hide(); + $('.qlo-bulk-title-field').val(''); + $('#qlo_bulk_update_description_off').prop('checked', true); + $('#qlo-bulk-description-fields-wrap').hide(); + $('.qlo-bulk-description-field').val(''); + $('#qlo-bulk-desc-color').val('').trigger('keyup'); + $('#qlo-bulk-desc-font-size').val(0); + $('#qlo-bulk-desc-font-weight').val(''); + hideOtherLanguage(qloHmDefaultLangId); + }); + + $(document).on('change', 'input[name="qlo_bulk_update_title"]', function () { + if ($(this).val() === '1') { + $('#qlo-bulk-title-fields-wrap').show(200); + } else { + $('#qlo-bulk-title-fields-wrap').hide(200); + } + }); + + $(document).on('change', 'input[name="qlo_bulk_update_description"]', function () { + if ($(this).val() === '1') { + $('#qlo-bulk-description-fields-wrap').show(200); + } else { + $('#qlo-bulk-description-fields-wrap').hide(200); + } + }); + + $('#qlo-bulk-update-apply').on('click', function () { + var ids = $('.qlo-img-checkbox:checked').map(function () { return $(this).val(); }).get(); + var updateTitle = $('input[name="qlo_bulk_update_title"]:checked').val() === '1'; + var updateDescription = $('input[name="qlo_bulk_update_description"]:checked').val() === '1'; + var postData = { + ajax: 1, action: 'bulkUpdateImages', token: qloHmToken, + id_header_image: ids, + active: $('#qlo-bulk-active').val(), + update_title: updateTitle ? 1 : 0, + update_description: updateDescription ? 1 : 0, + description_color: $.trim($('#qlo-bulk-desc-color').val()), + description_font_size: $('#qlo-bulk-desc-font-size').val(), + description_font_weight: $('#qlo-bulk-desc-font-weight').val() + }; + if (updateTitle) { + $('.qlo-bulk-title-field').each(function () { + postData['title_' + $(this).data('lang')] = $.trim($(this).val()); + }); + } + if (updateDescription) { + $('.qlo-bulk-description-field').each(function () { + postData['description_' + $(this).data('lang')] = $.trim($(this).val()); + }); + } + + var $btn = $(this).prop('disabled', true); + $('#page-loader').show(); + $.ajax({ + url: qloHmCurrentIndex, + type: 'POST', + data: postData, + success: function (raw) { + $btn.prop('disabled', false); + var data = safeParseJsonHm(raw); + if (data && data.success) { + (data.data.rows || []).forEach(function (rowData) { + var $row = $('#qlo-image-tbody .qlo-img-row[data-id="' + rowData.id + '"]'); + patchImageRow($row, rowData); + }); + $('#qlo-bulk-update-modal').modal('hide'); + showSuccessMessage(data.confirmations); + } else { + showErrorMessage(data ? data.errors.join('
') : qloHmI18n.updateFailed); + } + }, + error: function () { $btn.prop('disabled', false); showErrorMessage(qloHmI18n.requestFailed); } + }).always(function () { $('#page-loader').hide(); }); + }); + + $('#qlo-img-form-upload-btn').on('click', function () { + var fileInput = document.getElementById('qlo-img-form-file'); + var files = fileInput ? Array.prototype.slice.call(fileInput.files) : []; + if (!files.length) { + showErrorMessage((typeof qloHmI18n !== 'undefined') ? qloHmI18n.noFileSelected : 'Please select at least one image file.'); + return; + } + uploadImagesWithDetails(files); + }); + + $('#qlo-img-form-save-btn').on('click', function () { + var id = parseInt($.trim($('#qlo-img-form-id').val()), 10); + if (id) { + saveEditedImage(id); + } + }); + + $(document).on('click', '.qlo-img-row .js-toggle-active', function (e) { + e.preventDefault(); + var $link = $(this); + var $row = $link.closest('tr.qlo-img-row'); + var id = parseInt($row.data('id'), 10); + var active = $link.hasClass('action-enabled') ? 0 : 1; + $('#page-loader').show(); + $.ajax({ + url: qloHmCurrentIndex, + type: 'POST', + data: { ajax: 1, action: 'toggle_image_active', id_header_image: id, active: active, token: qloHmToken }, + success: function (raw) { + var data = safeParseJsonHm(raw); + if (data && data.success) { + $link.toggleClass('action-enabled action-disabled'); + $link.find('i').toggleClass('hidden'); + showSuccessMessage(data.confirmations); + } else { + showErrorMessage(data ? data.errors.join('
') : qloHmI18n.updateFailed); + } + }, + error: function () { showErrorMessage(qloHmI18n.requestFailed); } + }).always(function () { $('#page-loader').hide(); }); + }); + + $(document).on('click', '.qlo-delete-img', function () { + var id = parseInt($(this).data('id'), 10); + $('#page-loader').show(); + $.ajax({ + url: qloHmCurrentIndex, + type: 'POST', + data: { ajax: 1, action: 'deleteMedia', id_header_image: id, token: qloHmToken }, + success: function (raw) { + var data = safeParseJsonHm(raw); + if (data && data.success) { + var $row = $('#qlo-image-tbody .qlo-img-row[data-id="' + id + '"]'); + if (parseInt($('#qlo-img-form-id').val(), 10) === id) { + closeImgForm(); + } + $row.fadeOut(250, function () { + $row.remove(); + var count = $('#qlo-image-tbody .qlo-img-row').length; + $('#qlo-image-count').text(count); + if (!count) { + $('#qlo-no-images').show(); + } + updateBulkActionsVisibility(); + }); + showSuccessMessage(data.confirmations || qloHmI18n.deleteFailed); + } else { + showErrorMessage(data ? data.errors.join('
') : qloHmI18n.deleteFailed); + } + }, + error: function () { showErrorMessage(qloHmI18n.requestFailed); } + }).always(function () { $('#page-loader').hide(); }); + }); + + if ($('#qlo-image-table').length) { + var _hmDragOriginalOrder = null; + $('#qlo-image-table').tableDnD({ + dragHandle: 'dragHandle', + onDragClass: 'myDragClass', + onDragStart: function (table) { + _hmDragOriginalOrder = []; + $(table).find('tbody tr.qlo-img-row').each(function () { + _hmDragOriginalOrder.push(parseInt($(this).data('id'), 10)); + }); + }, + onDrop: function (table) { + var ids = []; + $(table).find('tbody tr.qlo-img-row').each(function (i) { + var id = parseInt($(this).data('id'), 10); + ids.push(id); + $(this).find('.positions').text(i + 1); + }); + if (_hmDragOriginalOrder && JSON.stringify(ids) === JSON.stringify(_hmDragOriginalOrder)) { + return; + } + $('#page-loader').show(); + $.post(qloHmCurrentIndex, { + ajax: 1, + action: 'saveImagePositions', + image_ids: ids, + token: qloHmToken + }, function (raw) { + var data = safeParseJsonHm(raw); + if (data && data.success) { + showSuccessMessage(data.confirmations); + } + }).always(function () { $('#page-loader').hide(); }); + } + }); + } + + function openImgForm(mode, id, titles, descriptions, isActive, imgUrl, descColor, descFontSize, descFontWeight) { + $('#qlo-img-form-id').val(id || ''); + $('#qlo-form-upload-progress').hide(); + + if (mode === 'edit') { + $('#qlo-img-modal-title-add').hide(); + $('#qlo-img-modal-title-edit').show(); + $('#qlo-img-add-footer').hide(); + $('#qlo-img-edit-footer').show(); + $('#qlo-img-form-file-group').hide(); + $('#qlo-img-form-add-active-group').hide(); + $('#qlo-img-form-edit-group').show(); + $('#qlo-img-edit-file-group').show(); + var editFileInput = document.getElementById('qlo-img-edit-file'); + if (editFileInput) { + editFileInput.value = ''; + } + $('#qlo-img-edit-file-name').val(''); + revokeEditImagePreview(); + if (isActive) { + $('#qlo_img_active_edit_on').prop('checked', true); + } else { + $('#qlo_img_active_edit_off').prop('checked', true); + } + titles = titles || {}; + descriptions = descriptions || {}; + $('.qlo-form-title-field').each(function () { + var langId = $(this).data('lang'); + $(this).val(titles[langId] || ''); + }); + $('.qlo-form-description-field').each(function () { + var langId = $(this).data('lang'); + $(this).val(descriptions[langId] || ''); + }); + if (imgUrl) { + $('#qlo-img-edit-thumb').attr('src', imgUrl); + $('#qlo-img-edit-preview-group').show(); + } else { + $('#qlo-img-edit-preview-group').hide(); + } + $('#qlo-img-desc-color').val(descColor || '#ffffff'); + $('#qlo-img-desc-font-size').val(descFontSize || 16); + var fw = descFontWeight || '400'; + $('#qlo-img-desc-font-weight').val(fw); + } else { + $('#qlo-img-modal-title-edit').hide(); + $('#qlo-img-modal-title-add').show(); + $('#qlo-img-edit-footer').hide(); + $('#qlo-img-add-footer').show(); + $('#qlo-img-form-file-group').show(); + $('#qlo-img-form-add-active-group').show(); + $('#qlo-img-form-edit-group').hide(); + $('#qlo-img-edit-preview-group').hide(); + $('#qlo-img-edit-file-group').hide(); + var fileInput = document.getElementById('qlo-img-form-file'); + if (fileInput) { + fileInput.value = ''; + } + $('#qlo-img-form-file-name').val(''); + $('#qlo_img_active_add_on').prop('checked', true); + $('.qlo-form-title-field').val(''); + $('.qlo-form-description-field').val(''); + $('#qlo-img-desc-color').val('#ffffff'); + $('#qlo-img-desc-font-size').val(16); + $('#qlo-img-desc-font-weight').val('400'); + } + + $('#qlo-img-desc-color').trigger('keyup'); + + hideOtherLanguage(id_language); + + $('#qlo-img-form-modal').modal('show'); + } + + function closeImgForm() { + $('#qlo-img-form-modal').modal('hide'); + revokeEditImagePreview(); + } + + function getFormTitles() { + var titles = {}; + $('.qlo-form-title-field').each(function () { + titles[$(this).data('lang')] = $.trim($(this).val()); + }); + return titles; + } + + function getFormDescriptions() { + var descriptions = {}; + $('.qlo-form-description-field').each(function () { + descriptions[$(this).data('lang')] = $.trim($(this).val()); + }); + return descriptions; + } + + function saveEditedImage(id) { + var titles = getFormTitles(); + var descriptions = getFormDescriptions(); + var active = parseInt($('input[name="qlo_img_active_edit"]:checked').val() || 0, 10); + var descColor = $('#qlo-img-desc-color').val() || '#ffffff'; + var descFontSize = parseInt($('#qlo-img-desc-font-size').val() || 16, 10); + var descFontWeight = $('#qlo-img-desc-font-weight').val() || '400'; + var editFileInput = document.getElementById('qlo-img-edit-file'); + var newFile = editFileInput && editFileInput.files && editFileInput.files[0] ? editFileInput.files[0] : null; + + if (newFile && typeof qloHmMaxUpload !== 'undefined' && qloHmMaxUpload > 0 && newFile.size > qloHmMaxUpload) { + showErrorMessage(qloHmI18n.fileTooLarge); + return; + } + + var fd = new FormData(); + fd.append('ajax', '1'); + fd.append('action', 'edit_image'); + fd.append('id_header_image', id); + fd.append('active', active); + fd.append('token', qloHmToken); + fd.append('description_color', descColor); + fd.append('description_font_size', descFontSize); + fd.append('description_font_weight', descFontWeight); + $.each(titles, function (langId, val) { + fd.append('title_' + langId, val); + }); + $.each(descriptions, function (langId, val) { + fd.append('description_' + langId, val); + }); + if (newFile) { + fd.append('header_image_file', newFile); + } + + $('#page-loader').show(); + $.ajax({ + url: qloHmCurrentIndex, + type: 'POST', + data: fd, + processData: false, + contentType: false, + success: function (raw) { + var resp = safeParseJsonHm(raw); + if (resp && resp.success) { + var $row = $('#qlo-image-tbody .qlo-img-row[data-id="' + id + '"]'); + patchImageRow($row, $.extend({ id: id }, resp)); + closeImgForm(); + showSuccessMessage(resp.confirmations || qloHmI18n.imageUpdatedSuccess); + } else { + showErrorMessage(resp ? resp.errors.join('
') : qloHmI18n.updateFailed); + } + }, + error: function () { showErrorMessage(qloHmI18n.requestFailed); } + }).always(function () { $('#page-loader').hide(); }); + } + + function uploadImagesWithDetails(files) { + var index = 0; + var titles = getFormTitles(); + var descriptions = getFormDescriptions(); + var active = parseInt($('input[name="qlo_img_active_add"]:checked').val() || 1, 10); + var descColor = $('#qlo-img-desc-color').val() || '#ffffff'; + var descFontSize = parseInt($('#qlo-img-desc-font-size').val() || 16, 10); + var descFontWeight = $('#qlo-img-desc-font-weight').val() || '400'; + $('#qlo-form-upload-progress').show(); + $('#qlo-img-form-upload-btn').prop('disabled', true); + $('#page-loader').show(); + + function next() { + if (index >= files.length) { + $('#qlo-form-upload-progress').hide(); + $('#qlo-img-form-upload-btn').prop('disabled', false); + $('#page-loader').hide(); + closeImgForm(); + return; + } + var file = files[index++]; + if (typeof qloHmMaxUpload !== 'undefined' && qloHmMaxUpload > 0 && file.size > qloHmMaxUpload) { + showErrorMessage(qloHmI18n.fileTooLarge); + next(); + return; + } + var fd = new FormData(); + fd.append('header_image_file', file); + fd.append('ajax', '1'); + fd.append('action', 'uploadImage'); + fd.append('token', qloHmToken); + fd.append('active', active); + fd.append('description_color', descColor); + fd.append('description_font_size', descFontSize); + fd.append('description_font_weight', descFontWeight); + $.each(titles, function (langId, val) { + fd.append('title_' + langId, val); + }); + $.each(descriptions, function (langId, val) { + fd.append('description_' + langId, val); + }); + + $.ajax({ + url: qloHmCurrentIndex, + type: 'POST', + data: fd, + processData: false, + contentType: false, + success: function (raw) { + var resp = safeParseJsonHm(raw); + if (resp && resp.success) { + appendImageRow(resp.data.image_row); + showSuccessMessage(qloHmI18n.imageUploadedSuccess); + } else { + showErrorMessage(file.name + ': ' + (resp ? resp.errors.join(', ') : qloHmI18n.uploadFailed)); + } + next(); + }, + error: function () { + showErrorMessage(file.name + ': ' + qloHmI18n.requestFailed); + next(); + } + }); + } + next(); + } + + function appendImageRow(rowHtml) { + $('#qlo-image-tbody').append(rowHtml); + $('#qlo-image-table').tableDnDUpdate(); + $('#qlo-no-images').hide(); + $('#qlo-image-count').text(parseInt($('#qlo-image-count').text(), 10) + 1); + updateBulkActionsVisibility(); + } + + function updateBulkActionsVisibility() { + var count = $('#qlo-image-tbody .qlo-img-row').length; + $('#qlo-bulk-actions-row').toggle(count > 1); + updateBulkUpdateTriggerState(); + } + + function patchImageRow($row, data) { + var id = parseInt(data.id, 10); + if (data.thumb) { + var $thumbCell = $row.find('.qlo-img-thumb-cell'); + if (!$thumbCell.length) { + $thumbCell = $row.find('td').eq(1); + } + $thumbCell.html(data.thumb); + } + if (data.thumb_src) { + $row.attr('data-thumb-src', data.thumb_src); + } + var updatedTitles = safeParseJsonHm(data.titles_json) || {}; + $row.attr('data-titles', data.titles_json); + $row.data('titles', updatedTitles); + var titleDisplay = data.title || ''; + $row.find('.qlo-img-title-cell').text( + titleDisplay.length > 50 ? titleDisplay.substring(0, 50) + '...' : (titleDisplay || '—') + ); + + var updatedDescriptions = safeParseJsonHm(data.descriptions_json) || {}; + $row.attr('data-descriptions', data.descriptions_json); + $row.data('descriptions', updatedDescriptions); + $row.attr('data-description-color', data.description_color || '#ffffff'); + $row.attr('data-description-font-size', data.description_font_size || 16); + $row.attr('data-description-font-weight', data.description_font_weight || '400'); + var descDisplay = data.description || ''; + $row.find('.qlo-img-description-cell').text( + descDisplay.length > 50 ? descDisplay.substring(0, 50) + '...' : (descDisplay || '—') + ); + + var nowActive = parseInt(data.active, 10); + var $toggle = $row.find('.js-toggle-active'); + $toggle.toggleClass('action-enabled', !!nowActive) + .toggleClass('action-disabled', !nowActive); + $toggle.find('i.icon-check').toggleClass('hidden', !nowActive); + $toggle.find('i.icon-remove').toggleClass('hidden', !!nowActive); + $toggle.attr('href', $toggle.attr('href').replace(/id_header_image=\d+/, 'id_header_image=' + id) + .replace(/active=\d+/, 'active=' + (nowActive ? 0 : 1))); + } + + function safeParseJsonHm(raw) { + try { return JSON.parse(raw); } catch (_e) { return null; } + } +}); diff --git a/modules/hotelreservationsystem/views/js/hotelImage.js b/modules/hotelreservationsystem/views/js/admin/qhrs_hotel_image.js similarity index 100% rename from modules/hotelreservationsystem/views/js/hotelImage.js rename to modules/hotelreservationsystem/views/js/admin/qhrs_hotel_image.js diff --git a/modules/hotelreservationsystem/views/js/qhrs_hotel_header_media_front.js b/modules/hotelreservationsystem/views/js/qhrs_hotel_header_media_front.js new file mode 100644 index 000000000..e1fcb647a --- /dev/null +++ b/modules/hotelreservationsystem/views/js/qhrs_hotel_header_media_front.js @@ -0,0 +1,176 @@ +/** +* 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 +*/ + + +$(document).ready(function () { + + /* Background video autoplay fallback (handles strict browser autoplay policies) */ + var $bgVideo = $('video.header-bg-video'); + if ($bgVideo.length) { + $bgVideo.each(function () { + var vid = this; + vid.muted = true; + var p = vid.play(); + if (p !== undefined) { + p.catch(function () {}); + } + }); + } + + var $imgCarousel = $('.header-img-carousel'); + if (!$imgCarousel.length) { return; } + + var autoPlay = parseInt($imgCarousel.data('auto-play'), 10) === 1; + var interval = parseInt($imgCarousel.data('interval'), 10) || 5000; + var navType = parseInt($imgCarousel.data('nav-type'), 10) || 1; // 1=dots 2=arrows 3=both + var animType = parseInt($imgCarousel.data('anim-type'), 10) || 1; // 1=slide 2=fade 3=zoom 4=blur + var animNames = {1: 'Slide', 2: 'Fade', 3: 'Zoom', 4: 'Blur'}; + var animLabel = animNames[animType] || 'Slide'; + + var showDots = (navType === 1 || navType === 3); + $imgCarousel.owlCarousel({ + loop: true, + items: 1, + dots: showDots, + dotsContainer: showDots ? '#wk-header-owl-dots' : false, + nav: false, + autoplay: autoPlay, + autoplayTimeout: interval, + autoplaySpeed: 800, + autoplayHoverPause: false, + animateOut: 'wk' + animLabel + 'Out', + animateIn: 'wk' + animLabel + 'In', + responsiveClass: true, + rtl: (typeof language_is_rtl !== 'undefined' ? language_is_rtl : false) + }); + + var owl = $imgCarousel.data('owl.carousel'); + + var _origLeave = $.proxy(owl.leave, owl); + owl.leave = function (name) { + _origLeave(name); + var cur = owl._states.current; + for (var k in cur) { + if (cur[k] < 0) { cur[k] = 0; } + } + }; + + + var $descriptionEl = $('.js-header-description'); + var $titleEl = $('.js-header-title'); + var _fadeTimer = null; + var _shownIndex = -1; + + var $slides = $imgCarousel.find('.owl-item:not(.cloned) .header-slide-img'); + var titles = $slides.map(function () { return $(this).data('title') || ''; }).get(); + var descriptions = $slides.map(function () { return $(this).data('description') || ''; }).get(); + var descStyles = $slides.map(function () { + return { + color: $(this).data('desc-color') || '#ffffff', + fontSize: $(this).data('desc-font-size') || 16, + fontWeight: $(this).data('desc-font-weight') || '400' + }; + }).get(); + + function showTitle(title) { + if (!$titleEl.length) { return; } + $titleEl.text(title); + $titleEl.toggle(!!title); + } + + function showDescription(text, style) { + if (!$descriptionEl.length) { return; } + if (_fadeTimer) { clearTimeout(_fadeTimer); _fadeTimer = null; } + + style = style || { color: '#ffffff', fontSize: 16, fontWeight: '400' }; + $descriptionEl.css({ + color: style.color, + fontSize: style.fontSize + 'px', + fontWeight: style.fontWeight + }); + + $descriptionEl.removeClass('wk-tagline-out wk-tagline-in').text(text); + if (!text) { $descriptionEl.hide(); return; } + + $descriptionEl.show(); + $descriptionEl[0].offsetHeight; // force reflow so the transition actually runs + $descriptionEl.addClass('wk-tagline-in'); + _fadeTimer = setTimeout(function () { + _fadeTimer = null; + $descriptionEl.removeClass('wk-tagline-in'); + }, 400); + } + + _shownIndex = owl.relative(owl.current()); + showTitle(titles[_shownIndex] || ''); + showDescription(descriptions[_shownIndex] || '', descStyles[_shownIndex]); + + $imgCarousel.on('changed.owl.carousel', function () { + var realIndex = owl.relative(owl.current()); + if (realIndex === _shownIndex) { return; } // loop-snap second fire — no-op + _shownIndex = realIndex; + showTitle(titles[realIndex] || ''); + showDescription(descriptions[realIndex] || '', descStyles[realIndex]); + }); + + + $('.js-header-media-prev').on('click', function () { + $imgCarousel.trigger('prev.owl.carousel'); + }); + $('.js-header-media-next').on('click', function () { + $imgCarousel.trigger('next.owl.carousel'); + }); + + + if (autoPlay) { + var ap = owl._plugins && owl._plugins.autoplay; + + if (ap) { ap.pause = function () {}; } + + $imgCarousel.on('translated.owl.carousel', function () { + if (ap && owl.is('rotating') && !ap._paused) { + ap._setAutoPlayInterval(); + } + }); + + document.addEventListener('visibilitychange', function () { + if (!document.hidden) { + $imgCarousel.trigger('stop.owl.autoplay'); + $imgCarousel.trigger('play.owl.autoplay'); + } + }); + + var _watchdogTimer = setInterval(function () { + if (document.hidden) { return; } + var apNow = owl._plugins && owl._plugins.autoplay; + if (!owl.is('rotating') || (apNow && apNow._paused)) { + $imgCarousel.trigger('stop.owl.autoplay'); + $imgCarousel.trigger('play.owl.autoplay'); + } + }, interval + 1000); + + $(window).one('beforeunload', function () { + clearInterval(_watchdogTimer); + }); + } + +}); diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/_partials/htl-header-image-row.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/_partials/htl-header-image-row.tpl new file mode 100644 index 000000000..574d9e148 --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/_partials/htl-header-image-row.tpl @@ -0,0 +1,77 @@ +{** +* 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 $img.thumb}{$img.thumb nofilter}{else}{/if} + + + {if $img.title}{$img.title|truncate:50:'...'|escape:'html':'UTF-8'}{else}—{/if} + + + {if $img.description}{$img.description|truncate:50:'...'|escape:'html':'UTF-8'}{else}—{/if} + + +
+
{$position|intval}
+
+ + +
+ + + + + +
+
+ + + +
+
+ + diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/helpers/view/view.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/helpers/view/view.tpl new file mode 100644 index 000000000..8a49eb9fc --- /dev/null +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_header_image/helpers/view/view.tpl @@ -0,0 +1,704 @@ +{** +* 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='Header Media Settings' mod='hotelreservationsystem'} +
+
+ +
+ +
+ +

{l s='Choose whether the home page header shows a slideshow of images or a background video.' mod='hotelreservationsystem'}

+
+
+ + + + +
+ +
+
+ +{* Confirm switch-to-video modal — triggered when saving with Video selected while 2+ images exist *} + + +{* Confirm bulk-delete images modal — triggered by the "Delete selected" bulk action *} + + + + +{* Bulk update modal — triggered by the "Bulk update" bulk action; only touches fields the admin actually sets *} + + + diff --git a/modules/hotelreservationsystem/views/templates/hook/headerHotelDescBlock.tpl b/modules/hotelreservationsystem/views/templates/hook/headerHotelDescBlock.tpl index 9ea527e80..62625d528 100644 --- a/modules/hotelreservationsystem/views/templates/hook/headerHotelDescBlock.tpl +++ b/modules/hotelreservationsystem/views/templates/hook/headerHotelDescBlock.tpl @@ -24,17 +24,17 @@
-
+
-
-

{l s='Welcome To' mod='hotelreservationsystem'}

-
+
- {block name='header_hotel_chain_name'} -

{$WK_HTL_CHAIN_NAME|escape:'htmlall':'UTF-8'}

+ {if $QLO_HEADER_MEDIA_TYPE == $QLO_HEADER_MEDIA_TYPE_IMAGE} + {block name='header_hotel_title'} +

{if isset($wkHeaderMediaTitle) && $wkHeaderMediaTitle}{$wkHeaderMediaTitle|escape:'htmlall':'UTF-8'}{/if}

{/block} + {/if} {block name='header_hotel_description'} -

{$WK_HTL_TAG_LINE|escape:'htmlall':'UTF-8'}

+ {/block}
diff --git a/themes/hotel-reservation-theme/header.tpl b/themes/hotel-reservation-theme/header.tpl index 8dc419a6b..af7919df6 100644 --- a/themes/hotel-reservation-theme/header.tpl +++ b/themes/hotel-reservation-theme/header.tpl @@ -87,7 +87,63 @@ {/if}
-