diff --git a/.gitignore b/.gitignore index ae0a05c8f..9ce95681a 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ composer.lock img/** !/img/404.gif +!/img/.htaccess !/img/admin/ !/img/admin/*.gif !/img/admin/*.png diff --git a/admin/ajax_products_list.php b/admin/ajax_products_list.php index 98f9647cb..2971bdd42 100644 --- a/admin/ajax_products_list.php +++ b/admin/ajax_products_list.php @@ -60,22 +60,39 @@ $exclude_packs = (bool)Tools::getValue('exclude_packs', true); $bookingProduct = (int) Tools::getValue('booking_product'); +$idHotel = (int) Tools::getValue('id_hotel'); + $context = Context::getContext(); -$sql = 'SELECT p.`id_product`, pl.`link_rewrite`, p.`reference`, pl.`name`, image_shop.`id_image` id_image, il.`legend`, p.`cache_default_attribute` - FROM `'._DB_PREFIX_.'product` p - '.Shop::addSqlAssociation('product', 'p').' - LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product = p.id_product AND pl.id_lang = '.(int)$context->language->id.Shop::addSqlRestrictionOnLang('pl').') +$sqlSelect = 'SELECT p.`id_product`, pl.`link_rewrite`, p.`reference`, pl.`name`, image_shop.`id_image` id_image, il.`legend`, p.`cache_default_attribute`'; + +$sqlFrom = ' FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p'); + +$sqlJoin =' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int) $context->language->id.Shop::addSqlRestrictionOnLang('pl').') LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop - ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop='.(int)$context->shop->id.') - LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$context->language->id.') - WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\')'. + ON (image_shop.`id_product` = p.`id_product` AND image_shop.`cover`=1 AND image_shop.`id_shop`='.(int) $context->shop->id.') + LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = '.(int) $context->language->id.')'; + +$sqlWhere = ' WHERE (pl.name LIKE \'%'.pSQL($query).'%\' OR p.reference LIKE \'%'.pSQL($query).'%\')'. (!empty($excludeIds) ? ' AND p.id_product NOT IN ('.$excludeIds.') ' : ' '). (!empty($excludePackItself) ? ' AND p.id_product <> '.$excludePackItself.' ' : ' '). ($excludeVirtuals ? 'AND NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'product_download` pd WHERE (pd.id_product = p.id_product))' : ''). ($exclude_packs ? 'AND (p.cache_is_pack IS NULL OR p.cache_is_pack = 0)' : ''). - ($bookingProduct ? 'AND p.`booking_product` = '.(int) $bookingProduct : ''). - ' GROUP BY p.id_product'; + ($bookingProduct ? 'AND p.`booking_product` = '.(int) $bookingProduct : ''); + +$sqlGroupBy = ' GROUP BY p.id_product'; + +if ($idHotel && $bookingProduct) { + // To get hotel info for the booking product only + $sqlSelect .= ', hbil.`hotel_name`, hbil.`id` AS id_hotel '; + $sqlJoin .= ' LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt + ON hrt.`id_product` = p.`id_product` + LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil + ON pl.`id_lang` = hbil.`id_lang` AND hbil.`id` = hrt.`id_hotel`'; + $sqlWhere .= ' AND hbil.`id`='.(int) $idHotel ; +} + +$sql = $sqlSelect.' '.$sqlFrom.' '.$sqlJoin.' '.$sqlWhere.' '.$sqlGroupBy; $items = Db::getInstance()->executeS($sql); diff --git a/admin/backups/.htaccess b/admin/backups/.htaccess index 93169e4eb..3de9e4008 100644 --- a/admin/backups/.htaccess +++ b/admin/backups/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/admin/export/.htaccess b/admin/export/.htaccess index 93169e4eb..3de9e4008 100644 --- a/admin/export/.htaccess +++ b/admin/export/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/admin/import/.htaccess b/admin/import/.htaccess index 93169e4eb..3de9e4008 100644 --- a/admin/import/.htaccess +++ b/admin/import/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/admin/tabs/.htaccess b/admin/tabs/.htaccess index 93169e4eb..3de9e4008 100644 --- a/admin/tabs/.htaccess +++ b/admin/tabs/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/admin/themes/default/sass/admin-theme_rtl.sass b/admin/themes/default/sass/admin-theme_rtl.sass index 90d7eec1b..712d08aa9 100644 --- a/admin/themes/default/sass/admin-theme_rtl.sass +++ b/admin/themes/default/sass/admin-theme_rtl.sass @@ -84,14 +84,20 @@ @import "partials/date-range-picker" @import "partials/multistore" @import "partials/product" + @import "partials/skeleton-loading" + //Controllers @import "controllers/carrier-wizard" @import "controllers/dashboard" @import "controllers/login" + @import "controllers/modules_catalog" @import "controllers/modules" @import "controllers/search" @import "controllers/translations" @import "controllers/customer-thread" + @import "controllers/themes" + @import "controllers/order" + @import "controllers/products" @import "vendor/bootstrap-rtl-sass/bootstrap-rtl" //Plug-ins @@ -99,6 +105,9 @@ @import "partials/growl" @import "partials/chosen" @import "partials/ladda" +@import "partials/date-picker" +@import "partials/select2" +@import "partials/ndv3" //RTL @import "partials/rtl" @@ -106,3 +115,5 @@ //Backward compatibility @import "partials/backward" +//Print support +@import "partials/print" diff --git a/admin/themes/default/sass/controllers/_modules_catalog.sass b/admin/themes/default/sass/controllers/_modules_catalog.sass index 67c7b45f4..74a40fc8f 100644 --- a/admin/themes/default/sass/controllers/_modules_catalog.sass +++ b/admin/themes/default/sass/controllers/_modules_catalog.sass @@ -53,10 +53,12 @@ .module-info-wrapper position: relative height: 100% - .module-logo img - max-height: 60px + .module-logo + display: flex + gap: 10px margin-bottom: 20px - margin-right: 10px + img + max-height: 60px .panel-action .module-price font-size: 14px diff --git a/admin/themes/default/sass/controllers/_order.sass b/admin/themes/default/sass/controllers/_order.sass index c5315218e..d061c8615 100644 --- a/admin/themes/default/sass/controllers/_order.sass +++ b/admin/themes/default/sass/controllers/_order.sass @@ -77,3 +77,9 @@ .room_status_info_form .room_status white-space: normal + +#noteContent + max-height: 200px + +.panel-refund-request .refunded_amount + margin-top: 2px \ No newline at end of file diff --git a/admin/themes/default/sass/partials/_kpi.sass b/admin/themes/default/sass/partials/_kpi.sass index 78df786ff..e6ccfe8cb 100644 --- a/admin/themes/default/sass/partials/_kpi.sass +++ b/admin/themes/default/sass/partials/_kpi.sass @@ -3,6 +3,7 @@ $kpi-gap: 10px .kpi-container display: flex + gap: 15px justify-content: space-between padding: 12px !important .kpis-wrap @@ -23,7 +24,6 @@ $kpi-gap: 10px padding-right: $kpi-gap / 2 .actions-wrap width: 16px - margin-left: 16px button padding: 0 border: none @@ -97,11 +97,21 @@ $kpi-gap: 10px border: 1px solid #e7edfa border-left-width: 3px border-radius: 6px - padding: 4px 8px 8px 42px + padding: 4px 8px 8px 4px display: flex - flex-direction: column - justify-content: space-between + gap: 10px white-space: normal + i.kpi-icon + font-size: 15px + text-align: center + color: white + line-height: 26px + background: #eee + width: 28px + height: 28px + @include border-radius(6px) + .kpi-data + flex-grow: 1 .title-subtitle display: flex justify-content: space-between @@ -109,22 +119,7 @@ $kpi-gap: 10px display: block color: #666 font-size: 13px - i - position: absolute - top: 5px - font-size: 15px - text-align: center - color: white - line-height: 26px - background: #eee - width: 28px - height: 28px - @include left(5px) - @include border-radius(6px) - &::before - position: absolute - top: 1px - left: 8px + .subtitle display: block text-transform: capitalize @@ -144,12 +139,8 @@ $kpi-gap: 10px &.loading height: 22px min-width: 40px - .arrow - position: absolute - bottom: 7px - right: 9px - i - color: #828282 !important + .arrow i + color: #828282 !important &:hover text-decoration: none .color1 diff --git a/admin/themes/default/sass/partials/_rtl.sass b/admin/themes/default/sass/partials/_rtl.sass index c3b7b569f..7fd16f206 100644 --- a/admin/themes/default/sass/partials/_rtl.sass +++ b/admin/themes/default/sass/partials/_rtl.sass @@ -119,3 +119,8 @@ html margin-left: 0px @include border-right(1px solid $sidebar-menu-bg-hover-color) border-left: 0px +#nav-topbar + #ellipsistab + ul#ellipsis_submenu + left: 0 + right: unset diff --git a/admin/themes/default/sass/partials/_tree.sass b/admin/themes/default/sass/partials/_tree.sass index b6cb0ecdf..897c29f85 100644 --- a/admin/themes/default/sass/partials/_tree.sass +++ b/admin/themes/default/sass/partials/_tree.sass @@ -62,4 +62,8 @@ .tree-panel-label-title font-weight: 400 margin: 0 - @include padding(0, 0, 0, 8px) \ No newline at end of file + @include padding(0, 0, 0, 8px) + +.tree.cattree + max-height: 350px + overflow-y: auto diff --git a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_button-groups-rtl.sass b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_button-groups-rtl.sass index 052bd3634..52404f5f6 100644 --- a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_button-groups-rtl.sass +++ b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_button-groups-rtl.sass @@ -2,14 +2,8 @@ // Button groups // -------------------------------------------------- -// Make the div behave like a button -.btn-group, -.btn-group-vertical - > .btn - float: right - // Prevent double borders when buttons are next to each other -.btn-group +.btn-group .btn + .btn, .btn + .btn-group, .btn-group + .btn, diff --git a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_grid-rtl.sass b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_grid-rtl.sass index 4563bca33..c8e9fb9fd 100644 --- a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_grid-rtl.sass +++ b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_grid-rtl.sass @@ -187,28 +187,42 @@ .col-sm-push-11 right: percentage((11/ $grid-columns)) + .col-sm-pull-0 + left: auto + right: auto .col-sm-pull-1 left: percentage((1 / $grid-columns)) + right: auto .col-sm-pull-2 left: percentage((2 / $grid-columns)) + right: auto .col-sm-pull-3 left: percentage((3 / $grid-columns)) + right: auto .col-sm-pull-4 left: percentage((4 / $grid-columns)) + right: auto .col-sm-pull-5 left: percentage((5 / $grid-columns)) + right: auto .col-sm-pull-6 left: percentage((6 / $grid-columns)) + right: auto .col-sm-pull-7 left: percentage((7 / $grid-columns)) + right: auto .col-sm-pull-8 left: percentage((8 / $grid-columns)) + right: auto .col-sm-pull-9 left: percentage((9 / $grid-columns)) + right: auto .col-sm-pull-10 left: percentage((10/ $grid-columns)) + right: auto .col-sm-pull-11 left: percentage((11/ $grid-columns)) + right: auto // Offsets .col-sm-offset-1 @@ -269,23 +283,23 @@ .col-md-10, .col-md-11 float: right - .col-md-1 + .col-md-1 width: percentage((1 / $grid-columns)) - .col-md-2 + .col-md-2 width: percentage((2 / $grid-columns)) - .col-md-3 + .col-md-3 width: percentage((3 / $grid-columns)) - .col-md-4 + .col-md-4 width: percentage((4 / $grid-columns)) - .col-md-5 + .col-md-5 width: percentage((5 / $grid-columns)) - .col-md-6 + .col-md-6 width: percentage((6 / $grid-columns)) - .col-md-7 + .col-md-7 width: percentage((7 / $grid-columns)) - .col-md-8 + .col-md-8 width: percentage((8 / $grid-columns)) - .col-md-9 + .col-md-9 width: percentage((9 / $grid-columns)) .col-md-10 width: percentage((10/ $grid-columns)) @@ -318,28 +332,42 @@ .col-md-push-11 right: percentage((11/ $grid-columns)) + .col-md-pull-0 + left: auto + right: auto .col-md-pull-1 left: percentage((1 / $grid-columns)) + right: auto .col-md-pull-2 left: percentage((2 / $grid-columns)) + right: auto .col-md-pull-3 left: percentage((3 / $grid-columns)) + right: auto .col-md-pull-4 left: percentage((4 / $grid-columns)) + right: auto .col-md-pull-5 left: percentage((5 / $grid-columns)) + right: auto .col-md-pull-6 left: percentage((6 / $grid-columns)) + right: auto .col-md-pull-7 left: percentage((7 / $grid-columns)) + right: auto .col-md-pull-8 left: percentage((8 / $grid-columns)) + right: auto .col-md-pull-9 left: percentage((9 / $grid-columns)) + right: auto .col-md-pull-10 left: percentage((10/ $grid-columns)) + right: auto .col-md-pull-11 left: percentage((11/ $grid-columns)) + right: auto // Offsets .col-md-offset-1 @@ -402,77 +430,92 @@ .col-lg-11 float: right - .col-lg-1 + .col-lg-1 width: percentage((1 / $grid-columns)) - .col-lg-2 + .col-lg-2 width: percentage((2 / $grid-columns)) - .col-lg-3 + .col-lg-3 width: percentage((3 / $grid-columns)) - .col-lg-4 + .col-lg-4 width: percentage((4 / $grid-columns)) - .col-lg-5 + .col-lg-5 width: percentage((5 / $grid-columns)) - .col-lg-6 + .col-lg-6 width: percentage((6 / $grid-columns)) - .col-lg-7 + .col-lg-7 width: percentage((7 / $grid-columns)) - .col-lg-8 + .col-lg-8 width: percentage((8 / $grid-columns)) - .col-lg-9 + .col-lg-9 width: percentage((9 / $grid-columns)) - .col-lg-10 + .col-lg-10 width: percentage((10/ $grid-columns)) - .col-lg-11 + .col-lg-11 width: percentage((11/ $grid-columns)) - .col-lg-12 + .col-lg-12 width: 100% // Push and pull columns for source order changes - .col-lg-push-1 + .col-lg-push-1 right: percentage((1 / $grid-columns)) - .col-lg-push-2 + .col-lg-push-2 right: percentage((2 / $grid-columns)) - .col-lg-push-3 + .col-lg-push-3 right: percentage((3 / $grid-columns)) - .col-lg-push-4 + .col-lg-push-4 right: percentage((4 / $grid-columns)) - .col-lg-push-5 + .col-lg-push-5 right: percentage((5 / $grid-columns)) - .col-lg-push-6 + .col-lg-push-6 right: percentage((6 / $grid-columns)) - .col-lg-push-7 + .col-lg-push-7 right: percentage((7 / $grid-columns)) - .col-lg-push-8 + .col-lg-push-8 right: percentage((8 / $grid-columns)) - .col-lg-push-9 + .col-lg-push-9 right: percentage((9 / $grid-columns)) .col-lg-push-10 right: percentage((10/ $grid-columns)) .col-lg-push-11 right: percentage((11/ $grid-columns)) - .col-lg-pull-1 + .col-lg-pull-0 + left: auto + right: auto + .col-lg-pull-1 left: percentage((1 / $grid-columns)) - .col-lg-pull-2 + right: auto + .col-lg-pull-2 left: percentage((2 / $grid-columns)) - .col-lg-pull-3 + right: auto + .col-lg-pull-3 left: percentage((3 / $grid-columns)) - .col-lg-pull-4 + right: auto + .col-lg-pull-4 left: percentage((4 / $grid-columns)) - .col-lg-pull-5 + right: auto + .col-lg-pull-5 left: percentage((5 / $grid-columns)) - .col-lg-pull-6 + right: auto + .col-lg-pull-6 left: percentage((6 / $grid-columns)) - .col-lg-pull-7 + right: auto + .col-lg-pull-7 left: percentage((7 / $grid-columns)) - .col-lg-pull-8 + right: auto + right: unset + .col-lg-pull-8 left: percentage((8 / $grid-columns)) - .col-lg-pull-9 + right: auto + .col-lg-pull-9 left: percentage((9 / $grid-columns)) + right: auto .col-lg-pull-10 left: percentage((10/ $grid-columns)) + right: auto .col-lg-pull-11 left: percentage((11/ $grid-columns)) + right: auto // Offsets .col-lg-offset-1 diff --git a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_merged-rtl.sass b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_merged-rtl.sass index 835e73b6f..a302d5d30 100644 --- a/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_merged-rtl.sass +++ b/admin/themes/default/sass/vendor/bootstrap-rtl-sass/_merged-rtl.sass @@ -118,7 +118,7 @@ h1, h2, h3, h4, h5, h6, border-radius: $border-radius-base $border-radius-base 0 0 // pulling this in mainly for less shorthand - &.nav-justified + &.nav-justified @extend .nav-justified @extend .nav-tabs-justified @@ -169,9 +169,9 @@ h1, h2, h3, h4, h5, h6, // The dropdown menu (ul) .dropdown-menu - right: 0 - float: left - left: auto + right: unset + float: right + left: 0 // Aligns the dropdown menu to left &.pull-left @@ -185,6 +185,11 @@ h1, h2, h3, h4, h5, h6, float: right right: auto +.pull-right > .dropdown-menu + right: unset + float: right + left: 0 + // Right aligned menus need alt position .navbar-nav.pull-left > li > .dropdown-menu, .navbar-nav > li > .dropdown-menu.pull-left @@ -338,13 +343,13 @@ h1, h2, h3, h4, h5, h6, // Popovers // ------------------------- -.popover.top, +.popover.top, .popover.bottom direction:ltr -.popover.top .popover-title, +.popover.top .popover-title, .popover.top .popover-content, -.popover.bottom .popover-title, +.popover.bottom .popover-title, .popover.bottom .popover-content direction: rtl text-align: right diff --git a/admin/themes/default/sass/vendor/bootstrap-sass/_modals.scss b/admin/themes/default/sass/vendor/bootstrap-sass/_modals.scss index 8240fa4ad..a126c3986 100644 --- a/admin/themes/default/sass/vendor/bootstrap-sass/_modals.scss +++ b/admin/themes/default/sass/vendor/bootstrap-sass/_modals.scss @@ -9,7 +9,7 @@ // Kill the scroll on the body .modal-open { - overflow-x: hidden; + overflow: hidden; } // Container that the modal scrolls within diff --git a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl index ec102910d..9fd0f69e6 100644 --- a/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl +++ b/admin/themes/default/template/controllers/addresses/helpers/form/form.tpl @@ -29,31 +29,29 @@ {if $input.name == 'vat_number'}
{/if} - - {if $input.type == 'text_customer' && !isset($customer)} - - {else} - {$smarty.block.parent} - {/if} + {$smarty.block.parent} {/block} -{block name="field"} +{block name="input"} {if $input.type == 'text_customer'} {if isset($customer)} -
- - {$customer->lastname} {$customer->firstname} ({$customer->email}) - -
+ + {$customer->lastname} {$customer->firstname} ({$customer->email}) + - {else} - - -
- - -
- {/if} + function resetCustomerRelatedAddressFields() { + $('input[name=firstname]').val(''); + $('input[name=lastname]').val(''); + $('input[name=company]').val(''); + $('input[name=id_customer]').val(''); + } + {else} {$smarty.block.parent} {/if} diff --git a/admin/themes/default/template/controllers/cart_rules/actions.tpl b/admin/themes/default/template/controllers/cart_rules/actions.tpl index efe1a4d24..d7da999e3 100644 --- a/admin/themes/default/template/controllers/cart_rules/actions.tpl +++ b/admin/themes/default/template/controllers/cart_rules/actions.tpl @@ -46,7 +46,6 @@ %
- {l s='Does not apply to the shipping costs'} diff --git a/admin/themes/default/template/controllers/cart_rules/conditions.tpl b/admin/themes/default/template/controllers/cart_rules/conditions.tpl index bfdea3f15..8f225fbbf 100644 --- a/admin/themes/default/template/controllers/cart_rules/conditions.tpl +++ b/admin/themes/default/template/controllers/cart_rules/conditions.tpl @@ -47,7 +47,7 @@
@@ -125,7 +125,6 @@ {l s='Country selection'}

- {l s='This restriction applies to the country of delivery.'}

diff --git a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl index e802993eb..630836734 100644 --- a/admin/themes/default/template/controllers/carts/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/carts/helpers/view/view.tpl @@ -35,15 +35,9 @@

{l s='Customer information'}

{if $customer->id} {$customer->email} -

- {if $customer->id_gender == 1} - - {elseif $customer->id_gender == 2} - - {else} - - {/if} - {$customer->firstname} {$customer->lastname}

+

+ {l s='Customer Name'}: + {$customer->firstname} {$customer->lastname}

diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 88da2734e..18145ce07 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -146,15 +146,27 @@

- {if $customer->active} - - - {l s='Active'} + {if !$customer->deleted} + {if $customer->active} + + + {l s='Active'} + + {else} + + + {l s='Inactive'} + + {/if} + {elseif $customer->deleted == Customer::STATUS_BANNED} + + + {l s='Banned'} - {else} + {elseif $customer->deleted == Customer::STATUS_DELETED} - {l s='Inactive'} + {l s='Deleted'} {/if}

diff --git a/admin/themes/default/template/controllers/login/content.tpl b/admin/themes/default/template/controllers/login/content.tpl index f28b4a838..e29607c74 100644 --- a/admin/themes/default/template/controllers/login/content.tpl +++ b/admin/themes/default/template/controllers/login/content.tpl @@ -67,6 +67,7 @@
+ {hook h="displayAdminLoginFormFieldsAfter"}
- - - - - - - {*{if ($order->hasBeenPaid())}{/if} - {if $display_warehouse}{/if} - {if ($order->hasBeenDelivered())}{/if} - *} - - - - - - diff --git a/admin/themes/default/template/controllers/orders/_overbookings.tpl b/admin/themes/default/template/controllers/orders/_overbookings.tpl index b2b89fa6c..8f0064708 100644 --- a/admin/themes/default/template/controllers/orders/_overbookings.tpl +++ b/admin/themes/default/template/controllers/orders/_overbookings.tpl @@ -43,15 +43,19 @@ - {if (isset($refundReqBookings) && $refundReqBookings) || (isset($isCancelledRoom) && $isCancelledRoom)} + {if (isset($refundReqBookings) && $refundReqBookings)} {/if} diff --git a/admin/themes/default/template/controllers/orders/_rooms_informaion_table.tpl b/admin/themes/default/template/controllers/orders/_rooms_informaion_table.tpl index cd9914afa..8fa049382 100644 --- a/admin/themes/default/template/controllers/orders/_rooms_informaion_table.tpl +++ b/admin/themes/default/template/controllers/orders/_rooms_informaion_table.tpl @@ -33,7 +33,7 @@ - {if (isset($refundReqBookings) && $refundReqBookings) || (isset($isCancelledRoom) && $isCancelledRoom)} + {if (isset($refundReqBookings) && $refundReqBookings)} {/if} diff --git a/admin/themes/default/template/controllers/orders/form.tpl b/admin/themes/default/template/controllers/orders/form.tpl index 933d0a6cc..3cd980765 100644 --- a/admin/themes/default/template/controllers/orders/form.tpl +++ b/admin/themes/default/template/controllers/orders/form.tpl @@ -139,6 +139,7 @@ $('body').on('click', '.delete_hotel_cart_data', function(){ if (confirm("{l s='Are you sure?'}")) { + var idCart = $(this).data('id_cart'); $.ajax({ type:"POST", url: "{$link->getAdminLink('AdminOrders')|addslashes}", @@ -147,7 +148,7 @@ action: "deleteRoomProcess", del_id: $(this).data('id'), id_product: $(this).data('id_product'), - id_cart: $(this).data('id_cart'), + id_cart: idCart, id_room: $(this).data('id_room'), date_from: $(this).data('date_from'), date_to: $(this).data('date_to'), @@ -159,7 +160,7 @@ { showSuccessMessage("{l s='Remove successful'}"); if (data.cart_rooms) - location.reload(); + window.location.href = "{$link->getAdminLink('AdminOrders',true)}" + '&addorder&cart_id=' + idCart; else window.location.href = "{$link->getAdminLink('AdminHotelRoomsBooking',true)}"; } @@ -1170,7 +1171,7 @@ currency_format = jsonSummary.currency.format; currency_sign = jsonSummary.currency.sign; currency_blank = jsonSummary.currency.blank; - priceDisplayPrecision = jsonSummary.currency.decimals ? 2 : 0; + priceDisplayPrecision = parseInt(jsonSummary.currency.decimals) ? {$smarty.const._PS_PRICE_DISPLAY_PRECISION_|intval} : 0; updateCartProducts(jsonSummary.summary.products, jsonSummary.summary.gift_products, jsonSummary.cart.id_address_delivery); updateCartVouchers(jsonSummary.summary.discounts); @@ -1731,539 +1732,540 @@
{block name="leadin"}{/block}
{include file='controllers/orders/_current_cart_details_data.tpl'} -
-
- - {l s='Customer'} -
-
- -
-
-
-
- - - - -
-
- -
-
-
-
-
-
- {*
- + {* If cart has errors the do not allow to proceed with this cart *} +
+
+ + {l s='Customer'} +
+
+ +
+
+
+
+ + + + +
+
+ +
+
+
+
+
+
+ {*
{if $order->with_occupancy && $data['children']} - {if $data.is_cancelled} - {l s='Cancelled'} - {elseif isset($data.refund_info) && $data.refund_info} - {$data.refund_info.name|escape:'html':'UTF-8'} + {if $data.id|in_array:$refundReqBookings} + {if $data.is_cancelled} + {l s='Cancelled'} + {elseif isset($data.refund_info) && (!$data.refund_info.refunded || $data.refund_info.id_customization)} + {$data.refund_info.name|escape:'html':'UTF-8'} + {else} + -- + {/if} {else} - -- - {/if} + -- + {/if} - {if isset($data.refund_info) && $data.refund_info} + {if $data.is_refunded && isset($data.refund_info) && $data.refund_info} {convertPriceWithCurrency price=$data.refund_info.refunded_amount currency=$currency->id} {else} -- @@ -227,27 +235,34 @@
- - - + {if isset($refundReqBookings) && $refundReqBookings && $data.id|in_array:$refundReqBookings && $data.is_cancelled} + + {else} + + + + {/if}
{l s='Extra Services/Fee (Tax excl.)'} {l s='Total Tax'} {l s='Total Price (Tax incl.)'}{l s='Refund/Cancel Status'} {l s='Refunded amount'}
- - - - - - - - - - -
{l s='ID'}{l s='Date'}{l s='Total'}
-
-
- - - - - - - - - - - - - - -
{l s='ID'}{l s='Date'}{l s='Products'}{l s='Total paid'}{l s='Payment'}{l s='Status'}
-
-
- -->*} - + +
+
+ + + + + + + + + + + +
{l s='ID'}{l s='Date'}{l s='Total'}
+
+
+ + + + + + + + + + + + + + +
{l s='ID'}{l s='Date'}{l s='Products'}{l s='Total paid'}{l s='Payment'}{l s='Status'}
+
+
+ -->*} + - + {strip} {addJsDef max_child_age=$max_child_age} {addJsDef max_child_in_room=$max_child_in_room} diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index f28080e92..fa85718d8 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -28,9 +28,9 @@ {block name=pageTitle}

{if is_array($title)}{$title|end|strip_tags}{else}{$title|strip_tags}{/if} - {if $currentState == Configuration::get('PS_OS_REFUND')} + {if $currentState->id == Configuration::get('PS_OS_REFUND')} {l s='Refunded'} - {elseif $currentState == Configuration::get('PS_OS_CANCELED')} + {elseif $currentState->id == Configuration::get('PS_OS_CANCELED')} {l s='Cancelled'} {else} {l s='Booked'} @@ -41,6 +41,7 @@ {block name="override_tpl"} {/if} + {block name="updatelist"} {if $new_list_header_design}
@@ -291,28 +295,30 @@
{if $params.type == 'range'} + {$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"}
- - + +
{elseif $params.type == 'bool'} - - - + + {elseif $params.type == 'date' || $params.type == 'datetime'}
- +
- + @@ -366,28 +372,30 @@
{elseif $params.type == 'select'} + {$field_name="`$list_id`Filter_`$params.filter_key`"} {if isset($params.multiple) && $params.multiple} - {if isset($params.list) && is_array($params.list)} {foreach $params.list AS $option_value => $option_display} - + {/foreach} {/if} {else} {if isset($params.filter_key)} - {if isset($params.list) && is_array($params.list)} {foreach $params.list AS $option_value => $option_display} - + {/foreach} {/if} {/if} {/if} {else} - + {$field_name="`$list_id`Filter_{if isset($params.filter_key)}`$params.filter_key`{else}`$key`{/if}"} + {/if}
@@ -553,10 +561,11 @@ diff --git a/admin/themes/default/template/helpers/options/options.tpl b/admin/themes/default/template/helpers/options/options.tpl index 24a6094cd..527850f73 100644 --- a/admin/themes/default/template/helpers/options/options.tpl +++ b/admin/themes/default/template/helpers/options/options.tpl @@ -138,6 +138,9 @@ {elseif isset($input.empty_message)} {$input.empty_message} + {else} + {/if}
{elseif $field['type'] == 'bool'} diff --git a/admin/themes/default/template/search_form.tpl b/admin/themes/default/template/search_form.tpl index ac11075f7..b7c2e195a 100644 --- a/admin/themes/default/template/search_form.tpl +++ b/admin/themes/default/template/search_form.tpl @@ -64,7 +64,7 @@
  • - {l s='Invoices'} + {l s='Invoices'}
  • diff --git a/classes/.htaccess b/classes/.htaccess index 93169e4eb..3de9e4008 100644 --- a/classes/.htaccess +++ b/classes/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/classes/Address.php b/classes/Address.php index 9d1b583dd..48a30bd26 100644 --- a/classes/Address.php +++ b/classes/Address.php @@ -483,6 +483,14 @@ class AddressCore extends ObjectModel return array(); } + public function cacheFieldsRequiredDatabase($all = false) + { + parent::cacheFieldsRequiredDatabase($all); + if ($this->id_hotel) { + self::$fieldsRequiredDatabase['Address'] = array(); + } + } + public function searchByName($query, $idLang = false) { if (!$idLang) { @@ -509,5 +517,4 @@ class AddressCore extends ObjectModel ) '); } - } diff --git a/classes/BoOrder.php b/classes/BoOrder.php new file mode 100644 index 000000000..b6046c5c8 --- /dev/null +++ b/classes/BoOrder.php @@ -0,0 +1,31 @@ + +* @copyright 2010-2022 Webkul IN +* @license https://store.webkul.com/license.html +*/ + +class BoOrder extends PaymentModule +{ + public $active = 1; + public $name = 'bo_order'; + + public function __construct() + { + $this->displayName = $this->l('Back office order'); + $this->validateOrderAmount = false; + } +} \ No newline at end of file diff --git a/classes/Cart.php b/classes/Cart.php index 921afd2cf..8401a36b9 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -374,7 +374,7 @@ class CartCore extends ObjectModel if ($cart_vat_amount == 0 || $cart_amount_te == 0) { return 0; } else { - return Tools::ps_round($cart_vat_amount / $cart_amount_te, 3); + return Tools::ps_round($cart_vat_amount / $cart_amount_te, 6); } } @@ -2380,7 +2380,6 @@ class CartCore extends ObjectModel $array = array(); foreach($selectedServiceProducts as $selectedProduct) { if (isset($array[$selectedProduct['id_hotel']])) { - $array[$selectedProduct['id_hotel']]['quantity'] += $selectedProduct['quantity']; $array[$selectedProduct['id_hotel']]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl']; $array[$selectedProduct['id_hotel']]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl']; } else { @@ -2407,7 +2406,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'])) { diff --git a/classes/CartCustomerGuestDetail.php b/classes/CartCustomerGuestDetail.php index d21c56c68..0ab1592be 100644 --- a/classes/CartCustomerGuestDetail.php +++ b/classes/CartCustomerGuestDetail.php @@ -78,6 +78,31 @@ class CartCustomerGuestDetailCore extends ObjectModel if (!trim($this->phone) || !Validate::isPhoneNumber($this->phone)) { $isValid = false; } + + $className = 'CartCustomerGuestDetail'; + $rules = call_user_func(array($className, 'getValidationRules'), $className); + + if (isset($rules['size']['firstname'])) { + if (Tools::strlen(trim($this->firstname)) > $rules['size']['firstname']) { + $isValid = false; + } + } + if (isset($rules['size']['lastname'])) { + if (Tools::strlen(trim($this->lastname)) > $rules['size']['lastname']) { + $isValid = false; + } + } + if (isset($rules['size']['email'])) { + if (Tools::strlen(trim($this->email)) > $rules['size']['email']) { + $isValid = false; + } + } + if (isset($rules['size']['phone'])) { + if (Tools::strlen(trim($this->phone)) > $rules['size']['phone']) { + $isValid = false; + } + } + return $isValid; } } \ No newline at end of file diff --git a/classes/CartRule.php b/classes/CartRule.php index f48ffb3b1..634434e53 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -294,6 +294,13 @@ class CartRuleCore extends ObjectModel return array(); } + // Remove cart rule that does not match the id_customer + foreach ($result as $key => $cart_rule) { + if ($cart_rule['id_customer'] && $cart_rule['id_customer'] != $id_customer) { + unset($result[$key]); + } + } + // Remove cart rule that does not match the customer groups $customerGroups = Customer::getGroupsStatic($id_customer); @@ -1154,6 +1161,18 @@ class CartRuleCore extends ObjectModel $previous_reduction_amount = $prorata * $previous_reduction_amount * (1 + $cart_average_vat_rate); } + // First we convert the voucher value to the default currency + $previousCartRuleCurrency = new Currency($this->reduction_currency); + + if ($previous_reduction_amount == 0 || $previousCartRuleCurrency->conversion_rate == 0) { + $previous_reduction_amount = 0; + } else { + $previous_reduction_amount /= $previousCartRuleCurrency->conversion_rate; + } + + // Then we convert the voucher value in the default currency into the cart currency + $previous_reduction_amount *= $context->currency->conversion_rate; + $previous_reduction_amount = Tools::ps_round($previous_reduction_amount, _PS_PRICE_COMPUTE_PRECISION_); $current_cart_amount = max($current_cart_amount - (float)$previous_reduction_amount, 0); } diff --git a/classes/Cookie.php b/classes/Cookie.php index 0edb66672..90dbc9509 100644 --- a/classes/Cookie.php +++ b/classes/Cookie.php @@ -89,8 +89,9 @@ class CookieCore $this->_path = '/'.$this->_path; } $this->_path = rawurlencode($this->_path); - $this->_path = str_replace('%2F', '/', $this->_path); - $this->_path = str_replace('%7E', '~', $this->_path); + $search = array('%2F', '%7E', '%28', '%29', '%2B', '%26'); + $replace = array('/', '~', '(', ')', '+', '&'); + $this->_path = str_replace($search, $replace, $this->_path); $this->_domain = $this->getDomain($shared_urls); $this->_sameSite = Configuration::get('PS_COOKIE_SAMESITE'); $this->_name = 'QloApps-'.md5(($this->_standalone ? '' : _PS_VERSION_).$name.$this->_domain); diff --git a/classes/Customer.php b/classes/Customer.php index a8c4c3609..7367dcf24 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -135,6 +135,9 @@ class CustomerCore extends ObjectModel public $groupBox; + const STATUS_BANNED = 1; + const STATUS_DELETED = 2; + protected $webserviceParameters = array( 'fields' => array( 'id_default_group' => array('xlink_resource' => 'groups'), @@ -179,7 +182,7 @@ class CustomerCore extends ObjectModel 'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), - 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), + 'deleted' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false), 'note' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false), 'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), @@ -294,21 +297,37 @@ class CustomerCore extends ObjectModel } /** - * Return customers list + * Returns a list of customers. * - * @param null|bool $only_active Returns only active customers when true - * @return array Customers + * @param null|bool $active Optional. Filter customers by their active status. If null, no filter is applied. + * @param null|bool $deleted Optional. Filter customers by their deleted status. If null, no filter is applied. + * @param null|bool $havingAddress Optional. Filter customers having|not having address. If true, only customers having an address are returned. + * If false, only customers without an address are returned. If null, no filter is applied. + * @return array List of customers matching the specified criteria. */ - public static function getCustomers($only_active = null) + public static function getCustomers($active = null, $deleted = null, $havingAddress = null) { - $sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname` - FROM `'._DB_PREFIX_.'customer` - WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER). - ($only_active ? ' AND `active` = 1' : '').' - ORDER BY `id_customer` ASC'; + $sqlSelect = 'SELECT c.`id_customer`, c.`email`, c.`firstname`, c.`lastname`'; + $sqlFrom = 'FROM `'._DB_PREFIX_.'customer` c'; + $sqlJoin = ''; + $sqlWhere = 'WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER). + (!is_null($active) ? ' AND c.`active` = '.(int) $active: ' ' ). + (!is_null($deleted) ? ' AND c.`deleted` = '.(int) $deleted : ' '); + $sqlOrderBy = 'ORDER BY c.`id_customer` ASC'; + $sqlGroupBy = 'GROUP BY c.`id_customer`'; + + if (!is_null($havingAddress)) { + $sqlJoin .= ' LEFT JOIN `'._DB_PREFIX_.'address` a + ON a.`id_customer` = c.`id_customer` AND a.`deleted`=0'; + $sqlWhere .= (($havingAddress) ? ' AND a.`id_address` IS NOT NULL': ' AND a.`id_address` IS NULL'); + } + + $sql = $sqlSelect .' '. $sqlFrom.' '.$sqlJoin.' '.$sqlWhere.' '.$sqlGroupBy.' '.$sqlOrderBy; + return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } + /** * Return customer instance from its e-mail (optionnaly check password) * @@ -951,4 +970,5 @@ class CustomerCore extends ObjectModel $sql_filter .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'main'); return parent::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit); } + } diff --git a/classes/CustomerThread.php b/classes/CustomerThread.php index b6ec27283..70db8c507 100644 --- a/classes/CustomerThread.php +++ b/classes/CustomerThread.php @@ -140,14 +140,15 @@ class CustomerThreadCore extends ObjectModel return Db::getInstance()->executeS($sql); } - public static function getIdCustomerThreadByEmailAndIdOrder($email, $id_order) + public static function getIdCustomerThreadByEmailAndIdOrder($email, $id_order, $id_contact = false) { return Db::getInstance()->getValue(' SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm WHERE cm.email = \''.pSQL($email).'\' AND cm.id_shop = '.(int)Context::getContext()->shop->id.' - AND cm.id_order = '.(int)$id_order + AND cm.id_order = '.(int)$id_order.' '. + (($id_contact) ? ' AND cm.id_contact='.(int) $id_contact : ' ') ); } diff --git a/classes/Gender.php b/classes/Gender.php index f3da94ad1..35034c55d 100644 --- a/classes/Gender.php +++ b/classes/Gender.php @@ -44,7 +44,7 @@ class GenderCore extends ObjectModel 'type' => array('type' => self::TYPE_INT, 'required' => true), /* Lang fields */ - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString', 'required' => true, 'size' => 20), + 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 20), ), ); diff --git a/classes/MaintenanceAccess.php b/classes/MaintenanceAccess.php index 11e0f758d..4c08b2e9b 100644 --- a/classes/MaintenanceAccess.php +++ b/classes/MaintenanceAccess.php @@ -19,23 +19,15 @@ * @license https://store.webkul.com/license.html */ -class MaintenanceAccessCore extends ObjectModel +class MaintenanceAccessCore extends ObjectModel { - public $id_maintenance_access; public $ip_address; public $email; public $date_add; - const USERNAME_ATTEMPTS_PER_QUARTER_HOUR = 3; - const IP_ATTEMPTS_QUARTER_HOUR = 12; - const USERNAME_ATTEMPTS_PER_HOUR = 6; - const IP_ATTEMPTS_PER_HOUR = 24; - const QUARTER_HOUR = 60*15; - const HOUR = 60*60; - /** - * @see ObjectModel::$definition - */ + const LOGIN_ATTEMPTS_WINDOW = 30; /* in minutes */ + public static $definition = array( 'table' => 'maintenance_access', 'primary' => 'id_maintenance_access', @@ -46,51 +38,40 @@ class MaintenanceAccessCore extends ObjectModel ), ); - public function cleanData() + public function removeFailedAttempts($email, $ipAddress) { - $time = (time() - (self::HOUR*2)); Db::getInstance()->execute( - 'DELETE FROM `' . _DB_PREFIX_ .'maintenance_access` - WHERE `date_add` < "' . pSQL(date("Y-m-d H:i:s", $time)) . '"' + 'DELETE FROM `' . _DB_PREFIX_ .'maintenance_access` ma + WHERE (ma.`email` = "'.pSQL($email).'" AND ma.`ip_address` = "'.pSQL($ipAddress).'")' ); } - public function getUserFailedCount($time, $email=false, $ip_address=false, $attempts) + public function getFailedAttemptsCount($email, $ipAddress) { - $sql = "SELECT COUNT(`id_maintenance_access`) FROM `". _DB_PREFIX_ ."maintenance_access` WHERE `date_add` > '" - . pSQL(date('Y-m-d H:i:s', $time)) ."'"; + $sql = 'SELECT COUNT(ma.`id_maintenance_access`) + FROM `'._DB_PREFIX_.'maintenance_access` ma + WHERE (ma.`email` = "'.pSQL($email).'" OR ma.`ip_address` = "'.pSQL($ipAddress).'") + AND TIMESTAMPDIFF( + MINUTE, + ma.`date_add`, + ( + SELECT MAX(ma.`date_add`) + FROM `'._DB_PREFIX_.'maintenance_access` ma + WHERE (ma.`email` = "'.pSQL($email).'" OR ma.`ip_address` = "'.pSQL($ipAddress).'") + AND TIMESTAMPDIFF(MINUTE, ma.`date_add`, NOW()) < '.(int) MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW.' + ) + ) < '.(int) MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW; - if ($email) { - $sql .= " AND `email` = '".pSQL($email)."'"; - } - - if ($ip_address) { - $sql .= " AND `ip_address` = '".pSQL($ip_address)."'"; - } - - return Db::getInstance()->getValue($sql) >= $attempts; + return Db::getInstance()->getValue($sql); } - public function checkLimit($email) + public function getLastAttempt($email, $ipAddress) { - $has_error = false; - $minutes_ago = time() - self::QUARTER_HOUR; - $hours_ago = time() - self::HOUR; - $ip_address = Tools::getRemoteAddr(); - - $has_error |= $this->getUserFailedCount( - $minutes_ago, $email, false, self::USERNAME_ATTEMPTS_PER_QUARTER_HOUR - )? true : $has_error; - $has_error |= $this->getUserFailedCount( - $minutes_ago, false, $ip_address, self::IP_ATTEMPTS_QUARTER_HOUR - )? true : $has_error; - $has_error |= $this->getUserFailedCount( - $hours_ago, $email, false, self::USERNAME_ATTEMPTS_PER_HOUR - )? true : $has_error; - $has_error |= $this->getUserFailedCount( - $hours_ago, false, $ip_address, self::IP_ATTEMPTS_PER_HOUR - )? true : $has_error; - - return $has_error; + return Db::getInstance()->getRow( + 'SELECT * + FROM `'._DB_PREFIX_.'maintenance_access` ma + WHERE (ma.`email` = "'.pSQL($email).'" OR ma.`ip_address` = "'.pSQL($ipAddress).'") + ORDER BY ma.`date_add` DESC' + ); } -} \ No newline at end of file +} diff --git a/classes/Notification.php b/classes/Notification.php index 16ca67b94..fc46b176b 100644 --- a/classes/Notification.php +++ b/classes/Notification.php @@ -72,9 +72,11 @@ class NotificationCore SELECT SQL_CALC_FOUND_ROWS o.`id_order`, o.`id_customer`, o.`total_paid`, o.`id_currency`, o.`date_upd`, c.`firstname`, c.`lastname` FROM `'._DB_PREFIX_.'orders` as o LEFT JOIN `'._DB_PREFIX_.'customer` as c ON (c.`id_customer` = o.`id_customer`) - WHERE `id_order` > '.(int)$id_last_element. - Shop::addSqlRestriction(false, 'o').' - ORDER BY `id_order` DESC + LEFT JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = o.id_order) + WHERE o.`id_order` > '.(int)$id_last_element. + Shop::addSqlRestriction(false, 'o'). HotelBranchInformation::addHotelRestriction(false, 'hbd').' + GROUP BY o.`id_order` + ORDER BY o.`id_order` DESC LIMIT 5'; break; diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index d7e75b7d2..cea68af08 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -33,6 +33,7 @@ abstract class PaymentModuleCore extends Module public $currencies = true; public $currencies_mode = 'checkbox'; public $payment_type = OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT; + public $validateOrderAmount = true; public function install() { @@ -162,7 +163,7 @@ abstract class PaymentModuleCore extends Module */ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, - $secure_key = false, Shop $shop = null) + $secure_key = false, Shop $shop = null, $send_mails = true) { if (self::DEBUG_MODE) { PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int)$id_cart, true); @@ -418,8 +419,7 @@ abstract class PaymentModuleCore extends Module // If webservice order request then no need to impose equal amounts(total cart and sent amount) condition if ($order_status->logable && number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_) - && $this->name != 'wsorder' - && $this->name != 'bo_order' + && ($this->validateOrderAmount) ) { // if customer is paying full payment amount $id_order_state = Configuration::get('PS_OS_ERROR'); @@ -684,24 +684,25 @@ abstract class PaymentModuleCore extends Module if ($voucher->add()) { // If the voucher has conditions, they are now copied to the new voucher CartRule::copyConditions($cart_rule['obj']->id, $voucher->id); - - $params = array( - '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), - '{voucher_num}' => $voucher->code, - '{firstname}' => $this->context->customer->firstname, - '{lastname}' => $this->context->customer->lastname, - '{id_order}' => $order->reference, - '{order_name}' => $order->getUniqReference() - ); - Mail::Send( - (int)$order->id_lang, - 'voucher', - sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference), - $params, - $this->context->customer->email, - $this->context->customer->firstname.' '.$this->context->customer->lastname, - null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop - ); + if ($send_mails) { + $params = array( + '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false), + '{voucher_num}' => $voucher->code, + '{firstname}' => $this->context->customer->firstname, + '{lastname}' => $this->context->customer->lastname, + '{id_order}' => $order->reference, + '{order_name}' => $order->getUniqReference() + ); + Mail::Send( + (int)$order->id_lang, + 'voucher', + sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference), + $params, + $this->context->customer->email, + $this->context->customer->firstname.' '.$this->context->customer->lastname, + null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop + ); + } } } @@ -1050,10 +1051,12 @@ abstract class PaymentModuleCore extends Module // Set the order status $new_history = new OrderHistory(); $new_history->id_order = (int)$order->id; - $new_history->changeIdOrderState((int)$id_order_state, $order, true); - - $new_history->addWithemail(true, $extra_vars); + if ($send_mails) { + $new_history->addWithemail(true, $extra_vars); + } else { + $new_history->add(true); + } // Switch to back order if needed $objHotelBookingDetail = new HotelBookingDetail(); @@ -1089,7 +1092,11 @@ abstract class PaymentModuleCore extends Module $history = new OrderHistory(); $history->id_order = (int)$order->id; $history->changeIdOrderState($id_order_state, $order, true); - $history->addWithemail(); + if ($send_mails) { + $history->addWithemail(); + } else { + $history->add(); + } } unset($order_detail); @@ -1098,7 +1105,11 @@ abstract class PaymentModuleCore extends Module $order = new Order((int)$order->id); // Send an e-mail to customer (one order = one email) - if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) { + if ($id_order_state != Configuration::get('PS_OS_ERROR') + && $id_order_state != Configuration::get('PS_OS_CANCELED') + && $this->context->customer->id + && $send_mails + ) { $invoice = new Address($order->id_address_invoice); $delivery = new Address($order->id_address_delivery); $delivery_state = $delivery->id_state ? new State($delivery->id_state) : false; @@ -1327,9 +1338,7 @@ abstract class PaymentModuleCore extends Module } } } - if ($idHotel - && Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel)) - ) { + if ($idHotel && Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))) { if (Configuration::get('PS_ORDER_CONF_MAIL_TO_HOTEL_MANAGER')){ // If order currenct state is overbooking, the send overbooking email or send order confirmation email if ($isOverBookingStatus) { diff --git a/classes/Product.php b/classes/Product.php index d9fb9d6b3..c47bb1f04 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -5369,7 +5369,7 @@ class ProductCore extends ObjectModel $currentPosition = $this->getPositionInCategory(); - if ($currentPosition && isset($result[$currentPosition])) { + if ($currentPosition !== false && isset($result[$currentPosition])) { $save = $result[$currentPosition]; unset($result[$currentPosition]); array_splice($result, (int)$position, 0, $save); diff --git a/classes/Tools.php b/classes/Tools.php index 50b9cdf23..b58175fab 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -3437,14 +3437,9 @@ exit; $post_data .= '&method=listing&action=install-modules'; $post_data .= defined('_PS_HOST_MODE_') ? '-od' : ''; break; - case 'catalog-recommendation': - $protocols[] = 'http'; - $post_data .= '&method=content&action=catalogRecommendation'; - $post_data .= defined('_PS_HOST_MODE_') ? '-od' : ''; - break; - case 'dashboard-recommendation': - $protocols[] = 'http'; - $post_data .= '&method=content&action=dashboardRecommendation'; + case 'recommendation': + $post_data .= '&method=recommendation&controller='; + $post_data .= (isset($params['controller']) ? $params['controller'] : Context::getContext()->controller->controller_name); $post_data .= defined('_PS_HOST_MODE_') ? '-od' : ''; break; case 'check-version': diff --git a/classes/Validate.php b/classes/Validate.php index 63dcacc75..65fa7f790 100644 --- a/classes/Validate.php +++ b/classes/Validate.php @@ -233,7 +233,7 @@ class ValidateCore */ public static function isPrice($price) { - return preg_match('/^[0-9]{1,10}(\.[0-9]{1,9})?$/', $price); + return preg_match('/^[0-9]{1,10}(\.[0-9]{1,})?$/', $price); } /** @@ -244,7 +244,7 @@ class ValidateCore */ public static function isNegativePrice($price) { - return preg_match('/^[-]?[0-9]{1,10}(\.[0-9]{1,9})?$/', $price); + return preg_match('/^[-]?[0-9]{1,10}(\.[0-9]{1,})?$/', $price); } /** @@ -364,7 +364,7 @@ class ValidateCore */ public static function isCityName($city) { - return preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>;?=+@#"°{}_$%]*$/u'), $city); + return preg_match(Tools::cleanNonUnicodeSupport('/^\p{L}+[^!<>;?=+@#"°{}_$%]*$/u'), $city); } /** diff --git a/classes/cache/Cache.php b/classes/cache/Cache.php index d13b97791..96b0fed3f 100644 --- a/classes/cache/Cache.php +++ b/classes/cache/Cache.php @@ -502,7 +502,7 @@ abstract class CacheCore $this->_deleteMulti($invalidKeys); if ($keyToKeep) { - $this->sql_tables_cached[$table][$keyToKeep] = $toKeep ?? null; + $this->sql_tables_cached[$table][$keyToKeep] = isset($toKeep) ? $toKeep : null; } } $this->adjustTableCacheSize = false; diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 1e127f8e7..876652420 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -409,6 +409,9 @@ class AdminControllerCore extends Controller const QLO_SEARCH_TYPE_MODULE = 7; const QLO_SEARCH_TYPE_HOTEL = 8; + /** @var string path for recomendation content */ + const RECOMMENDATION_CONTENT_FILE_PATH = ''; + public function __construct() { global $timer_start; @@ -838,13 +841,13 @@ class AdminControllerCore extends Controller $this->ensureListIdDefinition(); $prefix = $this->getCookieFilterPrefix(); - + $filters = array(); if (isset($this->list_id)) { foreach ($_POST as $key => $value) { if ($value === '') { unset($this->context->cookie->{$prefix.$key}); } elseif (stripos($key, $this->list_id.'Filter_') === 0) { - $this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : json_encode($value); + $filters[$prefix.$key] = !is_array($value) ? $value : json_encode($value); } elseif (stripos($key, 'submitFilter') === 0) { $this->context->cookie->$key = !is_array($value) ? $value : json_encode($value); } @@ -852,7 +855,7 @@ class AdminControllerCore extends Controller foreach ($_GET as $key => $value) { if (stripos($key, $this->list_id.'Filter_') === 0) { - $this->context->cookie->{$prefix.$key} = !is_array($value) ? $value : json_encode($value); + $filters[$prefix.$key] = !is_array($value) ? $value : json_encode($value); } elseif (stripos($key, 'submitFilter') === 0) { $this->context->cookie->$key = !is_array($value) ? $value : json_encode($value); } @@ -860,65 +863,36 @@ class AdminControllerCore extends Controller if ($value === '' || $value == $this->_defaultOrderBy) { unset($this->context->cookie->{$prefix.$key}); } else { - $this->context->cookie->{$prefix.$key} = $value; + $filters[$prefix.$key] = $value; } } elseif (stripos($key, $this->list_id.'Orderway') === 0 && Validate::isOrderWay($value)) { if ($value === '' || $value == $this->_defaultOrderWay) { unset($this->context->cookie->{$prefix.$key}); } else { - $this->context->cookie->{$prefix.$key} = $value; + $filters[$prefix.$key] = $value; } } } } - $filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_'); - $definition = false; - if (isset($this->className) && $this->className) { - $definition = ObjectModel::getDefinition($this->className); + if (empty($filters)) { + $filters = $this->context->cookie->getFamily($prefix.$this->list_id.'Filter_'); } foreach ($filters as $key => $value) { - /* Extracting filters from $_POST on key filter_ */ - if ($value != null && !strncmp($key, $prefix.$this->list_id.'Filter_', 7 + Tools::strlen($prefix.$this->list_id))) { - $key_org = $key; - $key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id)); - /* Table alias could be specified using a ! eg. alias!field */ - $tmp_tab = explode('!', $key); - $filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]; - - 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') || ($type == 'select' && (isset($field['multiple']) && $field['multiple']))) - && is_string($value) - ) { - $value = json_decode($value, true); + $key_org = $key; + $key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id)); + /* Table alias could be specified using a ! eg. alias!field */ + $tmp_tab = explode('!', $key); + $filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]; + 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')) { + if (is_string($value)) { + $filter_value = json_decode($value, true); } - $key = isset($tmp_tab[1]) ? $tmp_tab[0].'.`'.$tmp_tab[1].'`' : '`'.$tmp_tab[0].'`'; - - // as in database 0 means position 1 in the renderlist - if (isset($field['position']) && Validate::isInt($value)) { - $value -= 1; - } - - // Assignment by reference - if (array_key_exists('tmpTableFilter', $field)) { - $sql_filter = & $this->_tmpTableFilter; - } elseif (array_key_exists('havingFilter', $field)) { - $sql_filter = & $this->_filterHaving; - } else { - $sql_filter = & $this->_filter; - } - - if (is_array($value)) { - 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') { + if (is_array($filter_value)) { + if ($type == 'range') { // set validation type if (isset($field['validation']) && $field['validation'] && method_exists('Validate', $field['validation'])) { $validation = $field['validation']; @@ -926,57 +900,120 @@ class AdminControllerCore extends Controller $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($filter_value[0]) && ($filter_value[0] !== '' || $filter_value[0] === 0)) { + if (!Validate::$validation($filter_value[0])) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'From\' value is invalid'), $field['title']); } } - 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]); + if (isset($filter_value[1]) && ($filter_value[1] !== '' || $filter_value[1] === 0)) { + if (!Validate::$validation($filter_value[1])) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'To\' value is invalid'), $field['title']); + } elseif ((isset($filter_value[0]) && ($filter_value[0] !== '' || $filter_value[0] === 0)) && $filter_value[0] > $filter_value[1]) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'To\' value cannot be less than \'From\' value'), $field['title']); } } } else { - if (isset($value[0]) && !empty($value[0])) { - if (!Validate::isDate($value[0])) { - $this->errors[] = Tools::displayError('The \'From\' date format is invalid (YYYY-MM-DD)'); - } else { - $sql_filter .= ' AND '.pSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\''; + if (isset($filter_value[0]) && !empty($filter_value[0])) { + if (!Validate::isDate($filter_value[0])) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'From\' date format is invalid (YYYY-MM-DD)'), $field['title']); } } - if (isset($value[1]) && !empty($value[1])) { - 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 earlier than \'From\' date'); - } else { - $sql_filter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\''; + if (isset($filter_value[1]) && !empty($filter_value[1])) { + if (!Validate::isDate($filter_value[1])) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'To\' date format is invalid (YYYY-MM-DD)'), $field['title']); + } elseif (isset($filter_value[0]) && !empty($filter_value[0]) && strtotime($filter_value[0]) > strtotime($filter_value[1])) { + $this->errors[] = sprintf(Tools::displayError('The %s field \'To\' date cannot be earlier than \'From\' date'), $field['title']); } } } - } else { - $sql_filter .= ' AND '; - $check_key = ($key == $this->identifier || $key == '`'.$this->identifier.'`'); - $alias = ($definition && !empty($definition['fields'][$filter]['shop'])) ? 'sa' : 'a'; + } + } + } + } - if ($type == 'int' || $type == 'bool') { - $sql_filter .= (($check_key || $key == '`active`') ? $alias.'.' : '').pSQL($key).' = '.(int)$value.' '; - } elseif ($type == 'decimal') { - $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = '.(float)$value.' '; - } elseif ($type == 'select') { - $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = \''.pSQL($value).'\' '; - } elseif ($type == 'price') { - $value = (float)str_replace(',', '.', $value); - $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = '.pSQL(trim($value)).' '; - } else { - $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' LIKE \'%'.pSQL(trim($value)).'%\' '; + if (empty($this->errors)) { + $definition = false; + if (isset($this->className) && $this->className) { + $definition = ObjectModel::getDefinition($this->className); + } + if ($filters) { + foreach ($filters as $key => $value) { + $this->context->cookie->$key = $value; + + /* Extracting filters from $_POST on key filter_ */ + if ($value != null && !strncmp($key, $prefix.$this->list_id.'Filter_', 7 + Tools::strlen($prefix.$this->list_id))) { + $key_org = $key; + $key = Tools::substr($key, 7 + Tools::strlen($prefix.$this->list_id)); + /* Table alias could be specified using a ! eg. alias!field */ + $tmp_tab = explode('!', $key); + $filter = count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]; + + 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') || ($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].'`'; + + // as in database 0 means position 1 in the renderlist + if (isset($field['position']) && Validate::isInt($value)) { + $value -= 1; + } + + // Assignment by reference + if (array_key_exists('tmpTableFilter', $field)) { + $sql_filter = & $this->_tmpTableFilter; + } elseif (array_key_exists('havingFilter', $field)) { + $sql_filter = & $this->_filterHaving; + } else { + $sql_filter = & $this->_filter; + } + + if (is_array($value)) { + 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') { + + if (isset($value[0]) && ($value[0] !== '' || $value[0] === 0)) { + $sql_filter .= ' AND '.pSQL($key).' >= '.pSQL($value[0]); + } + if (isset($value[1]) && ($value[1] !== '' || $value[1] === 0)) { + $sql_filter .= ' AND '.pSQL($key).' <= '.pSQL($value[1]); + } + } else { + if (isset($value[0]) && !empty($value[0])) { + $sql_filter .= ' AND '.pSQL($key).' >= \''.pSQL(Tools::dateFrom($value[0])).'\''; + } + if (isset($value[1]) && !empty($value[1])) { + $sql_filter .= ' AND '.pSQL($key).' <= \''.pSQL(Tools::dateTo($value[1])).'\''; + } + } + } else { + $sql_filter .= ' AND '; + $check_key = ($key == $this->identifier || $key == '`'.$this->identifier.'`'); + $alias = ($definition && !empty($definition['fields'][$filter]['shop'])) ? 'sa' : 'a'; + + if ($type == 'int' || $type == 'bool') { + $sql_filter .= (($check_key || $key == '`active`') ? $alias.'.' : '').pSQL($key).' = '.(int)$value.' '; + } elseif ($type == 'decimal') { + $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = '.(float)$value.' '; + } elseif ($type == 'select') { + $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = \''.pSQL($value).'\' '; + } elseif ($type == 'price') { + $value = (float)str_replace(',', '.', $value); + $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' = '.pSQL(trim($value)).' '; + } else { + $sql_filter .= ($check_key ? $alias.'.' : '').pSQL($key).' LIKE \'%'.pSQL(trim($value)).'%\' '; + } + } } } } @@ -986,7 +1023,7 @@ class AdminControllerCore extends Controller public function processListVisibility() { - $listFieldsVisibility = Tools::getValue('list_fields_visibility'); + $listFieldsVisibility = Tools::getValue('list_fields_visibility', array()); // To set optional list empty in case none is selected $controller = 'list_visibility_'.$this->context->controller->className; $this->context->cookie->$controller = json_encode($listFieldsVisibility); @@ -1039,7 +1076,7 @@ class AdminControllerCore extends Controller if ($this->filter && $this->action != 'reset_filters') { $this->processFilter(); } - if (isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) { + if (empty($this->errors) && isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) { $this->setRedirectAfter(self::$currentIndex.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : '').(isset($_GET['id_'.$this->list_id]) ? '&id_'.$this->list_id.'='.(int)$_GET['id_'.$this->list_id] : '')); } @@ -2310,6 +2347,7 @@ class AdminControllerCore extends Controller public function ajaxProcessRefreshModuleList($force_reload_cache = false) { $this->status = Module::refreshModuleList($force_reload_cache); + $this->ajaxDie(json_encode(array('status' => $this->status))); } /** @@ -3989,17 +4027,65 @@ class AdminControllerCore extends Controller public function ajaxProcessGetRecommendationContent() { $response = array('success' => false); - if (isset($this->context->cookie->{$this->controller_name.'_closed'}) && $this->context->cookie->{$this->controller_name.'_closed'}) { - $response['success'] = true; - } else { - if (method_exists($this, 'getRecommendationContent')) { - if ($content = $this->getRecommendationContent()) { - $response['success'] = true; - $response['content'] = $content; + if ($this->context->controller->getRecommendationFilePath()) { + $response = $this->getRecommendationContent(); + } + $this->context->cookie->write(); + $this->ajaxDie(json_encode($response)); + } + + public function getRecommendationContent() + { + $content = array( + 'success' => false, + 'cache' => true, + 'html' => '' + ); + + if ($recommendationContent = $this->updateRecommendationContent()) { + $content['cache'] = false; + } + if (file_exists(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath())) { + $content['success'] = true; + if (!isset($this->context->cookie->{$this->controller_name.'_closed'}) || !$this->context->cookie->{$this->controller_name.'_closed'}) { + $content['html'] = file_get_contents(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath()); + } + } + + return $content; + } + + public function updateRecommendationContent() + { + if (!Tools::isFresh($this->context->controller->getRecommendationFilePath(), _TIME_1_DAY_, false)) { + if ($recommendationContent = Tools::addonsRequest( + 'recommendation', + array('controller' => $this->context->controller->controller_name) + )) { + $recommendationContent = json_decode($recommendationContent, true); + if (!isset($this->context->cookie->{$this->context->controller->controller_name.'_key'})) { + $this->context->cookie->{$this->context->controller->controller_name.'_key'} = ''; + } + if ($this->context->cookie->{$this->context->controller->controller_name.'_key'} != $recommendationContent['key']) { + unset($this->context->cookie->{$this->context->controller->controller_name.'_closed'}); + } + $this->context->cookie->{$this->context->controller->controller_name.'_key'} = $recommendationContent['key']; + if (isset($recommendationContent['success']) && $recommendationContent['success']) { + @file_put_contents( + _PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath(), + $recommendationContent['html'] + ); + } elseif (file_exists(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath())) { + unlink(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath()); + } + return $recommendationContent; + } else { + if (file_exists(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath())) { + unlink(_PS_ROOT_DIR_.$this->context->controller->getRecommendationFilePath()); } } } - $this->ajaxDie(json_encode($response)); + return false; } public function ajaxProcessRecommendationClosed() @@ -4009,6 +4095,11 @@ class AdminControllerCore extends Controller $this->ajaxDie(json_encode($response)); } + public function getRecommendationFilePath() + { + return static::RECOMMENDATION_CONTENT_FILE_PATH; + } + /** * Save list visible columns * diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 6378c8570..f7ba791f7 100644 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -776,6 +776,7 @@ class FrontControllerCore extends Controller } if (Tools::isSubmit('SubmitLogin') + && !Configuration::get('PS_SHOP_ENABLE') && Configuration::get('PS_ALLOW_EMP') && !Context::getContext()->cookie->enable_maintenance_view ) { @@ -812,56 +813,102 @@ class FrontControllerCore extends Controller protected function processLogin($email, $passwd) { - $result = false; - $objMaintenanceAccess = new MaintenanceAccess(); + $remoteIpAddress = Tools::getRemoteAddr(); + $maxAttempts = Configuration::get('PS_ALLOW_EMP_MAX_ATTEMPTS'); - /* Check fields validity */ - if (empty($email)) { - $this->errors[] = Tools::displayError('Email is empty.'); - } elseif (!Validate::isEmail($email)) { - $this->errors[] = Tools::displayError('Invalid email address.'); - } + if ($maxAttempts) { + $objMaintenanceAccess = new MaintenanceAccess(); + $attemptsCount = $objMaintenanceAccess->getFailedAttemptsCount($email, $remoteIpAddress); // does not include the current one + if ($attemptsCount >= $maxAttempts) { + if ($lastAttempt = $objMaintenanceAccess->getLastAttempt($email, $remoteIpAddress)) { + $minutesElapsed = (int) ((time() - strtotime($lastAttempt['date_add'])) / 60); - if (empty($passwd)) { - $this->errors[] = Tools::displayError('The password field is blank.'); - } elseif (!Validate::isPasswd($passwd)) { - $this->errors[] = Tools::displayError('Invalid password.'); - } - - if ($objMaintenanceAccess->checkLimit($email)) { - $this->errors[] =Tools::displayError('You have exceeded the limit of login attempts, please try after some time'); + if ($minutesElapsed <= MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW) { + $minutesLeft = MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW - $minutesElapsed; + if ($minutesLeft > 1) { + $this->errors[] = Tools::displayError(sprintf('You have reached the limit of login attempts, please try after %d minutes.', $minutesLeft)); + } elseif ($minutesLeft == 1) { + $this->errors[] = Tools::displayError(sprintf('You have reached the limit of login attempts, please try after %d minute.', $minutesLeft)); + } + } + } + } } if (!count($this->errors)) { - // Find employee - $this->context->employee = new Employee(); - $is_employee_loaded = $this->context->employee->getByEmail($email, $passwd); - $employee_associated_shop = $this->context->employee->getAssociatedShops(); - if (!$is_employee_loaded) { - $this->errors[] = Tools::displayError('The Employee does not exist, or the password provided is incorrect.'); - $this->context->employee->logout(); - } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) { - $this->errors[] = Tools::displayError('This employee does not manage the shop anymore (Either the shop has been deleted or permissions have been revoked).'); - $this->context->employee->logout(); - } else { - // Update cookie - $cookie = Context::getContext()->cookie; - $cookie->enable_maintenance_view = $this->context->employee->id; - $cookie->remote_addr = ip2long(Tools::getRemoteAddr()); - $cookie->write(); + if (empty($email)) { + $this->errors[] = Tools::displayError('The Email address field is blank.'); + } elseif (!Validate::isEmail($email)) { + $this->errors[] = Tools::displayError('Invalid Email address.'); } - if (count($this->errors)) { - $this->context->smarty->assign('errors', $this->errors); - $objMaintenanceAccess->email = $email; - $objMaintenanceAccess->ip_address = Tools::getRemoteAddr(); - $objMaintenanceAccess->save(); + + if (empty($passwd)) { + $this->errors[] = Tools::displayError('The Password field is blank.'); + } elseif (!Validate::isPasswd($passwd)) { + $this->errors[] = Tools::displayError('Invalid Password.'); + } + + if (!count($this->errors)) { + // Find employee + $this->context->employee = new Employee(); + $is_employee_loaded = $this->context->employee->getByEmail($email, $passwd); + $employee_associated_shop = $this->context->employee->getAssociatedShops(); + + if (!$is_employee_loaded) { + $this->errors[] = Tools::displayError('The employee does not exist, or the password provided is incorrect.'); + $this->context->employee->logout(); + } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) { + $this->errors[] = Tools::displayError('This employee does not manage the website anymore (either the website has been deleted or permissions have been revoked).'); + $this->context->employee->logout(); + } else { + // Login successful + // Update cookie + $cookie = Context::getContext()->cookie; + $cookie->enable_maintenance_view = $this->context->employee->id; + $cookie->remote_addr = ip2long($remoteIpAddress); + $cookie->write(); + + // Reset attempts count on successful login + $objMaintenanceAccess->removeFailedAttempts($email, $remoteIpAddress); + } + + if (count($this->errors)) { + // Save only if attempts limit is set + if ($maxAttempts) { + $objMaintenanceAccess = new MaintenanceAccess(); + $objMaintenanceAccess->email = $email; + $objMaintenanceAccess->ip_address = $remoteIpAddress; + $objMaintenanceAccess->save(); + + if ($attemptsCount < $maxAttempts) { + $attemptsLeft = $maxAttempts - $attemptsCount - 1; + + if ($attemptsLeft > 0) { + if ($attemptsLeft > 1) { + $this->errors[] = Tools::displayError(sprintf('%d attempts left.', ($maxAttempts - $attemptsCount - 1))); + } else { + $this->errors[] = Tools::displayError(sprintf('%d attempt left.', ($maxAttempts - $attemptsCount - 1))); + } + } else { + if (MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW > 1) { + $this->errors[] = Tools::displayError(sprintf('You have reached the limit of login attempts, please try after %d minutes.', MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW)); + } else { + $this->errors[] = Tools::displayError(sprintf('You have reached the limit of login attempts, please try after %d minute.', MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW)); + } + } + } + } + + $this->context->smarty->assign('errors', $this->errors); + } else { + Tools::redirect('index.php'); + } } else { - Tools::redirect('index.php'); + $this->context->smarty->assign('errors', $this->errors); } } else { $this->context->smarty->assign('errors', $this->errors); } - return $result; } /** diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index df607f131..55219ea1e 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -337,7 +337,7 @@ class HelperListCore extends Helper } } - foreach ($this->fields_list as $key => $params) { + foreach ($this->fields_list as $key => $field) { if (isset($field['optional']) && $field['optional']) { $this->fields_optional[$key] = $field; } @@ -733,8 +733,8 @@ class HelperListCore extends Helper } if (isset($field['optional']) && $field['optional']) { $this->fields_optional[$key] = $field; - if ((empty($list_visibility) && isset($field['visible_default']) && $field['visible_default']) - || $list_visibility && in_array($key , $list_visibility) + if ((!is_array($list_visibility) && isset($field['visible_default']) && $field['visible_default']) + || ($list_visibility && in_array($key , $list_visibility)) ) { $this->fields_optional[$key]['selected'] = true; } diff --git a/classes/helper/HelperTreeHotels.php b/classes/helper/HelperTreeHotels.php index 5849ffb73..dd142943a 100644 --- a/classes/helper/HelperTreeHotels.php +++ b/classes/helper/HelperTreeHotels.php @@ -382,6 +382,23 @@ class HelperTreeHotelsCore extends TreeCore $this->addAction($expand_all); if ($this->useCheckBox()) { + if ($this->useBulkActions()) { + $check_all = new TreeToolbarLink( + 'Check All', + '#', + 'checkAllAssociatedHotels($(\'#'.$this->getId().'\'));return false;', + 'icon-check-sign'); + $check_all->setAttribute('id', 'check-all-'.$this->getId()); + $uncheck_all = new TreeToolbarLink( + 'Uncheck All', + '#', + 'uncheckAllAssociatedHotels($(\'#'.$this->getId().'\'));return false;', + 'icon-check-empty'); + $uncheck_all->setAttribute('id', 'uncheck-all-'.$this->getId()); + $this->addAction($check_all); + $this->addAction($uncheck_all); + } + $this->setNodeFolderTemplate('tree_node_hotel_folder_checkbox.tpl'); $this->setNodeItemTemplate('tree_node_hotel_item_checkbox.tpl'); $this->setAttribute('use_checkbox', $this->useCheckBox()); diff --git a/classes/module/ModuleGraph.php b/classes/module/ModuleGraph.php index f087a0a2c..190787bfe 100644 --- a/classes/module/ModuleGraph.php +++ b/classes/module/ModuleGraph.php @@ -77,6 +77,7 @@ abstract class ModuleGraphCore extends Module if (is_callable(array($this, 'setDayValues'))) { $this->setDayValues($layers); } + $this->_titles['x'][] = $this->l('Time'); } // If the granularity is inferior to 1 month // @TODO : change to manage 28 to 31 days @@ -110,6 +111,7 @@ abstract class ModuleGraphCore extends Module if (is_callable(array($this, 'setMonthValues'))) { $this->setMonthValues($layers); } + $this->_titles['x'][] = $this->l('Date'); } // If the granularity is less than 1 year elseif (strtotime('-1 year', strtotime($this->_employee->stats_date_to)) < strtotime($this->_employee->stats_date_from)) { @@ -141,6 +143,7 @@ abstract class ModuleGraphCore extends Module if (is_callable(array($this, 'setYearValues'))) { $this->setYearValues($layers); } + $this->_titles['x'][] = $this->l('Month'); } // If the granularity is greater than 1 year else { @@ -163,6 +166,7 @@ abstract class ModuleGraphCore extends Module if (is_callable(array($this, 'setAllTimeValues'))) { $this->setAllTimeValues($layers); } + $this->_titles['x'][] = $this->l('Year'); } } @@ -210,7 +214,7 @@ abstract class ModuleGraphCore extends Module if (isset($this->_values[$key])) { // We don't want strings to be divided. Example: product name if (is_numeric($this->_values[$key])) { - $this->_csv .= $this->_values[$key] / (($datas['type'] == 'pie') ? $total : 1); + $this->_csv .= $this->_values[$key] * 100 / (($datas['type'] == 'pie') ? $total : 1) . '%'; } else { $this->_csv .= $this->_values[$key]; } @@ -220,7 +224,7 @@ abstract class ModuleGraphCore extends Module } else { // We don't want strings to be divided. Example: product name if (is_numeric($this->_values[$i][$key])) { - $this->_csv .= $this->_values[$i][$key] / (($datas['type'] == 'pie') ? $total : 1); + $this->_csv .= $this->_values[$i][$key] * 100 / (($datas['type'] == 'pie') ? $total : 1) . '%'; } else { $this->_csv .= $this->_values[$i][$key]; } diff --git a/classes/module/ModuleGrid.php b/classes/module/ModuleGrid.php index 024066626..13f6f18ee 100644 --- a/classes/module/ModuleGrid.php +++ b/classes/module/ModuleGrid.php @@ -153,7 +153,10 @@ abstract class ModuleGridCore extends Module protected function csvExport($datas) { $this->_sort = $datas['defaultSortColumn']; - $this->setLang(Context::getContext()->language->id); + $context = Context::getContext(); + $this->setLang($context->language->id); + $this->setEmployee($context->employee->id); + if (isset($datas['option'])) { $this->setOption($datas['option'], $layers); } diff --git a/classes/order/Order.php b/classes/order/Order.php index a4e7a5e6b..a7d083ff6 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -797,8 +797,9 @@ class OrderCore extends ObjectModel public function getTaxesAverageUsed() { - // @todo should use order table to get tax average - return Cart::getTaxesAverageUsed((int)$this->id_cart); + $cart = new Cart((int) $this->id_cart); + + return $cart->getAverageProductsTaxRate() * 100; } /** @@ -1804,7 +1805,7 @@ class OrderCore extends ObjectModel SELECT opd.`amount` as `real_paid_amount`, opd.*, op.* FROM `'._DB_PREFIX_.'order_payment_detail` opd INNER JOIN `'._DB_PREFIX_.'order_payment` op ON (opd.`id_order_payment` = op.`id_order_payment`) - WHERE `id_order` = '.$this->id + WHERE `id_order` = '.(int) $this->id ); } @@ -2630,9 +2631,12 @@ class OrderCore extends ObjectModel * 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 + * + * @param integer includeCheckIn = 1: If you want to get result for rooms that are refunded or cancelled Or Checkin/Checkout. Send $action = 0 + * * @return boolean: true if order has been completely refunded as per requested parameters or false */ - public function hasCompletelyRefunded($action = 0) + public function hasCompletelyRefunded($action = 0, $includeCheckIn = 0) { $objHotelBooking = new HotelBookingdetail(); if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) { @@ -2657,11 +2661,18 @@ class OrderCore extends ObjectModel } 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'])) { + // If booking refund request is created and request is completed but booking is not refunded then return false + if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($this->id, 0, $booking['id'])) { + $bookingRefundDetail = reset($bookingRefundDetail); + if ($bookingRefundDetail['refunded']) { + return false; + } + } else { return false; } } } + return true; // Default process to check if order is fully refunded or cancelled or not } else { @@ -2669,6 +2680,16 @@ class OrderCore extends ObjectModel $uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_refunded')); if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) { return true; + } elseif ($includeCheckIn) { + foreach ($orderBookings as $booking) { + if ($booking['is_refunded'] == 0 + && !OrderReturn::getOrdersReturnDetail($this->id, 0, $booking['id']) + && $booking['id_status'] == HotelBookingDetail::STATUS_ALLOTED + ) { + return false; + } + } + return true; } } } @@ -2687,4 +2708,138 @@ class OrderCore extends ObjectModel { $this->transaction_id = $transactionId; } + + /** + * Validate and change order status + * @return array of status, errors, has_mail_error(if order status is changes but mail error occurs while sending mail) + */ + public function ChangeOrderStatus() + { + $result = array(); + $result['status'] = false; + $result['has_mail_error'] = false; + $result['errors'] = array(); + $objNewOrderState = new OrderState(Tools::getValue('id_order_state')); + if (!Validate::isLoadedObject($objNewOrderState)) { + $result['errors'][] = Tools::displayError('The new order status is invalid.'); + } else { + $objHotelBooking = new HotelBookingDetail(); + $objCurrentOrderState = $this->getCurrentOrderState(); + + if ($objCurrentOrderState->id == Configuration::get('PS_OS_REFUND')) { + $result['errors'][] = Tools::displayError('Order status can not be changed once order status is set to Refunded.'); + } elseif ($objCurrentOrderState->id == Configuration::get('PS_OS_CANCELED')) { + $result['errors'][] = Tools::displayError('Order status can not be changed once order status is set to Cancelled.'); + } elseif (in_array($objNewOrderState->id, array (Configuration::get('PS_OS_OVERBOOKING_PAID'), Configuration::get('PS_OS_OVERBOOKING_UNPAID'), Configuration::get('PS_OS_OVERBOOKING_PARTIAL_PAID')))) { + if (!$objHotelBooking->getOverbookedRooms($this->id)) { + $result['errors'][] = Tools::displayError('Order status can not be changed to any overbooking status as there are no overbooked rooms in the order.'); + } + } elseif ($objNewOrderState->id == Configuration::get('PS_OS_REFUND') + && !$this->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG) + ) { + $result['errors'][] = Tools::displayError('Order status can not be set to Refunded until all bookings in the order are completely refunded.'); + } elseif ($objNewOrderState->id == Configuration::get('PS_OS_CANCELED') + && !$this->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG) + ) { + $result['errors'][] = Tools::displayError('Order status can not be set to Cancelled until all bookings in the order are cancelled.'); + } elseif ($objCurrentOrderState->id == Configuration::get('PS_OS_ERROR') && !($objNewOrderState->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 + if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) { + foreach ($orderBookings as $orderBooking) { + // If booking is refunded then no need to check inventory + if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($this->id, 0, $orderBooking['id'])) { + $bookingRefundDetail = reset($bookingRefundDetail); + } + + // $bookingRefundDetail['id_customization'] is 1 for only refunded request completed and refunded bookings + if (($bookingRefundDetail && $bookingRefundDetail['refunded'] && $orderBooking['is_refunded'] && $bookingRefundDetail['id_customization']) + || ($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)) { + $result['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 { + $result['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 { + $result['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 ($objCurrentOrderState->id == $objNewOrderState->id) { + $result['errors'][] = Tools::displayError('The order has already been assigned this status.'); + } + } + + if (!count($result['errors'])) { + // Create new OrderHistory + $context = Context::getContext(); + $history = new OrderHistory(); + $history->id_order = $this->id; + $history->id_employee = (int)$context->employee->id; + + $useExistingsPayment = false; + if (!$this->hasInvoice()) { + $useExistingsPayment = true; + } + $history->changeIdOrderState((int)$objNewOrderState->id, $this, $useExistingsPayment); + + // Save all changes + $templateVars = array(); + if ($history->add(true)) { + if (!$history->sendEmail($this, $templateVars)) { + // if an error occurred while sending an email the set has_mail_error to true + $result['has_mail_error'] = true; + $result['errors'][] = Tools::displayError('We were unable to send an email to the customer while changing order status.'); + } + + // synchronizes quantities if needed.. + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { + foreach ($this->getProducts() as $product) { + if (StockAvailable::dependsOnStock($product['product_id'])) { + StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']); + } + } + } + } else { + $result['errors'][] = Tools::displayError('An error occurred while changing order status.'); + } + } + + // if no errors then return status true + if (!count($result['errors'])) { + $result['status'] = true; + } + + return $result; + } } diff --git a/classes/order/OrderCustomerGuestDetail.php b/classes/order/OrderCustomerGuestDetail.php index 9f7013bdd..863a695e6 100644 --- a/classes/order/OrderCustomerGuestDetail.php +++ b/classes/order/OrderCustomerGuestDetail.php @@ -34,12 +34,12 @@ class OrderCustomerGuestDetailCore extends ObjectModel 'table' => 'order_customer_guest_detail', 'primary' => 'id_order_customer_guest_detail', 'fields' => array( - 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), + 'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), - 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32), - 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128), - 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32), + 'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32, 'required' => true), + 'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32, 'required' => true), + 'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 128, 'required' => true), + 'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32, 'required' => true), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), ), @@ -53,22 +53,4 @@ class OrderCustomerGuestDetailCore extends ObjectModel WHERE `id_order` = '.(int)$id_order ); } - - public function validateGuestInfo() - { - $isValid = true; - if (!trim($this->firstname) || !Validate::isName($this->firstname)) { - $isValid = false; - } - if (!trim($this->lastname) || !Validate::isName($this->lastname)) { - $isValid = false; - } - if (!trim($this->email) || !Validate::isEmail($this->email)) { - $isValid = false; - } - if (!trim($this->phone) || !Validate::isPhoneNumber($this->phone)) { - $isValid = false; - } - return $isValid; - } } \ No newline at end of file diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index cfda5704a..60898f126 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -857,4 +857,103 @@ class OrderDetailCore extends ObjectModel return $wholesale_price; } + + /** + * @param OrderDetail $order_detail + * @param int $qty_cancel_product + * @param bool $delete + */ + public function reinjectQuantity($order_detail, $qty_cancel_product, $delete = false) + { + $errors = array(); + $context = Context::getContext(); + // Reinject product + $reinjectable_quantity = (int)$order_detail->product_quantity - (int)$order_detail->product_quantity_reinjected; + $quantity_to_reinject = $qty_cancel_product > $reinjectable_quantity ? $reinjectable_quantity : $qty_cancel_product; + // @since 1.5.0 : Advanced Stock Management + $product_to_inject = new Product($order_detail->product_id, false, (int)$context->language->id, (int)$order_detail->id_shop); + + $product = new Product($order_detail->product_id, false, (int)$context->language->id, (int)$order_detail->id_shop); + + if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management && $order_detail->id_warehouse != 0) { + $manager = StockManagerFactory::getManager(); + $movements = StockMvt::getNegativeStockMvts( + $order_detail->id_order, + $order_detail->product_id, + $order_detail->product_attribute_id, + $quantity_to_reinject + ); + $left_to_reinject = $quantity_to_reinject; + foreach ($movements as $movement) { + if ($left_to_reinject > $movement['physical_quantity']) { + $quantity_to_reinject = $movement['physical_quantity']; + } + + $left_to_reinject -= $quantity_to_reinject; + if (Pack::isPack((int)$product->id)) { + // Gets items + if ($product->pack_stock_type == 1 || $product->pack_stock_type == 2 || ($product->pack_stock_type == 3 && Configuration::get('PS_PACK_STOCK_TYPE') > 0)) { + $products_pack = Pack::getItems((int)$product->id, (int)Configuration::get('PS_LANG_DEFAULT')); + // Foreach item + foreach ($products_pack as $product_pack) { + if ($product_pack->advanced_stock_management == 1) { + $manager->addProduct( + $product_pack->id, + $product_pack->id_pack_product_attribute, + new Warehouse($movement['id_warehouse']), + $product_pack->pack_quantity * $quantity_to_reinject, + null, + $movement['price_te'], + true + ); + } + } + } + if ($product->pack_stock_type == 0 || $product->pack_stock_type == 2 || + ($product->pack_stock_type == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 0 || Configuration::get('PS_PACK_STOCK_TYPE') == 2))) { + $manager->addProduct( + $order_detail->product_id, + $order_detail->product_attribute_id, + new Warehouse($movement['id_warehouse']), + $quantity_to_reinject, + null, + $movement['price_te'], + true + ); + } + } else { + $manager->addProduct( + $order_detail->product_id, + $order_detail->product_attribute_id, + new Warehouse($movement['id_warehouse']), + $quantity_to_reinject, + null, + $movement['price_te'], + true + ); + } + } + + $id_product = $order_detail->product_id; + if ($delete) { + $order_detail->delete(); + } + StockAvailable::synchronize($id_product); + } elseif ($order_detail->id_warehouse == 0) { + StockAvailable::updateQuantity( + $order_detail->product_id, + $order_detail->product_attribute_id, + $quantity_to_reinject, + $order_detail->id_shop + ); + + if ($delete) { + $order_detail->delete(); + } + } else { + $errors[] = Tools::displayError('This product cannot be re-stocked.'); + } + + return $errors; + } } diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 874171009..1d09988c0 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -449,7 +449,7 @@ class OrderHistoryCore extends ObjectModel ); if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) { - $objHotelBranchInformation = new HotelBranchInformation($idHotel, $order->id_lang); + $objHotelBranchInformation = new HotelBranchInformation($idHotel); $fields = array_merge( $objHotelBranchInformation->getFields(), $objHotelBranchInformation->getFieldsLang()[$order->id_lang], diff --git a/classes/order/OrderReturn.php b/classes/order/OrderReturn.php index aaace5681..6af232e7f 100644 --- a/classes/order/OrderReturn.php +++ b/classes/order/OrderReturn.php @@ -177,9 +177,18 @@ class OrderReturnCore extends ObjectModel return (int)($data['total']); } - public function getOrderRefundRequestedBookings($idOrder, $idOrderReturn = 0, $onlyBookingIds = 0, $customerView = 0) + /** + * Get order refund requested bookings + * @param integer $idOrder + * @param integer $idOrderReturn + * @param integer $onlyBookingIds + * @param integer $customerView + * @param integer $skipReqCompletedNonRefunded: send 1 if you want to skip refund request completed but non-refunded booking + * @return array of refund requested bookings + */ + public function getOrderRefundRequestedBookings($idOrder, $idOrderReturn = 0, $onlyBookingIds = 0, $customerView = 0, $skipReqCompletedNonRefunded = 0) { - $sql = 'SELECT hbd.*, ord.* FROM `'._DB_PREFIX_.'order_return` orr'; + $sql = 'SELECT hbd.*, ord.*, orr.`state` as id_return_state FROM `'._DB_PREFIX_.'order_return` orr'; $sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (orr.`id_order_return` = ord.`id_order_return`)'; $sql .= ' LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id` = ord.`id_htl_booking`)'; $sql .= ' WHERE orr.`id_order` = '.(int)$idOrder; @@ -189,79 +198,92 @@ class OrderReturnCore extends ObjectModel } if ($returnDetails = Db::getInstance()->executeS($sql)) { + if ($customerView) { + $returnsCustView = array(); + } + + $objOrder = new Order($idOrder); + $objBookingDemands = new HotelBookingDemands(); + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); + + foreach ($returnDetails as $key => &$bookingRow) { + if ($skipReqCompletedNonRefunded) { + $objReturnState = new OrderReturnState($bookingRow['id_return_state']); + if ($objReturnState->refunded && !$bookingRow['is_refunded']) { + unset($returnDetails[$key]); + continue; + } + } + + if (!$onlyBookingIds) { + $bookingRow['extra_service_total_paid_amount'] = 0; + $bookingRow['extra_service_total_price_tax_incl'] = 0; + $bookingRow['room_paid_amount'] = 0; + if ($bookingRow['total_price_tax_incl'] > 0) { + if ($objOrder->total_paid_real > 0) { + $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + } + } + $roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands( + $idOrder, + $bookingRow['id_product'], + $bookingRow['id_room'], + $bookingRow['date_from'], + $bookingRow['date_to'], + 0 + ); + if (count($roomSelectedDemands)) { + foreach ($roomSelectedDemands as $demand) { + if ($demand['total_price_tax_incl'] > 0) { + if ($objOrder->total_paid_real > 0) { + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + } + $bookingRow['extra_service_total_price_tax_incl'] += $demand['total_price_tax_incl']; + } + } + } + + if ($roomSelectedServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( + $bookingRow['id_htl_booking'] + )) { + if (count($roomSelectedServices['additional_services'])) { + foreach ($roomSelectedServices['additional_services'] as $service) { + if ($service['total_price_tax_incl'] > 0) { + if ($objOrder->total_paid_real > 0) { + $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; + } + $bookingRow['extra_service_total_price_tax_incl'] += $service['total_price_tax_incl']; + } + } + } + } + if ($customerView) { + $dateJoin = $bookingRow['id_product'].'_'.strtotime($bookingRow['date_from']).strtotime($bookingRow['date_to']); + if (isset($returnsCustView[$dateJoin]['num_rooms'])) { + $returnsCustView[$dateJoin]['num_rooms'] += 1; + $returnsCustView[$dateJoin]['refunded_amount'] += $bookingRow['refunded_amount']; + $returnsCustView[$dateJoin]['total_price_tax_incl'] += $bookingRow['total_price_tax_incl']; + $returnsCustView[$dateJoin]['total_paid_amount'] += $bookingRow['total_paid_amount']; + } else { + unset($bookingRow['id_room']); + unset($bookingRow['room_num']); + unset($bookingRow['id_htl_booking']); + $returnsCustView[$dateJoin] = $bookingRow; + $returnsCustView[$dateJoin]['num_rooms'] = 1; + } + } + } + } + if ($onlyBookingIds) { return array_column($returnDetails, 'id_htl_booking'); } - if ($customerView) { - $returnsCustView = array(); - } - - $objBookingDemands = new HotelBookingDemands(); - $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); - $objOrder = new Order($idOrder); - foreach ($returnDetails as &$bookingRow) { - $bookingRow['extra_service_total_paid_amount'] = 0; - $bookingRow['extra_service_total_price_tax_incl'] = 0; - $bookingRow['room_paid_amount'] = 0; - if ($bookingRow['total_price_tax_incl'] > 0) { - if ($objOrder->total_paid_real > 0) { - $bookingRow['room_paid_amount'] = ($objOrder->total_paid_real*$bookingRow['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; - } - } - $roomSelectedDemands = $objBookingDemands->getRoomTypeBookingExtraDemands( - $idOrder, - $bookingRow['id_product'], - $bookingRow['id_room'], - $bookingRow['date_from'], - $bookingRow['date_to'], - 0 - ); - if (count($roomSelectedDemands)) { - foreach ($roomSelectedDemands as $demand) { - if ($demand['total_price_tax_incl'] > 0) { - if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$demand['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; - } - $bookingRow['extra_service_total_price_tax_incl'] += $demand['total_price_tax_incl']; - } - } - } - - if ($roomSelectedServices = $objRoomTypeServiceProductOrderDetail->getSelectedServicesForRoom( - $bookingRow['id_htl_booking'] - )) { - if (count($roomSelectedServices['additional_services'])) { - foreach ($roomSelectedServices['additional_services'] as $service) { - if ($service['total_price_tax_incl'] > 0) { - if ($objOrder->total_paid_real > 0) { - $bookingRow['extra_service_total_paid_amount'] += ($objOrder->total_paid_real*$service['total_price_tax_incl'])/$objOrder->total_paid_tax_incl; - } - $bookingRow['extra_service_total_price_tax_incl'] += $service['total_price_tax_incl']; - } - } - } - } - if ($customerView) { - $dateJoin = $bookingRow['id_product'].'_'.strtotime($bookingRow['date_from']).strtotime($bookingRow['date_to']); - if (isset($returnsCustView[$dateJoin]['num_rooms'])) { - $returnsCustView[$dateJoin]['num_rooms'] += 1; - $returnsCustView[$dateJoin]['refunded_amount'] += $bookingRow['refunded_amount']; - $returnsCustView[$dateJoin]['total_price_tax_incl'] += $bookingRow['total_price_tax_incl']; - $returnsCustView[$dateJoin]['total_paid_amount'] += $bookingRow['total_paid_amount']; - } else { - unset($bookingRow['id_room']); - unset($bookingRow['room_num']); - unset($bookingRow['id_htl_booking']); - $returnsCustView[$dateJoin] = $bookingRow; - $returnsCustView[$dateJoin]['num_rooms'] = 1; - } - } - } if ($customerView) { return $returnsCustView; } } + return $returnDetails; } @@ -297,8 +319,21 @@ class OrderReturnCore extends ObjectModel return $data; } - public static function getOrdersReturnDetail($idOrder, $idOrderReturn = 0, $idHtlBooking = 0, $idLang = 0) - { + /** + * @param $idOrder + * @param int $idOrderReturn + * @param int $idHtlBooking + * @param int $idLang + * @param int $orderByLatestRequest : If you want to return request with in the Desc order of refund requests + * @return array + */ + public static function getOrdersReturnDetail( + $idOrder, + $idOrderReturn = 0, + $idHtlBooking = 0, + $idLang = 0, + $orderByLatestRequest = 1 + ) { if (!$idLang) { $idLang = Context::getContext()->language->id; } @@ -316,6 +351,10 @@ class OrderReturnCore extends ObjectModel $sql .= ' AND ord.`id_htl_booking` = '.(int)$idHtlBooking; } + if ($orderByLatestRequest) { + $sql .= ' ORDER BY orr.`id_order_return` DESC'; + } + return Db::getInstance()->executeS($sql); } @@ -449,8 +488,8 @@ class OrderReturnCore extends ObjectModel '{order_reference}' => $objOrder->reference, '{order_date}' => date('Y-m-d h:i:s', strtotime($objOrder->date_add)), '{refunded_amount}' => Tools::displayPrice($this->refunded_amount, new Currency($objOrder->id_currency)), - '{payment_mode}' => $this->payment_mode, - '{id_transaction}' => $this->id_transaction, + '{payment_mode}' => $this->payment_mode ? $this->payment_mode : '--', + '{id_transaction}' => $this->id_transaction ? $this->id_transaction : '--', ); // if mail is true for the customer then send mail to customer with selected template @@ -480,7 +519,7 @@ class OrderReturnCore extends ObjectModel Mail::Send( (int)$idLang, $objOrderReturnState->customer_template, - $objOrderReturnState->name, + sprintf(Mail::l('Refund %s', (int)$idLang), $objOrderReturnState->name), $data, $objCustomer->email, $objCustomer->firstname.' '.$objCustomer->lastname, @@ -523,7 +562,7 @@ class OrderReturnCore extends ObjectModel Mail::Send( (int)$idLang, $objOrderReturnState->admin_template, - $objOrderReturnState->name, + sprintf(Mail::l('Refund %s', (int)$idLang), $objOrderReturnState->name), $data, $superAdminEmployee['email'], $superAdminEmployee['firstname'].' '.$superAdminEmployee['lastname'], @@ -553,7 +592,7 @@ class OrderReturnCore extends ObjectModel Mail::Send( (int)$idLang, $objOrderReturnState->admin_template, - $objOrderReturnState->name, + sprintf(Mail::l('Refund %s', (int)$idLang), $objOrderReturnState->name), $data, $objHotel->email, null, @@ -585,7 +624,7 @@ class OrderReturnCore extends ObjectModel Mail::Send( (int)$idLang, $objOrderReturnState->admin_template, - $objOrderReturnState->name, + sprintf(Mail::l('Refund %s', (int)$idLang), $objOrderReturnState->name), $data, $empl['email'], $empl['firstname'].' '.$empl['lastname'], diff --git a/classes/order/OrderReturnDetail.php b/classes/order/OrderReturnDetail.php index b956347c1..9975ee40a 100644 --- a/classes/order/OrderReturnDetail.php +++ b/classes/order/OrderReturnDetail.php @@ -30,9 +30,15 @@ class OrderReturnDetailCore extends ObjectModel public $refunded_amount; public $id_order_detail; + + // Used to manage refunded or refunde denied bookings in a refund request : 1 for only refunded request completed and refunded bookings public $id_customization; public $product_quantity; + const REFUND_REQUEST_STATUS_LATEST = 1; + const REFUND_REQUEST_STATUS_PENDING = 2; + const REFUND_REQUEST_STATUS_COMPLETED = 3; + /** * @see ObjectModel::$definition */ diff --git a/classes/pdf/HTMLTemplateInvoice.php b/classes/pdf/HTMLTemplateInvoice.php index 3d28fca40..6065a4d45 100644 --- a/classes/pdf/HTMLTemplateInvoice.php +++ b/classes/pdf/HTMLTemplateInvoice.php @@ -822,7 +822,9 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate */ protected function getTemplateByCountry($iso_country) { - $file = Configuration::get('PS_INVOICE_MODEL'); + // $file = Configuration::get('PS_INVOICE_MODEL'); + // @todo redesign invoice template for b2b, for now we have ony one template design. + $file = 'invoice'; // try to fetch the iso template $template = $this->getTemplate($file.'.'.$iso_country); diff --git a/classes/tax/TaxRulesTaxManager.php b/classes/tax/TaxRulesTaxManager.php index 6f78d4de7..3956fa95e 100644 --- a/classes/tax/TaxRulesTaxManager.php +++ b/classes/tax/TaxRulesTaxManager.php @@ -104,6 +104,7 @@ class TaxRulesTaxManagerCore implements TaxManagerInterface AND tr.`id_country` = '.(int)$this->address->id_country.' AND tr.`id_tax_rules_group` = '.(int)$this->type.' AND tr.`id_state` IN (0, '.(int)$this->address->id_state.') + AND tr.`id_tax` !=0 AND (\''.pSQL($postcode).'\' BETWEEN tr.`zipcode_from` AND tr.`zipcode_to` OR (tr.`zipcode_to` = 0 AND tr.`zipcode_from` IN(0, \''.pSQL($postcode).'\'))) ORDER BY tr.`zipcode_from` DESC, tr.`zipcode_to` DESC, tr.`id_state` DESC, tr.`id_country` DESC'); diff --git a/classes/webservice/WebserviceOrder.php b/classes/webservice/WebserviceOrder.php index 4b1d337e4..860fcc0c0 100644 --- a/classes/webservice/WebserviceOrder.php +++ b/classes/webservice/WebserviceOrder.php @@ -26,5 +26,6 @@ class WebserviceOrderCore extends PaymentModule public function __construct() { $this->displayName = $this->l('Order from API'); + $this->validateOrderAmount = false; } } diff --git a/config/.htaccess b/config/.htaccess index 93169e4eb..3de9e4008 100644 --- a/config/.htaccess +++ b/config/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/config/xml/.htaccess b/config/xml/.htaccess index 93169e4eb..3de9e4008 100644 --- a/config/xml/.htaccess +++ b/config/xml/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index 83a646cb6..5f6bb472d 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -112,18 +112,43 @@ class AdminAddressesControllerCore extends AdminController public function renderForm() { + $customerField =array( + 'type' => 'text_customer', + 'label' => $this->l('Customer'), + 'name' => 'id_customer', + 'required' => false, + ); + if ($this->loadObject(true) + && !$this->object->id + && !Tools::getValue('liteDisplaying') + ) { + $customerEmails = array(array( + 'email' => $this->l('Select Customer'), + 'id_customer' => 0, + 'id_address'=> 0 + )); + $customerEmails = array_merge($customerEmails, Customer::getCustomers(null, 0, 0)); + $customerField = array( + 'type' => 'select', + 'label' => $this->l('Customer'), + 'name' => 'id_customer', + 'required' => true, + 'class' => 'chosen', + 'options' => array( + 'query' => $customerEmails, + 'id' => 'id_customer', + 'name' => 'email' + ), + ); + } + $this->fields_form = array( 'legend' => array( 'title' => $this->l('Addresses'), 'icon' => 'icon-envelope-alt' ), 'input' => array( - array( - 'type' => 'text_customer', - 'label' => $this->l('Customer'), - 'name' => 'id_customer', - 'required' => false, - ), + $customerField, array( 'type' => 'text', 'label' => $this->l('Identification Number'), @@ -191,9 +216,8 @@ class AdminAddressesControllerCore extends AdminController } $this->tpl_form_vars = array( - 'customer' => isset($customer) ? $customer : null, - 'tokenCustomer' => isset($token_customer) ? $token_customer : null, - 'back_url' => urldecode(Tools::getValue('back')) + 'customer' => (isset($customer) && ($this->object->id || Tools::getValue('liteDisplaying'))) ? $customer : null, + 'tokenCustomer' => isset($token_customer) ? $token_customer : null ); // Order address fields depending on country format @@ -503,7 +527,7 @@ class AdminAddressesControllerCore extends AdminController return $out; } - /** + /** * Method called when an ajax request is made * @see AdminController::postProcess() */ diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index f8917621e..6a8c86277 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -411,7 +411,7 @@ class AdminCartRulesControllerCore extends AdminController $ruleGroupId, $ruleId, Tools::getValue('product_rule_'.$ruleGroupId.'_'.$ruleId.'_type'), - Tools::getValue('product_rule_select_'.$ruleGroupId.'_'.$ruleId) + Tools::getValue('product_rule_select_'.$ruleGroupId.'_'.$ruleId, array()) ); } } @@ -486,6 +486,7 @@ class AdminCartRulesControllerCore extends AdminController ON (p.`id_product` = hrt.`id_product`) LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hrt.`id_hotel` = hbl.`id` AND hbl.`id_lang` = '.(int)Context::getContext()->language->id.Shop::addSqlRestrictionOnLang('pl').') + WHERE p.`booking_product` = 1 ORDER BY name'); foreach ($results as $row) { if($row['hotel_name']) { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 8b53e911c..3f3798675 100644 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -42,11 +42,11 @@ class AdminCartsControllerCore extends AdminController $this->allow_export = true; $this->_orderWay = 'DESC'; $this->context = Context::getContext(); - $this->_select = 'CONCAT(c.`firstname`, \' \', c.`lastname`) `customer`, a.id_cart total, TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) AS `time_diff`, - IFNULL(GROUP_CONCAT(o.`id_order`), 0) AS `ids_order`, - IF (IFNULL(o.id_order, \''.$this->l('Non ordered cart').'\') = \''.$this->l('Non ordered cart').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > 86400, \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered cart').'\'), GROUP_CONCAT(o.`id_order`)) AS filter_ids_order, + + IFNULL(GROUP_CONCAT(DISTINCT o.`id_order`), 0) AS `ids_order`, + IF (IFNULL(o.id_order, \''.$this->l('Non ordered cart').'\') = \''.$this->l('Non ordered cart').'\', IF(TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', a.`date_add`)) > '._TIME_1_DAY_.', \''.$this->l('Abandoned cart').'\', \''.$this->l('Non ordered cart').'\'), GROUP_CONCAT(DISTINCT o.`id_order`)) AS filter_ids_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest'; $this->_join = 'LEFT JOIN '._DB_PREFIX_.'customer c ON (c.id_customer = a.id_customer) LEFT JOIN '._DB_PREFIX_.'currency cu ON (cu.id_currency = a.id_currency) @@ -54,10 +54,6 @@ class AdminCartsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', co.`date_add`)) < 1800)'; $this->_group = ' GROUP BY a.`id_cart`'; - if (Tools::getValue('action') == 'filterOnlyAbandonedCarts') { - $this->_filterHaving = ' AND `ids_order` = 0 AND `time_diff` > 86400'; - } - $this->fields_list = array( 'id_cart' => array( 'title' => $this->l('ID'), @@ -96,7 +92,7 @@ class AdminCartsControllerCore extends AdminController 'type' => 'bool', 'havingFilter' => true, 'class' => 'fixed-width-xs', - 'icon' => array(0 => 'icon-', 1 => 'icon-user') + 'callback' => 'getOnlineStatus', ) ); $this->shopLinkType = 'shop'; @@ -117,10 +113,32 @@ class AdminCartsControllerCore extends AdminController } parent::__construct(); - $this->list_no_link = true; } + public function postProcess() + { + if (Tools::getValue('action') == 'filterOnlyAbandonedCarts') { + $this->processResetFilters(); + $this->context->cookie->{'submitFilter'.$this->table} = true; + $prefix = $this->getCookieFilterPrefix(); + $this->context->cookie->{$prefix.$this->table.'Filter_filter_ids_order'} = $this->l('Abandoned cart'); + if (($dateFrom = Tools::getValue('date_from')) + && ($dateTo = Tools::getValue('date_to')) + && strtotime($dateTo) >= strtotime($dateFrom) + ) { + //Updating the date format of the filter dates to the required format. + $dateFrom = date('Y-m-d', strtotime($dateFrom)); + $dateTo = date('Y-m-d', strtotime($dateTo)); + $this->context->cookie->{$prefix.$this->table.'Filter_'.$this->fields_list['date_add']['filter_key']} = json_encode(array($dateFrom, $dateTo)); + } + + $this->redirect_after = $this->context->link->getAdminLink('AdminCarts'); + } + + parent::postProcess(); + } + public function getOrderColumn($idsOrder, $tr) { $smartyVars = array(); @@ -129,7 +147,7 @@ class AdminCartsControllerCore extends AdminController $smartyVars['type'] = 'orders'; $smartyVars['ids_order'] = $idsOrder; } else { - if ($tr['time_diff'] > 86400) { + if ($tr['time_diff'] > _TIME_1_DAY_) { $smartyVars['type'] = 'abandoned'; } else { $smartyVars['type'] = 'non_orderd'; @@ -143,6 +161,11 @@ class AdminCartsControllerCore extends AdminController return $tpl->fetch(); } + public function getOnlineStatus($status) + { + return $status ? $this->l('Yes') : $this->l('No'); + } + public function initPageHeaderToolbar() { if (empty($this->display)) { @@ -184,7 +207,7 @@ class AdminCartsControllerCore extends AdminController $date_from = date(Context::getContext()->language->date_format_lite, strtotime('-2 day')); $date_to = date(Context::getContext()->language->date_format_lite, strtotime('-1 day')); $helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to); - $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts'; + $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$date_from.'&date_to='.$date_to; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart'; $kpis[] = $helper; diff --git a/controllers/admin/AdminCmsContentController.php b/controllers/admin/AdminCmsContentController.php index 9bf088b58..6708fa987 100644 --- a/controllers/admin/AdminCmsContentController.php +++ b/controllers/admin/AdminCmsContentController.php @@ -85,6 +85,7 @@ class AdminCmsContentControllerCore extends AdminController public function initContent() { + $this->loadObject(true); $this->initTabModuleList(); $this->renderPageHeaderToolbar(); @@ -151,8 +152,9 @@ class AdminCmsContentControllerCore extends AdminController if (Tools::getValue('addcms') !== false) { $this->toolbar_title[] = $this->l('Add new'); - } elseif ($id_cms_page) { - $cms_page = new CMS($id_cms_page); + } elseif ($id_cms_page + && Validate::isLoadedObject($cms_page = new CMS($id_cms_page)) + ) { $this->toolbar_title[] = sprintf($this->l('Edit: %s'), $cms_page->meta_title[$this->context->employee->id_lang]); } } else { diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php index 98a5db874..5f81339a4 100644 --- a/controllers/admin/AdminCustomerPreferencesController.php +++ b/controllers/admin/AdminCustomerPreferencesController.php @@ -50,9 +50,9 @@ class AdminCustomerPreferencesControllerCore extends AdminController $this->fields_options = array( 'general' => array( - 'title' => $this->l('General'), - 'icon' => 'icon-cogs', - 'fields' => array( + 'title' => $this->l('General'), + 'icon' => 'icon-cogs', + 'fields' => array( 'PS_REGISTRATION_PROCESS_TYPE' => array( 'title' => $this->l('Registration process type'), 'hint' => $this->l('The "Only account creation" registration option allows the customer to register faster, and create his/her address later.'), @@ -121,6 +121,15 @@ class AdminCustomerPreferencesControllerCore extends AdminController 'cast' => 'intval', 'type' => 'bool' ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ), + 'customer_kpi' => array( + 'title' => $this->l('Customer KPI configuration'), + 'icon' => 'icon-cogs', + 'fields' => array( 'PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS' => array( 'title' => $this->l('Number of orders to use to calculate frequent customers'), 'hint' => $this->l('Set the number of orders to use to calculate frequent customers.'), @@ -157,8 +166,10 @@ class AdminCustomerPreferencesControllerCore extends AdminController 'class' => 'fixed-width-xl', ), ), - 'submit' => array('title' => $this->l('Save')), - ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ) ); } diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 6c763f10c..8f4a628ab 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -170,6 +170,11 @@ class AdminCustomersControllerCore extends AdminController 'type' => 'datetime', 'search' => false, 'havingFilter' => true + ), + 'deleted' => array( + 'title' => $this->l('Banned'), + 'type' => 'bool', + 'displayed' => false, ) )); @@ -218,6 +223,12 @@ class AdminCustomersControllerCore extends AdminController } parent::postProcess(); + // Added this to check if the filter for the banned(deleted) is used, since $this->delete = true will not display the deleted customers. + $prefix = $this->getCookieFilterPrefix(); + $filters = $this->context->cookie->getFamily($prefix.$this->table.'Filter_'); + if (isset($filters[$prefix.$this->table.'Filter_deleted']) && $filters[$prefix.$this->table.'Filter_deleted'] == 1) { + $this->deleted = false; + } } public function initContent() @@ -509,7 +520,7 @@ class AdminCustomersControllerCore extends AdminController ); // if we add a customer via fancybox (ajax), it's a customer and he doesn't need to be added to the visitor and guest groups - if (Tools::isSubmit('addcustomer') && Tools::isSubmit('submitFormAjax')) { + if (Tools::isSubmit('submitFormAjax')) { $visitor_group = Configuration::get('PS_UNIDENTIFIED_GROUP'); $guest_group = Configuration::get('PS_GUEST_GROUP'); foreach ($groups as $key => $g) { @@ -739,6 +750,9 @@ class AdminCustomersControllerCore extends AdminController $helper->color = 'color4'; $helper->title = $this->l('New Customers', null, null, false); $nbDaysNewCustomers = Validate::isUnsignedInt(Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS')) ? Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS') : 30; + $date_from = date('Y-m-d', strtotime('-'.$nbDaysNewCustomers.' day')); + $date_to = date('Y-m-d'); + $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_date_add[]='.$date_from.'&customerFilter_date_add[]='.$date_to; $helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysNewCustomers); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_new_customers'; $helper->tooltip = $this->l('The total number of new customers who registered in given period of time.', null, null, false); @@ -750,6 +764,7 @@ class AdminCustomersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Banned Customers', null, null, false); $helper->subtitle = $this->l('All Time', null, null, false); + $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_deleted=1'; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_banned_customers'; $helper->tooltip = $this->l('The total number of banned customers.', null, null, false); $kpis[] = $helper; @@ -958,8 +973,8 @@ class AdminCustomersControllerCore extends AdminController // If customer is going to be deleted permanently then if customer has orders the change this customer as an anonymous customer if (Validate::isLoadedObject($objCustomer = $this->loadObject())) { if ($this->delete_mode == 'real' && Order::getCustomerOrders($objCustomer->id, true)) { - $objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain(); - $objCustomer->deleted = 1; + $objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::link_rewrite(Configuration::get('PS_SHOP_NAME')).'_anonymous.com'; + $objCustomer->deleted = Customer::STATUS_DELETED; if (!$objCustomer->update()) { $this->errors[] = Tools::displayError('Some error ocurred while deleting the Customer'); return; @@ -1000,7 +1015,7 @@ class AdminCustomersControllerCore extends AdminController // check if customer has orders for email change else customer will be deleted if (Order::getCustomerOrders($objCustomer->id, true)) { $objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain(); - $objCustomer->deleted = 1; + $objCustomer->deleted = Customer::STATUS_DELETED; if ($objCustomer->update()) { // unset the customer which is processed // not processed customers will be deleted with default process if no errors are there @@ -1040,37 +1055,48 @@ class AdminCustomersControllerCore extends AdminController $this->redirect_after = false; } // Check that the new email is not already in use - $customer_email = strval(Tools::getValue('email')); + $customer_email = trim(strval(Tools::getValue('email'))); $customer = new Customer(); if (Validate::isEmail($customer_email)) { $customer->getByEmail($customer_email); - } - if ($customer->id) { - $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; + if ($customer->id) { + $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; + $this->display = 'edit'; + return $customer; + } elseif (Customer::customerExists($customer_email, false, true)) { + $this->errors[] = Tools::displayError('The email is already associated with a banned account. Please use a different one.'); + $this->display = 'edit'; + } elseif (trim(Tools::getValue('passwd')) == '') { + $this->validateRules(); + $this->errors[] = Tools::displayError('Password can not be empty.'); + $this->display = 'edit'; + } elseif ($customer = parent::processAdd()) { + $this->context->smarty->assign('new_customer', $customer); + return $customer; + } + } else { + $this->errors[] = Tools::displayError('Invalid email address.'); $this->display = 'edit'; - return $customer; - } elseif (trim(Tools::getValue('passwd')) == '') { - $this->validateRules(); - $this->errors[] = Tools::displayError('Password can not be empty.'); - $this->display = 'edit'; - } elseif ($customer = parent::processAdd()) { - $this->context->smarty->assign('new_customer', $customer); - return $customer; } + return false; } + public function processUpdate() { if (Validate::isLoadedObject($this->object)) { - $customer_email = strval(Tools::getValue('email')); + $customer_email = trim(strval(Tools::getValue('email'))); // check if e-mail already used if ($customer_email != $this->object->email) { $customer = new Customer(); if (Validate::isEmail($customer_email)) { $customer->getByEmail($customer_email); + } else { + $this->errors[] = Tools::displayError('Invalid email address.'); } + if (($customer->id) && ($customer->id != (int)$this->object->id)) { $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email; } @@ -1289,4 +1315,41 @@ class AdminCustomersControllerCore extends AdminController die('ok'); } } + + public function ajaxProcessVerifyCustomerEmail() + { + $response = array('status' => true); + $idCustomer = Tools::getValue('id_customer', 0); + if (($email = trim(strval(Tools::getValue('email')))) + && ($idCustomerByEmail = Customer::customerExists($email, true, false)) + && (Validate::isLoadedObject($objCustomer = new Customer($idCustomerByEmail))) + && $idCustomerByEmail != $idCustomer // the admin is trying to add/update the account + ) { + $response['status'] = false; + if ($objCustomer->deleted) { + $response['msg'] = Tools::displayError('This email is already associated with a banned account. Please use a different one.'); + } else { + $response['msg'] = Tools::displayError('An account already exists for this email address.'); + } + } + + $this->ajaxDie(json_encode($response)); + } + + public function setMedia() + { + parent::setMedia(); + if ($this->loadObject(true) + && ($this->display == 'edit' || $this->display == 'add') + ) { + $idCustomer = $this->object->id ? $this->object->id : 0; + Media::addJSDef( + array( + 'customer_controller_url' => self::$currentIndex.'&token='.$this->token, + 'id_customer' => $idCustomer + ) + ); + $this->addJS(_PS_JS_DIR_.'admin/customers.js'); + } + } } diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index facba168f..11ffe69e6 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -27,7 +27,7 @@ class AdminDashboardControllerCore extends AdminController { - const DASHBOARD_RECOMMENDATION_CONTENT = '/cache/dashboard_recommendation.html'; + const RECOMMENDATION_CONTENT_FILE_PATH = '/cache/dashboard_recommendation.html'; public function __construct() { @@ -502,15 +502,4 @@ class AdminDashboardControllerCore extends AdminController die(json_encode($return)); } - - public function getRecommendationContent() - { - if (!Tools::isFresh(self::DASHBOARD_RECOMMENDATION_CONTENT, _TIME_1_DAY_, false)) { - @file_put_contents(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT, Tools::addonsRequest('dashboard-recommendation')); - } - if (file_exists(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT)) { - return Tools::file_get_contents(_PS_ROOT_DIR_.self::DASHBOARD_RECOMMENDATION_CONTENT); - } - return false; - } } diff --git a/controllers/admin/AdminFeaturesController.php b/controllers/admin/AdminFeaturesController.php index c581d2604..c57d5d807 100644 --- a/controllers/admin/AdminFeaturesController.php +++ b/controllers/admin/AdminFeaturesController.php @@ -452,10 +452,9 @@ class AdminFeaturesControllerCore extends AdminController $this->initToolbar(); $this->initPageHeaderToolbar(); if ($this->display == 'edit' || $this->display == 'add') { - if (!$this->loadObject(true)) { - return; + if ($this->loadObject(true)) { + $this->content .= $this->renderForm(); } - $this->content .= $this->renderForm(); } elseif ($this->display == 'view') { // Some controllers use the view action without an object if ($this->className) { diff --git a/controllers/admin/AdminGendersController.php b/controllers/admin/AdminGendersController.php index 57a9ef514..7331a9c4c 100644 --- a/controllers/admin/AdminGendersController.php +++ b/controllers/admin/AdminGendersController.php @@ -77,7 +77,7 @@ class AdminGendersControllerCore extends AdminController 'list' => array( 0 => $this->l('Male'), 1 => $this->l('Female'), - 2 => $this->l('Neutral') + 2 => $this->l('Other') ), 'filter_key' => 'a!type', 'callback' => 'displayGenderType', @@ -145,7 +145,7 @@ class AdminGendersControllerCore extends AdminController array( 'id' => 'type_neutral', 'value' => 2, - 'label' => $this->l('Neutral') + 'label' => $this->l('Other') ) ) ), diff --git a/controllers/admin/AdminLocalizationController.php b/controllers/admin/AdminLocalizationController.php index d6f8adb30..aaba53ffa 100644 --- a/controllers/admin/AdminLocalizationController.php +++ b/controllers/admin/AdminLocalizationController.php @@ -175,7 +175,7 @@ class AdminLocalizationControllerCore extends AdminController if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack)) { if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_')) { - $pack = @Tools::file_get_contents(_PS_API_URL_.'/localization/'.$version.'/'.$iso_localization_pack.'.xml'); + $pack = @Tools::file_get_contents(_QLO_API_URL_.'/localization/'.$version.'/'.$iso_localization_pack.'.xml'); } else { $pack = false; } @@ -226,7 +226,7 @@ class AdminLocalizationControllerCore extends AdminController $localizations_pack = false; $this->tpl_option_vars['options_content'] = $this->renderOptions(); - $xml_localization = Tools::simplexml_load_file(_PS_API_URL_.'/rss/localization.xml'); + $xml_localization = Tools::simplexml_load_file(_QLO_API_URL_.'/xml/localization.xml'); if (!$xml_localization) { $localization_file = _PS_ROOT_DIR_.'/localization/localization.xml'; if (file_exists($localization_file)) { @@ -248,7 +248,7 @@ class AdminLocalizationControllerCore extends AdminController } if (!$localizations_pack) { - return $this->displayWarning($this->l('Cannot connect to '._PS_API_URL_)); + return $this->displayWarning($this->l('Cannot connect to '._QLO_API_URL_)); } // Add local localization .xml files to the list if they are not already there diff --git a/controllers/admin/AdminMaintenanceController.php b/controllers/admin/AdminMaintenanceController.php index d6911d4da..9e33f84f6 100644 --- a/controllers/admin/AdminMaintenanceController.php +++ b/controllers/admin/AdminMaintenanceController.php @@ -54,7 +54,16 @@ class AdminMaintenanceControllerCore extends AdminController 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', - 'class' => "hello" + 'form_group_class' => (Tools::getValue('PS_SHOP_ENABLE', Configuration::get('PS_SHOP_ENABLE'))) ? 'collapse' : '', + ), + 'PS_ALLOW_EMP_MAX_ATTEMPTS' => array( + 'title' => $this->l('Maximum Login Attempts'), + 'validation' => 'isUnsignedInt', + 'cast' => 'intval', + 'type' => 'text', + 'class' => 'fixed-width-xl', + 'desc' => sprintf($this->l('Set the number of maximum login attempts allowed in %d minutes. Set to 0 to disable this feature.'), MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW), + 'form_group_class' => ((Tools::getValue('PS_SHOP_ENABLE', Configuration::get('PS_SHOP_ENABLE'))) || !(Tools::getValue('PS_ALLOW_EMP', Configuration::get('PS_ALLOW_EMP')))) ? ' collapse' : '', ), 'PS_MAINTENANCE_IP' => array( 'title' => $this->l('Maintenance IP'), @@ -69,9 +78,44 @@ class AdminMaintenanceControllerCore extends AdminController ); } + public function postProcess() + { + if (Tools::isSubmit('submitOptionsconfiguration')) { + $shopEnable = Tools::getValue('PS_SHOP_ENABLE'); + $allowEmp = Tools::getValue('PS_ALLOW_EMP'); + $allowEmpMaxAttempts = trim(Tools::getValue('PS_ALLOW_EMP_MAX_ATTEMPTS')); + $maintenanceIp = trim(Tools::getValue('PS_MAINTENANCE_IP')); + + // validations + if (!$shopEnable && $allowEmp) { + if ($allowEmpMaxAttempts == '') { + $this->errors[] = $this->l('Maximum Login Attempts is a required field.'); + } elseif (!Validate::isUnsignedInt($allowEmpMaxAttempts)) { + $this->errors[] = $this->l('Maximum Login Attempts is invalid. Please enter a value greater than or equal to 0.'); + } + } + + // update values + if (!count($this->errors)) { + Configuration::updateValue('PS_SHOP_ENABLE', $shopEnable); + Configuration::updateValue('PS_MAINTENANCE_IP', $maintenanceIp); + + if (!$shopEnable) { + Configuration::updateValue('PS_ALLOW_EMP', $allowEmp); + + if ($allowEmp) { + Configuration::updateValue('PS_ALLOW_EMP_MAX_ATTEMPTS', $allowEmpMaxAttempts); + } + } + + Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=6'); + } + } + } + public function setMedia() { parent::setMedia(); - $this->addJS(_PS_JS_DIR_.'maintenance.js'); + $this->addJS(_PS_JS_DIR_.'/admin/maintenance.js'); } } diff --git a/controllers/admin/AdminModulesCatalogController.php b/controllers/admin/AdminModulesCatalogController.php index 72888b9d8..6fb11effa 100644 --- a/controllers/admin/AdminModulesCatalogController.php +++ b/controllers/admin/AdminModulesCatalogController.php @@ -23,7 +23,7 @@ class AdminModulesCatalogControllerCore extends AdminController public $modules; - const CATALOG_RECOMMENDATION_CONTENT = '/cache/catalog_recommendation.html'; + const RECOMMENDATION_CONTENT_FILE_PATH = '/cache/catalog_recommendation.html'; const ELEMENT_TYPE_MODULE = 1; const ELEMENT_TYPE_THEME = 2; @@ -240,17 +240,6 @@ class AdminModulesCatalogControllerCore extends AdminController ); } - public function getRecommendationContent() - { - if (!Tools::isFresh(self::CATALOG_RECOMMENDATION_CONTENT, _TIME_1_DAY_, false)) { - @file_put_contents(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT, Tools::addonsRequest('catalog-recommendation')); - } - if (file_exists(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT)) { - return Tools::file_get_contents(_PS_ROOT_DIR_.self::CATALOG_RECOMMENDATION_CONTENT); - } - return false; - } - public function sortList(&$list, $type) { diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 87a959951..29204f4e2 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -186,19 +186,17 @@ class AdminNormalProductsControllerCore extends AdminController $id_shop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP? (int)$this->context->shop->id : 'a.id_shop_default'; $this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.') - LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (a.`id_product` = hrt.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hb ON (hrt.`id_hotel` = hb.`id`) - LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hb.`id` = hbl.`id` AND b.`id_lang` = hbl.`id_lang`) LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.') LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.') 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_.'htl_room_type_service_product` rsp ON (rsp.`id_product` = a.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)'; + LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.') + '.HotelBranchInformation::addHotelRestriction(false, 'hrt'); $this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, IF(a.`price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', "'.$this->l('Per Day').'", "'.$this->l('Per Booking').'") as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; - $this->_select .= ' COUNT(rsp.`id_product`) as products_associated, hrt.`adults`, hrt.`children`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, '; + $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; $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`'; @@ -210,7 +208,6 @@ class AdminNormalProductsControllerCore extends AdminController // show the list of the product according to the booking or service products $this->_where .= ' AND a.`booking_product` = 0'; - $this->_use_found_rows = false; $this->_group = 'GROUP BY a.`id_product`'; $this->fields_list = array(); @@ -280,7 +277,7 @@ class AdminNormalProductsControllerCore extends AdminController $idServiceCategory = Configuration::get('PS_SERVICE_CATEGORY'); $this->objLocationsCategory = new Category($idServiceCategory, $this->context->language->id); $nestedCategories = Category::getNestedCategories($idServiceCategory); - if ($nestedCategories) { + if (isset($nestedCategories[$idServiceCategory]['children']) && $nestedCategories[$idServiceCategory]['children']) { foreach ($nestedCategories[$idServiceCategory]['children'] as $childCategory) { $this->buildCategoryOptions($childCategory); } @@ -1395,7 +1392,10 @@ class AdminNormalProductsControllerCore extends AdminController parent::postProcess(); } - if ($this->display == 'edit' || $this->display == 'add') { + if (in_array($this->display, array('add', 'edit')) + && $this->tabAccess[$this->display] == '1' + && $this->loadObject(true) + ) { $this->addJqueryUI(array( 'ui.core', 'ui.widget' @@ -2817,9 +2817,7 @@ class AdminNormalProductsControllerCore extends AdminController } // let's calculate this once for all - if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) { - $this->errors[] = 'Unable to load object'; - } else { + if ($this->loadObject(true)) { $this->_displayDraftWarning($this->object->active); // if there was an error while saving, we don't want to lose posted data @@ -2994,7 +2992,7 @@ class AdminNormalProductsControllerCore extends AdminController ->setUseSearch(false) ->setFullTree(0) ->setSelectedCategories($categories) - ->setUseBulkActions(false); + ->setUseBulkActions(true); $data->assign(array('default_category' => $default_category, 'selected_cat_ids' => implode(',', array_keys($selected_cat)), @@ -3079,7 +3077,7 @@ class AdminNormalProductsControllerCore extends AdminController } else { $address->id_country = (int)$address_infos['id_country']; $address->id_state = (int)$address_infos['id_state']; - $address->zipcode = $address_infos['postcode']; + $address->postcode = $address_infos['postcode']; } $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true); $tax_rates = array( @@ -3510,7 +3508,7 @@ class AdminNormalProductsControllerCore extends AdminController ->setRoomsOnly(false) ->setSelectedHotels($selectedElements['hotels']) ->setSelectedRoomTypes($selectedElements['room_types']) - ->setUseBulkActions(false) + ->setUseBulkActions(true) ->setAccessedHotels(HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 0)); $data->assign('hotel_tree', $tree->render()); diff --git a/controllers/admin/AdminOrderPreferencesController.php b/controllers/admin/AdminOrderPreferencesController.php index 4068a6f09..241ed1c29 100644 --- a/controllers/admin/AdminOrderPreferencesController.php +++ b/controllers/admin/AdminOrderPreferencesController.php @@ -82,6 +82,7 @@ class AdminOrderPreferencesControllerCore extends AdminController ) ); + $maxOrderDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE', Configuration::get('MAX_GLOBAL_BOOKING_DATE')); $this->fields_options = array( 'order_restrict' => array( 'title' => $this->l('Order Restrict'), @@ -92,11 +93,13 @@ class AdminOrderPreferencesControllerCore extends AdminController 'hint' => $this->l('Maximum date of check-out for which rooms of your hotels can be booked.'), 'type' => 'text', 'id' => 'max_global_book_date', + 'auto_value' => false, + 'value' => date('d-m-Y', strtotime($maxOrderDate)), 'class' => 'fixed-width-xxl readonly', ), 'GLOBAL_PREPARATION_TIME' => array( - 'title' => $this->l('Preparation time'), - 'hint' => $this->l('Number of days required to prepare a room for a guest\'s stay. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'), + 'title' => $this->l('Minimum booking offset'), + 'hint' => $this->l('The minimum booking offset is the minimum number of days before the check-in date that a guest must book a room. For example, if you set this value to 3 and someone is booking on 2nd of March he can only book rooms for dates from and after 3 days, i.e, 5th of March.'), 'desc' => $this->l('Set to 0 to disable this feature.'), 'type' => 'text', 'class' => 'fixed-width-xl', @@ -329,6 +332,7 @@ class AdminOrderPreferencesControllerCore extends AdminController $this->errors[] = Tools::displayError('Please assign a valid CMS page for Terms and Conditions.'); } + $_POST['MAX_GLOBAL_BOOKING_DATE'] = date('Y-m-d', strtotime(Tools::getValue('MAX_GLOBAL_BOOKING_DATE'))); $maxGlobalBookingDate = Tools::getValue('MAX_GLOBAL_BOOKING_DATE'); $globalPreparationTime = Tools::getValue('GLOBAL_PREPARATION_TIME'); $maxGlobalBookingDateFormatted = date('Y-m-d', strtotime($maxGlobalBookingDate)); @@ -342,9 +346,9 @@ class AdminOrderPreferencesControllerCore extends AdminController } if ($globalPreparationTime === '') { - $this->errors[] = Tools::displayError('Field \'Preparation time\' can not be empty.'); + $this->errors[] = Tools::displayError('Field \'Minimum booking offset\' can not be empty.'); } elseif ($globalPreparationTime !== '0' && !Validate::isUnsignedInt($globalPreparationTime)) { - $this->errors[] = Tools::displayError('Field \'Preparation time\' is invalid.'); + $this->errors[] = Tools::displayError('Field \'Minimum booking offset\' is invalid.'); } } diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 9c6d1fe61..b6c287554 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -24,17 +24,6 @@ * International Registered Trademark & Property of PrestaShop SA */ -class BoOrder extends PaymentModule -{ - public $active = 1; - public $name = 'bo_order'; - - public function __construct() - { - $this->displayName = $this->l('Back office order'); - } -} - /** * @property Order $object */ @@ -285,11 +274,6 @@ class AdminOrdersControllerCore extends AdminController 'payment' => array( 'title' => $this->l('Payment') ), - 'currency' => array( - 'title' => $this->l('Order Currency'), - 'hint' => $this->l('This is the currency in which customer created the order.'), - 'havingFilter' => true, - ), 'order_source' => array( 'title' => $this->l('Order Source'), 'type' => 'select', @@ -374,37 +358,18 @@ class AdminOrdersControllerCore extends AdminController $this->errors[] = $this->l('You have to select a shop before creating new orders.'); } - $id_cart = (int)Tools::getValue('id_cart'); - $cart = new Cart((int)$id_cart); - if ($id_cart && !Validate::isLoadedObject($cart)) { - $this->errors[] = $this->l('This cart does not exists'); - } - if ($id_cart && Validate::isLoadedObject($cart) && !$cart->id_customer) { - $this->errors[] = $this->l('The cart must have a customer'); - } - if (count($this->errors) && !Tools::getValue('submitAddorder')) { - return false; - } - - // check page is whether ad new order page or order detail page - if ((Tools::isSubmit('addorder') && ($id_cart = Tools::getValue('cart_id'))) - || (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart'))) - ) { + // check page is new order creation page and cart id is set + if (Tools::isSubmit('addorder') && ($id_cart = Tools::getValue('cart_id'))) { // set smarty variables if new order creation process has errors $cart = new Cart($id_cart); $cart_order_exists = $cart->orderExists(); if (!$cart_order_exists) { $this->context->cart = $cart; - if ($this->context->employee->isSuperAdmin()) { - $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; - } else { - $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; - } - if (!Configuration::get($backOrderConfigKey)) { - $objHotelCartBookingData = new HotelCartBookingData(); - $objHotelCartBookingData->removeBackdateRoomsFromCart($this->context->cart->id); - } $this->context->currency = new Currency((int)$cart->id_currency); + + // validate cart for removing invalid data from cart before new order creation + $this->errors = array_merge($this->errors, HotelCartBookingData::validateCartBookings()); + $cart_detail_data = array(); $cart_detail_data_obj = new HotelCartBookingData(); $objHotelServiceProductCartDetail = new HotelServiceProductCartDetail(); @@ -420,61 +385,68 @@ class AdminOrdersControllerCore extends AdminController $this->context->smarty->assign('cart_normal_data', $normalCartProduct); } + if (empty($cart_detail_data) && empty($normalCartProduct)) { + // if no rooms added in the cart and user visits add order page then redirect to BOOK NOW page + Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking')); + } + + $payment_modules = array(); + foreach (PaymentModule::getInstalledPaymentModules() as $p_module) { + $payment_modules[] = Module::getInstanceById((int)$p_module['id_module']); + } + + $paymentTypes = array(); + foreach ($this->getPaymentsTypes() as $paymentType) { + if ($paymentType['value'] != OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT) { + $paymentTypes[] = $paymentType; + } + } + + $occupancyRequiredForBooking = false; + if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { + $occupancyRequiredForBooking = true; + } + $objHotelAdvancedPayment = new HotelAdvancedPayment(); $this->context->smarty->assign(array( 'order_total' => $cart->getOrderTotal(true), 'is_advance_payment_active' => $objHotelAdvancedPayment->isAdvancePaymentAvailableForCurrentCart(), 'advance_payment_amount_without_tax' => $cart->getOrderTotal(false, Cart::ADVANCE_PAYMENT), 'advance_payment_amount_with_tax' => $cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT), + 'cart' => $cart, + 'currencies' => Currency::getCurrenciesByIdShop(Context::getContext()->shop->id), + 'langs' => Language::getLanguages(true, Context::getContext()->shop->id), + 'payment_modules' => $payment_modules, + 'payment_types' => $paymentTypes, + 'currency' => new Currency((int)$cart->id_currency), + 'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'), + 'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'), + 'occupancy_required_for_booking' => $occupancyRequiredForBooking, )); - if (empty($cart_detail_data) && empty($normalCartProduct)) { - // if no rooms added in the cart and user visits add order page then redirect to BOOK NOW page - Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking')); - } + } else { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking')); } $this->context->smarty->assign('is_order_created', $cart_order_exists); + } else { + Tools::redirectAdmin($this->context->link->getAdminLink('AdminHotelRoomsBooking')); } + //end parent::renderForm(); unset($this->toolbar_btn['save']); $this->addJqueryPlugin(array('autocomplete', 'fancybox', 'typewatch')); - $payment_modules = array(); - foreach (PaymentModule::getInstalledPaymentModules() as $p_module) { - $payment_modules[] = Module::getInstanceById((int)$p_module['id_module']); - } - - $paymentTypes = array(); - foreach ($this->getPaymentsTypes() as $paymentType) { - if ($paymentType['value'] != OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT) { - $paymentTypes[] = $paymentType; - } - } - - $occupancyRequiredForBooking = false; - if (Configuration::get('PS_BACKOFFICE_ROOM_BOOKING_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { - $occupancyRequiredForBooking = true; - } - $this->context->smarty->assign(array( 'recyclable_pack' => (int)Configuration::get('PS_RECYCLABLE_PACK'), 'gift_wrapping' => (int)Configuration::get('PS_GIFT_WRAPPING'), - 'cart' => $cart, - 'currencies' => Currency::getCurrenciesByIdShop(Context::getContext()->shop->id), - 'langs' => Language::getLanguages(true, Context::getContext()->shop->id), - 'payment_modules' => $payment_modules, - 'payment_types' => $paymentTypes, 'show_toolbar' => $this->show_toolbar, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'PS_CATALOG_MODE' => Configuration::get('PS_CATALOG_MODE'), 'title' => array($this->l('Orders'), $this->l('Create order')), - 'currency' => new Currency((int)$cart->id_currency), - 'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'), - 'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'), - 'occupancy_required_for_booking' => $occupancyRequiredForBooking, )); + $this->content .= $this->createTemplate('form.tpl')->fetch(); } @@ -482,44 +454,47 @@ class AdminOrdersControllerCore extends AdminController { if ($this->display == 'view') { /** @var Order $order */ - $order = $this->loadObject(); + if (Validate::isLoadedObject($order = $this->loadObject())) { + // hotel link in header + if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) { + $this->toolbar_btn['hotel'] = array( + 'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info', + 'desc' => $this->l('View Hotel'), + 'class' => 'icon-building', + 'target' => true, + ); + } - // hotel link in header - if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) { - $this->toolbar_btn['hotel'] = array( - 'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info', - 'desc' => $this->l('View Hotel'), - 'class' => 'icon-building', - 'target' => true, + if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) { + $this->toolbar_btn['file'] = array( + 'short' => $this->l('Invoice'), + 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id, + 'desc' => $this->l('View invoice'), + 'class' => 'icon-file-text', + 'target' => true, + ); + } + + $this->toolbar_btn['print'] = array( + 'short' => $this->l('Print'), + 'href' => 'javascript:window.print()', + 'desc' => $this->l('Print order'), + 'class' => 'icon-print', ); - } - if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) { - $this->toolbar_btn['file'] = array( - 'short' => $this->l('Invoice'), - 'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id, - 'desc' => $this->l('View invoice'), - 'class' => 'icon-file-text', - 'target' => true, - ); - } - - $this->toolbar_btn['print'] = array( - 'short' => $this->l('Print'), - 'href' => 'javascript:window.print()', - 'desc' => $this->l('Print order'), - 'class' => 'icon-print', - ); - - if (((int) $order->isReturnable()) && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG)) { - $this->toolbar_btn['cancel'] = array( - 'short' => ((float) $order->getTotalPaid()) ? $this->l('Refund') : $this->l('Cancel'), - 'href' => '#refundForm', - 'id' => 'desc-order-standard_refund', - 'desc' => ((float) $order->getTotalPaid()) ? $this->l('Initiate refund') : $this->l('Cancel bookings'), - 'class' => 'icon-exchange', - 'target' => true, - ); + if (((int) $order->isReturnable()) && !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG)) { + $orderTotalPaid = $order->getTotalPaid(); + $orderDiscounts = $order->getCartRules(); + $hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false; + $this->toolbar_btn['cancel'] = array( + 'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'), + 'href' => '#refundForm', + 'id' => 'desc-order-standard_refund', + 'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'), + 'class' => 'icon-exchange', + 'target' => true, + ); + } } } @@ -642,11 +617,23 @@ class AdminOrdersControllerCore extends AdminController $payment_methods[] = $module->displayName; } } + + // Set the order currency at first element of currencies + if ($currencies = Currency::getCurrenciesByIdShop($objOrder->id_shop)) { + foreach ($currencies as $key => $currency) { + if ($currency['id_currency'] == $objOrder->id_currency) { + unset($currencies[$key]); + array_unshift($currencies, $currency); + break; + } + } + } + $this->context->smarty->assign( array( 'current_index' => self::$currentIndex, 'order' => $objOrder, - 'currencies' => Currency::getCurrenciesByIdShop($objOrder->id_shop), + 'currencies' => $currencies, 'payment_methods' => $payment_methods, 'payment_types' => $this->getPaymentsTypes(), 'invoices_collection' => $objOrder->getInvoicesCollection(), @@ -779,6 +766,33 @@ class AdminOrdersControllerCore extends AdminController die(Tools::jsonEncode($response)); } + public function ajaxProcessInitRoomAllotmentCommentModal() + { + $response['hasError'] = 1; + if (Validate::isLoadedObject($objBookingDetail = new HotelBookingDetail(Tools::getValue('id_hotel_booking')))) { + if ($objBookingDetail->booking_type == HotelBookingDetail::ALLOTMENT_MANUAL) { + // get booking information by order + $this->context->smarty->assign('comment', $objBookingDetail->comment); + + $title = $objBookingDetail->room_num.' - '.$objBookingDetail->room_type_name.' ('. + Tools::displayDate($objBookingDetail->date_from).' - '.Tools::displayDate($objBookingDetail->date_to).')'; + $modal = array( + 'modal_id' => 'room-allotment-comment-modal', + 'modal_class' => 'modal-md order_detail_modal', + 'modal_title' => '  '.$title, + 'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_room_allotment_comment.tpl'), + 'modal_actions' => array(), + ); + + $this->context->smarty->assign($modal); + $response['hasError'] = 0; + $response['modalHtml'] = $this->context->smarty->fetch('modal.tpl'); + } + } + + die(Tools::jsonEncode($response)); + } + public function ajaxProcessInitRoomReallocationModal() { // set modal details @@ -789,7 +803,7 @@ class AdminOrdersControllerCore extends AdminController array( 'order' => $objOrder, 'currency' => new Currency($objOrder->id_currency), - 'current_index' => self::$currentIndex, + 'reallocate_form_action' => $this->context->link->getAdminLink('AdminOrders').'&vieworder&id_order='.$objOrder->id, ) ); $modal = array( @@ -927,6 +941,10 @@ class AdminOrdersControllerCore extends AdminController $smartyVars['roomTypeServiceProducts'] = $roomTypeServiceProducts; } + $objOrderReturn = new OrderReturn(); + $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1); + $smartyVars['refundReqBookings'] = $refundReqBookings; + $this->context->smarty->assign($smartyVars); $modal = array( @@ -951,7 +969,7 @@ class AdminOrdersControllerCore extends AdminController // get booking information by order $objBookingDetail = new HotelBookingDetail(); $objOrderReturn = new OrderReturn(); - $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1); + $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1, 0, 1); if ($bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($objOrder->id)) { foreach($bookingOrderInfo as $key => $booking) { if ((in_array($booking['id'], $refundReqBookings)) || $booking['is_refunded']) { @@ -959,6 +977,7 @@ class AdminOrdersControllerCore extends AdminController } } } + $this->context->smarty->assign( array( 'order' => $objOrder, @@ -971,15 +990,18 @@ class AdminOrdersControllerCore extends AdminController 'modal_class' => 'modal-md order_detail_modal', 'modal_title' => '  '.$this->l('Cancel Bookings'), 'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_cancel_room_bookings.tpl'), - 'modal_actions' => array( + ); + + if ($bookingOrderInfo) { + $modal['modal_actions'] = array( array( 'type' => 'button', 'value' => 'submitCancelBooking', 'class' => 'submitCancelBooking btn-primary pull-right', 'label' => ' '.$this->l('Cancel Bookings'), - ), - ), - ); + ) + ); + } $this->context->smarty->assign($modal); $response['hasError'] = 0; @@ -997,7 +1019,11 @@ class AdminOrdersControllerCore extends AdminController $this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js'); if ($this->tabAccess['edit'] == 1 && $this->display == 'view') { - $this->addJS(_PS_JS_DIR_.'admin/orders.js'); + if ($this->loadObject()) { + $this->addJS(_PS_JS_DIR_.'admin/orders.js'); + } + // add js for reallocation process + $this->addJS(_PS_JS_DIR_.'admin/reallocation.js'); // $this->addJS(_PS_JS_DIR_.'admin/orders-product-event.js'); // $this->addJS(_PS_JS_DIR_.'admin/orders-room-event.js'); $this->addJS(_PS_JS_DIR_.'tools.js'); @@ -1057,28 +1083,13 @@ class AdminOrdersControllerCore extends AdminController if (!Validate::isLoadedObject($order)) { $this->errors[] = sprintf(Tools::displayError('Order #%d cannot be loaded'), $id_order); } else { - $current_order_state = $order->getCurrentOrderState(); - if ($current_order_state->id == $order_state->id) { - $this->errors[] = $this->displayWarning(sprintf('Order #%d has already been assigned this status.', $id_order)); - } else { - $history = new OrderHistory(); - $history->id_order = $order->id; - $history->id_employee = (int)$this->context->employee->id; - - $use_existings_payment = !$order->hasInvoice(); - $history->changeIdOrderState((int)$order_state->id, $order, $use_existings_payment); - - $carrier = new Carrier($order->id_carrier, $order->id_lang); - $templateVars = array(); - - if ($history->addWithemail(true, $templateVars)) { - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { - foreach ($order->getProducts() as $product) { - if (StockAvailable::dependsOnStock($product['product_id'])) { - StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']); - } - } - } + $result = $order->changeOrderStatus(); + if (!$result['status']) { + if (isset($result['has_mail_error']) && $result['has_mail_error']) { + $this->errors[] = sprintf( + Tools::displayError('Unable to send email to the customer while changing order status for order #%d.'), + $id_order + ); } else { $this->errors[] = sprintf(Tools::displayError('Cannot change status for order #%d.'), $id_order); } @@ -1087,6 +1098,7 @@ class AdminOrdersControllerCore extends AdminController } } } + if (!count($this->errors)) { Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token); } @@ -1292,115 +1304,11 @@ class AdminOrdersControllerCore extends AdminController /* Change order status, add a new entry in order history and send an e-mail to the customer if needed */ elseif (Tools::isSubmit('submitState') && isset($order)) { if ($this->tabAccess['edit'] === '1') { - $order_state = new OrderState(Tools::getValue('id_order_state')); - - if (!Validate::isLoadedObject($order_state)) { - $this->errors[] = Tools::displayError('The new order status is invalid.'); + $result = $order->changeOrderStatus(); + if ($result['status']) { + Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$order->id.'&conf=5&vieworder&token='.$this->token); } else { - $current_order_state = $order->getCurrentOrderState(); - - 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; - $history->id_employee = (int)$this->context->employee->id; - - $use_existings_payment = false; - if (!$order->hasInvoice()) { - $use_existings_payment = true; - } - $history->changeIdOrderState((int)$order_state->id, $order, $use_existings_payment); - - $carrier = new Carrier($order->id_carrier, $order->id_lang); - $templateVars = array(); - - // Save all changes - if ($history->addWithemail(true, $templateVars)) { - // synchronizes quantities if needed.. - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { - foreach ($order->getProducts() as $product) { - if (StockAvailable::dependsOnStock($product['product_id'])) { - StockAvailable::synchronize($product['product_id'], (int)$product['id_shop']); - } - } - } - - 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.'); - } + $this->errors = array_merge($this->errors, $result['errors']); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); @@ -1506,19 +1414,22 @@ class AdminOrdersControllerCore extends AdminController } } } else { - $this->errors[] = Tools::displayError('You do not have permission to delete this.'); + $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } /* booking refunds from order */ elseif (Tools::isSubmit('initiateRefund') && isset($order)) { - if ($this->tabAccess['delete'] === '1') { + if ($this->tabAccess['edit'] === '1') { $bookings = Tools::getValue('id_htl_booking'); if ($bookings && count($bookings)) { foreach ($bookings as $idHtlBooking) { - if (OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) { - $this->errors[] = Tools::displayError('Wrong bookings found for booking cancelation.'); - break; + if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($order->id, 0, $idHtlBooking)) { + $bookingRefundDetail = reset($bookingRefundDetail); + if (!$bookingRefundDetail['refunded']) { + $this->errors[] = Tools::displayError('Wrong bookings found for booking cancelation.'); + break; + } } } } else { @@ -1530,51 +1441,66 @@ class AdminOrdersControllerCore extends AdminController } if (!count($this->errors)) { - // 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(); + // create refund request + $objOrderReturn = new OrderReturn(); + $objOrderReturn->id_customer = $order->id_customer; + $objOrderReturn->id_order = $order->id; + $objOrderReturn->state = 0; + $objOrderReturn->by_admin = 1; + $objOrderReturn->question = $refundReason; + $objOrderReturn->refunded_amount = 0; + $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->refunded_amount = 0; + if (!$order->getCartRules() && $order->getTotalPaid() <= 0) { + $objOrderReturnDetail->id_customization = 1; } + $objOrderReturnDetail->save(); } - } else { - // cancel the booking directly + } + + // Change order refund state + // Emails to customer, superadmin and employees on refund request state change + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); + + // process direct cancellations + if (!$order->getCartRules() && $order->getTotalPaid() <= 0) { + // Process refund in booking tables foreach ($bookings as $idHtlBooking) { $objHtlBooking = new HotelBookingDetail($idHtlBooking); 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)) { + // As object order is already changed in processRefundInBookingTables + $order = new Order($order->id); + // complete the booking refund directly in the refund request + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_REFUNDED')); + + // if all bookings are getting cancelled/Refunded then Cancel/Refund the order also + $idOrderState = 0; + if ($order->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) { + $idOrderState = Configuration::get('PS_OS_REFUND'); + } elseif ($order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) { + $idOrderState = Configuration::get('PS_OS_CANCELED'); + } + + if ($idOrderState) { $objOrderHistory = new OrderHistory(); $objOrderHistory->id_order = (int)$order->id; - $idOrderState = Configuration::get('PS_OS_CANCELED'); - $useExistingPayment = false; if (!$order->hasInvoice()) { $useExistingPayment = true; @@ -1591,7 +1517,7 @@ class AdminOrdersControllerCore extends AdminController Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=3&token='.$this->token); } } else { - $this->errors[] = Tools::displayError('You do not have permission to delete this.'); + $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } elseif (Tools::isSubmit('messageReaded')) { Message::markAsReaded(Tools::getValue('messageReaded'), $this->context->employee->id); @@ -1623,7 +1549,22 @@ class AdminOrdersControllerCore extends AdminController $this->errors[] = Tools::displayError('The date is invalid'); } elseif (!Validate::isUnsignedInt($payment_type)) { $this->errors[] = Tools::displayError('Payment source is invalid'); - } else { + // Amount cannot be less than paid amount by guest in negative price + } elseif ($amount < 0) { + if ($currency->id == $order->id_currency) { + if (($order->total_paid_real + $amount) < 0) { + $this->errors[] = sprintf(Tools::displayError('Amount cannot be less than -%s'), Tools::displayPrice($order->total_paid_real, new Currency($order->id_currency))); + } + } else { + $convertedAmount = Tools::ps_round(Tools::convertPriceFull($amount, $currency, new Currency($order->id_currency)), 6); + $convertedPaidAmount = Tools::ps_round(Tools::convertPriceFull($order->total_paid_real, new Currency($order->id_currency), $currency), 6); + if (($order->total_paid_real + $convertedAmount) < 0) { + $this->errors[] = sprintf(Tools::displayError('Amount cannot be less than -%s (-%s)'), Tools::displayPrice($convertedPaidAmount, $currency), Tools::displayPrice($order->total_paid_real, new Currency($order->id_currency))); + } + } + } + + if (!count($this->errors)) { if (!$order->addOrderPayment( $amount, Tools::getValue('payment_method'), @@ -1648,16 +1589,20 @@ class AdminOrdersControllerCore extends AdminController } elseif (Tools::isSubmit('submitEditNote')) { $note = Tools::getValue('note'); $order_invoice = new OrderInvoice((int)Tools::getValue('id_order_invoice')); - if (Validate::isLoadedObject($order_invoice) && Validate::isCleanHtml($note)) { - if ($this->tabAccess['edit'] === '1') { - $order_invoice->note = $note; - if ($order_invoice->save()) { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order_invoice->id_order.'&vieworder&conf=4&token='.$this->token); + if (Validate::isLoadedObject($order_invoice)) { + if (Validate::isCleanHtml($note)) { + if ($this->tabAccess['edit'] === '1') { + $order_invoice->note = $note; + if ($order_invoice->save()) { + Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order_invoice->id_order.'&vieworder&conf=4&token='.$this->token); + } else { + $this->errors[] = Tools::displayError('The invoice note was not saved.'); + } } else { - $this->errors[] = Tools::displayError('The invoice note was not saved.'); + $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } else { - $this->errors[] = Tools::displayError('You do not have permission to edit this.'); + $this->errors[] = Tools::displayError('Invalid note found.'); } } else { $this->errors[] = Tools::displayError('The invoice for edit note was unable to load. '); @@ -1666,6 +1611,10 @@ class AdminOrdersControllerCore extends AdminController if ($this->tabAccess['edit'] === '1') { $objCart = new Cart($id_cart); if (Validate::isLoadedObject($objCart)) { + $this->context->cart = $objCart; + $this->context->currency = new Currency((int)$objCart->id_currency); + + $this->errors = HotelCartBookingData::validateCartBookings(); $orderTotal = $objCart->getOrderTotal(true, Cart::BOTH); if ($objCart->is_advance_payment) { $advancePaymentAmount = $objCart->getOrderTotal(true, Cart::ADVANCE_PAYMENT); @@ -1683,7 +1632,7 @@ class AdminOrdersControllerCore extends AdminController if ($paymentAmount == '') { $this->errors[] = Tools::displayError('Please enter valid Payment amount of the order.'); } elseif ($paymentAmount && !Validate::isPrice($paymentAmount)) { - $this->errors[] = Tools::displayError('Payment amount is invalid. Please enter correct amount.'); + $this->errors[] = Tools::displayError('Payment amount is invalid. Please enter valid amount.'); } else { $paymentAmount = (float) $paymentAmount; } @@ -1710,23 +1659,6 @@ class AdminOrdersControllerCore extends AdminController } } - // Validate if booking dates are allowed - if ($this->context->employee->isSuperAdmin()) { - $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; - } else { - $backOrderConfigKey = 'PS_BACKDATE_ORDER_EMPLOYEES'; - } - if (!Configuration::get($backOrderConfigKey)) { - $objCartBookingData = new HotelCartBookingData(); - if ($cartBookingData = $objCartBookingData->getCartCurrentDataByCartId($cart->id)) { - foreach ($cartBookingData as $cartRoom) { - if (strtotime($cartRoom['date_from']) < strtotime(date('Y-m-d'))) { - $this->errors[] = Tools::displayError('You cannot book rooms before today date.'); - } - } - } - } - if (!count($this->errors)) { $this->context->currency = new Currency((int) $objCart->id_currency); $this->context->customer = new Customer((int) $objCart->id_customer); @@ -1804,10 +1736,6 @@ class AdminOrdersControllerCore extends AdminController if ($objPaymentModule->currentOrder) { Tools::redirectAdmin(self::$currentIndex.'&id_order='.$objPaymentModule->currentOrder.'&vieworder'.'&token='.$this->token.'&conf=3'); } - } else { - // if errors render add order form - $_GET['addorder'] = '1'; - $_GET['cart_id'] = $id_cart; } } else { $this->errors[] = Tools::displayError('Cart can not be loaded.'); @@ -2038,6 +1966,41 @@ class AdminOrdersControllerCore extends AdminController } } + // update Order refund prices (order_return and order_return_detail) + if ($orderReturns = OrderReturn::getOrdersReturn($order->id_customer, $order->id)) { + $fields = array( + 'refunded_amount', + ); + foreach ($orderReturns as $orderReturn) { + $objOrderReturn = new OrderReturn($orderReturn['id_order_return']); + foreach ($fields as $field) { + $objOrderReturn->{$field} = Tools::convertPriceFull( + $objOrderReturn->{$field}, + $old_currency, + $currency + ); + } + $objOrderReturn->update(); + } + } + + if ($orderReturnDetails = OrderReturn::getOrdersReturnDetail($order->id)) { + $fields = array( + 'refunded_amount', + ); + foreach ($orderReturnDetails as $orderReturnDetail) { + $objOrderReturnDetail = new OrderReturnDetail($orderReturnDetail['id_order_return_detail']); + foreach ($fields as $field) { + $objOrderReturnDetail->{$field} = Tools::convertPriceFull( + $objOrderReturnDetail->{$field}, + $old_currency, + $currency + ); + } + $objOrderReturnDetail->update(); + } + } + // If everything is updated, then redirect to view order with success message Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token); } else { @@ -2118,7 +2081,7 @@ class AdminOrdersControllerCore extends AdminController switch (Tools::getValue('discount_type')) { // Percent type case 1: - if ($discount_value < 100) { + if ($discount_value <= 100) { if (isset($order_invoice)) { $cart_rules[$order_invoice->id]['value_tax_incl'] = Tools::ps_round($order_invoice->total_paid_tax_incl * $discount_value / 100, 2); $cart_rules[$order_invoice->id]['value_tax_excl'] = Tools::ps_round($order_invoice->total_paid_tax_excl * $discount_value / 100, 2); @@ -2210,60 +2173,62 @@ class AdminOrdersControllerCore extends AdminController $this->errors[] = Tools::displayError('The discount type is invalid.'); } - $res = true; - foreach ($cart_rules as &$cart_rule) { - $cartRuleObj = new CartRule(); - $cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add))); - $cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour')); - $cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('discount_name'); - $cartRuleObj->quantity = 0; - $cartRuleObj->quantity_per_user = 1; - if (Tools::getValue('discount_type') == 1) { - $cartRuleObj->reduction_percent = $discount_value; - } elseif (Tools::getValue('discount_type') == 2) { - $cartRuleObj->reduction_amount = $cart_rule['value_tax_excl']; - } elseif (Tools::getValue('discount_type') == 3) { - $cartRuleObj->free_shipping = 1; + if (!count($this->errors)) { + $res = true; + foreach ($cart_rules as &$cart_rule) { + $cartRuleObj = new CartRule(); + $cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add))); + $cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour')); + $cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('discount_name'); + $cartRuleObj->quantity = 0; + $cartRuleObj->quantity_per_user = 1; + if (Tools::getValue('discount_type') == 1) { + $cartRuleObj->reduction_percent = $discount_value; + } elseif (Tools::getValue('discount_type') == 2) { + $cartRuleObj->reduction_amount = $cart_rule['value_tax_excl']; + } elseif (Tools::getValue('discount_type') == 3) { + $cartRuleObj->free_shipping = 1; + } + $cartRuleObj->active = 0; + if ($res = $cartRuleObj->add()) { + $cart_rule['id'] = $cartRuleObj->id; + $cart_rule['free_shipping'] = $cartRuleObj->free_shipping; + } else { + break; + } } - $cartRuleObj->active = 0; - if ($res = $cartRuleObj->add()) { - $cart_rule['id'] = $cartRuleObj->id; - $cart_rule['free_shipping'] = $cartRuleObj->free_shipping; + + if ($res) { + foreach ($cart_rules as $id_order_invoice => $cart_rule) { + // Create OrderCartRule + $order_cart_rule = new OrderCartRule(); + $order_cart_rule->id_order = $order->id; + $order_cart_rule->id_cart_rule = $cart_rule['id']; + $order_cart_rule->id_order_invoice = $id_order_invoice; + $order_cart_rule->name = Tools::getValue('discount_name'); + $order_cart_rule->value = $cart_rule['value_tax_incl']; + $order_cart_rule->value_tax_excl = $cart_rule['value_tax_excl']; + $order_cart_rule->free_shipping = $cart_rule['free_shipping']; + $res &= $order_cart_rule->add(); + + $order->total_discounts = Tools::ps_round($order->total_discounts + $order_cart_rule->value, 6); + $order->total_discounts_tax_incl = Tools::ps_round($order->total_discounts_tax_incl + $order_cart_rule->value, 6); + $order->total_discounts_tax_excl = Tools::ps_round($order->total_discounts_tax_excl + $order_cart_rule->value_tax_excl, 6); + $order->total_paid = Tools::ps_round($order->total_paid - $order_cart_rule->value, 6); + $order->total_paid_tax_incl = Tools::ps_round($order->total_paid_tax_incl - $order_cart_rule->value, 6); + $order->total_paid_tax_excl = Tools::ps_round($order->total_paid_tax_excl - $order_cart_rule->value_tax_excl, 6); + } + + // Update Order + $res &= $order->update(); + } + + if ($res) { + Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token); } else { - break; + $this->errors[] = Tools::displayError('An error occurred during the OrderCartRule creation'); } } - - if ($res) { - foreach ($cart_rules as $id_order_invoice => $cart_rule) { - // Create OrderCartRule - $order_cart_rule = new OrderCartRule(); - $order_cart_rule->id_order = $order->id; - $order_cart_rule->id_cart_rule = $cart_rule['id']; - $order_cart_rule->id_order_invoice = $id_order_invoice; - $order_cart_rule->name = Tools::getValue('discount_name'); - $order_cart_rule->value = $cart_rule['value_tax_incl']; - $order_cart_rule->value_tax_excl = $cart_rule['value_tax_excl']; - $order_cart_rule->free_shipping = $cart_rule['free_shipping']; - $res &= $order_cart_rule->add(); - - $order->total_discounts += $order_cart_rule->value; - $order->total_discounts_tax_incl += $order_cart_rule->value; - $order->total_discounts_tax_excl += $order_cart_rule->value_tax_excl; - $order->total_paid -= $order_cart_rule->value; - $order->total_paid_tax_incl -= $order_cart_rule->value; - $order->total_paid_tax_excl -= $order_cart_rule->value_tax_excl; - } - - // Update Order - $res &= $order->update(); - } - - if ($res) { - Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token); - } else { - $this->errors[] = Tools::displayError('An error occurred during the OrderCartRule creation'); - } } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); @@ -2318,24 +2283,56 @@ class AdminOrdersControllerCore extends AdminController $helper = new HelperKpi(); $helper->id = 'box-order-date'; $helper->icon = 'icon-calendar'; - $helper->color = 'color3'; + $helper->color = 'color1'; $helper->title = $this->l('Order Date'); + $helper->tooltip = $this->l('The date when the order was placed.'); $helper->value = Tools::displayDate($objOrder->date_add); $kpis[] = $helper; $helper = new HelperKpi(); $helper->id = 'box-order-total'; $helper->icon = 'icon-money'; - $helper->color = 'color4'; - $helper->title = $this->l('Total'); + $helper->color = 'color3'; + $helper->title = $this->l('Bookings Total'); + $helper->tooltip = $this->l('Total booking amount of this order.'); $helper->value = Tools::displayPrice($objOrder->total_paid_tax_incl, new Currency($objOrder->id_currency)); $kpis[] = $helper; + $helper = new HelperKpi(); + $helper->id = 'box-total-paid'; + $helper->icon = 'icon-money'; + $helper->color = 'color4'; + $helper->title = $this->l('Total Paid'); + $helper->tooltip = $this->l('Total paid is the amount which customer has already paid for this order.'); + $helper->value = Tools::displayPrice($objOrder->total_paid_real, new Currency($objOrder->id_currency)); + $kpis[] = $helper; + + $helper = new HelperKpi(); + $helper->id = 'box-total-due'; + $helper->icon = 'icon-money'; + $helper->color = 'color2'; + $helper->title = $this->l('Total Due'); + $helper->tooltip = $this->l('Total due is the amount which customer has to pay for this order.'); + $helper->value = Tools::displayPrice(($objOrder->total_paid_tax_incl - $objOrder->total_paid_real), new Currency($objOrder->id_currency)); + $kpis[] = $helper; + + $orderHistory = array_reverse($objOrder->getHistory($this->context->language->id)); + $helper = new HelperKpi(); + $helper->id = 'box-order-source'; + $helper->icon = 'icon-globe'; + $helper->color = 'color1'; + $helper->title = $this->l('Order Source'); + $helper->tooltip = $this->l('Order source shows from which source the order was placed.'); + $helper->subtitle = $orderHistory[0]['id_employee'] ? $this->l('Back office') : $this->l('Front office'); + $helper->value = $objOrder->source; + $kpis[] = $helper; + $helper = new HelperKpi(); $helper->id = 'box-messages'; $helper->icon = 'icon-comments'; $helper->color = 'color2'; $helper->title = $this->l('Messages'); + $helper->tooltip = $this->l('Messages is the number of customer messages for this order.'); $helper->href = $this->context->link->getAdminLink('AdminCustomerThreads').'&id_order='.$objOrder->id; $helper->value = count(CustomerThread::getCustomerMessages($objOrder->id_customer, null, $objOrder->id)); $kpis[] = $helper; @@ -2347,13 +2344,43 @@ class AdminOrdersControllerCore extends AdminController $helper->icon = 'icon-home'; $helper->color = 'color1'; $helper->title = $this->l('Total Rooms'); + $helper->tooltip = $this->l('Total rooms is the number of rooms booked in this order.'); $helper->href = '#start_products'; $helper->value = $numRooms; $kpis[] = $helper; - Hook::exec('action'.$this->controller_name.'KPIListingModifier', array( - 'kpis' => &$kpis, - )); + $helper = new HelperKpi(); + $helper->id = 'box-payment-type'; + $helper->icon = 'icon-home'; + $helper->color = 'color3'; + $helper->title = $this->l('Payment Type'); + $helper->tooltip = $this->l('The payment type refers to the type of payment that customer selected while placing this order.'); + $helper->value = $objOrder->is_advance_payment ? $this->l('Partial Payment') : $this->l('Full Payment'); + $kpis[] = $helper; + + if ($objOrder->is_advance_payment) { + $helper = new HelperKpi(); + $helper->id = 'box-partial-payment-amount'; + $helper->icon = 'icon-money'; + $helper->color = 'color4'; + $helper->title = $this->l('Partial Payment Amount'); + $helper->tooltip = $this->l('Partial payment amount refers to the amount that customer has to pay as advance payment, if payment type selected as partial payment while placing this order.'); + $helper->value = Tools::displayPrice($objOrder->advance_paid_amount, new Currency($objOrder->id_currency)); + $kpis[] = $helper; + } + + $objOrderReturn = new OrderReturn(); + if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrder->id, 0, 1)) { + $refundedAmount = $objOrderReturn->getRefundedAmount($objOrder->id); + $helper = new HelperKpi(); + $helper->id = 'box-payment-type'; + $helper->icon = 'icon-money'; + $helper->color = 'color3'; + $helper->title = $this->l('Refunded Amount'); + $helper->tooltip = $this->l('Refunded amount refers to the amount that has been refunded for this order.'); + $helper->value = Tools::displayPrice($refundedAmount, new Currency($objOrder->id_currency)); + $kpis[] = $helper; + } } else { $time = time(); $kpis = array(); @@ -2422,7 +2449,7 @@ class AdminOrdersControllerCore extends AdminController $dateFrom = date(Context::getContext()->language->date_format_lite, strtotime('-2 day')); $dateTo = date(Context::getContext()->language->date_format_lite, strtotime('-1 day')); $helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $dateFrom, $dateTo); - $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts'; + $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$dateFrom.'&date_to='.$dateTo; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart'; $helper->tooltip = $this->l('Total number of abandoned carts in given period of time.', null, null, false); $kpis[] = $helper; @@ -2468,6 +2495,10 @@ class AdminOrdersControllerCore extends AdminController $kpis[] = $helper; } + Hook::exec('action'.$this->controller_name.'KPIListingModifier', array( + 'kpis' => &$kpis, + )); + $helper = new HelperKpiRow(); $helper->kpis = $kpis; return $helper->generate(); @@ -2475,9 +2506,8 @@ class AdminOrdersControllerCore extends AdminController public function renderView() { - $order = new Order(Tools::getValue('id_order')); - if (!Validate::isLoadedObject($order)) { - $this->errors[] = Tools::displayError('The order cannot be found within your database.'); + if (!Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) { + return; } $this->content .= $this->renderKpis(); @@ -2640,7 +2670,7 @@ class AdminOrdersControllerCore extends AdminController $totalConvenienceFeeTI = 0; $totalDemandsPriceTE = 0; $totalDemandsPriceTI = 0; - + $totalRefundedRooms = 0; if ($order_detail_data = $objBookingDetail->getOrderFormatedBookinInfoByIdOrder($order->id)) { $objBookingDemand = new HotelBookingDemands(); $objHotelRoomType = new HotelRoomType(); @@ -2801,6 +2831,15 @@ class AdminOrdersControllerCore extends AdminController $order_detail_data[$key]['amt_with_qty_tax_incl'] = $value['total_price_tax_incl']; $order_detail_data[$key]['room_type_info'] = $objHotelRoomType->getRoomTypeInfoByIdProduct($value['id_product']); $order_detail_data[$key]['total_room_tax'] = $order_detail_data[$key]['total_room_price_ti'] - $order_detail_data[$key]['total_room_price_te']; + + if (isset($value['refund_info']) + && $value['refund_info']['refunded'] + && $value['refund_info']['id_customization'] + && $value['is_refunded'] + && !$value['is_cancelled'] + ) { + $totalRefundedRooms += 1; + } } } else { $order_detail_data = array(); @@ -2808,19 +2847,25 @@ class AdminOrdersControllerCore extends AdminController $objOrderReturn = new OrderReturn(); $refundedAmount = 0; - if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1)) { + if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1, 0, 1)) { $refundedAmount = $objOrderReturn->getRefundedAmount($order->id); } // get booking information by order $bookingOrderInfo = $objBookingDetail->getBookingDataByOrderId($order->id); foreach ($bookingOrderInfo as &$bookingOrderRoomInfo) { + // Get last refund request for booking + if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($bookingOrderRoomInfo['id_order'], 0, $bookingOrderRoomInfo['id'])) { + $bookingRefundDetail = reset($bookingRefundDetail); + if (!$bookingRefundDetail['id_customization']) { + $bookingOrderRoomInfo['is_refunded'] = 0; + } + } $bookingOrderRoomInfo['num_checkin_documents'] = HotelBookingDocument::getCountByIdHtlBooking($bookingOrderRoomInfo['id']); } $objHotelBookingDetail = new HotelBookingDetail(); $htlBookingDetail = $objHotelBookingDetail->getOrderCurrentDataByOrderId($order->id); - $isCancelledRoom = in_array(1, array_column($htlBookingDetail, 'is_cancelled')); // hotel booking statuses $htlOrderStatus = HotelBookingDetail::getAllHotelOrderStatus(); @@ -2839,15 +2884,14 @@ class AdminOrdersControllerCore extends AdminController $orderOverBookings = $objHotelBookingDetail->getOverbookedRooms($order->id, 0, '', '', 0, 0, 1); $this->tpl_view_vars = array( - // refund info + 'totalRefundedRooms' => $totalRefundedRooms, 'orderOverBookings' => $orderOverBookings, + // refund info 'refund_allowed' => (int) $order->isReturnable(), 'applicable_refund_policies' => $applicableRefundPolicies, 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'refundReqBookings' => $refundReqBookings, '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, @@ -2934,11 +2978,10 @@ class AdminOrdersControllerCore extends AdminController 'products' => $products, 'customer' => $customer) ), - 'isCancelledRoom' => $isCancelledRoom, 'orderDocuments' => $order->getDocuments(), - 'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED, 'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN, 'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT, + 'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL, ); return parent::renderView(); @@ -3121,44 +3164,52 @@ class AdminOrdersControllerCore extends AdminController public function ajaxProcessUpdateGuestDetails() { $response = array( - 'success' => false + 'hasError' => false, + 'errors' => array(), ); if (Validate::isLoadedObject($order = new Order(Tools::getValue('id_order')))) { - if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { - if (Validate::isLoadedObject($objCustomerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail))) { - $id_gender = Tools::getValue('id_gender'); - $firstname = Tools::getValue('firstname'); - $lastname = Tools::getValue('lastname'); - $email = Tools::getValue('email'); - $phone = Tools::getValue('phone'); - $objCustomerGuestDetail->id_gender = $id_gender; - $objCustomerGuestDetail->firstname = $firstname; - $objCustomerGuestDetail->lastname = $lastname; - $objCustomerGuestDetail->email = $email; - $objCustomerGuestDetail->phone = $phone; - if ($objCustomerGuestDetail->validateGuestInfo()) { + $objCustomerGuestDetail = new OrderCustomerGuestDetail(); + $response['errors'] = $objCustomerGuestDetail->validateController(); + if (!$response['errors']) { + if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) { + if (Validate::isLoadedObject($objCustomerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail))) { + $id_gender = Tools::getValue('id_gender'); + $firstname = Tools::getValue('firstname'); + $lastname = Tools::getValue('lastname'); + $email = Tools::getValue('email'); + $phone = Tools::getValue('phone'); + $objCustomerGuestDetail->id_gender = $id_gender; + $objCustomerGuestDetail->firstname = $firstname; + $objCustomerGuestDetail->lastname = $lastname; + $objCustomerGuestDetail->email = $email; + $objCustomerGuestDetail->phone = $phone; if ($objCustomerGuestDetail->save()) { - $response['success'] = true; $gender = new Gender($objCustomerGuestDetail->id_gender, $this->context->language->id); $response['data']['gender_name'] = $gender->name; $response['data']['guest_name'] = $objCustomerGuestDetail->firstname.' '.$objCustomerGuestDetail->lastname ; $response['data']['guest_email'] = $objCustomerGuestDetail->email; $response['data']['guest_phone'] = $objCustomerGuestDetail->phone; + $response['msg'] = $this->l('Guest details are updated.'); } else { $response['errors'][] = $this->l('Unable to save guest details.'); } } else { - $response['errors'][] = $this->l('Invalid guest details, please check and try again.'); + $response['errors'][] = $this->l('Guest details not found.'); } } else { $response['errors'][] = $this->l('Guest details not found.'); } - } else { - $response['errors'][] = $this->l('Guest details not found.'); } } + if ($response['errors']) { + $response['hasError'] = true; + $this->context->smarty->assign('errors', $response['errors']); + + $response['errorsHtml'] = $this->context->smarty->fetch('alerts.tpl'); + } + $this->ajaxDie(json_encode($response)); } @@ -4047,7 +4098,7 @@ class AdminOrdersControllerCore extends AdminController if ($createFeaturePrice) { $featurePriceParams['id_room'] = $room_info['id_room']; $featurePriceParams = array_merge($featurePriceParams, array('date_from' => $date_from, 'date_to' => $date_to)); - $this->createFeaturePrice($featurePriceParams); + HotelRoomTypeFeaturePricing::createAutoFeaturePrice($featurePriceParams); } } else { break; @@ -4501,32 +4552,6 @@ class AdminOrdersControllerCore extends AdminController ))); } - protected function createFeaturePrice($params) - { - $feature_price_name = array(); - foreach (Language::getIDs(true) as $id_lang) { - $feature_price_name[$id_lang] = 'Auto-generated'; - } - - $hrt_feature_price = new HotelRoomTypeFeaturePricing(); - $hrt_feature_price->id_product = (int) $params['id_product']; - $hrt_feature_price->id_cart = (int) $params['id_cart']; - $hrt_feature_price->id_guest = (int) $params['id_guest']; - $hrt_feature_price->id_room = (int) $params['id_room']; - $hrt_feature_price->feature_price_name = $feature_price_name; - $hrt_feature_price->date_selection_type = HotelRoomTypeFeaturePricing::DATE_SELECTION_TYPE_RANGE; - $hrt_feature_price->date_from = date('Y-m-d', strtotime($params['date_from'])); - $hrt_feature_price->date_to = date('Y-m-d', strtotime($params['date_to'])); - $hrt_feature_price->is_special_days_exists = 0; - $hrt_feature_price->special_days = json_encode(false); - $hrt_feature_price->impact_way = HotelRoomTypeFeaturePricing::IMPACT_WAY_FIX_PRICE; - $hrt_feature_price->impact_type = HotelRoomTypeFeaturePricing::IMPACT_TYPE_FIXED_PRICE; - $hrt_feature_price->impact_value = $params['price']; - $hrt_feature_price->active = 1; - $hrt_feature_price->groupBox = array_column(Group::getGroups($this->context->language->id), 'id_group'); - $hrt_feature_price->add(); - } - public function ajaxProcessEditRoomOnOrder() { // Return value @@ -4561,103 +4586,6 @@ class AdminOrdersControllerCore extends AdminController $children = $occupancy['children']; $child_ages = $occupancy['child_ages']; - /*By webkul to validate fields before deleting the cart and order data form the tables*/ - if ($id_hotel == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Hotel Id is mising.'), - ))); - } elseif ($id_room == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Room Id is missing.'), - ))); - } elseif ($new_date_from == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please Enter Check In Date.'), - ))); - } elseif (!Validate::isDateFormat($new_date_from)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please Enter a Valid Check In Date.'), - ))); - } elseif ($new_date_to == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please Enter Check Out Date.'), - ))); - } elseif (!Validate::isDateFormat($new_date_to)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please Enter a valid Check out Date.'), - ))); - } elseif ($new_date_from < $curr_date) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check In date should not be after current date.'), - ))); - } elseif ($new_date_to <= $new_date_from) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check out Date Should be after Check In date.'), - ))); - } elseif ($room_unit_price == '') { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please enter unit price.'), - ))); - } elseif (!Validate::isPrice($room_unit_price)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please enter a valid unit price.'), - ))); - } elseif (!Validate::isUnsignedInt($product_quantity)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Invalid quantity.'), - ))); - } - - // validations if order is with occupancy - if (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Invalid number of adults.'), - ))); - } elseif (!Validate::isUnsignedInt($children)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Invalid number of children.'), - ))); - } - - if ($children > 0) { - if (!isset($child_ages) || ($children != count($child_ages))) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Please provide all children age.'), - ))); - } else { - foreach($child_ages as $childAge) { - if (!Validate::isUnsignedInt($childAge)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Invalid children age.'), - ))); - } - } - } - } - - $rooms_booked = $obj_booking_detail->getRoomBookinInformationForDateRangeByOrder($id_room, $old_date_from, $old_date_to, $new_date_from, $new_date_to); - if ($rooms_booked) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('This Room Unavailable For Selected Duration.'), - ))); - } - // By webkul to calculate rates of the product from hotelreservationsystem tables with feature prices.... // add feature price for updated price @@ -4685,7 +4613,7 @@ class AdminOrdersControllerCore extends AdminController if (Validate::isLoadedObject($objProduct = new Product($roomInfo['id_product']))) { // If room type is NOT DELETED then use current room type price calculation $params = array_merge($params, array('date_from' => $new_date_from, 'date_to' => $new_date_to)); - $this->createFeaturePrice($params); + HotelRoomTypeFeaturePricing::createAutoFeaturePrice($params); $roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $roomInfo['id_product'], @@ -4760,47 +4688,47 @@ class AdminOrdersControllerCore extends AdminController if ($order_detail->id_order_invoice != $order_invoice->id) { $old_order_invoice = new OrderInvoice($order_detail->id_order_invoice); // We remove cost of products - $old_order_invoice->total_products -= $order_detail->total_price_tax_excl; - $old_order_invoice->total_products_wt -= $order_detail->total_price_tax_incl; + $old_order_invoice->total_products -= Tools::ps_round($order_detail->total_price_tax_excl, 6); + $old_order_invoice->total_products_wt -= Tools::ps_round($order_detail->total_price_tax_incl, 6); - $old_order_invoice->total_paid_tax_excl -= $order_detail->total_price_tax_excl; - $old_order_invoice->total_paid_tax_incl -= $order_detail->total_price_tax_incl; + $old_order_invoice->total_paid_tax_excl -= Tools::ps_round($order_detail->total_price_tax_excl, 6); + $old_order_invoice->total_paid_tax_incl -= Tools::ps_round($order_detail->total_price_tax_incl, 6); $res &= $old_order_invoice->update(); - $order_invoice->total_products += $order_detail->total_price_tax_excl; - $order_invoice->total_products_wt += $order_detail->total_price_tax_incl; + $order_invoice->total_products += Tools::ps_round($order_detail->total_price_tax_excl, 6); + $order_invoice->total_products_wt += Tools::ps_round($order_detail->total_price_tax_incl, 6); - $order_invoice->total_paid_tax_excl += $order_detail->total_price_tax_excl; - $order_invoice->total_paid_tax_incl += $order_detail->total_price_tax_incl; + $order_invoice->total_paid_tax_excl += Tools::ps_round($order_detail->total_price_tax_excl, 6); + $order_invoice->total_paid_tax_incl += Tools::ps_round($order_detail->total_price_tax_incl, 6); $order_detail->id_order_invoice = $order_invoice->id; } } if ($diff_price_tax_incl != 0 && $diff_price_tax_excl != 0) { - $order_detail->unit_price_tax_excl = $product_price_tax_excl; - $order_detail->unit_price_tax_incl = $product_price_tax_incl; + $order_detail->unit_price_tax_excl = Tools::ps_round($product_price_tax_excl, 6); + $order_detail->unit_price_tax_incl = Tools::ps_round($product_price_tax_incl, 6); - $order_detail->total_price_tax_incl += (float)$diff_price_tax_incl; - $order_detail->total_price_tax_excl += (float)$diff_price_tax_excl; + $order_detail->total_price_tax_incl += Tools::ps_round((float)$diff_price_tax_incl, 6); + $order_detail->total_price_tax_excl += Tools::ps_round((float)$diff_price_tax_excl, 6); if (isset($order_invoice)) { // Apply changes on OrderInvoice - $order_invoice->total_products += (float)$diff_price_tax_excl; - $order_invoice->total_products_wt += (float)$diff_price_tax_incl; + $order_invoice->total_products += Tools::ps_round((float)$diff_price_tax_excl, 6); + $order_invoice->total_products_wt += Tools::ps_round((float)$diff_price_tax_incl, 6); - $order_invoice->total_paid_tax_excl += (float)$diff_price_tax_excl; - $order_invoice->total_paid_tax_incl += (float)$diff_price_tax_incl; + $order_invoice->total_paid_tax_excl += Tools::ps_round((float)$diff_price_tax_excl, 6); + $order_invoice->total_paid_tax_incl += Tools::ps_round((float)$diff_price_tax_incl, 6); } // Apply changes on Order $order = new Order($order_detail->id_order); - $order->total_products += (float)$diff_price_tax_excl; - $order->total_products_wt += (float)$diff_price_tax_incl; - $order->total_paid += (float)$diff_price_tax_incl; - $order->total_paid_tax_excl += (float)$diff_price_tax_excl; - $order->total_paid_tax_incl += (float)$diff_price_tax_incl; + $order->total_products += Tools::ps_round((float)$diff_price_tax_excl, 6); + $order->total_products_wt += Tools::ps_round((float)$diff_price_tax_incl, 6); + $order->total_paid += Tools::ps_round((float)$diff_price_tax_incl, 6); + $order->total_paid_tax_excl += Tools::ps_round((float)$diff_price_tax_excl, 6); + $order->total_paid_tax_incl += Tools::ps_round((float)$diff_price_tax_incl, 6); $res &= $order->update(); } @@ -4923,6 +4851,7 @@ class AdminOrdersControllerCore extends AdminController 'tax_excl' => $totalRoomPriceAfterTE, 'tax_incl' => $totalRoomPriceAfterTI, ); + if ($update_htl_tables = $obj_booking_detail->UpdateHotelCartHotelOrderOnOrderEdit( $id_order, $id_room, @@ -5364,8 +5293,8 @@ class AdminOrdersControllerCore extends AdminController } else { // Calculate differences of price (Before / After) - $order_detail->total_price_tax_incl -= $diff_products_tax_incl; - $order_detail->total_price_tax_excl -= $diff_products_tax_excl; + $order_detail->total_price_tax_incl -= Tools::ps_round($diff_products_tax_incl, 6); + $order_detail->total_price_tax_excl -= Tools::ps_round($diff_products_tax_excl, 6); $old_quantity = $order_detail->product_quantity; @@ -5381,20 +5310,23 @@ class AdminOrdersControllerCore extends AdminController // update order detail for selected aditional services foreach ($selectedAdditonalServices['additional_services'] as $service) { $serviceOrderDetail = new OrderDetail($service['id_order_detail']); - if ($service['quantity'] >= $serviceOrderDetail->product_quantity) { + + $cart_quantity = $service['quantity']; + if ($service['product_price_calculation_method'] == Product::PRICE_CALCULATION_METHOD_PER_DAY) { + $cart_quantity = $cart_quantity * $product_quantity; + } + if ($cart_quantity >= $serviceOrderDetail->product_quantity) { $serviceOrderDetail->delete(); } else { - $order_detail->total_price_tax_incl -= $service['total_price_tax_incl']; - $order_detail->total_price_tax_excl -= $service['total_price_tax_excl']; - - $serviceOldQuantity = $serviceOrderDetail->product_quantity; - $serviceOrderDetail->product_quantity = $serviceOldQuantity - $service['quantity']; + $serviceOrderDetail->total_price_tax_incl -= Tools::ps_round($service['total_price_tax_incl'], 6); + $serviceOrderDetail->total_price_tax_excl -= Tools::ps_round($service['total_price_tax_excl'], 6); + $serviceOrderDetail->product_quantity -= $cart_quantity; // update taxes - $res &= $order_detail->updateTaxAmount($order); + $res &= $serviceOrderDetail->updateTaxAmount($order); // Save order detail - $res &= $order_detail->update(); + $res &= $serviceOrderDetail->update(); } } /*End*/ @@ -5403,25 +5335,42 @@ class AdminOrdersControllerCore extends AdminController if ($order_detail->id_order_invoice != 0) { // values changes as values are calculated accoding to the quantity of the product by webkul $order_invoice = new OrderInvoice($order_detail->id_order_invoice); - $order_invoice->total_paid_tax_excl -= ($diff_products_tax_excl + $roomExtraDemandTE + $additionlServicesTE); - $order_invoice->total_paid_tax_incl -= ($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI); - $order_invoice->total_products -= $diff_products_tax_excl; - $order_invoice->total_products_wt -= $diff_products_tax_incl; + $order_invoice->total_paid_tax_excl -= Tools::ps_round(($diff_products_tax_excl + $roomExtraDemandTE + $additionlServicesTE), 6); + $order_invoice->total_paid_tax_excl = $order_invoice->total_paid_tax_excl > 0 ? $order_invoice->total_paid_tax_excl : 0; + + $order_invoice->total_paid_tax_incl -= Tools::ps_round(($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI), 6); + $order_invoice->total_paid_tax_incl = $order_invoice->total_paid_tax_incl > 0 ? $order_invoice->total_paid_tax_incl : 0; + + $order_invoice->total_products -= Tools::ps_round($diff_products_tax_excl, 6); + $order_invoice->total_products = $order_invoice->total_products > 0 ? $order_invoice->total_products : 0; + + $order_invoice->total_products_wt -= Tools::ps_round($diff_products_tax_incl, 6); + $order_invoice->total_products_wt = $order_invoice->total_products_wt > 0 ? $order_invoice->total_products_wt : 0; + $res &= $order_invoice->update(); } // Update Order // values changes as values are calculated accoding to the quantity of the product by webkul - $order->total_paid -= ($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI); - $order->total_paid_tax_incl -= ($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI); - $order->total_paid_tax_excl -= ($diff_products_tax_excl + $roomExtraDemandTE + $additionlServicesTE); - $order->total_products -= ($diff_products_tax_excl + $additionlServicesTE); - $order->total_products_wt -= ($diff_products_tax_incl + $additionlServicesTI); + $order->total_paid -= Tools::ps_round(($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI), 6); + $order->total_paid = $order->total_paid > 0 ? $order->total_paid : 0; + + $order->total_paid_tax_incl -= Tools::ps_round(($diff_products_tax_incl + $roomExtraDemandTI + $additionlServicesTI), 6); + $order->total_paid_tax_incl = $order->total_paid_tax_incl > 0 ? $order->total_paid_tax_incl : 0; + + $order->total_paid_tax_excl -= Tools::ps_round(($diff_products_tax_excl + $roomExtraDemandTE + $additionlServicesTE), 6); + $order->total_paid_tax_excl = $order->total_paid_tax_excl > 0 ? $order->total_paid_tax_excl : 0; + + $order->total_products -= Tools::ps_round(($diff_products_tax_excl + $additionlServicesTE), 6); + $order->total_products = $order->total_products > 0 ? $order->total_products : 0; + + $order->total_products_wt -= Tools::ps_round(($diff_products_tax_incl + $additionlServicesTI), 6); + $order->total_products_wt = $order->total_products_wt > 0 ? $order->total_products_wt : 0; $res &= $order->update(); // Reinject quantity in stock - $this->reinjectQuantity($order_detail, $order_detail->product_quantity, $delete); + $order_detail->reinjectQuantity($order_detail, $order_detail->product_quantity, $delete); // Update weight SUM $order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier()); @@ -5511,7 +5460,7 @@ class AdminOrdersControllerCore extends AdminController $res &= $order->update(); // Reinject quantity in stock - $this->reinjectQuantity($order_detail, $order_detail->product_quantity, true); + $order_detail->reinjectQuantity($order_detail, $order_detail->product_quantity, true); // Update weight SUM $order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier()); @@ -5586,8 +5535,48 @@ class AdminOrdersControllerCore extends AdminController { $this->doEditValidation($order_detail, $order, $order_invoice); + $id_hotel_booking = Tools::getValue('id_booking_detail'); $product_price_tax_incl = str_replace(',', '.', Tools::getValue('product_price_tax_incl')); $product_price_tax_excl = str_replace(',', '.', Tools::getValue('product_price_tax_excl')); + $product_informations = $_POST['edit_product']; + $new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from']))); + $new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to']))); + $old_date_from = date('Y-m-d', strtotime(trim(Tools::getValue('date_from')))); + $old_date_to = date('Y-m-d', strtotime(trim(Tools::getValue('date_to')))); + $id_hotel = trim(Tools::getValue('id_hotel')); + $id_room = trim(Tools::getValue('id_room')); + $id_product = trim(Tools::getValue('id_product')); + $room_unit_price = trim(Tools::getValue('room_unit_price')); + $obj_booking_detail = new HotelBookingDetail(); + $product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to); + $old_product_quantity = (int) $obj_booking_detail->getNumberOfDays($old_date_from, $old_date_to); + $qty_diff = $product_quantity - $old_product_quantity; + $occupancy = array_shift(Tools::getValue('occupancy')); + $adults = $occupancy['adults']; + $children = $occupancy['children']; + $child_ages = $occupancy['child_ages']; + + // If order is refunded, the validate changes which are not allowed + $objOrderReturn = new OrderReturn(); + $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1); + if ($refundReqBookings && (in_array($id_hotel_booking, $refundReqBookings))) { + $objBookingDetail = new HotelBookingDetail($id_hotel_booking); + // If order is cancelled, we can't edit order + if ($objBookingDetail->is_refunded && $objBookingDetail->is_cancelled) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Booking cannot be edited if booking is cancelled.'), + ))); + // If order is refunded, we can't edit dates + } elseif ($objBookingDetail->is_refunded + && (strtotime($old_date_from) != strtotime($new_date_from) || strtotime($old_date_to) != strtotime($new_date_to)) + ) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Check-In/Check-Out dates cannot be changed if booking is refunded.'), + ))); + } + } if (!Validate::isPrice($product_price_tax_incl) || !Validate::isPrice($product_price_tax_excl)) { die(json_encode(array( @@ -5596,46 +5585,89 @@ class AdminOrdersControllerCore extends AdminController ))); } - $product_informations = Tools::getValue('edit_product'); - $old_date_from = date('Y-m-d', strtotime(trim(Tools::getValue('date_from')))); - $old_date_to = date('Y-m-d', strtotime(trim(Tools::getValue('date_to')))); - $new_date_from = trim(date('Y-m-d', strtotime($product_informations['date_from']))); - $new_date_to = trim(date('Y-m-d', strtotime($product_informations['date_to']))); - $obj_booking_detail = new HotelBookingDetail(); - $product_quantity = (int) $obj_booking_detail->getNumberOfDays($new_date_from, $new_date_to); - $id_room = Tools::getValue('id_room'); - - if (trim(Tools::getValue('id_hotel')) == '') { + if ($id_hotel == '') { die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Hotel Id is mising.'), ))); - } elseif (trim($id_room) == '') { + } elseif ($id_room == '') { die(json_encode(array( 'result' => false, 'error' => Tools::displayError('Room Id is missing.'), ))); - } elseif (trim(date('Y-m-d', strtotime($product_informations['date_from']))) == '') { + } elseif ($new_date_from == '') { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Please enter check-in date.'), + 'error' => Tools::displayError('Please enter Check-In date.'), ))); } elseif (!Validate::isDateFormat($new_date_from)) { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Please enter a valid check-in date.'), + 'error' => Tools::displayError('Please enter a valid Check-In date.'), ))); } elseif ($new_date_to == '') { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Please enter check-out date.'), + 'error' => Tools::displayError('Please enter Check-Out date.'), ))); } elseif (!Validate::isDateFormat($new_date_to)) { die(json_encode(array( 'result' => false, - 'error' => Tools::displayError('Please enter a valid check-out date.'), + 'error' => Tools::displayError('Please enter a valid Check-out date.'), + ))); + } elseif ($new_date_to <= $new_date_from) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Check-out date should be after Check-In date.'), + ))); + } elseif ($room_unit_price == '') { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Please enter unit price.'), + ))); + } elseif (!Validate::isPrice($room_unit_price)) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Please enter a valid unit price.'), + ))); + } elseif (!Validate::isUnsignedInt($product_quantity)) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Invalid quantity.'), ))); } + + // validations if order is with occupancy + if (!isset($adults) || !$adults || !Validate::isUnsignedInt($adults)) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Invalid number of adults.'), + ))); + } elseif (!Validate::isUnsignedInt($children)) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Invalid number of children.'), + ))); + } + + if ($children > 0) { + if (!isset($child_ages) || ($children != count($child_ages))) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Please provide all children age.'), + ))); + } else { + foreach($child_ages as $childAge) { + if (!Validate::isUnsignedInt($childAge)) { + die(json_encode(array( + 'result' => false, + 'error' => Tools::displayError('Invalid children age.'), + ))); + } + } + } + } + if ($this->context->employee->isSuperAdmin()) { $backOrderConfigKey = 'PS_BACKDATE_ORDER_SUPERADMIN'; } else { @@ -5646,24 +5678,18 @@ class AdminOrdersControllerCore extends AdminController if ($new_date_from < $compareDate) { die(json_encode(array( 'result' => false, - 'error' => sprintf(Tools::displayError('Check-in date should not be date before %s.'),$compareDate) + 'error' => sprintf(Tools::displayError('Check-In date should not be date before %s.'),$compareDate) ))); } } - if ($new_date_to <= $new_date_from) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Check-out date should be after check-in date.'), - ))); - } elseif (!Validate::isUnsignedInt($product_quantity)) { - die(json_encode(array( - 'result' => false, - 'error' => Tools::displayError('Invalid quantity.'), - ))); - } - $rooms_booked = $obj_booking_detail->getRoomBookinInformationForDateRangeByOrder($id_room, $old_date_from, $old_date_to, $new_date_from, $new_date_to); - if ($rooms_booked) { + if ($rooms_booked = $obj_booking_detail->getRoomBookinInformationForDateRangeByOrder( + $id_room, + $old_date_from, + $old_date_to, + $new_date_from, + $new_date_to + )) { die(json_encode(array( 'result' => false, 'error' => Tools::displayError('This room is unavailable for selected duration.'), @@ -5834,101 +5860,6 @@ class AdminOrdersControllerCore extends AdminController ); } - /** - * @param OrderDetail $order_detail - * @param int $qty_cancel_product - * @param bool $delete - */ - protected function reinjectQuantity($order_detail, $qty_cancel_product, $delete = false) - { - // Reinject product - $reinjectable_quantity = (int)$order_detail->product_quantity - (int)$order_detail->product_quantity_reinjected; - $quantity_to_reinject = $qty_cancel_product > $reinjectable_quantity ? $reinjectable_quantity : $qty_cancel_product; - // @since 1.5.0 : Advanced Stock Management - $product_to_inject = new Product($order_detail->product_id, false, (int)$this->context->language->id, (int)$order_detail->id_shop); - - $product = new Product($order_detail->product_id, false, (int)$this->context->language->id, (int)$order_detail->id_shop); - - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management && $order_detail->id_warehouse != 0) { - $manager = StockManagerFactory::getManager(); - $movements = StockMvt::getNegativeStockMvts( - $order_detail->id_order, - $order_detail->product_id, - $order_detail->product_attribute_id, - $quantity_to_reinject - ); - $left_to_reinject = $quantity_to_reinject; - foreach ($movements as $movement) { - if ($left_to_reinject > $movement['physical_quantity']) { - $quantity_to_reinject = $movement['physical_quantity']; - } - - $left_to_reinject -= $quantity_to_reinject; - if (Pack::isPack((int)$product->id)) { - // Gets items - if ($product->pack_stock_type == 1 || $product->pack_stock_type == 2 || ($product->pack_stock_type == 3 && Configuration::get('PS_PACK_STOCK_TYPE') > 0)) { - $products_pack = Pack::getItems((int)$product->id, (int)Configuration::get('PS_LANG_DEFAULT')); - // Foreach item - foreach ($products_pack as $product_pack) { - if ($product_pack->advanced_stock_management == 1) { - $manager->addProduct( - $product_pack->id, - $product_pack->id_pack_product_attribute, - new Warehouse($movement['id_warehouse']), - $product_pack->pack_quantity * $quantity_to_reinject, - null, - $movement['price_te'], - true - ); - } - } - } - if ($product->pack_stock_type == 0 || $product->pack_stock_type == 2 || - ($product->pack_stock_type == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 0 || Configuration::get('PS_PACK_STOCK_TYPE') == 2))) { - $manager->addProduct( - $order_detail->product_id, - $order_detail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantity_to_reinject, - null, - $movement['price_te'], - true - ); - } - } else { - $manager->addProduct( - $order_detail->product_id, - $order_detail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantity_to_reinject, - null, - $movement['price_te'], - true - ); - } - } - - $id_product = $order_detail->product_id; - if ($delete) { - $order_detail->delete(); - } - StockAvailable::synchronize($id_product); - } elseif ($order_detail->id_warehouse == 0) { - StockAvailable::updateQuantity( - $order_detail->product_id, - $order_detail->product_attribute_id, - $quantity_to_reinject, - $order_detail->id_shop - ); - - if ($delete) { - $order_detail->delete(); - } - } else { - $this->errors[] = Tools::displayError('This product cannot be re-stocked.'); - } - } - /** * @param OrderInvoice $order_invoice * @param float $value_tax_incl @@ -6996,14 +6927,23 @@ class AdminOrdersControllerCore extends AdminController // if room is changing in the reallocation if ($objHotelBooking->id_product != $idNewRoomType) { $result['has_room_type_change'] = 1; + // set context currency So that we can get prices in the order currency + $objOrder = new Order($objHotelBooking->id_order); + $this->context->currency = new Currency($objOrder->id_currency); $newRoomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice( $idNewRoomType, $objHotelBooking->date_from, - $objHotelBooking->date_to + $objHotelBooking->date_to, + 0, + 0, + 0, + 0, + 0, + 0 ); if ($objHotelBooking->total_price_tax_excl != $newRoomTotalPrice['total_price_tax_excl']) { $result['has_price_changes'] = 1; - $result['price_diff'] = $newRoomTotalPrice['total_price_tax_excl'] - $objHotelBooking->total_price_tax_excl; + $result['price_diff'] = Tools::ps_round(($newRoomTotalPrice['total_price_tax_excl'] - $objHotelBooking->total_price_tax_excl), 6); } } } else { @@ -7015,4 +6955,4 @@ class AdminOrdersControllerCore extends AdminController $this->ajaxDie(json_encode($result)); } -} +} \ No newline at end of file diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 811207d39..6b58c036b 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -201,13 +201,15 @@ class AdminProductsControllerCore extends AdminController 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`))'; + 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`)) + LEFT JOIN `'._DB_PREFIX_.'htl_advance_payment` hap ON (hap.`id_product` = 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 .= ' a.`show_at_front`, (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`, 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'; + $this->_select .= ', IFNULL(hap.`active`, 0) AS advance_payment'; + $this->_select .= ', IF(IFNULL(hap.`active`, 0), 1, 0) badge_success, IF(IFNULL(hap.`active`, 0), 0, 1) badge_danger '; 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.') '; @@ -245,9 +247,10 @@ class AdminProductsControllerCore extends AdminController ); } else { $hotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1); + $hotelsArray = array(); foreach ($hotels as $hotel) { $addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']); - $this->hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city']; + $hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city']; } $this->fields_list['hotel_name'] = array( @@ -256,7 +259,7 @@ class AdminProductsControllerCore extends AdminController 'multiple' => true, 'operator' => 'or', 'filter_key' => 'hrt!id_hotel', - 'list' => $this->hotelsArray, + 'list' => $hotelsArray, 'optional' => true, 'class' => 'chosen', 'visible_default' => true, @@ -318,10 +321,23 @@ class AdminProductsControllerCore extends AdminController 'optional' => true, ); + $this->fields_list['show_at_front'] = array( + 'title' => $this->l('Show at front'), + 'align' => 'text-center', + 'type' => 'bool', + 'active' => 'show_at_front', + 'optional' => true, + 'havingFilter' => true, + 'visible_default' => true, + 'orderby' => false, + ); + if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) { $this->fields_list['advance_payment'] = array( 'title' => $this->l('Advance Payment'), - 'active' => 'advance_payment', + 'callback' => 'getAdvancePaymentStatus', + 'badge_success' => true, + 'badge_danger' => true, 'align' => 'text-center', 'type' => 'bool', 'optional' => true, @@ -399,7 +415,7 @@ class AdminProductsControllerCore extends AdminController $idLocationsCategory = Configuration::get('PS_LOCATIONS_CATEGORY'); $this->objLocationsCategory = new Category($idLocationsCategory, $this->context->language->id); $nestedCategories = Category::getNestedCategories($idLocationsCategory); - if ($nestedCategories) { + if (isset($nestedCategories[$idLocationsCategory]['children']) && $nestedCategories[$idLocationsCategory]['children']) { foreach ($nestedCategories[$idLocationsCategory]['children'] as $childCategory) { $this->buildCategoryOptions($childCategory); } @@ -430,6 +446,18 @@ class AdminProductsControllerCore extends AdminController } } + public function getAdvancePaymentStatus($val, $row) + { + if ($val) { + $str_return = $this->l('Yes'); + } else { + $str_return = $this->l('No'); + } + + return $str_return; + } + + private function buildCategoryOptions($category) { $space = str_repeat(' ', 5 * (($category['level_depth'] - $this->objLocationsCategory->level_depth) - 1)); @@ -815,6 +843,13 @@ class AdminProductsControllerCore extends AdminController if (!$id_hotel_new) { $id_hotel_new = $room_type_info['id_hotel']; } + + if ($product->hasAttributes()) { + Product::updateDefaultAttribute($product->id); + } else { + Product::duplicateSpecificPrices($id_product_old, $product->id); + } + $id_room_type_new = HotelRoomType::duplicateRoomType( $id_product_old, $product->id, @@ -838,11 +873,6 @@ class AdminProductsControllerCore extends AdminController } else { $this->errors[] = Tools::displayError('An error occurred while duplicating room type.'); } - if ($product->hasAttributes()) { - Product::updateDefaultAttribute($product->id); - } else { - Product::duplicateSpecificPrices($id_product_old, $product->id); - } if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { $this->errors[] = Tools::displayError('An error occurred while copying images.'); @@ -1089,16 +1119,18 @@ class AdminProductsControllerCore extends AdminController } $id_product = Tools::getValue('id_product'); - $id_adv_pmt = Tools::getValue('id_adv_pmt'); if ($id_adv_pmt) { $obj_adv_pmt = new HotelAdvancedPayment($id_adv_pmt); } else { $obj_adv_pmt = new HotelAdvancedPayment(); + if ($adv_pmt_info = $obj_adv_pmt->getIdAdvPaymentByIdProduct($id_product)) { + // To prevent duplication from two separate tabs + $obj_adv_pmt = new HotelAdvancedPayment((int) $adv_pmt_info['id']); + } } $adv_payment_active = Tools::getValue('adv_payment_active'); - $obj_adv_pmt->id_product = $id_product; $obj_adv_pmt->active = $adv_payment_active; @@ -1333,10 +1365,10 @@ 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)) { + // Toggle Show at front + elseif (Tools::getIsset('show_at_front'.$this->table)) { if ($this->tabAccess['edit'] === '1') { - $this->action = 'toggleAdvancePayment'; + $this->action = 'toggleShowAtFront'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } @@ -1454,6 +1486,7 @@ class AdminProductsControllerCore extends AdminController if (in_array($this->display, array('add', 'edit')) && $this->tabAccess[$this->display] == '1' + && $this->loadObject(true) ) { $this->addJqueryUI(array( 'ui.core', @@ -1893,38 +1926,21 @@ class AdminProductsControllerCore extends AdminController return $res; } - public function processToggleAdvancePayment() + public function processToggleShowAtFront() { - if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) { - $this->loadObject(true); - if (!Validate::isLoadedObject($this->object)) { - return false; - } + if (!$this->loadObject()) { + return false; + } - if (!Product::isBookingProduct($this->object->id)) { - 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.'); - } + $this->object->show_at_front = !$this->object->show_at_front; + if ($this->object->save()) { + Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=4'); + } else { + $this->errors[] = $this->l('An error occurred while updating "show at front".'); } } @@ -2199,10 +2215,14 @@ class AdminProductsControllerCore extends AdminController } if (!$res) { - $this->errors[] = sprintf( - Tools::displayError('The %s field is invalid.'), - call_user_func(array($className, 'displayFieldName'), $field, $className) - ); + if (Tools::strtolower($field) == 'wholesale_price') { + $this->errors[] = Tools::displayError('The Pre-tax operating cost field is invalid.'); + } else { + $this->errors[] = sprintf( + Tools::displayError('The %s field is invalid.'), + call_user_func(array($className, 'displayFieldName'), $field, $className) + ); + } } } } @@ -2456,7 +2476,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Occupied Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=occupied_rooms'; - $helper->tooltip = $this->l('The current count of rooms that are currently occupied by guests.', null, null, false); + $helper->tooltip = $this->l('The count of rooms that are currently occupied by guests.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2466,7 +2486,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Vacant Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=vacant_rooms'; - $helper->tooltip = $this->l('The count of rooms that are currently unoccupied and available for booking.', null, null, false); + $helper->tooltip = $this->l('The count of rooms that are either booked but currently unoccupied or available for booking', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2476,7 +2496,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Booked Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=booked_rooms'; - $helper->tooltip = $this->l('The number of rooms that are currently booked but not yet occupied.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that are currently booked and and awaiting guest check-in', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2486,7 +2506,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Disabled Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_rooms'; - $helper->tooltip = $this->l('The number of rooms that are currently disabled.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that are currently disabled.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2496,7 +2516,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Online Bookable Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=online_bookable_rooms'; - $helper->tooltip = $this->l('The total number of rooms that can be booked only using website.', null, null, false); + $helper->tooltip = $this->l('The total number of rooms that can be booked directly from the front office.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2506,7 +2526,7 @@ class AdminProductsControllerCore extends AdminController $helper->title = $this->l('Offline Bookable Rooms', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=offline_bookable_rooms'; - $helper->tooltip = $this->l('The number of rooms that can be booked either through website or offline channels (e.g., phone or in-person).', null, null, false); + $helper->tooltip = $this->l('The total number of rooms available for booking through the back office.', null, null, false); $kpis[] = $helper; $helper = new HelperKpi(); @@ -2843,9 +2863,7 @@ class AdminProductsControllerCore extends AdminController } // let's calculate this once for all - if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) { - $this->errors[] = 'Unable to load object'; - } else { + if ($this->loadObject(true)) { $this->_displayDraftWarning($this->object->active); // if there was an error while saving, we don't want to lose posted data @@ -3178,12 +3196,8 @@ class AdminProductsControllerCore extends AdminController $objRoomTypeServiceProductPrice->id_element = $idProduct; $objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE; } - $objRoomTypeServiceProductPrice->price = $price; - if ($idTaxRulesGroup) { - $objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup; - } - + $objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup; $objRoomTypeServiceProductPrice->save(); } else { // create new association @@ -3274,22 +3288,26 @@ class AdminProductsControllerCore extends AdminController $this->errors[] = Tools::displayError('Invalid base children'); } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { if ($baseChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - $this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); + $this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); } } if (!$maxAdults || !Validate::isUnsignedInt($maxAdults)) { $this->errors[] = Tools::displayError('Invalid maximum number of adults'); } elseif ($maxAdults < $baseAdults) { $this->errors[] = Tools::displayError('Maximum number of adults cannot be less than base adults'); + } elseif ($maxAdults > $maxGuests) { + $this->errors[] = Tools::displayError('Maximum number of adults cannot be more than maximum number of guests'); } if ($maxChildren == '' || !Validate::isUnsignedInt($maxChildren)) { $this->errors[] = Tools::displayError('Invalid maximum number of children'); - } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { - $this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); - } } elseif ($maxChildren < $baseChildren) { $this->errors[] = Tools::displayError('Maximum number of children cannot be less than base children'); + } elseif ($maxChildren >= $maxGuests) { + $this->errors[] = Tools::displayError('Maximum number of children cannot be more or equal than maximum number of guests.(1 adult is mandatory in a room)'); + } else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { + if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) { + $this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')); + } } if (!$maxGuests || !Validate::isUnsignedInt($maxGuests)) { $this->errors[] = Tools::displayError('Invalid maximum number of guests'); @@ -3672,6 +3690,7 @@ class AdminProductsControllerCore extends AdminController public function processAdditionalFacilities() { if ($idProduct = Tools::getValue('id_product')) { + $errors = array(); $objRoomTypeDemand = new HotelRoomTypeDemand(); $objRoomTypeDemandPrice = new HotelRoomTypeDemandPrice(); // first delete all the previously saved prices and demands of this room type @@ -3699,7 +3718,7 @@ class AdminProductsControllerCore extends AdminController $objRoomTypeDemandPrice->save(); } } else { - $this->errors[] = Tools::displayError('Invalid demand price of facility.'). + $errors[] = Tools::displayError('Invalid demand price of facility.'). ' : '.$objGlobalDemand->name[$this->context->language->id]; } if ($advOptions = $objAdvOption->getGlobalDemandAdvanceOptions($idGlobalDemand)) { @@ -3716,15 +3735,16 @@ class AdminProductsControllerCore extends AdminController $objRoomTypeDemandPrice->save(); } } else { - $this->errors[] = Tools::displayError('Invalid price of advanced option: ').$objAdvOption->name[$this->context->language->id]; + $errors[] = Tools::displayError('Invalid price of advanced option: ').$objAdvOption->name[$this->context->language->id]; } } } } } } - if (count($this->errors)) { - $this->warnings[] = Tools::displayError('Invalid price values are not saved. Please correct them and save again.'); + if (count($errors)) { + $this->warnings[] = Tools::displayError('Invalid price values for additional facilities were not saved. Please correct them and try again.'); + $this->errors = array_merge($this->errors, $errors); } $objCartBookingData = new HotelCartBookingData(); @@ -3910,7 +3930,7 @@ class AdminProductsControllerCore extends AdminController } else { $address->id_country = (int)$address_infos['id_country']; $address->id_state = (int)$address_infos['id_state']; - $address->zipcode = $address_infos['postcode']; + $address->postcode = $address_infos['postcode']; } $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true); diff --git a/controllers/admin/AdminRequestSqlController.php b/controllers/admin/AdminRequestSqlController.php index a8e5507b1..068face35 100644 --- a/controllers/admin/AdminRequestSqlController.php +++ b/controllers/admin/AdminRequestSqlController.php @@ -283,11 +283,9 @@ class AdminRequestSqlControllerCore extends AdminController $this->initToolbar(); $this->initPageHeaderToolbar(); if ($this->display == 'edit' || $this->display == 'add') { - if (!$this->loadObject(true)) { - return; + if ($this->loadObject(true)) { + $this->content .= $this->renderForm(); } - - $this->content .= $this->renderForm(); } elseif ($this->display == 'view') { // Some controllers use the view action without an object if ($this->className) { diff --git a/controllers/admin/AdminSpecificPriceRuleController.php b/controllers/admin/AdminSpecificPriceRuleController.php index 4694f46e3..783aced1d 100644 --- a/controllers/admin/AdminSpecificPriceRuleController.php +++ b/controllers/admin/AdminSpecificPriceRuleController.php @@ -172,6 +172,7 @@ class AdminSpecificPriceRuleControllerCore extends AdminController 'name' => 'name', 'maxlength' => 32, 'required' => true, + 'col' => 3, 'hint' => $this->l('Forbidden characters').' <>;=#{}' ), array( @@ -222,8 +223,8 @@ class AdminSpecificPriceRuleControllerCore extends AdminController 'name' => 'price', 'disabled' => ($this->object->price == -1 ? 1 : 0), 'maxlength' => 10, - 'suffix' => $this->context->currency->getSign('right'), - + 'suffix' => $this->context->currency->sign, + 'col' => 3, ), array( 'type' => 'checkbox', @@ -279,6 +280,7 @@ class AdminSpecificPriceRuleControllerCore extends AdminController 'type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', + 'col' => 3, 'required' => true, ), ), @@ -297,16 +299,12 @@ class AdminSpecificPriceRuleControllerCore extends AdminController ); $price = $this->getFieldValue($this->object, 'price'); - if ($price != -1 && Validate::isPrice($price)) { - $price = number_format($price, 6); - } else { + if ($price == -1 || !Validate::isPrice($price)) { $price = ''; } $reduction = $this->getFieldValue($this->object, 'reduction'); - if (Validate::isPrice($reduction)) { - $reduction = number_format($reduction, 6); - } else { + if (!Validate::isPrice($reduction)) { $reduction = 0; } diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 2de11a362..b2ef1e69b 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -78,13 +78,15 @@ class AdminStatsControllerCore extends AdminStatsTabController return $visits; } - public static function getAbandonedCarts($date_from, $date_to) + + public static function getAbandonedCarts($date_from, $date_to, $timeDiff = false) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' - SELECT COUNT(DISTINCT id_guest) - FROM `'._DB_PREFIX_.'cart` - WHERE `date_add` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'" - AND NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'orders` WHERE `'._DB_PREFIX_.'orders`.id_cart = `'._DB_PREFIX_.'cart`.id_cart) + SELECT COUNT(`id_cart`) + FROM `'._DB_PREFIX_.'cart` c + WHERE `date_add` BETWEEN "'.pSQL($date_from).'" AND "'.pSQL($date_to).'"'. + (($timeDiff) ? 'AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', `date_add`)) > '.$timeDiff : ' ').' + AND NOT EXISTS (SELECT 1 FROM `'._DB_PREFIX_.'orders` o WHERE o.`id_cart` = c.`id_cart`) '.Shop::addSqlRestriction()); } @@ -571,20 +573,20 @@ class AdminStatsControllerCore extends AdminStatsTabController { $sql = 'SELECT p.`id_product`, ( - SELECT IFNULL(SUM(ROUND((DATEDIFF(LEAST(hbd.`date_to`, "'.pSQL($dateTo).'"), GREATEST(hbd.`date_from`, "'.pSQL($dateFrom).'")) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)) * hbd.`total_price_tax_excl`, 2)), 0) + SELECT count(hbd.`id_product`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`) WHERE hbd.`id_product` = p.`id_product` AND o.`valid` = 1 AND hbd.`date_to` > "'.pSQL($dateFrom).'" AND hbd.`date_from` < "'.pSQL($dateTo).'" - ) AS totalRevenue - FROM `'._DB_PREFIX_.'product` p + ) as total_booked FROM `'._DB_PREFIX_.'product` p INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = p.`id_product`) - WHERE p.`active` = 1 AND p.`booking_product` = 1'. + WHERE p.`active` = 1 AND p.`booking_product` = 1 '. (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hrt') : '').' - HAVING totalRevenue > 0 - ORDER BY totalRevenue DESC'; + GROUP By p.`id_product` + HAVING total_booked > 0 + ORDER BY total_booked DESC'; return Db::getInstance()->getValue($sql); } @@ -638,7 +640,11 @@ class AdminStatsControllerCore extends AdminStatsTabController break; case 'abandoned_cart': - $value = AdminStatsController::getAbandonedCarts(date('Y-m-d H:i:s', strtotime('-2 day')), date('Y-m-d H:i:s', strtotime('-1 day'))); + $value = AdminStatsController::getAbandonedCarts( + date('Y-m-d', strtotime('-2 day')).' 0:0:0', + date('Y-m-d', strtotime('-1 day')).' 23:59:59', + _TIME_1_DAY_ + ); break; case 'installed_modules': @@ -850,20 +856,36 @@ class AdminStatsControllerCore extends AdminStatsTabController break; case 'occupied_rooms': - $value = AdminStatsController::getOccupiedRooms(0); + $value = AdminStatsController::getDistinctRoomBookingsCount( + date('Y-m-d', strtotime('-1 day')), + date('Y-m-d'), + 0, + HotelBookingDetail::STATUS_CHECKED_IN + ); break; case 'vacant_rooms': - $totalAvailableRooms = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, 0); - $totalAvailableRooms = $totalAvailableRooms[strtotime(date('Y-m-d'))]; - $totalOccupiedRooms = AdminStatsController::getOccupiedRooms(0); - $value = $totalAvailableRooms - $totalOccupiedRooms; + $totalUnAvailRooms = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, 0); + $totalUnAvailRooms = $totalUnAvailRooms[strtotime(date('Y-m-d'))]; + $totalRooms = AdminStatsController::getTotalRooms(0); + $totalOccupiedRooms = AdminStatsController::getDistinctRoomBookingsCount( + date('Y-m-d', strtotime('-1 day')), + date('Y-m-d'), + 0, + HotelBookingDetail::STATUS_CHECKED_IN + ); + $value = $totalRooms - ($totalUnAvailRooms + $totalOccupiedRooms); break; case 'booked_rooms': - $value = AdminStatsController::getBookedRooms(0); + $value = AdminStatsController::getDistinctRoomBookingsCount( + date('Y-m-d'), + date('Y-m-d', strtotime('+1 day')), + 0, + HotelBookingDetail::STATUS_ALLOTED + ); break; @@ -959,6 +981,12 @@ class AdminStatsControllerCore extends AdminStatsTabController case 'average_lead_time': $dateToday = date('Y-m-d'); $value = Tools::ps_round(AdminStatsController::getAverageLeadTime(), 2); + if ($value && $value <= 1) { + $value .= ' '.$this->l('day'); + } else { + $value .= ' '.$this->l('days'); + } + break; case 'average_guest_in_booking': $dateToday = date('Y-m-d'); @@ -1097,13 +1125,14 @@ class AdminStatsControllerCore extends AdminStatsTabController ); } - public static function getTotalRooms($idHotel = null) + public static function getTotalRooms($idHotel = null, $active = null) { $sql = 'SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hri.`id_product`) WHERE p.`booking_product` = 1 '. + (!is_null($active) ? ' AND p.`active` ='.(int) $active : ' '). (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hri') : ''); return Db::getInstance()->getValue($sql); @@ -1117,16 +1146,7 @@ class AdminStatsControllerCore extends AdminStatsTabController $occupancyData = array('count_total' => 0, 'count_occupied' => 0, 'count_available' => 0, 'count_unavailable' => 0); - $countTotal = Db::getInstance()->getValue( - 'SELECT COUNT(hri.`id`) - FROM `'._DB_PREFIX_.'htl_room_information` hri - INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi - ON (hbi.`id` = hri.`id_hotel`) - LEFT JOIN `'._DB_PREFIX_.'product` p - ON (p.`id_product` = hri.`id_product`) - WHERE p.`active` = 1'. - HotelBranchInformation::addHotelRestriction($idsHotel, 'hri') - ); + $countTotal = self::getTotalRooms($idsHotel, true); $occupancyData['count_total'] = $countTotal; // Occupied rooms are booked rooms that are not refunded in the date range @@ -1411,7 +1431,27 @@ class AdminStatsControllerCore extends AdminStatsTabController return $result; } - public static function getTotalOccupiedRooms($dateFrom, $dateTo, $idHotel = null) + public static function getDistinctRoomBookingsCount($dateFrom = false, $dateTo = false, $idHotel = null, $roomBookingStatus = null) + { + $sql = 'SELECT COUNT(DISTINCT hbd.`id_room`) + FROM `'._DB_PREFIX_.'htl_booking_detail` hbd + LEFT JOIN `'._DB_PREFIX_.'htl_room_information` hri + ON (hri.`id` = hbd.`id_room`) + LEFT JOIN `'._DB_PREFIX_.'product` p + ON (p.`id_product` = hri.`id_product`) + WHERE p.`active` = 1 + AND hbd.`is_refunded` = 0 + AND hbd.`is_cancelled` = 0 '. + (($dateFrom && $dateTo) ? ' AND hbd.`date_from` <= "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00" ': ' '). + (!is_null($roomBookingStatus) ? ' AND hbd.`id_status` = '.(int) $roomBookingStatus : ' '). + (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); + $result = Db::getInstance()->getValue($sql); + + return $result ? $result : 0; + + } + + public static function getTotalBookedRooms($dateFrom, $dateTo, $idHotel = null) { $sql = 'SELECT COUNT(hbd.`id_room`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd @@ -1789,46 +1829,6 @@ class AdminStatsControllerCore extends AdminStatsTabController return $result; } - /** - * Returns the number of rooms that have been checked-in. - */ - public static function getOccupiedRooms($idHotel = null) - { - $sql = 'SELECT COUNT(DISTINCT hbd.`id_room`) - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - LEFT JOIN `'._DB_PREFIX_.'htl_room_information` hri - ON (hri.`id` = hbd.`id_room`) - LEFT JOIN `'._DB_PREFIX_.'product` p - ON (p.`id_product` = hri.`id_product`) - WHERE p.`active` = 1 - AND hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 - AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN. - (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); - $result = Db::getInstance()->getValue($sql); - - return $result; - } - - /** - * Returns the number of rooms that have been booked but not checked-in yet. - */ - public static function getBookedRooms($idHotel = null) - { - $dateToday = date('Y-m-d'); - - $sql = 'SELECT COUNT(DISTINCT hbd.`id_room`) - FROM `'._DB_PREFIX_.'htl_booking_detail` hbd - WHERE hbd.`is_refunded` = 0 - AND hbd.`is_cancelled` = 0 - AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_ALLOTED.' - AND hbd.`date_from` = "'.pSQL($dateToday).' 00:00:00"'. - (!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : ''); - $result = Db::getInstance()->getValue($sql); - - return $result; - } - public static function getTotalFrequentCustomers($nbOrders = 5, $idHotel = null) { $sql = 'SELECT COUNT(t.`id_customer`) @@ -1885,7 +1885,7 @@ class AdminStatsControllerCore extends AdminStatsTabController public static function getTotalNewCustomers($nbDaysNewCustomers) { - $maxDateAdd = date('Y-m-d H:i:s', strtotime('-'.$nbDaysNewCustomers.' day')); + $maxDateAdd = date('Y-m-d', strtotime('-'.$nbDaysNewCustomers.' day')); $sql = 'SELECT COUNT(c.`id_customer`) FROM `'._DB_PREFIX_.'customer` c WHERE c.`date_add` >= "'.pSQL($maxDateAdd).'" AND c.`deleted` = 0'; @@ -1970,7 +1970,7 @@ class AdminStatsControllerCore extends AdminStatsTabController $nightsBookedByDate = self::getRoomNightsData($dateFrom, $dateTo, $idHotel); $totalNightsBooked = array_sum($nightsBookedByDate); - $totalOccupiedRoom = self::getTotalOccupiedRooms($dateFrom, $dateTo, $idHotel); + $totalOccupiedRoom = self::getTotalBookedRooms($dateFrom, $dateTo, $idHotel); return $totalOccupiedRoom ? ($totalNightsBooked / $totalOccupiedRoom) : 0; } diff --git a/controllers/admin/AdminStatusesController.php b/controllers/admin/AdminStatusesController.php index e10140b77..aadb4ee44 100644 --- a/controllers/admin/AdminStatusesController.php +++ b/controllers/admin/AdminStatusesController.php @@ -707,6 +707,15 @@ class AdminStatusesControllerCore extends AdminController $theme = new Theme($this->context->shop->id_theme); $default_path = '../mails/'; $theme_path = '../themes/'.$theme->directory.'/mails/'; // Mail templates can also be found in the theme folder + $templatesToIgnore = array( + 'footer.html', + 'header.html', + 'shipped.html', + 'in_transit.html', + 'download_products.html', + 'header_order_conf.html', + 'test.html' + ); $array = array(); foreach (Language::getLanguages(false) as $language) { @@ -722,7 +731,9 @@ class AdminStatusesControllerCore extends AdminController // We merge all available emails in one array $templates = array_unique(array_merge(scandir(_PS_ADMIN_DIR_.'/'.$default_path.$iso_code), $theme_templates)); foreach ($templates as $key => $template) { - if (!strncmp(strrev($template), 'lmth.', 5)) { + if (!strncmp(strrev($template), 'lmth.', 5) + && !in_array($template, $templatesToIgnore) + ) { $search_result = array_search($template, $theme_templates); $array[$iso_code][] = array( 'id' => substr($template, 0, -5), diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index df1f46d29..09470ad22 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -186,8 +186,8 @@ class AdminThemesControllerCore extends AdminController 'thumb' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_FAVICON').(Tools::getValue('conf') ? sprintf('?%04d', rand(0, 9999)) : '')) ), 'PS_STORES_ICON' => array( - 'title' => $this->l('Store icon'), - 'hint' => $this->l('Will appear on the store locator (inside Google Maps).').'
    '.$this->l('Suggested size: 30x30, transparent GIF.'), + 'title' => $this->l('Map icon'), + 'hint' => $this->l('This icon will be displayed at hotel locations on Google Maps.').'
    '.$this->l('Suggested size: 30x30, transparent GIF.'), 'type' => 'file', 'name' => 'PS_STORES_ICON', 'tab' => 'icons', @@ -677,6 +677,8 @@ class AdminThemesControllerCore extends AdminController if (!count($this->errors)) { Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes').'&conf=6'); + } else { + $this->redirect_after = ''; } } @@ -1981,7 +1983,7 @@ class AdminThemesControllerCore extends AdminController } } if ($xml_version_too_old && !$this->_checkConfigForFeatures(array_keys(AdminThemes::$check_features))) { - $this->errors[] .= Tools::displayError('The config.xml file has not been created for this version of PrestaShop.'); + $this->errors[] = Tools::displayError('The config.xml file has not been created for this version of QloApps.'); $return = false; } diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 5f275f62d..8b5dcfb04 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -954,7 +954,7 @@ class AdminTranslationsControllerCore extends AdminController * * @throws PrestaShopException */ - protected function findAndWriteTranslationsIntoFile($file_name, $files, $theme_name, $module_name, $dir = false) + protected function findAndWriteTranslationsIntoFile($file_name, $files, $theme_name, $module_name, $dir = false, $copyExistingTranslations = false) { // These static vars allow to use file to write just one time. static $cache_file = array(); @@ -964,7 +964,12 @@ class AdminTranslationsControllerCore extends AdminController // Set file_name in static var, this allow to open and wright the file just one time if (!isset($cache_file[$theme_name.'-'.$file_name])) { - require $file_name; + if (file_exists($file_name)) { + require $file_name; + } else { + $_MODULE = array(); + } + $module_existing_translations = $_MODULE; $str_write = ''; $cache_file[$theme_name.'-'.$file_name] = true; @@ -1010,25 +1015,26 @@ class AdminTranslationsControllerCore extends AdminController } if (array_key_exists($post_key, $_POST) && !in_array($pattern, $array_check_duplicate)) { + $array_check_duplicate[] = $pattern; if ($_POST[$post_key] == '') { continue; } - $array_check_duplicate[] = $pattern; $str_write .= '$_MODULE['.$pattern.'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $_POST[$post_key])).'\';'."\n"; $this->total_expression++; } } - foreach ($module_existing_translations as $key => $value) { - if (!in_array('\''.$key.'\'', $array_check_duplicate)) { - $str_write .= '$_MODULE[\''.$key.'\'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $value)).'\';'."\n"; - - } - } - } } - if (isset($cache_file[$theme_name.'-'.$file_name]) && $str_write != " $value) { + if (!in_array('\''.$key.'\'', $array_check_duplicate)) { + $str_write .= '$_MODULE[\''.$key.'\'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $value)).'\';'."\n"; + } + } + } + + if (isset($cache_file[$theme_name.'-'.$file_name])) { file_put_contents($file_name, $str_write); } } @@ -1056,6 +1062,8 @@ class AdminTranslationsControllerCore extends AdminController unset($files[$key]); } elseif ($type_clear === 'directory' && (!is_dir($path.$file) || in_array($file, $arr_exclude))) { unset($files[$key]); + } else if ($file == 'index.php') { + unset($files[$key]); } } @@ -1468,8 +1476,15 @@ class AdminTranslationsControllerCore extends AdminController $arr_files = $this->getAllModuleFiles($modules, null, $this->lang_selected->iso_code, true); // Find and write all translation modules files - foreach ($arr_files as $value) { - $this->findAndWriteTranslationsIntoFile($value['file_name'], $value['files'], $value['theme'], $value['module'], $value['dir']); + foreach ($arr_files as $key => $value) { + $copyExistingTranslations = false; + if (!isset($arr_files[$key + 1]) + || ($arr_files[$key + 1]['module'] != $value['module']) + ) { + $copyExistingTranslations = true; + } + + $this->findAndWriteTranslationsIntoFile($value['file_name'], $value['files'], $value['theme'], $value['module'], $value['dir'], $copyExistingTranslations); } // Clear modules cache diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index fe8caa4a3..a706b5ede 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -438,6 +438,12 @@ class AuthControllerCore extends FrontController $this->errors[] = Tools::displayError('You must register at least one phone number.'); } + if (!Tools::getValue('is_new_customer', 1)) { + if ($idCustomer = Customer::customerExists(Tools::getValue('email'), true, false)) { + $customer = new Customer($idCustomer); + } + } + $this->errors = array_unique(array_merge($this->errors, $customer->validateController())); // Check the requires fields which are settings in the BO @@ -601,13 +607,7 @@ class AuthControllerCore extends FrontController $customer->active = 1; // New Guest customer if (Tools::isSubmit('is_new_customer')) { - if (isset($idCustomer) && $idCustomer) { - // update guest customer details - $customer = new Customer($idCustomer); - $customer->firstname = Tools::getValue('firstname'); - $customer->lastname = Tools::getValue('lastname'); - } - $customer->is_guest = 1; + $customer->is_guest = !Tools::getValue('is_new_customer', 1); } else { $customer->is_guest = 0; } diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 3823504ab..fb3b1a784 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -59,7 +59,6 @@ class CategoryControllerCore extends FrontController $this->addCSS(_THEME_CSS_DIR_.'occupancy.css'); $this->addJS(_THEME_JS_DIR_.'occupancy.js'); - $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false); if ($scenes && count($scenes)) { $this->addJS(_THEME_JS_DIR_.'scenes.js'); @@ -101,16 +100,8 @@ class CategoryControllerCore extends FrontController // validate dates if available $dateFrom = Tools::getValue('date_from'); $dateTo = Tools::getValue('date_to'); - - $currentTimestamp = strtotime(date('Y-m-d')); - $dateFromTimestamp = strtotime($dateFrom); - $dateToTimestamp = strtotime($dateTo); - - if ($dateFrom != '' && ($dateFromTimestamp === false || ($dateFromTimestamp < $currentTimestamp))) { - Tools::redirect($this->context->link->getPageLink('pagenotfound')); - } - - if ($dateTo != '' && ($dateToTimestamp === false || ($dateToTimestamp < $currentTimestamp))) { + $idHotel = HotelBranchInformation::getHotelIdByIdCategory($id_category); + if (!HotelHelper::validateDateRangeForHotel($dateFrom, $dateTo, $idHotel)) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } @@ -165,6 +156,16 @@ class CategoryControllerCore extends FrontController $currency = new Currency($this->context->currency->id); if ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($id_category)) { + $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($id_hotel); + if ($preparationTime + && strtotime('+ '.$preparationTime.' day') >= strtotime($date_from) + ) { + $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + if (strtotime($date_from) >= strtotime($date_to)) { + $date_to = date('Y-m-d', strtotime($date_from) + 86400); + } + } + $id_cart = $this->context->cart->id; $id_guest = $this->context->cookie->id_guest; @@ -181,22 +182,6 @@ class CategoryControllerCore extends FrontController $booking_data = $objBookingDetail->dataForFrontSearch($bookingParams); - // set default occupancies in required format - if (isset($booking_data['rm_data']) && $booking_data['rm_data']) { - foreach ($booking_data['rm_data'] as &$roomTypeData) { - $occupancy = array( - array( - 'adults' => $roomTypeData['adults'], - 'children' => 0, - 'child_ages' => array(), - ), - ); - - $roomTypeData['occupancies'] = $occupancy; - $roomTypeData['occupancy_adults'] = $roomTypeData['adults']; // only one room by default - } - } - $obj_booking_detail = new HotelBookingDetail(); $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to); diff --git a/controllers/front/CmsController.php b/controllers/front/CmsController.php index 01a4726bb..c855df6b4 100644 --- a/controllers/front/CmsController.php +++ b/controllers/front/CmsController.php @@ -79,8 +79,8 @@ class CmsControllerCore extends FrontController } elseif (Validate::isLoadedObject($this->cms_category) && $this->cms_category->active && $this->cms_category->isAssociatedToShop()) { $this->assignCase = 2; } else { - header('HTTP/1.1 404 Not Found'); - header('Status: 404 Not Found'); + // incase the cms page in invalid i.e, url is tampered + Tools::redirect($this->context->link->getPageLink('pagenotfound')); } } @@ -134,6 +134,9 @@ class CmsControllerCore extends FrontController 'path' => ($this->cms_category->id !== 1) ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'body_classes' => array($this->php_self.'-'.$this->cms_category->id, $this->php_self.'-'.$this->cms_category->link_rewrite) )); + } else { + // incase the cms page is inactive + Tools::redirect($this->context->link->getPageLink('pagenotfound')); } $this->setTemplate(_PS_THEME_DIR_.'cms.tpl'); diff --git a/controllers/front/ContactController.php b/controllers/front/ContactController.php index ba68dd08c..0124fb8d0 100644 --- a/controllers/front/ContactController.php +++ b/controllers/front/ContactController.php @@ -77,7 +77,7 @@ class ContactControllerCore extends FrontController SELECT cm.id_customer_thread FROM '._DB_PREFIX_.'customer_thread cm WHERE cm.id_customer_thread = '.(int)$id_customer_thread.' AND cm.id_shop = '.(int)$this->context->shop->id.' AND token = \''.pSQL(Tools::getValue('token')).'\'') ) || ( - $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order) + $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order, $id_contact) ))) { $fields = Db::getInstance()->executeS(' SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email @@ -115,99 +115,112 @@ class ContactControllerCore extends FrontController WHERE cc.id_customer_thread = '.(int)$id_customer_thread.' AND cc.id_shop = '.(int)$this->context->shop->id.' ORDER BY cm.date_add DESC'); if ($old_message == $message) { - $this->context->smarty->assign('alreadySent', 1); + $this->errors[] = Tools::displayError('Your message has already been sent.'); + $_POST = array(); $contact->email = ''; $contact->customer_service = 0; - } - - if ($contact->customer_service) { - if ((int)$id_customer_thread) { - $ct = new CustomerThread($id_customer_thread); - $ct->status = 'open'; - $ct->id_lang = (int)$this->context->language->id; - $ct->id_contact = (int)$id_contact; - $ct->id_order = (int)$id_order; - if ($id_product = (int)Tools::getValue('id_product')) { - $ct->id_product = $id_product; + } else { + if ($contact->customer_service) { + if ((int)$id_customer_thread) { + $ct = new CustomerThread($id_customer_thread); + $ct->status = 'open'; + $ct->id_lang = (int)$this->context->language->id; + $ct->id_contact = (int)$id_contact; + $ct->id_order = (int)$id_order; + if ($id_product = (int)Tools::getValue('id_product')) { + $ct->id_product = $id_product; + } + $ct->update(); + } else { + $ct = new CustomerThread(); + if (isset($customer->id)) { + $ct->id_customer = (int)$customer->id; + } + $ct->id_shop = (int)$this->context->shop->id; + $ct->id_order = (int)$id_order; + if ($id_product = (int)Tools::getValue('id_product')) { + $ct->id_product = $id_product; + } + $ct->id_contact = (int)$id_contact; + $ct->id_lang = (int)$this->context->language->id; + $ct->email = $from; + $ct->status = 'open'; + $ct->token = Tools::passwdGen(12); + $ct->add(); } - $ct->update(); - } else { - $ct = new CustomerThread(); - if (isset($customer->id)) { - $ct->id_customer = (int)$customer->id; - } - $ct->id_shop = (int)$this->context->shop->id; - $ct->id_order = (int)$id_order; - if ($id_product = (int)Tools::getValue('id_product')) { - $ct->id_product = $id_product; - } - $ct->id_contact = (int)$id_contact; - $ct->id_lang = (int)$this->context->language->id; - $ct->email = $from; - $ct->status = 'open'; - $ct->token = Tools::passwdGen(12); - $ct->add(); - } - if ($ct->id) { - $cm = new CustomerMessage(); - $cm->id_customer_thread = $ct->id; - $cm->message = $message; - if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename']))) { - $cm->file_name = $file_attachment['rename']; - @chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664); - } - $cm->ip_address = (int)ip2long(Tools::getRemoteAddr()); - $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; - if (!$cm->add()) { - $this->errors[] = Tools::displayError('An error occurred while sending the message.'); - } - } else { - $this->errors[] = Tools::displayError('An error occurred while sending the message.'); - } - } - - if (!count($this->errors)) { - $var_list = array( - '{order_name}' => '-', - '{attached_file}' => '-', - '{message}' => Tools::nl2br(stripslashes($message)), - '{email}' => $from, - '{product_name}' => '', - ); - - if (isset($file_attachment['name'])) { - $var_list['{attached_file}'] = $file_attachment['name']; - } - - $id_product = (int)Tools::getValue('id_product'); - - if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) { - $order = new Order((int)$ct->id_order); - $var_list['{order_name}'] = $order->getUniqReference(); - $var_list['{id_order}'] = (int)$order->id; - } - - if ($id_product) { - $product = new Product((int)$id_product); - if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) { - $var_list['{product_name}'] = $product->name[Context::getContext()->language->id]; - } - } - - if (!empty($contact->email)) { - if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]', - $var_list, $contact->email, $contact->name, null, null, - $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $from)) { + if ($ct->id) { + $cm = new CustomerMessage(); + $cm->id_customer_thread = $ct->id; + $cm->message = $message; + if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename']))) { + $cm->file_name = $file_attachment['rename']; + @chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664); + } + $cm->ip_address = (int)ip2long(Tools::getRemoteAddr()); + $cm->user_agent = $_SERVER['HTTP_USER_AGENT']; + if (!$cm->add()) { + $this->errors[] = Tools::displayError('An error occurred while sending the message.'); + } + } else { $this->errors[] = Tools::displayError('An error occurred while sending the message.'); } } - } - if (count($this->errors) > 1) { - array_unique($this->errors); - } elseif (!count($this->errors)) { - $this->context->smarty->assign('confirmation', 1); + if (!count($this->errors)) { + $var_list = array( + '{order_name}' => '-', + '{attached_file}' => '-', + '{message}' => Tools::nl2br(stripslashes($message)), + '{email}' => $from, + '{product_name}' => '', + ); + + if (isset($file_attachment['name'])) { + $var_list['{attached_file}'] = $file_attachment['name']; + } + + $id_product = (int)Tools::getValue('id_product'); + + if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) { + $order = new Order((int)$ct->id_order); + $var_list['{order_name}'] = $order->getUniqReference(); + $var_list['{id_order}'] = (int)$order->id; + } + + if ($id_product) { + $product = new Product((int)$id_product); + if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) { + $var_list['{product_name}'] = $product->name[Context::getContext()->language->id]; + } + } + + if (!empty($contact->email)) { + Mail::Send( + $this->context->language->id, + 'contact', + Mail::l('Message from contact form').' [no_sync]', + $var_list, + $contact->email, + $contact->name, + null, + null, + $file_attachment, + null, + _PS_MAIL_DIR_, + false, + null, + null, + $from + ); + } + } + + if (count($this->errors) > 1) { + array_unique($this->errors); + } elseif (!count($this->errors)) { + Tools::redirect($this->context->link->getPageLink('contact', null, null, array('confirm' => 1))); + } } } } @@ -222,6 +235,11 @@ class ContactControllerCore extends FrontController // GOOGLE MAP if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) { + Media::addJsDef( + array( + 'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')), + ) + ); $this->addJS( 'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY. '&libraries=places&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code @@ -295,6 +313,7 @@ class ContactControllerCore extends FrontController $this->context->smarty->assign( array( 'hotelsInfo' => $hotelsInfo, + 'viewOnMap' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'), 'gblHtlPhone' => $gblHtlPhone, 'gblHtlEmail' => $gblHtlEmail, 'gblHtlAddress' => $gblHtlAddress, @@ -312,6 +331,7 @@ class ContactControllerCore extends FrontController } } //End + $this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl'); } diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index ab05a2876..79ec067c2 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -92,10 +92,11 @@ class GuestTrackingControllerCore extends FrontController $customer = new Customer((int)$order->id_customer); if (!Validate::isLoadedObject($customer)) { $this->errors[] = Tools::displayError('Invalid customer'); - } elseif (!Tools::getValue('password')) { + } elseif (!Tools::getValue('password') + || !Validate::isPasswd(Tools::getValue('password') + )) { $this->errors[] = Tools::displayError('Invalid password.'); } elseif (!$customer->transformToCustomer($this->context->language->id, Tools::getValue('password'))) { - // @todo clarify error message $this->errors[] = Tools::displayError('An error occurred while transforming a guest into a registered customer.'); } else { $this->context->smarty->assign('transformSuccess', true); @@ -248,6 +249,7 @@ class GuestTrackingControllerCore extends FrontController $total_demands_price_ti = 0; $total_convenience_fee_te = 0; $total_convenience_fee_ti = 0; + foreach ($orderProducts as $type_key => $type_value) { if (in_array($type_value['product_id'], $processedProducts)) { continue; @@ -305,13 +307,6 @@ class GuestTrackingControllerCore extends FrontController if ($data_v['is_back_order']) { $anyBackOrder = 1; } - if ($data_v['is_refunded']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; - } - if ($data_v['is_cancelled']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1; - } } else { $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; @@ -331,15 +326,6 @@ class GuestTrackingControllerCore extends FrontController if ($data_v['is_back_order']) { $anyBackOrder = 1; } - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] = 0; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] = 0; - if ($data_v['is_refunded']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; - } - if ($data_v['is_cancelled']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1; - } } $cartHotelData[$type_key]['date_diff'][$date_join]['is_refunded'] = $data_v['is_refunded']; @@ -628,7 +614,9 @@ class GuestTrackingControllerCore extends FrontController if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($objOrder->id)) { $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); if (Validate::isLoadedObject($objHotelBranchInformation)) { - if ($apiKey = Configuration::get('PS_API_KEY')) { + if (($apiKey = Configuration::get('PS_API_KEY')) + && Configuration::get('WK_GOOGLE_ACTIVE_MAP') + ) { if (floatval($objHotelBranchInformation->latitude) != 0 && floatval($objHotelBranchInformation->longitude) != 0 ) { diff --git a/controllers/front/OrderConfirmationController.php b/controllers/front/OrderConfirmationController.php index 8c63c8907..a60326859 100644 --- a/controllers/front/OrderConfirmationController.php +++ b/controllers/front/OrderConfirmationController.php @@ -175,6 +175,7 @@ class OrderConfirmationControllerCore extends FrontController $order_bk_data = $obj_htl_bk_dtl->getOnlyOrderBookingData($idOrder, $customer->id_guest, $type_value['product_id']); } if ($rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id'])) { + $cart_htl_data[$type_key]['id_order'] = $idOrder; $cart_htl_data[$type_key]['id_product'] = $type_value['product_id']; $cart_htl_data[$type_key]['cover_img'] = $cover_img; $cart_htl_data[$type_key]['adults'] = $rm_dtl['adults']; @@ -366,9 +367,6 @@ class OrderConfirmationControllerCore extends FrontController } } - if (!empty($cart_htl_data)) { - $this->context->smarty->assign('cart_htl_data', $cart_htl_data); - } if (!empty($cart_service_products)) { $this->context->smarty->assign('cart_service_products', $cart_service_products); } @@ -399,6 +397,10 @@ class OrderConfirmationControllerCore extends FrontController $this->context->smarty->assign('orders_has_invoice', $orders_has_invoice); } + if (!empty($cart_htl_data)) { + $this->context->smarty->assign('cart_htl_data', $cart_htl_data); + } + $shw_bo_msg = Configuration::get('WK_SHOW_MSG_ON_BO'); $bo_msg = Configuration::get('WK_BO_MESSAGE'); $this->context->smarty->assign( @@ -469,6 +471,8 @@ class OrderConfirmationControllerCore extends FrontController parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'history.css'); $this->addJS(_THEME_JS_DIR_.'history.js'); + $this->addJS(_THEME_JS_DIR_.'order-confirmation.js'); + $this->addCSS(_THEME_CSS_DIR_.'order-confirmation.css'); $this->addJqueryPlugin(array('fancybox')); //fancybox not found for some client theme $this->addJqueryUI('ui.tooltip', 'base', true); } diff --git a/controllers/front/OrderDetailController.php b/controllers/front/OrderDetailController.php index afa1ea9e8..5e1da2853 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -83,339 +83,350 @@ class OrderDetailControllerCore extends FrontController } - //by webkul to show order details properly on order history page - - // if (Module::isInstalled('hotelreservationsystem')) { - // include_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php'; - // $objHtlBranchInfo = new HotelBranchInformation(); - $objBookingDetail = new HotelBookingDetail(); - $objRoomType = new HotelRoomType(); - $objBookingDemand = new HotelBookingDemands(); - $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); - $anyBackOrder = 0; - $processedProducts = array(); - $cartHotelData = array(); - $cartServiceProducts = array(); - $total_demands_price_te = 0; - $total_demands_price_ti = 0; - $total_convenience_fee_te = 0; - $total_convenience_fee_ti = 0; - if (!empty($products)) { - foreach ($products as $type_key => $type_value) { - if (in_array($type_value['product_id'], $processedProducts)) { - continue; - } - if ($type_value['is_booking_product']) { - $processedProducts[] = $type_value['product_id']; - - $product = new Product($type_value['product_id'], false, $this->context->language->id); - $cover_image_arr = $product->getCover($type_value['product_id']); - - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default'); - } else { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default'); - } - - if (isset($customer->id)) { - $obj_cart = new Cart($order->id_cart); - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); - } else { - $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); - } - $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; - $cartHotelData[$type_key]['cover_img'] = $cover_img; - - - $objBookingDemand = new HotelBookingDemands(); - foreach ($order_bk_data as $data_k => $data_v) { - $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); - - $cartHotelData[$type_key]['adults'] = $data_v['adults']; - $cartHotelData[$type_key]['children'] = $data_v['children']; - /*Product price when order was created*/ - $order_details_obj = new OrderDetail($data_v['id_order_detail']); - $cartHotelData[$type_key]['name'] = $order_details_obj->product_name; - $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; - $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; - - if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; - - $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; - $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; - $cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; - } - if ($data_v['is_refunded']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; - } - if ($data_v['is_cancelled']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1; - } - } else { - $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); - $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; - $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; - $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; - $cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; - $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; - if ($data_v['is_back_order']) { - $anyBackOrder = 1; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] = 0; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] = 0; - if ($data_v['is_refunded']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; - } - if ($data_v['is_cancelled']) { - $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; - $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1; - } - } - - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['id_htl_booking'] = $data_v['id']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['id_room'] = $data_v['id_room']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['adults'] = $data_v['adults']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['children'] = $data_v['children']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['child_ages'] = $data_v['child_ages']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['is_refunded'] = $data_v['is_refunded']; - $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['is_cancelled'] = $data_v['is_cancelled']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['is_refunded'] = $data_v['is_refunded']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id']; - $cartHotelData[$type_key]['date_diff'][$date_join]['ids_rooms'][] = $data_v['id_room']; - - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( - $id_order, - $type_value['product_id'], - 0, - $data_v['date_from'], - $data_v['date_to'] - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( - $id_order, - $type_value['product_id'], - $data_v['id_room'], - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 1 - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( - $id_order, - $type_value['product_id'], - $data_v['id_room'], - $data_v['date_from'], - $data_v['date_to'], - 0, - 1, - 0 - ); - $total_demands_price_ti += $extraDemandPriceTI; - $total_demands_price_te += $extraDemandPriceTE; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; - $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; - - $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); - $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; - - $cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name']; - // add additional services products in hotel detail. - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'] - ); - - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1 - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0 - ); - // get auto added price to be displayed with room price - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 1, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; - } - $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - 0, - 0, - $type_value['product_id'], - $data_v['date_from'], - $data_v['date_to'], - $data_v['id_room'], - 1, - 0, - 1, - Product::PRICE_ADDITION_TYPE_WITH_ROOM - ); - } - // calculate averages now - foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { - $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); - $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6); - - $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); - $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); - } - } else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) { - if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { - $total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - $type_value['product_id'], - 0, - 0, - 0, - 0, - 0, - 1, - 1, - 1 - ); - $total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( - $id_order, - $type_value['product_id'], - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 1 - ); - } - } else { - // get all products that are independent. - if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) { - $product = new Product($type_value['product_id'], false, $this->context->language->id); - $cover_image_arr = $product->getCover($type_value['product_id']); - - if (!empty($cover_image_arr)) { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); - } else { - $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); - } - $cartServiceProducts[] = $type_value; - } - } - - - } - - $redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id); - } - - $objHotelBookingDetail = new HotelBookingDetail(); - $htlBookingDetail = $objHotelBookingDetail->getOrderCurrentDataByOrderId($order->id); - $idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id); - $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); - $hotelAddressInfo = HotelBranchInformation::getAddress($idHotel); - - $objHotelBranchRefundRules = new HotelBranchRefundRules(); - $hotelRefundRules = $objHotelBranchRefundRules->getHotelRefundRules($idHotel, 0, 1); - - $this->context->smarty->assign( - array( - 'id_cms_refund_policy' => Configuration::get('WK_GLOBAL_REFUND_POLICY_CMS'), - 'THEME_DIR' => _THEME_DIR_, - 'total_convenience_fee_ti' => $total_convenience_fee_ti, - 'total_convenience_fee_te' => $total_convenience_fee_te, - 'total_demands_price_ti' => $total_demands_price_ti, - 'total_demands_price_te' => $total_demands_price_te, - 'any_back_order' => $anyBackOrder, - 'shw_bo_msg' => Configuration::get('WK_SHOW_MSG_ON_BO'), - 'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'), - 'order_has_invoice' => $order->hasInvoice(), - 'cart_htl_data' => $cartHotelData, - 'cart_service_products' => $cartServiceProducts, - 'obj_hotel_branch_information' => $objHotelBranchInformation, - 'hotel_address_info' => $hotelAddressInfo, - 'hotel_refund_rules' => $hotelRefundRules, - ) - ); - // } - + //To show order details properly on order history page + $objBookingDetail = new HotelBookingDetail(); + $objRoomType = new HotelRoomType(); + $objBookingDemand = new HotelBookingDemands(); + $objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail(); + $anyBackOrder = 0; + $processedProducts = array(); + $cartHotelData = array(); + $cartServiceProducts = array(); + $total_demands_price_te = 0; + $total_demands_price_ti = 0; + $total_convenience_fee_te = 0; + $total_convenience_fee_ti = 0; + $roomTypes = array(); $objOrderReturn = new OrderReturn(); $refundedAmount = 0; if ($refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($order->id, 0, 1)) { $refundedAmount = $objOrderReturn->getRefundedAmount($order->id); } + if (!empty($products)) { + foreach ($products as $type_key => $type_value) { + if (in_array($type_value['product_id'], $processedProducts)) { + continue; + } + if ($type_value['is_booking_product']) { + $processedProducts[] = $type_value['product_id']; + + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); + + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default'); + } else { + $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default'); + } + + if (isset($customer->id)) { + $obj_cart = new Cart($order->id_cart); + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id); + } else { + $order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']); + } + $cartHotelData[$type_key]['id_product'] = $type_value['product_id']; + $cartHotelData[$type_key]['cover_img'] = $cover_img; + + + $objBookingDemand = new HotelBookingDemands(); + foreach ($order_bk_data as $data_k => $data_v) { + $date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']); + + $cartHotelData[$type_key]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['children'] = $data_v['children']; + /*Product price when order was created*/ + $order_details_obj = new OrderDetail($data_v['id_order_detail']); + $cartHotelData[$type_key]['name'] = $order_details_obj->product_name; + $cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity; + $cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity; + + // Get last refund request for booking + if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($data_v['id_order'], 0, $data_v['id'])) { + $bookingRefundDetail = reset($bookingRefundDetail); + } + + if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1; + + $num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days']; + $var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } + + if ($refundReqBookings && in_array($data_v['id'], $refundReqBookings) && $data_v['is_refunded']) { + if ($data_v['is_cancelled']) { + $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; + } elseif ($bookingRefundDetail && $bookingRefundDetail['refunded'] && $bookingRefundDetail['id_customization']) { + $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; + } + } + } else { + $num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']); + $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from']; + $cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to']; + $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl']; + $cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order']; + if ($data_v['is_back_order']) { + $anyBackOrder = 1; + } + + $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] = 0; + $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] = 0; + if ($refundReqBookings && in_array($data_v['id'], $refundReqBookings) && $data_v['is_refunded']) { + if ($data_v['is_cancelled']) { + $cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1; + } elseif ($bookingRefundDetail && $bookingRefundDetail['refunded'] && $bookingRefundDetail['id_customization']) { + $cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1; + } + } + } + + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['id_htl_booking'] = $data_v['id']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['id_room'] = $data_v['id_room']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['adults'] = $data_v['adults']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['children'] = $data_v['children']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['child_ages'] = $data_v['child_ages']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['is_refunded'] = $data_v['is_refunded']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['is_cancelled'] = $data_v['is_cancelled']; + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['id_status'] = $data_v['id_status']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['refund_denied'] = 0; + if ($bookingRefundDetail && $bookingRefundDetail['refunded'] && !$bookingRefundDetail['id_customization']) { + $cartHotelData[$type_key]['date_diff'][$date_join]['hotel_booking_details'][$data_v['id']]['refund_denied'] = 1; + } + + $cartHotelData[$type_key]['date_diff'][$date_join]['is_refunded'] = $data_v['is_refunded']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id']; + $cartHotelData[$type_key]['date_diff'][$date_join]['ids_rooms'][] = $data_v['id_room']; + + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + 0, + $data_v['date_from'], + $data_v['date_to'] + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands( + $id_order, + $type_value['product_id'], + $data_v['id_room'], + $data_v['date_from'], + $data_v['date_to'], + 0, + 1, + 0 + ); + $total_demands_price_ti += $extraDemandPriceTI; + $total_demands_price_te += $extraDemandPriceTE; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl; + $cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl; + + $feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']); + $cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff; + + $cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name']; + // add additional services products in hotel detail. + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'] + ); + + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1 + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0 + ); + // get auto added price to be displayed with room price + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 1, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) { + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0; + } + $cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + 0, + 0, + $type_value['product_id'], + $data_v['date_from'], + $data_v['date_to'], + $data_v['id_room'], + 1, + 0, + 1, + Product::PRICE_ADDITION_TYPE_WITH_ROOM + ); + } + + // calculate averages now + foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) { + $value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6); + $value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6); + + $value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6)); + $value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6)); + } + } else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) { + if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) { + $total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1 + ); + $total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts( + $id_order, + $type_value['product_id'], + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 1 + ); + } + } else { + // get all products that are independent. + if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) { + $product = new Product($type_value['product_id'], false, $this->context->language->id); + $cover_image_arr = $product->getCover($type_value['product_id']); + + if (!empty($cover_image_arr)) { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default'); + } else { + $type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default'); + } + $cartServiceProducts[] = $type_value; + } + } + + $roomTypes[$type_value['id_product']] = $type_value; + } + + $redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id); + } + + $objHotelBookingDetail = new HotelBookingDetail(); + $htlBookingDetail = $objHotelBookingDetail->getOrderCurrentDataByOrderId($order->id); + $idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id); + $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); + $hotelAddressInfo = HotelBranchInformation::getAddress($idHotel); + + $objHotelBranchRefundRules = new HotelBranchRefundRules(); + $hotelRefundRules = $objHotelBranchRefundRules->getHotelRefundRules($idHotel, 0, 1); + + $this->context->smarty->assign( + array( + 'id_cms_refund_policy' => Configuration::get('WK_GLOBAL_REFUND_POLICY_CMS'), + 'THEME_DIR' => _THEME_DIR_, + 'total_convenience_fee_ti' => $total_convenience_fee_ti, + 'total_convenience_fee_te' => $total_convenience_fee_te, + 'total_demands_price_ti' => $total_demands_price_ti, + 'total_demands_price_te' => $total_demands_price_te, + 'any_back_order' => $anyBackOrder, + 'shw_bo_msg' => Configuration::get('WK_SHOW_MSG_ON_BO'), + 'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'), + 'order_has_invoice' => $order->hasInvoice(), + 'cart_htl_data' => $cartHotelData, + 'cart_service_products' => $cartServiceProducts, + 'obj_hotel_branch_information' => $objHotelBranchInformation, + 'hotel_address_info' => $hotelAddressInfo, + 'hotel_refund_rules' => $hotelRefundRules, + 'view_on_map' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'), + ) + ); + $this->context->smarty->assign( array( 'hasOrderPaid' => $order->hasBeenPaid(), @@ -423,7 +434,7 @@ class OrderDetailControllerCore extends FrontController 'refund_allowed' => (int) $order->isReturnable(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'refundReqBookings' => $refundReqBookings, - 'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG), + 'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(0, 1), 'refundedAmount' => $refundedAmount, 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, @@ -437,6 +448,7 @@ class OrderDetailControllerCore extends FrontController 'order_history' => $order->getHistory($this->context->language->id, false, true), 'overbooking_order_states' => OrderState::getOverBookingStates(), 'products' => $products, + 'roomTypes' => $roomTypes, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, @@ -455,6 +467,9 @@ class OrderDetailControllerCore extends FrontController 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING'), + 'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED, + 'ROOM_STATUS_CHECKED_IN' => HotelBookingDetail::STATUS_CHECKED_IN, + 'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT, ) ); @@ -561,6 +576,12 @@ class OrderDetailControllerCore extends FrontController break; } + // the room has already been checked in/checked out, room will not be able to be cancelled by the customer + if ($objHotelBookingDetail->id_status != HotelBookingDetail::STATUS_ALLOTED) { + $this->errors[] = Tools::displayError('Some selected rooms have already been checked-in/checked-out.'); + break; + } + if (OrderReturn::getOrdersReturnDetail($objOrder->id, 0, $idHtlBooking)) { $this->errors[] = Tools::displayError('Some selected rooms have already been requested for cancellation.'); break; @@ -569,66 +590,61 @@ class OrderDetailControllerCore extends FrontController } if (!count($this->errors)) { - if ((int) $objOrder->total_paid_real == 0) { + // create refund request + $objOrderReturn = new OrderReturn(); + $objOrderReturn->id_customer = $objOrder->id_customer; + $objOrderReturn->id_order = $objOrder->id; + $objOrderReturn->state = 0; + $objOrderReturn->by_admin = 0; + $objOrderReturn->question = $cancellationReason; + $objOrderReturn->refunded_amount = 0; + $objOrderReturn->save(); + if ($objOrderReturn->id) { foreach ($idsHtlBooking as $idHtlBooking) { $objHtlBooking = new HotelBookingDetail($idHtlBooking); - $objHtlBooking->save(); + $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->refunded_amount = 0; + if (!$objOrder->getCartRules() && $objOrder->getTotalPaid() <= 0) { + $objOrderReturnDetail->id_customization = 1; + } + $objOrderReturnDetail->save(); } } - // if amount paid is > 0 then create refund request else cancel the booking directly - if ($objOrder->getTotalPaid() > 0) { - $objOrderReturn = new OrderReturn(); - $objOrderReturn->id_customer = $objOrder->id_customer; - $objOrderReturn->id_order = $objOrder->id; - $objOrderReturn->state = 0; - $objOrderReturn->by_admin = 0; - $objOrderReturn->question = $cancellationReason; - $objOrderReturn->save(); - if ($objOrderReturn->id) { - foreach ($idsHtlBooking as $idHtlBooking) { - $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); - $numDays = $objHotelBookingDetail->getNumberOfDays( - $objHotelBookingDetail->date_from, - $objHotelBookingDetail->date_to - ); + // Emails to customer, superadmin and employees on refund request state change + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); - $objOrderReturnDetail = new OrderReturnDetail(); - $objOrderReturnDetail->id_order_return = $objOrderReturn->id; - $objOrderReturnDetail->id_order_detail = $objHotelBookingDetail->id_order_detail; - $objOrderReturnDetail->product_quantity = $numDays; - $objOrderReturnDetail->id_htl_booking = $idHtlBooking; - $objOrderReturnDetail->save(); - } - } - - // Emails to customer, superadmin and employees on refund request state change - $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING')); - } else { - // cancel the booking directly + if (!$objOrder->getCartRules() && $objOrder->getTotalPaid() <= 0) { + // Process refund in booking tables foreach ($idsHtlBooking as $idHtlBooking) { - $objHotelBookingDetail = new HotelBookingDetail($idHtlBooking); - if (!$objHotelBookingDetail->processRefundInBookingTables()) { - $this->errors[] = Tools::displayError('Something went wrong. Please try later.'); - } else { - // set the message for the cancellation - $message = Tools::displayError(sprintf( - "1 room from %s has been cancelled by hotel.\nReason: %s", - $objHotelBookingDetail->room_type_name, - $cancellationReason - )); - - $objHotelBookingDetail->setBookingCancellationMessage($message); + $objHtlBooking = new HotelBookingDetail($idHtlBooking); + if (!$objHtlBooking->processRefundInBookingTables()) { + $this->errors[] = Tools::displayError('An error occurred while cancelling the booking.'); } } + // complete the booking refund directly in the refund request + $objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_REFUNDED')); - // if all bookings are getting cancelled then cancel the order also - if ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) { + // if all bookings are getting cancelled/Refunded then Cancel/Refund the order also + $idOrderState = 0; + if ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_REFUND_FLAG)) { + $idOrderState = Configuration::get('PS_OS_REFUND'); + } elseif ($objOrder->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) { + $idOrderState = Configuration::get('PS_OS_CANCELED'); + } + + if ($idOrderState) { $objOrderHistory = new OrderHistory(); $objOrderHistory->id_order = (int)$objOrder->id; - $idOrderState = Configuration::get('PS_OS_CANCELED'); - $useExistingPayment = false; if (!$objOrder->hasInvoice()) { $useExistingPayment = true; @@ -782,7 +798,9 @@ class OrderDetailControllerCore extends FrontController if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder(Tools::getValue('id_order'))) { $objHotelBranchInformation = new HotelBranchInformation($idHotel, $this->context->language->id); if (Validate::isLoadedObject($objHotelBranchInformation)) { - if ($apiKey = Configuration::get('PS_API_KEY')) { + if (($apiKey = Configuration::get('PS_API_KEY')) + && Configuration::get('WK_GOOGLE_ACTIVE_MAP') + ) { if (floatval($objHotelBranchInformation->latitude) != 0 && floatval($objHotelBranchInformation->longitude) != 0 ) { @@ -793,6 +811,7 @@ class OrderDetailControllerCore extends FrontController 'map_input_text' => $objHotelBranchInformation->map_input_text, ), 'hotel_name' => $objHotelBranchInformation->hotel_name, + 'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')) )); $this->addJS( @@ -805,4 +824,4 @@ class OrderDetailControllerCore extends FrontController } } } -} +} \ No newline at end of file diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 465c6a7ca..ee809dc2f 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -173,7 +173,9 @@ class OrderOpcControllerCore extends ParentOrderController if (!count($this->errors)) { $customer = new Customer($this->context->customer->id); - if ($customer->transformToCustomer($this->context->language->id, $passwd)) { + if (!$customer->isGuest()) { + $this->errors[] = Tools::displayError('This account is already registered as a customer.'); + } else if ($customer->transformToCustomer($this->context->language->id, $passwd)) { $this->context->updateCustomer($customer); } else { $this->errors[] = Tools::displayError('An error occurred while transforming your account into a registered customer.'); @@ -424,7 +426,9 @@ class OrderOpcControllerCore extends ParentOrderController public function initContent() { // validate room types before payment by customer - $orderRestrictErr = HotelCartBookingData::validateCartBookings(); + if ($orderRestrictErr = HotelCartBookingData::validateCartBookings()) { + $this->errors = array_merge($this->errors, $orderRestrictErr); + } parent::initContent(); @@ -492,7 +496,7 @@ class OrderOpcControllerCore extends ParentOrderController // $objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $this->context->smarty->assign( array( - 'orderRestrictErr' => $orderRestrictErr, + 'orderRestrictErr' => count($orderRestrictErr) ? 1 : 0, // 'allDemands' => $allDemands, // 'defaultcurrencySign' => $objCurrency->sign, 'THEME_DIR' => _THEME_DIR_, @@ -589,7 +593,6 @@ class OrderOpcControllerCore extends ParentOrderController if (!empty($cartProducts)) { if ($cartBookingInfo = HotelCartBookingData::getHotelCartBookingData()) { - // ddd($cartBookingInfo); $this->context->smarty->assign('cart_htl_data', $cartBookingInfo); } $objHotelServiceProductCartDetail = new HotelServiceProductCartDetail(); @@ -1076,21 +1079,52 @@ class OrderOpcControllerCore extends ParentOrderController $customerGuestDetailLastname = Tools::getValue('customer_guest_detail_lastname'); $customerGuestDetailEmail = Tools::getValue('customer_guest_detail_email'); $customerGuestDetailPhone = Tools::getValue('customer_guest_detail_phone'); + + $className = 'CartCustomerGuestDetail'; + $rules = call_user_func(array($className, 'getValidationRules'), $className); + if (trim($customerGuestDetailGender) && Validate::isUnsignedInt($customerGuestDetailGender)) { $objCustomerGuestDetail->id_gender = $customerGuestDetailGender; + } else { + $result['errors']['customer_guest_detail_gender'] = Tools::displayError('Invalid gender'); } - if (trim($customerGuestDetailFirstname) && Validate::isName($customerGuestDetailFirstname)) { + + if (trim($customerGuestDetailFirstname) + && Validate::isName($customerGuestDetailFirstname) + && (!isset($rules['size']['firstname']) + || (isset($rules['size']['firstname']) && (Tools::strlen(trim($customerGuestDetailFirstname)) <= $rules['size']['firstname'])) + ) + ) { $objCustomerGuestDetail->firstname = $customerGuestDetailFirstname; } - if (trim($customerGuestDetailLastname) && Validate::isName($customerGuestDetailLastname)) { + + if (trim($customerGuestDetailLastname) + && Validate::isName($customerGuestDetailLastname) + && (!isset($rules['size']['lastname']) + || (isset($rules['size']['lastname']) && (Tools::strlen(trim($customerGuestDetailLastname)) <= $rules['size']['lastname'])) + ) + ) { $objCustomerGuestDetail->lastname = $customerGuestDetailLastname; } - if (trim($customerGuestDetailEmail) && Validate::isEmail($customerGuestDetailEmail)) { + + if (trim($customerGuestDetailEmail) + && Validate::isEmail($customerGuestDetailEmail) + && (!isset($rules['size']['email']) + || (isset($rules['size']['email']) && (Tools::strlen(trim($customerGuestDetailEmail)) <= $rules['size']['email'])) + ) + ) { $objCustomerGuestDetail->email = $customerGuestDetailEmail; } - if (trim($customerGuestDetailPhone) && Validate::isPhoneNumber($customerGuestDetailPhone)) { + + if (trim($customerGuestDetailPhone) + && Validate::isPhoneNumber($customerGuestDetailPhone) + && (!isset($rules['size']['phone']) + || (isset($rules['size']['phone']) && (Tools::strlen(trim($customerGuestDetailPhone)) <= $rules['size']['phone'])) + ) + ) { $objCustomerGuestDetail->phone = $customerGuestDetailPhone; } + $objCustomerGuestDetail->id_cart = $this->context->cart->id; $objCustomerGuestDetail->save(); } else { @@ -1100,6 +1134,7 @@ class OrderOpcControllerCore extends ParentOrderController } } } + $this->context->cart->save(); } } diff --git a/controllers/front/OrderReturnController.php b/controllers/front/OrderReturnController.php index 7a57ef229..4fe62ec09 100644 --- a/controllers/front/OrderReturnController.php +++ b/controllers/front/OrderReturnController.php @@ -50,22 +50,23 @@ class OrderReturnControllerCore extends FrontController $objOrder = new Order($objOrderReturn->id_order); $orderCurrency = new Currency($objOrder->id_currency); - $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrderReturn->id_order, $objOrderReturn->id, 0, 1); - $isCanceled = false; + $refundReqBookings = $objOrderReturn->getOrderRefundRequestedBookings($objOrderReturn->id_order, $objOrderReturn->id); + $isCanceledBookings = false; if (count(array_unique(array_column($refundReqBookings, 'is_cancelled'))) === 1 && array_unique(array_column($refundReqBookings, 'is_cancelled'))[0] != 0 ) { - $isCanceled = true; + $isCanceledBookings = true; } $voucher = ''; if (Validate::isLoadedObject($objCartRule = new CartRule($objOrderReturn->id_return_type))) { $voucher = $objCartRule->name[$this->context->language->id]; } + $this->context->smarty->assign( array ( 'orderReturnInfo' => (array)$objOrderReturn, 'refundReqBookings' => $refundReqBookings, - 'isCanceled' => $isCanceled, + 'isCanceledBookings' => $isCanceledBookings, 'orderInfo' => (array) $objOrder, 'orderCurrency' => (array) $orderCurrency, 'currentStateInfo' => (array) new OrderReturnState($objOrderReturn->state, diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index ec77ebd09..0e205f560 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -78,7 +78,8 @@ class ProductControllerCore extends FrontController 'hotel_location' => array( 'latitude' => $objHotelBranchInformation->latitude, 'longitude' => $objHotelBranchInformation->longitude, - ) + ), + 'PS_STORES_ICON' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')) )); $this->addJS( @@ -109,26 +110,18 @@ class ProductControllerCore extends FrontController // validate dates if available $dateFrom = Tools::getValue('date_from'); $dateTo = Tools::getValue('date_to'); - - $currentTimestamp = strtotime(date('Y-m-d')); - $dateFromTimestamp = strtotime($dateFrom); - $dateToTimestamp = strtotime($dateTo); - - if ($dateFrom != '' && ($dateFromTimestamp === false || ($dateFromTimestamp < $currentTimestamp))) { - Tools::redirect($this->context->link->getPageLink('pagenotfound')); - } - - if ($dateTo != '' && ($dateToTimestamp === false || ($dateToTimestamp < $currentTimestamp))) { - Tools::redirect($this->context->link->getPageLink('pagenotfound')); - } - parent::init(); if ($id_product = (int) Tools::getValue('id_product')) { $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); } - if (!$this->product->booking_product || ($this->product->booking_product && !$this->product->show_at_front)) { + $objHotelRoomType = new HotelRoomType(); + $hotelRoomInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id); + $idHotel = (int) $hotelRoomInfo['id_hotel']; + if (!HotelHelper::validateDateRangeForHotel($dateFrom, $dateTo, $idHotel)) { + Tools::redirect($this->context->link->getPageLink('pagenotfound')); + } else if (!$this->product->booking_product || ($this->product->booking_product && !$this->product->show_at_front)) { Tools::redirect($this->context->link->getPageLink('pagenotfound')); } @@ -341,6 +334,7 @@ class ProductControllerCore extends FrontController $date_from = Tools::getValue('date_from'); $date_to = Tools::getValue('date_to'); + $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id); if (!($date_from = Tools::getValue('date_from'))) { $date_from = date('Y-m-d'); // set date to according to los @@ -355,6 +349,17 @@ class ProductControllerCore extends FrontController $date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from))); } + if ($preparationTime + && strtotime('+ '.$preparationTime.' day') >= strtotime($date_from) + ) { + $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + if (strtotime($date_from) >= strtotime($date_to)) { + $objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from); + $date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from))); + } + } + $hotel_branch_obj = new HotelBranchInformation($hotel_id); /*Max date of ordering for order restrict*/ $order_date_restrict = false; @@ -368,9 +373,6 @@ class ProductControllerCore extends FrontController } } /*End*/ - // booking preparation time - $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_id); - $objHotelImage = new HotelImage(); $hotelImageLink = null; if ($coverImage = HotelImage::getCover($hotel_id)) { @@ -413,6 +415,7 @@ class ProductControllerCore extends FrontController 'hotel_address1' => $addressInfo['address1'], 'hotel_phone' => $addressInfo['phone'], 'hotel_name' => $hotel_name, + 'hotel_rating' => $hotel_info_by_id['rating'], 'hotel_policies' => $hotel_policies, 'hotel_features' => $htl_features, 'hotel_image_link' => $hotelImageLink, @@ -427,14 +430,27 @@ class ProductControllerCore extends FrontController if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_QUANTITY) { $occupancy_value = 1; } else { - $occupancy_value = array( - array( - 'adults' => $room_info_by_product_id['adults'], - 'children' => 0, - 'child_ages' => array(), - ), - ); + $useDefaultOccupancy = true; + // if coming from hotel page do not set occupancy, otherwise set base adult occupancy + if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] == Tools::secureReferrer($_SERVER['HTTP_REFERER'])) { // Assure us the previous page was one of the site + $idCategoryHotel = $hotel_branch_obj->id_category; + $categoryPageLink = $this->context->link->getCategoryLink($idCategoryHotel); + if (Tools::strpos($_SERVER['HTTP_REFERER'], $categoryPageLink) === 0) { + $useDefaultOccupancy = false; + } + } + + if ($useDefaultOccupancy) { + $occupancy_value = array( + array( + 'adults' => $room_info_by_product_id['adults'], + 'children' => 0, + 'child_ages' => array(), + ), + ); + } } + $this->assignBookingFormVars($this->product->id, $date_from, $date_to, $occupancy_value); $this->assignServiceProductVars(); diff --git a/controllers/front/StoresController.php b/controllers/front/StoresController.php index 89f21c5ac..901f5ec7d 100644 --- a/controllers/front/StoresController.php +++ b/controllers/front/StoresController.php @@ -208,8 +208,12 @@ class StoresControllerCore extends FrontController */ protected function assignStores() { - $this->context->smarty->assign('hasStoreIcon', Tools::file_get_contents($this->context->link->getMediaLink(_PS_IMG_DIR_.Configuration::get('PS_STORES_ICON')))); // by webkul to get media link. + $hasStoreIcon = false; + if (Tools::file_get_contents($this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_STORES_ICON')))) { // by webkul to get media link. + $hasStoreIcon = true; + } + $this->context->smarty->assign('hasStoreIcon', $hasStoreIcon); $distance_unit = Configuration::get('PS_DISTANCE_UNIT'); if (!in_array($distance_unit, array('km', 'mi'))) { $distance_unit = 'km'; diff --git a/docs/.htaccess b/docs/.htaccess index 8703119f9..3de9e4008 100644 --- a/docs/.htaccess +++ b/docs/.htaccess @@ -1 +1,10 @@ -Deny from ALL +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/docs/csv_import/.htaccess b/docs/csv_import/.htaccess index 18aba5838..041b7e558 100644 --- a/docs/csv_import/.htaccess +++ b/docs/csv_import/.htaccess @@ -1 +1,10 @@ -Allow from ALL \ No newline at end of file +# Apache 2.2 + + Order allow,deny + Allow from ALL + + +# Apache 2.4 + + Require all granted + diff --git a/download/.htaccess b/download/.htaccess index 93169e4eb..3de9e4008 100644 --- a/download/.htaccess +++ b/download/.htaccess @@ -1,2 +1,10 @@ -Order deny,allow -Deny from all +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/img/.htaccess b/img/.htaccess new file mode 100644 index 000000000..b892de715 --- /dev/null +++ b/img/.htaccess @@ -0,0 +1,16 @@ +# Apache 2.2 + + Order deny,allow + Deny from all + + Allow from all + + + +# Apache 2.4 + + Require all denied + + Require all granted + + \ No newline at end of file diff --git a/img/cms/.htaccess b/img/cms/.htaccess deleted file mode 100644 index 91920ed0a..000000000 --- a/img/cms/.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - - php_flag engine off - -deny from all - - order deny,allow - allow from all - diff --git a/img/hotel_header_image.jpg b/img/hotel_header_image.jpg index ce7f91454..fbb6d003d 100644 Binary files a/img/hotel_header_image.jpg and b/img/hotel_header_image.jpg differ diff --git a/install/data/xml/access.xml b/install/data/xml/access.xml deleted file mode 100644 index 3e5107348..000000000 --- a/install/data/xml/access.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 557f554f6..be03b27c3 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -92,6 +92,12 @@ 1 + + 0 + + + 3 + 20 diff --git a/install/fixtures/fashion/data/access.xml b/install/fixtures/fashion/data/access.xml deleted file mode 100644 index 5b5f0d074..000000000 --- a/install/fixtures/fashion/data/access.xml +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/install/fixtures/fashion/data/profile.xml b/install/fixtures/fashion/data/profile.xml deleted file mode 100644 index abdc58077..000000000 --- a/install/fixtures/fashion/data/profile.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/install/fixtures/fashion/langs/bn/data/index.php b/install/fixtures/fashion/langs/bn/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/bn/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/bn/data/profile.xml b/install/fixtures/fashion/langs/bn/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/bn/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/bn/index.php b/install/fixtures/fashion/langs/bn/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/bn/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/br/data/index.php b/install/fixtures/fashion/langs/br/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/br/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/br/data/profile.xml b/install/fixtures/fashion/langs/br/data/profile.xml deleted file mode 100644 index 879171f36..000000000 --- a/install/fixtures/fashion/langs/br/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Especialista em logística - - - Tradutor - - - Vendedor - - diff --git a/install/fixtures/fashion/langs/br/index.php b/install/fixtures/fashion/langs/br/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/br/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/de/data/index.php b/install/fixtures/fashion/langs/de/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/de/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/de/data/profile.xml b/install/fixtures/fashion/langs/de/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/de/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/de/index.php b/install/fixtures/fashion/langs/de/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/de/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/en/data/index.php b/install/fixtures/fashion/langs/en/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/en/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/en/data/profile.xml b/install/fixtures/fashion/langs/en/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/en/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/en/index.php b/install/fixtures/fashion/langs/en/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/en/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/es/data/index.php b/install/fixtures/fashion/langs/es/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/es/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/es/data/profile.xml b/install/fixtures/fashion/langs/es/data/profile.xml deleted file mode 100644 index 6dd663bbf..000000000 --- a/install/fixtures/fashion/langs/es/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Especialista en logística - - - Traductor - - - Vendedor - - diff --git a/install/fixtures/fashion/langs/es/index.php b/install/fixtures/fashion/langs/es/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/es/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/fa/data/index.php b/install/fixtures/fashion/langs/fa/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/fa/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/fa/data/profile.xml b/install/fixtures/fashion/langs/fa/data/profile.xml deleted file mode 100644 index 0ca3c4e77..000000000 --- a/install/fixtures/fashion/langs/fa/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - پشتیبان - - - مترجم - - - مسئول فروش - - diff --git a/install/fixtures/fashion/langs/fa/index.php b/install/fixtures/fashion/langs/fa/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/fa/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/fr/data/index.php b/install/fixtures/fashion/langs/fr/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/fr/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/fr/data/profile.xml b/install/fixtures/fashion/langs/fr/data/profile.xml deleted file mode 100644 index 1f0f97ca8..000000000 --- a/install/fixtures/fashion/langs/fr/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logisticien - - - Traducteur - - - Commercial - - diff --git a/install/fixtures/fashion/langs/fr/index.php b/install/fixtures/fashion/langs/fr/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/fr/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/id/data/index.php b/install/fixtures/fashion/langs/id/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/id/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/id/data/profile.xml b/install/fixtures/fashion/langs/id/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/id/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/id/index.php b/install/fixtures/fashion/langs/id/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/id/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/it/data/index.php b/install/fixtures/fashion/langs/it/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/it/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/it/data/profile.xml b/install/fixtures/fashion/langs/it/data/profile.xml deleted file mode 100644 index abdf63cec..000000000 --- a/install/fixtures/fashion/langs/it/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Responsabile logistica - - - Traduttore - - - Commesso - - diff --git a/install/fixtures/fashion/langs/it/index.php b/install/fixtures/fashion/langs/it/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/it/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/nl/data/index.php b/install/fixtures/fashion/langs/nl/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/nl/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/nl/data/profile.xml b/install/fixtures/fashion/langs/nl/data/profile.xml deleted file mode 100644 index 92fa0ecb1..000000000 --- a/install/fixtures/fashion/langs/nl/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistiek medewerker - - - Vertaler - - - Verkoper - - diff --git a/install/fixtures/fashion/langs/nl/index.php b/install/fixtures/fashion/langs/nl/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/nl/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/pl/data/index.php b/install/fixtures/fashion/langs/pl/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/pl/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/pl/data/profile.xml b/install/fixtures/fashion/langs/pl/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/pl/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/pl/index.php b/install/fixtures/fashion/langs/pl/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/pl/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/qc/data/index.php b/install/fixtures/fashion/langs/qc/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/qc/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/qc/data/profile.xml b/install/fixtures/fashion/langs/qc/data/profile.xml deleted file mode 100644 index 1f0f97ca8..000000000 --- a/install/fixtures/fashion/langs/qc/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logisticien - - - Traducteur - - - Commercial - - diff --git a/install/fixtures/fashion/langs/qc/index.php b/install/fixtures/fashion/langs/qc/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/qc/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/ro/data/index.php b/install/fixtures/fashion/langs/ro/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/ro/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/ro/data/profile.xml b/install/fixtures/fashion/langs/ro/data/profile.xml deleted file mode 100644 index fd1a8a923..000000000 --- a/install/fixtures/fashion/langs/ro/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Coordonator logistic - - - Translator - - - Agent comercial - - diff --git a/install/fixtures/fashion/langs/ro/index.php b/install/fixtures/fashion/langs/ro/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/ro/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/ru/data/index.php b/install/fixtures/fashion/langs/ru/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/ru/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/ru/data/profile.xml b/install/fixtures/fashion/langs/ru/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/ru/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/ru/index.php b/install/fixtures/fashion/langs/ru/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/ru/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/tw/data/index.php b/install/fixtures/fashion/langs/tw/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/tw/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/tw/data/profile.xml b/install/fixtures/fashion/langs/tw/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/tw/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/tw/index.php b/install/fixtures/fashion/langs/tw/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/tw/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/vn/data/index.php b/install/fixtures/fashion/langs/vn/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/vn/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/vn/data/profile.xml b/install/fixtures/fashion/langs/vn/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/vn/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/vn/index.php b/install/fixtures/fashion/langs/vn/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/vn/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/zh/data/index.php b/install/fixtures/fashion/langs/zh/data/index.php deleted file mode 100644 index f1226f56d..000000000 --- a/install/fixtures/fashion/langs/zh/data/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../../'); -exit; diff --git a/install/fixtures/fashion/langs/zh/data/profile.xml b/install/fixtures/fashion/langs/zh/data/profile.xml deleted file mode 100644 index 04e65582f..000000000 --- a/install/fixtures/fashion/langs/zh/data/profile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - Logistician - - - Translator - - - Salesman - - diff --git a/install/fixtures/fashion/langs/zh/index.php b/install/fixtures/fashion/langs/zh/index.php deleted file mode 100644 index d36aa378a..000000000 --- a/install/fixtures/fashion/langs/zh/index.php +++ /dev/null @@ -1,35 +0,0 @@ - -* @copyright 2007-2015 PrestaShop SA -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../../../../../'); -exit; diff --git a/install/langs/bg/data/cms.xml b/install/langs/bg/data/cms.xml index afe6a4e2b..fe5c4504a 100644 --- a/install/langs/bg/data/cms.xml +++ b/install/langs/bg/data/cms.xml @@ -4,7 +4,61 @@ Policies Our policies of hotel bookings conditions, policy, guidelines, protocol, rule - <h2>Policies</h2><h3>Our policies for booking</h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Enim tortor at auctor urna nunc id cursus metus aliquam. Ut enim blandit volutpat maecenas volutpat blandit. Odio ut enim blandit volutpat maecenas volutpat. Hendrerit dolor magna eget est lorem ipsum dolor sit amet. Senectus et netus et malesuada fames ac. Posuere urna nec tincidunt praesent semper feugiat nibh sed. Eu consequat ac felis donec et. Viverra nibh cras pulvinar mattis nunc. Augue mauris augue neque gravida. Risus at ultrices mi tempus imperdiet nulla malesuada. Nibh cras pulvinar mattis nunc sed blandit. Maecenas volutpat blandit aliquam etiam erat velit scelerisque in.</p><p>Feugiat nibh sed pulvinar proin. Vestibulum sed arcu non odio euismod lacinia at quis risus. Turpis tincidunt id aliquet risus feugiat in. Varius morbi enim nunc faucibus a pellentesque sit amet porttitor. Posuere morbi leo urna molestie at elementum eu facilisis. Id eu nisl nunc mi. Aliquet risus feugiat in ante metus dictum at. Sed turpis tincidunt id aliquet risus. Ac orci phasellus egestas tellus rutrum. Non diam phasellus vestibulum lorem sed risus ultricies tristique nulla. Leo vel orci porta non pulvinar. Dictumst quisque sagittis purus sit amet. Scelerisque viverra mauris in aliquam sem fringilla ut morbi tincidunt. Egestas diam in arcu cursus euismod quis. Vestibulum morbi blandit cursus risus at ultrices.</p> + <h2 class="page-heading bottom-indent">Policies</h2> + <div> + <p style="border-left:2px solid #808080;padding-left:5px;">This page contains demo content for illustrative purposes only. Any resemblance to actual products, services, or events is purely coincidental. Thank you for your understanding.</p> + <hr /></div> + <div> + <p class="page-subheading">Reservation Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Guests must provide valid credit card details to secure a reservation.</li> + <li class="margin-btm-10">Cancellation policies vary based on room type and rate plan.</li> + <li class="margin-btm-10">Changes to reservations may be subject to availability and additional charges.</li> + </ul> + <p class="page-subheading">Check-in and Check-out Times:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Check-in time: 11:00 AM</li> + <li class="margin-btm-10">Check-out time: 10:30 AM</li> + <li class="margin-btm-10">Early check-in and late check-out requests are subject to availability and may incur additional charges.</li> + </ul> + <p class="page-subheading">Payment Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Payment for the entire stay is due upon check-in.</li> + <li class="margin-btm-10">Acceptable forms of payment: credit cards, cash, etc.</li> + <li class="margin-btm-10">A security deposit may be required upon arrival.</li> + </ul> + <p class="page-subheading">Cancellation and No-show Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Cancellations made 7 days prior to arrival are eligible for a full refund.</li> + <li class="margin-btm-10">No-shows will be charged the full amount of the reservation.</li> + </ul> + <p class="page-subheading">Pet Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Pets are welcome with prior arrangement.</li> + <li class="margin-btm-10">Additional charges may apply for pet-friendly accommodations.</li> + <li class="margin-btm-10">Guests are responsible for any damages caused by their pets.</li> + </ul> + <p class="page-subheading">Smoking Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Our hotel is smoke-free. Smoking is strictly prohibited indoors.</li> + <li class="margin-btm-10">Designated smoking areas are available outside the premises.</li> + </ul> + <p class="page-subheading">Privacy Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">We are committed to protecting your privacy and personal information.</li> + <li class="margin-btm-10">Information collected during booking and stay is used solely for operational purposes.</li> + </ul> + <p class="page-subheading">Accessibility Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Our hotel is committed to providing accessible accommodations and facilities for guests with disabilities.</li> + <li class="margin-btm-10">Please contact us directly for specific accessibility requests.</li> + </ul> + <p class="page-subheading">Additional Policies:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-10">Use of hotel facilities such as the gym, spa, pool, etc.</li> + <li class="margin-btm-10">Conduct and behavior expectations while on hotel premises.</li> + </ul> + </div> policies @@ -12,71 +66,135 @@ Legal Notice Legal notice notice, legal, credits - <h2>Legal</h2><h3>Credits</h3><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> + + <h2 class="page-heading bottom-indent"><strong>Legal Notice</strong></h2> + <div> + <p style="border-left:2px solid #808080;padding-left:5px;">This page contains demo content for illustrative purposes only. Any resemblance to actual products, services, or events is purely coincidental. Thank you for your understanding.</p> + <hr /></div> + <p class="margin-btm-30 page-subheading">Website Terms of Use:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-20">The content of the pages of this website is for your general information and use only. It is subject to change without notice.</li> + <li class="margin-btm-20">Neither we nor any third parties provide any warranty or guarantee as to the accuracy, timeliness, performance, completeness, or suitability of the information and materials found or offered on this website for any particular purpose. You acknowledge that such information and materials may contain inaccuracies or errors, and we expressly exclude liability for any such inaccuracies or errors to the fullest extent permitted by law.</li> + <li class="margin-btm-20">Your use of any information or materials on this website is entirely at your own risk, for which we shall not be liable. It shall be your own responsibility to ensure that any products, services, or information available through this website meet your specific requirements.</li> + </ul> + <p class="page-subheading">Intellectual Property:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-20">This website contains material which is owned by or licensed to us. This material includes, but is not limited to, the design, layout, look, appearance, and graphics. Reproduction is prohibited other than in accordance with the copyright notice, which forms part of these terms and conditions.</li> + <li class="margin-btm-20">All trademarks reproduced in this website, which are not the property of, or licensed to the operator, are acknowledged on the website.</li> + </ul> + <p class="page-subheading">Privacy Policy:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-20">Your privacy is important to us. Please review our Privacy Policy to understand how we collect, use, and disclose information about you.</li> + </ul> + <p class="page-subheading">Limitation of Liability:</p> + <ul class="margin-btm-30"> + <li class="margin-btm-20">Neither we nor any third parties provide any warranty or guarantee as to the accuracy, timeliness, performance, completeness, or suitability of the information and materials found or offered on this website for any particular purpose. You acknowledge that such information and materials may contain inaccuracies or errors, and we expressly exclude liability for any such inaccuracies or errors to the fullest extent permitted by law.</li> + <li class="margin-btm-20">Your use of any information or materials on this website is entirely at your own risk, for which we shall not be liable. It shall be your own responsibility to ensure that any products, services, or information available through this website meet your specific requirements.</li> + </ul> + legal-notice Terms and Conditions Our Terms and Conditions conditions, terms, use, sell - <h1 class="page-heading">Terms and Conditions</h1> -<h3 class="page-subheading">Rule 1</h3> -<p class="bottom-indent">Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> -<h3 class="page-subheading">Rule 2</h3> -<p class="bottom-indent">Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam&#1102;</p> -<h3 class="page-subheading">Rule 3</h3> -<p class="bottom-indent">Tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam&#1102;</p> + + <h2 class="page-heading bottom-indent">Terms and Conditions</h2> + <div> + <p style="border-left:2px solid #808080;padding-left:5px;">This page contains demo content for illustrative purposes only. Any resemblance to actual products, services, or events is purely coincidental. Thank you for your understanding.</p> + <hr /></div> + <div> + <h3 class="page-subheading"><strong>Cancellation Policy:</strong></h3> + <div> + <ul> + <li><span>Free Cancellation: Up to 48 hours before arrival for standard rates.</span></li> + <li><span>Bookings made with a non-refundable rate cannot be canceled or modified.</span></li> + <li><span>Cancellations within 24 hours of arrival will incur a fee of one night's stay.</span></li> + </ul> + </div> + <br /> + <h3 class="page-subheading"><strong>Changes to Bookings:</strong></h3> + <div> + <ul> + <li><span>A fee of $25 may apply to change your reservation dates after booking.</span></li> + <li><span>Changes to room type or number of guests are subject to availability at the hotel.</span></li> + </ul> + </div> + <br /> + <h3 class="page-subheading"><strong>Guest Responsibility:</strong></h3> + <div> + <ul> + <li><span>All guests must present a valid government-issued photo ID at check-in.</span></li> + <li><span>The maximum occupancy for the room type is 2 adults.</span></li> + <li><span>Smoking and alcohol are strictly prohibited in all guest rooms and public areas.</span></li> + </ul> + </div> + </div> + terms-and-conditions-of-use About Us Learn more about us about us, informations - <h1 class="page-heading bottom-indent">About Us</h1> -<div class="row"> -<div class="col-xs-12 col-sm-4"> -<div class="cms-block"> -<h3 class="page-subheading">Our company</h3> -<p><strong class="dark">Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididun.</strong></p> -<p>Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. Lorem ipsum dolor sit amet conse ctetur adipisicing elit.</p> -<ul class="list-1"> -<li><em class="icon-ok"></em>Top quality products</li> -<li><em class="icon-ok"></em>Best customer service</li> -<li><em class="icon-ok"></em>30-days money back guarantee</li> -</ul> -</div> -</div> -<div class="col-xs-12 col-sm-4"> -<div class="cms-box"> -<h3 class="page-subheading">Our team</h3> -<img title="cms-img" src="../img/cms/cms-img.jpg" alt="cms-img" width="370" height="192" /> -<p><strong class="dark">Lorem set sint occaecat cupidatat non </strong></p> -<p>Eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo.</p> -</div> -</div> -<div class="col-xs-12 col-sm-4"> -<div class="cms-box"> -<h3 class="page-subheading">Testimonials</h3> -<div class="testimonials"> -<div class="inner"><span class="before">“</span>Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim.<span class="after">”</span></div> -</div> -<p><strong class="dark">Lorem ipsum dolor sit</strong></p> -<div class="testimonials"> -<div class="inner"><span class="before">“</span>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet conse ctetur adipisicing elit. Lorem ipsum dolor sit amet conse ctetur adipisicing elit, sed do eiusmod.<span class="after">”</span></div> -</div> -<p><strong class="dark">Ipsum dolor sit</strong></p> -</div> -</div> -</div> + <h2 class="page-heading bottom-indent">About Us</h2><div> + <p style="border-left:2px solid #808080;padding-left:5px;">This page contains demo content for illustrative purposes only. Any resemblance to actual products, services, or events is purely coincidental. Thank you for your understanding.</p> + <hr /></div> + <div class="row"> + <div class="col-xs-12 col-sm-8"> + <div class="cms-block"> + <div class="margin-btm-30"> + <p class="dark">Welcome to our sanctuary of luxury and tranquility, where every stay is crafted to provide an unparalleled experience. Whether you're seeking a relaxing getaway, a productive business trip, or a memorable event, we are dedicated to making your visit exceptional.</p> + </div> + <div class="margin-btm-30"> + <p class="page-subheading">Our Story</p> + <p>Inspired by serene surroundings and rich local culture, our hotel combines modern comfort with timeless elegance. Our thoughtfully designed rooms, impeccable service, and attention to detail reflect our commitment to providing a haven for travelers.</p> + </div> + <div class="margin-btm-30"> + <p class="page-subheading">Our Mission</p> + <p>Our mission is to create a home away from home, offering personalized service and luxurious amenities tailored to your needs. Your comfort and satisfaction are our top priorities, and we strive to exceed your expectations at every turn.</p> + </div> + <div class="margin-btm-30"> + <p class="page-subheading">Our Amenities</p> + <p>Indulge in the finest amenities during your stay. Relax in elegantly appointed rooms and suites with breathtaking views. Savor gourmet dining at our on-site restaurant, unwind with a cocktail at our stylish bar, and rejuvenate at our state-of-the-art spa and fitness center. Enjoy our serene outdoor pool, lush gardens, and modern business facilities to cater to all your needs.</p> + </div> + <div class="margin-btm-30"> + <p class="page-subheading">Our Team</p> + <p>Our dedicated team of hospitality professionals is here to serve you with a passion for excellence. From personalized concierge services to meticulous housekeeping, every member of our team is committed to making your stay extraordinary.</p> + </div> + <div class="margin-btm-30"> + <p class="page-subheading">Join Us</p> + <p>Discover the charm and elegance of our hotel for yourself. Whether visiting for leisure or business, we invite you to experience our warm hospitality and luxurious accommodations. Book your stay with us today and let us make your visit unforgettable.</p> + </div> + </div> + </div> + <div class="col-xs-12 col-sm-4"> + <div class="cms-box"> + <p class="page-subheading">Testimonials</p> + <div class="testimonials"> + <div class="inner"><span class="before">“</span>Hotel Prime surpassed my expectations in every way. The Executive Room was not only luxurious but also provided a peaceful retreat with its stunning lake views. The attention to detail and personalized service made my stay truly memorable. I highly recommend Hotel Prime for both business and leisure travelers looking for a blend of comfort and sophistication<span class="after">”</span></div> + </div> + <p><strong class="dark">Calrk Kent</strong></p> + <div class="testimonials"> + <div class="inner"><span class="before">“</span>As a frequent traveler, I can confidently say Hotel Prime stands out for its tranquil environment and exceptional hospitality. The View Room provided a perfect retreat with its stunning cityscape views and comfortable accommodations.<span class="after">”</span></div> + </div> + <p><strong class="dark">john Doe</strong></p> + </div> + </div> + </div> + about-us Secure payment Our secure payment method secure payment, ssl, visa, mastercard, paypal - <h2>Secure payment</h2> -<h3>Our secure payment</h3><p>With SSL</p> -<h3>Using Visa/Mastercard/Paypal</h3><p>About this service</p> + <h2 class="page-heading bottom-indent">Secure payment</h2> + <div> + <p style="border-left:2px solid #808080;padding-left:5px;">This page contains demo content for illustrative purposes only. Any resemblance to actual products, services, or events is purely coincidental. Thank you for your understanding.</p> + <hr /></div> + <div>We prioritize your security. All transactions made on our website are encrypted using Secure Socket Layer (SSL) technology to ensure your personal information and payment details are protected. We accept major credit cards and provide a secure environment for a seamless booking experience. For any inquiries regarding payment security, feel free to contact our customer support team.</div> + secure-payment diff --git a/install/langs/bg/data/order_return_state.xml b/install/langs/bg/data/order_return_state.xml index c7b945970..161883976 100644 --- a/install/langs/bg/data/order_return_state.xml +++ b/install/langs/bg/data/order_return_state.xml @@ -1,17 +1,17 @@ - Pending + В очакване order_refund_pending_customer order_refund_pending_admin - Refund denied + Отказано order_refund_denied_customer order_refund_denied_admin - Refund completed + Завършено order_refund_completed_customer order_refund_completed_admin diff --git a/install/langs/bg/data/order_state.xml b/install/langs/bg/data/order_state.xml index fd178eee0..f4661ce31 100644 --- a/install/langs/bg/data/order_state.xml +++ b/install/langs/bg/data/order_state.xml @@ -45,7 +45,7 @@