Fix incorrect values

This commit is contained in:
Abhishek Kumar
2024-02-16 15:19:55 +05:30
parent fbb1c2b6ec
commit 2d6f0da309
6 changed files with 95 additions and 66 deletions

View File

@@ -58,7 +58,14 @@ $kpi-gap: 10px
white-space: normal
flex-wrap: nowrap
.kpi-wrap
min-width: 200px
@media (min-width: $screen-lg)
min-width: 20%
@media (max-width: $screen-lg)
min-width: 20%
@media (max-width: $screen-sm)
min-width: 33.33%
@media (max-width: $screen-xs)
min-width: 50%
@media (max-width: $screen-desktop)
&.no-wrapping

View File

@@ -68,40 +68,64 @@
{/if}
<div class="panel kpi-container">
<div class="row">
<div class="col-xs-6 col-sm-3 box-stats color3" >
<div class="kpi-content">
<i class="icon-calendar-empty"></i>
<span class="title">{l s='Date'}</span>
<span class="value">{dateFormat date=$order->date_add full=false}</span>
</div>
</div>
<div class="col-xs-6 col-sm-3 box-stats color4" >
<div class="kpi-content">
<i class="icon-money"></i>
<span class="title">{l s='Total'}</span>
<span class="value">{displayPrice price=$order->total_paid_tax_incl currency=$currency->id}</span>
</div>
</div>
<div class="col-xs-6 col-sm-3 box-stats color2" >
<div class="kpi-content">
<i class="icon-comments"></i>
<span class="title">{l s='Messages'}</span>
<span class="value"><a href="{$link->getAdminLink('AdminCustomerThreads')|escape:'html':'UTF-8'}&amp;id_order={$order->id|intval}">{sizeof($customer_thread_message)}</a></span>
</div>
</div>
<div class="col-xs-6 col-sm-3 box-stats color1" >
<a href="#start_products">
<div class="kpis-wrap">
<div class="kpi-wrap">
<div class="box-stats color3">
<div class="kpi-content">
<i class="icon icon-home"></i>
<!-- Original -->
<!-- <span class="title">{l s='Total'}</span>
<span class="value">{sizeof($products)}</span> -->
<span class="title">{l s='Total Rooms'}</span>
<span class="value">{$order_detail_data|@count}</span>
<div class="title-subtitle">
<div class="title-container">
<span class="title"><i class="icon-calendar-empty"></i> {l s='Date'}</span>
</div>
</div>
<div class="value-container">
<span class="value">{dateFormat date=$order->date_add}</span>
</div>
</div>
</div>
</div>
<div class="kpi-wrap">
<div class="box-stats color4">
<div class="kpi-content">
<div class="title-subtitle">
<div class="title-container">
<span class="title"><i class="icon-money"></i> {l s='Total'}</span>
</div>
</div>
<div class="value-container">
<span class="value">{displayPrice price=$order->total_paid_tax_incl currency=$currency->id}</span>
</div>
</div>
</div>
</div>
<div class="kpi-wrap">
<a href="{$link->getAdminLink('AdminCustomerThreads')|escape:'html':'UTF-8'}&amp;id_order={$order->id|intval}" class="box-stats color2">
<div class="kpi-content">
<div class="title-subtitle">
<div class="title-container">
<span class="title"><i class="icon-comments"></i> {l s='Messages'}</span>
</div>
</div>
<div class="value-container">
<span class="value">{count($customer_thread_message)}</span>
</div>
<span class="arrow"><i class="icon-angle-right"></i></span>
</div>
</a>
</div>
<div class="kpi-wrap">
<a href="#start_products" class="box-stats color1">
<div class="kpi-content">
<div class="title-subtitle">
<div class="title-container">
<span class="title"><i class="icon-home"></i> {l s='Total Rooms'}</span>
</div>
</div>
<div class="value-container">
<span class="value">{count($order_detail_data)}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">

View File

@@ -138,7 +138,7 @@ class AdminCustomerPreferencesControllerCore extends AdminController
),
'PS_KPI_REVPAC_NB_DAYS' => array(
'title' => $this->l('Number of days to use to calculate RevPAC'),
'hint' => $this->l('Set the number of days to use to calculate RevPAC.'),
'hint' => $this->l('Set the number of days to use to calculate Revenue Per Available Customer.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
@@ -155,8 +155,8 @@ class AdminCustomerPreferencesControllerCore extends AdminController
'class' => 'fixed-width-xl',
),
'PS_KPI_NEW_CUSTOMERS_NB_DAYS' => array(
'title' => $this->l('Number of days to use to calculate New Customers'),
'hint' => $this->l('Set the number of days to use to calculate New Customers.'),
'title' => $this->l('Number of days for which a customer is considered \'new\''),
'hint' => $this->l('Set the number of days for which a customer is considered \'new\' after creation date.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',

View File

@@ -672,10 +672,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->icon = 'icon-dollar';
$helper->color = 'color3';
$helper->title = $this->l('RevPAC', null, null, false);
$nbDaysRevPac = 30;
if (Configuration::get('PS_KPI_REVPAC_NB_DAYS') !== false) {
$nbDaysRevPac = Configuration::get('PS_KPI_REVPAC_NB_DAYS');
}
$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);
$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);
@@ -696,10 +693,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->icon = 'icon-refresh';
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$nbDaysConversionRate = 30;
if (Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS') !== false) {
$nbDaysConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
}
$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);
$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);
@@ -710,10 +704,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->icon = 'icon-plus-circle';
$helper->color = 'color4';
$helper->title = $this->l('New Customers', null, null, false);
$nbDaysNewCustomers = 30;
if (Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS') !== false) {
$nbDaysNewCustomers = Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS');
}
$nbDaysNewCustomers = Validate::isUnsignedInt(Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS')) ? Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS') : 30;
$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);

