Merge pull request #568 from abhishek-webkul/gli-1224
Fix room add/edit issue on order from back office
This commit is contained in:
@@ -2695,10 +2695,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->context->cart = $cart;
|
||||
$this->context->customer = new Customer($order->id_customer);
|
||||
|
||||
if ($order->with_occupancy) {
|
||||
$objRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($id_product);
|
||||
}
|
||||
/*By Webkul to make entries in HotelCartBookingData */
|
||||
$hotel_room_info_arr = $hotel_room_data['rm_data'][$idProduct]['data']['available'];
|
||||
$chkQty = 0;
|
||||
@@ -2724,8 +2720,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objCartBookingData->children = $room_occupancy['children'];
|
||||
$objCartBookingData->child_ages = $room_occupancy['children'] ? json_encode($room_occupancy['child_ages']) : json_encode(array());
|
||||
} else {
|
||||
$objCartBookingData->adults = $roomTypeInfo['adults'];
|
||||
$objCartBookingData->children = $roomTypeInfo['children'];
|
||||
$objCartBookingData->adults = $room_info_by_id_product['adults'];
|
||||
$objCartBookingData->children = $room_info_by_id_product['children'];
|
||||
$objCartBookingData->child_ages = json_encode(array());
|
||||
}
|
||||
$objCartBookingData->save();
|
||||
@@ -3247,10 +3243,12 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to);
|
||||
$old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to);
|
||||
$qty_diff = $product_quantity - $old_product_quantity;
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
if ($order->with_occupancy) {
|
||||
$occupancy = array_shift(Tools::getValue('occupancy'));
|
||||
$adults = $occupancy['adults'];
|
||||
$children = $occupancy['children'];
|
||||
$child_ages = $occupancy['child_ages'];
|
||||
}
|
||||
|
||||
/*By webkul to validate fields before deleting the cart and order data form the tables*/
|
||||
if ($id_hotel == '') {
|
||||
@@ -3308,30 +3306,36 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid quantity.'),
|
||||
)));
|
||||
} elseif (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of adults.'),
|
||||
)));
|
||||
} elseif (!Validate::isUnsignedInt($children)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of children.'),
|
||||
)));
|
||||
}
|
||||
if ($children > 0) {
|
||||
if (!isset($child_ages) || ($children != count($child_ages))) {
|
||||
|
||||
// validations if order is with occupancy
|
||||
if ($order->with_occupancy) {
|
||||
if (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please provide all children age.'),
|
||||
'error' => Tools::displayError('Invalid number of adults.'),
|
||||
)));
|
||||
} else {
|
||||
foreach($child_ages as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid children age.'),
|
||||
)));
|
||||
} elseif (!Validate::isUnsignedInt($children)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid number of children.'),
|
||||
)));
|
||||
}
|
||||
|
||||
if ($children > 0) {
|
||||
if (!isset($child_ages) || ($children != count($child_ages))) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Please provide all children age.'),
|
||||
)));
|
||||
} else {
|
||||
foreach($child_ages as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('Invalid children age.'),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user