Updated the conditions checked while updating the booking status of a room
This commit is contained in:
@@ -7173,8 +7173,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|| (strtotime($statusDate) > strtotime($dateTo))
|
||||
) {
|
||||
$this->errors[] = Tools::displayError('Date should be between booking from date and to date.');
|
||||
} else if (date('Y-m-d', strtotime($objHotelBookingDetail->check_out)) != date('Y-m-d', strtotime($objHotelBookingDetail->date_to))
|
||||
&& ($booked = $objHotelBookingDetail->chechRoomBooked($objHotelBookingDetail->id_room, $objHotelBookingDetail->check_out, $objHotelBookingDetail->date_to))
|
||||
}
|
||||
}
|
||||
|
||||
if ($objHotelBookingDetail->id_status == HotelBookingDetail::STATUS_CHECKED_OUT
|
||||
&& (date('Y-m-d', strtotime($objHotelBookingDetail->check_out)) != date('Y-m-d', strtotime($objHotelBookingDetail->date_to)))
|
||||
&& ($booking = $objHotelBookingDetail->chechRoomBooked($objHotelBookingDetail->id_room, $objHotelBookingDetail->check_out, $objHotelBookingDetail->date_to))
|
||||
) {
|
||||
if ($booking['id_status'] != HotelBookingDetail::STATUS_CHECKED_OUT
|
||||
|| date('Y-m-d', strtotime($booking['check_out'])) > date('Y-m-d', strtotime($objHotelBookingDetail->date_from))
|
||||
) {
|
||||
$this->errors[] = Tools::displayError('You cannot update this room\'s booking status as a new booking has been created for this room. Please change the room to update the status.');
|
||||
}
|
||||
|
||||
@@ -1419,7 +1419,8 @@ 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`, `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`,
|
||||
`check_out`, `check_in`, `id_status`
|
||||
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).
|
||||
@@ -1431,6 +1432,8 @@ class HotelBookingDetail extends ObjectModel
|
||||
$sql .= ' AND `id` !='.(int) $this->id;
|
||||
}
|
||||
|
||||
$sql .= ' ORDER BY `date_add` DESC';
|
||||
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user