Merge branch 'develop' into gli-1475
This commit is contained in:
@@ -35,7 +35,7 @@ class BankwireValidationModuleFrontController extends ModuleFrontController
|
||||
public function postProcess()
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active)
|
||||
if ($cart->id_customer == 0 || !$this->module->active)
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
|
||||
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
|
||||
|
||||
@@ -33,7 +33,7 @@ class ChequeValidationModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
|
||||
if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active)
|
||||
if ($cart->id_customer == 0 || !$this->module->active)
|
||||
Tools::redirect('index.php?controller=order&step=1');
|
||||
|
||||
// Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
|
||||
|
||||
@@ -774,6 +774,34 @@ class HotelCartBookingData extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* [removeBackdateRoomsFromCart :: To delete the rooms from cart whose booking date is before the current date
|
||||
*
|
||||
* @param [int] $idCart [Id of the cart]
|
||||
*
|
||||
* @return [boolean] [If removed successfully returns true else returns false]
|
||||
*/
|
||||
public function removeBackdateRoomsFromCart($idCart)
|
||||
{
|
||||
if ($cartBookingData = $this->getCartCurrentDataByCartId($idCart)) {
|
||||
$res = true;
|
||||
foreach ($cartBookingData as $cartRoom) {
|
||||
if (strtotime($cartRoom['date_from']) < strtotime(date('Y-m-d'))) {
|
||||
$res = $res && $this->deleteRoomDataFromOrderLine(
|
||||
$cartRoom['id_cart'],
|
||||
$cartRoom['id_guest'],
|
||||
$cartRoom['id_product'],
|
||||
$cartRoom['date_from'],
|
||||
$cartRoom['date_to']
|
||||
);
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* [getCustomerIdRoomsByIdCartIdProduct :: To get array of rooms ids in the cart booked by a customer for a date range].
|
||||
*
|
||||
|
||||
@@ -64,14 +64,13 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
}
|
||||
|
||||
if ($updateQty = $quantity - $objRoomTypeServiceProductCartDetail->quantity) {
|
||||
$way = $updateQty > 0 ? 'up' : 'down';
|
||||
$objRoomTypeServiceProductCartDetail->quantity += $updateQty;
|
||||
if (Product::getProductPriceCalculation($idProduct) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$objHotelCartBookingData = new HotelCartBookingData($idHtlCartData);
|
||||
$numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to);
|
||||
$updateQty *= $numdays;
|
||||
|
||||
}
|
||||
$way = $updateQty > 0 ? 'up' : 'down';
|
||||
$objRoomTypeServiceProductCartDetail->quantity = $quantity;
|
||||
if ($objRoomTypeServiceProductCartDetail->save()) {
|
||||
$objCart = new Cart($idCart);
|
||||
return $objCart->updateQty((int)abs($updateQty), $idProduct, null, false, $way);
|
||||
@@ -86,16 +85,45 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
|
||||
public function removeServiceProductByIdHtlCartBooking($htlCartBookingId)
|
||||
{
|
||||
if ($stadardProductsData = Db::getInstance()->executeS(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail`
|
||||
WHERE `htl_cart_booking_id` = '.(int)$htlCartBookingId
|
||||
'SELECT * FROM `' . _DB_PREFIX_ . 'htl_room_type_service_product_cart_detail`
|
||||
WHERE `htl_cart_booking_id` = ' . (int)$htlCartBookingId
|
||||
)) {
|
||||
foreach ($stadardProductsData as $product) {
|
||||
if (Validate::isLoadedObject(
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail($product['id_room_type_service_product_cart_detail'])
|
||||
)) {
|
||||
$updateQty = $product['quantity'];
|
||||
if (Product::getProductPriceCalculation($product['id_product']) == Product::PRICE_CALCULATION_METHOD_PER_DAY) {
|
||||
$objHotelCartBookingData = new HotelCartBookingData($idHtlCartData);
|
||||
$numdays = HotelHelper::getNumberOfDays($objHotelCartBookingData->date_from, $objHotelCartBookingData->date_to);
|
||||
$updateQty *= $numdays;
|
||||
}
|
||||
if ($objRoomTypeServiceProductCartDetail->delete()) {
|
||||
$objCart = new Cart($product['id_cart']);
|
||||
$objCart->updateQty((int)($product['quantity']), $product['id_product'], null, false, 'down');
|
||||
if (isset(Context::getContext()->controller->controller_type)) {
|
||||
$controllerType = Context::getContext()->controller->controller_type;
|
||||
} else {
|
||||
$controllerType = 'front';
|
||||
}
|
||||
if ($controllerType == 'admin' || $controllerType == 'moduleadmin') {
|
||||
if ($cartQty = Cart::getProductQtyInCart($product['id_cart'], $product['id_product'])) {
|
||||
if ($product['quantity'] < $cartQty) {
|
||||
Db::getInstance()->update(
|
||||
'cart_product',
|
||||
array('quantity' => (int)($cartQty - $product['quantity'])),
|
||||
'`id_product` = '.(int)$product['id_product'].' AND `id_cart` = '.(int)$product['id_cart']
|
||||
);
|
||||
} else {
|
||||
//if room type has no qty remaining in cart then delete row
|
||||
Db::getInstance()->delete(
|
||||
'cart_product',
|
||||
'`id_product` = '.(int)$product['id_product'].' AND `id_cart` = '.(int)$product['id_cart']
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$objCart->updateQty((int)($updateQty), $product['id_product'], null, false, 'down');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,24 @@ class RoomTypeServiceProductPrice extends ObjectModel
|
||||
|
||||
public static function getProductRoomTypePriceAndTax($idProduct, $idElement, $elementType)
|
||||
{
|
||||
return Db::getInstance()->getRow(
|
||||
'SELECT `price`, `id_tax_rules_group` FROM `'._DB_PREFIX_.'htl_room_type_service_product_price`
|
||||
WHERE `id_product`='.(int)$idProduct.
|
||||
' AND `id_element`='.(int)$idElement.
|
||||
' AND `element_type`='.(int)$elementType
|
||||
);
|
||||
if ($result = Db::getInstance()->getRow('
|
||||
SELECT spp.`price`, spp.`id_tax_rules_group`, p.`auto_add_to_cart`, p.`price_addition_type`
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` sp ON (sp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_price` spp ON (spp.`id_product` = p.`id_product`)
|
||||
WHERE p.`id_product`='.(int)$idProduct.
|
||||
' AND sp.`id_element`='.(int)$idElement.
|
||||
' AND sp.`element_type`='.(int)$elementType)
|
||||
) {
|
||||
if ($result['auto_add_to_cart'] && $result['price_addition_type'] == Product::PRICE_ADDITION_TYPE_WITH_ROOM) {
|
||||
// if service is auto add to cart and added in room price, we need to find room type tax rule group
|
||||
if ($elementType == RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE) {
|
||||
$result['id_tax_rules_group'] = Product::getIdTaxRulesGroupByIdProduct((int)$idElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProductRoomTypeLinkPriceInfo($idProduct, $idElement, $elementType)
|
||||
|
||||
@@ -69,6 +69,15 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
$objCustomer->id_guest = (int) $this->context->cookie->id_guest;
|
||||
|
||||
$this->context->customer = $objCustomer;
|
||||
if ($this->context->employee->isSuperAdmin()) {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN';
|
||||
} else {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES';
|
||||
}
|
||||
if (!Configuration::get($backOrderConfigKey)) {
|
||||
$htlCart = new HotelCartBookingData();
|
||||
$htlCart->removeBackdateRoomsFromCart($this->context->cart->id);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createNewCart()
|
||||
@@ -98,13 +107,23 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
} else {
|
||||
$date_from = date('Y-m-d');
|
||||
}
|
||||
if ($this->context->employee->isSuperAdmin()) {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN';
|
||||
} else {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES';
|
||||
}
|
||||
if (!Configuration::get($backOrderConfigKey)) {
|
||||
if (strtotime(date('Y-m-d')) > strtotime($date_from)) {
|
||||
$date_from = date('Y-m-d');
|
||||
}
|
||||
}
|
||||
if (Tools::getValue('date_to')) {
|
||||
$date_to = Tools::getValue('date_to');
|
||||
} else {
|
||||
$date_to = date('Y-m-d');
|
||||
if (strtotime($date_from) >= strtotime($date_to)) {
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_to)));
|
||||
}
|
||||
}
|
||||
if (strtotime($date_from) >= strtotime($date_to)) {
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_to)));
|
||||
}
|
||||
|
||||
if (Tools::getValue('id_hotel')) {
|
||||
@@ -886,6 +905,13 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) {
|
||||
$occupancyRequiredForBooking = true;
|
||||
}
|
||||
if ($this->context->employee->isSuperAdmin()) {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN';
|
||||
} else {
|
||||
$backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES';
|
||||
}
|
||||
$PS_BACKDATE_ORDER_ALLOW = (int)Configuration::get($backOrderConfigKey);
|
||||
|
||||
$jsVars = array(
|
||||
'currency_prefix' => $currency->prefix,
|
||||
'currency_suffix' => $currency->suffix,
|
||||
@@ -925,7 +951,12 @@ class AdminHotelRoomsBookingController extends ModuleAdminController
|
||||
'below_txt' => $this->l('Below', null, true),
|
||||
'years_txt' => $this->l('years', null, true),
|
||||
'all_children_txt' => $this->l('All Children', null, true),
|
||||
'max_occupancy_reached_txt' => $this->l('Maximum room occupancy reached', null, true),
|
||||
'max_adults_txt' => $this->l('Maximum adult occupancy reached', null, true),
|
||||
'max_children_txt' => $this->l('Maximum children occupancy reached', null, true),
|
||||
'no_children_allowed_txt' => $this->l('Only adults can be accommodated', null, true),
|
||||
'invalid_occupancy_txt' => $this->l('Invalid occupancy(adults/children) found.', null, true),
|
||||
'PS_BACKDATE_ORDER_ALLOW' => $PS_BACKDATE_ORDER_ALLOW,
|
||||
// 'check_calender_var' => $check_calender_var,
|
||||
'txtSomeErr' => $this->l('Some error occurred. Please try again.'),
|
||||
'no_rm_avail_txt' => $this->l('No room available.', null, true),
|
||||
|
||||
@@ -76,24 +76,8 @@ class HotelReservationSystem extends Module
|
||||
if (!Configuration::get('PS_CATALOG_MODE')) {
|
||||
/*To remove room from cart before todays date*/
|
||||
if (isset($this->context->cart->id) && $this->context->cart->id) {
|
||||
$htlCart = new HotelCartBookingData();
|
||||
if ($cartBookingData = $htlCart->getCartBookingDetailsByIdCartIdGuest(
|
||||
$this->context->cart->id,
|
||||
$this->context->cart->id_guest,
|
||||
$this->context->language->id
|
||||
)) {
|
||||
foreach ($cartBookingData as $cartRoom) {
|
||||
if (strtotime($cartRoom['date_from']) < strtotime(date('Y-m-d'))) {
|
||||
$htlCart->deleteRoomDataFromOrderLine(
|
||||
$cartRoom['id_cart'],
|
||||
$cartRoom['id_guest'],
|
||||
$cartRoom['id_product'],
|
||||
$cartRoom['date_from'],
|
||||
$cartRoom['date_to']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$objHotelCartBookingData = new HotelCartBookingData();
|
||||
$objHotelCartBookingData->removeBackdateRoomsFromCart($this->context->cart->id);
|
||||
}
|
||||
}
|
||||
//End
|
||||
|
||||
@@ -230,6 +230,7 @@ $(document).ready(function() {
|
||||
dateFormat: 'dd-mm-yy',
|
||||
altFormat: 'yy-mm-dd',
|
||||
altField: '#date_from',
|
||||
minDate: PS_BACKDATE_ORDER_ALLOW == 1 ? null : 0,
|
||||
beforeShowDay: function (date) {
|
||||
return highlightDateBorder($("#from_date").val(), date);
|
||||
},
|
||||
@@ -246,6 +247,11 @@ $(document).ready(function() {
|
||||
dateFormat: 'dd-mm-yy',
|
||||
altFormat: 'yy-mm-dd',
|
||||
altField: '#date_to',
|
||||
beforeShow: function () {
|
||||
from_date = $.datepicker.parseDate('dd-mm-yy', $("#from_date").val());
|
||||
from_date.setDate(from_date.getDate() + 1);
|
||||
$("#to_date").datepicker("option", "minDate", from_date);
|
||||
},
|
||||
beforeShowDay: function (date) {
|
||||
return highlightDateBorder($("#to_date").val(), date);
|
||||
},
|
||||
@@ -597,55 +603,91 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$(document).on('change', '.num_occupancy', function(e) {
|
||||
|
||||
let elementVal = parseInt($(this).val());
|
||||
let current_room_occupancy = 0;
|
||||
$(this).closest('.occupancy_info_block').find('.num_occupancy').each(function(){
|
||||
current_room_occupancy += parseInt($(this).val());
|
||||
});
|
||||
let max_guests_in_room = $(this).closest(".booking_occupancy_wrapper").find('.max_guests').val();
|
||||
let max_allowed_for_current = (max_guests_in_room - current_room_occupancy) + parseInt($(this).val());
|
||||
if ($(this).val() > $(this).attr('max')) {
|
||||
$(this).val($(this).attr('max'));
|
||||
}
|
||||
if ($(this).val() > max_allowed_for_current) {
|
||||
$(this).val(max_allowed_for_current);
|
||||
}
|
||||
|
||||
let haserror = false
|
||||
if ($(this).hasClass('num_children')) {
|
||||
let totalChilds = $(this).closest('.occupancy_info_block').find('.guest_child_age').length;
|
||||
if (totalChilds < $(this).val()) {
|
||||
$(this).closest('.occupancy_info_block').find('.children_age_info_block').show();
|
||||
while ($(this).closest('.occupancy_info_block').find('.guest_child_age').length < $(this).val()) {
|
||||
var roomBlockIndex = parseInt($(this).closest('.occupancy_info_block').attr('occ_block_index'));
|
||||
var childAgeSelect = '<div class="form-group col-xs-12 col-sm-12 col-md-6 col-lg-6">';
|
||||
childAgeSelect += '<select class="guest_child_age room_occupancies" name="occupancy[' +roomBlockIndex+ '][child_ages][]">';
|
||||
childAgeSelect += '<option value="-1">' + select_age_txt + '</option>';
|
||||
childAgeSelect += '<option value="0">' + under_1_age + '</option>';
|
||||
for (let age = 1; age < max_child_age; age++) {
|
||||
childAgeSelect += '<option value="'+age+'">'+age+'</option>';
|
||||
}
|
||||
childAgeSelect += '</select>';
|
||||
childAgeSelect += '</div>';
|
||||
$(this).closest('.occupancy_info_block').find('.children_ages').append(childAgeSelect);
|
||||
max_child_in_room = $(this).closest(".booking_occupancy_wrapper").find('.max_children').val();
|
||||
if (elementVal > max_child_in_room) {
|
||||
$(this).val(max_child_in_room);
|
||||
if (elementVal == 1) {
|
||||
showOccupancyError(no_children_allowed_txt, $(this).closest(".occupancy_info_block"));
|
||||
haserror = true;
|
||||
} else {
|
||||
showOccupancyError(max_children_txt, $(this).closest(".occupancy_info_block"));
|
||||
haserror = true;
|
||||
}
|
||||
} else {
|
||||
let child = $(this).val();
|
||||
$(this).closest('.occupancy_info_block').find('.guest_child_age').each(function(ind, element) {
|
||||
if (child <= ind) {
|
||||
$(element).parent().remove();
|
||||
}
|
||||
});
|
||||
if (child == 0) {
|
||||
$(this).closest('.occupancy_info_block').find('.children_age_info_block').hide();
|
||||
}
|
||||
|
||||
} else if (elementVal > max_allowed_for_current) {
|
||||
$(this).val(max_allowed_for_current);
|
||||
showOccupancyError(max_occupancy_reached_txt, $(this).closest(".occupancy_info_block"));
|
||||
haserror = true;
|
||||
}
|
||||
} else {
|
||||
max_adults_in_room = $(this).closest(".booking_occupancy_wrapper").find('.max_adults').val();
|
||||
if (elementVal >= max_adults_in_room) {
|
||||
$(this).val(max_adults_in_room);
|
||||
showOccupancyError(max_adults_txt, $(this).closest(".occupancy_info_block"));
|
||||
haserror = true;
|
||||
} else if (elementVal > max_allowed_for_current) {
|
||||
$(this).val(max_allowed_for_current);
|
||||
showOccupancyError(max_occupancy_reached_txt, $(this).closest(".occupancy_info_block"));
|
||||
haserror = true;
|
||||
}
|
||||
}
|
||||
|
||||
setRoomTypeGuestOccupancy($(this).closest('.booking_occupancy_wrapper'));
|
||||
if (!haserror) {
|
||||
if ($(this).hasClass('num_children')) {
|
||||
let totalChilds = $(this).closest('.occupancy_info_block').find('.guest_child_age').length;
|
||||
if (totalChilds < $(this).val()) {
|
||||
$(this).closest('.occupancy_info_block').find('.children_age_info_block').show();
|
||||
while ($(this).closest('.occupancy_info_block').find('.guest_child_age').length < $(this).val()) {
|
||||
var roomBlockIndex = parseInt($(this).closest('.occupancy_info_block').attr('occ_block_index'));
|
||||
var childAgeSelect = '<div class="form-group col-xs-12 col-sm-12 col-md-6 col-lg-6">';
|
||||
childAgeSelect += '<select class="guest_child_age room_occupancies" name="occupancy[' +roomBlockIndex+ '][child_ages][]">';
|
||||
childAgeSelect += '<option value="-1">' + select_age_txt + '</option>';
|
||||
childAgeSelect += '<option value="0">' + under_1_age + '</option>';
|
||||
for (let age = 1; age < max_child_age; age++) {
|
||||
childAgeSelect += '<option value="'+age+'">'+age+'</option>';
|
||||
}
|
||||
childAgeSelect += '</select>';
|
||||
childAgeSelect += '</div>';
|
||||
$(this).closest('.occupancy_info_block').find('.children_ages').append(childAgeSelect);
|
||||
}
|
||||
} else {
|
||||
let child = $(this).val();
|
||||
$(this).closest('.occupancy_info_block').find('.guest_child_age').each(function(ind, element) {
|
||||
if (child <= ind) {
|
||||
$(element).parent().remove();
|
||||
}
|
||||
});
|
||||
if (child == 0) {
|
||||
$(this).closest('.occupancy_info_block').find('.children_age_info_block').hide();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
setRoomTypeGuestOccupancy($(this).closest('.booking_occupancy_wrapper'));
|
||||
});
|
||||
|
||||
var errorMsgTime;
|
||||
$('.occupancy-input-errors').parent().hide();
|
||||
function showOccupancyError(msg, occupancy_info_block)
|
||||
{
|
||||
var errorMsgBlock = $(occupancy_info_block).find('.occupancy-input-errors')
|
||||
$(errorMsgBlock).html(msg).parent().show('fast');
|
||||
clearTimeout(errorMsgTime);
|
||||
errorMsgTime = setTimeout(function() {
|
||||
$(errorMsgBlock).parent().hide('fast');
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
||||
$(document).on('click', '.booking_guest_occupancy', function(e) {
|
||||
$(this).parent().toggleClass('open');
|
||||
});
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
({l s='Below'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
|
||||
</div>
|
||||
</div>
|
||||
<p style="display:none;"><span class="text-danger occupancy-input-errors"></span></p>
|
||||
<div class="row children_age_info_block" style="display:none">
|
||||
<div class="form-group col-sm-12">
|
||||
<label class="">{l s='All Children' mod='hotelreservationsystem'}</label>
|
||||
@@ -212,6 +213,7 @@
|
||||
({l s='Below' mod='hotelreservationsystem'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
|
||||
</div>
|
||||
</div>
|
||||
<p style="display:none;"><span class="text-danger occupancy-input-errors"></span></p>
|
||||
<div class="row children_age_info_block" style="display:none">
|
||||
<div class="form-group col-sm-12">
|
||||
<label class="">{l s='All Children' mod='hotelreservationsystem'}</label>
|
||||
@@ -240,6 +242,7 @@
|
||||
({l s='Below' mod='hotelreservationsystem'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='hotelreservationsystem'})
|
||||
</div>
|
||||
</div>
|
||||
<p style="display:none;"><span class="text-danger occupancy-input-errors"></span></p>
|
||||
<div class="row children_age_info_block" style="display:none">
|
||||
<div class="form-group col-sm-12">
|
||||
<label class="">{l s='All Children' mod='hotelreservationsystem'}</label>
|
||||
|
||||
@@ -325,12 +325,7 @@ class WkPaypalCommerceHelper
|
||||
$sql .= ' AND a.`id_address` = ' . (int) $idAddress;
|
||||
}
|
||||
|
||||
$res = Db::getInstance()->executeS($sql);
|
||||
if (count($res) === 1) {
|
||||
return $res[0];
|
||||
} else {
|
||||
return $res;
|
||||
}
|
||||
return Db::getInstance()->getRow($sql);
|
||||
}
|
||||
|
||||
public static function getOrdersByCartId($idCart)
|
||||
|
||||
@@ -278,10 +278,6 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$customer = new Customer((int)$cart->id_customer);
|
||||
|
||||
$ppHelper = new WkPaypalCommerceHelper();
|
||||
$bilAddr = $ppHelper->getSimpleAddress(
|
||||
(int)$cart->id_customer,
|
||||
(int)$cart->id_address_invoice
|
||||
);
|
||||
|
||||
$orderData['payer'] = array(
|
||||
'name' => array(
|
||||
@@ -291,14 +287,20 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
'email_address' => $customer->email
|
||||
);
|
||||
|
||||
$orderData['payer']['address'] = array(
|
||||
'address_line_1' => $bilAddr['address1'],
|
||||
'address_line_2' => $bilAddr['address2'],
|
||||
'admin_area_2' => $bilAddr['city'],
|
||||
'admin_area_1' => $bilAddr['state_iso'],
|
||||
'postal_code' => $bilAddr['postcode'],
|
||||
'country_code' => $bilAddr['country_iso'],
|
||||
);
|
||||
// address is not required in paypal payment, if customer has added an address then we add tha address to paypal payer object
|
||||
if ($bilAddr = $ppHelper->getSimpleAddress(
|
||||
(int)$cart->id_customer,
|
||||
(int)$cart->id_address_invoice
|
||||
)) {
|
||||
$orderData['payer']['address'] = array(
|
||||
'address_line_1' => $bilAddr['address1'],
|
||||
'address_line_2' => $bilAddr['address2'],
|
||||
'admin_area_2' => $bilAddr['city'],
|
||||
'admin_area_1' => $bilAddr['state_iso'],
|
||||
'postal_code' => $bilAddr['postcode'],
|
||||
'country_code' => $bilAddr['country_iso'],
|
||||
);
|
||||
}
|
||||
|
||||
$timestamp = time().rand(100, 999);
|
||||
$currency = Currency::getCurrency((int) $cart->id_currency);
|
||||
|
||||
@@ -191,7 +191,7 @@ class StatsBestCategories extends ModuleGrid
|
||||
AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'"
|
||||
) AS totalOrders,
|
||||
(
|
||||
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * hbd.`total_price_tax_excl`, 2)), 0)
|
||||
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * (hbd.`total_price_tax_excl` / o.`conversion_rate`), 2)), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON (o.`id_order` = hbd.`id_order`)
|
||||
|
||||
@@ -176,7 +176,7 @@ class StatsBestProducts extends ModuleGrid
|
||||
AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'"
|
||||
) AS sellingPrice,
|
||||
(
|
||||
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * hbd.`total_price_tax_excl`, 2)), 0)
|
||||
SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($date_to).'"), GREATEST(hbd.`date_from`, "'.pSQL($date_from).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * (hbd.`total_price_tax_excl` / o.`conversion_rate`) , 2)), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON (o.`id_order` = hbd.`id_order`)
|
||||
|
||||
@@ -179,7 +179,10 @@ class StatsEquipment extends ModuleGraph
|
||||
{
|
||||
switch ($option) {
|
||||
case 'wb':
|
||||
$this->_titles['main'] = $this->l('Web browser used');
|
||||
$this->_titles['main'][] = $this->l('Web browser used');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = '';
|
||||
}
|
||||
$this->query = 'SELECT wb.`name`, COUNT(g.`id_web_browser`) AS total
|
||||
FROM `'._DB_PREFIX_.'web_browser` wb
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_web_browser` = wb.`id_web_browser`
|
||||
@@ -191,7 +194,10 @@ class StatsEquipment extends ModuleGraph
|
||||
break;
|
||||
|
||||
case 'os':
|
||||
$this->_titles['main'] = $this->l('Operating system used');
|
||||
$this->_titles['main'][] = $this->l('Operating system used');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = '';
|
||||
}
|
||||
$this->query = 'SELECT os.`name`, COUNT(g.`id_operating_system`) AS total
|
||||
FROM `'._DB_PREFIX_.'operating_system` os
|
||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_operating_system` = os.`id_operating_system`
|
||||
|
||||
@@ -125,10 +125,12 @@ class StatsNewsletter extends ModuleGraph
|
||||
|
||||
protected function getData($layers)
|
||||
{
|
||||
$this->_titles['main'][0] = $this->l('Customers');
|
||||
$this->_titles['main'][1] = $this->l('Visitors');
|
||||
$this->_titles['main'][2] = $this->l('Newsletter statistics');
|
||||
$this->_titles['main'][3] = $this->l('Both');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
$this->_titles['main'][] = $this->l('Customers');
|
||||
$this->_titles['main'][] = $this->l('Visitors');
|
||||
$this->_titles['main'][] = $this->l('Both');
|
||||
$this->_formats['y'] = 'd';
|
||||
|
||||
$this->_query = 'SELECT newsletter_date_add
|
||||
|
||||
@@ -142,7 +142,10 @@ class StatsOrigin extends ModuleGraph
|
||||
|
||||
protected function getData($layers)
|
||||
{
|
||||
$this->_titles['main'] = $this->l('Top ten referral websites');
|
||||
$this->_titles['main'][] = $this->l('Top ten referral websites');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Referal percentage');
|
||||
}
|
||||
$websites = $this->getOrigins($this->getDate());
|
||||
$total = 0;
|
||||
$total2 = 0;
|
||||
|
||||
@@ -212,7 +212,12 @@ class StatsPersonalInfos extends ModuleGraph
|
||||
{
|
||||
switch ($this->option) {
|
||||
case 'gender':
|
||||
$this->_titles['main'] = $this->l('Gender distribution');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Gender');
|
||||
$this->_titles['main'][] = '';
|
||||
} else {
|
||||
$this->_titles['main'] = $this->l('Gender distribution');
|
||||
}
|
||||
$genders = array(
|
||||
0 => $this->l('Male'),
|
||||
1 => $this->l('Female'),
|
||||
@@ -243,7 +248,12 @@ class StatsPersonalInfos extends ModuleGraph
|
||||
break;
|
||||
|
||||
case 'age':
|
||||
$this->_titles['main'] = $this->l('Age range');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Age');
|
||||
$this->_titles['main'][] = '';
|
||||
} else {
|
||||
$this->_titles['main'] = $this->l('Age range');
|
||||
}
|
||||
|
||||
// 0 - 18 years
|
||||
$sql = 'SELECT COUNT(`id_customer`) as total
|
||||
@@ -334,7 +344,12 @@ class StatsPersonalInfos extends ModuleGraph
|
||||
break;
|
||||
|
||||
case 'country':
|
||||
$this->_titles['main'] = $this->l('Country distribution');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Country');
|
||||
$this->_titles['main'][] = '';
|
||||
} else {
|
||||
$this->_titles['main'] = $this->l('Country distribution');
|
||||
}
|
||||
$sql = 'SELECT cl.`name`, COUNT(c.`id_country`) AS total
|
||||
FROM `'._DB_PREFIX_.'address` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` cu ON cu.id_customer = a.id_customer
|
||||
@@ -351,7 +366,12 @@ class StatsPersonalInfos extends ModuleGraph
|
||||
break;
|
||||
|
||||
case 'currency':
|
||||
$this->_titles['main'] = $this->l('Currency distribution');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Currency');
|
||||
$this->_titles['main'][] = '';
|
||||
} else {
|
||||
$this->_titles['main'] = $this->l('Currency distribution');
|
||||
}
|
||||
$sql = 'SELECT c.`name`, COUNT(c.`id_currency`) AS total
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.`id_currency` = c.`id_currency`
|
||||
@@ -366,7 +386,12 @@ class StatsPersonalInfos extends ModuleGraph
|
||||
break;
|
||||
|
||||
case 'language':
|
||||
$this->_titles['main'] = $this->l('Language distribution');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Language');
|
||||
$this->_titles['main'][] = '';
|
||||
} else {
|
||||
$this->_titles['main'] = $this->l('Language distribution');
|
||||
}
|
||||
$sql = 'SELECT c.`name`, COUNT(c.`id_lang`) AS total
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang` c ON o.`id_lang` = c.`id_lang`
|
||||
|
||||
@@ -351,8 +351,11 @@ class StatsProduct extends ModuleGraph
|
||||
$date_between = $this->getDate();
|
||||
switch ($this->option) {
|
||||
case 1:
|
||||
$this->_titles['main'][0] = $this->l('Room nights');
|
||||
$this->_titles['main'][1] = $this->l('Views (x100)');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
$this->_titles['main'][] = $this->l('Room nights');
|
||||
$this->_titles['main'][] = $this->l('Views (x100)');
|
||||
$this->_titles['x'] = $this->l('Date');
|
||||
$this->_titles['y'] = $this->l('Room nights, Views (x100)');
|
||||
$this->_formats['y'] = 'd';
|
||||
|
||||
@@ -172,7 +172,10 @@ class StatsRegistrations extends ModuleGraph
|
||||
WHERE 1
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
|
||||
AND `date_add` BETWEEN';
|
||||
$this->_titles['main'] = $this->l('Number of customer registrations');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
$this->_titles['main'][] = $this->l('Number of customer registrations');
|
||||
$this->_formats['y'] = 'd';
|
||||
$this->setDateGraph($layers, true);
|
||||
}
|
||||
|
||||
@@ -214,14 +214,23 @@ class StatsSales extends ModuleGraph
|
||||
list($this->option, $this->id_country, $this->id_hotel) = explode('-', $options);
|
||||
switch ($this->option) {
|
||||
case 1:
|
||||
$this->_titles['main'] = $this->l('Orders placed');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
$this->_titles['main'][] = $this->l('Orders placed');
|
||||
break;
|
||||
case 2:
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
$currency = new Currency((int)Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$this->_titles['main'] = sprintf($this->l('Revenue currency: %s'), $currency->iso_code);
|
||||
$this->_titles['main'][] = sprintf($this->l('Revenue currency: %s'), $currency->iso_code);
|
||||
break;
|
||||
case 3:
|
||||
$this->_titles['main'] = $this->l('Percentage of orders per status.');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Payment method');
|
||||
}
|
||||
$this->_titles['main'][] = $this->l('Percentage of orders per status.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +137,12 @@ class StatsVisits extends ModuleGraph
|
||||
{
|
||||
switch ($option) {
|
||||
case 3:
|
||||
$this->_titles['main'][0] = $this->l('Visits');
|
||||
$this->_titles['main'][1] = $this->l('Number of visits and unique visitors');
|
||||
$this->_titles['main'][2] = $this->l('Visitors');
|
||||
if (Tools::getValue('export')) {
|
||||
$this->_titles['main'][] = $this->l('Date');
|
||||
}
|
||||
|
||||
$this->_titles['main'][] = $this->l('Visits');
|
||||
$this->_titles['main'][] = $this->l('Number of visits and unique visitors');
|
||||
$this->query[0] = 'SELECT date_add, COUNT(`date_add`) as total
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE 1
|
||||
|
||||
@@ -273,6 +273,8 @@
|
||||
font-weight: 400;}
|
||||
#search_occupancy_wrapper .occupancy_info_block .qty_direction .occupancy_quantity_down {
|
||||
margin-top: 3px;}
|
||||
#search_occupancy_wrapper .occupancy-input-errors {
|
||||
font-weight: 700;}
|
||||
|
||||
#search_occupancy_wrapper .children_ages {
|
||||
display: grid;
|
||||
|
||||
@@ -447,6 +447,16 @@ $(document).ready(function() {
|
||||
|
||||
// set input field value
|
||||
$(this).closest('.occupancy_count_block').find('.occupancy_count > span').text(elementVal);
|
||||
} else {
|
||||
if (elementVal >= max_child_in_room) {
|
||||
if (elementVal == 0) {
|
||||
showOccupancyError(no_children_allowed_txt, $(this).closest(".occupancy_info_block"));
|
||||
} else {
|
||||
showOccupancyError(max_children_txt, $(this).closest(".occupancy_info_block"));
|
||||
}
|
||||
} else {
|
||||
showOccupancyError(max_occupancy_reached_txt, $(this).closest(".occupancy_info_block"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
element.val(elementVal);
|
||||
@@ -458,6 +468,18 @@ $(document).ready(function() {
|
||||
setGuestOccupancy();
|
||||
});
|
||||
|
||||
var errorMsgTime;
|
||||
function showOccupancyError(msg, occupancy_info_block)
|
||||
{
|
||||
var errorMsgBlock = $(occupancy_info_block).find('.occupancy-input-errors')
|
||||
$(errorMsgBlock).html(msg).parent().show('fast');
|
||||
clearTimeout(errorMsgTime);
|
||||
errorMsgTime = setTimeout(function() {
|
||||
$(errorMsgBlock).parent().hide('fast');
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
|
||||
$(document).on('click', '#search_occupancy_wrapper .occupancy_quantity_down', function(e) {
|
||||
e.preventDefault();
|
||||
// set input field value
|
||||
|
||||
@@ -112,6 +112,8 @@
|
||||
<p class="label-desc-txt">({l s='Below' mod='wkroomsearchblock'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='wkroomsearchblock'})</p>
|
||||
</div>
|
||||
</div>
|
||||
<p style="display:none;"><span class="text-danger occupancy-input-errors"></span></p>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group children_age_info_block col-sm-12" {if isset($occupancy['child_ages']) && $occupancy['child_ages']}style="display:block;"{/if}>
|
||||
<label>{l s='All Children' mod='wkroomsearchblock'}</label>
|
||||
@@ -186,6 +188,7 @@
|
||||
<p class="label-desc-txt">({l s='Below' mod='wkroomsearchblock'} {$max_child_age|escape:'htmlall':'UTF-8'} {l s='years' mod='wkroomsearchblock'})</p>
|
||||
</div>
|
||||
</div>
|
||||
<p style="display:none;"><span class="text-danger occupancy-input-errors"></span></p>
|
||||
<div class="row">
|
||||
<div class="form-group children_age_info_block col-sm-12">
|
||||
<label>{l s='All Children' mod='wkroomsearchblock'}</label>
|
||||
|
||||
Reference in New Issue
Block a user