Merge branch 'Qloapps:develop' into gli-2934

This commit is contained in:
Shazar Rahman
2026-07-14 12:25:08 +05:30
committed by GitHub
60 changed files with 1288 additions and 136 deletions

View File

@@ -54,8 +54,6 @@ class Blocknewsletter extends Module
$this->tab = 'front_office_features';
$this->need_instance = 0;
$this->controllers = array('verification');
$this->bootstrap = true;
parent::__construct();

View File

@@ -1331,6 +1331,7 @@ class HotelCartBookingData extends ObjectModel
);
$cart_detail_data[$key]['amt_with_qty'] = $roomTypeDateRangePrice['total_price_tax_excl'];
$cart_detail_data[$key]['connected_rooms'] = HotelConnectedRoom::getConnectedRooms((int) $obj_htl_room_info->id, null, null, Context::getContext()->language->id);
}
}
if ($cart_detail_data) {

View File

@@ -0,0 +1,180 @@
<?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 HotelConnectedRoom extends ObjectModel
{
/** @var bool|null */
protected static $connectedRoomTableAvailable = null;
public $id_connected_room;
public $id_room;
public $id_room_connected;
public $date_add;
public $date_upd;
public static $definition = array(
'table' => 'htl_connected_room',
'primary' => 'id_connected_room',
'fields' => array(
'id_room' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_room_connected' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'date_add' => array('type' => self::TYPE_DATE),
'date_upd' => array('type' => self::TYPE_DATE),
),
);
public static function getConnectedRooms($idRoom = null, $idRoomType = null, $idHotel = null, $idLang = null)
{
$idLang = $idLang ? (int) $idLang : (int) Context::getContext()->language->id;
$sql = 'SELECT
hcr.id_connected_room,
hcr.id_room,
base_room.room_num AS room_name,
connected_room.id AS id_room_connected,
connected_room.id_product AS id_room_type,
conn_pl.name AS room_type_name,
connected_room.room_num AS connected_room_name
FROM `' . _DB_PREFIX_ . 'htl_connected_room` hcr
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` connected_room
ON connected_room.id = hcr.id_room_connected
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` base_room
ON base_room.id = hcr.id_room
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` conn_pl
ON (conn_pl.id_product = connected_room.id_product AND conn_pl.id_lang = ' . $idLang . ')
WHERE 1';
if ($idRoom !== null) {
$sql .= ' AND hcr.id_room = ' . $idRoom;
}
if ($idRoomType !== null) {
$sql .= ' AND base_room.id_product = ' . (int) $idRoomType;
}
if ($idHotel !== null) {
$sql .= ' AND base_room.id_hotel = ' . (int) $idHotel;
}
$sql .= ' ORDER BY hcr.id_room, connected_room.id_product, connected_room.room_num';
$results = Db::getInstance()->executeS($sql);
if ($results === false) {
return array();
}
$connectedRooms = array();
foreach ($results as $row) {
$roomId = (int) $row['id_room'];
$roomTypeId = (int) $row['id_room_type'];
if (!isset($connectedRooms[$roomId])) {
$connectedRooms[$roomId] = array(
'name' => $row['room_name'],
'connected_room_types' => array(),
);
}
if (!isset($connectedRooms[$roomId]['connected_room_types'][$roomTypeId])) {
$connectedRooms[$roomId]['connected_room_types'][$roomTypeId] = array(
'room_type_name' => $row['room_type_name'],
'connected_rooms' => array(),
);
}
$connectedRooms[$roomId]['connected_room_types'][$roomTypeId]['connected_rooms'][] = array(
'id_connected_room' => (int) $row['id_connected_room'],
'id_room' => (int) $row['id_room_connected'],
'name' => $row['connected_room_name'],
);
}
return $connectedRooms;
}
public static function getNotConnectedRooms($idRoom, $idLang = null)
{
$idRoom = (int) $idRoom;
if ($idRoom <= 0) {
return array();
}
$idLang = $idLang ? (int) $idLang : (int) Context::getContext()->language->id;
$sql = 'SELECT hri.id AS id_room, hri.id_product AS id_room_type, pl.name AS room_type_name, hri.room_num AS room_name
FROM `' . _DB_PREFIX_ . 'htl_room_information` hri
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (pl.id_product = hri.id_product AND pl.id_lang = ' . $idLang . ')
WHERE hri.id != ' . $idRoom . '
AND hri.id_hotel = (
SELECT id_hotel FROM `' . _DB_PREFIX_ . 'htl_room_information` WHERE id = ' . $idRoom . '
)
AND NOT EXISTS (
SELECT 1 FROM `' . _DB_PREFIX_ . 'htl_connected_room` cr
WHERE cr.id_room = ' . $idRoom . ' AND cr.id_room_connected = hri.id
)
ORDER BY pl.name ASC, hri.room_num ASC';
$results = Db::getInstance()->executeS($sql);
$grouped = array();
foreach ($results as $row) {
$typeId = (int) $row['id_room_type'];
if (!isset($grouped[$typeId])) {
$grouped[$typeId] = array(
'id_room_type' => $typeId,
'name' => $row['room_type_name'],
'rooms' => array(),
);
}
$grouped[$typeId]['rooms'][] = array(
'id_room' => (int) $row['id_room'],
'name' => $row['room_name'],
);
}
return $grouped;
}
public static function getTotalConnectedRooms($idRoom = 0, $idRoomConnected = 0)
{
$idRoom = (int) $idRoom;
$idRoomConnected = (int) $idRoomConnected;
if ($idRoom <= 0 && $idRoomConnected > 0) {
$sql = 'SELECT DISTINCT id_room
FROM `' . _DB_PREFIX_ . 'htl_connected_room`
WHERE id_room_connected = ' . $idRoomConnected;
$results = Db::getInstance()->executeS($sql);
if ($results === false) {
return array();
}
return array_column($results, 'id_room');
}
$sql = 'SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'htl_connected_room` hcr
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` hri
ON hri.id = hcr.id_room_connected
WHERE hcr.id_room = ' . $idRoom;
return (int) Db::getInstance()->getValue($sql);
}
}

View File

@@ -262,7 +262,7 @@ class HotelOrderRefundRules extends ObjectModel
ON (horr.`id_refund_rule` = hbrr.`id_refund_rule`)
LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` horrl
ON (horrl.`id_refund_rule` = horr.`id_refund_rule` AND horrl.`id_lang` = '.(int) $idLang.')
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
ON (hbd.`id_hotel` = hbrr.`id_hotel` AND hbd.`id_order` = '.(int) $idOrder.')
WHERE horr.`days` <= '.(int) $days.'
GROUP BY hbrr.`id_refund_rule`

View File

@@ -569,6 +569,17 @@ class HotelReservationSystemDb
SELECT 5, `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`;",
"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,
`id_room_connected` int(11) NOT NULL,
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_connected_room`),
UNIQUE KEY `uniq_room_connection` (`id_room`, `id_room_connected`),
KEY `idx_id_room` (`id_room`),
KEY `idx_id_room_connected` (`id_room_connected`)
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
);
}
@@ -634,7 +645,8 @@ class HotelReservationSystemDb
`'._DB_PREFIX_.'htl_room_type_bed_type`,
`'._DB_PREFIX_.'htl_access`,
`'._DB_PREFIX_.'htl_settings_link`,
`'._DB_PREFIX_.'htl_settings_link_lang`'
`'._DB_PREFIX_.'htl_settings_link_lang`,
`'._DB_PREFIX_.'htl_connected_room`'
);
}
}

View File

@@ -386,6 +386,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
'link' => $this->context->link,
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
'htl_connected_rooms' => HotelConnectedRoom::getConnectedRooms(null, null, $this->id_hotel, $this->context->language->id),
));
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
@@ -1035,6 +1036,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
// add fullcalender plugin
$this->addJqueryUI('ui.tooltip', 'base', true);
$this->removeJS(Media::getJqueryUIPath('effects.core', 'base', false), false);
$this->addCSS(array(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css'));
$this->addCSS(_PS_JS_DIR_.'fullcalendar/main.css');
$this->addJs(_PS_JS_DIR_.'fullcalendar/main.js');

View File

@@ -50,6 +50,7 @@ require_once 'classes/HotelRoomDisableDates.php';
require_once 'classes/HotelBranchRefundRules.php';
require_once 'classes/HotelBedType.php';
require_once 'classes/HotelRoomTypeBedType.php';
require_once 'classes/HotelConnectedRoom.php';
// linked products
require_once 'classes/RoomTypeServiceProduct.php';

View File

@@ -577,36 +577,6 @@ p.room_cat_data
.fc-today-button:disabled {
display: none;
}
/* book now page tooltip */
.tooltip_cont {
min-width: 280px;
width: 100%;
font-size: 14px;
font-weight: 600;
/* display: grid; */
}
.tooltip_cont .tip_header {
margin-bottom: 10px;
}
.tooltip_cont .tip-body > div {
margin-bottom: 6px;
}
.tip_element_head {
font-size: 12px;
}
.tip_element_value {
font-size: 16px;
opacity: 0.6;
}
.tip-body {
display: grid;
grid-template-columns: auto auto;
}
body.adminhotelroomsbooking .ui-tooltip {
border: unset;
padding: 10px;
box-shadow: 0px 0px 15px 0px #00000026;
}
#room-reallocation-modal .modal-footer {
padding: 15px 0px 0px 0px

View File

@@ -40,7 +40,12 @@
<tbody>
{foreach from=$book_v['data']['available'] key=avai_k item=avai_v}
<tr>
<td>{$avai_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$avai_v type='available'}</td>
<td>{$avai_v['room_num']|escape:'htmlall':'UTF-8'}
{if isset($htl_connected_rooms[$avai_v['id_room']]) && $htl_connected_rooms[$avai_v['id_room']]|@count > 0}
{include file="controllers/products/connected-rooms.tpl" htl_connected_rooms=$htl_connected_rooms[$avai_v['id_room']]}
{/if}
{hook h='displayRoomNumAfter' data=$avai_v type='available'}</td>
{assign var="is_full_date" value=($show_full_date && ($date_from|date_format:'%D' == $date_to|date_format:'%D'))}
<td>{dateFormat date=$date_from full=$is_full_date} - {dateFormat date=$date_to full=$is_full_date}</td>
<td>{$avai_v['room_comment']|escape:'htmlall':'UTF-8'}</td>
@@ -132,7 +137,11 @@
<p>{dateFormat date=$part_v['date_from'] full=$is_full_date} - {dateFormat date=$part_v['date_to'] full=$is_full_date}</p>
</td>
{/if}
<td >{$sub_part_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$sub_part_v type='partially_available'}</td>
<td >{$sub_part_v['room_num']|escape:'htmlall':'UTF-8'}
{if isset($htl_connected_rooms[$sub_part_v['id_room']]) && $htl_connected_rooms[$sub_part_v['id_room']]|@count > 0}
{include file="controllers/products/connected-rooms.tpl" htl_connected_rooms=$htl_connected_rooms[$sub_part_v['id_room']]}
{/if}
{hook h='displayRoomNumAfter' data=$sub_part_v type='partially_available'}</td>
<td>
{foreach $allotment_types as $allotment_type}
<label class="control-label">
@@ -217,7 +226,11 @@
<tr>
{assign var="is_full_date" value=($show_full_date && ($rm_dtl_v['date_from']|date_format:'%D' == $rm_dtl_v['date_to']|date_format:'%D'))}
{if $rm_dtl_v@first}
<td rowspan="{$booked_v['detail']|count}">{$booked_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$booked_v key=$rm_dtl_k type='booked'}</td>
<td rowspan="{$booked_v['detail']|count}">{$booked_v['room_num']|escape:'htmlall':'UTF-8'}
{if isset($htl_connected_rooms[$booked_v['id_room']]) && $htl_connected_rooms[$booked_v['id_room']]|@count > 0}
{include file="controllers/products/connected-rooms.tpl" htl_connected_rooms=$htl_connected_rooms[$booked_v['id_room']]}
{/if}
{hook h='displayRoomNumAfter' data=$booked_v key=$rm_dtl_k type='booked'}</td>
{/if}
<td>{dateFormat date=$rm_dtl_v['date_from'] full=$is_full_date} - {dateFormat date=$rm_dtl_v['date_to'] full=$is_full_date}</td>
<td><a href="{$link->getAdminLink('AdminOrders')}&id_order={$rm_dtl_v['id_order']|intval}&vieworder" target="_blank">#{$rm_dtl_v['id_order']}</a></td>
@@ -257,7 +270,11 @@
{foreach from=$unavai_v['detail'] key=rm_dtl_k item=unavail_dtl_v}
<tr>
{if $unavail_dtl_v@first}
<td rowspan="{$unavai_v['detail']|count}">{$unavai_v['room_num']|escape:'htmlall':'UTF-8'}</td>
<td rowspan="{$unavai_v['detail']|count}">{$unavai_v['room_num']|escape:'htmlall':'UTF-8'}
{if isset($htl_connected_rooms[$unavai_v['id_room']]) && $htl_connected_rooms[$unavai_v['id_room']]|@count > 0}
{include file="controllers/products/connected-rooms.tpl" htl_connected_rooms=$htl_connected_rooms[$unavai_v['id_room']]}
{/if}
</td>
{/if}
<td>{HotelRoomInformation::getRoomStatusTitle($unavail_dtl_v['id_status'])|escape:'htmlall':'UTF-8'}</td>
<td>

View File

@@ -290,9 +290,13 @@ class QhrHotelReview extends ObjectModel
public function saveReviewImages()
{
$files = QhrHotelReviewHelper::fileAttachmentMultiple('images');
$allowedExtensions = array('jpg', 'png', 'jpeg',);
if (is_array($files) && count($files)) {
foreach ($files as $key => $file) {
$ext = pathinfo($file['rename'], PATHINFO_EXTENSION);
if (!in_array($ext, $allowedExtensions, true)) {
continue;
}
$dir = _PS_MODULE_DIR_.'qlohotelreview/views/img/review/'.Image::getImgFolderStatic($this->id);
QhrHotelReviewHelper::createDirectory($dir);
$useSameExt = false;

View File

@@ -85,6 +85,17 @@ class QloHotelReviewDefaultModuleFrontController extends ModuleFrontController
}
}
if (is_array($_FILES) && array_key_exists('images', $_FILES) ) {
$allowedExtensions = array('jpg', 'png', 'jpeg',);
foreach ($_FILES['images']['name'] as $key => $imageName) {
$extension = Tools::strtolower(pathinfo($imageName, PATHINFO_EXTENSION));
if (!in_array($extension, $allowedExtensions)) {
$errors['general'][] = $objModule->l('Only images with the following extensions are allowed: jpg, jpeg, png','default');
}
}
}
if (!count($errors['by_key']) && !count($errors['general'])) {
$customerReview = QhrHotelReview::getByCustomer(
$objOrder->id_customer,

View File

@@ -182,6 +182,7 @@ class QloHotelReview extends Module
$this->l('You can upload a maximum of %d images.', false, true),
(int) Configuration::get('QHR_MAX_IMAGES_PER_REVIEW')
),
'allowed_extensions' => $this->l('Only images with the following extensions are allowed: jpg, jpeg, png', false, true),
),
)));

View File

@@ -52,6 +52,10 @@
margin-bottom: 14px;
}
#add-review-popup .hint {
margin-top: 6px;
}
#add-review-popup .review-error {
margin-top: 2px;
color: #E85757;

View File

@@ -132,6 +132,29 @@ var QhrReviewImages = {
init: function() {
QhrReviewImages.inputHtml = '<input type="file" accept="image/*" class="input-images hidden" name="images[]" multiple>';
},
validateFiles: function () {
$('#review-general-errors').hide();
let isValid = true;
$('.images-field input.input-images').each(function (iInput, input) {
let files = input.files;
let dataTransfer = new DataTransfer();
$.each(files, function (iFile, file) {
if (file.type.startsWith('image/')) {
dataTransfer.items.add(file);
} else {
isValid = false;
}
});
input.files = dataTransfer.files;
if (!input.files.length) {
$(input).remove();
}
});
if (!isValid) {
QhrReviewForm.showGeneralErrors(qlo_hotel_review_js_vars.texts.allowed_extensions);
}
return isValid;
},
getFilesCount: function() {
var count = 0;
$('.images-field input.input-images').each(function(i, input) {
@@ -156,6 +179,9 @@ var QhrReviewImages = {
}
});
input.files = dataTransfer.files;
if (input.files.length === 0) {
$(input).remove();
}
},
resetPreviews: function() {
$('.previews-wrap').html('');
@@ -241,8 +267,9 @@ $(document).on('change', 'input.input-images', function(e) {
var filesCount = QhrReviewImages.getFilesCount();
if (filesCount > qlo_hotel_review_js_vars.num_images_max) {
QhrReviewImages.removeLastInput();
alert(qlo_hotel_review_js_vars.texts.num_files);
QhrReviewForm.showGeneralErrors(qlo_hotel_review_js_vars.texts.num_files);
} else {
QhrReviewImages.validateFiles();
QhrReviewImages.updatePreviews();
if (filesCount == qlo_hotel_review_js_vars.num_images_max) {

View File

@@ -40,6 +40,7 @@
<div class="image-input-btn">
<img class="img-camera-plus">
</div>
<p class="hint">{l s='Allowed formats are: .jpg, .jpeg, .png' mod='qlohotelreview'}</p>
<div class="previews-wrap"></div>
</div>