Fix popup issues
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
{**
|
||||
* 2010-2023 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-2023 Webkul IN
|
||||
* @license LICENSE.txt
|
||||
*}
|
||||
|
||||
{l s='This room already has bookings for highlighted date range(s). Please reselect the date ranges:'}
|
||||
|
||||
{foreach from=$booked_rows_list item=booked_row}
|
||||
<br>
|
||||
{dateFormat date=$booked_row->date_from} {l s='to'} {dateFormat date=$booked_row->date_to} - <a href="{$link->getAdminLink('AdminOrders')}&id_order={$booked_row->id_order}&vieworder" target="_blank"><strong>#{$booked_row->id_order|intval}</strong></a>
|
||||
{/foreach}
|
||||
@@ -240,8 +240,6 @@
|
||||
var prod_link = "{$link->getAdminLink('AdminProducts')}";
|
||||
var rm_status = {$rm_status|@json_encode};
|
||||
var currentRoomRow = 0;
|
||||
var datesMissing = "{$datesMissing}";
|
||||
var datesOverlapping = "{$datesOverlapping}";
|
||||
|
||||
$(document).ready(function() {
|
||||
const DisableDatesModal = {
|
||||
@@ -303,13 +301,12 @@
|
||||
});
|
||||
},
|
||||
showErrors: function(errors) {
|
||||
$('#deactiveDatesModal .errors-wrap').stop().html(errors);
|
||||
$('#deactiveDatesModal .errors-wrap').show(200);
|
||||
$('#deactiveDatesModal .errors-wrap').html(errors);
|
||||
$('#deactiveDatesModal .errors-wrap').show();
|
||||
},
|
||||
hideErrors: function() {
|
||||
$('#deactiveDatesModal .errors-wrap').hide(200, function() {
|
||||
$('#deactiveDatesModal .errors-wrap').html('');
|
||||
});
|
||||
$('#deactiveDatesModal .errors-wrap').hide();
|
||||
$('#deactiveDatesModal .errors-wrap').html('');
|
||||
},
|
||||
addInvalidRowDataMarkers: function(rowsToHighlight) {
|
||||
rowsToHighlight.map(function (rowIndex) {
|
||||
@@ -380,9 +377,19 @@
|
||||
}
|
||||
|
||||
disableDates = JSON.parse(disableDates);
|
||||
DisableDatesModal.hideErrors();
|
||||
DisableDatesModal.populateWithDatesInfo(disableDates);
|
||||
});
|
||||
|
||||
// Disable dates data filling when model open
|
||||
$('#deactiveDatesModal').on('hide.bs.modal', function(e) {
|
||||
const disableDates = DisableDatesModal.getDisableDatesInfo();
|
||||
console.log(disableDates);
|
||||
const roomRowIndex = parseInt($('#deactiveDatesModal table.room-disable-dates').attr('data-room-row-index'));
|
||||
const roomRow = $('#product-configuration .hotel-room tr.room_data_values[data-row-index='+roomRowIndex+']');
|
||||
$(roomRow).find('.disable_dates_json').val(JSON.stringify(disableDates));
|
||||
});
|
||||
|
||||
// copy json formatted dates to room
|
||||
$(document).on('click', '.deactiveDatesModalSubmit', function() {
|
||||
DisableDatesModal.validateDisableDates(function () {
|
||||
|
||||
@@ -2779,8 +2779,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
'product' => $obj,
|
||||
'htl_info' => $hotelInfo,
|
||||
'rm_status' => $roomStatus,
|
||||
'datesMissing' => $this->l('Some dates are missing. Please select all the date ranges.'),
|
||||
'datesOverlapping' => $this->l('Some dates are conflicting with each other. Please check and reselect the date ranges.'),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
@@ -4640,6 +4638,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$disableDates = Tools::getValue('disable_dates');
|
||||
|
||||
$rowsToHighlight = array();
|
||||
$bookedRows = array();
|
||||
if (is_array($disableDates) && count($disableDates)) {
|
||||
foreach ($disableDates as $key => $dateRange) {
|
||||
if (!Validate::isDate($dateRange['date_from']) || !Validate::isDate($dateRange['date_to'])) {
|
||||
@@ -4652,8 +4651,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
foreach ($disableDates as $keyOuter => $dateRangeOuter) {
|
||||
foreach ($disableDates as $keyInner => $dateRangeInner) {
|
||||
if ($keyInner != $keyOuter) {
|
||||
if ((strtotime($dateRangeOuter['date_from']) <= strtotime($dateRangeInner['date_to']))
|
||||
&& (strtotime($dateRangeInner['date_from']) <= strtotime($dateRangeOuter['date_to']))
|
||||
if ((($dateRangeOuter['date_from'] >= $dateRangeInner['date_from']) && ($dateRangeOuter['date_from'] < $dateRangeInner['date_to']))
|
||||
|| (($dateRangeInner['date_from'] >= $dateRangeOuter['date_from']) && ($dateRangeInner['date_from'] < $dateRangeOuter['date_to']))
|
||||
) {
|
||||
$this->errors[] = $this->l('Some dates are conflicting with each other. Please check and reselect the date ranges.');
|
||||
$rowsToHighlight[] = $keyOuter;
|
||||
@@ -4668,8 +4667,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($idRoom) {
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
foreach ($disableDates as $key => $dateRange) {
|
||||
if ($objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
|
||||
$this->errors[] = $this->l('This room has been booked for highlighted date range(s). Please reselect the date ranges.');
|
||||
if ($bookingRow = $objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
|
||||
$bookedRows[] = new HotelBookingDetail($bookingRow['id']);
|
||||
$rowsToHighlight[] = $key;
|
||||
}
|
||||
}
|
||||
@@ -4677,8 +4676,17 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if (count($bookedRows)) {
|
||||
$this->context->smarty->assign(array(
|
||||
'link' => $this->context->link,
|
||||
'booked_rows_list' => $bookedRows,
|
||||
));
|
||||
|
||||
$this->errors[] = $this->context->smarty->fetch('controllers/products/booked_room_date_ranges_list.tpl');
|
||||
}
|
||||
|
||||
$this->errors = array_unique($this->errors);
|
||||
$rowsToHighlight = array_unique($rowsToHighlight);
|
||||
$rowsToHighlight = array_values(array_unique($rowsToHighlight));
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$response['status'] = true;
|
||||
|
||||
@@ -1254,7 +1254,7 @@ class HotelBookingDetail extends ObjectModel
|
||||
// This function algo is same as available rooms algo and it not similar to booked rooms algo.
|
||||
public function chechRoomBooked($id_room, $date_from, $date_to)
|
||||
{
|
||||
$sql = 'SELECT `id_product`, `id_order`, `id_cart`, `id_room`, `id_hotel`, `id_customer`
|
||||
$sql = 'SELECT `id`, `id_product`, `id_order`, `id_cart`, `id_room`, `id_hotel`, `id_customer`
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE `id_room` = '.(int)$id_room.
|
||||
' AND `is_back_order` = 0 AND `is_refunded` = 0 AND ((date_from <= \''.pSQL($date_from).'\' AND date_to > \''.
|
||||
pSQL($date_from).'\' AND date_to <= \''.pSQL($date_to).'\') OR (date_from > \''.pSQL($date_from).
|
||||
|
||||
Reference in New Issue
Block a user