diff --git a/admin/themes/default/sass/partials/_kpi.sass b/admin/themes/default/sass/partials/_kpi.sass index ca3b43257..78df786ff 100644 --- a/admin/themes/default/sass/partials/_kpi.sass +++ b/admin/themes/default/sass/partials/_kpi.sass @@ -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 diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index b72c4e4cb..0570a9d46 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -68,40 +68,64 @@ {/if}
-
-
-
- - {l s='Date'} - {dateFormat date=$order->date_add full=false} -
-
-
-
- - {l s='Total'} - {displayPrice price=$order->total_paid_tax_incl currency=$currency->id} -
-
-
-
- - {l s='Messages'} - {sizeof($customer_thread_message)} -
-
-
diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php index 73e397ed2..cd9f4cee5 100644 --- a/controllers/admin/AdminCustomerPreferencesController.php +++ b/controllers/admin/AdminCustomerPreferencesController.php @@ -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', diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 5f5988b19..bcfc1b4e1 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -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); diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index 1d574a783..5ddd8cb31 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -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); diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php index 0514f3d4d..d47812a4f 100644 --- a/controllers/admin/AdminStatsController.php +++ b/controllers/admin/AdminStatsController.php @@ -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;