diff --git a/admin/themes/default/template/helpers/list/list_header.tpl b/admin/themes/default/template/helpers/list/list_header.tpl index d8e313a11..ad1326265 100644 --- a/admin/themes/default/template/helpers/list/list_header.tpl +++ b/admin/themes/default/template/helpers/list/list_header.tpl @@ -167,7 +167,7 @@ $(form).find('table.table .field_optional').hide(); $(form).find('table.table .field_optional').each(function(i, val) { if (list_fields_visibility.includes($(this).data('key'))) { - $(this).show(); + $(this).css('display', ''); } }); updateListVisibility(list_fields_visibility) diff --git a/classes/Address.php b/classes/Address.php index 9d1b583dd..10c3cf0c4 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -483,6 +483,14 @@ class AddressCore extends ObjectModel return array(); } + public function cacheFieldsRequiredDatabase($all = false) + { + parent::cacheFieldsRequiredDatabase($all); + if ($this->id_hotel) { + self::$fieldsRequiredDatabase['Address'] = array(); + } + } + public function searchByName($query, $idLang = false) { if (!$idLang) { diff --git a/classes/CartRule.php b/classes/CartRule.php index f48ffb3b1..634434e53 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -294,6 +294,13 @@ class CartRuleCore extends ObjectModel return array(); } + // Remove cart rule that does not match the id_customer + foreach ($result as $key => $cart_rule) { + if ($cart_rule['id_customer'] && $cart_rule['id_customer'] != $id_customer) { + unset($result[$key]); + } + } + // Remove cart rule that does not match the customer groups $customerGroups = Customer::getGroupsStatic($id_customer); @@ -1154,6 +1161,18 @@ class CartRuleCore extends ObjectModel $previous_reduction_amount = $prorata * $previous_reduction_amount * (1 + $cart_average_vat_rate); } + // First we convert the voucher value to the default currency + $previousCartRuleCurrency = new Currency($this->reduction_currency); + + if ($previous_reduction_amount == 0 || $previousCartRuleCurrency->conversion_rate == 0) { + $previous_reduction_amount = 0; + } else { + $previous_reduction_amount /= $previousCartRuleCurrency->conversion_rate; + } + + // Then we convert the voucher value in the default currency into the cart currency + $previous_reduction_amount *= $context->currency->conversion_rate; + $previous_reduction_amount = Tools::ps_round($previous_reduction_amount, _PS_PRICE_COMPUTE_PRECISION_); $current_cart_amount = max($current_cart_amount - (float)$previous_reduction_amount, 0); } diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index fe8caa4a3..a706b5ede 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -438,6 +438,12 @@ class AuthControllerCore extends FrontController $this->errors[] = Tools::displayError('You must register at least one phone number.'); } + if (!Tools::getValue('is_new_customer', 1)) { + if ($idCustomer = Customer::customerExists(Tools::getValue('email'), true, false)) { + $customer = new Customer($idCustomer); + } + } + $this->errors = array_unique(array_merge($this->errors, $customer->validateController())); // Check the requires fields which are settings in the BO @@ -601,13 +607,7 @@ class AuthControllerCore extends FrontController $customer->active = 1; // New Guest customer if (Tools::isSubmit('is_new_customer')) { - if (isset($idCustomer) && $idCustomer) { - // update guest customer details - $customer = new Customer($idCustomer); - $customer->firstname = Tools::getValue('firstname'); - $customer->lastname = Tools::getValue('lastname'); - } - $customer->is_guest = 1; + $customer->is_guest = !Tools::getValue('is_new_customer', 1); } else { $customer->is_guest = 0; } diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 3823504ab..0fc5f8efb 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -181,22 +181,6 @@ class CategoryControllerCore extends FrontController $booking_data = $objBookingDetail->dataForFrontSearch($bookingParams); - // set default occupancies in required format - if (isset($booking_data['rm_data']) && $booking_data['rm_data']) { - foreach ($booking_data['rm_data'] as &$roomTypeData) { - $occupancy = array( - array( - 'adults' => $roomTypeData['adults'], - 'children' => 0, - 'child_ages' => array(), - ), - ); - - $roomTypeData['occupancies'] = $occupancy; - $roomTypeData['occupancy_adults'] = $roomTypeData['adults']; // only one room by default - } - } - $obj_booking_detail = new HotelBookingDetail(); $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to); diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index ec77ebd09..1028ae6e0 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -427,14 +427,27 @@ class ProductControllerCore extends FrontController if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY) { $occupancy_value = 1; } else { - $occupancy_value = array( - array( - 'adults' => $room_info_by_product_id['adults'], - 'children' => 0, - 'child_ages' => array(), - ), - ); + $useDefaultOccupancy = true; + // if coming from hotel page do not set occupancy, otherwise set base adult occupancy + if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] == Tools::secureReferrer($_SERVER['HTTP_REFERER'])) { // Assure us the previous page was one of the site + $idCategoryHotel = $hotel_branch_obj->id_category; + $categoryPageLink = $this->context->link->getCategoryLink($idCategoryHotel); + if (Tools::strpos($_SERVER['HTTP_REFERER'], $categoryPageLink) === 0) { + $useDefaultOccupancy = false; + } + } + + if ($useDefaultOccupancy) { + $occupancy_value = array( + array( + 'adults' => $room_info_by_product_id['adults'], + 'children' => 0, + 'child_ages' => array(), + ), + ); + } } + $this->assignBookingFormVars($this->product->id, $date_from, $date_to, $occupancy_value); $this->assignServiceProductVars(); diff --git a/js/admin/orders.js b/js/admin/orders.js index 8a551b4fa..097961a27 100644 --- a/js/admin/orders.js +++ b/js/admin/orders.js @@ -2515,13 +2515,6 @@ const AddRoomBookingModal = { $('#new_product .booking_guest_occupancy').removeClass('disabled'); setRoomTypeGuestOccupancy($('#new_product .booking_occupancy_wrapper')); } - if (data.room_type_info) { - $('#new_product .max_adults').val(data.room_type_info.max_adults); - $('#new_product .max_children').val(data.room_type_info.max_children); - $('#new_product .max_guests').val(data.room_type_info.max_guests); - $('#new_product .num_adults').attr('max', data.room_type_info.max_adults); - $('#new_product .num_children').attr('max', data.room_type_info.max_children); - } // Keep product variable current_product = data; diff --git a/modules/bankwire/bankwire.php b/modules/bankwire/bankwire.php index a5add709a..442a6b97a 100644 --- a/modules/bankwire/bankwire.php +++ b/modules/bankwire/bankwire.php @@ -208,14 +208,16 @@ class Bankwire extends PaymentModule } $objOrder = $params['objOrder']; - $orderState = $objOrder->getCurrentState(); + $idOrderState = $objOrder->getCurrentState(); + $objOrderState = new OrderState($idOrderState); + $history = $objOrder->getHistory($this->context->language->id); + $initialStatus = array_pop($history); $smartyVars = array(); - if (in_array( - $orderState, - array( - Configuration::get('PS_OS_AWAITING_PAYMENT'), + if ($idOrderState == Configuration::get('PS_OS_AWAITING_PAYMENT') + || ($objOrderState->logable + && $initialStatus['id_order_state'] == Configuration::get('PS_OS_AWAITING_PAYMENT') ) - )) { + ) { $objCart = new Cart($objOrder->id_cart); if ($objCart->is_advance_payment) { $cartTotal = $objOrder->getOrdersTotalPaid(1); diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index c1cb4b1e7..9dfd93abd 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -478,6 +478,9 @@ var ajaxCart = { else $(callerElement).removeProp('disabled'); } + if (!addedFromProductPage) { + resetOccupancyField($(callerElement).closest('.booking_room_fields').find('.booking_occupancy_wrapper')); + } emptyCustomizations(); }, diff --git a/modules/cheque/cheque.php b/modules/cheque/cheque.php index 63bb05629..002f207e3 100644 --- a/modules/cheque/cheque.php +++ b/modules/cheque/cheque.php @@ -191,13 +191,15 @@ class Cheque extends PaymentModule return; } $objOrder = $params['objOrder']; - $orderState = $objOrder->getCurrentState(); - if (in_array( - $orderState, - array( - Configuration::get('PS_OS_AWAITING_PAYMENT') - ) - )) { + $idOrderState = $objOrder->getCurrentState(); + $objOrderState = new OrderState($idOrderState); + $history = $objOrder->getHistory($this->context->language->id); + $initialStatus = array_pop($history); + if ($idOrderState == Configuration::get('PS_OS_AWAITING_PAYMENT') + || ($objOrderState->logable + && $initialStatus['id_order_state'] == Configuration::get('PS_OS_AWAITING_PAYMENT') + ) + ) { $objCart = new Cart($objOrder->id_cart); if ($objCart->is_advance_payment) { $cartTotal = $objOrder->getOrdersTotalPaid(1); diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php index 5113d2ee1..04b02fe59 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelRoomsBookingController.php @@ -813,19 +813,6 @@ class AdminHotelRoomsBookingController extends ModuleAdminController $objHotelRoomType = new HotelRoomType(); foreach ($booking_data['rm_data'] as $key_bk_data => $value_bk_data) { $booking_data['rm_data'][$key_bk_data]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value_bk_data['id_product']); - - // set default occupancies in required format - $occupancy = array( - array( - 'adults' => $value_bk_data['adults'], - 'children' => 0, - 'child_ages' => array(), - ), - ); - - $booking_data['rm_data'][$key_bk_data]['occupancies'] = $occupancy; - $booking_data['rm_data'][$key_bk_data]['occupancy_adults'] = $booking_data['rm_data'][$key_bk_data]['adults']; // only one room by default - if (isset($value_bk_data['data']['booked']) && $value_bk_data['data']['booked']) { foreach ($value_bk_data['data']['booked'] as $booked_k1 => $booked_v1) { if (isset($booked_v1['detail']) && $booked_v1['detail']) { diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl index 20013d8d0..70bcd1cd3 100644 --- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl @@ -56,79 +56,40 @@