Merge branch 'origin/develop' into gli-1751

This commit is contained in:
vishalsingh.qlo325
2024-03-15 15:19:23 +05:30
325 changed files with 6027 additions and 6920 deletions

View File

@@ -27,4 +27,6 @@
max-height: 55px
max-width: 55px
.room_status_info_form
.room_status
white-space: normal

View File

@@ -64,7 +64,7 @@ $sidebar-menu-hover-color: white !default
$sidebar-menu-bg-hover-color: #282b30
// Toolbar
$toolbar-buttons-color: #2eacce
$toolbar-buttons-color: #00aff0
$toolbar-buttons-hover-color: #40c9ed
// Scaffolding

View File

@@ -229,6 +229,7 @@ $chosen-sprite-path: '../img/chosen-sprite.png'
border: 0 !important
color: $gray
height: $chosen-multi-height - 8px
width: 100% !important
margin: 0
padding: 4px
outline: 0
@@ -297,6 +298,15 @@ $chosen-sprite-path: '../img/chosen-sprite.png'
.search-field input
color: #111 !important
.chosen-container-multi.chosen-options-horizontal .chosen-choices
max-height: 55px !important
white-space: nowrap
overflow-x: auto
.chosen-container-multi.chosen-options-horizontal .chosen-choices li
float: none
display: inline-block
.chosen-disabled
cursor: default
opacity: 0.5 !important
@@ -343,4 +353,7 @@ $chosen-sprite-path: '../img/chosen-sprite.png'
.chosen-search input
background: url($chosen-sprite-path) no-repeat -28px -20px, $chosen-background
direction: rtl
padding: 4px 5px 4px 20px
padding: 4px 5px 4px 20px
#list_filters_panel .chosen-container
width: 100% !important

View File

@@ -16,7 +16,7 @@ body
@include float(left)
#content.bootstrap
padding: 120px 10px 0
padding: 90px 10px 0
@include transition-property(margin)
@include transition-duration(0.4s)
@include transition-timing-function(ease-out)

View File

@@ -1,6 +1,6 @@
.page-head
width: 100%
height: 100px
height: 78px
padding: 0
margin: 0
position: fixed
@@ -14,10 +14,11 @@
@include float(left)
position: relative
margin: 0
font: 20pt $font-family-sans-serif
font: 14pt $font-family-sans-serif
font-weight: bold
color: #363A41
white-space: nowrap
@include padding(26px, 0, 0, ($widthSidebarNav+20px))
@include padding(31px, 0, 0, ($widthSidebarNav+20px))
@media (max-width: $screen-tablet)
@include padding(26px, 0, 0, 70px)
a
@@ -40,6 +41,7 @@
position: absolute
background-color: transparent!important
@include right(0)
top: 18px
@media (max-width: $screen-sm)
#toolbar-nav
border: none
@@ -48,37 +50,54 @@
@include padding(3px, 0, 0, 0)
.toolbar_btn
position: relative
padding: 20px 5px !important
padding: 10px 10px !important
font-size: 12px
line-height: 8px
color: $main-color
color: $toolbar-buttons-color
text-align: center
text-shadow: none
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
border: 1px solid $toolbar-buttons-color
border-radius: 2px
@include margin(0, 3px, 2px, 0)
@media (max-width: $screen-desktop)
width: 46px
font-size: 11px
div
color: #363A41
i
color: $toolbar-buttons-color
display: inline
font-size: 18px
&:hover
color: $toolbar-buttons-hover-color
div
padding-top: 10px
span
position: relative
top: -2px
left: 2px
color: #363A41
font-weight: 400
.dropdown-toolbar
display: none
@include float(right)
@include border-radius(3px)
@media (max-width: $screen-sm)
display: block
padding: 6px 10px !important
margin-right: 10px
@media (max-width: $screen-xs)
margin-right: 5px
#toolbar-nav
li + li
margin-left: 8px
ul.page-breadcrumb
position: absolute
list-style: none
margin: 0
padding: 0
top: 4px
top: 9px
height: 20px
line-height: 20px
color: black

View File

@@ -49,7 +49,7 @@
<li>
<a id="desc-module-update-all" class="toolbar_btn" href="{$currentIndex|escape:'html':'UTF-8'}&amp;token={$token|escape:'html':'UTF-8'}&amp;updateAll=1" title="{l s='Update all'}">
<i class="process-icon-refresh"></i>
<div>{l s='Update all'}</div>
<span>{l s='Update all'}</span>
</a>
</li>
{/if}
@@ -57,14 +57,14 @@
<li>
<a id="desc-module-check-and-update-all" class="toolbar_btn" href="{$currentIndex|escape:'html':'UTF-8'}&amp;token={$token|escape:'html':'UTF-8'}&amp;check=1" title="{l s='Check for update'}">
<i class="process-icon-refresh"></i>
<div>{l s='Check for update'}</div>
<span>{l s='Check for update'}</span>
</a>
</li>
{/if}
<li>
<a id="desc-module-catalog" class="toolbar_btn anchor" href="{$link->getAdminLink('AdminModulesCatalog')}" title="{l s='Recommended Modules and Services'}">
<i class="process-icon-modules-list"></i>
<div>{l s='Recommended Modules and Services'}</div>
<span>{l s='Recommended Modules and Services'}</span>
</a>
</li>
{if $add_permission eq '1'}
@@ -72,14 +72,14 @@
<li>
<a id="desc-module-new" class="toolbar_btn anchor" href="#" onclick="$('#module_install').slideToggle();" title="{l s='Add a new module'}">
<i class="process-icon-new"></i>
<div>{l s='Add a new module'}</div>
<span>{l s='Add a new module'}</span>
</a>
</li>
{else}
<li>
<a id="desc-module-new" class="toolbar_btn" href="{$link->getAdminLink('AdminModules')}&addnewmodule" title="{l s='Add a new module'}">
<i class="process-icon-new"></i>
<div>{l s='Add a new module'}</div>
<span>{l s='Add a new module'}</span>
</a>
</li>
{/if}

View File

@@ -391,7 +391,7 @@
</div>
</div>
<div id="allow_multiple_quantity_container" {if (!$product->available_for_order && $product->isAssociatedToShop()) || $product->auto_add_to_cart}style="display:none;"{/if}>
<div id="allow_multiple_quantity_container" {if $product->auto_add_to_cart && $product->isAssociatedToShop()}style="display:none;"{/if}>
<div class="form-group">
<label class="control-label col-lg-3">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='When enabled, customer can order multiple quantity of product otherwise only one quantity can be purchased by customer per room/hotel'}">
@@ -412,7 +412,7 @@
</span>
</div>
</div>
<div id="max_quantity_container" class="form-group" {if (!$product->available_for_order && $product->isAssociatedToShop()) || $product->auto_add_to_cart || !$product->allow_multiple_quantity}style="display:none;"{/if}>
<div id="max_quantity_container" class="form-group" {if ($product->auto_add_to_cart && $product->isAssociatedToShop()) || !$product->allow_multiple_quantity}style="display:none;"{/if}>
<label class="control-label col-lg-3" for="max_quantity">
<span class="label-tooltip" data-toggle="tooltip"
title="{l s='Enter max allowed quantity per room, enter 0 for unlimited.'}">

View File

@@ -46,7 +46,7 @@
{assign var=curr_id value=$cart->id_currency|intval}
{foreach from=$cart_detail_data item=data}
<tr data-id-booking-data="{$data.id}" data-id-product="{$data.id_product}" data-id-room="{$data.id_room}" data-date-from="{$data.date_from}" data-date-to="{$data.date_to}" >
<td>{$data.room_num|escape:'html':'UTF-8'}</td>
<td>{$data.room_num|escape:'html':'UTF-8'} {hook h='displayRoomNumAfter' data=$data type='adminOrder'}</td>
<td><img src="{$data.image_link|escape:'html':'UTF-8'}" title="Room image" /></td>
<td>
<p>{$data.room_type|escape:'html':'UTF-8'}</p>

View File

@@ -0,0 +1,25 @@
{**
* 2010-2024 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2024 Webkul IN
* @license LICENSE.txt
*}
{if is_array($hotel_rooms_info) && count($hotel_rooms_info)}
<option value="" selected="selected">-</option>
{foreach from=$hotel_rooms_info item=hotel_room}
<option value="{$hotel_room.id}">{$hotel_room.room_num}, {$hotel_room.room_type_name}, {$hotel_room.hotel_name}</option>
{/foreach}
{/if}

View File

@@ -0,0 +1,25 @@
{**
* 2010-2024 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2024 Webkul IN
* @license LICENSE.txt
*}
{if is_array($room_types_info) && count($room_types_info)}
<option value="" selected="selected">-</option>
{foreach from=$room_types_info item=room_type}
<option value="{$room_type.id_product}">{$room_type.room_type}, {$room_type.hotel_name}</option>
{/foreach}
{/if}

View File

@@ -23,10 +23,10 @@
* International Registered Trademark & Property of PrestaShop SA
*}
<tr class="product-line-row" data-id_room="{$data.id_room}" data-id_product="{$data.id_product}" data-id_hotel="{$data.id_hotel}" data-date_from="{$data.date_from}" data-date_to="{$data.date_to}" data-product_price="{$data.unit_amt_tax_incl}" data-id_order_detail="{$data.id_order_detail}">
<tr class="product-line-row" data-id_htl_booking="{$data.id|escape:'html':'UTF-8'}" data-id_room="{$data.id_room}" data-id_product="{$data.id_product}" data-id_hotel="{$data.id_hotel}" data-date_from="{$data.date_from}" data-date_to="{$data.date_to}" data-product_price="{$data.unit_amt_tax_incl}" data-id_order_detail="{$data.id_order_detail}">
{if $refund_allowed}
<td class="standard_refund_fields" style="display:none">
<input type="checkbox" name="id_htl_booking[]" value="{$data.id|escape:'html':'UTF-8'}" {if isset($refundReqBookings) && ($data.id|in_array:$refundReqBookings)}disabled{/if}/>
<input type="checkbox" name="id_htl_booking[]" value="{$data.id|escape:'html':'UTF-8'}" {if (isset($refundReqBookings) && ($data.id|in_array:$refundReqBookings)) || $data.is_refunded}disabled{/if}/>
</td>
{/if}
<td class="text-center">
@@ -261,7 +261,7 @@
<li>
<a href="#" data-toggle="modal" data-target="#mySwappigModal" data-id_order="{$order->id}" data-room_num='{$data.room_num}' data-date_from='{$data.date_from}' data-date_to='{$data.date_to}' data-id_room='{$data.id_room}' data-cust_name='{$data.alloted_cust_name}' data-cust_email='{$data.alloted_cust_email}' data-avail_rm_swap='{$data.avail_rooms_to_swap|@json_encode}' data-avail_rm_realloc='{$data.avail_rooms_to_realloc|@json_encode}'>
<i class="icon-refresh"></i>
{l s='Reallocate Room'}
{l s='Reallocate/Swap Room'}
</a>
</li>
<li>
@@ -283,4 +283,4 @@
</button>
</td>
{/if}
</tr>
</tr>

View File

