Merge pull request #1496 from vishal-singh-webkul/gli-2703
Updated: The KPIs will now include data up to and including the current date in the back office
This commit is contained in:
@@ -192,7 +192,11 @@ class AdminCartsControllerCore extends AdminController
|
||||
//$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');
|
||||
}
|
||||
@@ -217,7 +221,12 @@ class AdminCartsControllerCore extends AdminController
|
||||
$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;
|
||||
|
||||
@@ -227,7 +236,11 @@ class AdminCartsControllerCore extends AdminController
|
||||
$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;
|
||||
|
||||
|
||||
@@ -185,9 +185,21 @@ class AdminCustomerPreferencesControllerCore extends AdminController
|
||||
|
||||
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']);;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -414,6 +414,16 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
$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)) {
|
||||
|
||||
@@ -3030,9 +3030,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$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');
|
||||
@@ -3041,9 +3045,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$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();
|
||||
|
||||
@@ -415,6 +415,11 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
$_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();
|
||||
|
||||
@@ -2646,9 +2646,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$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();
|
||||
|
||||
@@ -778,7 +778,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
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).'"
|
||||
AND hbd.`date_to` >= "'.pSQL($dateFrom).'" AND hbd.`date_from` <= "'.pSQL($dateTo).'"
|
||||
) as total_booked FROM `'._DB_PREFIX_.'product` p
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt
|
||||
ON (hrt.`id_product` = p.`id_product`)
|
||||
@@ -811,17 +811,22 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
switch ($kpi) {
|
||||
case 'conversion_rate':
|
||||
$nbDaysConversionRate = Validate::isUnsignedInt(Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS')) ? Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS') : 30;
|
||||
|
||||
if ($nbDaysConversionRate == 1) {
|
||||
$dateFrom = date('Y-m-d');
|
||||
} else {
|
||||
$dateFrom = date('Y-m-d', strtotime('-'.($nbDaysConversionRate - 1).' day'));
|
||||
}
|
||||
$dateTo = date('Y-m-d');
|
||||
$visitors = AdminStatsController::getVisits(
|
||||
true,
|
||||
date('Y-m-d', strtotime('-'.($nbDaysConversionRate + 1).' day')),
|
||||
date('Y-m-d', strtotime('+1 day')),
|
||||
false,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
false /*'day'*/
|
||||
);
|
||||
|
||||
$orders = AdminStatsController::getOrders(
|
||||
date('Y-m-d', strtotime('-'.($nbDaysConversionRate + 1).' day')),
|
||||
date('Y-m-d', strtotime('-1 day')),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
false /*'day'*/,
|
||||
$idHotels
|
||||
);
|
||||
@@ -923,7 +928,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case 'avg_msg_response_time':
|
||||
$value = AdminStatsController::getAverageMessageResponseTime(date('Y-m-d', strtotime('-31 day')), date('Y-m-d', strtotime('-1 day')), true);
|
||||
$value = AdminStatsController::getAverageMessageResponseTime(date('Y-m-d', strtotime('-30 day')), date('Y-m-d'), true);
|
||||
|
||||
if ($value <= 0) {
|
||||
$value = '--';
|
||||
@@ -937,7 +942,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case 'messages_per_thread':
|
||||
$value = round(AdminStatsController::getMessagesPerThread(date('Y-m-d', strtotime('-31 day')), date('Y-m-d', strtotime('-1 day'))), 1);
|
||||
$value = round(AdminStatsController::getMessagesPerThread(date('Y-m-d', strtotime('-31 day')), date('Y-m-d')), 1);
|
||||
break;
|
||||
|
||||
case 'enabled_languages':
|
||||
@@ -980,16 +985,22 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case 'average_order_value':
|
||||
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
|
||||
$daysForAvgOrderVal = Validate::isUnsignedInt(Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS')) ? Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS') : 30;
|
||||
|
||||
if ($daysForAvgOrderVal == 1) {
|
||||
$dateFrom = date('Y-m-d');
|
||||
} else {
|
||||
$dateFrom = date('Y-m-d', strtotime('-'.($daysForAvgOrderVal -1).' day'));
|
||||
}
|
||||
$dateTo = date('Y-m-d');
|
||||
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
|
||||
SELECT
|
||||
COUNT(o.`id_order`) as orders,
|
||||
SUM(o.`total_paid_tax_excl` / o.`conversion_rate`) as total_paid_tax_excl
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON os.`id_order_state` = o.`current_state`
|
||||
WHERE o.`invoice_date` BETWEEN "'.pSQL(date('Y-m-d', strtotime('-'.($daysForAvgOrderVal + 1).' day'))).' 00:00:00"
|
||||
AND "'.pSQL(date('Y-m-d')).' 23:59:59" AND os.`logable` = 1
|
||||
WHERE o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00"
|
||||
AND "'.pSQL($dateTo).' 23:59:59" AND os.`logable` = 1
|
||||
AND (
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
@@ -1010,15 +1021,19 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case 'netprofit_visit':
|
||||
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
|
||||
$daysForProfitPerVisitor = Validate::isUnsignedInt(Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS')) ? Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS') : 30;
|
||||
|
||||
$date_from = date('Y-m-d', strtotime('-'.($daysForProfitPerVisitor + 1).' day'));
|
||||
$date_to = date('Y-m-d', strtotime('-1 day'));
|
||||
if ($daysForProfitPerVisitor == 1) {
|
||||
$dateFrom = date('Y-m-d');
|
||||
} else {
|
||||
$dateFrom = date('Y-m-d', strtotime('-'.($daysForProfitPerVisitor -1).' day'));
|
||||
}
|
||||
|
||||
$total_visitors = AdminStatsController::getVisits(false, $date_from, $date_to);
|
||||
$net_profits = AdminStatsController::getTotalSales($date_from, $date_to, false, $idHotels);
|
||||
$net_profits -= AdminStatsController::getExpenses($date_from, $date_to, false, $idHotels);
|
||||
$net_profits -= AdminStatsController::getPurchases($date_from, $date_to, false, $idHotels);
|
||||
$dateTo = date('Y-m-d');
|
||||
$total_visitors = AdminStatsController::getVisits(false, $dateFrom, $dateTo);
|
||||
$net_profits = AdminStatsController::getTotalSales($dateFrom, $dateTo, false, $idHotels);
|
||||
$net_profits -= AdminStatsController::getExpenses($dateFrom, $dateTo, false, $idHotels);
|
||||
$net_profits -= AdminStatsController::getPurchases($dateFrom, $dateTo, false, $idHotels);
|
||||
|
||||
if ($total_visitors) {
|
||||
$value = Tools::displayPrice($net_profits / $total_visitors, $currency);
|
||||
@@ -1049,9 +1064,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
case 'best_selling_room_type':
|
||||
$nbDaysBestSelling = Validate::isUnsignedInt(Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS')) ? Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS') : 30;
|
||||
|
||||
if ($nbDaysBestSelling == 1) {
|
||||
$dateFrom = date('Y-m-d');
|
||||
} else {
|
||||
$dateFrom = date('Y-m-d', strtotime('-'.($nbDaysBestSelling - 1).' day'));
|
||||
}
|
||||
|
||||
$dateTo = date('Y-m-d');
|
||||
if (!($idProduct = AdminStatsController::getBestSellingRoomType(
|
||||
date('Y-m-d', strtotime('-'.($nbDaysBestSelling + 1).' day')),
|
||||
date('Y-m-d', strtotime('-1 day')),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idHotels
|
||||
))) {
|
||||
$value = $this->l('--', null, null, false);
|
||||
@@ -1133,10 +1155,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
case 'revenue_per_available_customer':
|
||||
$nbDaysRevPac = Configuration::get('PS_KPI_REVPAC_NB_DAYS');
|
||||
if ($nbDaysRevPac == 1) {
|
||||
$dateFrom = date('Y-m-d');
|
||||
} else {
|
||||
$dateFrom = date('Y-m-d', strtotime('-'.($nbDaysRevPac -1).' day'));
|
||||
}
|
||||
|
||||
$dateTo = date('Y-m-d');
|
||||
$value = AdminStatsController::getRevenuePerAvailableCustomer(
|
||||
date('Y-m-d', strtotime('-'.($nbDaysRevPac + 1).' day')),
|
||||
date('Y-m-d', strtotime('-1 day')),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$idHotels
|
||||
);
|
||||
|
||||
@@ -2116,7 +2144,12 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getTotalNewCustomers($nbDaysNewCustomers)
|
||||
{
|
||||
$maxDateAdd = date('Y-m-d', strtotime('-'.$nbDaysNewCustomers.' day'));
|
||||
if ($nbDaysNewCustomers == 1) {
|
||||
$maxDateAdd = date('Y-m-d');
|
||||
} else {
|
||||
$maxDateAdd = date('Y-m-d', strtotime('-'.($nbDaysNewCustomers -1).' day'));
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(c.`id_customer`)
|
||||
FROM `'._DB_PREFIX_.'customer` c
|
||||
WHERE c.`date_add` >= "'.pSQL($maxDateAdd).'" AND c.`deleted` = 0';
|
||||
|
||||
Reference in New Issue
Block a user