Updated the KPIs to get the current date inclusive data

This commit is contained in:
vishalsingh.qlo325
2025-06-17 21:02:30 +05:30
parent 1ec8f8307c
commit d138a95328
8 changed files with 135 additions and 38 deletions

View File

@@ -766,9 +766,13 @@ class AdminCustomersControllerCore extends AdminController
$helper->color = 'color3';
$helper->title = $this->l('RevPAC', null, null, false);
$nbDaysRevPac = Validate::isUnsignedInt(Configuration::get('PS_KPI_REVPAC_NB_DAYS')) ? Configuration::get('PS_KPI_REVPAC_NB_DAYS') : 30;
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysRevPac);
if ($nbDaysRevPac == 1) {
$helper->subtitle = sprintf($this->l('%d Day', null, null, false), (int) $nbDaysRevPac);
} else {
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysRevPac);
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=revenue_per_available_customer';
$helper->tooltip = $this->l('Revenue per Available Customer (RevPAC) in given period of time.', null, null, false);
$helper->tooltip = sprintf($this->l('Revenue per Available Customer (RevPAC) in the last %s day(s).', null, null, false), $nbDaysRevPac);
$this->kpis[] = $helper;
$helper = new HelperKpi();
@@ -787,9 +791,13 @@ class AdminCustomersControllerCore extends AdminController
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$nbDaysConversionRate = Validate::isUnsignedInt(Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS')) ? Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS') : 30;
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysConversionRate);
if ($nbDaysConversionRate == 1) {
$helper->subtitle = $nbDaysConversionRate.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $nbDaysConversionRate.' '.$this->l('days', null, null, false);
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
$helper->tooltip = $this->l('The percentage of visitors who created a booking in given period of time.', null, null, false);
$helper->tooltip = sprintf($this->l('The percentage of visitors who created a booking in last %s day(s).', null, null, false), $nbDaysConversionRate);
$this->kpis[] = $helper;
$helper = new HelperKpi();
@@ -798,12 +806,17 @@ 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'));
if ($nbDaysNewCustomers == 1) {
$helper->subtitle = sprintf($this->l('%d Day', null, null, false), (int) $nbDaysNewCustomers);
$date_from = date('Y-m-d');
} else {
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysNewCustomers);
$date_from = date('Y-m-d', strtotime('-'.($nbDaysNewCustomers - 1).' day'));
}
$date_to = date('Y-m-d');
$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);
$helper->tooltip = sprintf($this->l('The total number of new customers who registered in last %s day(s).', null, null, false), $nbDaysNewCustomers);
$this->kpis[] = $helper;
$helper = new HelperKpi();