Merge branch 'develop' into edit-order-services
This commit is contained in:
@@ -612,10 +612,24 @@ class AdminCartsControllerCore extends AdminController
|
||||
$cart_detail_data = array();
|
||||
$cart_detail_data_obj = new HotelCartBookingData();
|
||||
$cart_detail_data_obj->updateIdCurrencyByIdCart($id_cart, $currency->id);
|
||||
$cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart((int) $id_cart);
|
||||
|
||||
if ($cart_detail_data = $cart_detail_data_obj->getCartFormatedBookinInfoByIdCart((int) $id_cart)) {
|
||||
$objRoomType = new HotelRoomType();
|
||||
foreach ($cart_detail_data as $key => $cart_data) {
|
||||
|
||||
$cart_detail_data[$key]['room_type_info'] = $objRoomType->getRoomTypeInfoByIdProduct($cart_data['id_product']);
|
||||
}
|
||||
}
|
||||
$occupancyRequiredForBooking = false;
|
||||
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
$occupancyRequiredForBooking = true;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'cart_detail_data' => $cart_detail_data,
|
||||
'currency' => new Currency((int)$this->context->cart->id_currency),
|
||||
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
|
||||
'ajax' => true
|
||||
));
|
||||
|
||||
$tpl_path = 'default/template/controllers/orders/_current_cart_details_data.tpl';
|
||||
@@ -1171,19 +1185,80 @@ class AdminCartsControllerCore extends AdminController
|
||||
// Process when admin changes extra demands of any room while order creation process form.tpl
|
||||
public function ajaxProcessChangeRoomDemands()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
|
||||
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
|
||||
$roomDemands = Tools::getValue('room_demands');
|
||||
$roomDemands = json_decode($roomDemands, true);
|
||||
$roomDemands = json_encode($roomDemands);
|
||||
$objCartbookingCata->extra_demands = $roomDemands;
|
||||
if ($objCartbookingCata->save()) {
|
||||
$response['status'] = true;
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$response = array('status' => false);
|
||||
if ($idCartBooking = Tools::getValue('id_cart_booking')) {
|
||||
if (Validate::isLoadedObject($objCartbookingCata = new HotelCartBookingData($idCartBooking))) {
|
||||
$roomDemands = Tools::getValue('room_demands');
|
||||
$roomDemands = json_decode($roomDemands, true);
|
||||
$roomDemands = json_encode($roomDemands);
|
||||
$objCartbookingCata->extra_demands = $roomDemands;
|
||||
if ($objCartbookingCata->save()) {
|
||||
$response['status'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdateServiceProduct()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$operator = Tools::getValue('operator', 'up');
|
||||
$idServiceProduct = Tools::getValue('id_product');
|
||||
$idCartBooking = Tools::getValue('id_cart_booking');
|
||||
$qty = Tools::getValue('qty');
|
||||
|
||||
if (Validate::isLoadedObject($objHotelCartBookingData = new HotelCartBookingData($idCartBooking))) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
|
||||
if ($operator == 'up') {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($objHotelCartBookingData->id_product, $idServiceProduct)) {
|
||||
// validate quanitity
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idServiceProduct))) {
|
||||
if ($objProduct->allow_multiple_quantity) {
|
||||
if (!Validate::isUnsignedInt($qty)) {
|
||||
$this->errors[] = Tools::displayError('The quantity code you\'ve entered is invalid.');
|
||||
// } elseif ($objProduct->max_quantity && $qty > $objProduct->max_quantity) {
|
||||
// $this->errors[] = Tools::displayError(sprintf('cannot add more than %d quantity.', $objProduct->max_quantity));
|
||||
}
|
||||
} else {
|
||||
$qty = 1;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This Service is not available.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('This Service is not available with selected room.');
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
if ($objRoomTypeServiceProductCartDetail->updateCartServiceProduct(
|
||||
$idCartBooking,
|
||||
$idServiceProduct,
|
||||
$qty,
|
||||
$objHotelCartBookingData->id_cart,
|
||||
$operator
|
||||
)) {
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => false
|
||||
)));
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Unable to update services. Please try reloading the page.');
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Room not found. Please try reloading the page.');
|
||||
}
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
)));
|
||||
}
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public static function getOrderTotalUsingTaxCalculationMethod($id_cart)
|
||||
|
||||
Reference in New Issue
Block a user