@@ -122,25 +122,37 @@
{if ($params.type == 'date' || $params.type == 'datetime' || $params.type == 'range') && $params.value|is_array}
{assign var="filter_value" value=''}
{foreach $params.value as $value}
{if ($value|is_string && !empty($value))}
{if empty($filter_value)}
{if (isset($value) && ($value !== '' || $value === 0))}
{if !(isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
{assign var="filter_value" value=$value}
{else}
{assign var="filter_value" value="`$filter_value` - `$value`"}
{/if}
{/if}
{/foreach}
{if !empty($filter_value)}
{if (isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
<span data-filter_key="{if isset($params.name_date)}{$params.name_date}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$filter_value|escape:'html':'UTF-8'}</span>
<i class="icon-times"></i>
</span>
{/if}
{else if $params.type == 'select'}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$params['list'][$params['value']]|escape:'html':'UTF-8'}</span>
<i class="icon-times"></i>
</span>
{elseif $params.type == 'select'}
{if isset($params.multiple) && $params.multiple}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}" data-multiple="{$params.multiple|intval}" data-operator="{$params.operator}">
{$params['title']|escape:'html':'UTF-8'}:
<span class="filter_value">
{foreach from=$params.value item=option name=foreachInfo}
{$params.list[$option]}{if !$smarty.foreach.foreachInfo.last}{if $params.operator == 'or'} | {else}, {/if}{/if}
{/foreach}
</span>
<i class="icon-times"></i>
</span>
{else}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$params['list'][$params['value']]|replace: '&nbsp;' : ''}</span>
<i class="icon-times"></i>
</span>
{/if}
{else}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$params['value']|escape:'html':'UTF-8'}</span>
@@ -166,7 +178,7 @@
<input type="text" class="filter form-control" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}[0]" placeholder="{l s='From'}" value="{if isset($params.value.0)}{$params.value.0}{/if}">
<input type="text" class="filter form-control" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}[1]" placeholder="{l s='To'}" value="{if isset($params.value.1)}{$params.value.1}{/if}">
</div>
{else if $params.type == 'bool'}
{elseif $params.type == 'bool'}
<select id="filter_input_{$key}" class="filter fixed-width-sm center" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}">
<option value="">-</option>
<option value="1" {if $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option>
@@ -217,7 +229,7 @@
let dateFrom = $('#local_{$params.id_date}_0').val().trim();
let dateTo = $('#local_{$params.id_date}_1').val().trim();
if (dateFrom >= dateTo) {
if ((dateFrom && dateTo) && (dateFrom >= dateTo)) {
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
objDateToMin.setDate(objDateToMin.getDate() + 1);
@@ -245,18 +257,28 @@
</script>
</div>
{elseif $params.type == 'select'}
{if isset($params.filter_key)}
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if}" onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();" name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
<option value="" {if $params.value == ''} selected="selected" {/if}>-</option>
{if isset($params.multiple) && $params.multiple}
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if} select_multiple_{$params.operator} chosen chosen-options-horizontal" multiple name="{$list_id}Filter_{$params.filter_key}[]" {if isset($params.width)} style="width:{$params.width}px"{/if}>
{if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display}
<option value="{$option_value}" {if (string)$option_display === (string)$params.value || (string)$option_value === (string)$params.value} selected="selected"{/if}>{$option_display}</option>
<option value="{$option_value}" {if isset($params.value) && $params.value}{if in_array($option_value, $params.value)} selected="selected"{/if}{/if}>{$option_display}</option>
{/foreach}
{/if}
</select>
{else}
{if isset($params.filter_key)}
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if} {if isset($params.class)}{$params.class}{/if}" {if !isset($params.remove_onchange) || !$params.remove_onchange}onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();"{/if} name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
<option value="" {if $params.value == ''} selected="selected" {/if}>-</option>
{if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display}
<option value="{$option_value}" {if (string)$option_display === (string)$params.value || (string)$option_value === (string)$params.value} selected="selected"{/if}>{$option_display}</option>
{/foreach}
{/if}
</select>
{/if}
{/if}
{else}
<input type="text" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'html':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
<input type="text" id="filter_input_{$key}" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'html':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
{/if}
</div>
</div>
@@ -297,12 +319,112 @@
} else if (type == 'range') {
$('#list_filters_panel').find('[name*="orderFilter_'+$(this).parent().data('filter_key')+'"]').val('');
} else if (type == 'select') {
$('#list_filters_panel').find('select[name="orderFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop("selected", false);
$('#list_filters_panel').find('select[name*="orderFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop('selected', false);
} else {
$('#list_filters_panel').find('input[name="orderFilter_'+$(this).parent().data('filter_key')+'"]').val('');
}
// set post data for empty multi-select filters
$(form).find('select[multiple]').each(function (i, selectElement) {
if ($(selectElement).find('option:selected').length == 0) {
$(form).append('<input type="hidden" name="' + $(selectElement).attr('name').slice(0, -2) + '" value="">');
}
});
form.submit();
});
$('#form-order').submit(function () {
let form = $(this);
$(form).find('select[multiple]').each(function (i, selectElement) {
if ($(selectElement).val() == null) {
$(form).append('<input type="hidden" name="' + $(selectElement).attr('name').slice(0, -2) + '" value="">');
}
});
return true;
});
});
function updateRoomTypeFilter() {
let filterInputHotelName = $('#filter_input_hotel_name');
let filterInputRoomTypeName = $('#filter_input_room_type_name');
let idHotel = parseInt($(filterInputHotelName).val() || '0');
$.ajax({
url: currentIndex + '&token=' + token,
data: {
ajax: true,
action: 'GetHotelRoomTypes',
id_hotel: idHotel,
},
type: 'POST',
dataType: 'JSON',
success: function(response) {
if (response.status) {
if (response.has_room_types) {
$(filterInputRoomTypeName).html(response.html_room_types);
} else {
$(filterInputRoomTypeName).find('option').not(':first').remove();
}
// destroy current chosen and re-initialize
$(filterInputRoomTypeName).chosen('destroy');
$(filterInputRoomTypeName).chosen({
disable_search_threshold: 5,
search_contains: true,
});
}
},
});
}
function updateHotelRoomsFilter(useRoomType = true) {
let filterInputHotelName = $('#filter_input_hotel_name');
let filterInputRoomTypeName = $('#filter_input_room_type_name');
let filterInputRoomNumber = $('#filter_input_id_room_information');
let idHotel = parseInt($(filterInputHotelName).val() || '0');
let idProduct = parseInt($(filterInputRoomTypeName).val() || '0');
$.ajax({
url: currentIndex + '&token=' + token,
data: {
ajax: true,
action: 'GetHotelRooms',
id_hotel: idHotel,
id_product: useRoomType ? idProduct : 0,
},
type: 'POST',
dataType: 'JSON',
success: function(response) {
if (response.status) {
if (response.has_hotel_rooms) {
$(filterInputRoomNumber).html(response.html_hotel_rooms);
} else {
$(filterInputRoomNumber).find('option').not(':first').remove();
}
// destroy current chosen and re-initialize
$(filterInputRoomNumber).chosen('destroy');
$(filterInputRoomNumber).chosen({
disable_search_threshold: 5,
search_contains: true,
});
}
},
});
}
// manage Hotel and Room type filter inputs
$(document).on('change', '#filter_input_hotel_name', function () {
updateRoomTypeFilter();
updateHotelRoomsFilter(false);
});
$(document).on('change', '#filter_input_room_type_name', function () {
updateHotelRoomsFilter();
});
</script>
<style>
@@ -354,7 +476,7 @@
.list_filters {
padding: 0 30px;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(3, minmax(0, 1fr));;
gap: 8px 40px;}
.list_filters > .row {
display: flex;

View File

@@ -157,7 +157,8 @@
{/if} -->
<!-- End -->
&nbsp;
{if $refund_allowed && !$hasCompletelyRefunded}
<!-- Check if refund is allowed and all bookings are not requested for refund -->
{if $refund_allowed && !$completeRefundRequestOrCancel}
<a id="desc-order-standard_refund" class="btn btn-default" href="#refundForm">
<i class="icon-exchange"></i>
{if $order->getTotalPaid()|floatval}
@@ -232,23 +233,26 @@
</table>
</div>
<!-- Change status form -->
<form action="{$currentIndex|escape:'html':'UTF-8'}&amp;vieworder&amp;token={$smarty.get.token}" method="post" class="form-horizontal well hidden-print">
<div class="row">
<div class="col-lg-9">
<select id="id_order_state" class="chosen form-control" name="id_order_state">
{foreach from=$states item=state}
<option value="{$state['id_order_state']|intval}"{if isset($currentState) && $state['id_order_state'] == $currentState->id} selected="selected" disabled="disabled"{/if}>{$state['name']|escape}</option>
{/foreach}
</select>
<input type="hidden" name="id_order" value="{$order->id}" />
</div>
<div class="col-lg-3">
<button type="submit" name="submitState" class="btn btn-primary">
{l s='Update status'}
</button>
</div>
</div>
</form>
{* If current state is refunded or cancelled the further order status changes are not allowed *}
{if !isset($currentState) || (isset($currentState) && ($currentState->id != Configuration::get('PS_OS_REFUND') && $currentState->id != Configuration::get('PS_OS_CANCELED')))}
<form action="{$currentIndex|escape:'html':'UTF-8'}&amp;vieworder&amp;id_order={$order->id|intval}&amp;token={$smarty.get.token}" method="post" class="form-horizontal well hidden-print">
<div class="row">
<div class="col-lg-9">
<select id="id_order_state" class="chosen form-control" name="id_order_state">
{foreach from=$states item=state}
<option value="{$state['id_order_state']|intval}"{if isset($currentState) && $state['id_order_state'] == $currentState->id} selected="selected" disabled="disabled"{elseif ($state['id_order_state'] == Configuration::get('PS_OS_REFUND') && !$allBookingsRefunded)} disabled="disabled"{elseif ($state['id_order_state'] == Configuration::get('PS_OS_CANCELED') && !$allBookingsCancelled)} disabled="disabled"{elseif ($state['id_order_state'] == Configuration::get('PS_OS_OVERBOOKING_PAID') || $state['id_order_state'] == Configuration::get('PS_OS_OVERBOOKING_UNPAID') || $state['id_order_state'] == Configuration::get('PS_OS_OVERBOOKING_PARTIAL_PAID')) && (!isset($orderOverBookings) || !$orderOverBookings)} disabled="disabled"{/if}>{$state['name']|escape}</option>
{/foreach}
</select>
<input type="hidden" name="id_order" value="{$order->id}" />
</div>
<div class="col-lg-3">
<button type="submit" name="submitState" class="btn btn-primary">
{l s='Update status'}
</button>
</div>
</div>
</form>
{/if}
</div>
<!-- Tab documents -->
<div class="tab-pane" id="documents">
@@ -277,61 +281,69 @@
<th>{l s='Hotel Name'}</th>
<th>{l s='Duration'}</th>
<th>{l s='Documents'}</th>
<th>{l s='Order Status'}</th>
<th>{l s='Room Status'}</th>
</tr>
{if isset($htl_booking_order_data) && $htl_booking_order_data}
{foreach from=$htl_booking_order_data item=data}
{if !$data.is_refunded}
<tr>
<td>
{$data['room_num']}
</td>
<td>
<a href="{$link->getAdminLink('AdminAddHotel')}&amp;id={$data['id_hotel']}&amp;updatehtl_branch_info" target="_blank">
<span>{$data['hotel_name']}</span>
</a>
</td>
<td>
{dateFormat date=$data['date_from']} - {dateFormat date=$data['date_to']}
</td>
<td>
<a class="btn btn-default" onclick="BookingDocumentsModal.init({$data.id|intval}, this); return false;">
<i class="icon icon-file-text"></i>
{l s='Documents'} <span class="badge badge-info count-documents">{$data.num_checkin_documents}</span>
</a>
</td>
<td>
<form action="" method="post" class="form-horizontal row room_status_info_form">
<div class="col-sm-7">
<select name="booking_order_status" class="form-control booking_order_status margin-bottom-5">
{foreach from=$hotel_order_status item=state}
<option value="{$state['id_status']|intval}" {if isset($data.id_status) && $state.id_status == $data.id_status} selected="selected" disabled="disabled"{/if}>{$state.name|escape}</option>
{/foreach}
</select>
<tr>
<td>
{$data['room_num']}
</td>
<td>
<a href="{$link->getAdminLink('AdminAddHotel')}&amp;id={$data['id_hotel']}&amp;updatehtl_branch_info" target="_blank">
<span>{$data['hotel_name']}</span>
</a>
</td>
<td>
{dateFormat date=$data['date_from']} - {dateFormat date=$data['date_to']}
</td>
<td>
<a class="btn btn-default" onclick="BookingDocumentsModal.init({$data.id|intval}, this); return false;">
<i class="icon icon-file-text"></i>
{l s='Documents'} <span class="badge badge-info count-documents">{$data.num_checkin_documents}</span>
</a>
</td>
<td>
<form action="" method="post" class="form-horizontal row room_status_info_form">
<div class="col-sm-7">
{if $data.is_refunded || $data.is_cancelled}
{if $data['id_status'] == $hotel_order_status['STATUS_ALLOTED']['id_status']}
<p><span class="room_status badge badge-infomation">{l s='Room alloted'}</span></p>
{/if}
{else}
<select name="booking_order_status" class="form-control booking_order_status margin-bottom-5">
{foreach from=$hotel_order_status item=state}
<option value="{$state['id_status']|intval}" {if isset($data.id_status) && $state.id_status == $data.id_status} selected="selected" disabled="disabled"{/if}>{$state.name|escape}</option>
{/foreach}
</select>
{/if}
{if $data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']}
<p class="text-center"><span class="badge badge-success margin-bottom-5">{l s='Checked in on'} {dateFormat date=$data['check_in']}</span></p>
{elseif $data['id_status'] == $hotel_order_status['STATUS_CHECKED_OUT']['id_status']}
<p class="text-center"><span class="badge badge-success margin-bottom-5">{l s='Checked out on'} {dateFormat date=$data['check_out']}</span></p>
{/if}
{if $data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']}
<p><span class="room_status badge badge-success">{l s='Checked in on'} {dateFormat date=$data['check_in']}</span></p>
{elseif $data['id_status'] == $hotel_order_status['STATUS_CHECKED_OUT']['id_status']}
<p><span class="room_status badge badge-success">{l s='Checked out on'} {dateFormat date=$data['check_out']}</span></p>
{/if}
{* field for the current date *}
<input class="room_status_date wk-input-date" type="text" name="status_date" value="{if $data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']}{$data['date_to']|date_format:"%d-%m-%Y"}{else}{$data['date_from']|date_format:"%d-%m-%Y"}{/if}" readonly/>
{* field for the current date *}
<input class="room_status_date wk-input-date" type="text" name="status_date" value="{if $data['id_status'] == $hotel_order_status['STATUS_CHECKED_IN']['id_status']}{$data['date_to']|date_format:"%d-%m-%Y"}{else}{$data['date_from']|date_format:"%d-%m-%Y"}{/if}" readonly/>
<input type="hidden" name="date_from" value="{$data['date_from']|date_format:"%Y-%m-%d"}" />
<input type="hidden" name="date_to" value="{$data['date_to']|date_format:"%Y-%m-%d"}" />
<input type="hidden" name="id_room" value="{$data['id_room']}" />
<input type="hidden" name="id_order" value="{$order->id}" />
</div>
<div class="col-sm-5">
<button type="submit" name="submitbookingOrderStatus" class="btn btn-primary">
{l s='Update Status'}
</button>
</div>
</form>
</td>
</tr>
{/if}
<input type="hidden" name="date_from" value="{$data['date_from']|date_format:"%Y-%m-%d"}" />
<input type="hidden" name="date_to" value="{$data['date_to']|date_format:"%Y-%m-%d"}" />
<input type="hidden" name="id_room" value="{$data['id_room']}" />
<input type="hidden" name="id_order" value="{$order->id}" />
</div>
<div class="col-sm-5 text-right">
{if $data.is_refunded || $data.is_cancelled}
<span class="badge badge-danger">{if $data.is_cancelled}{l s='Cancelled'}{else}{l s='Refunded'}{/if}</span>
{else}
<button type="submit" name="submitbookingOrderStatus" class="btn btn-primary">
{l s='Update Status'}
</button>
{/if}
</div>
</form>
</td>
</tr>
{/foreach}
{else}
<tr>
@@ -1187,9 +1199,11 @@
<input type="hidden" name="TaxMethod" value="1">
{/if}
{if $can_edit}
<div class="row-margin-bottom row-margin-top standard_refund_fields" style="display: none;">
<textarea class="cancellation_reason" name="cancellation_reason" placeholder="{l s='Enter reason to cancel bookings'}"></textarea>
</div>
{if $refund_allowed && !$completeRefundRequestOrCancel}
<div class="row-margin-bottom row-margin-top standard_refund_fields" style="display: none;">
<textarea class="cancellation_reason" name="cancellation_reason" placeholder="{l s='Enter reason to cancel bookings'}"></textarea>
</div>
{/if}
<div class="row-margin-bottom row-margin-top order_action">
{if !$order->hasBeenDelivered()}
{* <button type="button" id="add_product" class="btn btn-default">
@@ -1206,7 +1220,7 @@
{l s='Add a new discount'}
</button>
{if $refund_allowed && !$hasCompletelyRefunded}
{if $refund_allowed && !$completeRefundRequestOrCancel}
<div class="pull-right">
<button style="display: none;" type="button" class="btn btn-default standard_refund_fields" id="cancelRefund">
{l s='Cancel'}
@@ -1396,16 +1410,14 @@
</tr>
{/if}
{if $order->total_paid_tax_incl > $order->total_paid_real}
<tr>
<td class="text-right"><strong>{l s='Due Amount'}</strong></td>
<td class="amount text-right nowrap">
<strong>
{displayPrice currency=$order->id_currency price=($order->total_paid_tax_incl - $order->total_paid_real)}
</strong>
</td>
</tr>
{/if}
<tr>
<td class="text-right"><strong>{l s='Due Amount'}</strong></td>
<td class="amount text-right nowrap">
<strong>
{displayPrice currency=$order->id_currency price=($order->total_paid_tax_incl - $order->total_paid_real)}
</strong>
</td>
</tr>
</table>
</div>
</div>
@@ -1631,6 +1643,7 @@
{addJsDefL name='invalid_occupancy_txt'}{l s='Invalid occupancy(adults/children) found.' js=1}{/addJsDefL}
{addJsDef max_child_age=$max_child_age|escape:'quotes':'UTF-8'}
{addJsDef max_child_in_room=$max_child_in_room|escape:'quotes':'UTF-8'}
{addJsDefL name='undo_cancellation_success'}{l s='Booking cancellation undo process is done successfully.' js=1}{/addJsDefL}
{/strip}
{* Apply javascript for the page *}
@@ -1657,12 +1670,10 @@
{* open date picker for the date input of check-in checkout dates *}
$(document).on('focus', '.room_status_date', function() {
var dateFrom = $(this).closest('.room_status_info_form').find('[name="date_from"]').val();
dateFrom = dateFrom.split("-");
minDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(dateFrom[0], dateFrom[1] - 1, dateFrom[2])));
minDate = $.datepicker.parseDate('yy-mm-dd', dateFrom);
var dateTo = $(this).closest('.room_status_info_form').find('[name="date_to"]').val();
dateTo = dateTo.split("-");
maxDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(dateTo[0], dateTo[1] - 1, dateTo[2])));
maxDate = $.datepicker.parseDate('yy-mm-dd', dateTo);
$(this).datepicker({
dateFormat: 'dd-mm-yy',
@@ -2119,4 +2130,4 @@
});
</script>
{/block}
{/block}

View File

@@ -20,7 +20,7 @@
{if isset($product->id)}
<div id="product-configuration" class="panel product-tab">
<input type="hidden" name="submitted_tabs[]" value="Configuration" />
<h3 class="tab"> <i class="icon-AdminAdmin"></i> {l s='Configuration'}</h3>
<h3 class="tab"> <i class="icon-AdminAdmin"></i> {l s='Rooms'}</h3>
<input type="hidden" id="checkConfSubmit" value="0" name="checkConfSubmit">
@@ -101,6 +101,8 @@
</td>
<td class="col-sm-1 center">
{if isset($room_info['id'])}
<input type="hidden" class="booked-dates" name="{$var_name_room_info|cat:'[booked_dates]'}" value="{$room_info['booked_dates']|escape:'html':'UTF-8'}">
<a href="#" class="view_htl_room btn btn-default" data-toggle="modal" data-target="#room-dates-modal" data-id-room="{$room_info['id']}"><i class="icon-info"></i></a>
<a href="#" class="rm_htl_room btn btn-default" data-id-htl-info="{$room_info['id']}"><i class="icon-trash"></i></a>
<input type="hidden" name="{$var_name_room_info|cat:'[id]'}" value="{$room_info['id']}">
{else}
@@ -224,6 +226,36 @@
</div>
{*END*}
<div class="modal fade" id="room-dates-modal" tabindex="-1" role="dialog" aria-labelledby="">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close margin-right-10" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><i class="icon-calendar"></i>&nbsp; {l s='Upcoming bookings'}</h4>
</div>
<div class="room-booked-dates-table modal-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><span>{l s='Order'}</span></th>
<th><span>{l s='Date From'}</span></th>
<th><span>{l s='Date To'}</span></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-label="Close">{l s='Done'}</button>
</div>
</div>
</div>
</div>
<style>
.deactiveDatesModal {
cursor: pointer;
@@ -400,6 +432,30 @@
});
});
{literal}
$('#room-dates-modal').on('show.bs.modal', function(e) {
const triggerRoom = $(e.relatedTarget);
$('#room-dates-modal tbody').html('');
var bookedDates = JSON.parse($(triggerRoom).closest('tr').find('.booked-dates').val());
if (bookedDates.length) {
if (bookedDates.length) {
$('#room-dates-modal .room-booked-dates-table').show();
$(bookedDates).each(function() {
$('#room-dates-modal .room-booked-dates-table tbody').append(`<tr>
<td><a href="{/literal}{$link->getAdminLink('AdminOrders')|escape:'html':'UTF-8'}{literal}&vieworder&id_order=${this.id_order}" target="_blank">#${this.id_order}</a></td>
<td>${this.date_from_formatted}</td>
<td>${this.date_to_formatted}</td>
</tr>`);
});
}
} else {
$('#room-dates-modal .room-booked-dates-table tbody').append(`<tr>
<td colspan="3" class="center">{/literal}{l s='No Booking for this room'}{literal}</td>
</tr>`);
}
});
{/literal}
// Add new room detail
$('#add-more-rooms-button').on('click',function() {
var lengthRooms = parseInt($('.room_data_values').length);
@@ -444,18 +500,19 @@
$.ajax({
url: prod_link,
type: 'POST',
dataType: 'text',
dataType: 'JSON',
data: {
ajax:true,
action:'deleteHotelRoom',
id: id_htl_info,
},
success: function (result) {
if (parseInt(result) == 1) {
success: function (response) {
if (response.success) {
showSuccessMessage("{l s='Removed successfully'}");
$current.closest(".room_data_values").remove();
} else {
showErrorMessage("{l s='Some error occurred'}");
if (response.errors)
showErrorMessage(response.errors);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
@@ -499,10 +556,10 @@
dateFormat: 'yy-mm-dd',
minDate: 0,
onSelect: function(selectedDate) {
var date_format = selectedDate.split('-');
selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[0], date_format[1] - 1, date_format[2])));
selectedDate.setDate(selectedDate.getDate() + 1);
$(this).closest('tr').find('.disabled_date_to').datepicker('option', 'minDate', selectedDate);
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', selectedDate);
objDateToMin.setDate(objDateToMin.getDate() + 1);
$(this).closest('tr').find('.disabled_date_to').datepicker('option', 'minDate', objDateToMin);
},
onClose: function(selectedDate) {
var dateTo = $(this).closest('tr').find('.disabled_date_to').val();
@@ -517,16 +574,17 @@
dateFormat: 'yy-mm-dd',
minDate: 0,
beforeShow: function (input, instance) {
var date_to = $(this).closest('tr').find('.disabled_date_from').val();
if (typeof date_to != 'undefined' && date_to != '') {
var date_format = date_to.split('-');
var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date(date_format[0], date_format[1] - 1, date_format[2])));
let dateFrom = $(this).closest('tr').find('.disabled_date_from').val();
let objDateToMin = null;
if (typeof dateFrom != 'undefined' && dateFrom != '') {
objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
} else {
var date_format = new Date();
var selectedDate = new Date($.datepicker.formatDate('yy-mm-dd', new Date()));
objDateToMin = new Date();
}
selectedDate.setDate(selectedDate.getDate()+1);
$(this).datepicker('option', 'minDate', selectedDate);
objDateToMin.setDate(objDateToMin.getDate() + 1);
$(this).datepicker('option', 'minDate', objDateToMin);
},
});
});

View File

@@ -0,0 +1,53 @@
{**
* 2010-2024 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through LICENSE.txt file inside our module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to CustomizationPolicy.txt file inside our module for more information.
*
* @author Webkul IN
* @copyright 2010-2024 Webkul IN
* @license LICENSE.txt
*}
{extends file='helpers/list/list_content.tpl'}
{block name='td_content'}
{if isset($tr.$key) && isset($params.position)}
{if $order_by == 'position' && $order_way != 'DESC'}
{assign var=filters_has_value_no_location_hotel value=false}
{foreach $fields_display AS $key => $params}
{if $key != 'id_category_default' && (isset($params['value']) && $params['value'] !== false && $params['value'] !== '')}
{if is_array($params['value']) && trim(implode('', $params['value'])) == ''}
{continue}
{/if}
{assign var=filters_has_value_no_location_hotel value=true}
{break}
{/if}
{/foreach}
{if !$filters_has_value_no_location_hotel}
<div class="dragGroup">
<div class="positions">
{$tr.$key.position + 1}
</div>
</div>
{else}
{$tr.$key.position + 1}
{/if}
{else}
{$tr.$key.position + 1}
{/if}
{else}
{$smarty.block.parent}
{/if}
{/block}

View File

@@ -25,12 +25,393 @@
{extends file="helpers/list/list_header.tpl"}
{block name=leadin}
{if isset($category_tree)}
<div class="bloc-leadin">
<div id="container_category_tree">
{$category_tree}
{block name="tableFilter"}{/block}
{block name="override_form_extra"}
{if !$simple_header && $show_filters}
<script>
$(function() {
if ($("#list_filters_panel .datepicker").length > 0) {
$("#list_filters_panel .datepicker").datepicker({
prevText: '',
nextText: '',
altFormat: 'yy-mm-dd'
});
}
});
</script>
<div class="list_action_wrapper">
<div class="row">
<div class="col-xs-4 col-sm-3 col-md-2">
<div class="list_availibility_container">
<button type="button" class="btn btn-default btn-left btn-block dropdown-toggle" data-toggle="dropdown">
<span>{l s='Available Fields'}
<i class="icon-caret-down pull-right"></i>
</button>
<ul id="optional-list-toggle" class="dropdown-menu">
{foreach $fields_optional as $key => $field}
<li>
<label>
<input type="checkbox" name="list_fields_visibility" value="{$key}" {if isset($field['selected']) && $field['selected']}checked="checked"{/if}>
{$field['title']}
</label>
</li>
{/foreach}
{assign var="fields_optional" value=array()}
</ul>
</div>
</div>
<div class="col-xs-3 col-xs-offset-5 col-sm-2 col-sm-offset-7 col-md-1 col-md-offset-9">
<div class="list_filter_container">
<button type="button" class="btn btn-default btn-block" data-toggle="collapse" data-target="#list_filters_panel">
<i class="icon-sliders"></i>
<span>{l s='Filters'}
</button>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
{if $filters_has_value}
<div id="selected_filter_container">
{l s='Filters: '}
<span class="selected_filters">
{foreach $fields_display AS $key => $params}
{if (!isset($params.search) || $params.search) && $params.value != ''}
{if ($params.type == 'date' || $params.type == 'datetime') && $params.value|is_array}
{assign var="filter_value" value=''}
{foreach $params.value as $value}
{if ($value|is_string && !empty($value))}
{if empty($filter_value)}
{assign var="filter_value" value=$value}
{else}
{assign var="filter_value" value="`$filter_value` - `$value`"}
{/if}
{/if}
{/foreach}
{if !empty($filter_value)}
<span data-filter_key="{if isset($params.name_date)}{$params.name_date}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$filter_value|escape:'html':'UTF-8'}</span>
<i class="icon-times"></i>
</span>
{/if}
{elseif $params.type == 'range' && $params.value|is_array}
{assign var="filter_value" value=''}
{foreach $params.value as $value}
{if (isset($value) && ($value !== '' || $value === 0))}
{if !(isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
{assign var="filter_value" value=$value}
{else}
{assign var="filter_value" value="`$filter_value` - `$value`"}
{/if}
{/if}
{/foreach}
{if (isset($filter_value) && ($filter_value !== '' || $filter_value === 0))}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$filter_value|escape:'html':'UTF-8'}</span>
<i class="icon-times"></i>
</span>
{/if}
{elseif $params.type == 'select'}
{if isset($params.multiple) && $params.multiple}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}" data-multiple="{$params.multiple|intval}" data-operator="{$params.operator}">
{$params['title']|escape:'html':'UTF-8'}:
<span class="filter_value">
{foreach from=$params.value item=option name=foreachInfo}
{$params.list[$option]}{if !$smarty.foreach.foreachInfo.last}{if $params.operator == 'or'} | {else}, {/if}{/if}
{/foreach}
</span>
<i class="icon-times"></i>
</span>
{else}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$params['list'][$params['value']]|replace: '&nbsp;' : ''}</span>
<i class="icon-times"></i>
</span>
{/if}
{elseif $params.type == 'bool' && $key == 'advance_payment'}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{if $params['value'] == 1}{l s='Yes'}{elseif $params['value'] == 0}{l s='No'}{/if}</span>
<i class="icon-times"></i>
</span>
{else}
<span data-filter_key="{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" data-filter_type="{$params.type}">
{$params['title']|escape:'html':'UTF-8'}: <span class="filter_value">{$params['value']|escape:'html':'UTF-8'}</span>
<i class="icon-times"></i>
</span>
{/if}
{/if}
{/foreach}
</span>
</div>
{/if}
<div class="panel collapse" id="list_filters_panel">
<div class="row">
<div class="col-sm-12">
<div class="list_filters">
{foreach $fields_display AS $key => $params}
{if !isset($params.search) || $params.search}
<div class="row">
<label class="col-xs-3" for="filter_input_{$key}">{$params['title']|escape:'html':'UTF-8'}</label>
<div class="col-xs-9">
{if $params.type == 'range'}
<div class="input_range">
<input type="text" class="filter form-control" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}[0]" placeholder="{l s='From'}" value="{if isset($params.value.0)}{$params.value.0}{/if}">
<input type="text" class="filter form-control" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}[1]" placeholder="{l s='To'}" value="{if isset($params.value.1)}{$params.value.1}{/if}">
</div>
{else if $params.type == 'bool'}
<select id="filter_input_{$key}" class="filter center" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}">
<option value="">-</option>
<option value="1" {if $params.value == 1} selected="selected" {/if}>{l s='Yes'}</option>
<option value="0" {if $params.value == 0 && $params.value != ''} selected="selected" {/if}>{l s='No'}</option>
</select>
{elseif $params.type == 'date' || $params.type == 'datetime'}
<div class="date_range">
<div class="input-group center">
<input type="text" class="filter datepicker date-input form-control" id="local_{$params.id_date}_0" name="local_{$params.name_date}[0]" placeholder="{l s='From'}" autocomplete="off"/>
<input type="hidden" id="{$params.id_date}_0" name="{$params.name_date}[0]" value="{if isset($params.value.0)}{$params.value.0}{/if}">
<span class="input-group-addon">
<i class="icon-calendar"></i>
</span>
</div>
<div class="input-group center">
<input type="text" class="filter datepicker date-input form-control" id="local_{$params.id_date}_1" name="local_{$params.name_date}[1]" placeholder="{l s='To'}" autocomplete="off"/>
<input type="hidden" id="{$params.id_date}_1" name="{$params.name_date}[1]" value="{if isset($params.value.1)}{$params.value.1}{/if}">
<span class="input-group-addon">
<i class="icon-calendar"></i>
</span>
</div>
<script>
$(function() {
var dateStart = parseDate($("#{$params.id_date}_0").val());
var dateEnd = parseDate($("#{$params.id_date}_1").val());
$("#local_{$params.id_date}_0").datepicker("option", "altField", "#{$params.id_date}_0");
$("#local_{$params.id_date}_1").datepicker("option", "altField", "#{$params.id_date}_1");
if (dateStart !== null){
$("#local_{$params.id_date}_0").datepicker("setDate", dateStart);
}
if (dateEnd !== null){
$("#local_{$params.id_date}_1").datepicker("setDate", dateEnd);
}
$('#local_{$params.id_date}_0').datepicker('option', {
prevText: '',
nextText: '',
dateFormat: 'yy-mm-dd',
beforeShow: function() {
let dateTo = $('#local_{$params.id_date}_1').val().trim();
if (typeof dateTo != 'undefined' && dateTo != '') {
let objDateToMax = $.datepicker.parseDate('yy-mm-dd', dateTo);
objDateToMax.setDate(objDateToMax.getDate() - 1);
$('#local_{$params.id_date}_0').datepicker('option', 'maxDate', objDateToMax);
}
},
onClose: function() {
let dateFrom = $('#local_{$params.id_date}_0').val().trim();
let dateTo = $('#local_{$params.id_date}_1').val().trim();
if (dateFrom >= dateTo) {
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
objDateToMin.setDate(objDateToMin.getDate() + 1);
$('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin);
}
},
});
$('#local_{$params.id_date}_1').datepicker('option', {
prevText: '',
nextText: '',
dateFormat: 'yy-mm-dd',
beforeShow: function() {
let dateFrom = $('#local_{$params.id_date}_0').val().trim();
if (typeof dateFrom != 'undefined' && dateFrom != '') {
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
objDateToMin.setDate(objDateToMin.getDate() + 1);
$('#local_{$params.id_date}_1').datepicker('option', 'minDate', objDateToMin);
}
},
});
});
</script>
</div>
{elseif $params.type == 'select'}
{if isset($params.multiple) && $params.multiple}
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if} select_multiple_{$params.operator} chosen chosen-options-horizontal" multiple name="{$list_id}Filter_{$params.filter_key}[]" {if isset($params.width)} style="width:{$params.width}px"{/if}>
{if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display}
<option value="{$option_value}" {if isset($params.value) && $params.value}{if in_array($option_value, $params.value)} selected="selected"{/if}{/if}>{$option_display}</option>
{/foreach}
{/if}
</select>
{else}
{if isset($params.filter_key)}
<select id="filter_input_{$key}" class="filter{if isset($params.align) && $params.align == 'center'}center{/if} {if isset($params.class)}{$params.class}{/if}" {if !isset($params.remove_onchange) || !$params.remove_onchange}onchange="$('#submitFilterButton{$list_id}').focus();$('#submitFilterButton{$list_id}').click();"{/if} name="{$list_id}Filter_{$params.filter_key}" {if isset($params.width)} style="width:{$params.width}px"{/if}>
<option value="" {if $params.value == ''} selected="selected" {/if}>-</option>
{if isset($params.list) && is_array($params.list)}
{foreach $params.list AS $option_value => $option_display}
<option value="{$option_value}" {if (string)$option_display === (string)$params.value || (string)$option_value === (string)$params.value} selected="selected"{/if}>{$option_display}</option>
{/foreach}
{/if}
</select>
{/if}
{/if}
{else}
<input type="text" class="filter" name="{$list_id}Filter_{if isset($params.filter_key)}{$params.filter_key}{else}{$key}{/if}" value="{$params.value|escape:'html':'UTF-8'}" {if isset($params.width) && $params.width != 'auto'} style="width:{$params.width}px"{/if} />
{/if}
</div>
</div>
{/if}
{/foreach}
{if $has_actions || $show_filters}
<div class="actions">
<hr>
{if $show_filters}
<span class="pull-right">
<button type="submit" id="submitFilterButton{$list_id}" name="submitFilter" class="btn btn-default" data-list-id="{$list_id}">
<i class="icon-search"></i> {l s='Search'}
</button>
{if $filters_has_value}
<button type="submit" name="submitReset{$list_id}" class="btn btn-warning">
<i class="icon-eraser"></i> {l s='Reset'}
</button>
{/if}
</span>
{/if}
</div>
{/if}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#selected_filter_container .selected_filters span i').on('click', function() {
let form = $(this).closest('form');
let type = $(this).parent().data('filter_type');
$(this).parent().remove();
if (type == 'date' || type == 'datetime') {
$('#list_filters_panel').find('[name*="'+$(this).parent().data('filter_key')+'"]').val('');
} else if (type == 'range') {
$('#list_filters_panel').find('[name*="productFilter_'+$(this).parent().data('filter_key')+'"]').val('');
} else if (type == 'select') {
$('#list_filters_panel').find('select[name*="productFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop('selected', false);
} else if (type == 'bool' && $(this).parent().data('filter_key') == 'advance_payment') {
$('#list_filters_panel').find('select[name*="productFilter_'+$(this).parent().data('filter_key')+'"] option:selected').prop('selected', false);
} else {
$('#list_filters_panel').find('input[name*="productFilter_'+$(this).parent().data('filter_key')+'"]').val('');
}
// set post data for empty multi-select filters
$(form).find('select[multiple]').each(function (i, selectElement) {
if ($(selectElement).find('option:selected').length == 0) {
$(form).append('<input type="hidden" name="' + $(selectElement).attr('name').slice(0, -2) + '" value="">');
}
});
form.submit();
});
$('#form-product').submit(function () {
let form = $(this);
$(form).find('select[multiple]').each(function (i, selectElement) {
if ($(selectElement).val() == null) {
$(form).append('<input type="hidden" name="' + $(selectElement).attr('name').slice(0, -2) + '" value="">');
}
});
return true;
});
});
</script>
<style>
.list_action_wrapper {
margin-bottom: 15px;
}
.list_availibility_container {
position: relative;}
.list_availibility_container .dropdown-menu {
right: 0;
padding: 8px 12px;}
.list_availibility_container .dropdown-menu label {
font-weight: 400;}
#selected_filter_container {
background-color: #fff;
padding: 8px 20px;
border: solid 1px #d3d8db;
border-radius: 5px 5px 0 0;
font-size: 14px;
min-height: 52px;
margin-top: 15px;}
#selected_filter_container .selected_filters > span {
font-size: 12px;
padding: 6px 10px;
display: inline-block;
background: #F5F8F9;
border: 1px solid #A0D0EB;
border-radius: 3px;}
#selected_filter_container .selected_filters > span + span {
margin-left: 12px;}
#selected_filter_container .selected_filters > span .filter_value {
font-weight: 700;
}
#selected_filter_container .selected_filters > span i {
cursor: pointer;}
#content.bootstrap #list_filters_panel{
margin-top: 15px;
margin-bottom: 0;
}
#content.bootstrap #selected_filter_container + #list_filters_panel {
margin-top: 0;
}
#content.bootstrap #selected_filter_container + div.panel {
border-top: transparent;
border-radius: 0 0 5px 5px;
}
.list_filters {
padding: 0 30px;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px 40px;}
.list_filters > .row {
display: flex;
align-items: center;}
.list_filters .date_range, .list_filters .input_range {
display: flex;
justify-content: space-between;
gap: 15px;}
.list_filters .date_range .input-group:first-child {
margin-bottom: 0;}
.list_filters label {
text-align: right;
font-weight: 400;}
.list_filters .actions {
grid-column-start: 1;
grid-column-end: 4;}
@media (max-width: 992px) {
.list_filters {
grid-template-columns: repeat(2, 1fr);}
.list_filters .actions {
grid-column-start: 1;
grid-column-end: 3;}
}
@media (max-width: 768px) {
.list_filters {
grid-template-columns: repeat(1, 1fr);}
.list_filters .actions {
grid-column-start: 1;
grid-column-end: 2;}
.list_filters label {
text-align: left;
}
}
</style>
{/if}
{/block}
{/block}

