Merge pull request #786 from abhishek-webkul/gli-1468
Fixed: PHP warning on removing room from cart dropdown at front office
This commit is contained in:
@@ -319,25 +319,23 @@ class CartControllerCore extends FrontController
|
||||
$serviceProducts = json_decode(Tools::getValue('serviceProducts'),true);
|
||||
|
||||
// valdiate occupancy if providede
|
||||
if ($operator == 'up') {
|
||||
if ($occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if (!isset($roomOccupancy['adults']) || !$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
|
||||
if ($operator == 'up' && $occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if (!isset($roomOccupancy['adults']) || !$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
|
||||
}
|
||||
if (isset($roomOccupancy['children'])) {
|
||||
if (!Validate::isUnsignedInt($roomOccupancy['children'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of children for Room %s.'), ($key + 1));
|
||||
}
|
||||
if (isset($roomOccupancy['children'])) {
|
||||
if (!Validate::isUnsignedInt($roomOccupancy['children'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of children for Room %s.'), ($key + 1));
|
||||
}
|
||||
if ($roomOccupancy['children'] > 0) {
|
||||
if (!isset($roomOccupancy['child_ages']) || ($roomOccupancy['children'] != count($roomOccupancy['child_ages'])) || !is_array($roomOccupancy['child_ages'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Please provide all children age for Room %s.'), ($key + 1));
|
||||
} else {
|
||||
if (is_array($roomOccupancy['child_ages'])) {
|
||||
foreach($roomOccupancy['child_ages'] as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid children age for Room %s.'), ($key + 1));
|
||||
}
|
||||
if ($roomOccupancy['children'] > 0) {
|
||||
if (!isset($roomOccupancy['child_ages']) || ($roomOccupancy['children'] != count($roomOccupancy['child_ages'])) || !is_array($roomOccupancy['child_ages'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Please provide all children age for Room %s.'), ($key + 1));
|
||||
} else {
|
||||
if (is_array($roomOccupancy['child_ages'])) {
|
||||
foreach($roomOccupancy['child_ages'] as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid children age for Room %s.'), ($key + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,6 +343,20 @@ class CartControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if ($roomOccupancy['adults'] > $roomTypeInfo['max_adults']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);
|
||||
}
|
||||
if ($roomOccupancy['children'] > $roomTypeInfo['max_children']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have children more than %s'), $key + 1, $roomTypeInfo['max_children']);
|
||||
}
|
||||
if ($roomOccupancy['adults'] + $roomOccupancy['children'] > $roomTypeInfo['max_guests']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have total guests more than %s'), $key + 1, $roomTypeInfo['max_guests']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_hotel = $roomTypeInfo['id_hotel']) {
|
||||
@@ -361,19 +373,7 @@ class CartControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('You can\'t book room after date '.$maxOrdDate);
|
||||
}
|
||||
}
|
||||
if ($occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if ($roomOccupancy['adults'] > $roomTypeInfo['max_adults']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);
|
||||
}
|
||||
if ($roomOccupancy['children'] > $roomTypeInfo['max_children']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have children more than %s'), $key + 1, $roomTypeInfo['max_children']);
|
||||
}
|
||||
if ($roomOccupancy['adults'] + $roomOccupancy['children'] > $roomTypeInfo['max_guests']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have total guests more than %s'), $key + 1, $roomTypeInfo['max_guests']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->errors) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$num_days = $objBookingDetail->getNumberOfDays($date_from, $date_to);
|
||||
|
||||
Reference in New Issue
Block a user