diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php
index 1dc360f64..ffb9f0007 100644
--- a/controllers/admin/AdminPPreferencesController.php
+++ b/controllers/admin/AdminPPreferencesController.php
@@ -213,6 +213,13 @@ class AdminPPreferencesControllerCore extends AdminController
'required' => false,
'type' => 'bool'
),
+ 'PS_HOTEL_IMAGES_PER_PAGE' => array(
+ 'title' => $this->l('Number of hotel images per page'),
+ 'hint' => $this->l('Number of hotel images displayed per page. Default is 9.'),
+ 'validation' => 'isUnsignedInt',
+ 'cast' => 'intval',
+ 'type' => 'text'
+ ),
),
'submit' => array('title' => $this->l('Save'))
),
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 2d85e00c0..84bc8282b 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -1015,4 +1015,40 @@ class ProductControllerCore extends FrontController
}
die(json_encode($result));
}
+
+ public function displayAjaxGetHotelImages()
+ {
+ $response = array('status' => 'ko');
+ $idProduct = (int) Tools::getValue('id_product');
+ $page = (int) Tools::getValue('page');
+ $imagesPerPage = (int) Configuration::get('PS_HOTEL_IMAGES_PER_PAGE');
+
+ $objHotelRoomType = new HotelRoomType();
+ $objHotelImage = new HotelImage();
+
+ $roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
+ $idHotel = $roomTypeInfo['id_hotel'];
+ $hotelImages = $objHotelImage->getImagesByHotelId($idHotel, $page, $imagesPerPage);
+ $hasNextPage = ($objHotelImage->getImagesByHotelId($idHotel, $page + 1, $imagesPerPage)) ? true : false;
+ $hotelImagesBaseDir = _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_img/';
+ foreach ($hotelImages as &$hotelImage) {
+ $hotelImage['link'] = $this->context->link->getMediaLink(
+ $hotelImagesBaseDir.$hotelImage['hotel_image_id'].'.jpg'
+ );
+ }
+
+ if (is_array($hotelImages) && count($hotelImages)) {
+ $this->context->smarty->assign(array('hotel_images' => $hotelImages));
+ $html = $this->context->smarty->fetch(
+ $this->getTemplatePath('_partials/hotel_images.tpl')
+ );
+
+ $response['html'] = $html;
+ $response['status'] = 'ok';
+ $response['has_next_page'] = $hasNextPage;
+ $response['message'] = 'HTML_OK';
+ }
+
+ die(json_encode($response));
+ }
}
diff --git a/install/data/theme.sql b/install/data/theme.sql
index 9785d6955..e86e05bfd 100644
--- a/install/data/theme.sql
+++ b/install/data/theme.sql
@@ -2,6 +2,7 @@ SET NAMES 'utf8';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS';
UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE';
+UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES';
diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml
index eaa524deb..7d09e334d 100644
--- a/install/data/xml/configuration.xml
+++ b/install/data/xml/configuration.xml
@@ -56,6 +56,9 @@
12
+
+ 9
+
0
diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
index fb4561107..37d03bfa3 100644
--- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php
+++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
@@ -616,7 +616,7 @@ class HotelBranchInformation extends ObjectModel
'HotelBranchInformation'
);
}
- $hotelAllImages = $objHotelImage->getAllImagesByHotelId($idHotel);
+ $hotelAllImages = $objHotelImage->getImagesByHotelId($idHotel);
if ($hotelAllImages) {
foreach ($hotelAllImages as $key_img => $value_img) {
if (Validate::isLoadedObject($objHotelImage = new HotelImage((int) $value_img['id']))) {
diff --git a/modules/hotelreservationsystem/classes/HotelImage.php b/modules/hotelreservationsystem/classes/HotelImage.php
index 79a6f0f1b..8882b140d 100644
--- a/modules/hotelreservationsystem/classes/HotelImage.php
+++ b/modules/hotelreservationsystem/classes/HotelImage.php
@@ -59,13 +59,26 @@ class HotelImage extends ObjectModel
}
/**
- * [getAllImagesByHotelId :: To get all images data of a hotel by hotel id]
- * @param [int] $htl_id [Id of the hotel which images data you want]
+ * [getImagesByHotelId :: To get paginated hotel images data]
+ * @param [int] $id_hotel [id_hotel to get images of]
+ * @param [int] $p [page number of the paginated images data]
+ * @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 getAllImagesByHotelId($htl_id)
+ public function getImagesByHotelId($id_hotel, $p = 1, $n = null)
{
- return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_image` WHERE `id_hotel` = '.(int)$htl_id);
+ $p = (int) $p;
+ $n = $n !== null ? (int) $n : $n; // n = null for no pagination
+ if ($p <= 1) {
+ $p = 1;
+ }
+
+ $sql = 'SELECT *
+ FROM `'._DB_PREFIX_.'htl_image`
+ WHERE `id_hotel` = '.(int) $id_hotel.
+ ($n ? ' LIMIT '.(int) (($p - 1) * $n).', '.(int) ($n) : '');
+
+ return Db::getInstance()->executeS($sql);
}
/**
diff --git a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelImages.php b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelImages.php
index eaf26c1be..4e13597eb 100644
--- a/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelImages.php
+++ b/modules/hotelreservationsystem/classes/WebserviceSpecificManagementHotelImages.php
@@ -172,7 +172,7 @@ class WebserviceSpecificManagementHotelImages implements WebserviceSpecificManag
$available_image_ids = array();
$objHotelImg = new HotelImage();
- $images = $objHotelImg->getAllImagesByHotelId($object_id);
+ $images = $objHotelImg->getImagesByHotelId($object_id);
foreach ($images as $image) {
$available_image_ids[] = $image['id'];
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
index a40cb255b..44a0976d9 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
@@ -141,7 +141,7 @@ class AdminAddHotelController extends ModuleAdminController
$smartyVars['hotel_info'] = $hotelBranchInfo;
//Hotel Images
$objHotelImage = new HotelImage();
- if ($hotelAllImages = $objHotelImage->getAllImagesByHotelId($idHotel)) {
+ if ($hotelAllImages = $objHotelImage->getImagesByHotelId($idHotel)) {
foreach ($hotelAllImages as &$image) {
$image['image_link'] = $this->context->link->getMediaLink(_MODULE_DIR_.$this->module->name.'/views/img/hotel_img/'.$image['hotel_image_id'].'.jpg');
}
@@ -562,7 +562,7 @@ class AdminAddHotelController extends ModuleAdminController
if (Validate::isLoadedObject($objHtlImage = new HotelImage((int) $idImage))) {
if ($objHtlImage->delete()) {
if (!HotelImage::getCover($idHotel)) {
- $images = $objHtlImage->getAllImagesByHotelId($idHotel);
+ $images = $objHtlImage->getImagesByHotelId($idHotel);
if ($images) {
$objHtlImage = new HotelImage($images[0]['id']);
$objHtlImage->cover = 1;
diff --git a/themes/hotel-reservation-theme/_partials/hotel_images.tpl b/themes/hotel-reservation-theme/_partials/hotel_images.tpl
new file mode 100644
index 000000000..05b4fe86c
--- /dev/null
+++ b/themes/hotel-reservation-theme/_partials/hotel_images.tpl
@@ -0,0 +1,28 @@
+{**
+* 2010-2022 Webkul.
+*
+* NOTICE OF LICENSE
+*
+* All right is reserved,
+* Please go through LICENSE.txt file inside our module
+*
+* DISCLAIMER
+*
+* Do not edit or add to this file if you wish to upgrade this module to newer
+* versions in the future. If you wish to customize this module for your
+* needs please refer to CustomizationPolicy.txt file inside our module for more information.
+*
+* @author Webkul IN
+* @copyright 2010-2022 Webkul IN
+* @license LICENSE.txt
+*}
+
+{if is_array($hotel_images) && count($hotel_images)}
+ {foreach from=$hotel_images item=hotel_image}
+
+ {/foreach}
+{/if}
diff --git a/themes/hotel-reservation-theme/css/product.css b/themes/hotel-reservation-theme/css/product.css
index e3694e19f..e97fcadb8 100644
--- a/themes/hotel-reservation-theme/css/product.css
+++ b/themes/hotel-reservation-theme/css/product.css
@@ -1469,4 +1469,36 @@ Quick View Styles
#rooms_extra_demands .accordion-section-content {
display:none;
border-top: 1px solid #eee;
- padding-top: 15px;} */
\ No newline at end of file
+ padding-top: 15px;} */
+
+.room_info_hotel_images_wrap .row {
+ margin-left: -7.5px;
+ margin-right: -7.5px; }
+
+.room_info_hotel_images_wrap .col-sm-4 {
+ padding-left: 7.5px;
+ padding-right: 7.5px; }
+
+#room_info_hotel_images .image-item {
+ margin-bottom: 15px; }
+
+#room_info_hotel_images .image-item img {
+ width: 100%;
+ height: 200px;
+ border-radius: 4px;
+ object-fit: cover;
+ transition: all 0.2s; }
+
+#room_info_hotel_images .image-item img:hover {
+ transform: scale(1.05); }
+
+.room_info_hotel_images_wrap .btn-show-more-images {
+ background: #379BF0;
+ padding: 10px 25px;
+ border: none;
+ border-radius: 2px;
+ color: #fff;
+ font-weight: bold; }
+
+.room_info_hotel_images_wrap .btn-show-more-images:hover {
+ opacity: 0.8; }
diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js
index 01ecd1ec4..d5c9bb410 100644
--- a/themes/hotel-reservation-theme/js/product.js
+++ b/themes/hotel-reservation-theme/js/product.js
@@ -204,6 +204,8 @@ $(document).ready(function() {
if (url.indexOf('#') != -1)
getProductAttribute();
}
+
+ loadHotelImages();
});
$(window).resize(function() {
@@ -1431,3 +1433,65 @@ function changeRoomDate(date_in, date_out){
}
});
}
+
+function loadHotelImages() {
+ const btnShowMore = $('.btn-show-more-images');
+
+ $.ajax({
+ url: product_controller_url,
+ type: 'POST',
+ dataType: 'JSON',
+ data: {
+ ajax: true,
+ action: 'getHotelImages',
+ id_product: id_product,
+ page: 1,
+ },
+ success: function(response) {
+ if (response.message == 'HTML_OK') {
+ $('#room_info_hotel_images').append(response.html);
+ $('.hotel-images-fancybox').fancybox();
+ } else {
+ $('.room_info_hotel_images_wrap').hide();
+ }
+
+ if (!response.has_next_page) {
+ $(btnShowMore).hide(200);
+ }
+ }
+ });
+}
+
+$(document).on('click', '.btn-show-more-images', function () {
+ loadMoreHotelImages();
+});
+
+function loadMoreHotelImages() {
+ const btnShowMore = $('.btn-show-more-images');
+ const page = parseInt($(btnShowMore).attr('data-next-page'));
+
+ $.ajax({
+ url: product_controller_url,
+ type: 'POST',
+ dataType: 'JSON',
+ data: {
+ ajax: true,
+ action: 'getHotelImages',
+ id_product: id_product,
+ page: page,
+ },
+ success: function(response) {
+ if (response.message == 'HTML_OK') {
+ $('#room_info_hotel_images').append(response.html);
+ $('.hotel-images-fancybox').fancybox();
+ }
+
+ if (response.has_next_page) {
+ $(btnShowMore).show(200);
+ $(btnShowMore).attr('data-next-page', page + 1);
+ } else {
+ $(btnShowMore).hide(200);
+ }
+ }
+ });
+}
diff --git a/themes/hotel-reservation-theme/product.tpl b/themes/hotel-reservation-theme/product.tpl
index c10f43ae4..6c5ef9354 100644
--- a/themes/hotel-reservation-theme/product.tpl
+++ b/themes/hotel-reservation-theme/product.tpl
@@ -231,6 +231,19 @@
{/if}
+