Allow updating same day checkin and checkout in room status

This commit is contained in:
Shreesh Arora
2023-09-27 11:43:10 +05:30
parent ce93a9826f
commit 6d9d4e97d1

View File

@@ -5437,7 +5437,7 @@ class AdminOrdersControllerCore extends AdminController
} elseif ((strtotime($statusDate) < strtotime($dateFrom))
|| (strtotime($statusDate) > strtotime($dateTo))
) {
$this->errors[] = Tools::displayError('Invalid dates found.');
$this->errors[] = Tools::displayError('Date should be between booking from date and to date.');
}
}
@@ -5445,27 +5445,17 @@ class AdminOrdersControllerCore extends AdminController
$objBookingDetail = new HotelBookingDetail();
if ($roomBookingInfo = $objBookingDetail->getRoomBookingData($idRoom, $idOrder, $dateFrom, $dateTo)) {
// if admin choose Check-Out status
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT
&& $roomBookingInfo['check_in'] == '0000-00-00 00:00:00'
) {
$this->errors[] = Tools::displayError('Room status must be set to Check-In before setting the room status to Check-Out.');
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT
&& $roomBookingInfo['check_in'] != '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_in']) >= strtotime($statusDate)
) {
$this->errors[] = Tools::displayError('Check-Out date can not be before Check-In date').
'('.date('d-m-Y', strtotime($roomBookingInfo['check_in'])).')';
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN && $roomBookingInfo['check_out'] == '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_in']) >= strtotime($dateTo)
) {
$this->errors[] = Tools::displayError('Check-In date can not be after Check-Out date').
'('.date('d-m-Y', strtotime($roomBookingInfo['date_to'])).')';
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN && $roomBookingInfo['check_out'] != '0000-00-00 00:00:00'
&& strtotime($roomBookingInfo['check_out']) <= strtotime($statusDate)
) {
$this->errors[] = Tools::displayError('Check-In date can not be after Check-Out date').
'('.date('d-m-Y', strtotime($roomBookingInfo['check_out'])).')';
} else {
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
if ($roomBookingInfo['check_in'] == '0000-00-00 00:00:00') {
$this->errors[] = Tools::displayError('Room status must be set to Check-In before setting the room status to Check-Out.');
} elseif (strtotime($roomBookingInfo['check_in']) > strtotime($statusDate)) {
$this->errors[] = sprintf(
Tools::displayError('Check-Out date can not be before Check-In date (%s)'),
date('d-m-Y', strtotime($roomBookingInfo['check_in']))
);
}
}
if (empty($this->errors)) {
if ($objBookingDetail->updateBookingOrderStatusByOrderId(
$idOrder,
$newStatus,