From 55cf83563a2fe25ad09920aaeecfae4f1d960e76 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 3 Apr 2024 18:53:21 +0530 Subject: [PATCH 01/63] Fixed: Room type duplication was not creating a perfect copy of existing the room type --- modules/hotelreservationsystem/classes/HotelRoomType.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index a5445ec18..6c0a80fd4 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -107,6 +107,11 @@ class HotelRoomType extends ObjectModel $objHotelRoomType->id_hotel = $idHotelNew; $objHotelRoomType->adults = $roomType['adults']; $objHotelRoomType->children = $roomType['children']; + $objHotelRoomType->max_adults = $roomType['max_adults']; + $objHotelRoomType->max_children = $roomType['max_children']; + $objHotelRoomType->max_guests = $roomType['max_guests']; + $objHotelRoomType->min_los = $roomType['min_los']; + $objHotelRoomType->max_los = $roomType['max_los']; if ($objHotelRoomType->save()) { $objHotelRoomType->updateCategories(); return $returnId ? $objHotelRoomType->id : true; From 52b6e3f87edaa744e9c6ed099a1fcba40dc05425 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 5 Apr 2024 11:32:07 +0530 Subject: [PATCH 02/63] Fixed: Defaul dates in the booking form, search block, if prepration time is applied to the hotel --- controllers/front/ProductController.php | 8 +++++--- .../controllers/front/autocompletesearch.php | 3 ++- .../views/js/wk-room-search-block.js | 13 +++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index ec77ebd09..d44e46489 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -341,8 +341,13 @@ 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'); + if ($preparationTime) { + $date_from = date('Y-m-d', strtotime('+ '.$preparationTime.' day')); + } + // set date to according to los $objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); $los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from); @@ -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)) { diff --git a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php index 4a051c103..4d5eec20a 100644 --- a/modules/wkroomsearchblock/controllers/front/autocompletesearch.php +++ b/modules/wkroomsearchblock/controllers/front/autocompletesearch.php @@ -46,9 +46,10 @@ class WkRoomSearchBlockAutoCompleteSearchModuleFrontController extends ModuleFro foreach ($cat_ids as $value) { if ($hotel_info = $obj_htl_info->hotelBranchInfoByCategoryId($value['id_category'])) { $maxOrderDate = HotelOrderRestrictDate::getMaxOrderDate($hotel_info['id']); + $preparationTime = (int) HotelOrderRestrictDate::getPreparationTime($hotel_info['id']); $maxOrderDate = date('Y-m-d', strtotime($maxOrderDate)); $html .= '
  • '. + $hotel_info['id_category'].'" data-max_order_date="'.$maxOrderDate.'" data-preparation_time="'.$preparationTime.'">'. $hotel_info['hotel_name'].'
  • '; } } diff --git a/modules/wkroomsearchblock/views/js/wk-room-search-block.js b/modules/wkroomsearchblock/views/js/wk-room-search-block.js index f5d180d16..d85c25e5b 100644 --- a/modules/wkroomsearchblock/views/js/wk-room-search-block.js +++ b/modules/wkroomsearchblock/views/js/wk-room-search-block.js @@ -62,6 +62,14 @@ $(document).ready(function() { if (preparation_time) { start_date.setDate(start_date.getDate() + parseInt(preparation_time)); start_date.setHours(0, 0, 0, 0); + let selecteDateFrom = new Date(Date.parse(dateFrom)); + let selecteDateTo = new Date(Date.parse(dateTo)); + if (selecteDateFrom < start_date + || selecteDateTo < start_date + ) { + $('#check_in_time').val(''); + $('#check_out_time').val(''); + } } if (max_order_date) { @@ -203,6 +211,11 @@ $(document).ready(function() { $('#hotel_cat_name').html('Select Hotel'); $('.hotel_dropdown_ul').empty(); $('.hotel_dropdown_ul').html(result.data); + // Resetting the data from previously selected hotel + $('#preparation_time').val(0); + var max_order_date = $('#max_order_date').val(); + var preparation_time = 0; + createDateRangePicker(max_order_date, preparation_time, $('#check_in_time').val(), $('#check_out_time').val()); } else { alert(no_results_found_cond); } From cd58f81cbcab68f7f7d291b5342fe76464971192 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 17 Apr 2024 13:31:20 +0530 Subject: [PATCH 03/63] Added:Admin is show global max order date and global preparation time in AdminAddHotel while editing hotel --- .../controllers/admin/AdminAddHotelController.php | 2 ++ .../views/templates/admin/add_hotel/helpers/form/form.tpl | 2 ++ 2 files changed, 4 insertions(+) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php index 1d0e738b3..9b6f35bbf 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php @@ -183,6 +183,8 @@ class AdminAddHotelController extends ModuleAdminController $smartyVars['state_var'] = $stateOptions; $smartyVars['enabledDisplayMap'] = Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP'); $smartyVars['ps_img_dir'] = _PS_IMG_.'l/'; + $smartyVars['MAX_GLOBAL_BOOKING_DATE'] = date('Y-m-d', strtotime(Configuration::get('MAX_GLOBAL_BOOKING_DATE'))); + $smartyVars['GLOBAL_PREPARATION_TIME'] = Configuration::get('GLOBAL_PREPARATION_TIME'); $this->context->smarty->assign($smartyVars); diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl index 4ef90c7d8..53a919257 100644 --- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl +++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl @@ -357,6 +357,7 @@ +
    {l s='Global max order date:' mod='hotelreservationsystem'} {dateFormat date=$MAX_GLOBAL_BOOKING_DATE}
    + {/if} {/if} From e8551769b87221eda98f65acb166216a9c8cd4a8 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 6 Jun 2024 19:47:06 +0530 Subject: [PATCH 22/63] Added: Different Advance price rule for different group for same date ranges --- .../classes/HotelRoomTypeFeaturePricing.php | 46 +++++++++++-------- .../admin/AdminHotelFeaturePricesSettings.php | 11 ++++- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php index 5dbfbd1db..a49d60ec1 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php +++ b/modules/hotelreservationsystem/classes/HotelRoomTypeFeaturePricing.php @@ -180,6 +180,7 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $id_product, $date_from, $date_to, + $groups, $type = 'date_range', $current_Special_days = false, $id_feature_price = 0 @@ -188,20 +189,26 @@ class HotelRoomTypeFeaturePricing extends ObjectModel $date_to = date('Y-m-d', strtotime($date_to)); if ($type == 'specific_date') { return Db::getInstance()->getRow( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` - WHERE `id_product`='.(int) $id_product.' AND `active`=1 - AND `date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_SPECIFIC.' - AND `date_from` = \''.pSQL($date_from).'\' - AND `id_feature_price`!='.(int) $id_feature_price + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp + INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg + ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`) + WHERE rtfp.`id_product`='.(int) $id_product.' AND rtfp.`active`=1 + AND rtfp.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_SPECIFIC.' + AND rtfp.`date_from` = \''.pSQL($date_from).'\' + AND rtfp.`id_feature_price`!='.(int) $id_feature_price.' + AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')' ); } elseif ($type == 'special_day') { $featurePrices = Db::getInstance()->executeS( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` - WHERE `id_product`='.(int) $id_product.' - AND `is_special_days_exists`=1 AND `active`=1 - AND `date_from` < \''.pSQL($date_to).'\' - AND `date_to` > \''.pSQL($date_from).'\' - AND `id_feature_price`!='.(int) $id_feature_price + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp + INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg + ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`) + WHERE rtfp.`id_product`='.(int) $id_product.' + AND rtfp.`is_special_days_exists`=1 AND `active`=1 + AND rtfp.`date_from` < \''.pSQL($date_to).'\' + AND rtfp.`date_to` > \''.pSQL($date_from).'\' + AND rtfp.`id_feature_price`!='.(int) $id_feature_price.' + AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')' ); if ($featurePrices) { foreach ($featurePrices as $featurePrice) { @@ -216,13 +223,16 @@ class HotelRoomTypeFeaturePricing extends ObjectModel return false; } elseif ($type == 'date_range') { return Db::getInstance()->getRow( - 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` - WHERE `id_product`='.(int) $id_product.' AND `active`=1 - AND `date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_RANGE.' - AND `is_special_days_exists`=0 - AND `date_from` <= \''.pSQL($date_to).'\' - AND `date_to` >= \''.pSQL($date_from).'\' - AND `id_feature_price`!='.(int) $id_feature_price + 'SELECT * FROM `'._DB_PREFIX_.'htl_room_type_feature_pricing` rtfp + INNER JOIN `'._DB_PREFIX_.'htl_room_type_feature_pricing_group` rtfpg + ON (rtfp.`id_feature_price` = rtfpg.`id_feature_price`) + WHERE rtfp.`id_product`='.(int) $id_product.' AND rtfp.`active`=1 + AND rtfp.`date_selection_type` = '.(int) self::DATE_SELECTION_TYPE_RANGE.' + AND rtfp.`is_special_days_exists`=0 + AND rtfp.`date_from` <= \''.pSQL($date_to).'\' + AND rtfp.`date_to` >= \''.pSQL($date_from).'\' + AND rtfp.`id_feature_price`!='.(int) $id_feature_price.' + AND rtfpg.`id_group` IN ('.pSQL(implode(', ',$groups)).')' ); } return false; diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php index d77a293a2..0652f90c7 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelFeaturePricesSettings.php @@ -182,6 +182,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $objFeaturePricing->id_product, $objFeaturePricing->date_from, $objFeaturePricing->date_to, + $objFeaturePricing->getGroups($objFeaturePricing->id), $objFeaturePricing->id, $objFeaturePricing->is_special_days_exists, $objFeaturePricing->special_days @@ -283,6 +284,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $roomTypeId, $dateFrom, $dateTo, + $group, $idFeaturePrice, $isSpecialDaysExists = false, $jsonSpecialDays = "false" @@ -293,6 +295,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $roomTypeId, $dateFrom, $dateTo, + $group, 'specific_date', false, $idFeaturePrice @@ -302,6 +305,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $roomTypeId, $dateFrom, $dateTo, + $group, 'special_day', $jsonSpecialDays, $idFeaturePrice @@ -311,6 +315,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $roomTypeId, $dateFrom, $dateTo, + $group, 'date_range', false, $idFeaturePrice @@ -335,6 +340,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $impactValue = Tools::getValue('impact_value'); $dateSelectionType = Tools::getValue('date_selection_type'); $specificDate = date('Y-m-d', strtotime(Tools::getValue('specific_date'))); + $groups = Tools::getValue('groupBox'); $jsonSpecialDays = json_encode($specialDays); $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); @@ -361,6 +367,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $roomTypeId, $dateFrom, $dateTo, + $groups, $idFeaturePrice, $isSpecialDaysExists, $jsonSpecialDays @@ -435,7 +442,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController } } - if (!(bool)Tools::getValue('groupBox')) { + if (!(bool)$groups) { $this->errors[] = $this->l('Please select at least one group for the group access'); } @@ -467,7 +474,7 @@ class AdminHotelFeaturePricesSettingsController extends ModuleAdminController $objFeaturePricing->active = $enableFeaturePrice; // set the values of the groups for this feature price - $objFeaturePricing->groupBox = Tools::getValue('groupBox'); + $objFeaturePricing->groupBox = $groups; if ($objFeaturePricing->save()) { if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) { From 08d9017845a894307685f73e815030adcfe43dba Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 11 Jun 2024 12:02:44 +0530 Subject: [PATCH 23/63] applied changes to the new uploaded files after merge --- .../wkroomsearchblock/views/templates/front/hotel-options.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wkroomsearchblock/views/templates/front/hotel-options.tpl b/modules/wkroomsearchblock/views/templates/front/hotel-options.tpl index b6dd9cd0d..1c258d2c8 100644 --- a/modules/wkroomsearchblock/views/templates/front/hotel-options.tpl +++ b/modules/wkroomsearchblock/views/templates/front/hotel-options.tpl @@ -20,7 +20,7 @@ {if isset($hotels_info) && is_array($hotels_info)} {foreach from=$hotels_info item=hotel_info} - {/foreach} From e7c85cd15424cfa48b93175dfeab5f9ea4df8903 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 12 Jun 2024 11:28:54 +0530 Subject: [PATCH 24/63] Fixed: Hotel locations is displayed on the google map at order-detail and category page even if option 'Display Google Maps For Hotel Location' is disabled --- controllers/front/GuestTrackingController.php | 4 +++- controllers/front/OrderDetailController.php | 5 ++++- .../admin/AdminHotelGeneralSettingsController.php | 2 +- modules/hotelreservationsystem/hotelreservationsystem.php | 4 +++- themes/hotel-reservation-theme/order-detail.tpl | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/controllers/front/GuestTrackingController.php b/controllers/front/GuestTrackingController.php index e7017e12f..b58af864e 100644 --- a/controllers/front/GuestTrackingController.php +++ b/controllers/front/GuestTrackingController.php @@ -629,7 +629,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/OrderDetailController.php b/controllers/front/OrderDetailController.php index afa1ea9e8..ed11b9cc3 100644 --- a/controllers/front/OrderDetailController.php +++ b/controllers/front/OrderDetailController.php @@ -406,6 +406,7 @@ class OrderDetailControllerCore extends FrontController 'obj_hotel_branch_information' => $objHotelBranchInformation, 'hotel_address_info' => $hotelAddressInfo, 'hotel_refund_rules' => $hotelRefundRules, + 'view_on_google_map' => Configuration::get('WK_GOOGLE_ACTIVE_MAP'), ) ); // } @@ -782,7 +783,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 ) { diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index 2d8d7ff6d..a0fb09dad 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -307,7 +307,7 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'value' => 0, ), ), - 'hint' => $this->l('If set to No, Google Maps will not be displayed for hotel location. You need to set hotels location from edit hotel page to display location on the map at contact-us page.'), + 'hint' => $this->l('If set to No, Google Maps will not be displayed for hotel location. You need to set hotels location from edit hotel page to display location on the map on front office.'), ), 'WK_MAP_HOTEL_ACTIVE_ONLY' => array( 'title' => $this->l('Display Active Hotels Only'), diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index 76a6c3bae..d2bfe7cb0 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -293,7 +293,9 @@ class HotelReservationSystem extends Module public function hookDisplayLeftColumn() { if (Tools::getValue('controller') == 'category') { - if ($apiKey = Configuration::get('PS_API_KEY')) { + if (($apiKey = Configuration::get('PS_API_KEY')) + && Configuration::get('WK_GOOGLE_ACTIVE_MAP') + ) { $idCategory = Tools::getValue('id_category'); $idHotel = HotelBranchInformation::getHotelIdByIdCategory($idCategory); $objHotel = new HotelBranchInformation($idHotel, $this->context->language->id); diff --git a/themes/hotel-reservation-theme/order-detail.tpl b/themes/hotel-reservation-theme/order-detail.tpl index e0000be46..ebbc7575e 100644 --- a/themes/hotel-reservation-theme/order-detail.tpl +++ b/themes/hotel-reservation-theme/order-detail.tpl @@ -155,7 +155,7 @@
    {l s='Hotel location not available.'}
    {/if} - {if ($obj_hotel_branch_information->latitude|floatval != 0 && $obj_hotel_branch_information->longitude|floatval != 0)} + {if ($obj_hotel_branch_information->latitude|floatval != 0 && $obj_hotel_branch_information->longitude|floatval != 0) && $view_on_google_map}
    @@ -542,7 +542,7 @@
    {l s='Hotel location not available.'}
    {/if} - {if ($obj_hotel_branch_information->latitude|floatval != 0 && $obj_hotel_branch_information->longitude|floatval != 0)} + {if ($obj_hotel_branch_information->latitude|floatval != 0 && $obj_hotel_branch_information->longitude|floatval != 0) && $view_google_map}
    From 601e51b514c42848b0c7562cd7f9307982fe72fd Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Fri, 14 Jun 2024 12:39:42 +0530 Subject: [PATCH 25/63] Fixed the new customer KPI --- .../admin/AdminCustomersController.php | 20 +++++++++++++++++++ controllers/admin/AdminStatsController.php | 8 +++++++- modules/dashactivity/views/js/dashactivity.js | 6 ++++-- .../templates/hook/dashboard_zone_one.tpl | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 6c763f10c..526c59dbb 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -230,6 +230,23 @@ class AdminCustomersControllerCore extends AdminController )); } + $prefix = $this->getCookieFilterPrefix(); + if (Tools::getValue('filterOnlyNewCustomer')) { + if (($dateFrom = Tools::getValue('date_from')) + && ($dateTo = Tools::getValue('date_to')) + && strtotime($dateTo) >= strtotime($dateFrom) + ) { + $this->processResetFilters(); + $this->context->cookie->{'submitFilter'.$this->table} = true; + //Updating the date format of the filter dates to the desired format. + $dateFrom = date('Y-m-d', strtotime($dateFrom)); + $dateTo = date('Y-m-d', strtotime($dateTo)); + $this->context->cookie->{$prefix.$this->table.'Filter_date_add'} = json_encode(array($dateFrom, $dateTo)); + } + + $this->redirect_after = $this->context->link->getAdminLink('AdminCustomers'); + } + if (!$this->can_add_customer && !$this->display) { $this->informations[] = $this->l('You have to select a shop if you want to create a customer.'); } @@ -739,6 +756,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').'&filterOnlyNewCustomer=1&date_from='.$date_from.'&date_to='.$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); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index f647411b1..abd0d9be7 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -981,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'); @@ -1879,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'; diff --git a/modules/dashactivity/views/js/dashactivity.js b/modules/dashactivity/views/js/dashactivity.js index a84820e02..1aa71314a 100644 --- a/modules/dashactivity/views/js/dashactivity.js +++ b/modules/dashactivity/views/js/dashactivity.js @@ -58,7 +58,8 @@ $(document).ready(function() { $('#date-start').change(function() { start = Date.parseDate($('#date-start').val(), 'Y-m-d'); end = Date.parseDate($('#date-end').val(), 'Y-m-d'); - + var url = $('#dash_filter_new_customers').data('href') + '&date_from='+start.format('Y-m-d')+ '&date_to='+ end.format('Y-m-d'); + $('#dash_filter_new_customers').attr('href', url); $('#customers-newsletters-subtitle').html(sprintf(date_subtitle, start.format(date_format), end.format(date_format))); $('#traffic-subtitle').html(sprintf(date_subtitle, start.format(date_format), end.format(date_format))); }); @@ -66,7 +67,8 @@ $(document).ready(function() { $('#date-end').change(function() { start = Date.parseDate($('#date-start').val(), 'Y-m-d'); end = Date.parseDate($('#date-end').val(), 'Y-m-d'); - + var url = $('#dash_filter_new_customers').data('href') + '&date_from='+start.format('Y-m-d')+ '&date_to='+ end.format('Y-m-d'); + $('#dash_filter_new_customers').attr('href', url); $('#customers-newsletters-subtitle').html(sprintf(date_subtitle, start.format(date_format), end.format(date_format))); $('#traffic-subtitle').html(sprintf(date_subtitle, start.format(date_format), end.format(date_format))); }); diff --git a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl index 95cee2cd3..a649805a3 100644 --- a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl +++ b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl @@ -121,7 +121,7 @@