Updated the fuction checkIfRoomAlreadyDisabled(), to check if the room is disabled for any day in the given date
This commit is contained in:
@@ -5188,22 +5188,22 @@ class AdminOrdersControllerCore extends AdminController
|
||||
} elseif (trim(date('Y-m-d', strtotime($product_informations['date_from']))) == '') {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please Enter Check In Date.'),
|
||||
'error' => Tools::displayError('Please enter check-in date.'),
|
||||
)));
|
||||
} elseif (!Validate::isDateFormat($new_date_from)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please Enter a Valid Check In Date.'),
|
||||
'error' => Tools::displayError('Please enter a valid check-in date.'),
|
||||
)));
|
||||
} elseif ($new_date_to == '') {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please Enter Check Out Date.'),
|
||||
'error' => Tools::displayError('Please enter check-out date.'),
|
||||
)));
|
||||
} elseif (!Validate::isDateFormat($new_date_to)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please Enter a valid Check out Date.'),
|
||||
'error' => Tools::displayError('Please enter a valid check-out date.'),
|
||||
)));
|
||||
}
|
||||
if ($this->context->employee->isSuperAdmin()) {
|
||||
@@ -5216,14 +5216,14 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($new_date_from < $compareDate) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => sprintf(Tools::displayError('Check In date should not be date before %s.'),$compareDate)
|
||||
'error' => sprintf(Tools::displayError('Check-in date should not be date before %s.'),$compareDate)
|
||||
)));
|
||||
}
|
||||
}
|
||||
if ($new_date_to <= $new_date_from) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Check out Date Should be after Check In date.'),
|
||||
'error' => Tools::displayError('Check-out date should be after check-in date.'),
|
||||
)));
|
||||
} elseif (!Validate::isUnsignedInt($product_quantity)) {
|
||||
die(json_encode(array(
|
||||
@@ -5236,7 +5236,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
if ($rooms_booked) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('This Room is Unavailable For Selected Duration.'),
|
||||
'error' => Tools::displayError('This room is unavailable for selected duration.'),
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -5246,10 +5246,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'date_from' => $new_date_from,
|
||||
'date_to' => $new_date_to
|
||||
);
|
||||
if ($objHotelRoomDisableDates->checkIfRoomAlreadyDisabledInDateRange($params)) {
|
||||
if ($objHotelRoomDisableDates->checkIfRoomAlreadyDisabled($params)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('This Room is Disabled in Selected Duration.'),
|
||||
'error' => Tools::displayError('This room is disabled in selected duration.'),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class HotelRoomDisableDates extends ObjectModel
|
||||
|
||||
public function checkIfRoomAlreadyDisabled($params)
|
||||
{
|
||||
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room` = '.(int)$params['id_room'].' AND `date_from` <= \''.pSQL($params['date_from']).'\' AND `date_to` >= \''.pSQL($params['date_to']).'\'');
|
||||
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room` = '.(int)$params['id_room'].' AND `date_from` < \''.pSQL($params['date_to']).'\' AND `date_to` > \''.pSQL($params['date_from']).'\'');
|
||||
}
|
||||
|
||||
public function updateDisableDateRanges($params)
|
||||
@@ -119,16 +119,4 @@ class HotelRoomDisableDates extends ObjectModel
|
||||
return Db::getInstance()->delete('htl_room_disable_dates', '`id_room_type`='.(int)$idRoomType);
|
||||
}
|
||||
|
||||
public function checkIfRoomAlreadyDisabledInDateRange($params)
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT `id` FROM `'._DB_PREFIX_.'htl_room_disable_dates`
|
||||
WHERE `id_room` = '.(int)$params['id_room'].'
|
||||
AND (
|
||||
`date_from` BETWEEN \''.pSQL($params['date_from']).'\' AND \''.pSQL($params['date_to']).'\'
|
||||
OR `date_to` BETWEEN \''.pSQL($params['date_from']).'\' AND \''.pSQL($params['date_to']).'\'
|
||||
)'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user