diff --git a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl index e3405fa99..161c83965 100644 --- a/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl +++ b/admin/themes/default/template/controllers/orders/_current_cart_details_data.tpl @@ -51,7 +51,11 @@ {assign var=curr_id value=$cart->id_currency|intval} {foreach from=$cart_detail_data item=data} - {$data.room_num|escape:'html':'UTF-8'} {hook h='displayRoomNumAfter' data=$data type='adminOrder'} + {$data.room_num|escape:'html':'UTF-8'} + {if isset($data['connected_rooms'][$data['id_room']]) && $data['connected_rooms'][$data['id_room']]|@count > 0} + {include file="controllers/products/connected-rooms.tpl" htl_connected_rooms= $data['connected_rooms'][$data['id_room']]} + {/if} + {hook h='displayRoomNumAfter' data=$data type='adminOrder'}

{$data.room_type|escape:'html':'UTF-8'}

diff --git a/admin/themes/default/template/controllers/orders/_product_line.tpl b/admin/themes/default/template/controllers/orders/_product_line.tpl index 1e44a648f..299c0fa22 100644 --- a/admin/themes/default/template/controllers/orders/_product_line.tpl +++ b/admin/themes/default/template/controllers/orders/_product_line.tpl @@ -29,6 +29,9 @@ {if $data.is_back_order} {l s='overbooked'} {/if} + {if isset($data['connected_rooms'][$data['id_room']]) && $data['connected_rooms'][$data['id_room']]|@count > 0} + {include file="controllers/products/connected-rooms.tpl" htl_connected_rooms=$data['connected_rooms'][$data['id_room']]} + {/if} diff --git a/admin/themes/default/template/controllers/products/configuration.tpl b/admin/themes/default/template/controllers/products/configuration.tpl index 7f0bc0f60..c960e3f53 100644 --- a/admin/themes/default/template/controllers/products/configuration.tpl +++ b/admin/themes/default/template/controllers/products/configuration.tpl @@ -67,6 +67,14 @@ + + + {hook h='displayHotelRoomListTableHeaderColumn'} {l s='--'} @@ -108,6 +116,16 @@ {* Since the data can also be used from post incase of errors, which will cause issues with the id index *} + + {if isset($room_info['id'])} + + + + {/if} + {if isset($room_info['id'])} {hook h='displayHotelRoomListTableRowColumn' index=$key id_room=$room_info['id']} {else} @@ -1885,6 +1903,141 @@ return false; } } + //connected modal + $(document).on('click', '.connectedRoomModal', function(e) { + e.preventDefault(); + + let roomId = $(this).data('id-room'); + let hotelId = $(this).data('id-hotel'); + let currentRoomType = $('[name="id_product"]').val(); + $.ajax({ + type: 'POST', + url: prod_link, + dataType: 'json', + data: { + ajax: true, + action: 'getModalConnectedRooms', + room_id: roomId, + hotel_id: hotelId, + current_roomtype: currentRoomType, + }, + success: function(response) { + $('#modalLoader').remove(); + if (response.success) { + if ($('#connectedRoomModal').length) { + $('#connectedRoomModal').modal('hide'); + $('#connectedRoomModal').data('bs.modal', null); + $('#connectedRoomModal').remove(); + } + $('.modal-backdrop').remove(); + $('body').removeClass('modal-open'); + $("#footer").next(".bootstrap").append(response.html); + $('#connectedRoomModal').modal({ + backdrop: 'static', + keyboard: true + }); + } else { + alert(response.message); + } + } + + + }); + }); + function filterRoomsByType() { + var selectedType = $('#connect_room_type').val(); + var firstVisible = null; + $('#connect_room option').each(function() { + if ($(this).data('type') == selectedType) { + $(this).show(); + if (!firstVisible) firstVisible = $(this); + } else { + $(this).hide(); + } + }); + if (firstVisible) { + firstVisible.prop('selected', true); + } + } + $(document).on('change', '#connect_room_type', function() { + filterRoomsByType(); + }); + $(document).on('shown.bs.modal', '#connectedRoomModal', function() { + filterRoomsByType(); + }); + //add connected room + $(document).on('click', '#save_connected_room', function() { + var mainRoomId = $('#connected_room_main_id').val(); + var connectedRoomId = $('#connect_room').val(); + var hotelId = $('#hotel_id').val(); + let currentRoomType = $('[name="id_product"]').val(); + if (!connectedRoomId) { + alert('Please select a room'); + return; + } + $.ajax({ + url: prod_link, + type: 'POST', + dataType: 'json', + data: { + ajax: true, + action: 'ManageConnectedRoom', + mode: 'add', + hotel_id: hotelId, + room_id: mainRoomId, + connected_room_id: connectedRoomId, + current_roomtype: currentRoomType, + }, + beforeSend: function() { + $('#save_connected_room').prop('disabled', true); + }, + success: function(response) { + if (response.success) { + showSuccessMessage(response.message); + $('#connectedRoomModal .modal-content').replaceWith($(response.html).find('.modal-content')); + filterRoomsByType(); + } else { + alert(response.message); + } + }, + complete: function() { + $('#save_connected_room').prop('disabled', false); + } + }); + }); + //remove connected room + $(document).on('click', '.delete-connected-room', function() { + var roomId = $(this).data('room-id'); + var connectedRoomId = $(this).data('connected-room-id'); + var connectedId = $(this).data('connected-id'); + var hotelId = $(this).data('hotel-id'); + let currentRoomType = $('[name="id_product"]').val(); + $.ajax({ + url: prod_link, + type: 'POST', + dataType: 'json', + data: { + ajax: true, + action: 'ManageConnectedRoom', + mode: 'delete', + room_id: roomId, + connected_room_id: connectedRoomId, + connected_id: connectedId, + hotel_id: hotelId, + current_roomtype: currentRoomType, + }, + success: function(response) { + if (response.success) { + showSuccessMessage(response.message); + $('#connectedRoomModal .modal-content').replaceWith($(response.html).find( + '.modal-content')); + filterRoomsByType(); + } else { + alert(response.message); + } + } + }); + }); }); diff --git a/admin/themes/default/template/controllers/products/connected-rooms.tpl b/admin/themes/default/template/controllers/products/connected-rooms.tpl new file mode 100644 index 000000000..2e33a4daf --- /dev/null +++ b/admin/themes/default/template/controllers/products/connected-rooms.tpl @@ -0,0 +1,87 @@ +{** +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License version 3.0 +* that is bundled with this package in the file LICENSE.md +* It is also available through the world-wide-web at this URL: +* https://opensource.org/license/osl-3-0-php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to support@qloapps.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade this module to a newer +* versions in the future. If you wish to customize this module for your needs +* please refer to https://store.webkul.com/customisation-guidelines for more information. +* +* @author Webkul IN +* @copyright Since 2010 Webkul +* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 +*} +{if isset($htl_connected_rooms) && $htl_connected_rooms|@count > 0} + + +
+ + +
+
+{/if} + \ No newline at end of file diff --git a/admin/themes/default/template/controllers/products/modal-connected-rooms.tpl b/admin/themes/default/template/controllers/products/modal-connected-rooms.tpl new file mode 100644 index 000000000..38b34e2d8 --- /dev/null +++ b/admin/themes/default/template/controllers/products/modal-connected-rooms.tpl @@ -0,0 +1,148 @@ +{** +* 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 +*} + \ No newline at end of file diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 30026bcca..1bc548457 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -3485,6 +3485,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'] = HotelRoomConnected::getConnectedRoomsByHotel($value['id_hotel'], Context::getContext()->language->id, $value['id_room'], true); if (isset($value['refund_info']) && $value['refund_info']['refunded'] diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php index be3cabc94..d57e208d0 100644 --- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php +++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php @@ -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'] = HotelRoomConnected::getConnectedRoomsByHotel($obj_htl_room_info->id_hotel, Context::getContext()->language->id, $obj_htl_room_info->id, true); } } if ($cart_detail_data) { diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index ca44a2826..1260200cd 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -552,6 +552,14 @@ 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_information` int(11) NOT NULL, + `id_room` int(11) NOT NULL, + `date_add` datetime NOT NULL, + `date_upd` datetime NOT NULL, + PRIMARY KEY (`id_connected_room`) + ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", ); } @@ -615,7 +623,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`' ); } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomConnected.php b/modules/hotelreservationsystem/classes/HotelRoomConnected.php new file mode 100644 index 000000000..be9ccaf6b --- /dev/null +++ b/modules/hotelreservationsystem/classes/HotelRoomConnected.php @@ -0,0 +1,86 @@ + '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), + ), + ); + public static function getConnectedRoomsByHotel($idHotel, $idLang, $roomId = null, $isConnected = true) + { + if ($isConnected) { + $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 = ' . $idLang . ') + LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` conn_pl ON (conn_pl.id_product = connected_room.id_product AND conn_pl.id_lang = ' . $idLang . ') + WHERE main_room.id_hotel = ' . $idHotel . ' + AND connected_room.id_hotel = ' . $idHotel; + if (!empty($roomId)) { + $sql .= ' AND main_room.id = ' . (int) $roomId; + $results = Db::getInstance()->executeS($sql); + } else { + $results = Db::getInstance()->executeS($sql); + } + $grouped = []; + foreach ($results as $row) { + $roomId = $row['id_room_information']; + $connType = $row['connected_room_type']; + if (!isset($grouped[$roomId])) { + $grouped[$roomId] = []; + } + if (!isset($grouped[$roomId][$connType])) { + $grouped[$roomId][$connType] = []; + } + $grouped[$roomId][$connType][] = $row; + } + 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 = ' . $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'; + return Db::getInstance()->executeS($sql); + } + } +} + diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index fac60d468..3cccd6ca7 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -387,6 +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), )); if (Configuration::get('PS_BACKOFFICE_SEARCH_TYPE') == HotelBookingDetail::SEARCH_TYPE_OWS) { diff --git a/modules/hotelreservationsystem/define.php b/modules/hotelreservationsystem/define.php index e8a7cc909..141064a13 100644 --- a/modules/hotelreservationsystem/define.php +++ b/modules/hotelreservationsystem/define.php @@ -49,6 +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'; // linked products require_once 'classes/RoomTypeServiceProduct.php'; diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index 7c68db350..e83979106 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -40,7 +40,11 @@ {foreach from=$book_v['data']['available'] key=avai_k item=avai_v} - {$avai_v['room_num']|escape:'htmlall':'UTF-8'} {hook h='displayRoomNumAfter' data=$avai_v type='available'} + {$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'} {assign var="is_full_date" value=($show_full_date && ($date_from|date_format:'%D' == $date_to|date_format:'%D'))} {dateFormat date=$date_from full=$is_full_date} - {dateFormat date=$date_to full=$is_full_date} {$avai_v['room_comment']|escape:'htmlall':'UTF-8'}