From e28453584de7b1acb8b4c3d80320ae3c5098678b Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 10 Oct 2024 12:59:54 +0530 Subject: [PATCH 1/2] Updated: Remove previous filters when applying new filter from KPI --- classes/controller/AdminController.php | 3 +++ controllers/admin/AdminCustomersController.php | 6 +++--- controllers/admin/AdminOrdersController.php | 8 ++++---- controllers/admin/AdminProductsController.php | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 405797c38..12bef797f 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -3066,6 +3066,9 @@ class AdminControllerCore extends Controller || $this->context->cookie->{'submitFilter'.$this->list_id} !== false || Tools::getValue($this->list_id.'Orderby') || Tools::getValue($this->list_id.'Orderway')) { + if (Tools::isSubmit('submitReset'.$this->list_id)) { + $this->processResetFilters($this->list_id); + } $this->filter = true; } diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 79cdae793..38d0d82c9 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -720,7 +720,7 @@ class AdminCustomersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Total Frequent Customers', null, null, false); $helper->subtitle = $this->l('1 year', null, null, false); - $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&submitFiltercustomer=1&customerFilter_total_orders%5B0%5D='.Configuration::get('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS').'&customerFilter_o%21date_add%5B0%5D='.date('Y-m-d', strtotime('-365 day')).'&customerFilter_o%21date_add%5B1%5D='.date('Y-m-d'); + $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&submitResetcustomer&submitFiltercustomer=1&customerFilter_total_orders%5B0%5D='.Configuration::get('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS').'&customerFilter_o%21date_add%5B0%5D='.date('Y-m-d', strtotime('-365 day')).'&customerFilter_o%21date_add%5B1%5D='.date('Y-m-d'); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_frequent_customers'; $helper->tooltip = $this->l('The total number of frequent customers in given period of time.', null, null, false); $this->kpis[] = $helper; @@ -765,7 +765,7 @@ class AdminCustomersControllerCore extends AdminController $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_a!date_add[]='.$date_from.'&customerFilter_a!date_add[]='.$date_to; + $helper->href = $this->context->link->getAdminLink('AdminCustomers').'&submitResetcustomer&submitFiltercustomer=1&customerFilter_a!date_add[]='.$date_from.'&customerFilter_a!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); @@ -777,7 +777,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->href = $this->context->link->getAdminLink('AdminCustomers').'&submitResetcustomer&submitFiltercustomer=1&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); $this->kpis[] = $helper; diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 75490c162..5871a6137 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -2515,7 +2515,7 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Total Due Amount', null, null, false); $minValue = ('0.' . str_repeat('0', (Configuration::get('PS_PRICE_DISPLAY_PRECISION') - 1)) . '1'); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_amount_due%5B0%5D='.$minValue; + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_amount_due%5B0%5D='.$minValue; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_due_amount'; $helper->tooltip = $this->l('Total due amount of all the orders created.', null, null, false); $this->kpis[] = $helper; @@ -2527,7 +2527,7 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color1'; $helper->title = $this->l('Arrivals', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ALLOTED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')); + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_ALLOTED.'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_from[]='.pSQL(date('Y-m-d')); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_arrivals'; $helper->tooltip = $this->l('Total number of arrivals for today.', null, null, false); $this->kpis[] = $helper; @@ -2539,7 +2539,7 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Departures', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d')); + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d')).'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d')); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_departures'; $helper->tooltip = $this->l('Total number of departures for today.', null, null, false); $this->kpis[] = $helper; @@ -2552,7 +2552,7 @@ class AdminOrdersControllerCore extends AdminController $helper->color = 'color4'; $helper->title = $this->l('Stay Overs', null, null, false); $helper->subtitle = $this->l('Today', null, null, false); - $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d', strtotime('+ 1 days'))).'&orderFilter_hbd!date_to[]='; + $helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder&submitFilterorder=1&orderFilter_hbd!is_refunded=0&orderFilter_hbd!id_status='.HotelBookingDetail::STATUS_CHECKED_IN.'&orderFilter_hbd!date_to[]='.pSQL(date('Y-m-d', strtotime('+ 1 days'))).'&orderFilter_hbd!date_to[]='; $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_stay_over'; $helper->tooltip = $this->l('Total number of stay overs for today.', null, null, false); $this->kpis[] = $helper; diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index d68e88941..ca230ad15 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2551,7 +2551,7 @@ class AdminProductsControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Disabled Room Types', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_room_types'; - $helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&productFilter_sa!active=0&submitFilterproduct=1'; + $helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&submitResetproduct&submitFilterproduct=1&&productFilter_sa!active=0&submitFilterproduct=1'; $helper->tooltip = $this->l('The total number of room types that are currently disabled.', null, null, false); $this->kpis[] = $helper; From 6798d6ad7562b0da960c921452b8ee6492db03c4 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 10 Oct 2024 13:36:40 +0530 Subject: [PATCH 2/2] updated kpi filter url --- controllers/admin/AdminProductsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index ca230ad15..80ac896f9 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2551,7 +2551,7 @@ class AdminProductsControllerCore extends AdminController $helper->color = 'color2'; $helper->title = $this->l('Disabled Room Types', null, null, false); $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_room_types'; - $helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&submitResetproduct&submitFilterproduct=1&&productFilter_sa!active=0&submitFilterproduct=1'; + $helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&submitResetproduct&submitFilterproduct=1&productFilter_sa!active=0&submitFilterproduct=1'; $helper->tooltip = $this->l('The total number of room types that are currently disabled.', null, null, false); $this->kpis[] = $helper;