ui and database changes
This commit is contained in:
@@ -1930,7 +1930,7 @@
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//connected modal
|
||||
//connected modal
|
||||
$(document).on('click', '.connectedRoomModal', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1966,8 +1966,10 @@
|
||||
});
|
||||
if (roomNum) {
|
||||
roomNum = '( ' + roomNoText + ' ' + roomNum + ')';
|
||||
$('#connectedRoomModal').attr('data-room-num-title', roomNum);
|
||||
$('#connected_room_title').html(roomNum);
|
||||
} else {
|
||||
$('#connectedRoomModal').attr('data-room-num-title', '');
|
||||
$('#connected_room_title').html('');
|
||||
}
|
||||
} else {
|
||||
@@ -1978,6 +1980,7 @@
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function filterRoomsByType($row) {
|
||||
var selectedType = $row.find('.connect-room-type').val();
|
||||
var $roomSelect = $row.find('.connect-room');
|
||||
@@ -1998,6 +2001,7 @@
|
||||
$roomSelect.val('');
|
||||
}
|
||||
}
|
||||
|
||||
function addConnectedRoomRow() {
|
||||
var $template = $('#connected_room_add_template');
|
||||
if (!$template.length) {
|
||||
@@ -2020,16 +2024,23 @@
|
||||
$tbody.append($newRow);
|
||||
filterRoomsByType($newRow);
|
||||
if ($addButton.length) {
|
||||
$addButton.prop('disabled', true).hide();
|
||||
$addButton.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
$(document).on('click', '#add_connected_room_row', function() {
|
||||
addConnectedRoomRow();
|
||||
});
|
||||
$(document).on('change', '.connect-room-type', function() {
|
||||
}); $(document).on('click', '.remove-connected-room-row', function() {
|
||||
var $row = $(this).closest('tr');
|
||||
$('#add_connected_room_row').prop('disabled', false);
|
||||
$row.remove();
|
||||
if (!$('#connected_rooms_tbody').find('.connected-room-row').length && !$('#connected_rooms_tbody')
|
||||
.find('.connected-room-add-row').not('#connected_room_add_template').length) {
|
||||
$('#connected_rooms_table_wrapper').addClass('hide');
|
||||
$('#connected_rooms_empty_state').removeClass('hide').show();
|
||||
}
|
||||
}); $(document).on('change', '.connect-room-type', function() {
|
||||
filterRoomsByType($(this).closest('tr'));
|
||||
});
|
||||
$(document).on('shown.bs.modal', '#connectedRoomModal', function() {
|
||||
}); $(document).on('shown.bs.modal', '#connectedRoomModal', function() {
|
||||
var $row = $(this).find('.connected-room-add-row').not('#connected_room_add_template').first();
|
||||
if ($row.length) {
|
||||
filterRoomsByType($row);
|
||||
@@ -2065,9 +2076,13 @@
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showSuccessMessage(response.message);
|
||||
$('#connectedRoomModal .modal-content').replaceWith($(response.html).find('.modal-content'));
|
||||
$('#connectedRoomModal .modal-content').replaceWith($(response.html).find(
|
||||
'.modal-content'));
|
||||
$('#connected_room_title').html($('#connectedRoomModal').attr(
|
||||
'data-room-num-title'));
|
||||
// update connected rooms count badge in list
|
||||
var $icon = $('.connectedRoomModal[data-id-room="' + mainRoomId + '"]').find('.connected-room-count');
|
||||
var $icon = $('.connectedRoomModal[data-id-room="' + mainRoomId + '"]')
|
||||
.find('.connected-room-count');
|
||||
if ($icon.length) {
|
||||
var currentCount = parseInt($.trim($icon.text()), 10);
|
||||
if (isNaN(currentCount)) {
|
||||
@@ -2075,6 +2090,10 @@
|
||||
}
|
||||
$icon.text(currentCount + 1);
|
||||
}
|
||||
if (response.details) {
|
||||
$('.connectedRoomModal[data-id-room="' + mainRoomId + '"]').data(
|
||||
'connected-details', response.details);
|
||||
}
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
@@ -2087,7 +2106,7 @@
|
||||
//remove connected room
|
||||
$(document).on('click', '.delete-connected-room', function() {
|
||||
var $row = $(this).closest('tr');
|
||||
var roomId = $(this).data('room-id');
|
||||
var mainRoomId = $('#connected_room_main_id').val();
|
||||
var connectedRoomId = $(this).data('connected-room-id');
|
||||
var connectedId = $(this).data('connected-id');
|
||||
var hotelId = $(this).data('hotel-id');
|
||||
@@ -2100,7 +2119,7 @@
|
||||
ajax: true,
|
||||
action: 'ManageConnectedRoom',
|
||||
mode: 'delete',
|
||||
room_id: roomId,
|
||||
room_id: mainRoomId,
|
||||
connected_room_id: connectedRoomId,
|
||||
connected_id: connectedId,
|
||||
hotel_id: hotelId,
|
||||
@@ -2110,7 +2129,10 @@
|
||||
if (response.success) {
|
||||
showSuccessMessage(response.message);
|
||||
if (response.html) {
|
||||
$('#connectedRoomModal .modal-content').replaceWith($(response.html).find('.modal-content'));
|
||||
$('#connectedRoomModal .modal-content').replaceWith($(response.html)
|
||||
.find('.modal-content'));
|
||||
$('#connected_room_title').html($('#connectedRoomModal').attr(
|
||||
'data-room-num-title'));
|
||||
} else {
|
||||
$row.remove();
|
||||
var $modal = $('#connectedRoomModal');
|
||||
@@ -2118,11 +2140,14 @@
|
||||
var hasConnectedRows = $tbody.find('.connected-room-row').length > 0;
|
||||
if (!hasConnectedRows) {
|
||||
$modal.find('#connected_rooms_table_wrapper').addClass('hide');
|
||||
$modal.find('#connected_rooms_empty_state').removeClass('hide').show();
|
||||
$modal.find('#connected_rooms_empty_state').removeClass('hide')
|
||||
.show();
|
||||
}
|
||||
}
|
||||
// update connected rooms count badge in list
|
||||
var $icon = $('.connectedRoomModal[data-id-room="' + roomId + '"]').find('.connected-room-count');
|
||||
var $icon = $('.connectedRoomModal[data-id-room="' + mainRoomId + '"]')
|
||||
.find(
|
||||
'.connected-room-count');
|
||||
if ($icon.length) {
|
||||
var currentCount = parseInt($.trim($icon.text()), 10);
|
||||
if (isNaN(currentCount)) {
|
||||
@@ -2130,6 +2155,10 @@
|
||||
}
|
||||
$icon.text(Math.max(0, currentCount - 1));
|
||||
}
|
||||
if (response.details) {
|
||||
$('.connectedRoomModal[data-id-room="' + mainRoomId + '"]').data(
|
||||
'connected-details', response.details);
|
||||
}
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
|
||||
@@ -20,59 +20,84 @@
|
||||
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
|
||||
*}
|
||||
{if isset($htl_connected_rooms) && $htl_connected_rooms|@count > 0}
|
||||
{assign var=connectedRoomsCount value=0}
|
||||
{foreach from=$htl_connected_rooms item=rooms_by_type}
|
||||
{assign var=connectedRoomsCount value=$connectedRoomsCount+$rooms_by_type|@count}
|
||||
{/foreach}
|
||||
<span class="qlo-tooltip-wrapper connected-room-popup-wrapper">
|
||||
<span class="connected-room-tooltip-trigger"
|
||||
data-connected-details='{json_encode($htl_connected_rooms)|escape:'html':'UTF-8'}'>
|
||||
<i class="icon-random connected-room-icon"></i>
|
||||
<div class="qlo-tooltip connected-room-popup{if $htl_connected_rooms|@count == 1} single-col{/if}">
|
||||
<div class="qlo_tooltip_content">
|
||||
<div class="qlo_tooltip_cont">
|
||||
<div class="qlo_header">
|
||||
<div class="qlo_heading">{l s='Connected Rooms'}</div>
|
||||
</div>
|
||||
<div class="qlo_body grid{if $htl_connected_rooms|@count == 1} single-col{/if}">
|
||||
{foreach from=$htl_connected_rooms key=conn_type item=rooms_by_type}
|
||||
<div class="qlo_element">
|
||||
<div class="qlo_element_heading">{$conn_type|escape:'html':'UTF-8'}</div>
|
||||
<div class="qlo_element_value">
|
||||
<ul class="connected-room-list qlo_tooltip_list">
|
||||
{foreach from=$rooms_by_type item=room}
|
||||
<li>{$room.connected_room_num|escape:'html':'UTF-8'}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</span>
|
||||
{/if}
|
||||
<style>
|
||||
.connected-room-icon {
|
||||
color: #008abd;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var wrappers = document.querySelectorAll('.qlo-tooltip-wrapper');
|
||||
wrappers.forEach(function(wrapper) {
|
||||
wrapper.addEventListener('mouseenter', function() {
|
||||
var popup = wrapper.querySelector('.connected-room-popup');
|
||||
if (!popup) {
|
||||
return;
|
||||
}
|
||||
popup.classList.remove('align-right', 'align-left');
|
||||
var rect = popup.getBoundingClientRect();
|
||||
if (rect.right > window.innerWidth) {
|
||||
popup.classList.add('align-right');
|
||||
} else if (rect.left < 0) {
|
||||
popup.classList.add('align-left');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).ready(function() {
|
||||
{literal}
|
||||
if (typeof $.fn.tooltip !== 'undefined' && typeof $.ui !== 'undefined' && typeof $.ui.tooltip !==
|
||||
'undefined') {
|
||||
$('.connected-room-tooltip-trigger').tooltip({
|
||||
items: '.connected-room-tooltip-trigger',
|
||||
content: function() {
|
||||
var details = $(this).data('connected-details');
|
||||
if (!details || Object.keys(details).length === 0) {
|
||||
return "{/literal}{l s='No rooms connected' js=1}{literal}";
|
||||
}
|
||||
var html = '<div class="tooltip_cont">';
|
||||
html += '<div class="tip_header"><div class="tip_date">{/literal}{l s="Connected Rooms" js=1}{literal}</div></div>';
|
||||
html += '<div class="tip-body">';
|
||||
for (var type in details) {
|
||||
html += '<div>';
|
||||
html += '<div class="tip_element_head">' + type + '</div>';
|
||||
html += '<div class="tip_element_value">';
|
||||
var rooms = details[type];
|
||||
for (var i = 0; i < rooms.length; i++) {
|
||||
html += rooms[i].connected_room_num + (i < rooms.length - 1 ? ', ' :
|
||||
'');
|
||||
}
|
||||
html += '</div></div>';
|
||||
}
|
||||
html += '</div></div>';
|
||||
return html;
|
||||
},
|
||||
position: {
|
||||
my: "center bottom-10",
|
||||
at: "center top",
|
||||
collision: "flipfit"
|
||||
}
|
||||
});
|
||||
}
|
||||
{/literal}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
@@ -24,17 +24,22 @@
|
||||
#connectedRoomModal .connected-rooms-table {
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#connectedRoomModal .modal-title .disable_dates_title {
|
||||
display: inline-block;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#connectedRoomModal .modal-title .connected_room_num {
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#connectedRoomModal .modal-title {
|
||||
line-height: 2;
|
||||
}
|
||||
|
||||
#connectedRoomModal .modal-title .close {
|
||||
line-height: 2;
|
||||
}
|
||||
@@ -46,7 +51,8 @@
|
||||
<div class="modal-title">
|
||||
<div class="row">
|
||||
<div class="disable_dates_title">
|
||||
<i class="icon-random"></i> {l s='Connected Rooms'} <span id="connected_room_title" class="connected_room_num"></span>
|
||||
<i class="icon-random"></i> {l s='Connected Rooms'} <span id="connected_room_title"
|
||||
class="connected_room_num"></span>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
@@ -61,64 +67,67 @@
|
||||
<input type="hidden" id="connected_room_main_id" name="main_room_id" value="{$main_room_id|intval}">
|
||||
<!-- connectedrooms list -->
|
||||
<div class="">
|
||||
<div class="panel">
|
||||
<div class="">
|
||||
<div id="connected_rooms_list">
|
||||
<div id="connected_rooms_table_wrapper" class="{if !isset($htl_connected_rooms) || $htl_connected_rooms|count == 0}hide{/if}">
|
||||
<div id="connected_rooms_table_wrapper"
|
||||
class="{if !isset($htl_connected_rooms) || $htl_connected_rooms|count == 0}hide{/if}">
|
||||
<table class="table table-bordered table-striped connected-rooms-table">
|
||||
<colgroup>
|
||||
<col style="width: 45%;">
|
||||
<col style="width: 35%;">
|
||||
<col style="width: 120px;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{l s='Room Type'}</th>
|
||||
<th>{l s='Room'}</th>
|
||||
<th width="120" class="text-center">
|
||||
{l s='Action'}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="connected_rooms_tbody">
|
||||
{if isset($htl_connected_rooms) && $htl_connected_rooms|count > 0}
|
||||
{foreach from=$htl_connected_rooms item=hotelRooms}
|
||||
{foreach from=$hotelRooms key=roomType item=rooms}
|
||||
{foreach from=$rooms item=row}
|
||||
<tr class="connected-room-row">
|
||||
<td>{$row.connected_room_type|escape:'html':'UTF-8'}</td>
|
||||
<td>{$row.connected_room_num|escape:'html':'UTF-8'}</td>
|
||||
<td class="text-center">
|
||||
<a href="javascript:void(0);" class="delete-connected-room btn btn-default"
|
||||
data-connected-id="{$row.id_connected_room|intval}"
|
||||
data-room-id="{$row.id_room_information|intval}"
|
||||
data-connected-room-id="{$row.id_room|intval}"
|
||||
data-hotel-id="{$row.id_hotel|intval}" title="{l s='Remove'}">
|
||||
<i class="icon-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<colgroup>
|
||||
<col style="width: 45%;">
|
||||
<col style="width: 35%;">
|
||||
<col style="width: 120px;">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{l s='Room Type'}</th>
|
||||
<th>{l s='Room'}</th>
|
||||
<th width="120" class="text-center">
|
||||
{l s='Action'}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="connected_rooms_tbody">
|
||||
{if isset($htl_connected_rooms) && $htl_connected_rooms|count > 0}
|
||||
{foreach from=$htl_connected_rooms item=hotelRooms}
|
||||
{foreach from=$hotelRooms key=roomType item=rooms}
|
||||
{foreach from=$rooms item=row}
|
||||
<tr class="connected-room-row">
|
||||
<td>{$row.connected_room_type|escape:'html':'UTF-8'}</td>
|
||||
<td>{$row.connected_room_num|escape:'html':'UTF-8'}</td>
|
||||
<td class="text-center">
|
||||
<a href="javascript:void(0);"
|
||||
class="delete-connected-room btn btn-default"
|
||||
data-connected-id="{$row.id_connected_room|intval}"
|
||||
data-room-id="{$row.id_room_information|intval}"
|
||||
data-connected-room-id="{$row.id_room|intval}"
|
||||
data-hotel-id="{$row.id_hotel|intval}" title="{l s='Remove'}">
|
||||
<i class="icon-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
{/if}
|
||||
</tbody>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="list-empty {if isset($htl_connected_rooms) && $htl_connected_rooms|count > 0}hide{/if}" id="connected_rooms_empty_state">
|
||||
<div class="list-empty-msg">
|
||||
<i class="icon-warning-sign list-empty-icon"></i>
|
||||
{l s='No connected rooms.'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if isset($htl_not_connected_rooms) && $htl_not_connected_rooms|count > 0}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-12">
|
||||
<button type="button" id="add_connected_room_row" class="btn btn-default">
|
||||
<i class="icon-plus"></i> {l s='Add Room'}
|
||||
</button>
|
||||
<div class="list-empty {if isset($htl_connected_rooms) && $htl_connected_rooms|count > 0}hide{/if}"
|
||||
id="connected_rooms_empty_state">
|
||||
<div class="list-empty-msg">
|
||||
<i class="icon-warning-sign list-empty-icon"></i>
|
||||
{l s='No connected rooms.'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if isset($htl_not_connected_rooms) && $htl_not_connected_rooms|count > 0}
|
||||
|
||||
|
||||
<button type="button" id="add_connected_room_row" class="btn btn-default">
|
||||
<i class="icon-plus"></i> {l s='Add Connected Room'}
|
||||
</button>
|
||||
|
||||
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -143,15 +152,20 @@
|
||||
<td>
|
||||
<select class="form-control connect-room" name="connect_room">
|
||||
{foreach from=$htl_not_connected_rooms item=room}
|
||||
<option value="{$room.id|intval}" class="room-option" data-type="{$room.id_product|intval}">
|
||||
<option value="{$room.id|intval}" class="room-option"
|
||||
data-type="{$room.id_product|intval}">
|
||||
{$room.room_num|escape:'html':'UTF-8'}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<button type="button" class="btn btn-default remove-connected-room-row"
|
||||
title="{l s='Remove'}">
|
||||
<i class="icon-trash"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary save-connected-room">
|
||||
<i class="icon-plus"></i> {l s='Add'}
|
||||
{l s='Add'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -170,4 +184,4 @@
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="hotel_id" value="{$hotel_id|intval}">
|
||||
</div>
|
||||
</div>
|
||||
@@ -3484,15 +3484,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order_detail_data[$key]['amt_with_qty_tax_incl'] = $value['total_price_tax_incl'];
|
||||
$order_detail_data[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']);
|
||||
$order_detail_data[$key]['total_room_tax'] = $order_detail_data[$key]['total_room_price_ti'] - $order_detail_data[$key]['total_room_price_te'];
|
||||
$order_detail_data[$key]['connected_rooms'] = array();
|
||||
if (class_exists('HotelRoomConnected')) {
|
||||
$order_detail_data[$key]['connected_rooms'] = HotelRoomConnected::getConnectedRoomsByHotel(
|
||||
(int) $value['id_hotel'],
|
||||
(int) Context::getContext()->language->id,
|
||||
(int) $value['id_room'],
|
||||
true
|
||||
);
|
||||
}
|
||||
$order_detail_data[$key]['connected_rooms'] = HotelConnectedRoom::getConnectedRooms((int) Context::getContext()->language->id, (int) $value['id_room'], true);
|
||||
|
||||
if (isset($value['refund_info'])
|
||||
&& $value['refund_info']['refunded']
|
||||
|
||||
@@ -3090,6 +3090,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$disableDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
|
||||
$room['disable_dates_json'] = json_encode($disableDates);
|
||||
}
|
||||
$room['connected_rooms_count'] = HotelConnectedRoom::getConnectedRooms($this->context->language->id, $room['id'], true,true);
|
||||
}
|
||||
|
||||
$data->assign('htl_room_info', $hotelRoomInfo);
|
||||
@@ -5647,15 +5648,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
protected function getConnectedRoomsModalHtml($hotelId, $roomId, $currentRoomType)
|
||||
protected function getConnectedRoomsModalHtml($roomId, $currentRoomType)
|
||||
{
|
||||
$connectedRooms = HotelRoomConnected::getConnectedRoomsByHotel($hotelId, $this->context->language->id, $roomId, true);
|
||||
$notConnectedRooms = HotelRoomConnected::getConnectedRoomsByHotel($hotelId, $this->context->language->id, $roomId, false);
|
||||
$connectedRooms = HotelConnectedRoom::getConnectedRooms($this->context->language->id, $roomId, true);
|
||||
$notConnectedRooms = HotelConnectedRoom::getConnectedRooms($this->context->language->id, $roomId, false);
|
||||
$this->context->smarty->assign(array(
|
||||
'htl_connected_rooms' => $connectedRooms,
|
||||
'htl_not_connected_rooms' => $notConnectedRooms,
|
||||
'main_room_id' => (int) $roomId,
|
||||
'hotel_id' => (int) $hotelId,
|
||||
'current_roomtype' => (int) $currentRoomType,
|
||||
));
|
||||
|
||||
@@ -5664,38 +5664,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessGetModalConnectedRooms()
|
||||
{
|
||||
if ($this->tabAccess['edit'] !== 1) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Permission denied.')
|
||||
]));
|
||||
}
|
||||
|
||||
$roomId = (int) Tools::getValue('room_id');
|
||||
$hotelId = (int) Tools::getValue('hotel_id');
|
||||
if (!$roomId || !$hotelId) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Invalid data.')
|
||||
]));
|
||||
}
|
||||
|
||||
if (!class_exists('HotelRoomConnected') || !HotelRoomConnected::isConnectedRoomTableAvailable()) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Connected rooms feature is not available. Please upgrade the Hotel Reservation System module.')
|
||||
]));
|
||||
}
|
||||
|
||||
$mainRoomHotelId = HotelRoomConnected::getRoomHotelId($roomId);
|
||||
if ($mainRoomHotelId !== (int) $hotelId) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Invalid room data.')
|
||||
]));
|
||||
}
|
||||
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($hotelId, $roomId, (int) Tools::getValue('current_roomtype'));
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($roomId, (int) Tools::getValue('current_roomtype'));
|
||||
die(json_encode([
|
||||
'success' => true,
|
||||
'html' => $modalContent
|
||||
@@ -5704,66 +5674,18 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessManageConnectedRoom()
|
||||
{
|
||||
if ($this->tabAccess['edit'] !== 1) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Permission denied.')
|
||||
]));
|
||||
}
|
||||
|
||||
$mode = Tools::getValue('mode');
|
||||
$roomId = (int) Tools::getValue('room_id');
|
||||
$connectedRoomId = (int) Tools::getValue('connected_room_id');
|
||||
$connectedId = (int) Tools::getValue('connected_id');
|
||||
$hotelId = (int) Tools::getValue('hotel_id');
|
||||
if (!$roomId || !$connectedRoomId) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Invalid room data.')
|
||||
]));
|
||||
}
|
||||
|
||||
if (!class_exists('HotelRoomConnected') || !HotelRoomConnected::isConnectedRoomTableAvailable()) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Connected rooms feature is not available. Please upgrade the Hotel Reservation System module.')
|
||||
]));
|
||||
}
|
||||
|
||||
if ($roomId == $connectedRoomId) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('You cannot connect a room to itself.')
|
||||
]));
|
||||
}
|
||||
|
||||
$mainRoomHotelId = HotelRoomConnected::getRoomHotelId($roomId);
|
||||
$connectedRoomHotelId = HotelRoomConnected::getRoomHotelId($connectedRoomId);
|
||||
if (!$hotelId || $mainRoomHotelId !== $hotelId || $connectedRoomHotelId !== $hotelId) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Invalid room data.')
|
||||
]));
|
||||
}
|
||||
|
||||
$currentRoomType = (int) Tools::getValue('current_roomtype');
|
||||
|
||||
if ($mode === 'add') {
|
||||
$existingConnectedId = HotelRoomConnected::getExistingConnectedRoomId($roomId, $connectedRoomId);
|
||||
if ($existingConnectedId) {
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($hotelId, $roomId, $currentRoomType);
|
||||
die(json_encode([
|
||||
'html' => $modalContent,
|
||||
'success' => true,
|
||||
'message' => $this->l('Room is already connected.')
|
||||
]));
|
||||
}
|
||||
|
||||
$connection = new HotelRoomConnected();
|
||||
$connection->id_room_information = $roomId;
|
||||
$connection->id_room = $connectedRoomId;
|
||||
$connection = new HotelConnectedRoom();
|
||||
$connection->id_room = $roomId;
|
||||
$connection->id_room_connected = $connectedRoomId;
|
||||
if ($connection->add()) {
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($hotelId, $roomId, $currentRoomType);
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($roomId, $currentRoomType);
|
||||
die(json_encode([
|
||||
'html' => $modalContent,
|
||||
'success' => true,
|
||||
@@ -5785,16 +5707,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
]));
|
||||
}
|
||||
|
||||
if (!HotelRoomConnected::isConnectionMatch($connectedId, $roomId, $connectedRoomId)) {
|
||||
die(json_encode([
|
||||
'success' => false,
|
||||
'message' => $this->l('Invalid data.')
|
||||
]));
|
||||
}
|
||||
|
||||
$objHotelRoomConnected = new HotelRoomConnected($connectedId);
|
||||
$objHotelRoomConnected = new HotelConnectedRoom($connectedId);
|
||||
if ($objHotelRoomConnected->delete()) {
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($hotelId, $roomId, $currentRoomType);
|
||||
$modalContent = $this->getConnectedRoomsModalHtml($roomId, $currentRoomType);
|
||||
die(json_encode([
|
||||
'success' => true,
|
||||
'html' => $modalContent,
|
||||
|
||||
@@ -1331,7 +1331,7 @@ class HotelCartBookingData extends ObjectModel
|
||||
);
|
||||
|
||||
$cart_detail_data[$key]['amt_with_qty'] = $roomTypeDateRangePrice['total_price_tax_excl'];
|
||||
$cart_detail_data[$key]['connected_rooms'] = HotelRoomConnected::getConnectedRoomsByHotel($obj_htl_room_info->id_hotel, Context::getContext()->language->id, $obj_htl_room_info->id, true);
|
||||
$cart_detail_data[$key]['connected_rooms'] = HotelConnectedRoom::getConnectedRooms(Context::getContext()->language->id, $obj_htl_room_info->id, true);
|
||||
}
|
||||
}
|
||||
if ($cart_detail_data) {
|
||||
|
||||
100
modules/hotelreservationsystem/classes/HotelConnectedRoom.php
Normal file
100
modules/hotelreservationsystem/classes/HotelConnectedRoom.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?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($idLang, $roomId = null, $isConnected = true ,$count = false)
|
||||
{
|
||||
$idLang = (int) $idLang;
|
||||
$roomId = (int) $roomId;
|
||||
$objHotelRoomInformation = new HotelRoomInformation($roomId);
|
||||
$hotelId = $objHotelRoomInformation->id_hotel;
|
||||
|
||||
if ($isConnected) {
|
||||
$sql = 'SELECT
|
||||
hcr.id_connected_room, hcr.id_room AS id_room_information, hcr.id_room_connected AS id_room, main_room.id_hotel, main_room.room_num AS main_room_num, connected_room.room_num AS connected_room_num,
|
||||
main_pl.name AS main_room_type, conn_pl.name AS connected_room_type
|
||||
FROM `' . _DB_PREFIX_ . 'htl_connected_room` hcr
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` main_room ON main_room.id = hcr.id_room
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` connected_room ON connected_room.id = hcr.id_room_connected
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` main_pl ON (main_pl.id_product = main_room.id_product AND main_pl.id_lang = ' . (int) $idLang . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` conn_pl ON (conn_pl.id_product = connected_room.id_product AND conn_pl.id_lang = ' . (int) $idLang . ')
|
||||
WHERE main_room.id_hotel = ' . (int) $hotelId . '
|
||||
AND connected_room.id_hotel = ' . (int) $hotelId;
|
||||
if ($roomId > 0) {
|
||||
$sql .= ' AND main_room.id = ' . (int) $roomId;
|
||||
}
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
if ($results === false) {
|
||||
return array();
|
||||
}
|
||||
$grouped = array();
|
||||
foreach ($results as $row) {
|
||||
$mainRoomId = (int) $row['id_room_information'];
|
||||
$connType = (string) $row['connected_room_type'];
|
||||
if (!isset($grouped[$mainRoomId])) {
|
||||
$grouped[$mainRoomId] = array();
|
||||
}
|
||||
if (!isset($grouped[$mainRoomId][$connType])) {
|
||||
$grouped[$mainRoomId][$connType] = array();
|
||||
}
|
||||
$grouped[$mainRoomId][$connType][] = $row;
|
||||
}
|
||||
if($count){
|
||||
return count($results);
|
||||
}else{
|
||||
return $grouped;
|
||||
}
|
||||
} else {
|
||||
$sql = 'SELECT hri.*, pl.name AS room_type
|
||||
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 = ' . (int) $idLang . ')
|
||||
WHERE hri.id_hotel = ' . (int) $hotelId . '
|
||||
AND hri.id != ' . (int) $roomId . '
|
||||
AND NOT EXISTS (SELECT 1 FROM `' . _DB_PREFIX_ . 'htl_connected_room` cr WHERE cr.id_room = ' . (int) $roomId . ' AND cr.id_room_connected = hri.id)
|
||||
ORDER BY hri.room_num ASC';
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
return ($results === false) ? array() : $results;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,14 +554,14 @@ class HotelReservationSystemDb
|
||||
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_information` int(11) NOT NULL,
|
||||
`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_information`, `id_room`),
|
||||
KEY `idx_id_room_information` (`id_room_information`),
|
||||
KEY `idx_id_room` (`id_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;",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
<?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 HotelRoomConnected extends ObjectModel
|
||||
{
|
||||
/** @var bool|null */
|
||||
protected static $connectedRoomTableAvailable = null;
|
||||
|
||||
public $id_connected_room;
|
||||
public $id_room_information;
|
||||
public $id_room;
|
||||
public $date_add;
|
||||
public $date_upd;
|
||||
|
||||
public static $definition = array(
|
||||
'table' => 'htl_connected_room',
|
||||
'primary' => 'id_connected_room',
|
||||
'fields' => array(
|
||||
'id_room_information' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_room' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'date_add' => array('type' => self::TYPE_DATE),
|
||||
'date_upd' => array('type' => self::TYPE_DATE),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Check whether the connected room table exists and is queryable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isConnectedRoomTableAvailable()
|
||||
{
|
||||
if (self::$connectedRoomTableAvailable !== null) {
|
||||
return (bool) self::$connectedRoomTableAvailable;
|
||||
}
|
||||
|
||||
$result = Db::getInstance()->executeS('SELECT 1 FROM `' . _DB_PREFIX_ . 'htl_connected_room` LIMIT 1');
|
||||
self::$connectedRoomTableAvailable = ($result !== false);
|
||||
|
||||
return (bool) self::$connectedRoomTableAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hotel id for a room.
|
||||
*
|
||||
* @param int $roomId
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getRoomHotelId($roomId)
|
||||
{
|
||||
return (int) Db::getInstance()->getValue(
|
||||
'SELECT `id_hotel` FROM `' . _DB_PREFIX_ . 'htl_room_information` WHERE `id` = ' . (int) $roomId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get existing connected room id for a room pair.
|
||||
*
|
||||
* @param int $roomId
|
||||
* @param int $connectedRoomId
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getExistingConnectedRoomId($roomId, $connectedRoomId)
|
||||
{
|
||||
return (int) Db::getInstance()->getValue(
|
||||
'SELECT `id_connected_room` FROM `' . _DB_PREFIX_ . 'htl_connected_room` WHERE `id_room_information` = ' . (int) $roomId . ' AND `id_room` = ' . (int) $connectedRoomId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a connected room record matches provided ids.
|
||||
*
|
||||
* @param int $connectedId
|
||||
* @param int $roomId
|
||||
* @param int $connectedRoomId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isConnectionMatch($connectedId, $roomId, $connectedRoomId)
|
||||
{
|
||||
$matchId = (int) Db::getInstance()->getValue(
|
||||
'SELECT `id_connected_room` FROM `' . _DB_PREFIX_ . 'htl_connected_room` WHERE `id_connected_room` = ' . (int) $connectedId . ' AND `id_room_information` = ' . (int) $roomId . ' AND `id_room` = ' . (int) $connectedRoomId
|
||||
);
|
||||
|
||||
return ($matchId > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch connected/not-connected rooms for a hotel.
|
||||
*
|
||||
* @param int $idHotel
|
||||
* @param int $idLang
|
||||
* @param int|null $roomId
|
||||
* @param bool $isConnected
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getConnectedRoomsByHotel($idHotel, $idLang, $roomId = null, $isConnected = true)
|
||||
{
|
||||
$idHotel = (int) $idHotel;
|
||||
$idLang = (int) $idLang;
|
||||
$roomId = (int) $roomId;
|
||||
|
||||
if ($isConnected) {
|
||||
if (!self::isConnectedRoomTableAvailable()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = 'SELECT
|
||||
hcr.id_connected_room,hcr.id_room_information,hcr.id_room,main_room.id_hotel,main_room.room_num AS main_room_num,connected_room.room_num AS connected_room_num,
|
||||
main_pl.name AS main_room_type,conn_pl.name AS connected_room_type
|
||||
FROM `' . _DB_PREFIX_ . 'htl_connected_room` hcr
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` main_room ON main_room.id = hcr.id_room_information
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'htl_room_information` connected_room ON connected_room.id = hcr.id_room
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` main_pl ON (main_pl.id_product = main_room.id_product AND main_pl.id_lang = ' . (int) $idLang . ')
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` conn_pl ON (conn_pl.id_product = connected_room.id_product AND conn_pl.id_lang = ' . (int) $idLang . ')
|
||||
WHERE main_room.id_hotel = ' . (int) $idHotel . '
|
||||
AND connected_room.id_hotel = ' . (int) $idHotel;
|
||||
if ($roomId > 0) {
|
||||
$sql .= ' AND main_room.id = ' . (int) $roomId;
|
||||
}
|
||||
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
if ($results === false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$grouped = array();
|
||||
foreach ($results as $row) {
|
||||
$mainRoomId = (int) $row['id_room_information'];
|
||||
$connType = (string) $row['connected_room_type'];
|
||||
if (!isset($grouped[$mainRoomId])) {
|
||||
$grouped[$mainRoomId] = array();
|
||||
}
|
||||
if (!isset($grouped[$mainRoomId][$connType])) {
|
||||
$grouped[$mainRoomId][$connType] = array();
|
||||
}
|
||||
$grouped[$mainRoomId][$connType][] = $row;
|
||||
}
|
||||
return $grouped;
|
||||
} else {
|
||||
// If the connected room table is not yet available (e.g., older installs),
|
||||
// fall back to returning all rooms except the main room.
|
||||
if (!self::isConnectedRoomTableAvailable()) {
|
||||
$sql = 'SELECT hri.*, pl.name AS room_type
|
||||
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 = ' . (int) $idLang . ')
|
||||
WHERE hri.id_hotel = ' . (int) $idHotel . '
|
||||
AND hri.id != ' . (int) $roomId . '
|
||||
ORDER BY hri.room_num ASC';
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
return ($results === false) ? array() : $results;
|
||||
}
|
||||
|
||||
$sql = 'SELECT hri.*, pl.name AS room_type
|
||||
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 = ' . (int) $idLang . ')
|
||||
WHERE hri.id_hotel = ' . (int) $idHotel . '
|
||||
AND hri.id != ' . (int) $roomId . '
|
||||
AND NOT EXISTS (SELECT 1 FROM `' . _DB_PREFIX_ . 'htl_connected_room` cr WHERE cr.id_room_information = ' . (int) $roomId . ' AND cr.id_room = hri.id)
|
||||
ORDER BY hri.room_num ASC';
|
||||
$results = Db::getInstance()->executeS($sql);
|
||||
return ($results === false) ? array() : $results;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
|
||||
'link' => $this->context->link,
|
||||
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
|
||||
'htl_connected_rooms' => HotelRoomConnected::getConnectedRoomsByHotel($this->id_hotel, $this->context->language->id, 0, true),
|
||||
'htl_connected_rooms' => HotelConnectedRoom::getConnectedRooms($this->context->language->id, true, true),
|
||||
));
|
||||
|
||||
if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) {
|
||||
|
||||
@@ -49,7 +49,7 @@ require_once 'classes/HotelRoomDisableDates.php';
|
||||
require_once 'classes/HotelBranchRefundRules.php';
|
||||
require_once 'classes/HotelBedType.php';
|
||||
require_once 'classes/HotelRoomTypeBedType.php';
|
||||
require_once 'classes/HotelRoomConnected.php';
|
||||
require_once 'classes/HotelConnectedRoom.php';
|
||||
|
||||
// linked products
|
||||
require_once 'classes/RoomTypeServiceProduct.php';
|
||||
|
||||
Reference in New Issue
Block a user