Merge pull request #1765 from shazar-webkul/gli-2934
Added: Image categorisation for hotel images at back-office
This commit is contained in:
@@ -25,6 +25,7 @@ class HotelImage extends ObjectModel
|
||||
{
|
||||
public $id;
|
||||
public $id_hotel;
|
||||
public $id_htl_image_category;
|
||||
public $cover;
|
||||
public $source_index;
|
||||
public $image_dir;
|
||||
@@ -37,6 +38,7 @@ class HotelImage extends ObjectModel
|
||||
'primary' => 'id',
|
||||
'fields' => array(
|
||||
'id_hotel' => array('type' => self::TYPE_INT, 'validate' => 'isInt'),
|
||||
'id_htl_image_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'allow_null' => true),
|
||||
'cover' => array('type' => self::TYPE_BOOL,'validate' => 'isBool')
|
||||
),
|
||||
);
|
||||
@@ -99,7 +101,7 @@ class HotelImage extends ObjectModel
|
||||
* @param [int] $n [number of images per page for paginated images data]
|
||||
* @return [array|boolean] [if data found returns array containing information of the images of the hotel which id is passed]
|
||||
*/
|
||||
public function getImagesByHotelId($id_hotel, $p = 1, $n = null)
|
||||
public function getImagesByHotelId($id_hotel, $p = 1, $n = null, $idLang = null)
|
||||
{
|
||||
$p = (int) $p;
|
||||
$n = $n !== null ? (int) $n : $n; // n = null for no pagination
|
||||
@@ -107,9 +109,16 @@ class HotelImage extends ObjectModel
|
||||
$p = 1;
|
||||
}
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM `'._DB_PREFIX_.'htl_image`
|
||||
WHERE `id_hotel` = '.(int) $id_hotel.
|
||||
if (!$idLang) {
|
||||
$idLang = (int) Context::getContext()->language->id;
|
||||
}
|
||||
|
||||
$sql = 'SELECT hi.*, hicl.`name` AS `category_name`
|
||||
FROM `'._DB_PREFIX_.'htl_image` hi
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hicl
|
||||
ON (hicl.`id_htl_image_category` = hi.`id_htl_image_category`
|
||||
AND hicl.`id_lang` = '.(int) $idLang.')
|
||||
WHERE hi.`id_hotel` = '.(int) $id_hotel.
|
||||
($n ? ' LIMIT '.(int) (($p - 1) * $n).', '.(int) ($n) : '');
|
||||
|
||||
return Db::getInstance()->executeS($sql);
|
||||
@@ -174,107 +183,80 @@ class HotelImage extends ObjectModel
|
||||
);
|
||||
}
|
||||
|
||||
public function uploadHotelImages($images, $idHotel)
|
||||
public function uploadHotelImages($images, $idHotel, $idHtlImageCategory = 0, $objCategory = null)
|
||||
{
|
||||
if (isset($images) && $idHotel) {
|
||||
$objHotelHelper = new HotelHelper();
|
||||
$hotelImages = $images['tmp_name'];
|
||||
if (is_array($images['tmp_name'])) {
|
||||
foreach ($hotelImages as $image) {
|
||||
$objHtlImage = new HotelImage();
|
||||
$objHtlImage->id_hotel = $idHotel;
|
||||
if ($coverImgExist = HotelImage::getCover($idHotel)) {
|
||||
$objHtlImage->cover = 0;
|
||||
} else {
|
||||
$objHtlImage->cover = 1;
|
||||
}
|
||||
if ($objHtlImage->save()) {
|
||||
if ($path = $objHtlImage->getPathForCreation()) {
|
||||
if (ImageManager::resize(
|
||||
$image,
|
||||
$path.$objHtlImage->id.'.'.$objHtlImage->image_format
|
||||
)) {
|
||||
// add hotel images in all required sizes
|
||||
$imagesTypes = ImageType::getImagesTypes('hotels');
|
||||
$generate_hight_dpi_images = (bool)Configuration::get('PS_HIGHT_DPI');
|
||||
if (!isset($images['tmp_name']) || !$idHotel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($imagesTypes as $imageType) {
|
||||
if (!ImageManager::resize(
|
||||
$image,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
$imageType['width'],
|
||||
$imageType['height']
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
$isMultiple = is_array($images['tmp_name']);
|
||||
$tmpFiles = $isMultiple ? $images['tmp_name'] : array($images['tmp_name']);
|
||||
|
||||
if ($generate_hight_dpi_images) {
|
||||
if (!ImageManager::resize(
|
||||
$image,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
(int)$imageType['width']*2,
|
||||
(int)$imageType['height']*2
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$generateHighDpiImages = (bool) Configuration::get('PS_HIGHT_DPI');
|
||||
$imagesTypes = ImageType::getImagesTypes('hotels');
|
||||
|
||||
$addedImage = false;
|
||||
$allSucceeded = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($tmpFiles as $tmpFile) {
|
||||
if (!is_string($tmpFile) || $tmpFile === '') {
|
||||
$allSucceeded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$objHtlImage = new HotelImage();
|
||||
$objHtlImage->id_hotel = $idHotel;
|
||||
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
|
||||
$objHtlImage->cover = self::getCover($idHotel) ? 0 : 1;
|
||||
|
||||
if (!$objHtlImage->save()
|
||||
|| !($path = $objHtlImage->getPathForCreation())
|
||||
|| !ImageManager::resize($tmpFile, $path.$objHtlImage->id.'.'.$objHtlImage->image_format)
|
||||
) {
|
||||
$allSucceeded = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($imagesTypes as $imageType) {
|
||||
if (!ImageManager::resize(
|
||||
$tmpFile,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
$imageType['width'],
|
||||
$imageType['height']
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$objHtlImage = new HotelImage();
|
||||
$objHtlImage->id_hotel = $idHotel;
|
||||
if ($coverImgExist = HotelImage::getCover($idHotel)) {
|
||||
$objHtlImage->cover = 0;
|
||||
} else {
|
||||
$objHtlImage->cover = 1;
|
||||
}
|
||||
if ($objHtlImage->save()) {
|
||||
if ($path = $objHtlImage->getPathForCreation()) {
|
||||
if (ImageManager::resize(
|
||||
$hotelImages,
|
||||
$path.$objHtlImage->id.'.'.$objHtlImage->image_format
|
||||
)) {
|
||||
$imagesTypes = ImageType::getImagesTypes('hotels');
|
||||
$generate_hight_dpi_images = (bool)Configuration::get('PS_HIGHT_DPI');
|
||||
foreach ($imagesTypes as $imageType) {
|
||||
if (!ImageManager::resize(
|
||||
$hotelImages,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
$imageType['width'],
|
||||
$imageType['height']
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($generate_hight_dpi_images) {
|
||||
if (!ImageManager::resize(
|
||||
$hotelImages,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
(int)$imageType['width']*2,
|
||||
(int)$imageType['height']*2
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$addedImage = array(
|
||||
'id' => $objHtlImage->id,
|
||||
'cover' => $objHtlImage->cover,
|
||||
'image_link' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)),
|
||||
);
|
||||
return $addedImage;
|
||||
}
|
||||
}
|
||||
if ($generateHighDpiImages) {
|
||||
ImageManager::resize(
|
||||
$tmpFile,
|
||||
$path.$objHtlImage->id.'-'.stripslashes($imageType['name']).'.'.$objHtlImage->image_format,
|
||||
(int) $imageType['width'] * 2,
|
||||
(int) $imageType['height'] * 2
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
if (!$isMultiple) {
|
||||
if (!$objCategory || (int) $objCategory->id !== $idHtlImageCategory) {
|
||||
$objCategory = new HotelImageCategory($idHtlImageCategory, Context::getContext()->language->id);
|
||||
}
|
||||
|
||||
$addedImage = array(
|
||||
'id' => $objHtlImage->id,
|
||||
'cover' => $objHtlImage->cover,
|
||||
'id_htl_image_category' => $idHtlImageCategory,
|
||||
'category_name' => (string) $objCategory->name,
|
||||
'image_link' => Context::getContext()->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id)),
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
if ($isMultiple) {
|
||||
return $allSucceeded;
|
||||
}
|
||||
|
||||
return $allSucceeded ? $addedImage : false;
|
||||
}
|
||||
|
||||
public function getPathForCreation()
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
class HotelImageCategory extends ObjectModel
|
||||
{
|
||||
public $id_htl_image_category;
|
||||
public $name;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'htl_image_category',
|
||||
'primary' => 'id_htl_image_category',
|
||||
'multilang' => true,
|
||||
'fields' => array(
|
||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
|
||||
),
|
||||
);
|
||||
|
||||
public static function getImageCategories($idLang = null)
|
||||
{
|
||||
if (!$idLang) {
|
||||
$idLang = (int) Context::getContext()->language->id;
|
||||
}
|
||||
|
||||
$defaultLangId = (int) Configuration::get('PS_LANG_DEFAULT');
|
||||
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT hic.`id_htl_image_category`, COALESCE(hicl.`name`, hiclDefault.`name`) AS `name`
|
||||
FROM `'._DB_PREFIX_.'htl_image_category` hic
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hicl
|
||||
ON (hicl.`id_htl_image_category` = hic.`id_htl_image_category`
|
||||
AND hicl.`id_lang` = '.(int) $idLang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_image_category_lang` hiclDefault
|
||||
ON (hiclDefault.`id_htl_image_category` = hic.`id_htl_image_category`
|
||||
AND hiclDefault.`id_lang` = '.(int) $defaultLangId.')
|
||||
WHERE COALESCE(hicl.`name`, hiclDefault.`name`) IS NOT NULL
|
||||
ORDER BY `name` ASC'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -87,10 +87,27 @@ class HotelReservationSystemDb
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_hotel` int(10) unsigned NOT NULL,
|
||||
`id_htl_image_category` int(10) unsigned DEFAULT NULL,
|
||||
`cover` tinyint(1) NOT NULL DEFAULT '0',
|
||||
KEY `id_hotel` (`id_hotel`),
|
||||
KEY `id_htl_image_category` (`id_htl_image_category`),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image_category` (
|
||||
`id_htl_image_category` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_htl_image_category`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_image_category_lang` (
|
||||
`id_htl_image_category` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
`name` varchar(128) NOT NULL,
|
||||
PRIMARY KEY (`id_htl_image_category`, `id_lang`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_amenity` (
|
||||
`id_amenity` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_parent` int(10) unsigned NOT NULL,
|
||||
@@ -588,6 +605,8 @@ class HotelReservationSystemDb
|
||||
`'._DB_PREFIX_.'htl_branch_info`,
|
||||
`'._DB_PREFIX_.'htl_branch_info_lang`,
|
||||
`'._DB_PREFIX_.'htl_image`,
|
||||
`'._DB_PREFIX_.'htl_image_category`,
|
||||
`'._DB_PREFIX_.'htl_image_category_lang`,
|
||||
`'._DB_PREFIX_.'htl_branch_amenity`,
|
||||
`'._DB_PREFIX_.'htl_room_type_amenity`,
|
||||
`'._DB_PREFIX_.'htl_amenity`,
|
||||
|
||||
@@ -204,6 +204,9 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
} else {
|
||||
$idCountry = Tools::getValue('hotel_country');
|
||||
}
|
||||
|
||||
$smartyVars['hotelImageCategories'] = HotelImageCategory::getImageCategories($this->context->language->id);
|
||||
|
||||
// manage state option
|
||||
$stateOptions = null;
|
||||
if ($idCountry) {
|
||||
@@ -816,10 +819,12 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$conf = 4;
|
||||
}
|
||||
|
||||
$tabParam = Tools::getValue('htl_active_tab') ? '&htl_active_tab='.urlencode(Tools::getValue('htl_active_tab')) : '';
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token );
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id='.(int) $newIdHotel.'&update'.$this->table.'&conf='.$conf.'&token='.$this->token.$tabParam);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf='.$conf.'&token='.$this->token.$tabParam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -867,38 +872,35 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessUploadHotelImages()
|
||||
public function ajaxProcessUploadHotelImage()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
$idHotel = Tools::getValue('id_hotel');
|
||||
$response = array('success' => false, 'errors' => array());
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
|
||||
$file = isset($_FILES['hotel_image']) ? $_FILES['hotel_image'] : null;
|
||||
|
||||
if ($idHotel) {
|
||||
$invalidImg = ImageManager::validateUpload(
|
||||
$_FILES['hotel_image'],
|
||||
Tools::getMaxUploadSize()
|
||||
);
|
||||
if (!$invalidImg) {
|
||||
// Add Hotel images
|
||||
$objHotelImage = new HotelImage();
|
||||
$imageDetail = $objHotelImage->uploadHotelImages($_FILES['hotel_image'], $idHotel);
|
||||
if ($imageDetail) {
|
||||
$response['success'] = true;
|
||||
$imageDetail['image_link'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'],ImageType::getFormatedName('large')));
|
||||
$imageDetail['image_link_small'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('small')));
|
||||
$response['data']['image_info'] = $imageDetail;
|
||||
// get image row
|
||||
$this->context->smarty->assign(array(
|
||||
'image' => $imageDetail,
|
||||
'hotel_info' => array('id' => $idHotel)
|
||||
));
|
||||
$response['data']['image_row'] = $this->context->smarty->fetch(
|
||||
_PS_MODULE_DIR_.$this->module->name.
|
||||
'/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl'
|
||||
);
|
||||
if ($file && $file['size']) {
|
||||
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
|
||||
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
|
||||
$response['errors'][] = $this->l('Selected image category is invalid.');
|
||||
} elseif ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize())) {
|
||||
$response['errors'][] = $error;
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Unable to uploade image. Please try again');
|
||||
$objHotelImage = new HotelImage();
|
||||
$imageDetail = $objHotelImage->uploadHotelImages($file, $idHotel, $idHtlImageCategory, $objCategory);
|
||||
if ($imageDetail) {
|
||||
$imageDetail['image_link'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('large')));
|
||||
$imageDetail['image_link_small'] = $this->context->link->getMediaLink($objHotelImage->getImageLink($imageDetail['id'], ImageType::getFormatedName('small')));
|
||||
|
||||
$response['success'] = true;
|
||||
$response['image_row'] = $this->renderHotelImageRow($imageDetail, $idHotel);
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Unable to upload image. Please try again');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $_FILES['hotel_image']['name'].': '.$invalidImg;
|
||||
$response['errors'][] = $this->l('No file received.');
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Hotel info not found. Please try reloading the page');
|
||||
@@ -908,38 +910,181 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
|
||||
public function ajaxProcessChangeCoverImage()
|
||||
{
|
||||
$idImage = Tools::getValue('id_image');
|
||||
$idImage = (int) Tools::getValue('id_image');
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$response = array('status' => false);
|
||||
if ($idImage) {
|
||||
$idHotel = Tools::getValue('id_hotel');
|
||||
|
||||
if ($idImage && $idHotel && Validate::isLoadedObject($objHtlImage = new HotelImage($idImage)) && (int) $objHtlImage->id_hotel === $idHotel) {
|
||||
$oldCoverId = null;
|
||||
$affectedCoverImage = null;
|
||||
if ($coverImg = HotelImage::getCover($idHotel)) {
|
||||
$objHtlImage = new HotelImage((int) $coverImg['id']);
|
||||
$objHtlImage->cover = 0;
|
||||
$objHtlImage->save();
|
||||
$oldCoverId = (int) $coverImg['id'];
|
||||
$affectedCoverImage = new HotelImage($oldCoverId);
|
||||
$affectedCoverImage->cover = 0;
|
||||
$affectedCoverImage->save();
|
||||
}
|
||||
|
||||
$objHtlImage = new HotelImage((int) $idImage);
|
||||
$objHtlImage->cover = 1;
|
||||
if ($objHtlImage->update()) {
|
||||
$response['status'] = true;
|
||||
$objHtlImage->update();
|
||||
|
||||
$response['status'] = true;
|
||||
$response['image_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objHtlImage), $idHotel);
|
||||
|
||||
if ($oldCoverId) {
|
||||
$response['old_cover_id'] = $oldCoverId;
|
||||
$response['old_cover_row'] = $this->renderHotelImageRow(
|
||||
$this->getHotelImageRowData($affectedCoverImage),
|
||||
$idHotel
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessEditHotelImage()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
$idImage = (int) Tools::getValue('id_image');
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
|
||||
$setCover = (bool) Tools::getValue('cover');
|
||||
|
||||
if ($idImage && $idHotel && Validate::isLoadedObject($objHtlImage = new HotelImage($idImage)) && (int) $objHtlImage->id_hotel === $idHotel) {
|
||||
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
|
||||
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
|
||||
$response['errors'][] = $this->l('Selected image category is invalid.');
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
$otherImage = null;
|
||||
if (!$setCover && $objHtlImage->cover) {
|
||||
foreach ($objHtlImage->getImagesByHotelId($idHotel, 1, 2) as $image) {
|
||||
if ((int) $image['id'] !== $idImage) {
|
||||
$otherImage = $image;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$otherImage) {
|
||||
$response['errors'][] = $this->l('At least one image must remain marked as cover.');
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
}
|
||||
|
||||
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
|
||||
|
||||
$oldCoverId = null;
|
||||
$affectedCoverImage = null;
|
||||
if ($setCover && !$objHtlImage->cover) {
|
||||
if ($coverImg = HotelImage::getCover($idHotel)) {
|
||||
$oldCoverId = (int) $coverImg['id'];
|
||||
$affectedCoverImage = new HotelImage($oldCoverId);
|
||||
$affectedCoverImage->cover = 0;
|
||||
$affectedCoverImage->save();
|
||||
}
|
||||
|
||||
$objHtlImage->cover = 1;
|
||||
} elseif ($otherImage) {
|
||||
$objHtlImage->cover = 0;
|
||||
|
||||
$affectedCoverImage = new HotelImage($otherImage['id']);
|
||||
$affectedCoverImage->cover = 1;
|
||||
$affectedCoverImage->save();
|
||||
$oldCoverId = (int) $affectedCoverImage->id;
|
||||
}
|
||||
|
||||
$objHtlImage->update();
|
||||
|
||||
$response['status'] = true;
|
||||
$response['image_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objHtlImage, $objCategory), $idHotel);
|
||||
|
||||
if ($oldCoverId) {
|
||||
$response['old_cover_id'] = $oldCoverId;
|
||||
$response['old_cover_row'] = $this->renderHotelImageRow(
|
||||
$this->getHotelImageRowData($affectedCoverImage),
|
||||
$idHotel
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('Image not found.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
private function getHotelImageRowData($objHtlImage, ?HotelImageCategory $objCategory = null)
|
||||
{
|
||||
$idHtlImageCategory = (int) $objHtlImage->id_htl_image_category;
|
||||
if (!$objCategory || (int) $objCategory->id !== $idHtlImageCategory) {
|
||||
$objCategory = new HotelImageCategory($idHtlImageCategory, $this->context->language->id);
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => $objHtlImage->id,
|
||||
'cover' => $objHtlImage->cover,
|
||||
'id_htl_image_category' => $idHtlImageCategory,
|
||||
'category_name' => (string) $objCategory->name,
|
||||
'image_link' => $this->context->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id, ImageType::getFormatedName('large'))),
|
||||
'image_link_small' => $this->context->link->getMediaLink($objHtlImage->getImageLink($objHtlImage->id, ImageType::getFormatedName('small'))),
|
||||
);
|
||||
}
|
||||
|
||||
private function renderHotelImageRow($imageData, $idHotel)
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'image' => $imageData,
|
||||
'hotel_info' => array('id' => $idHotel),
|
||||
));
|
||||
|
||||
return $this->context->smarty->fetch(_PS_MODULE_DIR_.$this->module->name.'/views/templates/admin/add_hotel/_partials/htl-images-list-row.tpl');
|
||||
}
|
||||
|
||||
public function ajaxProcessBulkUpdateHotelImage()
|
||||
{
|
||||
$response = array('status' => false, 'errors' => array());
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$idHtlImageCategory = (int) Tools::getValue('id_htl_image_category');
|
||||
$imageIds = array_filter(array_map('intval', (array) Tools::getValue('image_ids', array())));
|
||||
|
||||
if ($idHotel && $imageIds) {
|
||||
$objCategory = $idHtlImageCategory ? new HotelImageCategory($idHtlImageCategory, $this->context->language->id) : null;
|
||||
if ($idHtlImageCategory && !Validate::isLoadedObject($objCategory)) {
|
||||
$response['errors'][] = $this->l('Selected image category is invalid.');
|
||||
} else {
|
||||
foreach ($imageIds as $idImage) {
|
||||
$objHtlImage = new HotelImage($idImage);
|
||||
if (Validate::isLoadedObject($objHtlImage) && (int) $objHtlImage->id_hotel === $idHotel) {
|
||||
$objHtlImage->id_htl_image_category = $idHtlImageCategory ?: null;
|
||||
$objHtlImage->update();
|
||||
}
|
||||
}
|
||||
|
||||
$response['status'] = true;
|
||||
$response['image_ids'] = $imageIds;
|
||||
$response['category_name'] = $objCategory ? (string) $objCategory->name : '';
|
||||
}
|
||||
} else {
|
||||
$response['errors'][] = $this->l('No images selected.');
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessDeleteHotelImage()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
if ($idImage = Tools::getValue('id_image')) {
|
||||
if ($idHotel = Tools::getValue('id_hotel')) {
|
||||
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) {
|
||||
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage)) && (int) $objHtlImage->id_hotel === (int) $idHotel) {
|
||||
if ($objHtlImage->delete()) {
|
||||
if (!HotelImage::getCover($idHotel)) {
|
||||
$images = $objHtlImage->getImagesByHotelId($idHotel);
|
||||
$images = $objHtlImage->getImagesByHotelId($idHotel, 1, 1);
|
||||
if ($images) {
|
||||
$objHtlImage = new HotelImage($images[0]['id']);
|
||||
$objHtlImage->cover = 1;
|
||||
$objHtlImage->save();
|
||||
$objNewCover = new HotelImage($images[0]['id']);
|
||||
$objNewCover->cover = 1;
|
||||
$objNewCover->save();
|
||||
|
||||
$response['new_cover_id'] = (int) $objNewCover->id;
|
||||
$response['new_cover_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objNewCover), $idHotel);
|
||||
}
|
||||
}
|
||||
$response['status'] = true;
|
||||
@@ -950,6 +1095,43 @@ class AdminAddHotelController extends ModuleAdminController
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessBulkDeleteHotelImage()
|
||||
{
|
||||
$response = array('status' => false, 'errors' => array());
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$imageIds = array_filter(array_map('intval', (array) Tools::getValue('image_ids', array())));
|
||||
|
||||
if (!$idHotel || !$imageIds) {
|
||||
$response['errors'][] = $this->l('No images selected.');
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
$deletedIds = array();
|
||||
foreach ($imageIds as $idImage) {
|
||||
$objHtlImage = new HotelImage($idImage);
|
||||
if (Validate::isLoadedObject($objHtlImage) && (int) $objHtlImage->id_hotel === $idHotel && $objHtlImage->delete()) {
|
||||
$deletedIds[] = $idImage;
|
||||
}
|
||||
}
|
||||
|
||||
if (!HotelImage::getCover($idHotel)) {
|
||||
$objHelper = new HotelImage();
|
||||
$images = $objHelper->getImagesByHotelId($idHotel, 1, 1);
|
||||
if ($images) {
|
||||
$objNewCover = new HotelImage($images[0]['id']);
|
||||
$objNewCover->cover = 1;
|
||||
$objNewCover->save();
|
||||
|
||||
$response['new_cover_id'] = (int) $objNewCover->id;
|
||||
$response['new_cover_row'] = $this->renderHotelImageRow($this->getHotelImageRowData($objNewCover), $idHotel);
|
||||
}
|
||||
}
|
||||
|
||||
$response['status'] = true;
|
||||
$response['deleted_ids'] = $deletedIds;
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateSlidesPosition()
|
||||
{
|
||||
if (($slideIds = Tools::getValue('slides'))
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
class AdminHotelImageCategoryController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'htl_image_category';
|
||||
$this->className = 'HotelImageCategory';
|
||||
$this->identifier = 'id_htl_image_category';
|
||||
$this->lang = true;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_htl_image_category' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'align' => 'center',
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Created On'),
|
||||
'type' => 'date',
|
||||
'align' => 'right'
|
||||
),
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'icon' => 'icon-trash',
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
if (!$this->display || $this->display == 'list') {
|
||||
$this->page_header_toolbar_btn['new'] = array(
|
||||
'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
|
||||
'desc' => $this->l('Add new category'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if (!$this->loadObject(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Hotel Image Category'),
|
||||
'icon' => 'icon-tags',
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'lang' => true,
|
||||
'col' => 4,
|
||||
'hint' => $this->l('Enter the name of the hotel image category.'),
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
public function processSave()
|
||||
{
|
||||
if (!$this->loadObject(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaultLangId = (int) Configuration::get('PS_LANG_DEFAULT');
|
||||
$defaultLanguage = Language::getLanguage($defaultLangId);
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
if (!trim(Tools::getValue('name_'.$defaultLangId))) {
|
||||
$this->errors[] = $this->l('Category name is required at least in ').$defaultLanguage['name'];
|
||||
} else {
|
||||
foreach ($languages as $lang) {
|
||||
$langName = trim(Tools::getValue('name_'.$lang['id_lang']));
|
||||
if ($langName && !Validate::isCatalogName($langName)) {
|
||||
$this->errors[] = $this->l('Invalid category name in ').$lang['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::processSave();
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
if (!$this->display || $this->display == 'list') {
|
||||
$back = $this->context->link->getAdminLink('AdminAddHotel');
|
||||
$this->page_header_toolbar_btn['back_to_list'] = array(
|
||||
'href' => $back,
|
||||
'desc' => $this->l('Back to hotel list'),
|
||||
'icon' => 'process-icon-back'
|
||||
);
|
||||
}
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ require_once 'classes/HotelRoomType.php';
|
||||
require_once 'classes/HotelRoomInformation.php';
|
||||
require_once 'classes/HotelBranchInformation.php';
|
||||
require_once 'classes/HotelImage.php';
|
||||
require_once 'classes/HotelImageCategory.php';
|
||||
require_once 'classes/HotelAmenities.php';
|
||||
require_once 'classes/HotelBranchAmenities.php';
|
||||
require_once 'classes/HotelRoomTypeAmenities.php';
|
||||
|
||||
@@ -529,6 +529,7 @@ class HotelReservationSystem extends Module
|
||||
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
|
||||
$this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', 'AdminHotelConfigurationSetting', false);
|
||||
$this->installTab('AdminBookingDocument', 'Booking Documents', false, false);
|
||||
$this->installTab('AdminHotelImageCategory', 'Hotel Image Category', false, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,82 +21,126 @@
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.htl-img-preview').fancybox({
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
autoSize : false,
|
||||
maxWidth: 700,
|
||||
'hideOnContentClick': false,
|
||||
});
|
||||
|
||||
$("#hotel_images").on("change", function(event) {
|
||||
const files = Array.from(event.target.files);
|
||||
uploadSelectedImages(files);
|
||||
});
|
||||
|
||||
function uploadSelectedImages(files)
|
||||
function initHotelImagePreview()
|
||||
{
|
||||
if (files.length == 0) return; // all done
|
||||
let file = files[0];
|
||||
files.splice(0, 1);
|
||||
createImageUploadRequest(file).then((formData) => {
|
||||
uploadHotelImages(formData).then(() => {
|
||||
uploadSelectedImages(files)
|
||||
});
|
||||
})
|
||||
$('.htl-img-preview').fancybox({
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
autoSize : false,
|
||||
maxWidth: 700,
|
||||
'hideOnContentClick': false,
|
||||
});
|
||||
}
|
||||
|
||||
function createImageUploadRequest(file)
|
||||
initHotelImagePreview();
|
||||
|
||||
function initHotelImageModal(modalId)
|
||||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof file != 'undefined') {
|
||||
if (file.size > maxSizeAllowed) {
|
||||
reject(filesizeError + '[' + file.name + ']');
|
||||
} else {
|
||||
var formData = new FormData();
|
||||
var idHotel = $("#id-hotel").val();
|
||||
formData.append('hotel_image', file);
|
||||
formData.append('id_hotel', idHotel);
|
||||
formData.append('ajax', true);
|
||||
formData.append('action', 'uploadHotelImages');
|
||||
resolve(formData);
|
||||
}
|
||||
$('#page-loader').show();
|
||||
$(modalId).modal('show');
|
||||
setTimeout(function () {
|
||||
$('#page-loader').hide();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function getCheckedImageIds()
|
||||
{
|
||||
return $('.hotel-image-checkbox:checked').map(function () {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
}
|
||||
|
||||
function showEmptyRowIfNoImagesLeft()
|
||||
{
|
||||
if (!$('#hotel-image-table tbody tr[data-id-image]').length) {
|
||||
$('.list-empty-tr').show();
|
||||
}
|
||||
}
|
||||
|
||||
$('#open-add-hotel-images-modal').on('click', function () {
|
||||
var fileInput = document.getElementById('hotel-images-file-input');
|
||||
if (fileInput) {
|
||||
fileInput.value = '';
|
||||
}
|
||||
$('#hotel-images-file-name').val('');
|
||||
initHotelImageModal('#addHotelImagesModal');
|
||||
});
|
||||
|
||||
$('#hotel-images-file-add-btn').on('click', function () {
|
||||
$('#hotel-images-file-input').trigger('click');
|
||||
});
|
||||
|
||||
$('#hotel-images-file-name').on('click', function () {
|
||||
$('#hotel-images-file-input').trigger('click');
|
||||
});
|
||||
|
||||
$('#hotel-images-file-input').on('change', function () {
|
||||
var fileNames = Array.prototype.map.call(this.files, function (file) {
|
||||
return file.name;
|
||||
});
|
||||
$('#hotel-images-file-name').val(fileNames.join(', '));
|
||||
});
|
||||
|
||||
$('#hotel-images-upload-btn').on('click', function () {
|
||||
var fileInput = document.getElementById('hotel-images-file-input');
|
||||
var files = fileInput ? Array.prototype.slice.call(fileInput.files) : [];
|
||||
if (!files.length) {
|
||||
showErrorMessage(imgSelectErrorMsg);
|
||||
return;
|
||||
}
|
||||
uploadHotelImagesSequentially(files);
|
||||
});
|
||||
|
||||
function uploadHotelImagesSequentially(files)
|
||||
{
|
||||
var index = 0;
|
||||
var idHotel = $('#id-hotel').val();
|
||||
var idHtlImageCategory = $('#id_htl_image_category').val();
|
||||
var $btn = $('#hotel-images-upload-btn').prop('disabled', true);
|
||||
|
||||
$('#page-loader').show();
|
||||
|
||||
function next() {
|
||||
if (index >= files.length) {
|
||||
$btn.prop('disabled', false);
|
||||
$('#page-loader').hide();
|
||||
$('#addHotelImagesModal').modal('hide');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function uploadHotelImages(formData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var file = files[index++];
|
||||
var formData = new FormData();
|
||||
formData.append('hotel_image', file);
|
||||
formData.append('ajax', true);
|
||||
formData.append('action', 'UploadHotelImage');
|
||||
formData.append('id_hotel', idHotel);
|
||||
formData.append('id_htl_image_category', idHtlImageCategory);
|
||||
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
dataType:'JSON',
|
||||
type: 'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: formData,
|
||||
cache:false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success:function(response){
|
||||
if (response.success) {
|
||||
$('.list-empty-tr').remove();
|
||||
$("#hotel-image-table tbody").append(response.data.image_row);
|
||||
contentType: false,
|
||||
success: function (resp) {
|
||||
if (resp && resp.success) {
|
||||
$('.list-empty-tr').hide();
|
||||
$('#hotel-image-table tbody').append(resp.image_row);
|
||||
initHotelImagePreview();
|
||||
showSuccessMessage(imgUploadSuccessMsg);
|
||||
resolve(imgUploadSuccessMsg);
|
||||
} else {
|
||||
if (typeof response.errors != 'undefined') {
|
||||
showErrorMessage(response.errors);
|
||||
reject(response.errors);
|
||||
} else {
|
||||
showErrorMessage(imgUploadErrorMsg);
|
||||
reject(imgUploadErrorMsg);
|
||||
}
|
||||
showErrorMessage(file.name + ': ' + ((resp && resp.errors && resp.errors.join(', ')) || imgUploadErrorMsg));
|
||||
}
|
||||
next();
|
||||
},
|
||||
error: function(data) {
|
||||
showErrorMessage(imgUploadErrorMsg);
|
||||
reject(imgUploadErrorMsg);
|
||||
error: function () {
|
||||
showErrorMessage(file.name + ': ' + imgUploadErrorMsg);
|
||||
next();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
$('body').on('click', '.changer-cover-image', function(e){
|
||||
@@ -104,8 +148,8 @@ $(document).ready(function () {
|
||||
var idHotel = $(this).attr('data-id-hotel');
|
||||
var idImage = $(this).attr('data-id-image');
|
||||
var isCover = $(this).attr('data-is-cover');
|
||||
var triggerElement = $(this);
|
||||
if (isCover == 0) {
|
||||
$('#page-loader').show();
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
@@ -118,15 +162,11 @@ $(document).ready(function () {
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.status) {
|
||||
// remover cover image identifier from old cover image
|
||||
var oldCoverImageTr = $("#hotel-image-table tbody tr.cover-image-tr");
|
||||
oldCoverImageTr.removeClass("cover-image-tr").find("td.cover-image-td").removeClass("cover-image-td").find("a.changer-cover-image").removeClass("text-success").addClass("text-danger").attr("data-is-cover", "0").find("i.icon-check").removeClass("icon-check").addClass("icon-times");
|
||||
oldCoverImageTr.find("td button.delete-hotel-image").attr("data-is-cover", "0");
|
||||
|
||||
// Add classes in new covre image elements
|
||||
triggerElement.removeClass("text-danger").addClass("text-success").find("i.icon-times").removeClass("icon-times").addClass("icon-check");
|
||||
triggerElement.parent().addClass("cover-image-td").parent().addClass("cover-image-tr").find("td button.delete-hotel-image").attr("data-is-cover", "1");
|
||||
|
||||
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').replaceWith(result.image_row);
|
||||
if (result.old_cover_row) {
|
||||
$('#hotel-image-table tr[data-id-image="' + result.old_cover_id + '"]').replaceWith(result.old_cover_row);
|
||||
}
|
||||
initHotelImagePreview();
|
||||
showSuccessMessage(coverImgSuccessMsg);
|
||||
} else {
|
||||
showErrorMessage(coverImgErrorMsg);
|
||||
@@ -135,18 +175,207 @@ $(document).ready(function () {
|
||||
error: function(data){
|
||||
showErrorMessage(coverImgErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('click', '.delete-hotel-image', function(e){
|
||||
$('body').on('click', '.edit-hotel-image', function () {
|
||||
var idImage = $(this).data('id-image');
|
||||
var idCategory = parseInt($(this).data('id-htl-image-category'), 10) || 0;
|
||||
var isCover = parseInt($(this).attr('data-is-cover'), 10) === 1;
|
||||
|
||||
var $categorySelect = $('#edit_id_htl_image_category');
|
||||
|
||||
$('#edit_hotel_image_id').val(idImage);
|
||||
$categorySelect.val($categorySelect.find('option[value="' + idCategory + '"]').length ? idCategory : 0);
|
||||
$('#edit_hotel_image_cover_on').prop('checked', isCover);
|
||||
$('#edit_hotel_image_cover_off').prop('checked', !isCover);
|
||||
|
||||
initHotelImageModal('#editHotelImageModal');
|
||||
});
|
||||
|
||||
$('#save-edit-hotel-image-btn').on('click', function () {
|
||||
var idImage = $('#edit_hotel_image_id').val();
|
||||
var idHotel = $('#id-hotel').val();
|
||||
var $btn = $(this).prop('disabled', true);
|
||||
|
||||
$('#page-loader').show();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ajax: true,
|
||||
action: 'EditHotelImage',
|
||||
id_hotel: idHotel,
|
||||
id_image: idImage,
|
||||
id_htl_image_category: $('#edit_id_htl_image_category').val(),
|
||||
cover: $('input[name="edit_hotel_image_cover"]:checked').val()
|
||||
},
|
||||
success: function (resp) {
|
||||
if (resp && resp.status) {
|
||||
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').replaceWith(resp.image_row);
|
||||
if (resp.old_cover_row) {
|
||||
$('#hotel-image-table tr[data-id-image="' + resp.old_cover_id + '"]').replaceWith(resp.old_cover_row);
|
||||
}
|
||||
initHotelImagePreview();
|
||||
showSuccessMessage(imgUpdateSuccessMsg);
|
||||
$('#editHotelImageModal').modal('hide');
|
||||
} else {
|
||||
showErrorMessage((resp && resp.errors && resp.errors.join('<br>')) || imgUploadErrorMsg);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
showErrorMessage(imgUploadErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$btn.prop('disabled', false);
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
});
|
||||
|
||||
$('#hotel-image-select-all').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var idHotel = $(this).attr('data-id-hotel');
|
||||
var idImage = $(this).attr('data-id-image');
|
||||
var isCover = $(this).attr('data-is-cover');
|
||||
var triggerElement = $(this);
|
||||
$('.hotel-image-checkbox').prop('checked', true);
|
||||
});
|
||||
|
||||
$('#hotel-image-unselect-all').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$('.hotel-image-checkbox').prop('checked', false);
|
||||
});
|
||||
|
||||
$('#hotel-image-bulk-update').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
if (!$('.hotel-image-checkbox:checked').length) {
|
||||
showErrorMessage(bulkUpdateSelectErrorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#bulk_id_htl_image_category').val(0);
|
||||
initHotelImageModal('#bulkUpdateHotelImageModal');
|
||||
});
|
||||
|
||||
var pendingBulkDeleteImageIds = null;
|
||||
|
||||
$('#hotel-image-bulk-delete').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var imageIds = getCheckedImageIds();
|
||||
if (!imageIds.length) {
|
||||
showErrorMessage(bulkDeleteSelectErrorMsg);
|
||||
return;
|
||||
}
|
||||
pendingBulkDeleteImageIds = imageIds;
|
||||
$('#confirmDeleteHotelImageModal').modal('show');
|
||||
});
|
||||
|
||||
$('#save-bulk-hotel-image-btn').on('click', function () {
|
||||
var idHotel = $('#id-hotel').val();
|
||||
var idHtlImageCategory = $('#bulk_id_htl_image_category').val();
|
||||
var imageIds = getCheckedImageIds();
|
||||
var $btn = $(this).prop('disabled', true);
|
||||
|
||||
$('#page-loader').show();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ajax: true,
|
||||
action: 'BulkUpdateHotelImage',
|
||||
id_hotel: idHotel,
|
||||
id_htl_image_category: idHtlImageCategory,
|
||||
image_ids: imageIds
|
||||
},
|
||||
success: function (resp) {
|
||||
if (resp && resp.status) {
|
||||
$.each(resp.image_ids, function (i, idImage) {
|
||||
var $row = $('#hotel-image-table tr[data-id-image="' + idImage + '"]');
|
||||
$row.find('.hotel-image-category-cell').text(resp.category_name || '—');
|
||||
$row.find('.edit-hotel-image').attr('data-id-htl-image-category', idHtlImageCategory);
|
||||
});
|
||||
$('.hotel-image-checkbox').prop('checked', false);
|
||||
showSuccessMessage(imgUpdateSuccessMsg);
|
||||
$('#bulkUpdateHotelImageModal').modal('hide');
|
||||
} else {
|
||||
showErrorMessage((resp && resp.errors && resp.errors.join('<br>')) || imgUploadErrorMsg);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
showErrorMessage(imgUploadErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$btn.prop('disabled', false);
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
});
|
||||
|
||||
var pendingDeleteHotelImage = null;
|
||||
|
||||
$('body').on('click', '.delete-hotel-image', function (e) {
|
||||
e.preventDefault();
|
||||
pendingDeleteHotelImage = $(this);
|
||||
pendingBulkDeleteImageIds = null;
|
||||
$('#confirmDeleteHotelImageModal').modal('show');
|
||||
});
|
||||
|
||||
$('#confirm-delete-hotel-image-btn').on('click', function () {
|
||||
$('#confirmDeleteHotelImageModal').modal('hide');
|
||||
|
||||
if (pendingBulkDeleteImageIds && pendingBulkDeleteImageIds.length) {
|
||||
var bulkImageIds = pendingBulkDeleteImageIds;
|
||||
var bulkIdHotel = $('#id-hotel').val();
|
||||
pendingBulkDeleteImageIds = null;
|
||||
|
||||
$('#page-loader').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
ajax: true,
|
||||
action: 'BulkDeleteHotelImage',
|
||||
id_hotel: bulkIdHotel,
|
||||
image_ids: bulkImageIds
|
||||
},
|
||||
success: function (result) {
|
||||
if (result.status) {
|
||||
$.each(result.deleted_ids, function (i, idImage) {
|
||||
$('#hotel-image-table tr[data-id-image="' + idImage + '"]').fadeOut().remove();
|
||||
});
|
||||
if (result.new_cover_row) {
|
||||
$('#hotel-image-table tr[data-id-image="' + result.new_cover_id + '"]').replaceWith(result.new_cover_row);
|
||||
initHotelImagePreview();
|
||||
}
|
||||
showEmptyRowIfNoImagesLeft();
|
||||
$('.hotel-image-checkbox').prop('checked', false);
|
||||
showSuccessMessage(deleteImgSuccessMsg);
|
||||
} else {
|
||||
showErrorMessage((result.errors && result.errors.join('<br>')) || deleteImgErrorMsg);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var triggerElement = pendingDeleteHotelImage;
|
||||
if (!triggerElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
var idHotel = triggerElement.attr('data-id-hotel');
|
||||
var idImage = triggerElement.attr('data-id-image');
|
||||
|
||||
if (parseInt(idHotel) && parseInt(idImage)) {
|
||||
$('#page-loader').show();
|
||||
$.ajax({
|
||||
type:'POST',
|
||||
url: adminHotelCtrlUrl,
|
||||
@@ -159,19 +388,16 @@ $(document).ready(function () {
|
||||
},
|
||||
success: function(result) {
|
||||
if (result.status) {
|
||||
if (parseInt(isCover)) {
|
||||
location.reload();
|
||||
} else {
|
||||
var currentPosition = parseInt(triggerElement.parents('tr').find('td.image-position').text());
|
||||
var nextAllSiblings = triggerElement.parents('tr').nextAll();
|
||||
triggerElement.parents('tr').fadeOut().remove();
|
||||
triggerElement.parents('tr').fadeOut().remove();
|
||||
|
||||
// Correct Images Positions
|
||||
$(nextAllSiblings).each(function(index, element) {
|
||||
$(this).find('td.image-position').text(parseInt(currentPosition + parseInt(index)));
|
||||
});
|
||||
showSuccessMessage(deleteImgSuccessMsg);
|
||||
if (result.new_cover_row) {
|
||||
$('#hotel-image-table tr[data-id-image="' + result.new_cover_id + '"]').replaceWith(result.new_cover_row);
|
||||
initHotelImagePreview();
|
||||
}
|
||||
|
||||
showEmptyRowIfNoImagesLeft();
|
||||
|
||||
showSuccessMessage(deleteImgSuccessMsg);
|
||||
} else {
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
}
|
||||
@@ -179,9 +405,11 @@ $(document).ready(function () {
|
||||
error: function(data){
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
}
|
||||
}).always(function () {
|
||||
$('#page-loader').hide();
|
||||
});
|
||||
} else {
|
||||
showErrorMessage(deleteImgErrorMsg);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,16 +20,25 @@
|
||||
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
|
||||
*}
|
||||
|
||||
<tr class="{if $image.cover == 1}cover-image-tr{/if}">
|
||||
{assign var="isCoverImage" value=$image.cover == 1}
|
||||
<tr class="{if $isCoverImage}cover-image-tr{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
|
||||
<td class="row-selector text-center"><input type="checkbox" class="noborder hotel-image-checkbox" value="{$image.id|escape:'html':'UTF-8'}"></td>
|
||||
<td class="text-center">{$image.id|escape:'html':'UTF-8'}</td>
|
||||
<td class="text-center">
|
||||
<a class="htl-img-preview" href="{$image.image_link|escape:'html':'UTF-8'}">
|
||||
<img class="img-thumbnail" width="100" src="{$image.image_link_small|escape:'html':'UTF-8'}"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center {if $image.cover == 1}cover-image-td{/if}">
|
||||
<a href="#" class="{if $image.cover == 1}text-success{else}text-danger{/if} changer-cover-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $image.cover == 1}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
|
||||
{if $image.cover == 1}
|
||||
<td class="text-center hotel-image-category-cell">
|
||||
{if isset($image.category_name) && $image.category_name}
|
||||
{$image.category_name|escape:'html':'UTF-8'}
|
||||
{else}
|
||||
—
|
||||
{/if}
|
||||
</td>
|
||||
<td class="text-center {if $isCoverImage}cover-image-td{/if}">
|
||||
<a href="#" class="{if $isCoverImage}text-success{else}text-danger{/if} changer-cover-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $isCoverImage}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}">
|
||||
{if $isCoverImage}
|
||||
<i class="icon-check"></i>
|
||||
{else}
|
||||
<i class="icon-times"></i>
|
||||
@@ -37,6 +46,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-default delete-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $image.cover == 1}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}"><i class="icon-trash"></i></button>
|
||||
<button type="button" class="btn btn-default edit-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-id-image="{$image.id|escape:'html':'UTF-8'}" data-id-htl-image-category="{if isset($image.id_htl_image_category)}{$image.id_htl_image_category|intval}{else}0{/if}" data-is-cover="{if $isCoverImage}1{else}0{/if}"><i class="icon-pencil"></i></button>
|
||||
<button type="button" class="btn btn-default delete-hotel-image" data-id-hotel="{$hotel_info.id|escape:'html':'UTF-8'}" data-is-cover="{if $isCoverImage}1{else}0{/if}" data-id-image="{$image.id|escape:'html':'UTF-8'}"><i class="icon-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
<table class="table" id="hotel-image-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center"> </th>
|
||||
<th class="text-center">{l s='Image Id' mod='hotelreservationsystem'}</th>
|
||||
<th class="text-center">{l s='Image' mod='hotelreservationsystem'}</th>
|
||||
<th class="text-center">{l s='Category' mod='hotelreservationsystem'}</th>
|
||||
<th class="text-center">{l s='Cover' mod='hotelreservationsystem'}</th>
|
||||
<th class="text-center">{l s='Action' mod='hotelreservationsystem'}</th>
|
||||
</tr>
|
||||
@@ -35,16 +37,183 @@
|
||||
{foreach from=$hotelImages item=image name=hotelImage}
|
||||
{include file="./htl-images-list-row.tpl"}
|
||||
{/foreach}
|
||||
{else}
|
||||
<tr class="list-empty-tr">
|
||||
<td class="list-empty" colspan="5">
|
||||
<div class="list-empty-msg">
|
||||
<i class="icon-warning-sign list-empty-icon"></i>
|
||||
{l s='No Image Found' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr class="list-empty-tr" {if isset($hotelImages) && $hotelImages}style="display:none;"{/if}>
|
||||
<td class="list-empty" colspan="6">
|
||||
<div class="list-empty-msg">
|
||||
<i class="icon-warning-sign list-empty-icon"></i>
|
||||
{l s='No Image Found' mod='hotelreservationsystem'}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group bulk-actions dropup">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
{l s='Bulk actions' mod='hotelreservationsystem'} <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="#" id="hotel-image-select-all">
|
||||
<i class="icon-check-sign"></i> {l s='Select all' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" id="hotel-image-unselect-all">
|
||||
<i class="icon-check-empty"></i> {l s='Unselect all' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a href="#" id="hotel-image-bulk-update">
|
||||
<i class="icon-edit"></i> {l s='Update selection' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" id="hotel-image-bulk-delete">
|
||||
<i class="icon-trash"></i> {l s='Delete selected' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addHotelImagesModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
|
||||
<h4 class="modal-title"><i class="icon-image"></i> {l s='Add Images' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Images' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<input type="file" id="hotel-images-file-input" class="hide" accept="image/gif, image/jpg, image/jpeg, image/png" multiple>
|
||||
<div class="dummyfile input-group">
|
||||
<span class="input-group-addon"><i class="icon-file"></i></span>
|
||||
<input id="hotel-images-file-name" type="text" readonly>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" id="hotel-images-file-add-btn" class="btn btn-default">
|
||||
<i class="icon-folder-open"></i> {l s='Add images' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="help-block">{l s='Allowed image formats: .gif, .jpg, .jpeg and .png' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="id_htl_image_category" name="id_htl_image_category">
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
<p class="help-block" style="margin-bottom:2px;">{l s='If not selected, image will be uncategorized.' mod='hotelreservationsystem'} — <a href="{$link->getAdminLink('AdminHotelImageCategory')|escape:'html':'UTF-8'}&addhtl_image_category" target="_blank" style="white-space:nowrap;">{l s='Create image category' mod='hotelreservationsystem'} <i class="icon-external-link" style="font-size:11px;"></i></a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="hotel-images-upload-btn"><i class="icon-upload"></i> {l s='Upload' mod='hotelreservationsystem'}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="confirmDeleteHotelImageModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
|
||||
<h4 class="modal-title"><i class="icon-exclamation-triangle"></i> {l s='Confirm Delete' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{l s='Are you sure you want to delete the selected image(s)? This cannot be undone.' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="confirm-delete-hotel-image-btn">{l s='Delete' mod='hotelreservationsystem'}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="editHotelImageModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
|
||||
<h4 class="modal-title"><i class="icon-image"></i> {l s='Edit Image' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="edit_hotel_image_id">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="edit_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="edit_id_htl_image_category">
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3">{l s='Cover image' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<span class="switch prestashop-switch fixed-width-lg">
|
||||
<input type="radio" id="edit_hotel_image_cover_on" name="edit_hotel_image_cover" value="1">
|
||||
<label for="edit_hotel_image_cover_on">{l s='Yes' mod='hotelreservationsystem'}</label>
|
||||
<input type="radio" id="edit_hotel_image_cover_off" name="edit_hotel_image_cover" value="0">
|
||||
<label for="edit_hotel_image_cover_off">{l s='No' mod='hotelreservationsystem'}</label>
|
||||
<a class="slide-button btn"></a>
|
||||
</span>
|
||||
<p class="help-block">{l s='Setting this to Yes will make this the cover image, replacing the current one.' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="save-edit-hotel-image-btn">
|
||||
<i class="icon-save"></i> {l s='Save' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="bulkUpdateHotelImageModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><i class="icon-remove-sign"></i></button>
|
||||
<h4 class="modal-title"><i class="icon-edit"></i> {l s='Bulk Update selection' mod='hotelreservationsystem'}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-lg-3" for="bulk_id_htl_image_category">{l s='Category' mod='hotelreservationsystem'}</label>
|
||||
<div class="col-lg-9">
|
||||
<select class="form-control" id="bulk_id_htl_image_category">
|
||||
<option value="0">{l s='Select category' mod='hotelreservationsystem'}</option>
|
||||
{if isset($hotelImageCategories) && $hotelImageCategories}
|
||||
{foreach from=$hotelImageCategories item=hotelImageCategory}
|
||||
<option value="{$hotelImageCategory.id_htl_image_category|intval}">{$hotelImageCategory.name|escape:'html':'UTF-8'}</option>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</select>
|
||||
<p class="help-block">{l s='If not selected, selected images will be uncategorized.' mod='hotelreservationsystem'}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="save-bulk-hotel-image-btn">
|
||||
<i class="icon-save"></i> {l s='Save' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
</div>
|
||||
|
||||
<form id="{$table|escape:'htmlall':'UTF-8'}_form" class="defaultForm {$name_controller|escape:'htmlall':'UTF-8'} form-horizontal" action="{$current|escape:'htmlall':'UTF-8'}&{if !empty($submit_action)}{$submit_action|escape:'htmlall':'UTF-8'}{/if}&token={$token|escape:'htmlall':'UTF-8'}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style|escape:'htmlall':'UTF-8'}"{/if}>
|
||||
<input type="hidden" id="htl_active_tab" name="htl_active_tab" value="">
|
||||
{if isset($edit)}
|
||||
{assign var=hook_arg_id_hotel value=$hotel_info.id}
|
||||
{else}
|
||||
@@ -437,19 +438,17 @@
|
||||
{hook h='displayAdminAddHotelFormImagesTabBefore' id_hotel=$hook_arg_id_hotel}
|
||||
|
||||
{if isset($hotel_info.id) && $hotel_info.id}
|
||||
<div class="form-group row">
|
||||
<label for="hotel_images" class="col-sm-3 control-label padding-top-0">
|
||||
{l s='Upload images' mod='hotelreservationsystem'} :
|
||||
</label>
|
||||
<div class="col-sm-5">
|
||||
<input class="form-control-static" type="file" accept="image/gif, image/jpg, image/jpeg, image/png" id="hotel_images" name="hotel_images[]" multiple>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{* Image table *}
|
||||
<h4><i class="icon-image"></i> <span>{l s='Hotel Images' mod='hotelreservationsystem'}</span></h4>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-right">
|
||||
<a href="{$link->getAdminLink('AdminHotelImageCategory')|escape:'html':'UTF-8'}" class="btn btn-default">
|
||||
<i class="icon-plus-sign"></i> {l s='ADD CATEGORY' mod='hotelreservationsystem'}
|
||||
</a>
|
||||
<button type="button" class="btn btn-primary" id="open-add-hotel-images-modal">
|
||||
<i class="icon-plus-sign"></i> {l s='Add images' mod='hotelreservationsystem'}
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<hr>
|
||||
{include file="../../_partials/htl-images-list.tpl"}
|
||||
</div>
|
||||
</div>
|
||||
@@ -672,10 +671,14 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{strip}
|
||||
{addJsDef adminHotelCtrlUrl = $link->getAdminlink('AdminAddHotel')}
|
||||
{addJsDefL name=imgUploadSuccessMsg}{l s='Image Successfully Uploaded' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=imgUploadErrorMsg}{l s='Something went wrong while uploading images. Please try again later !!' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{strip}
|
||||
{addJsDef adminHotelCtrlUrl = $link->getAdminlink('AdminAddHotel')}
|
||||
{addJsDefL name=imgSelectErrorMsg}{l s='Please select at least one image before uploading.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=bulkUpdateSelectErrorMsg}{l s='Please select at least one image to update.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=bulkDeleteSelectErrorMsg}{l s='Please select at least one image to delete.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=imgUploadSuccessMsg}{l s='Image Successfully Uploaded' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=imgUploadErrorMsg}{l s='Something went wrong while uploading images. Please try again later !!' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=imgUpdateSuccessMsg}{l s='Image updated successfully.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
|
||||
{addJsDefL name=coverImgSuccessMsg}{l s='Cover image changed successfully' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=coverImgErrorMsg}{l s='Error while changing cover image' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
@@ -686,8 +689,6 @@
|
||||
{addJsDef enabledDisplayMap = $enabledDisplayMap}
|
||||
{addJsDef defaultCountry = $defaultCountry}
|
||||
{addJsDef statebycountryurl = $link->getAdminLink('AdminAddHotel')}
|
||||
{addJsDefL name=htlImgDeleteSuccessMsg}{l s='Image removed successfully.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{addJsDefL name=htlImgDeleteErrMsg}{l s='Some error occurred while deleting hotel image.' js=1 mod='hotelreservationsystem'}{/addJsDefL}
|
||||
{/strip}
|
||||
|
||||
{block name=script}
|
||||
@@ -726,6 +727,17 @@
|
||||
$(document).on('wk.lang.changed', function(e, idLang) {
|
||||
$(window).trigger('resize.autosize');
|
||||
});
|
||||
|
||||
// Restore active tab from controller redirect param
|
||||
var _htlActiveTab = '{if !empty($smarty.get.htl_active_tab)}{$smarty.get.htl_active_tab|escape:'javascript':'UTF-8'}{/if}';
|
||||
if (/^#[\w-]+$/.test(_htlActiveTab) && $('a[href="' + _htlActiveTab + '"]').length) {
|
||||
$('a[href="' + _htlActiveTab + '"]').tab('show');
|
||||
}
|
||||
|
||||
// Keep hidden input in sync so active tab survives form submission
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
$('#htl_active_tab').val($(e.target).attr('href'));
|
||||
});
|
||||
});
|
||||
$(".textarea-autosize").autosize();
|
||||
// After full page load, reinit visible textareas so they start at the correct height
|
||||
|
||||
@@ -24,7 +24,10 @@
|
||||
{if is_array($hotel_images) && count($hotel_images)}
|
||||
{foreach from=$hotel_images item=hotel_image}
|
||||
<div class="col-sm-4 image-item">
|
||||
<a class="hotel-images-fancybox" href="{$hotel_image.link|escape:'html':'UTF-8'}">
|
||||
<a class="fancybox"
|
||||
href="{$hotel_image.link|escape:'html':'UTF-8'}"
|
||||
data-fancybox-group="hotel-images"
|
||||
title="{if isset($hotel_image.category_name) && $hotel_image.category_name}{$hotel_image.category_name|escape:'html':'UTF-8'}{/if}">
|
||||
<img class="img img-responsive" src="{$hotel_image.link|escape:'html':'UTF-8'}">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,9 @@ a.fancybox-nav {
|
||||
.pb-left-column #image-block img {
|
||||
background: #fbfbfb;
|
||||
border-radius: 4px;
|
||||
width: 100%; }
|
||||
width: 100%;
|
||||
min-height: 420px;
|
||||
object-fit: cover; }
|
||||
.pb-left-column #image-block #view_full_size .span_link {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
@@ -1787,4 +1789,4 @@ ul.service-product-nav > li:hover {
|
||||
#hotel_rating {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,6 +205,13 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
if ($('.room_info_hotel_images_wrap').length) {
|
||||
if (!!$.prototype.fancybox) {
|
||||
$('.room_info_hotel_images_wrap .fancybox').fancybox({
|
||||
'hideOnContentClick': true,
|
||||
'openEffect': 'elastic',
|
||||
'closeEffect': 'elastic',
|
||||
});
|
||||
}
|
||||
loadHotelImagesByPage(1);
|
||||
}
|
||||
});
|
||||
@@ -1536,7 +1543,6 @@ function loadHotelImagesByPage(page = 1) {
|
||||
success: function(response) {
|
||||
if (response.status == true && response.message == 'HTML_OK') {
|
||||
$('.room_info_hotel_images_wrap .images-wrap').append(response.html);
|
||||
$('.room_info_hotel_images_wrap .hotel-images-fancybox').fancybox();
|
||||
$('.room_info_hotel_images_wrap .btn-show-more-images').removeClass('hide');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user