View File

@@ -273,6 +273,27 @@
</div>
</div>
<div class="form-group" id="show_at_front_container">
<label class="control-label col-lg-3">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Enable if you want this room type to be shown and to be available for booking from front office.'}">
{l s='Show at front office'}
</span>
</label>
<div class="col-lg-3">
<span class="switch prestashop-switch fixed-width-lg">
<input type="radio" name="show_at_front" id="show_at_front_on" value="1" {if $product->show_at_front || !$product->isAssociatedToShop()}checked="checked"{/if}/>
<label for="show_at_front_on" class="radioCheck">
{l s='Yes'}
</label>
<input type="radio" name="show_at_front" id="show_at_front_off" value="0" {if !$product->show_at_front && $product->isAssociatedToShop()}checked="checked"{/if}/>
<label for="show_at_front_off" class="radioCheck">
{l s='No'}
</label>
<a class="slide-button btn"></a>
</span>
</div>
</div>
<div id="product_options" class="form-group hidden">
<div class="col-lg-12">
<div class="form-group">
@@ -422,6 +443,27 @@
</div>
{/if}
{if isset($product->id) && $product->id}
<div class="form-group">
<label class="control-label col-lg-3" id="category_position" for="category_position">
<span class="label-tooltip" data-toggle="tooltip" title="{l s='Set position of the room type when hotel search results are displayed.'}">
{l s='Position'}
</span>
</label>
<div class="col-lg-9">
<input type="text" id="category_position" class="form-control fixed-width-lg" name="category_position" value="{$category_position}" />
<p class="help-block">{l s='Please note that position numbering starts from 0. A position of 0 means room type will be displayed at the topmost.'}</p>
</div>
</div>
{/if}
{if isset($product->id) && $product->id}
<div class="alert alert-info">
{l s='You can change positions of room types of this hotel from '}
<a href="{$link->getAdminLink('AdminProducts')}&id_category={$htl_full_info['id_category']}">{l s='here.'}</a>
</div>
{/if}
{* <div class="form-group">
<label class="control-label col-lg-3" for="tags_{$id_lang}">
<span class="label-tooltip" data-toggle="tooltip"

View File

@@ -434,7 +434,7 @@
let dateFrom = $('#local_{$params.id_date}_0').val().trim();
let dateTo = $('#local_{$params.id_date}_1').val().trim();
if (dateFrom >= dateTo) {
if ((dateFrom && dateTo) && (dateFrom >= dateTo)) {
let objDateToMin = $.datepicker.parseDate('yy-mm-dd', dateFrom);
objDateToMin.setDate(objDateToMin.getDate() + 1);

View File

@@ -83,7 +83,7 @@
<li>
<a id="page-header-desc-{$table}-{if isset($btn.imgclass)}{$btn.imgclass|escape}{else}{$k}{/if}" class="toolbar_btn {if isset($btn.target) && $btn.target} _blank{/if} pointer"{if isset($btn.href)} href="{$btn.href|escape}"{/if} title="{if isset($btn.help)}{$btn.help}{else}{$btn.desc|escape}{/if}"{if isset($btn.js) && $btn.js} onclick="{$btn.js}"{/if}{if isset($btn.modal_target) && $btn.modal_target} data-target="{$btn.modal_target}" data-toggle="modal"{/if}{if isset($btn.help)} data-toggle="tooltip" data-placement="bottom"{/if}>
<i class="{if isset($btn.icon)}{$btn.icon|escape}{else}process-icon-{if isset($btn.imgclass)}{$btn.imgclass|escape}{else}{$k}{/if}{/if}{if isset($btn.class)} {$btn.class|escape}{/if}"></i>
<div{if isset($btn.force_desc) && $btn.force_desc == true } class="locked"{/if}>{$btn.desc|escape}</div>
<span{if isset($btn.force_desc) && $btn.force_desc == true } class="locked"{/if}>{$btn.desc|escape}</span>
</a>
</li>
{/if}
@@ -92,7 +92,7 @@
<li>
<a id="page-header-desc-{$table}-{if isset($toolbar_btn['modules-list'].imgclass)}{$toolbar_btn['modules-list'].imgclass}{else}modules-list{/if}" class="toolbar_btn{if isset($toolbar_btn['modules-list'].class)} {$toolbar_btn['modules-list'].class}{/if}{if isset($toolbar_btn['modules-list'].target) && $toolbar_btn['modules-list'].target} _blank{/if}" {if isset($toolbar_btn['modules-list'].href)}href="{$toolbar_btn['modules-list'].href}"{/if} title="{$toolbar_btn['modules-list'].desc}"{if isset($toolbar_btn['modules-list'].js) && $toolbar_btn['modules-list'].js} onclick="{$toolbar_btn['modules-list'].js}"{/if}>
<i class="{if isset($toolbar_btn['modules-list'].icon)}{$toolbar_btn['modules-list'].icon}{else}process-icon-{if isset($toolbar_btn['modules-list'].imgclass)}{$toolbar_btn['modules-list'].imgclass}{else}modules-list{/if}{/if}"></i>
<div{if isset($toolbar_btn['modules-list'].force_desc) && $toolbar_btn['modules-list'].force_desc == true } class="locked"{/if}>{$toolbar_btn['modules-list'].desc}</div>
<span{if isset($toolbar_btn['modules-list'].force_desc) && $toolbar_btn['modules-list'].force_desc == true } class="locked"{/if}>{$toolbar_btn['modules-list'].desc}</span>
</a>
</li>
{/if}

View File

@@ -532,7 +532,7 @@ class CartCore extends ObjectModel
$sql = new DbQuery();
// Build SELECT
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`, p.`booking_product`, p.`service_product_type`, p.`auto_add_to_cart`, p.`price_addition_type`, product_shop.`allow_multiple_quantity`, product_shop.`price_calculation_method`,
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`, p.`booking_product`, p.`service_product_type`, p.`auto_add_to_cart`, p.`price_addition_type`, p.`show_at_front`, product_shop.`allow_multiple_quantity`, product_shop.`price_calculation_method`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
@@ -2387,7 +2387,6 @@ class CartCore extends ObjectModel
$array[$selectedProduct['id_hotel']] = array(
'quantity' => $selectedProduct['quantity'],
'id_hotel' => $selectedProduct['id_hotel'],
'unit_price_tax_incl' => $selectedProduct['unit_price_tax_incl'],
'total_price_tax_excl' => $selectedProduct['total_price_tax_excl'],
'total_price_tax_incl' => $selectedProduct['total_price_tax_incl'],
);
@@ -2397,7 +2396,8 @@ class CartCore extends ObjectModel
$product['cart_quantity'] = $selectedProduct['quantity'];
$product['total'] = $selectedProduct['total_price_tax_excl'];
$product['total_wt'] = $selectedProduct['total_price_tax_incl'];
$product['price_wt'] = $selectedProduct['unit_price_tax_incl'];
$product['price_wt'] = $selectedProduct['total_price_tax_incl'] / $product['cart_quantity'];
$product['price'] = $selectedProduct['total_price_tax_excl'] / $product['cart_quantity'];
$product['id_hotel'] = $selectedProduct['id_hotel'];
$orderPackage[$id_address][$selectedProduct['id_hotel']]['product_list'][] = $product;
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'])) {
@@ -2431,6 +2431,7 @@ class CartCore extends ObjectModel
$unitPriceWt = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, $product['id_product'], $hotelProduct['id_hotel'], true);
$serviceProduct['total'] = $unitPrice * $hotelProduct['quantity'];
$serviceProduct['total_wt'] = $unitPriceWt * $hotelProduct['quantity'];
$serviceProduct['price'] = $unitPrice;
$serviceProduct['price_wt'] = $unitPriceWt;
// if (!empty($hotelProducts['products'])) {
// foreach($hotelProducts['products'] as $hotelProduct) {

View File

@@ -279,7 +279,12 @@ class DispatcherCore
$controllers = Dispatcher::getControllers(_PS_MODULE_DIR_.$module_name.'/controllers/front/');
if (isset($controllers[strtolower($this->controller)])) {
include_once(_PS_MODULE_DIR_.$module_name.'/controllers/front/'.$this->controller.'.php');
$controller_class = $module_name.$this->controller.'ModuleFrontController';
if (file_exists(_PS_OVERRIDE_DIR_.'modules/'.$module_name.'/controllers/front/'.$this->controller.'.php')) {
include_once(_PS_OVERRIDE_DIR_.'modules/'.$module_name.'/controllers/front/'.$this->controller.'.php');
$controller_class = $module_name.$this->controller.'ModuleFrontControllerOverride';
} else {
$controller_class = $module_name.$this->controller.'ModuleFrontController';
}
}
}
$params_hook_action_dispatcher = array('controller_type' => self::FC_FRONT, 'controller_class' => $controller_class, 'is_module' => 1);
@@ -310,7 +315,12 @@ class DispatcherCore
} else {
// Controllers in modules can be named AdminXXX.php or AdminXXXController.php
include_once(_PS_MODULE_DIR_.$tab->module.'/controllers/admin/'.$controllers[strtolower($this->controller)].'.php');
$controller_class = $controllers[strtolower($this->controller)].(strpos($controllers[strtolower($this->controller)], 'Controller') ? '' : 'Controller');
if (file_exists(_PS_OVERRIDE_DIR_ . 'modules/' . $tab->module . '/controllers/admin/' . $controllers[strtolower($this->controller)] . '.php')) {
include_once(_PS_OVERRIDE_DIR_ . 'modules/' . $tab->module . '/controllers/admin/' . $controllers[strtolower($this->controller)] . '.php');
$controller_class = $controllers[strtolower($this->controller)] . (strpos($controllers[strtolower($this->controller)], 'Controller') ? 'Override' : 'ControllerOverride');
} else {
$controller_class = $controllers[strtolower($this->controller)] . (strpos($controllers[strtolower($this->controller)], 'Controller') ? '' : 'Controller');
}
}
}
$params_hook_action_dispatcher = array('controller_type' => self::FC_ADMIN, 'controller_class' => $controller_class, 'is_module' => 1);

