Conflicts resolved
This commit is contained in:
@@ -44,6 +44,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
protected $statuses_array = array();
|
||||
protected $all_order_sources = array();
|
||||
protected $hotelsArray = array();
|
||||
protected $roomTypesArray = array();
|
||||
protected $roomsArray = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -73,7 +76,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
\' '.$this->l('Adult(s)').' \',
|
||||
IF(SUM(hbd.`children`), CONCAT(SUM(hbd.`children`), \' '.$this->l('Children').'\'), \'\')
|
||||
) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order`) as total_guests,
|
||||
(SELECT SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order`) as los';
|
||||
(SELECT SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order`) as los,
|
||||
hbd.`id_room` AS id_room_information';
|
||||
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||||
@@ -97,6 +101,32 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->all_order_sources[$source['source']] = $source['source'];
|
||||
}
|
||||
|
||||
$hotelsArray = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1);
|
||||
foreach ($hotelsArray as $hotel) {
|
||||
$addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']);
|
||||
$this->hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city'];
|
||||
}
|
||||
|
||||
$roomTypesArray = array();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
foreach ($hotelsArray as $hotel) {
|
||||
$hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($hotel['id_hotel'], $this->context->language->id);
|
||||
foreach ($hotelRoomTypes as $room_type) {
|
||||
$this->roomTypesArray[$room_type['id_product']] = $room_type['room_type'].', '.$hotel['hotel_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$roomsArray = array();
|
||||
$hotelRooms = HotelRoomInformation::getHotelRoomsInfo();
|
||||
foreach ($hotelRooms as $hotelRoom) {
|
||||
$this->roomsArray[$hotelRoom['id']] = $hotelRoom['room_num'].', '.$hotelRoom['room_type_name'].', '.$hotelRoom['hotel_name'];
|
||||
}
|
||||
|
||||
$orderCurrencies = Db::getInstance()->executeS('SELECT DISTINCT(`id_currency`) FROM `'._DB_PREFIX_.'orders`');
|
||||
foreach ($orderCurrencies as $orderCurrency) {
|
||||
$this->orderCurrenciesArray[$orderCurrency['id_currency']] = Currency::getCurrencyInstance($orderCurrency['id_currency'])->name;
|
||||
}
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_order' => array(
|
||||
'title' => $this->l('ID'),
|
||||
@@ -112,20 +142,38 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'optional' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'order_source' => array(
|
||||
'title' => $this->l('Order Source'),
|
||||
'type' => 'select',
|
||||
'filter_key' => 'a!source',
|
||||
'list' => $this->all_order_sources,
|
||||
'optional' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'hotel_name' => array(
|
||||
'title' => $this->l('Hotel'),
|
||||
'filter_key' => 'hbil!hotel_name',
|
||||
'type' => 'select',
|
||||
'filter_key' => 'hbd!id_hotel',
|
||||
'list' => $this->hotelsArray,
|
||||
'optional' => true,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'room_type_name' => array(
|
||||
'title' => $this->l('Room type'),
|
||||
'type' => 'select',
|
||||
'filter_key' => 'hbd!id_product',
|
||||
'list' => $this->roomTypesArray,
|
||||
'optional' => false,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => false,
|
||||
'displayed' => false,
|
||||
),
|
||||
'id_room_information' => array(
|
||||
'title' => $this->l('Rooms'),
|
||||
'type' => 'select',
|
||||
'filter_key' => 'hbd!id_room',
|
||||
'list' => $this->roomsArray,
|
||||
'optional' => false,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => false,
|
||||
'displayed' => false,
|
||||
),
|
||||
'date_from' => array(
|
||||
'title' => $this->l('Check-in'),
|
||||
'filter_key' => 'hbd!date_from',
|
||||
@@ -138,12 +186,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'type'=>'date',
|
||||
'displayed' => false,
|
||||
),
|
||||
'room_type_name' => array(
|
||||
'title' => $this->l('Room type'),
|
||||
'filter_key' => 'hbd!room_type_name',
|
||||
'type'=>'text',
|
||||
'displayed' => false,
|
||||
),
|
||||
'total_guests' => array(
|
||||
'title' => $this->l('Guests'),
|
||||
'type' => 'range',
|
||||
@@ -178,18 +220,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$this->fields_list = array_merge($this->fields_list, array(
|
||||
'total_paid_tax_incl' => array(
|
||||
'title' => $this->l('Order Total'),
|
||||
'align' => 'text-right',
|
||||
'type' => 'range',
|
||||
'currency' => true,
|
||||
'callback' => 'setOrderCurrency',
|
||||
'badge_success' => true,
|
||||
),
|
||||
'amount_due' => array(
|
||||
'title' => $this->l('Due Amount'),
|
||||
'align' => 'text-right',
|
||||
'type' => 'range',
|
||||
'validation' => 'isFloat',
|
||||
'currency' => true,
|
||||
'havingFilter' => true,
|
||||
'callback' => 'setOrderCurrency',
|
||||
@@ -197,16 +232,45 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'optional' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'id_currency' => array(
|
||||
'title' => $this->l('Order Currency'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'or',
|
||||
'filter_key' => 'a!id_currency',
|
||||
'list' => $this->orderCurrenciesArray,
|
||||
'displayed' => false,
|
||||
),
|
||||
'total_paid_tax_incl' => array(
|
||||
'title' => $this->l('Order Total'),
|
||||
'align' => 'text-right',
|
||||
'type' => 'range',
|
||||
'validation' => 'isFloat',
|
||||
'currency' => true,
|
||||
'callback' => 'setOrderCurrency',
|
||||
'badge_success' => true,
|
||||
),
|
||||
'payment' => array(
|
||||
'title' => $this->l('Payment')
|
||||
),
|
||||
'order_source' => array(
|
||||
'title' => $this->l('Order Source'),
|
||||
'type' => 'select',
|
||||
'filter_key' => 'a!source',
|
||||
'list' => $this->all_order_sources,
|
||||
'optional' => true,
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => true
|
||||
),
|
||||
'osname' => array(
|
||||
'title' => $this->l('Status'),
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'or',
|
||||
'color' => 'color',
|
||||
'list' => $this->statuses_array,
|
||||
'filter_key' => 'os!id_order_state',
|
||||
'filter_type' => 'int',
|
||||
'order_key' => 'osname',
|
||||
'optional' => true,
|
||||
'visible_default' => true
|
||||
@@ -535,6 +599,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->tpl_list_vars['POST'] = $_POST;
|
||||
}
|
||||
|
||||
$this->tpl_list_vars['title'] = $this->l('Orders');
|
||||
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
@@ -716,7 +782,79 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('The new order status is invalid.');
|
||||
} else {
|
||||
$current_order_state = $order->getCurrentOrderState();
|
||||
if ($current_order_state->id != $order_state->id) {
|
||||
|
||||
if ($current_order_state->id == Configuration::get('PS_OS_REFUND')) {
|
||||
$this->errors[] = Tools::displayError('Order status can not be changed once order status is set to Refunded.');
|
||||
} elseif ($current_order_state->id == Configuration::get('PS_OS_CANCELED')) {
|
||||
$this->errors[] = Tools::displayError('Order status can not be changed once order status is set to Cancelled.');
|
||||
} elseif (in_array($order_state->id, array (Configuration::get('PS_OS_OVERBOOKING_PAID'), Configuration::get('PS_OS_OVERBOOKING_UNPAID'), Configuration::get('PS_OS_OVERBOOKING_PARTIAL_PAID')))) {
|
||||
$objHotelBooking = new HotelBookingDetail();
|
||||
if (!$objHotelBooking->getOverbookedRooms($order->id)) {
|
||||
$this->errors[] = Tools::displayError('Order status can not be changed to any overbooking status as there are no overbooked rooms in the order.');
|
||||
}
|
||||
} elseif ($order_state->id == Configuration::get('PS_OS_REFUND')
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)
|
||||
) {
|
||||
$this->errors[] = Tools::displayError('Order status can not be set to Refunded until all bookings in the order are completely refunded.');
|
||||
} elseif ($order_state->id == Configuration::get('PS_OS_CANCELED')
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)
|
||||
) {
|
||||
$this->errors[] = Tools::displayError('Order status can not be set to Cancelled until all bookings in the order are cancelled.');
|
||||
} elseif ($current_order_state->id == Configuration::get('PS_OS_ERROR') && !($order_state->id == Configuration::get('PS_OS_ERROR'))) {
|
||||
// All rooms must be available before changing status from Payment Error to Other status in which rooms are getting blocked again
|
||||
$objHotelBooking = new HotelBookingDetail();
|
||||
if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($order->id)) {
|
||||
foreach ($orderBookings as $orderBooking) {
|
||||
// If booking is refunded then no need to check inventory
|
||||
if ((OrderReturn::getOrdersReturnDetail($order->id, 0, $orderBooking['id']) && $orderBooking['is_refunded'])
|
||||
|| ($orderBooking['is_cancelled'] && $orderBooking['is_refunded'])
|
||||
) {
|
||||
continue;
|
||||
} else {
|
||||
// if inventory is available for that booking
|
||||
$bookingParams = array(
|
||||
'date_from' => $orderBooking['date_from'],
|
||||
'date_to' => $orderBooking['date_to'],
|
||||
'hotel_id' => $orderBooking['id_hotel'],
|
||||
'id_room_type' => $orderBooking['id_product'],
|
||||
'only_search_data' => 1
|
||||
);
|
||||
|
||||
$objHotelBookingDetail = new HotelBookingDetail($orderBooking['id']);
|
||||
if ($searchRoomsInfo = $objHotelBooking->getBookingData($bookingParams)) {
|
||||
if (isset($searchRoomsInfo['rm_data'][$orderBooking['id_product']]['data']['available'])
|
||||
&& $searchRoomsInfo['rm_data'][$orderBooking['id_product']]['data']['available']
|
||||
) {
|
||||
$availableRoomsInfo = $searchRoomsInfo['rm_data'][$orderBooking['id_product']]['data']['available'];
|
||||
if ($roomIdsAvailable = array_column($availableRoomsInfo, 'id_room')) {
|
||||
// Check If room is still there in the available rooms list
|
||||
if (!in_array($orderBooking['id_room'], $roomIdsAvailable)) {
|
||||
$this->errors[] = Tools::displayError('You can not change the order status as some rooms are not available now in this order. You can reallocate/swap rooms with other rooms to make rooms available and then change the order status.');
|
||||
|
||||
break;
|
||||
} else {
|
||||
$objHotelBookingDetail->is_refunded = 0;
|
||||
$objHotelBookingDetail->save();
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not change the order status as some rooms are not available now in this order. You can reallocate/swap rooms with other rooms to make rooms available and then change the order status.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You can not change the order status as some rooms are not available now in this order. You can reallocate/swap rooms with other rooms to make rooms available and then change the order status.');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($current_order_state->id == $order_state->id) {
|
||||
$this->errors[] = Tools::displayError('The order has already been assigned this status.');
|
||||
}
|
||||
|
||||
// If no errors then we change the order status
|
||||
if (!count($this->errors)) {
|
||||
// Create new OrderHistory
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = $order->id;
|
||||
@@ -742,11 +880,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$order->id.'&vieworder&token='.$this->token);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$order->id.'&conf=5&vieworder&token='.$this->token);
|
||||
}
|
||||
|
||||
$this->errors[] = Tools::displayError('An error occurred while changing order status, or we were unable to send an email to the customer.');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('The order has already been assigned this status.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -877,26 +1014,58 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = Configuration::get('PS_ORS_PENDING');
|
||||
$objOrderReturn->by_admin = 1;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
// if amount paid is > 0 then create refund request else cancel the booking directly
|
||||
if ($order->getTotalPaid() > 0) {
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = Configuration::get('PS_ORS_PENDING');
|
||||
$objOrderReturn->by_admin = 1;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
foreach ($bookings as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// cancel the booking directly
|
||||
foreach ($bookings as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
if (!$objHtlBooking->processRefundInBookingTables()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while cancelling the booking.');
|
||||
} else {
|
||||
// set the message for the cancellation
|
||||
$message = $this->l('Room').': '.$objHtlBooking->room_num.', '.$objHtlBooking->room_type_name.' '.$this->l('has been cancelled by the hotel.');
|
||||
$message .= PHP_EOL.$this->l('Reasonn').': '.$refundReason;
|
||||
$objHtlBooking->setBookingCancellationMessage($message, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// if all bookings are getting cancelled then cancel the order also
|
||||
if ($order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) {
|
||||
$objOrderHistory = new OrderHistory();
|
||||
$objOrderHistory->id_order = (int)$order->id;
|
||||
|
||||
$idOrderState = Configuration::get('PS_OS_CANCELED');
|
||||
|
||||
$useExistingPayment = false;
|
||||
if (!$order->hasInvoice()) {
|
||||
$useExistingPayment = true;
|
||||
}
|
||||
|
||||
$objOrderHistory->changeIdOrderState($idOrderState, $order, $useExistingPayment);
|
||||
$objOrderHistory->addWithemail();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1911,7 +2080,9 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'applicable_refund_policies' => $applicableRefundPolicies,
|
||||
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'hasCompletelyRefunded' => $order->hasCompletelyRefunded(),
|
||||
'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG),
|
||||
'allBookingsRefunded' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG),
|
||||
'allBookingsCancelled' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG),
|
||||
'refundedAmount' => $refundedAmount,
|
||||
'totalDemandsPriceTI' => $totalDemandsPriceTI,
|
||||
'totalDemandsPriceTE' => $totalDemandsPriceTE,
|
||||
@@ -2019,6 +2190,86 @@ class AdminOrdersControllerCore extends AdminController
|
||||
return $modal;
|
||||
}
|
||||
|
||||
public function ajaxProcessGetHotelRoomTypes()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$hotelRoomTypes = array();
|
||||
|
||||
if ($idHotel > 0) {
|
||||
$hotelRoomTypes = $objHotelRoomType->getRoomTypeByHotelId($idHotel, $this->context->language->id);
|
||||
|
||||
$objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id);
|
||||
foreach ($hotelRoomTypes as &$hotelRoomType) {
|
||||
$hotelRoomType['hotel_name'] = $objHotelBranchInformation->hotel_name;
|
||||
}
|
||||
} else {
|
||||
$allHotelRoomTypes = $objHotelRoomType->getAllRoomTypes();
|
||||
if (is_array($allHotelRoomTypes) && count($allHotelRoomTypes)) {
|
||||
$hotels = array();
|
||||
foreach ($allHotelRoomTypes as $hotelRoomType) {
|
||||
if (!array_key_exists($hotelRoomType['id_hotel'], $hotels)) {
|
||||
$hotels[$hotelRoomType['id_hotel']] = new HotelBranchInformation(
|
||||
$hotelRoomType['id_hotel'],
|
||||
$this->context->language->id
|
||||
);
|
||||
}
|
||||
|
||||
$objProduct = new Product($hotelRoomType['id_product'], false, $this->context->language->id);
|
||||
$hotelRoomTypes[] = array(
|
||||
'id_product' => $hotelRoomType['id_product'],
|
||||
'room_type' => $objProduct->name,
|
||||
'hotel_name' => $hotels[$hotelRoomType['id_hotel']]->hotel_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($hotelRoomTypes) && count($hotelRoomTypes)) {
|
||||
$response['has_room_types'] = true;
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'room_types_info' => $hotelRoomTypes,
|
||||
));
|
||||
|
||||
$response['status'] = true;
|
||||
$response['html_room_types'] = $this->context->smarty->fetch('controllers/orders/_filter_room_types.tpl');
|
||||
} else {
|
||||
$response['has_room_types'] = false;
|
||||
$response['status'] = true;
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessGetHotelRooms()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$idProduct = (int) Tools::getValue('id_product');
|
||||
|
||||
$hotelRoomsInfo = HotelRoomInformation::getHotelRoomsInfo($idHotel, $idProduct);
|
||||
|
||||
if (is_array($hotelRoomsInfo) && count($hotelRoomsInfo)) {
|
||||
$response['has_hotel_rooms'] = true;
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'hotel_rooms_info' => $hotelRoomsInfo,
|
||||
));
|
||||
|
||||
$response['status'] = true;
|
||||
$response['html_hotel_rooms'] = $this->context->smarty->fetch('controllers/orders/_filter_hotel_rooms.tpl');
|
||||
} else {
|
||||
$response['has_hotel_rooms'] = false;
|
||||
$response['status'] = true;
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessGetBookingDocuments()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
@@ -2944,6 +3195,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
/*By Webkul to make entries in HotelCartBookingData */
|
||||
$hotel_room_info_arr = $hotel_room_data['rm_data'][$idProduct]['data']['available'];
|
||||
$chkQty = 0;
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($hotel_room_info_arr) {
|
||||
foreach ($hotel_room_info_arr as $key => $room_info) {
|
||||
if ($chkQty < $req_rm) {
|
||||
@@ -2971,7 +3223,18 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objCartBookingData->children = 0;
|
||||
$objCartBookingData->child_ages = json_encode(array());
|
||||
}
|
||||
$objCartBookingData->save();
|
||||
if ($objCartBookingData->save()
|
||||
&& $services = RoomTypeServiceProduct::getAutoAddServices($room_info['id_product'])
|
||||
) {
|
||||
foreach($services as $service) {
|
||||
$objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$service['id_product'],
|
||||
1,
|
||||
$this->context->cart->id,
|
||||
$objCartBookingData->id
|
||||
);
|
||||
}
|
||||
}
|
||||
++$chkQty;
|
||||
|
||||
// create feature price if needed
|
||||
@@ -2988,6 +3251,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
/*END*/
|
||||
// always add taxes even if there are not displayed to the customer
|
||||
$use_taxes = true;
|
||||
$this->context->currency = new Currency($order->id_currency);
|
||||
|
||||
$initial_product_price_tax_incl = Product::getPriceStatic(
|
||||
$product->id,
|
||||
@@ -3009,7 +3273,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$specific_price = new SpecificPrice();
|
||||
$specific_price->id_shop = 0;
|
||||
$specific_price->id_shop_group = 0;
|
||||
$specific_price->id_currency = 0;
|
||||
$specific_price->id_currency = $order->id_currency;
|
||||
$specific_price->id_country = 0;
|
||||
$specific_price->id_group = 0;
|
||||
$specific_price->id_customer = $order->id_customer;
|
||||
@@ -3259,7 +3523,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
/*By Webkul Entry into table HotelbookingDetail*/
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$inserted_id_order_detail = $objBookingDetail->getLastInsertedIdOrderDetail($order->id);
|
||||
$inserted_id_order_detail = $objBookingDetail->getLastInsertedRoomIdOrderDetail($order->id);
|
||||
$idLang = (int)$this->context->cart->id_lang;
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
if ($cartBookingData = $objCartBookingData->getOnlyCartBookingData(
|
||||
@@ -3331,7 +3595,69 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDetail->child_ages = $objCartBookingData->child_ages;
|
||||
}
|
||||
|
||||
$objBookingDetail->save();
|
||||
if ($objBookingDetail->save()) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($services = $objRoomTypeServiceProductCartDetail->getRoomServiceProducts($objCartBookingData->id, 0, null, 1)) {
|
||||
foreach ($services as $service) {
|
||||
$insertedServiceProductIdOrderDetail = $objBookingDetail->getLastInsertedServiceIdOrderDetail($order->id, $service['id_product']);
|
||||
$numDays = 1;
|
||||
if (Product::getProductPriceCalculation($service['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$numDays = HotelHelper::getNumberOfDays($objBookingDetail->date_from, $objBookingDetail->date_to);
|
||||
}
|
||||
|
||||
$totalPriceTaxExcl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int) $service['id_product'],
|
||||
$roomTypeInfo['id'],
|
||||
1,
|
||||
$objBookingDetail->date_from,
|
||||
$objBookingDetail->date_to,
|
||||
false
|
||||
);
|
||||
$totalPriceTaxIncl = $objRoomTypeServiceProductPrice->getServicePrice(
|
||||
(int)$service['id_product'],
|
||||
$roomTypeInfo['id'],
|
||||
1,
|
||||
$objBookingDetail->date_from,
|
||||
$objBookingDetail->date_to,
|
||||
true
|
||||
);
|
||||
$unitPriceTaxExcl = $totalPriceTaxExcl / $numDays;
|
||||
$unitPriceTaxIncl = $totalPriceTaxIncl / $numDays;
|
||||
switch (Configuration::get('PS_ROUND_TYPE')) {
|
||||
case Order::ROUND_TOTAL:
|
||||
$service['total'] = $totalPriceTaxExcl;
|
||||
$service['total_wt'] = $totalPriceTaxIncl;
|
||||
break;
|
||||
case Order::ROUND_LINE:
|
||||
$service['total'] = Tools::ps_round($totalPriceTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$service['total_wt'] = Tools::ps_round($totalPriceTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
break;
|
||||
|
||||
case Order::ROUND_ITEM:
|
||||
default:
|
||||
$service['total'] = Tools::ps_round($totalPriceTaxExcl, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$service['total_wt'] = Tools::ps_round($totalPriceTaxIncl, _PS_PRICE_COMPUTE_PRECISION_);
|
||||
break;
|
||||
}
|
||||
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $service['id_product'];
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $objBookingDetail->id_order;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $insertedServiceProductIdOrderDetail;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $cart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_htl_booking_detail = $objBookingDetail->id;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $unitPriceTaxExcl;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $unitPriceTaxIncl;
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $totalPriceTaxExcl;
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $totalPriceTaxIncl;
|
||||
$objRoomTypeServiceProductOrderDetail->name = $service['name'];
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = 1;
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3350,6 +3676,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called when order is changed (Add/Edit/Delete room on order)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user