Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions controllers/admin/AdminCartsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ public function renderKpis()
//$helper->chart = true;
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
if ($daysForConversionRate == 1) {
$helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
}
if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) {
$helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
}
Expand All @@ -217,7 +221,12 @@ public function renderKpis()
$helper->icon = 'icon-money';
$helper->color = 'color3';
$helper->title = $this->l('Average Order Value', null, null, false);
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
if ($daysForAvgOrderVal == 1) {
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
}

$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
$this->kpis[] = $helper;

Expand All @@ -227,7 +236,11 @@ public function renderKpis()
$helper->icon = 'icon-user';
$helper->color = 'color4';
$helper->title = $this->l('Net Profit per Visitor', null, null, false);
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false);
if ($daysForProfitPerVisitor == 1) {
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false);
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit';
$this->kpis[] = $helper;

Expand Down
16 changes: 14 additions & 2 deletions controllers/admin/AdminCustomerPreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,21 @@ public function __construct()

public function beforeUpdateOptions()
{
$fieldData = $this->fields_options['customer_kpi']['fields']['PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS'];
$frequentCustomerField = $this->fields_options['customer_kpi']['fields']['PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS'];
if (!Tools::getValue('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $fieldData['title']);;
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $frequentCustomerField['title']);;
}
$revpacField = $this->fields_options['customer_kpi']['fields']['PS_KPI_REVPAC_NB_DAYS'];
if (!Tools::getValue('PS_KPI_REVPAC_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $revpacField['title']);;
}
$conversionRateField = $this->fields_options['customer_kpi']['fields']['PS_KPI_CONVERSION_RATE_NB_DAYS'];
if (!Tools::getValue('PS_KPI_CONVERSION_RATE_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $conversionRateField['title']);;
}
$newCustomerNumDaysField = $this->fields_options['customer_kpi']['fields']['PS_KPI_NEW_CUSTOMERS_NB_DAYS'];
if (!Tools::getValue('PS_KPI_NEW_CUSTOMERS_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $newCustomerNumDaysField['title']);;
}
}

Expand Down
27 changes: 20 additions & 7 deletions controllers/admin/AdminCustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,13 @@ public function renderKpis()
$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();
Expand All @@ -787,9 +791,13 @@ public function renderKpis()
$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();
Expand All @@ -798,12 +806,17 @@ public function renderKpis()
$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();
Expand Down
10 changes: 10 additions & 0 deletions controllers/admin/AdminOrderPreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,16 @@ public function beforeUpdateOptions()
$this->errors[] = Tools::displayError('Field \'Maximum checkout offset\' is invalid.');
}

$avgOrderValueField = $this->fields_options['general']['fields']['PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS'];
if (!Tools::getValue('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $avgOrderValueField['title']);;
}

$netProfitField = $this->fields_options['general']['fields']['PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS'];
if (!Tools::getValue('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $netProfitField['title']);;
}

if ($minBookingOffset === '') {
$this->errors[] = Tools::displayError('Field \'Minimum booking offset\' can not be empty.');
} elseif ($minBookingOffset != 0 && !Validate::isUnsignedInt($minBookingOffset)) {
Expand Down
16 changes: 12 additions & 4 deletions controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3030,9 +3030,13 @@ public function renderKpis()
$helper->icon = 'icon-sort-by-attributes-alt';
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
if ($daysForConversionRate == 1) {
$helper->subtitle = $daysForConversionRate.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
$helper->tooltip = $this->l('Percentage of visits that resulted in an order/booking in given period of time.', null, null, false);
$helper->tooltip = sprintf($this->l('Percentage of visits that resulted in an order/booking in last %s day(s).', null, null, false), $daysForConversionRate);
$this->kpis[] = $helper;

$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
Expand All @@ -3041,9 +3045,13 @@ public function renderKpis()
$helper->icon = 'icon-money';
$helper->color = 'color3';
$helper->title = $this->l('Average Order Value', null, null, false);
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
if ($daysForAvgOrderVal == 1) {
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('day', null, null, false);
} else {
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
$helper->tooltip = $this->l('Total average order value without tax in given period of time.', null, null, false);
$helper->tooltip = sprintf($this->l('Total average order value without tax in the last %s day(s).', null, null, false), $daysForAvgOrderVal);
$this->kpis[] = $helper;

$helper = new HelperKpi();
Expand Down
5 changes: 5 additions & 0 deletions controllers/admin/AdminPPreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ public function beforeUpdateOptions()
$_POST['PS_DISPLAY_QTIES'] = 0;
}

$bestSellingField = $this->fields_options['products']['fields']['PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS'];
if (!Tools::getValue('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS')) {
$this->errors[] = sprintf(Tools::displayError('field %s must be greater than 0.'), $bestSellingField['title']);;
}

// if advanced stock management is disabled, updates concerned tables
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 && (int)Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0) {
$id_shop_list = Shop::getContextListShopID();
Expand Down
9 changes: 7 additions & 2 deletions controllers/admin/AdminProductsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2646,9 +2646,14 @@ public function renderKpis()
$helper->color = 'color1';
$helper->title = $this->l('Best Selling', null, null, false);
$nbDaysBestSelling = Validate::isUnsignedInt(Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS')) ? Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS') : 30;
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysBestSelling);
if ($nbDaysBestSelling == 1) {
$helper->subtitle = sprintf($this->l('%d Day', null, null, false), (int) $nbDaysBestSelling);
} else {
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysBestSelling);
}

$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=best_selling_room_type';
$helper->tooltip = $this->l('Displays the best selling room type based on the last 30 days of sales.', null, null, false);
$helper->tooltip = sprintf($this->l('Displays the best selling room type based on the sales in the last %s day(s).', null, null, false), $nbDaysBestSelling);
$this->kpis[] = $helper;

$helper = new HelperKpi();
Expand Down
Loading