View File

@@ -211,7 +211,9 @@ abstract class ObjectModelCore implements Core_Foundation_Database_EntityInterfa
throw new PrestaShopException('Identifier or table format not valid for class '.$class_name);
}
ObjectModel::$loaded_classes[$class_name] = get_object_vars($this);
$objProperties = get_object_vars($this);
Hook::exec('actionObject'.$class_name.'PropertiesModifier', array('obj_properties' => &$objProperties));
ObjectModel::$loaded_classes[$class_name] = $objProperties;
} else {
foreach (ObjectModel::$loaded_classes[$class_name] as $key => $value) {
$this->{$key} = $value;

View File

@@ -1008,11 +1008,9 @@ 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_ACCEPTED'), $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
@@ -1047,47 +1045,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);
@@ -1664,8 +1634,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']);
@@ -1767,8 +1740,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'];
@@ -1776,10 +1752,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);
}
}
}
}

View File

@@ -649,12 +649,12 @@ class ProductCore extends ObjectModel
* @param int $position
* return boolean Update result
*/
public function updatePosition($way, $position)
public function updatePosition($way, $position, $id_category = null)
{
if (!$res = Db::getInstance()->executeS('
SELECT cp.`id_product`, cp.`position`, cp.`id_category`
FROM `'._DB_PREFIX_.'category_product` cp
WHERE cp.`id_category` = '.(int)Tools::getValue('id_category', 1).'
WHERE cp.`id_category` = '.(int) ($id_category ? $id_category: Tools::getValue('id_category', 1)).'
ORDER BY cp.`position` ASC')
) {
return false;
@@ -5328,6 +5328,68 @@ class ProductCore extends ObjectModel
return $tax_calculator->getTotalRate();
}
public function getPositionInCategory()
{
return Db::getInstance()->getValue(
'SELECT position
FROM `'._DB_PREFIX_.'category_product`
WHERE id_category = '.(int) $this->id_category_default.'
AND id_product = '.(int) $this->id
);
}
public function setPositionInCategory($position)
{
if ($position < 0) {
die(Tools::displayError('You cannot set a negative position, the minimum for a position is 0.'));
}
$result = Db::getInstance()->executeS(
'SELECT `id_product`
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_category` = '.(int) $this->id_category_default.'
ORDER BY `position`'
);
if (($position > 0) && ($position + 1 > count($result))) {
die(Tools::displayError('You cannot set a position greater than the total number of room types in the hotel, minus 1 (position numbering starts at 0).'));
}
foreach ($result as &$value) {
$value = $value['id_product'];
}
$currentPosition = $this->getPositionInCategory();
if ($currentPosition && isset($result[$currentPosition])) {
$save = $result[$currentPosition];
unset($result[$currentPosition]);
array_splice($result, (int)$position, 0, $save);
}
$return = true;
foreach ($result as $position => $id_product) {
$return &= Db::getInstance()->update(
'category_product',
array('position' => $position),
'(`id_category` = '.(int) $this->id_category_default.' AND `id_product` = '.(int) $id_product.')'
);
}
return $return;
}
public static function getHighestPositionInCategory($idCategory)
{
$position = Db::getInstance()->getValue(
'SELECT MAX(`position`)
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_category` = '.(int) $idCategory
);
return (is_numeric($position)) ? $position : -1;
}
/**
* Webservice getter : get product features association
* @return array
@@ -5576,14 +5638,7 @@ class ProductCore extends ObjectModel
*/
public function getWsPositionInCategory()
{
$result = Db::getInstance()->executeS('SELECT position
FROM `'._DB_PREFIX_.'category_product`
WHERE id_category = '.(int)$this->id_category_default.'
AND id_product = '.(int)$this->id);
if (count($result) > 0) {
return $result[0]['position'];
}
return '';
return $this->getPositionInCategory();
}
/**

View File

@@ -3023,6 +3023,8 @@ exit;
$smarty = Context::getContext()->smarty;
Tools::clearCache($smarty);
Tools::clearCompile($smarty);
@copy(_PS_CACHE_DIR_.'smarty/index.php', _PS_CACHE_DIR_.'smarty/cache/index.php');
@copy(_PS_CACHE_DIR_.'smarty/index.php', _PS_CACHE_DIR_.'smarty/compile/index.php');
}
public static function clearColorListCache($id_product = false)

View File

@@ -407,6 +407,9 @@ class AdminControllerCore extends Controller
$this->controller_type = 'admin';
$this->controller_name = get_class($this);
if (strpos($this->controller_name, 'ControllerOverride')) {
$this->controller_name = substr($this->controller_name, 0, -18);
}
if (strpos($this->controller_name, 'Controller')) {
$this->controller_name = substr($this->controller_name, 0, -10);
}
@@ -875,7 +878,9 @@ class AdminControllerCore extends Controller
if ($field = $this->filterToField($key, $filter)) {
$type = (array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false));
if (($type == 'date' || $type == 'datetime' || $type == 'range') && is_string($value)) {
if ((($type == 'date' || $type == 'datetime' || $type == 'range') || ($type == 'select' && (isset($field['multiple']) && $field['multiple'])))
&& is_string($value)
) {
$value = json_decode($value, true);
}
$key = isset($tmp_tab[1]) ? $tmp_tab[0].'.`'.$tmp_tab[1].'`' : '`'.$tmp_tab[0].'`';
@@ -893,21 +898,35 @@ class AdminControllerCore extends Controller
} else {
$sql_filter = & $this->_filter;
}
/* Only for date filtering (from, to) */
if (is_array($value)) {
if ($type == 'range') {
if (isset($value[0]) && !empty($value[0])) {
if (!Validate::isUnsignedInt($value[0])) {
if ($type == 'select' && (isset($field['multiple']) && $field['multiple']) && isset($field['operator'])) {
if ($field['operator'] == 'and') {
$sql_filter .= ' AND '.pSQL($key).' IN ('.pSQL(implode(',', $value)).')';
$this->_filterHaving .= ' AND COUNT(DISTINCT '.pSQL($key).') = '.(int) count($value);
} elseif ($field['operator'] == 'or') {
$sql_filter .= ' AND '.pSQL($key).' IN ('.pSQL(implode(',', $value)).')';
}
} elseif ($type == 'range') {
// set validation type
if (isset($field['validation']) && $field['validation'] && method_exists('Validate', $field['validation'])) {
$validation = $field['validation'];
} else {
$validation = 'isUnsignedInt';
}
if (isset($value[0]) && ($value[0] !== '' || $value[0] === 0)) {
if (!Validate::$validation($value[0])) {
$this->errors[] = Tools::displayError('The \'From\' value is invalid');
} else {
$sql_filter .= ' AND '.pSQL($key).' >= '.pSQL($value[0]);
}
}
if (isset($value[1]) && !empty($value[1])) {
if (!Validate::isUnsignedInt($value[1])) {
$this->errors[] = Tools::displayError('The \'From\' value is invalid');
} elseif (isset($value[0]) && !empty($value[0]) && $value[0] > $value[1]) {
$this->errors[] = Tools::displayError('The \'To\' value cannot be less than from value');
if (isset($value[1]) && ($value[1] !== '' || $value[1] === 0)) {
if (!Validate::$validation($value[1])) {
$this->errors[] = Tools::displayError('The \'To\' value is invalid');
} elseif ((isset($value[0]) && ($value[0] !== '' || $value[0] === 0)) && $value[0] > $value[1]) {
$this->errors[] = Tools::displayError('The \'To\' value cannot be less than \'From\' value');
} else {
$sql_filter .= ' AND '.pSQL($key).' <= '.pSQL($value[1]);
}
@@ -925,7 +944,7 @@ class AdminControllerCore extends Controller
if (!Validate::isDate($value[1])) {
$this->errors[] = Tools::displayError('The \'To\' date format is invalid (YYYY-MM-DD)');
} elseif (isset($value[0]) && !empty($value[0]) && strtotime($value[0]) > strtotime($value[1])) {
$this->errors[] = Tools::displayError('The \'To\' date cannot be before than from date');
$this->errors[] = Tools::displayError('The \'To\' date cannot be earlier than \'From\' date');
} else {
$sql_filter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\'';
}

View File

@@ -221,6 +221,7 @@ class FrontControllerCore extends Controller
'js_dir' => _THEME_JS_DIR_,
'base_dir' => __PS_BASE_URI__,
'language_code' => $this->context->language->language_code ? $this->context->language->language_code : $this->context->language->iso_code,
'language_is_rtl' => $this->context->language->is_rtl,
]);
/* get page name to display it in body id */

View File

@@ -660,23 +660,41 @@ class HelperListCore extends Helper
$value = json_decode($value, true);
}
if (isset($value[0]) && !Validate::isUnsignedInt($value[0])) {
// set validation type
if (isset($params['validation']) && $params['validation'] && method_exists('Validate', $params['validation'])) {
$validation = $params['validation'];
} else {
$validation = 'isUnsignedInt';
}
$hasValueFrom = isset($value[0]) && ($value[0] !== '' || $value[0] === 0);
if ($hasValueFrom && !Validate::$validation($value[0])) {
$value[0] = '';
}
if (isset($value[1]) && !Validate::isUnsignedInt($value[1])) {
$hasValueTo = isset($value[1]) && ($value[1] !== '' || $value[1] === 0);
if ($hasValueTo && !Validate::$validation($value[1])) {
$value[1] = '';
}
if (isset($value[0]) && isset($value[1]) && $value[0] > $value[1]) {
if ($hasValueFrom && $hasValueTo && $value[0] > $value[1]) {
$value[1] = '';
}
break;
case 'select':
foreach ($params['list'] as $option_value => $option_display) {
if (isset(Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']})
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} == $option_value
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} != '') {
$this->fields_list[$key]['select'][$option_value]['selected'] = 'selected';
if (isset($params['multiple']) && $params['multiple']) {
if (!isset($params['operator'])) {
$params['operator'] = 'or';
}
$value = json_decode($value, true);
} else {
foreach ($params['list'] as $option_value => $option_display) {
if (isset(Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']})
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} == $option_value
&& Context::getContext()->cookie->{$prefix.$this->list_id.'Filter_'.$params['filter_key']} != '') {
$this->fields_list[$key]['select'][$option_value]['selected'] = 'selected';
}
}
}
break;

View File

@@ -185,6 +185,10 @@ abstract class ModuleCore
public static $hosted_modules_blacklist = array('autoupgrade');
const OVERRIDE_TYPE_CORE = 1;
const OVERRIDE_TYPE_MODULE = 2;
const OVERRIDE_TYPE_MODULE_CONTROLLER = 3;
/**
* Set the flag to indicate we are doing an import
*
@@ -2873,6 +2877,34 @@ abstract class ModuleCore
return true;
}
public function getOverrides()
{
if (!is_dir($this->getLocalPath().'override')) {
return array();
}
$overrides = array();
foreach (Tools::scandir($this->getLocalPath().'override', 'php', '', true) as $file) {
$class = basename($file, '.php');
$classInfo = array('class' => $class, 'file' => $file, 'type' => null);
if (PrestaShopAutoload::getInstance()->getClassPath($class.'Core')) {
$classInfo['type'] = self::OVERRIDE_TYPE_CORE;
} elseif (Module::getModuleIdByName($class)) {
$classInfo['type'] = self::OVERRIDE_TYPE_MODULE;
} elseif (preg_match('#^modules/([a-zA-Z0-9_-]+)/controllers/(admin|front)/([0-9a-zA-Z-_]+).php#', $file, $matches)) {
$classInfo['type'] = self::OVERRIDE_TYPE_MODULE_CONTROLLER;
$classInfo['module'] = $matches[1];
$classInfo['controller_type'] = $matches[2];
}
if ($classInfo['type']) {
$overrides[] = $classInfo;
}
}
return $overrides;
}
/**
* Install overrides files for the module
*
@@ -2885,10 +2917,9 @@ abstract class ModuleCore
}
$result = true;
foreach (Tools::scandir($this->getLocalPath().'override', 'php', '', true) as $file) {
$class = basename($file, '.php');
if (PrestaShopAutoload::getInstance()->getClassPath($class.'Core') || Module::getModuleIdByName($class)) {
$result &= $this->addOverride($class);
if ($overrideClassInfos = $this->getOverrides()) {
foreach ($overrideClassInfos as $classInfo) {
$result &= $this->addOverride($classInfo);
}
}
@@ -2907,10 +2938,9 @@ abstract class ModuleCore
}
$result = true;
foreach (Tools::scandir($this->getLocalPath().'override', 'php', '', true) as $file) {
$class = basename($file, '.php');
if (PrestaShopAutoload::getInstance()->getClassPath($class.'Core') || Module::getModuleIdByName($class)) {
$result &= $this->removeOverride($class);
if ($overrideClassInfos = $this->getOverrides()) {
foreach ($overrideClassInfos as $classInfo) {
$result &= $this->removeOverride($classInfo);
}
}
@@ -2923,28 +2953,50 @@ abstract class ModuleCore
* @param string $classname
* @return bool
*/
public function addOverride($classname)
public function addOverride($classInfo)
{
$orig_path = $path = PrestaShopAutoload::getInstance()->getClassPath($classname.'Core');
if (!$path) {
$path = 'modules'.DIRECTORY_SEPARATOR.$classname.DIRECTORY_SEPARATOR.$classname.'.php';
}
$path_override = $this->getLocalPath().'override'.DIRECTORY_SEPARATOR.$path;
$classname = $classInfo['class'];
if (!file_exists($path_override)) {
$parentClassFilePath = '';
$overrideClassName = $classname;
if ($classInfo['type'] == self::OVERRIDE_TYPE_CORE) {
$parentClassFilePath = PrestaShopAutoload::getInstance()->getClassPath($classname.'Core');
} elseif ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE) {
$parentClassFilePath = 'modules/'.$classname.'/'.$classname.'.php';
// require module main file
require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath;
$overrideClassName = Tools::ucfirst($classname).'Override';
} elseif ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE_CONTROLLER) {
$parentClassFilePath = $classInfo['file'];
// require module controller file
require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath;
if ($classInfo['controller_type'] == 'admin') {
$overrideClassName = $classname.((strpos($classname, 'Controller') === false) ? 'Controller' : '').'Override';
} else {
$overrideClassName = Tools::ucfirst($classInfo['module']).Tools::ucfirst($classInfo['class']).'ModuleFrontControllerOverride';
}
}
// the file in module which contains override information (methods, properties and constants)
$moduleClassFilePath = $this->getLocalPath().'override/'.$parentClassFilePath;
if (!file_exists($moduleClassFilePath)) {
return false;
} else {
file_put_contents($path_override, preg_replace('#(\r\n|\r)#ism', "\n", file_get_contents($path_override)));
// save $moduleClassFilePath file with consistent newline character, "\n"
file_put_contents($moduleClassFilePath, preg_replace('#(\r\n|\r)#ism', "\n", file_get_contents($moduleClassFilePath)));
}
$pattern_escape_com = '#(^\s*?\/\/.*?\n|\/\*(?!\n\s+\* module:.*?\* date:.*?\* version:.*?\*\/).*?\*\/)#ism';
// Check if there is already an override file, if not, we just need to copy the file
if ($file = PrestaShopAutoload::getInstance()->getClassPath($classname)) {
// Check if override file is writable
$override_path = _PS_ROOT_DIR_.'/'.$file;
$patternEscapeCommon = '#(^\s*?\/\/.*?\n|\/\*(?!\n\s+\* module:.*?\* date:.*?\* version:.*?\*\/).*?\*\/)#ism';
if ((!file_exists($override_path) && !is_writable(dirname($override_path))) || (file_exists($override_path) && !is_writable($override_path))) {
throw new Exception(sprintf(Tools::displayError('file (%s) not writable'), $override_path));
$overrideClassFilePath = _PS_ROOT_DIR_.'/override/'.$parentClassFilePath;
// Case 1: Check if there is already an override file, if so, merge override information otherwise just copy it
if (file_exists($overrideClassFilePath)) {
// Check if override file is writable
if (!is_writable(dirname($overrideClassFilePath)) || !is_writable($overrideClassFilePath)) {
throw new Exception(sprintf(Tools::displayError('file (%s) not writable'), $overrideClassFilePath));
}
// Get a uniq id for the class, because you can override a class (or remove the override) twice in the same session and we need to avoid redeclaration
@@ -2953,262 +3005,340 @@ abstract class ModuleCore
} while (class_exists($classname.'OverrideOriginal_remove', false));
// Make a reflection of the override class and the module override class
$override_file = file($override_path);
$override_file = array_diff($override_file, array("\n"));
eval(preg_replace(array('#^\s*<\?(?:php)?#', '#class\s+'.$classname.'\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?#i'), array(' ', 'class '.$classname.'OverrideOriginal'.$uniq), implode('', $override_file)));
$override_class = new ReflectionClass($classname.'OverrideOriginal'.$uniq);
$overrideClassFileArray = file($overrideClassFilePath);
$overrideClassFileArray = array_diff($overrideClassFileArray, array("\n")); // remove empty lines from array
$module_file = file($path_override);
$module_file = array_diff($module_file, array("\n"));
eval(preg_replace(array('#^\s*<\?(?:php)?#', '#class\s+'.$classname.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'), array(' ', 'class '.$classname.'Override'.$uniq), implode('', $module_file)));
$module_class = new ReflectionClass($classname.'Override'.$uniq);
eval(
preg_replace(
array(
'#^\s*<\?(?:php)?#',
'#class\s+'.$overrideClassName.'\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?#i'
),
array(
' ',
'class '.$overrideClassName.'OverrideOriginal'.$uniq
),
implode('', $overrideClassFileArray)
)
);
$reflectionClassOverride = new ReflectionClass($overrideClassName.'OverrideOriginal'.$uniq);
// Check if none of the methods already exists in the override class
foreach ($module_class->getMethods() as $method) {
if ($override_class->hasMethod($method->getName())) {
$method_override = $override_class->getMethod($method->getName());
if (preg_match('/module: (.*)/ism', $override_file[$method_override->getStartLine() - 5], $name) && preg_match('/date: (.*)/ism', $override_file[$method_override->getStartLine() - 4], $date) && preg_match('/version: ([0-9.]+)/ism', $override_file[$method_override->getStartLine() - 3], $version)) {
throw new Exception(sprintf(Tools::displayError('The method %1$s in the class %2$s is already overridden by the module %3$s version %4$s at %5$s.'), $method->getName(), $classname, $name[1], $version[1], $date[1]));
}
throw new Exception(sprintf(Tools::displayError('The method %1$s in the class %2$s is already overridden.'), $method->getName(), $classname));
}
$moduleClassFileArray = file($moduleClassFilePath);
$moduleClassFileArray = array_diff($moduleClassFileArray, array("\n")); // remove empty lines from array
$module_file = preg_replace('/((:?public|private|protected)\s+(static\s+)?function\s+(?:\b'.$method->getName().'\b))/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override method %1$s in class %2$s.'), $method->getName(), $classname));
}
}
eval(
preg_replace(
array(
'#^\s*<\?(?:php)?#',
'#class\s+'.$overrideClassName.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'
),
array(
' ',
'class '.$overrideClassName.'Override'.$uniq
),
implode('', $moduleClassFileArray)
)
);
$reflectionClassModule = new ReflectionClass($overrideClassName.'Override'.$uniq);
// Check if none of the properties already exists in the override class
foreach ($module_class->getProperties() as $property) {
if ($override_class->hasProperty($property->getName())) {
throw new Exception(sprintf(Tools::displayError('The property %1$s in the class %2$s is already defined.'), $property->getName(), $classname));
}
$module_file = preg_replace('/((?:public|private|protected)\s)\s*(static\s)?\s*(\$\b'.$property->getName().'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2$3", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override property %1$s in class %2$s.'), $property->getName(), $classname));
}
}
foreach ($module_class->getConstants() as $constant => $value) {
if ($override_class->hasConstant($constant)) {
throw new Exception(sprintf(Tools::displayError('The constant %1$s in the class %2$s is already defined.'), $constant, $classname));
}
$module_file = preg_replace('/(const\s)\s*(\b'.$constant.'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override constant %1$s in class %2$s.'), $constant, $classname));
}
}
$moduleClassFileArray = $this->getCommentedClass($moduleClassFileArray, $reflectionClassModule, $reflectionClassOverride, $overrideClassFileArray);
// Insert the methods from module override in override
$copy_from = array_slice($module_file, $module_class->getStartLine() + 1, $module_class->getEndLine() - $module_class->getStartLine() - 2);
array_splice($override_file, $override_class->getEndLine() - 1, 0, $copy_from);
$code = implode('', $override_file);
$generatedCodeToCopy = array_slice($moduleClassFileArray, $reflectionClassModule->getStartLine() + 1, $reflectionClassModule->getEndLine() - $reflectionClassModule->getStartLine() - 2);
file_put_contents($override_path, preg_replace($pattern_escape_com, '', $code));
// Merge code with that in destination override file
array_splice($overrideClassFileArray, $reflectionClassOverride->getEndLine() - 1, 0, $generatedCodeToCopy);
$code = implode('', $overrideClassFileArray);
file_put_contents($overrideClassFilePath, preg_replace($patternEscapeCommon, '', $code));
} else {
$override_src = $path_override;
// Case 2: Override file does not exist just copy override information (methods, properties and constants)
$baseDirectoryPath = dirname($overrideClassFilePath);
$override_dest = _PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'override'.DIRECTORY_SEPARATOR.$path;
$dir_name = dirname($override_dest);
if (!$orig_path && !is_dir($dir_name)) {
// Check if directory exists, if not, create
if (!is_dir($baseDirectoryPath)) {
$oldumask = umask(0000);
@mkdir($dir_name, 0777);
@mkdir($baseDirectoryPath, 0777, true); // create subdirectories if needed
umask($oldumask);
}
if (!is_writable($dir_name)) {
throw new Exception(sprintf(Tools::displayError('directory (%s) not writable'), $dir_name));
}
$module_file = file($override_src);
$module_file = array_diff($module_file, array("\n"));
if ($orig_path) {
do {
$uniq = uniqid();
} while (class_exists($classname.'OverrideOriginal_remove', false));
eval(preg_replace(array('#^\s*<\?(?:php)?#', '#class\s+'.$classname.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'), array(' ', 'class '.$classname.'Override'.$uniq), implode('', $module_file)));
$module_class = new ReflectionClass($classname.'Override'.$uniq);
// For each method found in the override, prepend a comment with the module name and version
foreach ($module_class->getMethods() as $method) {
$module_file = preg_replace('/((:?public|private|protected)\s+(static\s+)?function\s+(?:\b'.$method->getName().'\b))/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override method %1$s in class %2$s.'), $method->getName(), $classname));
}
}
// Same loop for properties
foreach ($module_class->getProperties() as $property) {
$module_file = preg_replace('/((?:public|private|protected)\s)\s*(static\s)?\s*(\$\b'.$property->getName().'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2$3", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override property %1$s in class %2$s.'), $property->getName(), $classname));
}
}
// Same loop for constants
foreach ($module_class->getConstants() as $constant => $value) {
$module_file = preg_replace('/(const\s)\s*(\b'.$constant.'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2", $module_file);
if ($module_file === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override constant %1$s in class %2$s.'), $constant, $classname));
}
}
if (!is_writable($baseDirectoryPath)) {
throw new Exception(sprintf(Tools::displayError('directory (%s) not writable'), $baseDirectoryPath));
}
file_put_contents($override_dest, preg_replace($pattern_escape_com, '', $module_file));
$moduleClassFileArray = file($moduleClassFilePath); // read file as array
$moduleClassFileArray = array_diff($moduleClassFileArray, array("\n")); // remove empty lines from array
do {
$uniq = uniqid();
} while (class_exists($classname.'OverrideOriginal_remove', false));
eval(
preg_replace(
array(
'#^\s*<\?(?:php)?#',
'#class\s+'.$overrideClassName.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'
),
array(
' ',
'class '.$overrideClassName.'Override'.$uniq
),
implode('', $moduleClassFileArray)
)
);
$reflectionClassModule = new ReflectionClass($overrideClassName.'Override'.$uniq);
$moduleClassFileArray = $this->getCommentedClass($moduleClassFileArray, $reflectionClassModule);
file_put_contents($overrideClassFilePath, preg_replace($patternEscapeCommon, '', $moduleClassFileArray));
// Re-generate the class index
Tools::generateIndex();
}
return true;
}
private function getCommentedClass($moduleClassFileArray, $reflectionClassModule, $reflectionClassOverride = null, $overrideClassFileArray = null)
{
// Check if none of the methods already exists in the override class
foreach ($reflectionClassModule->getMethods() as $method) {
if ($reflectionClassOverride) {
if ($reflectionClassOverride->hasMethod($method->getName())) {
$overrideMethodInfo = $reflectionClassOverride->getMethod($method->getName());
if (preg_match('/module: (.*)/ism', $overrideClassFileArray[$overrideMethodInfo->getStartLine() - 5], $name) && preg_match('/date: (.*)/ism', $overrideClassFileArray[$overrideMethodInfo->getStartLine() - 4], $date) && preg_match('/version: ([0-9.]+)/ism', $overrideClassFileArray[$overrideMethodInfo->getStartLine() - 3], $version)) {
throw new Exception(sprintf(Tools::displayError('The method %1$s in the class %2$s is already overridden by the module %3$s version %4$s at %5$s.'), $method->getName(), $classname, $name[1], $version[1], $date[1]));
}
throw new Exception(sprintf(Tools::displayError('The method %1$s in the class %2$s is already overridden.'), $method->getName(), $classname));
}
}
$moduleClassFileArray = preg_replace('/((:?public|private|protected)\s+(static\s+)?function\s+(?:\b'.$method->getName().'\b))/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1", $moduleClassFileArray);
if ($moduleClassFileArray === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override method %1$s in class %2$s.'), $method->getName(), $classname));
}
}
// Check if none of the properties already exists in the override class
foreach ($reflectionClassModule->getProperties() as $property) {
if ($reflectionClassOverride) {
if ($reflectionClassOverride->hasProperty($property->getName())) {
throw new Exception(sprintf(Tools::displayError('The property %1$s in the class %2$s is already defined.'), $property->getName(), $classname));
}
}
$moduleClassFileArray = preg_replace('/((?:public|private|protected)\s)\s*(static\s)?\s*(\$\b'.$property->getName().'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2$3", $moduleClassFileArray);
if ($moduleClassFileArray === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override property %1$s in class %2$s.'), $property->getName(), $classname));
}
}
// Check if none of the constants already exists in the override class
foreach ($reflectionClassModule->getConstants() as $constant => $value) {
if ($reflectionClassOverride) {
if ($reflectionClassOverride->hasConstant($constant)) {
throw new Exception(sprintf(Tools::displayError('The constant %1$s in the class %2$s is already defined.'), $constant, $classname));
}
}
$moduleClassFileArray = preg_replace('/(const\s)\s*(\b'.$constant.'\b)/ism', "/*\n * module: ".$this->name."\n * date: ".date('Y-m-d H:i:s')."\n * version: ".$this->version."\n */\n $1$2", $moduleClassFileArray);
if ($moduleClassFileArray === null) {
throw new Exception(sprintf(Tools::displayError('Failed to override constant %1$s in class %2$s.'), $constant, $classname));
}
}
return $moduleClassFileArray;
}
/**
* Remove all methods in a module override from the override class
*
* @param string $classname
* @return bool
*/
public function removeOverride($classname)
public function removeOverride($classInfo)
{
$orig_path = $path = PrestaShopAutoload::getInstance()->getClassPath($classname.'Core');
$classname = $classInfo['class'];
if ($orig_path && !$file = PrestaShopAutoload::getInstance()->getClassPath($classname)) {
$parentClassFilePath = '';
$overrideClassName = $classname;
if ($classInfo['type'] == self::OVERRIDE_TYPE_CORE) {
$parentClassFilePath = PrestaShopAutoload::getInstance()->getClassPath($classname.'Core');
} elseif ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE) {
$parentClassFilePath = 'modules/'.$classname.'/'.$classname.'.php';
require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath;
$overrideClassName = Tools::ucfirst($classname).'Override';
} elseif ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE_CONTROLLER) {
$parentClassFilePath = $classInfo['file'];
require_once _PS_ROOT_DIR_.'/'.$parentClassFilePath;
if ($classInfo['controller_type'] == 'admin') {
$overrideClassName = $classname.((strpos($classname, 'Controller') === false) ? 'Controller' : '').'Override';
} else {
$overrideClassName = Tools::ucfirst($classInfo['module']).Tools::ucfirst($classInfo['class']).'ModuleFrontControllerOverride';
}
}
$overrideClassFilePath = _PS_ROOT_DIR_.'/override/'.$parentClassFilePath;
// if override file does not exist return true
if (!file_exists($overrideClassFilePath)) {
return true;
} elseif (!$orig_path && Module::getModuleIdByName($classname)) {
$path = 'modules'.DIRECTORY_SEPARATOR.$classname.DIRECTORY_SEPARATOR.$classname.'.php';
}
// Check if override file is writable
if ($orig_path) {
$override_path = _PS_ROOT_DIR_.'/'.$file;
} else {
$override_path = _PS_OVERRIDE_DIR_.$path;
}
if (!is_file($override_path) || !is_writable($override_path)) {
if (!is_file($overrideClassFilePath) || !is_writable($overrideClassFilePath)) {
return false;
}
file_put_contents($override_path, preg_replace('#(\r\n|\r)#ism', "\n", file_get_contents($override_path)));
// save $overrideClassFilePath file with consistent newline character, "\n"
file_put_contents($overrideClassFilePath, preg_replace('#(\r\n|\r)#ism', "\n", file_get_contents($overrideClassFilePath)));
if ($orig_path) {
// Get a uniq id for the class, because you can override a class (or remove the override) twice in the same session and we need to avoid redeclaration
do {
$uniq = uniqid();
} while (class_exists($classname.'OverrideOriginal_remove', false));
// Get a uniq id for the class, because you can override a class (or remove the override) twice in the same session and we need to avoid redeclaration
do {
$uniq = uniqid();
} while (class_exists($classname.'OverrideOriginal_remove', false));
// Make a reflection of the override class and the module override class
$override_file = file($override_path);
// Make a reflection of the override class and the module override class
$overrideClassFileArray = file($overrideClassFilePath);
$moduleClassFileArray = array_diff($moduleClassFileArray, array("\n")); // remove empty lines from array
eval(preg_replace(array('#^\s*<\?(?:php)?#', '#class\s+'.$classname.'\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?#i'), array(' ', 'class '.$classname.'OverrideOriginal_remove'.$uniq), implode('', $override_file)));
$override_class = new ReflectionClass($classname.'OverrideOriginal_remove'.$uniq);
eval(
preg_replace(
array(
'#^\s*<\?(?:php)?#',
'#class\s+'.$overrideClassName.'\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?#i'
),
array(
' ',
'class '.$overrideClassName.'Original_remove'.$uniq
),
implode('', $overrideClassFileArray)
)
);
$reflectionClassOverride = new ReflectionClass($overrideClassName.'Original_remove'.$uniq);
$module_file = file($this->getLocalPath().'override/'.$path);
eval(preg_replace(array('#^\s*<\?(?:php)?#', '#class\s+'.$classname.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'), array(' ', 'class '.$classname.'Override_remove'.$uniq), implode('', $module_file)));
$module_class = new ReflectionClass($classname.'Override_remove'.$uniq);
$moduleClassFileArray = file($this->getLocalPath().'override/'.$parentClassFilePath);
eval(
preg_replace(
array(
'#^\s*<\?(?:php)?#',
'#class\s+'.$overrideClassName.'(\s+extends\s+([a-z0-9_]+)(\s+implements\s+([a-z0-9_]+))?)?#i'
),
array(
' ',
'class '.$overrideClassName.'Override_remove'.$uniq
),
implode('', $moduleClassFileArray)
)
);
$reflectionClassModule = new ReflectionClass($overrideClassName.'Override_remove'.$uniq);
// Remove methods from override file
foreach ($module_class->getMethods() as $method) {
if (!$override_class->hasMethod($method->getName())) {
continue;
}
$method = $override_class->getMethod($method->getName());
$length = $method->getEndLine() - $method->getStartLine() + 1;
$module_method = $module_class->getMethod($method->getName());
$module_length = $module_method->getEndLine() - $module_method->getStartLine() + 1;
$override_file_orig = $override_file;
$orig_content = preg_replace('/\s/', '', implode('', array_splice($override_file, $method->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$module_content = preg_replace('/\s/', '', implode('', array_splice($module_file, $module_method->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$replace = true;
if (preg_match('/\* module: ('.$this->name.')/ism', $override_file[$method->getStartLine() - 5])) {
$override_file[$method->getStartLine() - 6] = $override_file[$method->getStartLine() - 5] = $override_file[$method->getStartLine() - 4] = $override_file[$method->getStartLine() - 3] = $override_file[$method->getStartLine() - 2] = '#--remove--#';
$replace = false;
}
if (md5($module_content) != md5($orig_content) && $replace) {
$override_file = $override_file_orig;
}
// Remove methods from override file
foreach ($reflectionClassModule->getMethods() as $method) {
if (!$reflectionClassOverride->hasMethod($method->getName())) {
continue;
}
// Remove properties from override file
foreach ($module_class->getProperties() as $property) {
if (!$override_class->hasProperty($property->getName())) {
continue;
}
$method = $reflectionClassOverride->getMethod($method->getName());
$length = $method->getEndLine() - $method->getStartLine() + 1;
// Replace the declaration line by #--remove--#
foreach ($override_file as $line_number => &$line_content) {
if (preg_match('/(public|private|protected)\s+(static\s+)?(\$)?'.$property->getName().'/i', $line_content)) {
if (preg_match('/\* module: ('.$this->name.')/ism', $override_file[$line_number - 4])) {
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
}
$line_content = '#--remove--#';
break;
}
}
$moduleMethodInfo = $reflectionClassModule->getMethod($method->getName());
$overrideClassFileArrayOriginal = $overrideClassFileArray;
$overrideFileContent = preg_replace('/\s/', '', implode('', array_splice($overrideClassFileArray, $method->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$moduleFileContent = preg_replace('/\s/', '', implode('', array_splice($moduleClassFileArray, $moduleMethodInfo->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$replace = true;
if (preg_match('/\* module: ('.$this->name.')/ism', $overrideClassFileArray[$method->getStartLine() - 5])) {
$overrideClassFileArray[$method->getStartLine() - 6] = $overrideClassFileArray[$method->getStartLine() - 5] = $overrideClassFileArray[$method->getStartLine() - 4] = $overrideClassFileArray[$method->getStartLine() - 3] = $overrideClassFileArray[$method->getStartLine() - 2] = '#--remove--#';
$replace = false;
}
// Remove properties from override file
foreach ($module_class->getConstants() as $constant => $value) {
if (!$override_class->hasConstant($constant)) {
continue;
}
// Replace the declaration line by #--remove--#
foreach ($override_file as $line_number => &$line_content) {
if (preg_match('/(const)\s+(static\s+)?(\$)?'.$constant.'/i', $line_content)) {
if (preg_match('/\* module: ('.$this->name.')/ism', $override_file[$line_number - 4])) {
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
}
$line_content = '#--remove--#';
break;
}
}
if (md5($moduleFileContent) != md5($overrideFileContent) && $replace) {
$overrideClassFileArray = $overrideClassFileArrayOriginal;
}
$count = count($override_file);
for ($i = 0; $i < $count; ++$i) {
if (preg_match('/(^\s*\/\/.*)/i', $override_file[$i])) {
$override_file[$i] = '#--remove--#';
} elseif (preg_match('/(^\s*\/\*)/i', $override_file[$i])) {
if (!preg_match('/(^\s*\* module:)/i', $override_file[$i + 1])
&& !preg_match('/(^\s*\* date:)/i', $override_file[$i + 2])
&& !preg_match('/(^\s*\* version:)/i', $override_file[$i + 3])
&& !preg_match('/(^\s*\*\/)/i', $override_file[$i + 4])) {
for (; $override_file[$i] && !preg_match('/(.*?\*\/)/i', $override_file[$i]); ++$i) {
$override_file[$i] = '#--remove--#';
}
$override_file[$i] = '#--remove--#';
}
}
}
// Rewrite nice code
$code = '';
foreach ($override_file as $line) {
if ($line == '#--remove--#') {
continue;
}
$code .= $line;
}
$to_delete = preg_match('/<\?(?:php)?\s+(?:abstract|interface)?\s*?class\s+'.$classname.'\s+extends\s+'.$classname.'Core\s*?[{]\s*?[}]/ism', $code);
}
if (!isset($to_delete) || $to_delete) {
unlink($override_path);
// Remove properties from override file
foreach ($reflectionClassModule->getProperties() as $property) {
if (!$reflectionClassOverride->hasProperty($property->getName())) {
continue;
}
// Replace the declaration line by #--remove--#
foreach ($overrideClassFileArray as $lineNumber => &$line_content) {
if (preg_match('/(public|private|protected)\s+(static\s+)?(\$)?'.$property->getName().'/i', $line_content)) {
if (preg_match('/\* module: ('.$this->name.')/ism', $overrideClassFileArray[$lineNumber - 4])) {
$overrideClassFileArray[$lineNumber - 5] = $overrideClassFileArray[$lineNumber - 4] = $overrideClassFileArray[$lineNumber - 3] = $overrideClassFileArray[$lineNumber - 2] = $overrideClassFileArray[$lineNumber - 1] = '#--remove--#';
}
$line_content = '#--remove--#';
break;
}
}
}
// Remove constants from override file
foreach ($reflectionClassModule->getConstants() as $constant => $value) {
if (!$reflectionClassOverride->hasConstant($constant)) {
continue;
}
// Replace the declaration line by #--remove--#
foreach ($overrideClassFileArray as $lineNumber => &$line_content) {
if (preg_match('/(const)\s+(static\s+)?(\$)?'.$constant.'/i', $line_content)) {
if (preg_match('/\* module: ('.$this->name.')/ism', $overrideClassFileArray[$lineNumber - 4])) {
$overrideClassFileArray[$lineNumber - 5] = $overrideClassFileArray[$lineNumber - 4] = $overrideClassFileArray[$lineNumber - 3] = $overrideClassFileArray[$lineNumber - 2] = $overrideClassFileArray[$lineNumber - 1] = '#--remove--#';
}
$line_content = '#--remove--#';
break;
}
}
}
$count = count($overrideClassFileArray);
for ($i = 0; $i < $count; ++$i) {
if (preg_match('/(^\s*\/\/.*)/i', $overrideClassFileArray[$i])) {
$overrideClassFileArray[$i] = '#--remove--#';
} elseif (preg_match('/(^\s*\/\*)/i', $overrideClassFileArray[$i])) {
if (!preg_match('/(^\s*\* module:)/i', $overrideClassFileArray[$i + 1])
&& !preg_match('/(^\s*\* date:)/i', $overrideClassFileArray[$i + 2])
&& !preg_match('/(^\s*\* version:)/i', $overrideClassFileArray[$i + 3])
&& !preg_match('/(^\s*\*\/)/i', $overrideClassFileArray[$i + 4])) {
for (; $overrideClassFileArray[$i] && !preg_match('/(.*?\*\/)/i', $overrideClassFileArray[$i]); ++$i) {
$overrideClassFileArray[$i] = '#--remove--#';
}
$overrideClassFileArray[$i] = '#--remove--#';
}
}
}
// Rewrite nice code
$code = '';
foreach ($overrideClassFileArray as $line) {
if ($line == '#--remove--#') {
continue;
}
$code .= $line;
}
// set regex for empty class to decide if override class must be deleted
$emptyClassRegex = '/<\?(?:php)?\s+(?:abstract|interface)?\s*?class\s+'.$overrideClassName.'\s+extends\s+'.$classname.(($classInfo['type'] == self::OVERRIDE_TYPE_CORE) ? 'Core' : '').'\s*?[{]\s*?[}]/ism';
if ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE_CONTROLLER) {
$emptyClassRegex = '/<\?(?:php)?\s+(?:abstract|interface)?\s*?class\s+'.$overrideClassName.'\s+extends\s+'.substr($overrideClassName, 0, -8).'\s*?[{]\s*?[}]/ism';
}
$toDelete = preg_match($emptyClassRegex, $code);
if (!isset($toDelete) || $toDelete) {
unlink($overrideClassFilePath);
if ($classInfo['type'] == self::OVERRIDE_TYPE_MODULE_CONTROLLER) {
$this->cleanModulesOverrideDir($overrideClassFilePath);
}
} else {
file_put_contents($override_path, $code);
file_put_contents($overrideClassFilePath, $code);
}
// Re-generate the class index
@@ -3217,6 +3347,21 @@ abstract class ModuleCore
return true;
}
private function cleanModulesOverrideDir($dir)
{
if (rtrim($dir, '/') == _PS_ROOT_DIR_.'/override/modules') {
return;
}
$files = Tools::scandir($dir, '');
$diffResult = array_diff($files, array('.', '..', 'index.php'));
if (!count($diffResult)) {
Tools::deleteDirectory($dir);
$this->cleanModulesOverrideDir(dirname($dir));
}
}
/**
* Return the hooks list where this module can be hooked.
*

View File

@@ -34,6 +34,10 @@ class OrderCore extends ObjectModel
const ORDER_PAYMENT_TYPE_FULL = 1;
const ORDER_PAYMENT_TYPE_ADVANCE = 2;
const ORDER_COMPLETE_REFUND_FLAG = 1;
const ORDER_COMPLETE_CANCELLATION_FLAG = 2;
const ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG = 3;
/** @var int Delivery address id */
public $id_address_delivery;
@@ -2537,12 +2541,12 @@ class OrderCore extends ObjectModel
$order_ecotax_tax = Tools::ps_round($order_ecotax_tax, _PS_PRICE_COMPUTE_PRECISION_, $this->round_mode);
$tax_rounding_error = $expected_total_tax - $actual_total_tax - $order_ecotax_tax;
if ($tax_rounding_error !== 0) {
if ($tax_rounding_error != 0) {
Tools::spreadAmount($tax_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_amount');
}
$base_rounding_error = $expected_total_base - $actual_total_base;
if ($base_rounding_error !== 0) {
if ($base_rounding_error != 0) {
Tools::spreadAmount($base_rounding_error, _PS_PRICE_COMPUTE_PRECISION_, $order_detail_tax_rows, 'total_tax_base');
}
}
@@ -2602,51 +2606,53 @@ class OrderCore extends ObjectModel
return Db::getInstance()->executeS('SELECT * FROM '._DB_PREFIX_.'orders WHERE id_cart = '.(int)$id_cart);
}
// Order is considered as refunded if all bookings are requested for refund and all are with refunded status
// $refundFlag [ORDER_RETURN_STATE_FLAG_REFUNDED || ORDER_RETURN_STATE_FLAG_DENIED]
public function hasCompletelyRefunded($refundFlag = 0)
/**
* Function to check if order has been completely refunded
* @param integer action: can have 3 values as below
* Order::ORDER_COMPLETE_REFUND_FLAG for complete refunded and
* Order::ORDER_COMPLETE_CANCELLATION_FLAG for completely cancelled and
* Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG for all rooms are either cancelled or requested for refunded
* @return boolean: true if order has been completely refunded as per requested parameters or false
*/
public function hasCompletelyRefunded($action = 0)
{
$objHotelBooking = new HotelBookingdetail();
if ($refundBookings = OrderReturn::getOrdersReturnDetail($this->id)) {
if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) {
if (count($refundBookings) == count($orderBookings)) {
if ($refundFlag) {
foreach ($refundBookings as $refundRow) {
if (Validate::isLoadedObject(
$objReturnState = new OrderReturnState($refundRow['state']
))) {
if ($refundFlag == OrderReturnState::ORDER_RETURN_STATE_FLAG_REFUNDED
&& !$objReturnState->refunded
) {
return false;
}
if ($refundFlag == OrderReturnState::ORDER_RETURN_STATE_FLAG_DENIED
&& !$objReturnState->denied
) {
return false;
}
}
if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) {
// If action is Order::ORDER_COMPLETE_REFUND_FLAG (for refunded) then we will check
// that all rooms must be refunded and at least one booking is not cancelled
if ($action == Order::ORDER_COMPLETE_REFUND_FLAG) {
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_refunded'));
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
foreach ($orderBookings as $booking) {
if ($booking['is_cancelled'] == 0) {
return true;
}
}
}
// If action is Order::ORDER_COMPLETE_CANCELLATION_FLAG (for cancelled) then we will check that all rooms must be cancelled
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_FLAG) {
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_cancelled'));
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
return true;
}
// If action is Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG (for cancelled and refund requests) then we will check that all rooms are either cancelled or requested for refund
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG) {
foreach ($orderBookings as $booking) {
if (!$booking['is_refunded']) {
if (!OrderReturn::getOrdersReturnDetail($this->id, 0, $booking['id'])) {
return false;
}
}
}
return true;
// Default process to check if order is fully refunded or cancelled or not
} else {
// if is_refunded is 1 means booking either is cancelled or refunded. So check all bookings must have is_refunded = 1
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_refunded'));
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
return true;
}
}
} elseif ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) {
if (count(array_unique(array_column($orderBookings, 'is_cancelled'))) === 1
&& array_unique(array_column($orderBookings, 'is_cancelled'))[0] != 0
) {
return true;
}
}
return false;
}
// Order is considered as denied if all bookings are requested for refund and all are with denied status
public function orderRefundHasBeenDenied()
{
if (OrderReturn::getOrdersReturn($this->id_customer, $this->id)) {
}
return false;

View File

@@ -313,7 +313,6 @@ class OrderHistoryCore extends ObjectModel
// set orders as paid
if ($new_os->paid == 1) {
$invoices = $order->getInvoicesCollection();
if ($order->total_paid != 0) {
// if order is created by API then create a direct object instead of creating an object from module
if ($order->module == 'wsorder') {
@@ -323,22 +322,43 @@ class OrderHistoryCore extends ObjectModel
}
}
foreach ($invoices as $invoice) {
/** @var OrderInvoice $invoice */
$rest_paid = $invoice->getRestPaid();
// if order has invoices then create payment entry for all the invoices
if ($invoices = $order->getInvoicesCollection()->getResults()) {
foreach ($invoices as $invoice) {
/** @var OrderInvoice $invoice */
$rest_paid = $invoice->getRestPaid();
if ($rest_paid > 0) {
if ($order->total_paid != 0) {
$payment_method = $payment_method->displayName;
} else {
$payment_method = null;
}
$order->addOrderPayment(
$rest_paid,
$payment_method,
null,
null,
null,
$invoice
);
}
}
} else {
$rest_paid = $order->total_paid_tax_incl - $order->total_paid_real;
if ($rest_paid > 0) {
if ($order->total_paid != 0) {
$payment_method = $payment_method->displayName;
} else {
$payment_method = null;
}
$order->addOrderPayment(
$rest_paid,
$payment_method,
null,
null,
null,
$invoice
null
);
}
}
@@ -420,11 +440,29 @@ class OrderHistoryCore extends ObjectModel
'{firstname}' => $result['firstname'],
'{id_order}' => (int)$this->id_order,
'{order_name}' => $order->getUniqReference(),
'{total_paid_real}' => Tools::displayPrice($order->total_paid_real, (int)$order->id_currency),
'{is_advance_payment}' => $order->is_advance_payment,
'{advance_paid_amount}' => Tools::displayPrice($order->advance_paid_amount, (int)$order->id_currency),
'{extra_mail_content_html}' => '',
'{extra_mail_content_txt}' => '',
'{payment_method}' => '',
);
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) {
$objHotelBranchInformation = new HotelBranchInformation($idHotel, $order->id_lang);
$fields = array_merge(
$objHotelBranchInformation->getFields(),
$objHotelBranchInformation->getFieldsLang()[$order->id_lang],
$objHotelBranchInformation->getAddress($idHotel, $order->id_lang)
);
foreach ($fields as $key => $value) {
$data['{hotel_'.$key.'}'] = $value;
}
$objHotelBookingDetail = new HotelBookingDetail();
$hotelBookingDetail = $objHotelBookingDetail->getBookingDataByOrderId($order->id);
$data['{num_rooms}'] = count($hotelBookingDetail);
}
if ($result['module_name']) {
if (Validate::isLoadedObject($module = Module::getInstanceByName($result['module_name']))) {
$data['{payment_method}'] = $module->displayName;

View File

@@ -443,23 +443,27 @@ class OrderInvoiceCore extends ObjectModel
$details = $grouped_details;
}
foreach ($details as $row) {
$rate = sprintf('%.3f', $row['tax_rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!$sum_composite_taxes) {
$key = $row['id_tax'];
} else {
$key = sprintf('%.3f', $row['tax_rate']);
}
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' => $rate,
'rate' => sprintf('%.3f', $row['tax_rate']),
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
foreach ($breakdown as $rate => $data) {
$breakdown[$rate]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$rate]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
foreach ($breakdown as $key => $data) {
$breakdown[$key]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$key]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
}
ksort($breakdown);
@@ -503,23 +507,27 @@ class OrderInvoiceCore extends ObjectModel
$details = $grouped_details;
}
foreach ($details as $row) {
$rate = sprintf('%.3f', $row['tax_rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!$sum_composite_taxes) {
$key = $row['id_tax'];
} else {
$key = sprintf('%.3f', $row['tax_rate']);
}
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' => $rate,
'rate' => sprintf('%.3f', $row['tax_rate']),
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
foreach ($breakdown as $rate => $data) {
$breakdown[$rate]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$rate]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
foreach ($breakdown as $key => $data) {
$breakdown[$key]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$key]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
}
ksort($breakdown);
@@ -569,23 +577,27 @@ class OrderInvoiceCore extends ObjectModel
}
foreach ($details as $row) {
$rate = sprintf('%.3f', $row['tax_rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!$sum_composite_taxes) {
$key = $row['id_tax'];
} else {
$key = sprintf('%.3f', $row['tax_rate']);
}
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' => $rate,
'rate' => sprintf('%.3f', $row['tax_rate']),
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
foreach ($breakdown as $rate => $data) {
$breakdown[$rate]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$rate]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
foreach ($breakdown as $key => $data) {
$breakdown[$key]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$key]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
}
ksort($breakdown);
@@ -629,23 +641,27 @@ class OrderInvoiceCore extends ObjectModel
$details = $grouped_details;
}
foreach ($details as $row) {
$rate = sprintf('%.3f', $row['tax_rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!$sum_composite_taxes) {
$key = $row['id_tax'];
} else {
$key = sprintf('%.3f', $row['tax_rate']);
}
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' => $rate,
'rate' => $key,
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
foreach ($breakdown as $rate => $data) {
$breakdown[$rate]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$rate]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
foreach ($breakdown as $key => $data) {
$breakdown[$key]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
$breakdown[$key]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $order->round_mode);
}
ksort($breakdown);
@@ -693,17 +709,18 @@ class OrderInvoiceCore extends ObjectModel
}
} else {
foreach ($details as $row) {
$key = $row['id_tax'];
$rate = sprintf('%.3f', $row['rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' =>$rate,
'rate' => $rate,
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
}
foreach ($breakdown as $rate => $data) {
@@ -887,9 +904,11 @@ class OrderInvoiceCore extends ObjectModel
SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE DATE_ADD(oi.date_add, INTERVAL -1 DAY) <= \''.pSQL($date_to).'\'
AND oi.date_add >= \''.pSQL($date_from).'\'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')
.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
ORDER BY oi.date_add ASC
');
@@ -908,8 +927,10 @@ class OrderInvoiceCore extends ObjectModel
SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE '.(int)$id_order_state.' = o.current_state
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')
.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
ORDER BY oi.`date_add` ASC
');

View File

@@ -158,7 +158,8 @@ class OrderReturnCore extends ObjectModel
public function hasBeenCompleted()
{
if (Validate::isLoadedObject($objReturnState = new OrderReturnState($this->state))) {
if ($objReturnState->denied || $objReturnState->refunded) {
// refund process will be considered as completed when the state is "Refunded"
if ($objReturnState->refunded) {
return true;
}
}

View File

@@ -633,7 +633,6 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
'tax_excluded_display' => $tax_excluded_display,
'display_product_images' => $display_product_images,
'layout' => $layout,
'tax_tab' => $this->getTaxTabContent(),
'customer' => $customer,
'footer' => $footer,
'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_,

View File

@@ -200,8 +200,6 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
{
$address = new Address((int)$this->order->id_address_tax);
$this->smarty->assign(array(
'product_tax_breakdown' => $this->getProductTaxesBreakdown(),
'shipping_tax_breakdown' => $this->getShippingTaxesBreakdown(),
'order' => $this->order,
'ecotax_tax_breakdown' => $this->order_slip->getEcoTaxTaxesBreakdown(),
'is_order_slip' => true,
@@ -220,7 +218,7 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
protected function getTaxBreakdown()
{
$breakdowns = array(
'product_tax' => $this->getProductTaxesBreakdown(),
'room_tax' => $this->getRoomTypeTaxesBreakdown(),
'shipping_tax' => $this->getShippingTaxesBreakdown(),
'ecotax_tax' => $this->order_slip->getEcoTaxTaxesBreakdown(),
);
@@ -251,33 +249,78 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
return $breakdowns;
}
public function getProductTaxesBreakdown()
public function useOneAfterAnotherTaxComputationMethod()
{
// if one of the order details use the tax computation method the display will be different
return Db::getInstance()->getValue('
SELECT od.`tax_computation_method`
FROM `' . _DB_PREFIX_ . 'order_detail_tax` odt
LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` od ON (od.`id_order_detail` = odt.`id_order_detail`)
WHERE od.`id_order` = ' . (int) $this->order->id_order . '
AND od.`tax_computation_method` = ' . (int) TaxCalculator::ONE_AFTER_ANOTHER_METHOD)
|| Configuration::get('PS_INVOICE_TAXES_BREAKDOWN');
}
public function getRoomTypeTaxesBreakdown()
{
$sum_composite_taxes = !$this->useOneAfterAnotherTaxComputationMethod();
// $breakdown will be an array with tax rates as keys and at least the columns:
// - 'total_price_tax_excl'
// - 'total_amount'
$breakdown = array();
$details = $this->order->getProductTaxesDetails($this->order->products);
$order_detail = array_filter($this->order->products, function($v) {
return ($v['is_booking_product']
|| ($v['product_auto_add']
&& $v['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE
&& $v['product_price_addition_type'] == ProductCore::PRICE_ADDITION_TYPE_WITH_ROOM)
);
});
$details = $this->order->getProductTaxesDetails($order_detail);
if ($sum_composite_taxes) {
$grouped_details = array();
foreach ($details as $row) {
if (!isset($grouped_details[$row['id_order_detail']])) {
$grouped_details[$row['id_order_detail']] = array(
'tax_rate' => 0,
'total_tax_base' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
);
}
$grouped_details[$row['id_order_detail']]['tax_rate'] += $row['tax_rate'];
$grouped_details[$row['id_order_detail']]['total_tax_base'] += $row['total_tax_base'];
$grouped_details[$row['id_order_detail']]['total_amount'] += $row['total_amount'];
}
$details = $grouped_details;
}
foreach ($details as $row) {
$rate = sprintf('%.3f', $row['tax_rate']);
if (!isset($breakdown[$rate])) {
$breakdown[$rate] = array(
if (!$sum_composite_taxes) {
$key = $row['id_tax'];
} else {
$key = sprintf('%.3f', $row['tax_rate']);
}
if (!isset($breakdown[$key])) {
$breakdown[$key] = array(
'total_price_tax_excl' => 0,
'total_amount' => 0,
'id_tax' => $row['id_tax'],
'rate' =>$rate,
'rate' => sprintf('%.3f', $row['tax_rate']),
);
}
$breakdown[$rate]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$rate]['total_amount'] += $row['total_amount'];
$breakdown[$key]['total_price_tax_excl'] += $row['total_tax_base'];
$breakdown[$key]['total_amount'] += $row['total_amount'];
}
foreach ($breakdown as $rate => $data) {
$breakdown[$rate]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode);
$breakdown[$rate]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode);
foreach ($breakdown as $key => $data) {
$breakdown[$key]['total_price_tax_excl'] = Tools::ps_round($data['total_price_tax_excl'], _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode);
$breakdown[$key]['total_amount'] = Tools::ps_round($data['total_amount'], _PS_PRICE_COMPUTE_PRECISION_, $this->order->round_mode);
}
ksort($breakdown);

View File

@@ -68,7 +68,8 @@ function smartyTranslate($params, $smarty)
}
// If the tpl is used by a Helper
if (strpos($filename, 'helpers') === 0) {
$className = isset(Context::getContext()->controller->controller_name) ? Tools::toUnderscoreCase(substr(Context::getContext()->controller->controller_name, 5)) : '';
if (strpos($filename, 'helpers') === 0 && $className && strpos($smarty->source->name, '/template/controllers/'.$className.'/') === false) {
$class = 'Helper';
}
// If the tpl is used by a Controller

View File

@@ -74,16 +74,6 @@ class AdminAddressesControllerCore extends AdminController
'city' => array('title' => $this->l('City')),
'country' => array('title' => $this->l('Country'), 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country'));
// START send access query information to the admin controller
$this->access_select = ' SELECT a.`id_address` FROM '._DB_PREFIX_.'address a';
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'customer cust ON (cust.id_customer = a.id_customer)';
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'orders ord ON (cust.id_customer = ord.id_customer)';
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
$this->access_where = ' WHERE hbd.id_hotel IN ('.implode(',', $acsHtls).')';
}
parent::__construct();
$this->_select = 'cl.`name` as country';

View File

@@ -115,7 +115,7 @@ class AdminCustomerPreferencesControllerCore extends AdminController
),
'PS_CUSTOMER_OPTIN' => array(
'title' => $this->l('Enable opt-in'),
'hint' => $this->l('Display or not the opt-in tick box, to receive offers from the store\'s partners.'),
'hint' => $this->l('Display or not the opt-in tick box, to receive offers from your hotel partners.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'

View File

@@ -62,6 +62,15 @@ class AdminCustomerThreadsControllerCore extends AdminController
$status_array[$k] = $v['alt'];
}
// START send access query information to the admin controller
$this->access_select = ' SELECT a.`id_customer_thread` FROM '._DB_PREFIX_.'customer_thread a';
$this->access_join = ' LEFT JOIN '._DB_PREFIX_.'orders ord ON (a.id_order = ord.id_order)';
$this->access_join .= ' LEFT JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
$this->access_where = ' WHERE 1 ';
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
$this->access_where .= ' AND IF(a.`id_order`, hbd.`id_hotel` IN ('.implode(',', $acsHtls).'), 1)';
}
$this->fields_list = array(
'id_customer_thread' => array(
'title' => $this->l('ID'),

View File

@@ -39,8 +39,8 @@ class AdminCustomersControllerCore extends AdminController
public function __construct()
{
$this->bootstrap = true;
$this->required_database = true;
$this->required_fields = array('newsletter','optin');
// $this->required_database = true;
// $this->required_fields = array('newsletter','optin');
$this->table = 'customer';
$this->className = 'Customer';
$this->lang = false;
@@ -152,16 +152,6 @@ class AdminCustomersControllerCore extends AdminController
$this->shopLinkType = 'shop';
$this->shopShareDatas = Shop::SHARE_CUSTOMER;
// START send access query information to the admin controller
$this->access_select = ' SELECT a.`id_customer` FROM '._DB_PREFIX_.'customer a';
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'orders ord ON (a.id_customer = ord.id_customer)';
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
$this->access_where = ' WHERE hbd.id_hotel IN ('.implode(',', $acsHtls).')';
}
parent::__construct();
$this->_select = '
@@ -458,8 +448,9 @@ class AdminCustomersControllerCore extends AdminController
'label' => $this->l('Disabled')
)
),
'disabled' => (bool)!Configuration::get('PS_CUSTOMER_NWSL'),
'hint' => $this->l('This customer will receive your newsletter via email.')
'disabled' => (bool)!Configuration::get('PS_CUSTOMER_NWSL'),
'hint' => $this->l('This customer will receive your newsletter via email.'),
'desc' => (bool)!Configuration::get('PS_CUSTOMER_NWSL') ? sprintf($this->l('This field is disabled as option \'Enable newsletter registration\' is disabled. You can change it from %sPreferences > Customers%s page.'), '<a href="'.$this->context->link->getAdminLink('AdminCustomerPreferences').'" target="_blank">', '</a>') : '',
),
array(
'type' => 'switch',

View File

@@ -386,7 +386,16 @@ class AdminDashboardControllerCore extends AdminController
'extra' => Tools::getValue('extra')
);
die(json_encode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
// code to be added.
$data = Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'));
Hook::exec('actionDashboardDataModifier', array(
'data' => &$data,
'params' => $params,
'id_module' => $id_module,
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
));
$this->ajaxDie(json_encode($data));
}
public function ajaxProcessSetSimulationMode()

View File

@@ -195,10 +195,12 @@ class AdminInvoicesControllerCore extends AdminController
);
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT COUNT( o.id_order ) AS nbOrders, o.current_state as id_order_state
SELECT COUNT(DISTINCT(o.id_order)) AS nbOrders, o.current_state as id_order_state
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oi.id_order = o.id_order
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
WHERE o.id_shop IN('.implode(', ', Shop::getContextListShopID()).')
'.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
AND oi.number > 0
GROUP BY o.current_state
');

View File

@@ -444,8 +444,12 @@ class AdminModulesControllerCore extends AdminController
@unlink($file);
$this->recursiveDeleteOnDisk($tmp_folder);
if ($success && $redirect) {
Tools::redirectAdmin(self::$currentIndex.'&conf=8&anchor='.ucfirst($folder).'&token='.$this->token);
if ($success) {
if ($redirect) {
Tools::redirectAdmin(self::$currentIndex.'&conf=8&anchor='.ucfirst($folder).'&token='.$this->token);
} else {
$success = $folder;
}
}
return $success;
@@ -610,7 +614,7 @@ class AdminModulesControllerCore extends AdminController
} elseif (!move_uploaded_file($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name'])) {
$this->errors[] = Tools::displayError('An error occurred while copying the archive to the module directory.');
} else {
$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name'], $redirect);
return $this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name'], $redirect);
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
@@ -1669,11 +1673,9 @@ class AdminModulesControllerCore extends AdminController
public function ajaxProcessUploadModule()
{
$response = array('success' => false);
$this->postProcessDownload(false);
$folder = $this->postProcessDownload(false);
if (!count($this->errors)) {
$filename = $_FILES['file']['name'];
$filename = explode('.', $filename);
if ($module = Module::getInstanceByName($filename[0])) {
if ($folder && $module = Module::getInstanceByName($folder)) {
$response['success'] = true;
if (Module::isInstalled($module->name)) {
$response['msg'] = $this->l('module already installed, update if available');
@@ -1692,6 +1694,9 @@ class AdminModulesControllerCore extends AdminController
'author' => $module->author,
'image' => $module->image ? $module->image : ''
);
} else {
$this->errors[] = $this->l('The uploaded file does not contain a valid module.');
$response['errors'] = $this->errors;
}
} else {
$response['errors'] = $this->errors;

View File

@@ -1746,6 +1746,10 @@ class AdminNormalProductsControllerCore extends AdminController
$this->object = new $this->className();
$this->_removeTaxFromEcotax();
if (Tools::getValue('auto_add_to_cart')) {
$_POST['allow_multiple_quantity'] = 0;
}
$this->copyFromPost($this->object, $this->table);
$this->object->service_product_type = Product::SERVICE_PRODUCT_WITH_ROOMTYPE;
@@ -1884,6 +1888,9 @@ class AdminNormalProductsControllerCore extends AdminController
/** @var Product $object */
$object = new $this->className((int)$id);
$this->object = $object;
if (Tools::getValue('auto_add_to_cart')) {
$_POST['allow_multiple_quantity'] = 0;
}
if (Validate::isLoadedObject($object)) {
$this->_removeTaxFromEcotax();

View File

@@ -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
@@ -251,7 +315,6 @@ class AdminOrdersControllerCore extends AdminController
$this->access_where = ' WHERE hbd.id_hotel IN ('.implode(',', $acsHtls).')';
}
parent::__construct();
}
@@ -533,6 +596,8 @@ class AdminOrdersControllerCore extends AdminController
$this->tpl_list_vars['POST'] = $_POST;
}
$this->tpl_list_vars['title'] = $this->l('Orders');
return parent::renderList();
}
@@ -695,7 +760,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;
@@ -721,11 +858,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 {
@@ -856,26 +992,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();
}
}
}
@@ -1883,13 +2051,16 @@ class AdminOrdersControllerCore extends AdminController
// applicable refund policies
$applicableRefundPolicies = HotelOrderRefundRules::getApplicableRefundRules($order->id);
$this->tpl_view_vars = array(
// refund info
'refund_allowed' => (int) $order->isReturnable(),
'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,
@@ -1997,6 +2168,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);
@@ -2922,6 +3173,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) {
@@ -2949,7 +3201,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
@@ -2966,6 +3229,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,
@@ -2987,7 +3251,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;
@@ -3237,7 +3501,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(
@@ -3309,7 +3573,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();
}
}
}
}
}
@@ -3328,6 +3654,7 @@ class AdminOrdersControllerCore extends AdminController
)));
}
/**
* This function is called when order is changed (Add/Edit/Delete room on order)
*/

View File

@@ -194,6 +194,15 @@ class AdminPPreferencesControllerCore extends AdminController
'required' => false,
'type' => 'bool'
),
'WK_ROOM_LEFT_WARNING_NUMBER' => array(
'title' => $this->l('Display remaining Number of rooms when the rooms are lower than or equal to'),
'hint' => $this->l('Mention the minimum quantity of rooms after which alert message of remaining rooms will get displayed to users.'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'class' => 'fixed-width-xxl',
'visibility' => Shop::CONTEXT_ALL,
),
),
'submit' => array('title' => $this->l('Save'))
),
@@ -391,29 +400,6 @@ class AdminPPreferencesControllerCore extends AdminController
// 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
// 'submit' => array('title' => $this->l('Save'))
// ),
'fo_search_filters' => array(
'title' => $this->l('Search Results Page Filters'),
'icon' => 'icon-search',
'fields' => array(
'SHOW_AMENITIES_FILTER' => array(
'title' => $this->l('Show Amenities filter'),
'hint' => $this->l('Enable to display Amenities filter.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
),
'SHOW_PRICE_FILTER' => array(
'title' => $this->l('Show Price filter'),
'hint' => $this->l('Enable to display Price filter.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
),
),
'submit' => array('title' => $this->l('Save'))
),
);
}

View File

@@ -88,7 +88,6 @@ class AdminProductsControllerCore extends AdminController
parent::__construct();
$this->imageType = 'jpg';
$this->_defaultOrderBy = 'position';
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
$this->allow_export = true;
@@ -101,7 +100,7 @@ class AdminProductsControllerCore extends AdminController
'ServiceProduct' => $this->l('Service Products'),
// 'Associations' => $this->l('Associations'),
'Features' => $this->l('Features'),
'Configuration' => $this->l('Configuration'),
'Configuration' => $this->l('Rooms'),
'Occupancy' => $this->l('Occupancy'),
'LengthOfStay' => $this->l('Length of Stay'),
'AdditionalFacilities' => $this->l('Additional Facilities'),
@@ -144,32 +143,37 @@ class AdminProductsControllerCore extends AdminController
}
}
if (Tools::getValue('reset_filter_category')) {
$this->context->cookie->id_category_products_filter = false;
if (Tools::getValue('productFilter_a!id_category_default') === '') {
$this->context->cookie->id_category_room_types_filter = false;
}
if (Shop::isFeatureActive() && $this->context->cookie->id_category_products_filter) {
$category = new Category((int)$this->context->cookie->id_category_products_filter);
if (Shop::isFeatureActive() && $this->context->cookie->id_category_room_types_filter) {
$category = new Category((int)$this->context->cookie->id_category_room_types_filter);
if (!$category->inShop()) {
$this->context->cookie->id_category_products_filter = false;
$this->context->cookie->id_category_room_types_filter = false;
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts'));
}
}
/* Join categories table */
if ($id_category = (int)Tools::getValue('productFilter_cl!name')) {
$this->_category = new Category((int)$id_category);
$_POST['productFilter_cl!name'] = $this->_category->name[$this->context->language->id];
// to support filter URLs with 'id_category' parameter
if ($id_category = (int)Tools::getValue('id_category')) {
$_POST['submitFilter'] = '1';
$_POST['productFilter_a!id_category_default'] = $id_category;
}
if (($id_category = (int)Tools::getValue('id_category'))
|| ($id_category = (int) Tools::getValue('productFilter_a!id_category_default'))
) {
$this->id_current_category = $id_category;
$this->context->cookie->id_category_room_types_filter = $id_category;
} elseif ($id_category = $this->context->cookie->id_category_room_types_filter) {
$this->id_current_category = $id_category;
}
if ($this->id_current_category) {
$this->_category = new Category((int)$this->id_current_category);
$this->position_group_identifier = (int) $this->id_current_category;
} else {
if ($id_category = (int)Tools::getValue('id_category')) {
$this->id_current_category = $id_category;
$this->context->cookie->id_category_products_filter = $id_category;
} elseif ($id_category = $this->context->cookie->id_category_products_filter) {
$this->id_current_category = $id_category;
}
if ($this->id_current_category) {
$this->_category = new Category((int)$this->id_current_category);
} else {
$this->_category = new Category();
}
$this->_category = new Category();
}
$join_category = false;
@@ -194,12 +198,16 @@ class AdminProductsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = image_shop.`id_image`)
LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product` AND pd.`active` = 1)
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)';
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_demand` hrtd ON (hrtd.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`))';
$this->_select .= ' (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, ';
$this->_select .= 'hrt.`adults`, hrt.`children`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
$this->_select .= 'hrt.`adults`, hrt.`children`, hrt.`max_guests`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
$this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, ';
$this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`';
$this->_select .= ', IFNULL((SELECT hap.`active` FROM `'._DB_PREFIX_.'htl_advance_payment` hap WHERE hap.`id_product` = a.`id_product`), 0) AS advance_payment';
if ($join_category) {
$this->_join .= ' INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.') ';
@@ -209,8 +217,7 @@ class AdminProductsControllerCore extends AdminController
// show the list of the product according to the booking or service products
$this->_where .= ' AND a.`booking_product` = 1';
$this->_use_found_rows = false;
$this->_group = '';
$this->_group = ' GROUP BY a.`id_product`';
$this->fields_list = array();
$this->fields_list['id_product'] = array(
@@ -237,33 +244,51 @@ class AdminProductsControllerCore extends AdminController
'filter_key' => 'shop!name',
);
} else {
$hotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1);
foreach ($hotels as $hotel) {
$addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']);
$this->hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city'];
}
$this->fields_list['hotel_name'] = array(
'title' => $this->l('Hotel'),
'filter_key' => 'hbl!hotel_name',
'callback' => 'getHotelName',
'type' => 'select',
'multiple' => true,
'operator' => 'or',
'filter_key' => 'hrt!id_hotel',
'list' => $this->hotelsArray,
'optional' => true,
'class' => 'chosen',
'remove_onchange' => true,
'visible_default' => true,
);
}
$this->fields_list['adults'] = array(
'title' => $this->l('Adults'),
'filter_key' => 'hrt!adults',
'type' => 'range',
'align' => 'center',
);
$this->fields_list['child'] = array(
$this->fields_list['children'] = array(
'title' => $this->l('Children'),
'filter_key' => 'hrt!children',
'type' => 'range',
'align' => 'center',
);
// use it for total rooms
$this->fields_list['num_rooms'] = array(
'title' => $this->l('Total Rooms'),
'align' => 'center',
'type' => 'range',
'havingFilter' => true,
);
$this->fields_list['price'] = array(
'title' => $this->l('Base price'),
'type' => 'price',
'title' => $this->l('Base Price'),
'type' => 'range',
'validation' => 'isFloat',
'align' => 'text-left',
'filter_key' => 'a!price'
'filter_key' => 'a!price',
'callback' => 'displayBasePrice',
);
$this->fields_list['price_final'] = array(
'title' => $this->l('Final price'),
@@ -279,12 +304,126 @@ class AdminProductsControllerCore extends AdminController
'active' => 'status',
'filter_key' => $alias.'!active',
'align' => 'text-center',
'type' => 'bool',
'class' => 'fixed-width-sm',
'type' => 'select',
'list' => array(1 => $this->l('Yes'), 0 => $this->l('No')),
'optional' => true,
'visible_default' => true,
'remove_onchange' => true,
'orderby' => false
);
if ($join_category && (int)$this->id_current_category) {
$this->fields_list['max_guests'] = array(
'title' => $this->l('Maximum Occupancy'),
'filter_key' => 'hrt!max_guests',
'type' => 'range',
'align' => 'center',
'optional' => true,
);
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) {
$this->fields_list['advance_payment'] = array(
'title' => $this->l('Advance Payment'),
'active' => 'advance_payment',
'align' => 'text-center',
'type' => 'bool',
'optional' => true,
'havingFilter' => true,
'visible_default' => true,
'orderby' => false,
);
}
$taxRulesGroups = array();
foreach (TaxRulesGroup::getTaxRulesGroups(true) as $taxRulesGroup) {
$taxRulesGroups[$taxRulesGroup['id_tax_rules_group']] = $taxRulesGroup['name'];
}
$this->fields_list['id_tax_rules_group'] = array(
'title' => $this->l('Tax Rules'),
'align' => 'text-center',
'type' => 'select',
'multiple' => true,
'operator' => 'or',
'filter_key' => 'a!id_tax_rules_group',
'list' => $taxRulesGroups,
'displayed' => false,
);
$features = array();
foreach (Feature::getFeatures($this->context->language->id) as $feature) {
$features[$feature['id_feature']] = $feature['name'];
}
$this->fields_list['id_feature'] = array(
'title' => $this->l('Features'),
'align' => 'text-center',
'type' => 'select',
'multiple' => true,
'operator' => 'and',
'filter_key' => 'fp!id_feature',
'list' => $features,
'displayed' => false,
);
$objProduct = new Product();
$allServiceProducts = $objProduct->getServiceProducts();
$serviceProducts = array();
foreach ($allServiceProducts as $serviceProduct) {
$serviceProducts[$serviceProduct['id_product']] = $serviceProduct['name'];
}
$this->fields_list['id_service_product'] = array(
'title' => $this->l('Service Products'),
'align' => 'text-center',
'type' => 'select',
'multiple' => true,
'operator' => 'and',
'filter_key' => 'hrtsp!id_product',
'list' => $serviceProducts,
'displayed' => false,
);
$additionalFacilities = array();
$objHotelRoomTypeGlobalDemand = new HotelRoomTypeGlobalDemand();
$demands = $objHotelRoomTypeGlobalDemand->getAllDemands();
foreach ($demands as $demand) {
$additionalFacilities[$demand['id_global_demand']] = $demand['name'];
}
$this->fields_list['id_global_demand'] = array(
'title' => $this->l('Additional Facilities'),
'align' => 'text-center',
'type' => 'select',
'multiple' => true,
'operator' => 'and',
'filter_key' => 'hrtd!id_global_demand',
'list' => $additionalFacilities,
'displayed' => false,
);
$this->locationsAndHotels = array();
$idLocationsCategory = Configuration::get('PS_LOCATIONS_CATEGORY');
$this->objLocationsCategory = new Category($idLocationsCategory, $this->context->language->id);
$nestedCategories = Category::getNestedCategories($idLocationsCategory);
if ($nestedCategories) {
foreach ($nestedCategories[$idLocationsCategory]['children'] as $childCategory) {
$this->buildCategoryOptions($childCategory);
}
}
$this->fields_list['id_category_default'] = array(
'title' => $this->l('Location/Hotel'),
'align' => 'text-center',
'type' => 'select',
'list' => $this->locationsAndHotels,
'filter_key' => 'a!id_category_default',
'remove_onchange' => true,
'displayed' => false,
);
// display Position column only if it is a hotel category
if ($join_category
&& (int) $this->id_current_category
&& HotelBranchInformation::getHotelIdByIdCategory($this->id_current_category)
) {
$this->_orderBy = 'position';
$this->_orderWay = 'ASC';
$this->fields_list['position'] = array(
'title' => $this->l('Position'),
'filter_key' => 'cp!position',
@@ -294,13 +433,21 @@ class AdminProductsControllerCore extends AdminController
}
}
public function getHotelName($hotelName, $row)
private function buildCategoryOptions($category)
{
if ($hotelName && isset($row['city'])) {
return $hotelName.' - '.$row['city'];
}
$space = str_repeat('&nbsp;', 5 * (($category['level_depth'] - $this->objLocationsCategory->level_depth) - 1));
$this->locationsAndHotels[$category['id_category']] = $space.$category['name'];
return '--';
if (isset($category['children']) && count($category['children'])) {
foreach ($category['children'] as $childCategory) {
$this->buildCategoryOptions($childCategory);
}
}
}
public static function displayBasePrice($basePrice, $tr)
{
return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT'));
}
public static function getQuantities($hotelName, $tr)
@@ -352,6 +499,23 @@ class AdminProductsControllerCore extends AdminController
}
}
protected function filterToField($key, $filter)
{
if ($key == 'a!id_category_default') {
return false;
}
return parent::filterToField($key, $filter);
}
public function processResetFilters($list_id = null)
{
parent::processResetFilters($list_id);
// reset category filter
$this->context->cookie->id_category_room_types_filter = false;
}
/**
* @param Product|ObjectModel $object
* @param string $table
@@ -628,6 +792,10 @@ class AdminProductsControllerCore extends AdminController
}
}
// update `id_category_default`
$objHotelBranchInformation = new HotelBranchInformation($id_hotel_new);
$product->id_category_default = $objHotelBranchInformation->id_category;
// update lang fields
foreach (Language::getLanguages(true) as $language) {
$product->link_rewrite[$language['id_lang']] = Tools::str2url($product->name[$language['id_lang']]);
@@ -1168,6 +1336,14 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
}
// Toggle Advance Payment
elseif (Tools::getIsset('advance_payment'.$this->table)) {
if ($this->tabAccess['edit'] === '1') {
$this->action = 'toggleAdvancePayment';
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
}
// Product images management
elseif (Tools::getValue('id_image') && Tools::getValue('ajax')) {
if ($this->tabAccess['edit'] === '1') {
@@ -1720,6 +1896,41 @@ class AdminProductsControllerCore extends AdminController
return $res;
}
public function processToggleAdvancePayment()
{
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) {
$this->loadObject(true);
if (!Validate::isLoadedObject($this->object)) {
return false;
}
if (!Product::isBookingProduct($this->object->id)) {
return false;
}
$objHotelAdvancedPayment = new HotelAdvancedPayment();
$roomTypeAdvancePaymentInfo = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($this->object->id);
if ($roomTypeAdvancePaymentInfo) {
$objHotelAdvancedPayment = new HotelAdvancedPayment($roomTypeAdvancePaymentInfo['id']);
$objHotelAdvancedPayment->active = !$objHotelAdvancedPayment->active;
} else {
$objHotelAdvancedPayment->id_product = $this->object->id;
$objHotelAdvancedPayment->payment_type = '';
$objHotelAdvancedPayment->value = '';
$objHotelAdvancedPayment->id_currency = '';
$objHotelAdvancedPayment->tax_include = '';
$objHotelAdvancedPayment->calculate_from = 0;
$objHotelAdvancedPayment->active = 1;
}
if ($objHotelAdvancedPayment->save()) {
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=4');
} else {
$this->errors[] = $this->l('Something went wrong while updating Advance payment status.');
}
}
}
public function processUpdate()
{
$existing_product = $this->object;
@@ -1770,6 +1981,9 @@ class AdminProductsControllerCore extends AdminController
}
if ($object->update()) {
// update position in category
$object->setPositionInCategory(Tools::getValue('category_position'));
// If the product doesn't exist in the current shop but exists in another shop
if (Shop::getContext() == Shop::CONTEXT_SHOP && !$existing_product->isAssociatedToShop($this->context->shop->id)) {
$out_of_stock = StockAvailable::outOfStock($existing_product->id, $existing_product->id_shop_default);
@@ -2055,6 +2269,21 @@ class AdminProductsControllerCore extends AdminController
}
}
}
// Category Position
if (Validate::isLoadedObject($this->object)) {
$categoryPositon = Tools::getValue('category_position');
if ($categoryPositon < 0) {
$this->errors[] = $this->l('Position can not be less than 0.');
}
if (isset($objHotel) && Validate::isLoadedObject($objHotel)) {
$maxPosition = Product::getHighestPositionInCategory($objHotel->id_category);
if ($categoryPositon > $maxPosition) {
$this->errors[] = sprintf($this->l('Position can not be greater than %d.'), $maxPosition);
}
}
}
}
/**
@@ -2195,35 +2424,14 @@ class AdminProductsControllerCore extends AdminController
$this->tpl_form_vars['product_tabs'] = $product_tabs;
}
} else {
if ($id_category = (int)$this->id_current_category) {
self::$currentIndex .= '&id_category='.(int)$this->id_current_category;
}
// If products from all categories are displayed, we don't want to use sorting by position
if (!$id_category) {
if (!(int) $this->id_current_category) {
$this->_defaultOrderBy = $this->identifier;
if ($this->context->cookie->{$this->table.'Orderby'} == 'position') {
unset($this->context->cookie->{$this->table.'Orderby'});
unset($this->context->cookie->{$this->table.'Orderway'});
}
}
if (!$id_category) {
$id_category = Configuration::get('PS_ROOT_CATEGORY');
}
$this->tpl_list_vars['is_category_filter'] = (bool)$this->id_current_category;
// Generate category selection tree
$catFilter = $this->l('Filter by Places');
$tree = new HelperTreeCategories('categories-tree', $catFilter);
$tree->setAttribute('is_category_filter', (bool)$this->id_current_category)
->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token)
->setInputName('id-category')
->setRootCategory((int)Configuration::get('PS_LOCATIONS_CATEGORY'))
->setSelectedCategories(array((int)$id_category));
$this->tpl_list_vars['category_tree'] = $tree->render();
// used to build the new url when changing category
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
}
parent::initContent();
@@ -2298,6 +2506,9 @@ class AdminProductsControllerCore extends AdminController
$this->addRowAction('preview');
$this->addRowAction('duplicate');
$this->addRowAction('delete');
$this->tpl_list_vars['title'] = $this->l('Room Types');
return parent::renderList();
}
@@ -2693,6 +2904,13 @@ class AdminProductsControllerCore extends AdminController
$hotelRoomInfo = $objRoomInfo->getHotelRoomInfo($obj->id, $hotelRoomType['id_hotel']);
if ($hotelRoomInfo) {
foreach ($hotelRoomInfo as &$room) {
$bookedDates = $objRoomInfo->getFutureBookings($room['id']);
foreach($bookedDates as &$bookedDate) {
$bookedDate['date_from_formatted'] = Tools::displayDate($bookedDate['date_from']);
$bookedDate['date_to_formatted'] = Tools::displayDate($bookedDate['date_to']);
}
$room['booked_dates'] = json_encode($bookedDates);
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
$room['disable_dates_json'] = json_encode($disabledDates);
@@ -3279,6 +3497,14 @@ class AdminProductsControllerCore extends AdminController
$objHotelRoomDisableDates->reason = $disableDate['reason'];
$objHotelRoomDisableDates->add();
}
Hook::exec(
'actionRoomDisableDatesAddAfter',
array(
'room_info' => $roomInfo,
'disable_dates' => $disableDates
)
);
}
}
}
@@ -3317,10 +3543,15 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = sprintf(Tools::displayError('Invalid floor for room %s.'), $roomIndex);
}
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_INACTIVE) {
$objHotelRoomInformation = new HotelRoomInformation();
if (count($objHotelRoomInformation->getFutureBookings($roomInfo['id']))) {
$this->errors[] = sprintf(Tools::displayError('Cannot change room %s status to inactive as it already has some bookings, Please check the bookings and move those bookings to another room if you want make this room inactive'), $roomInfo['room_num']);
}
} elseif ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
$disableDates = json_decode($roomInfo['disable_dates_json'], true);
if ($roomInfo['disable_dates_json'] !== 0) {
$this->validateDisableDateRanges($disableDates, $roomIndex, $roomInfo['id']);
$this->validateDisableDateRanges($disableDates, $roomInfo['room_num'], $roomInfo['id']);
}
}
}
@@ -3331,14 +3562,28 @@ class AdminProductsControllerCore extends AdminController
public function ajaxProcessDeleteHotelRoom()
{
$response = array(
'success' => false
);
if ($this->tabAccess['edit'] == 1) {
$idRoom = Tools::getValue('id');
$objRoomInfo = new HotelRoomInformation((int)$idRoom);
if ($objRoomInfo->delete()) {
die('1');
$objHotelRoomInformation = new HotelRoomInformation();
if ($objHotelRoomInformation->getFutureBookings($idRoom)) {
$this->errors[] = $this->l('This room cannot be deleted as this room contains future booking.');
}
if (empty($this->errors)) {
if ($objRoomInfo->delete()) {
$response['success'] = true;
} else {
$this->errors[] = $this->l('Unable to delete room. Please try again!.');
}
}
}
die('0');
if (!empty($this->errors)) {
$response['errors'] = $this->errors;
}
die(json_encode($response));
}
public function initFormAdditionalFacilities($obj)
@@ -3484,7 +3729,7 @@ class AdminProductsControllerCore extends AdminController
$product = $obj;
// Prepare Categories tree for display in Associations tab
$root = Category::getRootCategory();
$default_category = $this->context->cookie->id_category_products_filter ? $this->context->cookie->id_category_products_filter : Context::getContext()->shop->id_category;
$default_category = $this->context->cookie->id_category_room_types_filter ? $this->context->cookie->id_category_room_types_filter : Context::getContext()->shop->id_category;
if (!$product->id || !$product->isAssociatedToShop()) {
$selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
} else {
@@ -4121,7 +4366,8 @@ class AdminProductsControllerCore extends AdminController
'token' => $this->token,
'currency' => $currency,
'link' => $this->context->link,
'PS_PRODUCT_SHORT_DESC_LIMIT' => Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400
'PS_PRODUCT_SHORT_DESC_LIMIT' => Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400,
'category_position' => Tools::getValue('category_position', $product->getPositionInCategory()),
));
$data->assign($this->tpl_form_vars);
@@ -4647,7 +4893,7 @@ class AdminProductsControllerCore extends AdminController
if ($this->tabAccess['edit'] === '1') {
$way = (int)(Tools::getValue('way'));
$id_product = (int)Tools::getValue('id_product');
$id_category = (int)Tools::getValue('id_category');
$id_category = (int)Tools::getValue('id_category_hotel');
$positions = Tools::getValue('product');
$page = (int)Tools::getValue('page');
$selected_pagination = (int)Tools::getValue('selected_pagination');
@@ -4662,7 +4908,7 @@ class AdminProductsControllerCore extends AdminController
}
if ($product = new Product((int)$pos[2])) {
if (isset($position) && $product->updatePosition($way, $position)) {
if (isset($position) && $product->updatePosition($way, $position, $id_category)) {
$category = new Category((int)$id_category);
if (Validate::isLoadedObject($category)) {
hook::Exec('categoryUpdate', array('category' => $category));

View File

@@ -2111,7 +2111,6 @@ class AdminThemesControllerCore extends AdminController
'blockcart',
'blockcurrencies',
'blocklanguages',
'qloblockcontact',
'blockmyaccount',
'blocknewsletter',
'blocksocial',

View File

@@ -628,7 +628,7 @@ class AuthControllerCore extends FrontController
$customer->active = 1;
// New Guest customer
if (Tools::isSubmit('is_new_customer')) {
if ($idCustomer) {
if (isset($idCustomer) && $idCustomer) {
// update guest customer details
$customer = new Customer($idCustomer);
$customer->firstname = Tools::getValue('firstname');

View File

@@ -221,10 +221,12 @@ class ContactControllerCore extends FrontController
$this->addJS(_PS_JS_DIR_.'validate.js');
// GOOGLE MAP
$language = $this->context->language;
$country = $this->context->country;
$PS_API_KEY = Configuration::get('PS_API_KEY');
$this->addJs("https://maps.googleapis.com/maps/api/js?key=$PS_API_KEY&libraries=places&language=$language->iso_code&region=$country->iso_code");
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
'&libraries=places&language='.$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}
/**
@@ -303,7 +305,7 @@ class ContactControllerCore extends FrontController
);
//By webkul to send hotels Map Informations for google Map.
if (Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
if (Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
$hotelLocationArray = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY'));
if ($hotelLocationArray) {
$this->context->smarty->assign('hotelLocationArray', json_encode($hotelLocationArray));

View File

@@ -205,7 +205,6 @@ class GuestTrackingControllerCore extends FrontController
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
$objRoomType = new HotelRoomType();
$nonRequestedRooms = 0;
$anyBackOrder = 0;
foreach ($order_list as &$order) {
@@ -570,7 +569,6 @@ class GuestTrackingControllerCore extends FrontController
//end
Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
}
}

View File

@@ -110,7 +110,6 @@ class OrderConfirmationControllerCore extends FrontController
/*By webkul to show order details properly on order history page*/
if (Module::isInstalled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
$non_requested_rooms = 0;
$any_back_order = 0;
$processed_product = array();
$orderTotalInfo = array();
@@ -186,12 +185,6 @@ class OrderConfirmationControllerCore extends FrontController
/*Product price when order was created*/
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
$cart_htl_data[$type_key]['name'] = $order_details_obj->product_name;
// $ord_refnd_info = $obj_ord_ref_info->getOderRefundInfoByIdOrderIdProductByDate($this->id_order, $type_value['product_id'], $data_v['date_from'], $data_v['date_to']);
// if ($ord_refnd_info) {
// $stage_name = $obj_refund_stages->getNameById($ord_refnd_info['refund_stage_id']);
// } else {
// $non_requested_rooms = 1;
// }
$stage_name = '';
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
@@ -403,7 +396,6 @@ class OrderConfirmationControllerCore extends FrontController
}
$this->context->smarty->assign('orderTotalInfo', $orderTotalInfo);
$this->context->smarty->assign('non_requested_rooms', $non_requested_rooms);
$this->context->smarty->assign('orders_has_invoice', $orders_has_invoice);
}
@@ -417,6 +409,7 @@ class OrderConfirmationControllerCore extends FrontController
'shw_bo_msg' => $shw_bo_msg,
'back_ord_msg' => $bo_msg,
'order' => $order,
'objOrderCurrency' => (new Currency($order->id_currency)),
'use_tax' => Configuration::get('PS_TAX'),
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
)

View File

@@ -214,6 +214,11 @@ class OrderDetailControllerCore extends FrontController
'additionalServices' => $additionalServices,
));
}
$this->context->smarty->assign(
array(
'objOrder' => new Order($idOrder)
)
);
$response['extra_demands'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl');
}
@@ -244,41 +249,70 @@ class OrderDetailControllerCore extends FrontController
}
$res = true;
if (!$hasError) {
if ((int)$order->total_paid_real == 0){
$hasCancelled = 0;
// 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 = 0;
$objOrderReturn->by_admin = 0;
$objOrderReturn->question = $refundReason;
$objOrderReturn->save();
if ($objOrderReturn->id) {
foreach ($bookingRefunds 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();
}
}
// Emails to customer, admin on refund request state change
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
} else {
$hasCancelled = 1;
// cancel the booking directly
foreach ($bookingRefunds as $idHtlBooking) {
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
$objHtlBooking->save();
if (!$objHtlBooking->processRefundInBookingTables()) {
die(json_encode(array('status' => 0)));
} else {
// set the message for the cancellation
$message = Tools::displayError('1 Room from').' '.', '.$objHtlBooking->room_type_name.' '.Tools::displayError('has been cancelled by the hotel.');
$message .= PHP_EOL.Tools::displayError('Reason').': '.$refundReason;
$objHtlBooking->setBookingCancellationMessage($refundReason);
}
}
// 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();
}
}
$objOrderReturn = new OrderReturn();
$objOrderReturn->id_customer = $order->id_customer;
$objOrderReturn->id_order = $order->id;
$objOrderReturn->state = 0;
$objOrderReturn->by_admin = 0;
$objOrderReturn->question = $refundReason;
$objOrderReturn->save();
if ($objOrderReturn->id) {
foreach ($bookingRefunds 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();
}
}
// Emails to customer, admin on refund request state change
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
die(json_encode(array('status' => 1)));
die(json_encode(array('status' => 1, 'has_cancelled' => $hasCancelled)));
}
die(json_encode(array('status' => 0)));
}
} else {
@@ -322,7 +356,6 @@ class OrderDetailControllerCore extends FrontController
$objRoomType = new HotelRoomType();
$objBookingDemand = new HotelBookingDemands();
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
$nonRequestedRooms = 1;
$anyBackOrder = 0;
$processedProducts = array();
$cartHotelData = array();
@@ -618,7 +651,6 @@ class OrderDetailControllerCore extends FrontController
'order_has_invoice' => $order->hasInvoice(),
'cart_htl_data' => $cartHotelData,
'cart_service_products' => $cartServiceProducts,
'non_requested_rooms' => $nonRequestedRooms,
)
);
// }
@@ -635,7 +667,7 @@ class OrderDetailControllerCore extends FrontController
'refund_allowed' => (int) $order->isReturnable(),
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
'refundReqBookings' => $refundReqBookings,
'hasCompletelyRefunded' => $order->hasCompletelyRefunded(),
'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG),
'refundedAmount' => $refundedAmount,
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
'order' => $order,
@@ -693,4 +725,4 @@ class OrderDetailControllerCore extends FrontController
$this->addCSS(_THEME_CSS_DIR_.'addresses.css');
}
}
}
}

View File

@@ -423,14 +423,11 @@ class OrderOpcControllerCore extends ParentOrderController
*/
public function initContent()
{
// check all service products are available
RoomTypeServiceProductCartDetail::validateServiceProductsInCart();
// validate room types before payment by customer
$orderRestrictErr = HotelCartBookingData::validateCartBookings();
parent::initContent();
// check ORDER RESTRICT condition before payment by the customer
$orderRestrictErr = HotelOrderRestrictDate::validateOrderRestrictDateOnPayment($this);
/* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
if (empty($this->context->cart->id_carrier)) {
$checked = $this->context->cart->simulateCarrierSelectedOutput();
@@ -553,7 +550,7 @@ class OrderOpcControllerCore extends ParentOrderController
}
Tools::safePostVars();
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
$newsletter = Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active && Configuration::get('PS_CUSTOMER_NWSL');
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));

View File

@@ -66,11 +66,27 @@ class ProductControllerCore extends FrontController
$this->addJqueryPlugin('jqzoom');
}
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))) {
$objHotelRoomType = new HotelRoomType();
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id);
if ($roomTypeInfo) {
$objHotelBranchInformation = new HotelBranchInformation($roomTypeInfo['id_hotel']);
if (floatval($objHotelBranchInformation->latitude) != 0
&& floatval($objHotelBranchInformation->longitude) != 0
) {
Media::addJsDef(array(
'hotel_location' => array(
'latitude' => $objHotelBranchInformation->latitude,
'longitude' => $objHotelBranchInformation->longitude,
)
));
$this->addJS(
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
$this->context->language->iso_code.'&region='.$this->context->country->iso_code
);
}
}
}
}
@@ -112,7 +128,7 @@ class ProductControllerCore extends FrontController
$this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
}
if (!$this->product->booking_product) {
if (!$this->product->booking_product || ($this->product->booking_product && !$this->product->show_at_front)) {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
}
@@ -375,13 +391,6 @@ class ProductControllerCore extends FrontController
}
}
Media::addJsDef(array(
'hotel_loc' => array(
'latitude' => $hotel_branch_obj->latitude,
'longitude' => $hotel_branch_obj->longitude,
)
));
$this->context->smarty->assign(
array(
'id_hotel' => $hotel_id,

View File

@@ -394,6 +394,18 @@ abstract class InstallControllerHttp
return $this->language->getInformation('services');
}
// Get link to QloApps tutorials for this language
public function getTutorialsLink()
{
return $this->language->getInformation('tutorials');
}
// Get link to QloApps must-have modules for this language
public function getInstallationGuideLink()
{
return $this->language->getInformation('installation_guide');
}
/**
* Get link to blog for this language
*

View File

@@ -3,8 +3,6 @@ SET NAMES 'utf8';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS';
UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '9' WHERE name = 'PS_HOTEL_IMAGES_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_AMENITIES_FILTER';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SHOW_PRICE_FILTER';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES';

View File

@@ -62,12 +62,6 @@
<configuration id="PS_HOTEL_IMAGES_PER_PAGE" name="PS_HOTEL_IMAGES_PER_PAGE">
<value>9</value>
</configuration>
<configuration id="SHOW_AMENITIES_FILTER" name="SHOW_AMENITIES_FILTER">
<value>1</value>
</configuration>
<configuration id="SHOW_PRICE_FILTER" name="SHOW_PRICE_FILTER">
<value>1</value>
</configuration>
<configuration id="PS_PURCHASE_MINIMUM" name="PS_PURCHASE_MINIMUM">
<value>0</value>
</configuration>

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Получено пълно плащане</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>পেমেন্ট গৃহীত </name>
<name>সম্পূর্ণ পেমেন্ট প্রাপ্ত</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Pagamento aceito</name>
<name>Pagamento completo recebido</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Platba byla přijata</name>
<name>Byla přijata úplná platba</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Zahlung eingegangen</name>
<name>Vollständige Zahlung erhalten</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -10,7 +10,7 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' =>

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Complete payment received</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Pago aceptado</name>
<name>Pago completo recibido</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>پرداخت تایید شده</name>
<name>پرداخت کامل دریافت شد</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Paiement accepté</name>
<name>Paiement complet reçu</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>התקבל תשלום</name>
<name>תשלום מלא התקבל</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Potpuna uplata primljena</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Teljes fizetés megérkezett</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Pembayaran diterima</name>
<name>Pembayaran lengkap diterima</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Pagamento accettato</name>
<name>Pagamento completo ricevuto</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Gautas pilnas mokėjimas</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Добиена е целосна исплата</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Betaling aanvaard</name>
<name>Volledige betaling ontvangen</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Payment accepted</name>
<name>Complete payment received</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Płatność zaakceptowana</name>
<name>Otrzymano pełną płatność</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id="Payment_accepted">
<name>Pagamento aceite</name>
<name>Pagamento completo recebido</name>
<template>payment_accepted</template>
</order_state>
<order_state id="Processing_in_progress">

View File

@@ -9,7 +9,9 @@ return array(
'tutorial' => 'https://www.youtube.com/watch?v=BWoifR8INCE',
'tailored_help' => 'https://webkul.uvdesk.com/',
'contact' => 'https://qloapps.com/contact/',
'services' => 'https://qloapps.com/services/?support',
'services' => 'https://qloapps.com/contact/',
'tutorials' => 'https://qloapps.com/qlo-reservation-system/',
'installation_guide' => 'https://qloapps.com/qloapps-installation-process/',
'install_help' => 'https://qloapps.com/install-qloapps/',
),
'translations' => array(

View File

@@ -5,7 +5,7 @@
<template>awaiting_payment</template>
</order_state>
<order_state id='Payment_accepted'>
<name>Paiement accepté</name>
<name>Paiement complet reçu</name>
<template>payment_accepted</template>
</order_state>
<order_state id='Processing_in_progress'>

Some files were not shown because too many files have changed in this diff Show More