View File

@@ -2309,10 +2309,7 @@ class AdminProductsControllerCore extends AdminController
$helper->icon = 'icon-star';
$helper->color = 'color1';
$helper->title = $this->l('Best Selling', null, null, false);
$nbDaysBestSelling = 30;
if (Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS') !== false) {
$nbDaysBestSelling = Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS');
}
$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);
$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);

View File

@@ -364,7 +364,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
SELECT SUM(IF(c.id_gender IS NOT NULL, 1, 0)) as total, SUM(IF(type = 0, 1, 0)) as male, SUM(IF(type = 1, 1, 0)) as female, SUM(IF(type = 2, 1, 0)) as neutral
FROM `'._DB_PREFIX_.'customer` c
LEFT JOIN `'._DB_PREFIX_.'gender` g ON c.id_gender = g.id_gender
WHERE c.active = 1 '.Shop::addSqlRestriction());
WHERE c.active = 1 AND c.deleted = 0 '.Shop::addSqlRestriction());
if (!$row['total']) {
return false;
@@ -571,6 +571,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
ON (hrt.`id_product` = p.`id_product`)
WHERE p.`active` = 1 AND p.`booking_product` = 1'.
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hrt') : '').'
HAVING totalRevenue > 0
ORDER BY totalRevenue DESC';
return Db::getInstance()->getValue($sql);
@@ -595,7 +596,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
$value = false;
switch ($kpi) {
case 'conversion_rate':
$nbDaysConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
$nbDaysConversionRate = Validate::isUnsignedInt(Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS')) ? Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS') : 30;
$visitors = AdminStatsController::getVisits(
true,
@@ -811,7 +812,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'best_selling_room_type':
$nbDaysBestSelling = Configuration::get('PS_KPI_BEST_SELLING_ROOM_TYPE_NB_DAYS');
$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 (!($idProduct = AdminStatsController::getBestSellingRoomType(
date('Y-m-d', strtotime('-'.($nbDaysBestSelling + 1).' day')),
@@ -847,8 +848,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'total_vacant_rooms':
$value = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d', strtotime('-1 day')), null, 0);
$value = $value[strtotime(date('Y-m-d', strtotime('-1 day')))];
$totalAvailableRooms = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, 0);
$totalAvailableRooms = $totalAvailableRooms[strtotime(date('Y-m-d'))];
$totalOccupiedRooms = AdminStatsController::getTotalOccupiedRooms(0);
$value = $totalAvailableRooms - $totalOccupiedRooms;
break;
@@ -858,8 +861,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'total_disabled_rooms':
$value = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d', strtotime('-1 day')), null, 0);
$value = $value[strtotime(date('Y-m-d', strtotime('-1 day')))];
$value = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, 0);
$value = $value[strtotime(date('Y-m-d'))];
break;
@@ -889,12 +892,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'total_new_customers':
$nbDaysNewCustomers = Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS');
$nbDaysNewCustomers = Validate::isUnsignedInt(Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS')) ? Configuration::get('PS_KPI_NEW_CUSTOMERS_NB_DAYS') : 30;
$value = AdminStatsController::getTotalNewCustomers(
date('Y-m-d', strtotime('-'.($nbDaysNewCustomers + 1).' day')),
date('Y-m-d', strtotime('-1 day')),
);
$value = AdminStatsController::getTotalNewCustomers($nbDaysNewCustomers);
break;
@@ -1213,14 +1213,17 @@ class AdminStatsControllerCore extends AdminStatsTabController
'SELECT SUM(total_paid_tax_excl - refunded_amount)
FROM (
SELECT o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl,
IFNULL(orr.`refunded_amount`, 0) AS refunded_amount,
(
SELECT IFNULL(SUM(orr.`refunded_amount`), 0)
FROM`'._DB_PREFIX_.'order_return` orr
WHERE orr.`id_order` = o.`id_order`
) AS refunded_amount,
(
SELECT hbd.`id_hotel`
FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
) AS id_hotel
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `' ._DB_PREFIX_.'order_return` orr ON orr.`id_order` = o.`id_order`
WHERE o.`valid` = 1 AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
HAVING 1 '.HotelBranchInformation::addHotelRestriction($idHotel).'
) AS t'
@@ -1706,6 +1709,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $result;
}
/**
* Returns the number of rooms that have been checked-in.
*/
public static function getTotalOccupiedRooms($idHotel = null)
{
$sql = 'SELECT COUNT(DISTINCT hbd.`id_room`)
@@ -1724,6 +1730,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $result;
}
/**
* Returns the number of rooms that have been booked but not checked-in yet.
*/
public static function getTotalReservedRooms($idHotel = null)
{
$dateToday = date('Y-m-d');
@@ -1799,11 +1808,12 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $customerRegistrations + $visitorRegistrations;
}
public static function getTotalNewCustomers($dateFrom, $dateTo)
public static function getTotalNewCustomers($nbDaysNewCustomers)
{
$maxDateAdd = date('Y-m-d H:i:s', strtotime('-'.$nbDaysNewCustomers.' day'));
$sql = 'SELECT COUNT(c.`id_customer`)
FROM `'._DB_PREFIX_.'customer` c
WHERE c.`date_add` >= "'.pSQL($dateFrom).' 00:00:00" AND c.`date_add` <= "'.pSQL($dateTo).' 23:59:59"';
WHERE c.`date_add` >= "'.pSQL($maxDateAdd).'" AND c.`deleted` = 0';
$result = Db::getInstance()->getValue($sql);
return $result;