Merge remote-tracking branch 'origin/develop' into gli-1584
This commit is contained in:
@@ -181,9 +181,6 @@ abstract class PaymentModuleCore extends Module
|
||||
ShopUrl::resetMainDomainCache();
|
||||
$id_currency = $currency_special ? (int)$currency_special : (int)$this->context->cart->id_currency;
|
||||
$this->context->currency = new Currency((int)$id_currency, null, (int)$this->context->shop->id);
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$context_country = $this->context->country;
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int)$id_order_state, (int)$this->context->language->id);
|
||||
if (!Validate::isLoadedObject($order_status)) {
|
||||
@@ -274,14 +271,6 @@ abstract class PaymentModuleCore extends Module
|
||||
$order = new Order();
|
||||
$order->product_list = $package['product_list'];
|
||||
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$address = new Address((int)$id_address);
|
||||
$this->context->country = new Country((int)$address->id_country, (int)$this->context->cart->id_lang);
|
||||
if (!$this->context->country->active) {
|
||||
throw new PrestaShopException('The delivery address country is not active.');
|
||||
}
|
||||
}
|
||||
|
||||
$carrier = null;
|
||||
if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
|
||||
$carrier = new Carrier((int)$package['id_carrier'], (int)$this->context->cart->id_lang);
|
||||
@@ -430,6 +419,7 @@ abstract class PaymentModuleCore extends Module
|
||||
if ($order_status->logable
|
||||
&& number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)
|
||||
&& $this->name != 'wsorder'
|
||||
&& $this->name != 'bo_order'
|
||||
&& $this->name != 'csvbooking'
|
||||
) {
|
||||
// if customer is paying full payment amount
|
||||
@@ -464,15 +454,6 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
}
|
||||
|
||||
// The country can only change if the address used for the calculation is the delivery address, and if multi-shipping is activated
|
||||
if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
|
||||
$this->context->country = $context_country;
|
||||
}
|
||||
|
||||
if (!$this->context->country->active) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Country is not active', 3, null, 'Cart', (int)$id_cart, true);
|
||||
throw new PrestaShopException('The order address country is not active.');
|
||||
}
|
||||
|
||||
if (self::DEBUG_MODE) {
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Payment is about to be added', 1, null, 'Cart', (int)$id_cart, true);
|
||||
@@ -647,17 +628,17 @@ abstract class PaymentModuleCore extends Module
|
||||
// THEN
|
||||
// The voucher is cloned with a new value corresponding to the remainder
|
||||
$reduction_amount_converted = $cart_rule['obj']->reduction_amount;
|
||||
if ((int) $cart_rule['obj']->reduction_currency !== (int) $cart->id_currency) {
|
||||
if ((int) $cart_rule['obj']->reduction_currency !== (int) $this->context->cart->id_currency) {
|
||||
$reduction_amount_converted = Tools::convertPriceFull(
|
||||
$cart_rule['obj']->reduction_amount,
|
||||
new Currency($cart_rule['obj']->reduction_currency),
|
||||
new Currency($cart->id_currency)
|
||||
new Currency($this->context->cart->id_currency)
|
||||
);
|
||||
}
|
||||
if ($cart_rule['obj']->reduction_tax) {
|
||||
$remaining_amount = $reduction_amount_converted - $values['tax_incl'];
|
||||
$remaining_amount = $values['tax_incl'] - $order->total_products_wt;
|
||||
} else {
|
||||
$remaining_amount = $reduction_amount_converted - $values['tax_excl'];
|
||||
$remaining_amount = $values['tax_excl'] - $order->total_products;
|
||||
}
|
||||
if ($remaining_amount > 0 && $cart_rule['obj']->partial_use == 1 && $reduction_amount_converted > 0) {
|
||||
// Create a new voucher from the original
|
||||
@@ -665,9 +646,13 @@ abstract class PaymentModuleCore extends Module
|
||||
unset($voucher->id);
|
||||
|
||||
// Set a new voucher code
|
||||
// For a customer, applying voucher ABCD will create partial vouchers ABCD-2, ABCD-3 and so on, and
|
||||
// applying voucher ABCD-2 will create vouchers ABCD-2-2, ABCD-2-3 and so on
|
||||
$voucher->code = empty($voucher->code) ? substr(md5($order->id.'-'.$order->id_customer.'-'.$cart_rule['obj']->id), 0, 16) : $voucher->code.'-2';
|
||||
if (preg_match('/\-([0-9]{1,2})\-([0-9]{1,2})$/', $voucher->code, $matches) && $matches[1] == $matches[2]) {
|
||||
$voucher->code = preg_replace('/'.$matches[0].'$/', '-'.(intval($matches[1]) + 1), $voucher->code);
|
||||
while (CartRule::cartRuleExists($voucher->code, $order->id_customer)) {
|
||||
if (preg_match('/\-([0-9]{1,2})$/', $voucher->code, $matches)) {
|
||||
$voucher->code = preg_replace('/'.$matches[1].'$/', (intval($matches[1]) + 1), $voucher->code);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the new voucher value
|
||||
@@ -779,24 +764,85 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
// update order in htl tables
|
||||
$objRoomType = new HotelRoomType();
|
||||
|
||||
$objAdvancedPayment = new HotelAdvancedPayment();
|
||||
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$vatAddress = new Address((int)$order->id_address_tax);
|
||||
|
||||
$idLang = (int)$this->context->cart->id_lang;
|
||||
$normalProducts = array();
|
||||
// variable to check max overbookings are created in the room in any date of the booking duration
|
||||
$maxOverbookingCount = 0;
|
||||
foreach ($order->product_list as $product) {
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
$idProduct = $product['id_product'];
|
||||
$cartBookingData = $objCartBookingData->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $idProduct);
|
||||
if ($cartBookingData) {
|
||||
if ($product['booking_product']
|
||||
&& $cartBookingData = $objCartBookingData->getCartInfoIdCartIdProduct($this->context->cart->id, $idProduct, $product['date_from'], $product['date_to'])
|
||||
) {
|
||||
foreach ($cartBookingData as $bookingInfo) {
|
||||
$objCartBookingData = new HotelCartBookingData($bookingInfo['id']);
|
||||
$objCartBookingData->id_order = $order->id;
|
||||
$objCartBookingData->id_customer = $this->context->customer->id;
|
||||
|
||||
// check if still room available for this booking or not
|
||||
$isRoomOverBooked = 1;
|
||||
|
||||
// get all the available rooms right now
|
||||
$bookingParams = array(
|
||||
'date_from' => $objCartBookingData->date_from,
|
||||
'date_to' => $objCartBookingData->date_to,
|
||||
'hotel_id' => $objCartBookingData->id_hotel,
|
||||
'id_room_type' => $idProduct,
|
||||
'only_search_data' => 1
|
||||
);
|
||||
|
||||
if ($searchRoomsInfo = $objBookingDetail->getBookingData($bookingParams)) {
|
||||
if (isset($searchRoomsInfo['rm_data'][$idProduct]['data']['available'])
|
||||
&& $searchRoomsInfo['rm_data'][$idProduct]['data']['available']
|
||||
) {
|
||||
$availableRoomsInfo = $searchRoomsInfo['rm_data'][$idProduct]['data']['available'];
|
||||
if ($roomIdsAvailable = array_column($availableRoomsInfo, 'id_room')) {
|
||||
// If room is still there in the available rooms list then it is not in back order
|
||||
if (in_array($objCartBookingData->id_room, $roomIdsAvailable)) {
|
||||
$isRoomOverBooked = 0;
|
||||
} else {
|
||||
$isRoomOverBooked = 1;
|
||||
foreach ($roomIdsAvailable as $idRoom) {
|
||||
if ($idRoom != $objCartBookingData->id_room) {
|
||||
$objCartBookingData->id_room = $idRoom;
|
||||
$isRoomOverBooked = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if room is not available right now the set it to back order
|
||||
if ($isRoomOverBooked) {
|
||||
$objCartBookingData->is_back_order = 1;
|
||||
|
||||
// max overbookings in a room datewise breakup. So that we can know no. of overbookings in every date
|
||||
if ($roomOverBookings = $objBookingDetail->getOverbookedRooms(
|
||||
0,
|
||||
$objCartBookingData->id_hotel,
|
||||
$objCartBookingData->date_from,
|
||||
$objCartBookingData->date_to,
|
||||
0,
|
||||
1
|
||||
)) {
|
||||
// check in the bokking duration what is the max overbookings in ay date in the date range
|
||||
// replace $maxOverbookingCount with $maxOverbookingsInDate if it is greater
|
||||
if ($maxOverbookingCount < $roomOverBookings) {
|
||||
$maxOverbookingCount = $roomOverBookings;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$objCartBookingData->is_back_order = 0;
|
||||
}
|
||||
$objCartBookingData->save();
|
||||
|
||||
// Lets set data to the hotel booking detail table
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$id_order_detail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id);
|
||||
$objBookingDetail->id_product = $idProduct;
|
||||
@@ -808,12 +854,9 @@ abstract class PaymentModuleCore extends Module
|
||||
$objBookingDetail->id_customer = $this->context->customer->id;
|
||||
$objBookingDetail->booking_type = $objCartBookingData->booking_type;
|
||||
$objBookingDetail->id_status = 1;
|
||||
$objBookingDetail->is_back_order = $objCartBookingData->is_back_order;
|
||||
$objBookingDetail->comment = $objCartBookingData->comment;
|
||||
|
||||
// For Back Order(Because of cart lock)
|
||||
if ($objCartBookingData->is_back_order) {
|
||||
$objBookingDetail->is_back_order = 1;
|
||||
}
|
||||
$total_price = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
|
||||
$idProduct,
|
||||
$objCartBookingData->date_from,
|
||||
@@ -865,7 +908,11 @@ abstract class PaymentModuleCore extends Module
|
||||
$objBookingDetail->total_paid_amount = $objAdvancedPayment->getRoomMinAdvPaymentAmount(
|
||||
$idProduct,
|
||||
$objCartBookingData->date_from,
|
||||
$objCartBookingData->date_to
|
||||
$objCartBookingData->date_to,
|
||||
1,
|
||||
$objCartBookingData->id_room,
|
||||
$objCartBookingData->id_cart,
|
||||
$objCartBookingData->id_guest
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -923,7 +970,6 @@ abstract class PaymentModuleCore extends Module
|
||||
$objBookingDemand->tax_computation_method = (int)$taxCalc->computation_method;
|
||||
if ($objBookingDemand->save()) {
|
||||
$objBookingDemand->tax_calculator = $taxCalc;
|
||||
$objBookingDemand->id_global_demand = $idGlobalDemand;
|
||||
// Now save tax details of the extra demand
|
||||
$objBookingDemand->setBookingDemandTaxDetails();
|
||||
}
|
||||
@@ -944,8 +990,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$product['id_product'],
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
$product['date_from'],
|
||||
$product['date_to'],
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
@@ -1008,18 +1054,45 @@ abstract class PaymentModuleCore extends Module
|
||||
// Set the order status
|
||||
$new_history = new OrderHistory();
|
||||
$new_history->id_order = (int)$order->id;
|
||||
if ($order_status->logable && $order->is_advance_payment && $order->advance_paid_amount < $order->total_paid_tax_incl) {
|
||||
$new_history->changeIdOrderState((int)Configuration::get('PS_OS_PARTIAL_PAYMENT'), $order, true);
|
||||
} else {
|
||||
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
|
||||
}
|
||||
|
||||
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
|
||||
|
||||
$new_history->addWithemail(true, $extra_vars);
|
||||
|
||||
// Switch to back order if needed
|
||||
if (Configuration::get('PS_STOCK_MANAGEMENT') && ($order_detail->getStockState() || $order_detail->product_quantity_in_stock <= 0)) {
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
if ($objHotelBookingDetail->getOverbookedRooms($order->id)) {
|
||||
$cancelOrder = 0;
|
||||
// Take overbooking action as per order->overbooking Preferences else set order for cancellation
|
||||
if (Configuration::get('PS_OVERBOOKING_ORDER_ACTION') == Order::OVERBOOKING_ORDER_CANCEL_ACTION) {
|
||||
$cancelOrder = 1;
|
||||
} else {
|
||||
// check conditions for maximun overbookings allowed for the hotel else set order for cancellation
|
||||
$maxAllowedOverbookings = Configuration::get('PS_MAX_OVERBOOKING_PER_HOTEL_PER_DAY');
|
||||
// >= condition applied because equal case means already overbooked rooms limit exceeded before this booking
|
||||
if ($maxAllowedOverbookings && ($maxOverbookingCount >= $maxAllowedOverbookings)) {
|
||||
$cancelOrder = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// set order status after all conditions checks
|
||||
if ($cancelOrder) {
|
||||
$id_order_state = Configuration::get('PS_OS_CANCELED');
|
||||
} else {
|
||||
if ($order->valid) {
|
||||
if ($order->is_advance_payment && $order->advance_paid_amount < $order->total_paid_tax_incl) {
|
||||
$id_order_state = Configuration::get('PS_OS_OVERBOOKING_PARTIAL_PAID');
|
||||
} else {
|
||||
$id_order_state = Configuration::get('PS_OS_OVERBOOKING_PAID');
|
||||
}
|
||||
} else {
|
||||
$id_order_state = Configuration::get('PS_OS_OVERBOOKING_UNPAID');
|
||||
}
|
||||
}
|
||||
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$order->id;
|
||||
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
|
||||
$history->changeIdOrderState($id_order_state, $order, true);
|
||||
$history->addWithemail();
|
||||
}
|
||||
|
||||
@@ -1047,47 +1120,19 @@ abstract class PaymentModuleCore extends Module
|
||||
$normal_products_data_txt = $this->getEmailTemplateContent('hotel-service-product-data-text.tpl', Mail::TYPE_TEXT, $orderServiceProducts);
|
||||
|
||||
// total room price
|
||||
$room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true);
|
||||
$room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true);
|
||||
$room_tax = ($order->getTotalProductsWithTaxes(false, true) - $order->getTotalProductsWithoutTaxes(false, true));
|
||||
$room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM);
|
||||
$room_price_tax_incl = $order->getTotalProductsWithTaxes(false, true) + $order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM);
|
||||
$room_tax = ($room_price_tax_incl - $room_price_tax_excl);
|
||||
|
||||
// extra services
|
||||
$additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $cart_booking_data['total_extra_demands_te']);
|
||||
$additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $cart_booking_data['total_extra_demands_ti']);
|
||||
$additional_service_tax = (($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $cart_booking_data['total_extra_demands_ti']) - ($order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE) + $cart_booking_data['total_extra_demands_te']));
|
||||
$additional_service_price_tax_excl = ($order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0) + $cart_booking_data['total_extra_demands_te']);
|
||||
$additional_service_price_tax_incl = ($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0) + $cart_booking_data['total_extra_demands_ti']);
|
||||
$additional_service_tax = ($additional_service_price_tax_incl - $additional_service_price_tax_excl);
|
||||
|
||||
|
||||
// convenience fee price
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$total_convenience_fee_ti = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order->id,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_INDEPENDENT
|
||||
);
|
||||
$total_convenience_fee_te = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$order->id,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_INDEPENDENT
|
||||
);
|
||||
$additional_service_price_tax_excl = $additional_service_price_tax_excl - $total_convenience_fee_te;
|
||||
$additional_service_price_tax_incl = $additional_service_price_tax_incl - $total_convenience_fee_ti;
|
||||
$room_price_tax_excl = $room_price_tax_excl + $additional_service_price_tax_excl;
|
||||
$room_price_tax_incl = $room_price_tax_incl + $additional_service_price_tax_incl;
|
||||
$total_convenience_fee_ti = $order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT);
|
||||
$total_convenience_fee_te = $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT);
|
||||
|
||||
// service products
|
||||
// $service_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
@@ -1193,8 +1238,21 @@ abstract class PaymentModuleCore extends Module
|
||||
PrestaShopLogger::addLog('PaymentModule::validateOrder - Mail is about to be sent', 1, null, 'Cart', (int)$id_cart, true);
|
||||
}
|
||||
|
||||
// Send order confirmation mails to the reciepients according to the order mail configuration
|
||||
$orderStatusObj = new OrderState((int)$id_order_state, (int)$this->context->language->id);
|
||||
$data['{order_status}'] = $orderStatusObj->name;
|
||||
$data['{order_status_color}'] = $orderStatusObj->color;
|
||||
// Send order confirmation/overbooking mails to the reciepients according to the order mail configuration
|
||||
$overBookingStates = OrderState::getOverBookingStates();
|
||||
$isOverBookingStatus = in_array($id_order_state, $overBookingStates);
|
||||
if (Configuration::get('PS_ORDER_CONF_MAIL_TO_CUSTOMER')){
|
||||
// If order currenct state is overbooking, the send overbooking email or send order confirmation email
|
||||
if ($isOverBookingStatus) {
|
||||
$subject = Mail::l('Order Not Confirmed', (int)$order->id_lang);
|
||||
$template = 'overbooking';
|
||||
} else {
|
||||
$subject = Mail::l('Order confirmation', (int)$order->id_lang);
|
||||
$template = 'order_conf';
|
||||
}
|
||||
if (Validate::isEmail($this->context->customer->email)) {
|
||||
// send customer information
|
||||
$data['{firstname}'] = $this->context->customer->firstname;
|
||||
@@ -1202,8 +1260,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$data['{email}'] = $this->context->customer->email;
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_conf',
|
||||
Mail::l('Order confirmation', (int)$order->id_lang),
|
||||
$template,
|
||||
$subject,
|
||||
$data,
|
||||
$this->context->customer->email,
|
||||
$this->context->customer->firstname.' '.$this->context->customer->lastname,
|
||||
@@ -1224,8 +1282,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$data['{email}'] = $objOrderCustomerGuestDetail->email;
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_conf',
|
||||
Mail::l('Order confirmation', (int)$order->id_lang),
|
||||
$template,
|
||||
$subject,
|
||||
$data,
|
||||
$objOrderCustomerGuestDetail->email,
|
||||
$objOrderCustomerGuestDetail->firstname.' '.$objOrderCustomerGuestDetail->lastname,
|
||||
@@ -1239,26 +1297,37 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
}
|
||||
if (Configuration::get('PS_ORDER_CONF_MAIL_TO_SUPERADMIN')){
|
||||
// send superadmin information
|
||||
if (Validate::isLoadedObject($superAdmin = new Employee(_PS_ADMIN_PROFILE_))) {
|
||||
if (Validate::isEmail($superAdmin->email)) {
|
||||
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
|
||||
$data['{customer_email}'] = $this->context->customer->email;
|
||||
$data['{firstname}'] = $superAdmin->firstname;
|
||||
$data['{lastname}'] = $superAdmin->lastname;
|
||||
$data['{email}'] = $superAdmin->email;
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_conf_admin',
|
||||
Mail::l('Order confirmation', (int)$order->id_lang),
|
||||
$data,
|
||||
$superAdmin->email,
|
||||
$superAdmin->firstname.' '.$superAdmin->lastname,
|
||||
null,
|
||||
null,
|
||||
$file_attachement,
|
||||
null, _PS_MAIL_DIR_, false, (int)$order->id_shop
|
||||
);
|
||||
// get superadmin employees
|
||||
if ($superAdminEmployees = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true)) {
|
||||
// If order currenct state is overbooking, the send overbooking email or send order confirmation email
|
||||
if ($isOverBookingStatus) {
|
||||
$subject = Mail::l('Order Not Confirmed', (int)$order->id_lang);
|
||||
$template = 'overbooking_admin';
|
||||
} else {
|
||||
$subject = Mail::l('Order confirmation', (int)$order->id_lang);
|
||||
$template = 'order_conf_admin';
|
||||
}
|
||||
|
||||
foreach ($superAdminEmployees as $superAdminEmployee) {
|
||||
if (Validate::isEmail($superAdminEmployee['email'])) {
|
||||
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
|
||||
$data['{customer_email}'] = $this->context->customer->email;
|
||||
$data['{firstname}'] = $superAdminEmployee['firstname'];
|
||||
$data['{lastname}'] = $superAdminEmployee['lastname'];
|
||||
$data['{email}'] = $superAdminEmployee['email'];
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
$template,
|
||||
$subject,
|
||||
$data,
|
||||
$superAdminEmployee['email'],
|
||||
$superAdminEmployee['firstname'].' '.$superAdminEmployee['lastname'],
|
||||
null,
|
||||
null,
|
||||
$file_attachement,
|
||||
null, _PS_MAIL_DIR_, false, (int)$order->id_shop
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1266,6 +1335,14 @@ abstract class PaymentModuleCore extends Module
|
||||
&& Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))
|
||||
) {
|
||||
if (Configuration::get('PS_ORDER_CONF_MAIL_TO_HOTEL_MANAGER')){
|
||||
// If order currenct state is overbooking, the send overbooking email or send order confirmation email
|
||||
if ($isOverBookingStatus) {
|
||||
$subject = Mail::l('Order Not Confirmed', (int)$order->id_lang);
|
||||
$template = 'overbooking_admin';
|
||||
} else {
|
||||
$subject = Mail::l('Order confirmation', (int)$order->id_lang);
|
||||
$template = 'order_conf_admin';
|
||||
}
|
||||
// send hotel information
|
||||
$data['{firstname}'] = '';
|
||||
$data['{lastname}'] = '';
|
||||
@@ -1275,8 +1352,8 @@ abstract class PaymentModuleCore extends Module
|
||||
if (Validate::isEmail($objHotel->email)) {
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_conf_admin',
|
||||
Mail::l('Order confirmation', (int)$order->id_lang),
|
||||
$template,
|
||||
$subject,
|
||||
$data,
|
||||
$objHotel->email,
|
||||
null,
|
||||
@@ -1291,8 +1368,18 @@ abstract class PaymentModuleCore extends Module
|
||||
if ($htlAccesses = $objHotel->getHotelAccess($idHotel)) {
|
||||
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
|
||||
$data['{customer_email}'] = $this->context->customer->email;
|
||||
|
||||
// If order currenct state is overbooking, the send overbooking email or send order confirmation email
|
||||
if ($isOverBookingStatus) {
|
||||
$subject = Mail::l('Order Not Confirmed', (int)$order->id_lang);
|
||||
$template = 'overbooking_admin';
|
||||
} else {
|
||||
$subject = Mail::l('Order confirmation', (int)$order->id_lang);
|
||||
$template = 'order_conf_admin';
|
||||
}
|
||||
|
||||
foreach ($htlAccesses as $access) {
|
||||
if ($access['id_profile'] != _PS_ADMIN_PROFILE_) {
|
||||
if ($access['access'] && $access['id_profile'] != _PS_ADMIN_PROFILE_) {
|
||||
if ($htlEmployees = Employee::getEmployeesByProfile($access['id_profile'])) {
|
||||
foreach ($htlEmployees as $empl) {
|
||||
if (Validate::isEmail($empl['email'])) {
|
||||
@@ -1302,8 +1389,8 @@ abstract class PaymentModuleCore extends Module
|
||||
$data['{email}'] = $empl['email'];
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_conf_admin',
|
||||
Mail::l('Order confirmation', (int)$order->id_lang),
|
||||
$template,
|
||||
$subject,
|
||||
$data,
|
||||
$empl['email'],
|
||||
$empl['firstname'].' '.$empl['lastname'],
|
||||
@@ -1321,7 +1408,6 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// updates stock in shops
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
|
||||
$product_list = $order->getProducts();
|
||||
@@ -1662,8 +1748,11 @@ abstract class PaymentModuleCore extends Module
|
||||
);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += ($data_v['total_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
} else {
|
||||
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
|
||||
@@ -1765,8 +1854,11 @@ abstract class PaymentModuleCore extends Module
|
||||
);
|
||||
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = ($data_v['total_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = ($cart_htl_data[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = ($data_v['total_price_tax_incl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti']);
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = ($data_v['total_price_tax_excl'] + $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te']);
|
||||
|
||||
$result['total_extra_demands_te'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_te'];
|
||||
$result['total_extra_demands_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'];
|
||||
@@ -1774,10 +1866,10 @@ abstract class PaymentModuleCore extends Module
|
||||
$result['total_additional_services_ti'] += $cart_htl_data[$type_key]['date_diff'][$date_join]['additional_services_price_ti'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// calculate averages now
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
|
||||
// calculate averages now
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user