Merge pull request #1946 from shazar-webkul/gli-3286

Updated: Make room disable dates independent of room status
This commit is contained in:
Rohit Jain
2026-10-19 20:36:12 +05:30
committed by GitHub
16 changed files with 197 additions and 228 deletions

View File

@@ -62,7 +62,7 @@
</th>
<th class="col-sm-2 center">
<label class="control-label">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Set date ranges when %s is set to Temporarily Inactive.' sprintf=$htl_room_type['selling_object_plural_name']}">
<span class="label-tooltip" data-toggle="tooltip" data-original-title="{l s='Set date ranges when %s are not available for booking.' sprintf=$htl_room_type['selling_object_plural_name']}">
{l s='Disable Dates'}
</span>
</label>
@@ -111,9 +111,9 @@
<input type="text" class="form-control room_comment" value="{if isset($room_info['comment'])}{$room_info['comment']|escape:'html':'UTF-8'}{/if}" name="{$var_name_room_info|cat:'[comment]'}">
</td>
<td class="col-sm-2 center">
<a class="btn btn-default deactiveDatesModal {if $room_info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }disabled{/if}" data-toggle="modal" data-target="#deactiveDatesModal" data-id-room="{if isset($room_info['id'])}{$room_info['id']}{/if}">{if $room_info['id_status'] != $rm_status['STATUS_TEMPORARY_INACTIVE']['id'] }{l s='Add Dates'}{else}{l s='View Dates'}{/if}
<a class="btn btn-default deactiveDatesModal" data-toggle="modal" data-target="#deactiveDatesModal" data-id-room="{if isset($room_info['id'])}{$room_info['id']}{/if}">{if isset($room_info['disable_dates_json']) && json_decode($room_info['disable_dates_json'])}{l s='View Dates'}{else}{l s='Add Dates'}{/if}
</a>
<input type="hidden" class="form-control disable_dates_json" name="{$var_name_room_info|cat:'[disable_dates_json]'}" {if $room_info['id_status'] == $rm_status['STATUS_TEMPORARY_INACTIVE']['id']}value="{$room_info['disable_dates_json']|escape:'html':'UTF-8'}"{/if}>
<input type="hidden" class="form-control disable_dates_json" name="{$var_name_room_info|cat:'[disable_dates_json]'}" {if isset($room_info['disable_dates_json'])}value="{$room_info['disable_dates_json']|escape:'html':'UTF-8'}"{/if}>
</td>
{* Since the data can also be used from post incase of errors, which will cause issues with the id index *}
<td class="col-sm-1 center">
@@ -381,7 +381,7 @@
<input type="text" name="bulk_update_room_comment"/>
</div>
</div>
<div class="from-group table-responsive-row clearfix" style="display:none;">
<div class="from-group table-responsive-row clearfix">
<div class="rooms-disable-dates-title">{l s='Disable Dates'}</div>
<table class="table rooms-disable-dates">
<thead>
@@ -495,7 +495,7 @@
<input type="text" name="bulk_create_room_comment"/>
</div>
</div>
<div class="from-group table-responsive-row clearfix" style="display:none;">
<div class="from-group table-responsive-row clearfix">
<div class="rooms-disable-dates-title">{l s='Disable Dates'}</div>
<table class="table rooms-disable-dates">
<thead>
@@ -785,16 +785,6 @@
});
});
// on changing the room status as disabled for some date range
$(document).on('change', '.room_status', function(){
var status_val = $(this).val();
if (status_val == rm_status.STATUS_TEMPORARY_INACTIVE.id) {
$(this).closest('.room_data_values').find('.deactiveDatesModal').removeClass('disabled');
} else {
$(this).closest('.room_data_values').find('.deactiveDatesModal').addClass('disabled');
}
});
// Initializing datepicker for date from for the disable dates calendar
$('#disable_dates_form .date_from_container').datepicker({
showOtherMonths: true,
@@ -1023,6 +1013,7 @@
const roomRowIndex = parseInt($('#deactiveDatesModal').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));
$(roomRow).find('.deactiveDatesModal').text(disableDates.length ? '{l s='View Dates'}' : '{l s='Add Dates'}');
DisableDatesObj.reset();
DisableDatesObj.allowCalendarActions();
});
@@ -1059,15 +1050,6 @@
BulkUpdateRoomModal.submitBulkDelete();
});
$(document).on('change', 'select[name="bulk_update_room_status"], select[name="bulk_create_room_status"]', function(){
var status_val = $(this).val();
if (status_val == rm_status.STATUS_TEMPORARY_INACTIVE.id) {
$(this).closest('.modal-body').find('.rooms-disable-dates').parent().show();
} else {
$(this).closest('.modal-body').find('.rooms-disable-dates').parent().hide();
}
});
$(document).on('focus', '.disabled_date_from, .disabled_date_to', function () {
$('.disabled_date_from').datepicker({
showOtherMonths: true,
@@ -1109,7 +1091,7 @@
$('#bulkUpdateRoomModal').on('show.bs.modal', function(e){
if (!$(e.relatedTarget).attr('disabled')) {
$('#bulkUpdateRoomModal table tbody').html('');
$('.bulk_update_room_status').val('0').closest('.modal-body').find('.rooms-disable-dates').parent().hide();
$('.bulk_update_room_status').val('0');
$('[name="bulk_update_room_comment"]').val('');
$('[name="bulk_update_room_floor"]').val('');
$('#page-loader').show();
@@ -1125,7 +1107,7 @@
$('#bulkCreateRoomModal').on('show.bs.modal', function(e){
$('#bulkCreateRoomModal table tbody').html('');
$('.bulk_create_room_status').val(rm_status.STATUS_ACTIVE.id).closest('.modal-body').find('.rooms-disable-dates').parent().hide();
$('.bulk_create_room_status').val(rm_status.STATUS_ACTIVE.id);
$('[name="bulk_create_room_comment"]').val('');
$('[name="bulk_create_room_floor"]').val('');
$('[name="bulk_create_room_prefix"]').val(''),

View File

@@ -231,11 +231,11 @@ class AdminImportControllerCore extends AdminController
'floor' => array('label' => $this->l('Floor')),
'id_product' => array('label' => $this->l('Room Type ID *')),
'id_status' => array(
'label' => $this->l('Room status (1/2/3)'),
'help' => $this->l('1 = Active, 2 = Inactive, 3 = Temporarily Inactive')),
'label' => $this->l('Room status (1/2)'),
'help' => $this->l('1 = Active, 2 = Inactive')),
'comment' => array('label' => $this->l('Extra Information')),
'dates' => array('label' => $this->l('Inactive date ranges and Reason(yyyy-mm-dd)'),
'help' => $this->l('If Temporarily Inactive (date_from:date_to:reason, date_from:date_to:reason,...)')
'dates' => array('label' => $this->l('Disable date ranges and Reason(yyyy-mm-dd)'),
'help' => $this->l('date_from:date_to:reason, date_from:date_to:reason,...')
),
);
break;
@@ -1996,46 +1996,31 @@ class AdminImportControllerCore extends AdminController
$lang_field_error = $objHotelRoomInfo->validateFieldsLang(UNFRIENDLY_ERROR, true);
$res = false;
if ($this->checkRequiredFields($info, 'room_num')) {
if ($objHotelRoomInfo->id_status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE
&& (!isset($objHotelRoomInfo->dates) || !$objHotelRoomInfo->dates)
) {
$this->errors[] = sprintf(
Tools::displayError('%1$s (ID: %2$s) cannot be saved due to missing disable dates.'),
(isset($info['room_num']) && !empty($info['room_num']))? Tools::safeOutput($info['room_num']) : 'No Name',
(isset($info['id']) && !empty($info['id']))? Tools::safeOutput($info['id']) : 'No ID'
);
} else if (Validate::isLoadedObject($objProduct = new Product((int) $info['id_product']))
if (Validate::isLoadedObject($objProduct = new Product((int) $info['id_product']))
&& Product::isBookingProduct($objProduct->id)
) {
if ($field_error === true && $lang_field_error === true) {
if ($res = $objHotelRoomInfo->add()) {
if ($idRoom = $objHotelRoomInfo->id) {
if ($objHotelRoomInfo->id_status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$objHotelRoomDisableDates = new HotelRoomDisableDates();
if (isset($objHotelRoomInfo->dates)
&& $objHotelRoomInfo->dates
) {
foreach ($objHotelRoomInfo->dates as $disableDate) {
$datesData = explode(':', $disableDate);
$reason = '';
if(isset($datesData[2])) {
$reason = $datesData[2];
}
if (isset($datesData[0]) && isset($datesData[1])
&& strtotime($datesData[1]) > strtotime($datesData[0])
) {
$objHotelRoomDisableDates = new HotelRoomDisableDates();
$objHotelRoomDisableDates->id_room_type = $objHotelRoomInfo->id_product;
$objHotelRoomDisableDates->id_room = $idRoom;
$objHotelRoomDisableDates->date_from = date('Y-m-d', strtotime($datesData[0]));
$objHotelRoomDisableDates->date_to = date('Y-m-d', strtotime($datesData[1]));
$objHotelRoomDisableDates->reason = $reason;
$objHotelRoomDisableDates->add();
}
if (isset($objHotelRoomInfo->dates) && $objHotelRoomInfo->dates) {
foreach ($objHotelRoomInfo->dates as $disableDate) {
$datesData = explode(':', $disableDate);
$reason = '';
if(isset($datesData[2])) {
$reason = $datesData[2];
}
if (isset($datesData[0]) && isset($datesData[1])
&& strtotime($datesData[1]) > strtotime($datesData[0])
) {
$objHotelRoomDisableDates = new HotelRoomDisableDates();
$objHotelRoomDisableDates->id_room_type = $objHotelRoomInfo->id_product;
$objHotelRoomDisableDates->id_room = $idRoom;
$objHotelRoomDisableDates->date_from = date('Y-m-d', strtotime($datesData[0]));
$objHotelRoomDisableDates->date_to = date('Y-m-d', strtotime($datesData[1]));
$objHotelRoomDisableDates->reason = $reason;
$objHotelRoomDisableDates->add();
}
} else {
$this->warnings[] = Tools::displayError('Please set date from and date to incase of temporary inactive status.');
}
}
}

View File

@@ -3233,10 +3233,8 @@ class AdminProductsControllerCore extends AdminController
}
$room['booked_dates'] = json_encode($bookedDates);
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
$room['disable_dates_json'] = json_encode($disableDates);
}
$disableDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
$room['disable_dates_json'] = json_encode($disableDates);
$room['connected_rooms_count'] = HotelConnectedRoom::getTotalConnectedRooms($room['id']);
}
@@ -3794,13 +3792,7 @@ class AdminProductsControllerCore extends AdminController
$objHotelRoomInfo->id_status = $roomInfo['id_status'];
$objHotelRoomInfo->floor = trim($roomInfo['floor']);
$objHotelRoomInfo->comment = trim($roomInfo['comment']);
if ($objHotelRoomInfo->save()
&& $objHotelRoomInfo->id_status != HotelRoomInformation::STATUS_TEMPORARY_INACTIVE
) {
// directly deleting the dates since we are validating the dates using hooks before this.
$objRoomDisableDates = new HotelRoomDisableDates();
$objRoomDisableDates->deleteRoomDisableDates($objHotelRoomInfo->id);
}
$objHotelRoomInfo->save();
}
}
}
@@ -3826,12 +3818,6 @@ class AdminProductsControllerCore extends AdminController
foreach ($roomsInfo as $key => $roomInfo) {
$roomIndex = $key + 1;
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
if ($roomInfo['disable_dates_json'] === 0) {
$this->errors[] = sprintf(Tools::displayError('Please add disable dates for room %s.'), $roomIndex);
}
}
if ($roomInfo['room_num'] && !Validate::isGenericName($roomInfo['room_num'])) {
$this->errors[] = sprintf(Tools::displayError('Invalid room number for room %s.'), $roomIndex);
}
@@ -3844,13 +3830,6 @@ class AdminProductsControllerCore extends AdminController
if (count($objHotelRoomInformation->getFutureBookings($roomInfo['id']))) {
$this->errors[] = sprintf(Tools::displayError('Cannot change room %s status to inactive as it already has some bookings, Please check the bookings and move those bookings to another room if you want make this room inactive'), $roomInfo['room_num']);
}
} elseif ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = json_decode($roomInfo['disable_dates_json'], true);
if (!is_array($disableDates)
|| !count($disableDates)
) {
$this->errors[] = sprintf(Tools::displayError('Please add disable dates for room %s.'), $roomIndex);
}
}
Hook::exec('actionValidateRoomInformation', array('room_information' => $roomInfo));
}
@@ -5210,7 +5189,7 @@ class AdminProductsControllerCore extends AdminController
$idProduct = Tools::getValue('id_product');
if ($this->tabAccess['edit'] === 1) {
if (!Validate::isDate($dateFrom) || !Validate::isDate($dateTo)) {
$this->errors[] = $this->l('Please select a valid date range to temporary disable this room');
$this->errors[] = $this->l('Please select a valid date range to disable this room');
} else if ($idRoom && Validate::isLoadedObject($objHotelRoomInfo = new HotelRoomInformation((int) $idRoom))) {
$dateTo = date('Y-m-d', strtotime($dateTo));
$objHotelBookingDetail = new HotelBookingDetail();
@@ -5234,10 +5213,7 @@ class AdminProductsControllerCore extends AdminController
$objHotelRoomDisableDates->date_from = $dateFrom;
$objHotelRoomDisableDates->date_to = $dateTo;
$objHotelRoomDisableDates->reason = trim(Tools::getValue('reason'));
$objHotelRoomInfo->id_status = HotelRoomInformation::STATUS_TEMPORARY_INACTIVE;
if ($objHotelRoomInfo->save()
&& $objHotelRoomDisableDates->save()
) {
if ($objHotelRoomDisableDates->save()) {
$response['id_disable_date'] = $objHotelRoomDisableDates->id;
$response['event_title'] = $this->l('Disabled');
if (Tools::getValue('id_disable_date')) {
@@ -5331,12 +5307,7 @@ class AdminProductsControllerCore extends AdminController
} else {
$response['status'] = true;
$this->confirmations[] = $this->l('Removed successfully.');
if (!($disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom))) {
$objRoomInfo = new HotelRoomInformation($idRoom);
$objRoomInfo->id_status = HotelRoomInformation::STATUS_ACTIVE;
$objRoomInfo->save();
}
$disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom);
$response['disable_dates'] = $disableDates;
}
@@ -5370,13 +5341,8 @@ class AdminProductsControllerCore extends AdminController
&& (int) $idDisableDate
&& Validate::isLoadedObject($objRoomDisableDates = new HotelRoomDisableDates($idDisableDate))
) {
$idRoom = $objRoomDisableDates->id_room;
if (!$objRoomDisableDates->delete()) {
$this->errors[] = Tools::displayError('An error occurred while trying to perform this operation.');
} else if (!$objRoomDisableDates->getRoomDisableDates($idRoom)) {
$objRoomInfo = new HotelRoomInformation($idRoom);
$objRoomInfo->id_status = HotelRoomInformation::STATUS_ACTIVE;
$objRoomInfo->save();
}
} else {
$this->errors[] = Tools::displayError('Invalid request');
@@ -5419,45 +5385,47 @@ class AdminProductsControllerCore extends AdminController
$room['id_status'] = Tools::getValue('id_status');
$disableDates = array();
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = Tools::getValue('disable_dates');
$room['disable_dates_json'] = json_encode($disableDates);
if (!$disableDates) {
$this->errors[] = Tools::displayError('Please add at least one date range for updating the rooms status to temporary inactive.');
} else {
$hasMissingRowError = false;
foreach ($disableDates as $key => $dateRange) {
if (!Validate::isDate($dateRange['date_from']) || !Validate::isDate($dateRange['date_to'])) {
if (!$hasMissingRowError) {
$hasMissingRowError = true;
$this->errors[] = Tools::displayError('Some dates are missing. Please select all the date ranges.');
}
$rowsToHighlight[] = $key;
}
if (is_array($rawDisableDates = Tools::getValue('disable_dates'))) {
foreach ($rawDisableDates as $key => $dateRange) {
if (trim($dateRange['date_from']) || trim($dateRange['date_to'])) {
$disableDates[$key] = $dateRange;
}
}
}
if (!count($this->errors)) {
$error = false;
foreach ($disableDates as $keyOuter => $dateRangeOuter) {
foreach ($disableDates as $keyInner => $dateRangeInner) {
if ($keyInner != $keyOuter) {
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']))
) {
if (!$error) {
$error = Tools::displayError('Some dates are conflicting with each other. Please check and reselect the date ranges.');
}
$rowsToHighlight[] = $keyOuter;
$rowsToHighlight[] = $keyInner;
if ($disableDates) {
$hasMissingRowError = false;
foreach ($disableDates as $key => $dateRange) {
if (!Validate::isDate($dateRange['date_from']) || !Validate::isDate($dateRange['date_to'])) {
if (!$hasMissingRowError) {
$hasMissingRowError = true;
$this->errors[] = Tools::displayError('Some dates are missing. Please select all the date ranges.');
}
$rowsToHighlight[] = $key;
}
}
if (!count($this->errors)) {
$error = false;
foreach ($disableDates as $keyOuter => $dateRangeOuter) {
foreach ($disableDates as $keyInner => $dateRangeInner) {
if ($keyInner != $keyOuter) {
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']))
) {
if (!$error) {
$error = Tools::displayError('Some dates are conflicting with each other. Please check and reselect the date ranges.');
}
$rowsToHighlight[] = $keyOuter;
$rowsToHighlight[] = $keyInner;
}
}
}
}
if ($error) {
$this->errors[] = $error;
}
if ($error) {
$this->errors[] = $error;
}
}
}
@@ -5471,12 +5439,12 @@ class AdminProductsControllerCore extends AdminController
if (count($objHotelRoomInfo->getFutureBookings($idRoom))) {
$this->errors[] = sprintf(Tools::displayError('Cannot change room %s status to inactive as it already has some bookings, Please check the bookings and move those bookings to another room if you want make this room inactive'), $objHotelRoomInfo->room_num);
}
} else if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE && $disableDates) {
foreach ($disableDates as $key => $dateRange) {
if ($bookingRow = $objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
$bookedRows[$bookingRow['id']] = new HotelBookingDetail($bookingRow['id']);
$rowsToHighlight[] = $key;
}
}
foreach ($disableDates as $key => $dateRange) {
if ($bookingRow = $objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
$bookedRows[$bookingRow['id']] = new HotelBookingDetail($bookingRow['id']);
$rowsToHighlight[] = $key;
}
}
@@ -5513,20 +5481,14 @@ class AdminProductsControllerCore extends AdminController
$objHotelRoomInfo->comment = $roomInfo['comment'];
}
if ($objHotelRoomInfo->save()
&& $objHotelRoomInfo->id_status != HotelRoomInformation::STATUS_TEMPORARY_INACTIVE
) {
// directly deleting the dates since we are validating the dates using hooks before this.
$objRoomDisableDates = new HotelRoomDisableDates();
$objRoomDisableDates->deleteRoomDisableDates($objHotelRoomInfo->id);
} else {
foreach ($disableDates as $key => $dateRange) {
if ($objHotelRoomInfo->save()) {
foreach ($disableDates as $dateRange) {
$objHotelRoomDisableDates = new HotelRoomDisableDates();
$objHotelRoomDisableDates->id_room_type = $objHotelRoomInfo->id_product;
$objHotelRoomDisableDates->id_room = $roomInfo['id'];
$objHotelRoomDisableDates->date_from = $dateRange['date_from'];
$objHotelRoomDisableDates->date_to = $dateRange['date_to'];
$objHotelRoomDisableDates->reason = $dateRange['reason'];
$objHotelRoomDisableDates->reason = isset($dateRange['reason']) ? $dateRange['reason'] : '';
$objHotelRoomDisableDates->save();
}
}
@@ -5597,22 +5559,47 @@ class AdminProductsControllerCore extends AdminController
$roomsInfo['id_status'] = Tools::getValue('id_status');
$disableDates = array();
if ($roomsInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = Tools::getValue('disable_dates');
$roomsInfo['disable_dates_json'] = json_encode($disableDates);
if (!$disableDates) {
$this->errors[] = sprintf(Tools::displayError('Please add at least one date range for updating the %s status to temporary inactive.') , $roomTypeInfo['selling_object_name']);
} else {
$hasMissingRowError = false;
foreach ($disableDates as $key => $dateRange) {
if (!Validate::isDate($dateRange['date_from']) || !Validate::isDate($dateRange['date_to'])) {
if (!$hasMissingRowError) {
$hasMissingRowError = true;
$this->errors[] = Tools::displayError('Some dates are missing. Please select all the date ranges.');
}
if (is_array($rawDisableDates = Tools::getValue('disable_dates'))) {
foreach ($rawDisableDates as $key => $dateRange) {
if (trim($dateRange['date_from']) || trim($dateRange['date_to'])) {
$disableDates[$key] = $dateRange;
}
}
}
$rowsToHighlight[] = $key;
if ($disableDates) {
$hasMissingRowError = false;
foreach ($disableDates as $key => $dateRange) {
if (!Validate::isDate($dateRange['date_from']) || !Validate::isDate($dateRange['date_to'])) {
if (!$hasMissingRowError) {
$hasMissingRowError = true;
$this->errors[] = Tools::displayError('Some dates are missing. Please select all the date ranges.');
}
$rowsToHighlight[] = $key;
}
}
if (!count($this->errors)) {
$error = false;
foreach ($disableDates as $keyOuter => $dateRangeOuter) {
foreach ($disableDates as $keyInner => $dateRangeInner) {
if ($keyInner != $keyOuter) {
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']))
) {
if (!$error) {
$error = Tools::displayError('Some dates are conflicting with each other. Please check and reselect the date ranges.');
}
$rowsToHighlight[] = $keyOuter;
$rowsToHighlight[] = $keyInner;
}
}
}
}
if ($error) {
$this->errors[] = $error;
}
}
}
@@ -5647,14 +5634,14 @@ class AdminProductsControllerCore extends AdminController
$objHotelRoomInfo->comment = $roomsInfo['comment'];
}
if ($objHotelRoomInfo->save() && $objHotelRoomInfo->id_status == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
foreach ($disableDates as $key => $dateRange) {
if ($objHotelRoomInfo->save()) {
foreach ($disableDates as $dateRange) {
$objHotelRoomDisableDates = new HotelRoomDisableDates();
$objHotelRoomDisableDates->id_room_type = $objHotelRoomInfo->id_product;
$objHotelRoomDisableDates->id_room = $objHotelRoomInfo->id;
$objHotelRoomDisableDates->date_from = $dateRange['date_from'];
$objHotelRoomDisableDates->date_to = $dateRange['date_to'];
$objHotelRoomDisableDates->reason = $dateRange['reason'];
$objHotelRoomDisableDates->reason = isset($dateRange['reason']) ? $dateRange['reason'] : '';
$objHotelRoomDisableDates->save();
}
}

View File

@@ -1439,7 +1439,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
// Unavailable are:
// - inactive rooms (unavailable for all nights in the range)
// - temporarily inactive rooms for overlapping disabled date ranges (night-wise)
// - active rooms for overlapping disabled date ranges (night-wise)
$countInactiveRooms = (int)Db::getInstance()->getValue(
'SELECT IFNULL(COUNT(hri.`id`), 0)
FROM `'._DB_PREFIX_.'htl_room_information` hri
@@ -1500,7 +1500,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
ON (hrdd.`id_room` = hri.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = hri.`id_product`)
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_ACTIVE.'
AND hrdd.`date_from` < "'.pSQL($dateTo).'"
AND hrdd.`date_to` > "'.pSQL($dateFrom).'"
AND p.`active` = 1
@@ -1508,7 +1508,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
(!is_null($idsHotel) ? HotelBranchInformation::addHotelRestriction($idsHotel, 'hri') : '')
);
// Booked nights overlapping temporary disable ranges should not be counted as unavailable.
// Booked nights overlapping disable ranges should not be counted as unavailable.
$countOccupiedTemporaryInactiveNights = (int)Db::getInstance()->getValue(
'SELECT IFNULL(SUM(
GREATEST(
@@ -1537,7 +1537,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
ON (hri.`id` = hbd.`id_room`)
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = hri.`id_product`)
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_ACTIVE.'
AND p.`active` = 1
AND p.`booking_product` = 1
AND hbd.`id` NOT IN ('.OrderReturn::getRefundedBookingIdsSubquery().')
@@ -2023,13 +2023,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : '').'
) AS num_inactive,
(
SELECT IFNULL(COUNT(hri.`id`), 0)
SELECT IFNULL(COUNT(DISTINCT hri.`id`), 0)
FROM `'._DB_PREFIX_.'htl_room_information` hri
LEFT JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
ON (hrdd.`id_room` = hri.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = hri.`id_product`)
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.'
AND ("'.pSQL($discreteDate['date_from']).'" >= hrdd.`date_from` AND "'.pSQL($discreteDate['date_from']).'" < hrdd.`date_to`)
AND p.`active` = 1'.
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : '').'
@@ -2104,13 +2104,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : '').'
) AS num_inactive,
(
SELECT IFNULL(COUNT(hri.`id`), 0)
SELECT IFNULL(COUNT(DISTINCT hri.`id`), 0)
FROM `'._DB_PREFIX_.'htl_room_information` hri
LEFT JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
ON (hrdd.`id_room` = hri.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = hri.`id_product`)
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.'
AND ("'.pSQL($discreteDate['date_from']).'" >= hrdd.`date_from` AND "'.pSQL($discreteDate['date_from']).'" < hrdd.`date_to`)
AND p.`active` = 1'.
(!is_null($showAtFront) ? ' AND p.`show_at_front` = '.(int) $showAtFront : '').
@@ -2168,13 +2168,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : '').'
) AS num_inactive,
(
SELECT IFNULL(COUNT(hri.`id`), 0)
SELECT IFNULL(COUNT(DISTINCT hri.`id`), 0)
FROM `'._DB_PREFIX_.'htl_room_information` hri
LEFT JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
ON (hrdd.`id_room` = hri.`id`)
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = hri.`id_product`)
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.'
AND ("'.pSQL($discreteDate['date_from']).'" >= hrdd.`date_from` AND "'.pSQL($discreteDate['date_from']).'" < hrdd.`date_to`)
AND p.`active` = 1'.
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : '').'

View File

@@ -1,3 +1,3 @@
Room No;Floor;Room Type ID;Room Status (1 = Active, 2 = Inactive, 3 = Temporarily Inactive);Extra Information;Disabled Dates And Reason Incase Of Temporary Inactive
GR-109;First;1;3;Newly added room;2024-01-01:2024-01-02:Reason1, 2023-02-03:2023-02-02:Reason2
Room No;Floor;Room Type ID;Room Status (1 = Active, 2 = Inactive);Extra Information;Disabled Dates And Reason
GR-109;First;1;1;Newly added room;2024-01-01:2024-01-02:Reason1, 2023-02-03:2023-02-02:Reason2
DR-107;First;2;1;;
1 Room No Floor Room Type ID Room Status (1 = Active, 2 = Inactive, 3 = Temporarily Inactive) Room Status (1 = Active, 2 = Inactive) Extra Information Disabled Dates And Reason Incase Of Temporary Inactive Disabled Dates And Reason
2 GR-109 First 1 3 1 Newly added room 2024-01-01:2024-01-02:Reason1, 2023-02-03:2023-02-02:Reason2 2024-01-01:2024-01-02:Reason1, 2023-02-03:2023-02-02:Reason2
3 DR-107 First 2 1 1

View File

@@ -603,11 +603,11 @@ class HotelBookingDetail extends ObjectModel
FROM `'._DB_PREFIX_.'htl_room_information`
WHERE `id_hotel`='.(int)$idHotel.' AND `id_status` = '. HotelRoomInformation::STATUS_INACTIVE.' AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')';
// check room is temperory inactive
// check active room disabled for the requested dates
$sql[] = 'SELECT hri.`id` AS `id_room`, hri.`id_product`, hri.`id_hotel`, hri.`room_num`, hri.`comment` AS `room_comment`, hri.`id_status`, hrdd.`date_from` AS `date_from`, hrdd.`date_to` AS `date_to`
FROM `'._DB_PREFIX_.'htl_room_information` AS hri
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd. id_room = hri.`id`)
WHERE hri.`id_hotel`='.(int) $idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (
WHERE hri.`id_hotel`='.(int) $idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_ACTIVE .' AND (
(hrdd.`date_from` <= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR
(hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` <= \''.pSQL($dateTo).'\') OR
(hrdd.`date_from` >= \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` >= \''.pSQL($dateTo).'\') OR
@@ -782,11 +782,11 @@ class HotelBookingDetail extends ObjectModel
(`date_from` <= \''.pSQL($dateFrom).'\' AND `date_to` >= \''.pSQL($dateTo).'\')
)) AND IF('.(int)$idRoomType.' > 0, `id_product` = '.(int)$idRoomType.', 1) AND `id_product` IN ('.$allowedIdRoomTypes.')';
// Exclude temporary disable rooms
// Exclude active rooms disabled for the requested dates
$excludeRoomId['disabled'] = 'SELECT hri.`id` AS id_room
FROM `'._DB_PREFIX_.'htl_room_information` AS hri
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd.`id_room` = hri.`id`)
WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (hrdd.`date_from` < \''.pSql($dateTo).'\' AND hrdd.`date_to` > \''.pSql($dateFrom).'\') AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')';
WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_ACTIVE .' AND (hrdd.`date_from` < \''.pSql($dateTo).'\' AND hrdd.`date_to` > \''.pSql($dateFrom).'\') AND IF('.(int)$idRoomType.' > 0, hri.`id_product` = '.(int)$idRoomType.', 1) AND hri.`id_product` IN ('.$allowedIdRoomTypes.')';
// LOS Restriction. Also, Remember to check max LOS restriction is greater than zero
if ($applyLosRestriction) {
@@ -1113,7 +1113,7 @@ class HotelBookingDetail extends ObjectModel
FROM `'._DB_PREFIX_.'htl_room_information` AS hri
INNER JOIN `'._DB_PREFIX_.'htl_room_type` AS hrt ON (hrt.`id_product` = hri.`id_product`)
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` AS hrdd ON (hrdd.`id_room_type` = hri.`id_product` AND hrdd.`id_room` = hri.`id`)
WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_TEMPORARY_INACTIVE .' AND (
WHERE hri.`id_hotel`='.(int)$idHotel.' AND hri.`id_status` = '. HotelRoomInformation::STATUS_ACTIVE .' AND (
(hrdd.`date_from` <= \''.pSQL($dateFrom).'\' AND hrdd.`date_to` > \''.pSQL($dateFrom).'\' AND hrdd.`date_to` < \''.pSQL($dateTo).'\') OR
(hrdd.`date_from` > \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` >= \''.pSQL($dateTo).'\') OR
(hrdd.`date_from` > \''.pSQL($dateFrom).'\' AND hrdd.`date_from` < \''.pSQL($dateTo).'\' AND hrdd.`date_to` < \''.pSQL($dateTo).'\')

View File

@@ -121,7 +121,7 @@ class HotelRoomDisableDates extends ObjectModel
}
if (!count($disableDates)) {
$wkDateErrors[] = $hotelResModInstance->l('Please enter disable dates for status temporary disable.', 'HotelRoomDisableDates');
$wkDateErrors[] = $hotelResModInstance->l('Please enter disable dates.', 'HotelRoomDisableDates');
}
return $wkDateErrors;
@@ -140,7 +140,7 @@ class HotelRoomDisableDates extends ObjectModel
/**
* Disabled/maintenance room rows for the out-of-order report.
* Returns both scheduled disable-date entries AND permanently inactive rooms (STATUS_INACTIVE).
* Returns scheduled disable-date entries of active rooms AND permanently inactive rooms (STATUS_INACTIVE).
*
* @param array $params date_from, date_to, id_hotel, id_product, floor, id_lang
* @return array
@@ -179,7 +179,8 @@ class HotelRoomDisableDates extends ObjectModel
FROM `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
INNER JOIN `'._DB_PREFIX_.'htl_room_information` hri ON (hri.`id` = hrdd.`id_room`)
'.$sharedJoins.'
WHERE hrdd.`date_from` < "'.$dateTo.' 23:59:59"
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.'
AND hrdd.`date_from` < "'.$dateTo.' 23:59:59"
AND hrdd.`date_to` > "'.$dateFrom.' 00:00:00"'
.$floorFilter.$productFilter.$hotelRestriction.'

View File

@@ -35,7 +35,6 @@ class HotelRoomInformation extends ObjectModel
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 2;
const STATUS_TEMPORARY_INACTIVE = 3;
const STATUS_SEARCH_LOS_UNSATISFIED = 4;
const STATUS_SEARCH_OCCUPANCY_UNSATISFIED = 5;
@@ -153,10 +152,6 @@ class HotelRoomInformation extends ObjectModel
'id' => HotelRoomInformation::STATUS_INACTIVE,
'status' => self::getRoomStatusTitle(HotelRoomInformation::STATUS_INACTIVE)
),
'STATUS_TEMPORARY_INACTIVE' => array(
'id' => HotelRoomInformation::STATUS_TEMPORARY_INACTIVE,
'status' => self::getRoomStatusTitle(HotelRoomInformation::STATUS_TEMPORARY_INACTIVE)
),
);
return $status;
}
@@ -167,7 +162,6 @@ class HotelRoomInformation extends ObjectModel
$status = array(
HotelRoomInformation::STATUS_ACTIVE => $moduleInstance->l('Active', 'hotelreservationsystem'),
HotelRoomInformation::STATUS_INACTIVE => $moduleInstance->l('Inactive', 'hotelreservationsystem'),
HotelRoomInformation::STATUS_TEMPORARY_INACTIVE => $moduleInstance->l('Temporarily Inactive', 'hotelreservationsystem'),
HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED => $moduleInstance->l('Length of stay restriction not satisfied', 'hotelreservationsystem'),
HotelRoomInformation::STATUS_SEARCH_OCCUPANCY_UNSATISFIED => $moduleInstance->l('Occupancy exceeds room capacity', 'hotelreservationsystem'),
);
@@ -353,7 +347,7 @@ class HotelRoomInformation extends ObjectModel
$roomTypes = Db::getInstance()->executeS(
'SELECT hri.`id_product`, pl.`name` AS room_type_name,
COUNT(hri.`id`) AS total_rooms,
SUM(CASE WHEN hri.`id_status` IN ('.(int) self::STATUS_INACTIVE.','.(int) self::STATUS_TEMPORARY_INACTIVE.') THEN 1 ELSE 0 END) AS ooo_rooms
SUM(CASE WHEN hri.`id_status` = '.(int) self::STATUS_INACTIVE.' THEN 1 ELSE 0 END) AS ooo_rooms
FROM `'._DB_PREFIX_.'htl_room_information` hri
INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hri.`id_product` AND p.`active` = 1)
INNER JOIN `'._DB_PREFIX_.'product_lang` pl
@@ -385,6 +379,22 @@ class HotelRoomInformation extends ObjectModel
$bookingsByProduct[$b['id_product']][] = $b;
}
// Active rooms blocked by a disable date range (inactive rooms are already counted as out of order)
$disabledRaw = Db::getInstance()->executeS(
'SELECT hri.`id_product`, hrdd.`id_room`, hrdd.`date_from`, hrdd.`date_to`
FROM `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
INNER JOIN `'._DB_PREFIX_.'htl_room_information` hri ON (hri.`id` = hrdd.`id_room`)
WHERE hri.`id_status` = '.(int) self::STATUS_ACTIVE.'
AND hrdd.`date_from` < "'.$dateToNext.'" AND hrdd.`date_to` > "'.$dateFrom.'"'
.HotelBranchInformation::addHotelRestriction($idsHotel, 'hri')
.($idProduct ? ' AND hri.`id_product` = '.$idProduct : '')
);
$disabledByProduct = array();
foreach ($disabledRaw as $d) {
$disabledByProduct[$d['id_product']][] = $d;
}
$result = array();
$current = $dateFrom;
while ($current <= $dateTo) {
@@ -399,9 +409,17 @@ class HotelRoomInformation extends ObjectModel
}
}
}
$disabledRooms = array();
if (isset($disabledByProduct[$idProd])) {
foreach ($disabledByProduct[$idProd] as $d) {
if ($d['date_from'] < $next && $d['date_to'] > $current) {
$disabledRooms[$d['id_room']] = true;
}
}
}
$booked = count($bookedRooms);
$total = (int) $rt['total_rooms'];
$ooo = (int) $rt['ooo_rooms'];
$ooo = (int) $rt['ooo_rooms'] + count($disabledRooms);
$available = max(0, $total - $booked - $ooo);
$result[] = array(
'date' => $current,
@@ -441,10 +459,8 @@ class HotelRoomInformation extends ObjectModel
return Db::getInstance()->executeS(
'SELECT hri.`id` AS id_room, hri.`room_num`, hri.`floor`,
CASE WHEN hri.`id_status` = '.(int) self::STATUS_TEMPORARY_INACTIVE.' AND hrdd.`id_room` IS NULL
THEN '.(int) self::STATUS_ACTIVE.'
ELSE hri.`id_status`
END AS id_status,
hri.`id_status`,
IF(hri.`id_status` = '.(int) self::STATUS_ACTIVE.' AND hrdd.`id_room` IS NOT NULL, 1, 0) AS is_disabled,
hri.`id_product`, hri.`id_hotel`,
pl.`name` AS room_type_name, hbil.`hotel_name`,
bkgs.`id_order`, bkgs.`date_from`, bkgs.`date_to`,

View File

@@ -177,23 +177,21 @@ class HotelRoomType extends ObjectModel
$objHRInformation->comment = $room['comment'];
if ($objHRInformation->save()) {
$idRoom = $objHRInformation->id;
if ((int)$room['id_status'] === (int)HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = Db::getInstance()->executeS(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
WHERE hrdd.`id_room` = '.(int)$room['id']
);
$disableDates = Db::getInstance()->executeS(
'SELECT * FROM `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
WHERE hrdd.`id_room` = '.(int)$room['id']
);
if (is_array($disableDates) && count($disableDates)) {
foreach ($disableDates as $disableDate) {
$objHRDisableDates = new HotelRoomDisableDates();
$objHRDisableDates->id_room_type = $idHotelRoomTypeNew;
$objHRDisableDates->id_room = $idRoom;
$objHRDisableDates->date_from = $disableDate['date_from'];
$objHRDisableDates->date_to = $disableDate['date_to'];
$objHRDisableDates->reason = $disableDate['reason'];
if (!$objHRDisableDates->save()) {
return false;
}
if (is_array($disableDates) && count($disableDates)) {
foreach ($disableDates as $disableDate) {
$objHRDisableDates = new HotelRoomDisableDates();
$objHRDisableDates->id_room_type = $idHotelRoomTypeNew;
$objHRDisableDates->id_room = $idRoom;
$objHRDisableDates->date_from = $disableDate['date_from'];
$objHRDisableDates->date_to = $disableDate['date_to'];
$objHRDisableDates->reason = $disableDate['reason'];
if (!$objHRDisableDates->save()) {
return false;
}
}
}

View File

@@ -386,7 +386,7 @@ class HotelReservationSystem extends Module
// delete the feature prices of the room type
HotelRoomTypeFeaturePricing::deleteFeaturePrices(false, $idProduct);
// delete the disable dates (temporary inactive status) of the room type
// delete the disable dates of the room type
$objRoomDisableDates = new HotelRoomDisableDates();
$objRoomDisableDates->deleteRoomDisableDatesByIdRoomType($idProduct);
}

View File

@@ -265,7 +265,7 @@
<tr>
<th><span class="title_box">{l s='%s No.' sprintf=$book_v['selling_object_name'] mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Status' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Duration' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Disable date duration' mod='hotelreservationsystem'}</span></th>
<th><span class="title_box">{l s='Message' mod='hotelreservationsystem'}</span></th>
</tr>
</thead>

View File

@@ -561,8 +561,8 @@ class QloHotelReports extends Module
)),
'room_statuses' => array(
HotelRoomInformation::STATUS_INACTIVE => array('label' => $this->l('Out of Order'), 'class' => 'label-default'),
HotelRoomInformation::STATUS_TEMPORARY_INACTIVE => array('label' => $this->l('Under Maintenance'), 'class' => 'label-warning'),
),
'maintenance_status' => array('label' => $this->l('Under Maintenance'), 'class' => 'label-warning'),
'filter_base_url' => $filterBaseUrl,
'export_url' => $filterBaseUrl
. '&id_product=' . $idProduct
@@ -657,10 +657,7 @@ class QloHotelReports extends Module
foreach ($allRooms as $room) {
if ($room['id_order']) {
$kpiOccupied++;
} elseif (in_array((int) $room['id_status'], array(
HotelRoomInformation::STATUS_INACTIVE,
HotelRoomInformation::STATUS_TEMPORARY_INACTIVE,
))) {
} elseif ((int) $room['id_status'] === HotelRoomInformation::STATUS_INACTIVE || !empty($room['is_disabled'])) {
$kpiOutOfOrder++;
}
}
@@ -849,8 +846,8 @@ class QloHotelReports extends Module
)),
'room_statuses' => array(
HotelRoomInformation::STATUS_INACTIVE => array('label' => $this->l('Out of Order'), 'class' => 'label-default'),
HotelRoomInformation::STATUS_TEMPORARY_INACTIVE => array('label' => $this->l('Under Maintenance'), 'class' => 'label-warning'),
),
'maintenance_status' => array('label' => $this->l('Under Maintenance'), 'class' => 'label-warning'),
'export_url' => $filterBaseUrl
. ($floor ? '&floor=' . urlencode($floor) : '')
. '&export=1',
@@ -1420,8 +1417,7 @@ class QloHotelReports extends Module
foreach ($rows as $row) {
if ($row['id_order']) {
$statusLabel = $this->l('Occupied');
} elseif ((int) $row['id_status'] === HotelRoomInformation::STATUS_INACTIVE
|| (int) $row['id_status'] === HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
} elseif ((int) $row['id_status'] === HotelRoomInformation::STATUS_INACTIVE || !empty($row['is_disabled'])) {
$statusLabel = $this->l('Under Maintenance');
} else {
$statusLabel = $this->l('Vacant');

View File

@@ -273,6 +273,8 @@
<td class="text-center">
{if $room.id_order}
<span class="label label-danger">{l s='Occupied' mod='qlohotelreports'}</span>
{elseif $room.is_disabled}
<span class="label {$maintenance_status.class|escape:'html':'UTF-8'}">{$maintenance_status.label|escape:'html':'UTF-8'}</span>
{elseif isset($room_statuses[$room.id_status])}
<span class="label {$room_statuses[$room.id_status].class|escape:'html':'UTF-8'}">{$room_statuses[$room.id_status].label|escape:'html':'UTF-8'}</span>
{else}

View File

@@ -234,6 +234,8 @@
<td class="text-center">
{if isset($room_statuses[$outOfOrderRow.id_status])}
<span class="label {$room_statuses[$outOfOrderRow.id_status].class|escape:'html':'UTF-8'}">{$room_statuses[$outOfOrderRow.id_status].label|escape:'html':'UTF-8'}</span>
{elseif $outOfOrderRow.disabled_from}
<span class="label {$maintenance_status.class|escape:'html':'UTF-8'}">{$maintenance_status.label|escape:'html':'UTF-8'}</span>
{/if}
</td>
<td>{if $outOfOrderRow.reason}{$outOfOrderRow.reason|escape:'html':'UTF-8'}{else}&mdash;{/if}</td>

View File

@@ -174,7 +174,7 @@ class StatsBestCategories extends ModuleGrid
SELECT hri.`id_hotel`, DATEDIFF("'.pSQL($date_to).'", "'.pSQL($date_from).'") AS max_room_nights,
CASE
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_INACTIVE.' THEN DATEDIFF("'.pSQL($date_to).'", "'.pSQL($date_from).'")
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.' THEN IF(hrdd.`date_to` > "'.pSQL($date_from).'" AND hrdd.`date_from` < "'.pSQL($date_to).'", SUM(ABS(DATEDIFF(LEAST(hrdd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hrdd.`date_from`, "'.pSQL($date_from).'")))), 0)
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.' THEN IF(hrdd.`date_to` > "'.pSQL($date_from).'" AND hrdd.`date_from` < "'.pSQL($date_to).'", SUM(ABS(DATEDIFF(LEAST(hrdd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hrdd.`date_from`, "'.pSQL($date_from).'")))), 0)
ELSE 0
END AS disabled_room_nights
FROM `'._DB_PREFIX_.'htl_room_information` hri

View File

@@ -195,7 +195,7 @@ class StatsBestProducts extends ModuleGrid
SELECT hri.`id_product`, DATEDIFF("'.pSQL($date_to).'", "'.pSQL($date_from).'") AS max_room_nights,
CASE
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_INACTIVE.' THEN DATEDIFF("'.pSQL($date_to).'", "'.pSQL($date_from).'")
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.' THEN IF(hrdd.`date_to` > "'.pSQL($date_from).'" AND hrdd.`date_from` < "'.pSQL($date_to).'", SUM(ABS(DATEDIFF(LEAST(hrdd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hrdd.`date_from`, "'.pSQL($date_from).'")))), 0)
WHEN hri.`id_status` = '.(int) HotelRoomInformation::STATUS_ACTIVE.' THEN IF(hrdd.`date_to` > "'.pSQL($date_from).'" AND hrdd.`date_from` < "'.pSQL($date_to).'", SUM(ABS(DATEDIFF(LEAST(hrdd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hrdd.`date_from`, "'.pSQL($date_from).'")))), 0)
ELSE 0
END AS disabled_room_nights
FROM `'._DB_PREFIX_.'htl_room_information` hri