// Added comparison to the dashboard
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
@import url(http://fonts.googleapis.com/css?family=Josefin+Sans:200,400,700);
|
||||
/*!
|
||||
/*
|
||||
* Bootstrap v3.0.0
|
||||
*
|
||||
* Copyright 2013 Twitter, Inc
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Designed and built with all the love in the world by @mdo and @fat.
|
||||
*/
|
||||
/*! normalize.css v2.1.0 | MIT License | git.io/normalize */
|
||||
/* normalize.css v2.1.0 | MIT License | git.io/normalize */
|
||||
/* line 22, ../bower_components/sass-bootstrap/lib/_normalize.scss */
|
||||
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
|
||||
display: block; }
|
||||
@@ -5718,7 +5718,7 @@ th.visible-print, td.visible-print {
|
||||
/* line 523, ../bower_components/sass-bootstrap/lib/_mixins.scss */
|
||||
th.hidden-print, td.hidden-print {
|
||||
display: none !important; } }
|
||||
/*!
|
||||
/*
|
||||
* Font Awesome 3.2.1
|
||||
* the iconic font designed for Bootstrap
|
||||
* ------------------------------------------------------------------------------
|
||||
@@ -9132,7 +9132,7 @@ textarea {
|
||||
-webkit-box-shadow: #1ba6e5 0 0 0 inset;
|
||||
box-shadow: #1ba6e5 0 0 0 inset; } }
|
||||
|
||||
/*!
|
||||
/*
|
||||
* Ladda
|
||||
* http://lab.hakim.se/ladda
|
||||
* MIT licensed
|
||||
@@ -9979,74 +9979,83 @@ li.sortable-placeholder {
|
||||
font-family: FontAwesome;
|
||||
content: "\f0aa"; }
|
||||
|
||||
/* line 34, admin-theme/_admin-dashboard.sass */
|
||||
/* line 33, admin-theme/_admin-dashboard.sass */
|
||||
.dash_trend_right {
|
||||
color: darkblue; }
|
||||
/* line 35, admin-theme/_admin-dashboard.sass */
|
||||
.dash_trend_right:before {
|
||||
margin-right: 4px;
|
||||
font-family: FontAwesome;
|
||||
content: "\f0a9"; }
|
||||
|
||||
/* line 40, admin-theme/_admin-dashboard.sass */
|
||||
.box-stats {
|
||||
height: 70px; }
|
||||
|
||||
/* line 39, admin-theme/_admin-dashboard.sass */
|
||||
/* line 45, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard section header {
|
||||
padding: 3px 8px;
|
||||
margin: 0 0 3px 0;
|
||||
color: white;
|
||||
font-size: 1.2em;
|
||||
background-color: #1ba6e5; }
|
||||
/* line 45, admin-theme/_admin-dashboard.sass */
|
||||
/* line 51, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard section header.panel-heading, #dashboard section #header_notifs_icon_wrapper .notifs_panel header.notifs_panel_header, #header_notifs_icon_wrapper .notifs_panel #dashboard section header.notifs_panel_header {
|
||||
color: #555555; }
|
||||
/* line 48, admin-theme/_admin-dashboard.sass */
|
||||
/* line 54, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list {
|
||||
margin: 0 0 10px 0;
|
||||
padding: 0; }
|
||||
/* line 52, admin-theme/_admin-dashboard.sass */
|
||||
/* line 58, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list li {
|
||||
position: relative; }
|
||||
/* line 57, admin-theme/_admin-dashboard.sass */
|
||||
/* line 63, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list .data_value {
|
||||
line-height: 39px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 0 10px 0 0; }
|
||||
/* line 64, admin-theme/_admin-dashboard.sass */
|
||||
/* line 70, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_small {
|
||||
margin: 8px 0 10px 0;
|
||||
padding: 0 0 0 0;
|
||||
border-top: solid 1px #dddddd; }
|
||||
/* line 68, admin-theme/_admin-dashboard.sass */
|
||||
/* line 74, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_small li {
|
||||
padding: 3px 0;
|
||||
position: relative;
|
||||
border: none;
|
||||
margin: 0;
|
||||
border-bottom: dashed 1px #dddddd; }
|
||||
/* line 74, admin-theme/_admin-dashboard.sass */
|
||||
/* line 80, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_small .data_label {
|
||||
text-transform: uppercase;
|
||||
color: #bbbbbb; }
|
||||
/* line 77, admin-theme/_admin-dashboard.sass */
|
||||
/* line 83, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_small .data_value {
|
||||
line-height: 25px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 0; }
|
||||
/* line 84, admin-theme/_admin-dashboard.sass */
|
||||
/* line 90, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large {
|
||||
margin: 8px 0 10px 0;
|
||||
padding: 0; }
|
||||
/* line 88, admin-theme/_admin-dashboard.sass */
|
||||
/* line 94, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large li {
|
||||
padding: 6px 0;
|
||||
position: relative;
|
||||
border: none;
|
||||
margin: 0; }
|
||||
/* line 93, admin-theme/_admin-dashboard.sass */
|
||||
/* line 99, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large .data_label {
|
||||
line-height: 0.8em; }
|
||||
/* line 95, admin-theme/_admin-dashboard.sass */
|
||||
/* line 101, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large .data_label small {
|
||||
font-size: 0.6em; }
|
||||
/* line 97, admin-theme/_admin-dashboard.sass */
|
||||
/* line 103, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large .data_value {
|
||||
text-align: right;
|
||||
line-height: 0.6em;
|
||||
@@ -10054,10 +10063,10 @@ li.sortable-placeholder {
|
||||
top: 0;
|
||||
right: 0;
|
||||
padding: 8px 0 0 0; }
|
||||
/* line 104, admin-theme/_admin-dashboard.sass */
|
||||
/* line 110, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_large .data_value small {
|
||||
font-size: 0.5em; }
|
||||
/* line 107, admin-theme/_admin-dashboard.sass */
|
||||
/* line 113, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_vertical {
|
||||
padding: 0;
|
||||
margin: 0 0 10px 0;
|
||||
@@ -10067,30 +10076,30 @@ li.sortable-placeholder {
|
||||
-ms-border-radius: 3px;
|
||||
-o-border-radius: 3px;
|
||||
border-radius: 3px; }
|
||||
/* line 114, admin-theme/_admin-dashboard.sass */
|
||||
/* line 120, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_vertical li {
|
||||
border-left: solid 1px #dddddd;
|
||||
padding: 6px; }
|
||||
/* line 118, admin-theme/_admin-dashboard.sass */
|
||||
/* line 124, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_vertical li:first-child {
|
||||
border: none; }
|
||||
/* line 120, admin-theme/_admin-dashboard.sass */
|
||||
/* line 126, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_vertical .data_label {
|
||||
min-height: 32px;
|
||||
display: block;
|
||||
line-height: 1em;
|
||||
text-align: center; }
|
||||
/* line 125, admin-theme/_admin-dashboard.sass */
|
||||
/* line 131, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .data_list_vertical .data_value {
|
||||
display: block;
|
||||
text-align: center; }
|
||||
/* line 130, admin-theme/_admin-dashboard.sass */
|
||||
/* line 136, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends header {
|
||||
margin-bottom: 0; }
|
||||
/* line 132, admin-theme/_admin-dashboard.sass */
|
||||
/* line 138, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends #dashtrends_toolbar {
|
||||
margin: 4px -16px; }
|
||||
/* line 134, admin-theme/_admin-dashboard.sass */
|
||||
/* line 140, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends dl {
|
||||
margin: 0;
|
||||
min-height: 120px;
|
||||
@@ -10099,42 +10108,42 @@ li.sortable-placeholder {
|
||||
padding: 10px;
|
||||
border-left: 1px solid #dddddd;
|
||||
border-bottom: 1px solid #dddddd; }
|
||||
/* line 142, admin-theme/_admin-dashboard.sass */
|
||||
/* line 148, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends dl:first-child {
|
||||
border-left: none; }
|
||||
/* line 144, admin-theme/_admin-dashboard.sass */
|
||||
/* line 150, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends dl.active {
|
||||
background-color: #eeeeee; }
|
||||
/* line 146, admin-theme/_admin-dashboard.sass */
|
||||
/* line 152, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends dt {
|
||||
text-align: center;
|
||||
height: 37px;
|
||||
line-height: 1em;
|
||||
font: 300 1.1em/120% "Ubuntu", sans-serif; }
|
||||
/* line 151, admin-theme/_admin-dashboard.sass */
|
||||
/* line 157, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashtrends svg {
|
||||
height: 350px; }
|
||||
/* line 158, admin-theme/_admin-dashboard.sass */
|
||||
/* line 164, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard #dashactivity svg {
|
||||
height: 150px; }
|
||||
/* line 165, admin-theme/_admin-dashboard.sass */
|
||||
/* line 171, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .loading .data_value {
|
||||
min-width: 30px;
|
||||
text-align: center; }
|
||||
/* line 168, admin-theme/_admin-dashboard.sass */
|
||||
/* line 174, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .loading .data_value:before {
|
||||
font-size: 0.7em;
|
||||
font-family: FontAwesome;
|
||||
content: "\f021";
|
||||
color: #cccccc; }
|
||||
/* line 174, admin-theme/_admin-dashboard.sass */
|
||||
/* line 180, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .loading .data_value span, #dashboard .loading .data_value small {
|
||||
display: none; }
|
||||
/* line 176, admin-theme/_admin-dashboard.sass */
|
||||
/* line 182, admin-theme/_admin-dashboard.sass */
|
||||
#dashboard .loading .data_trend {
|
||||
display: none; }
|
||||
|
||||
/* line 201, admin-theme/_admin-dashboard.sass */
|
||||
/* line 207, admin-theme/_admin-dashboard.sass */
|
||||
.data_loading, #dashboard .data_value span, #dashboard .data_value .dash_trend {
|
||||
opacity: 1;
|
||||
-webkit-animation-name: bounceG;
|
||||
@@ -10148,7 +10157,7 @@ li.sortable-placeholder {
|
||||
transform: scale(0.7); }
|
||||
|
||||
@-webkit-keyframes bounceG {
|
||||
/* line 209, admin-theme/_admin-dashboard.sass */
|
||||
/* line 215, admin-theme/_admin-dashboard.sass */
|
||||
0% {
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
@@ -10156,7 +10165,7 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
|
||||
/* line 212, admin-theme/_admin-dashboard.sass */
|
||||
/* line 218, admin-theme/_admin-dashboard.sass */
|
||||
100% {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
@@ -10165,7 +10174,7 @@ li.sortable-placeholder {
|
||||
transform: scale(1); } }
|
||||
|
||||
@-moz-keyframes bounceG {
|
||||
/* line 209, admin-theme/_admin-dashboard.sass */
|
||||
/* line 215, admin-theme/_admin-dashboard.sass */
|
||||
0% {
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
@@ -10173,7 +10182,7 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
|
||||
/* line 212, admin-theme/_admin-dashboard.sass */
|
||||
/* line 218, admin-theme/_admin-dashboard.sass */
|
||||
100% {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
@@ -10182,7 +10191,7 @@ li.sortable-placeholder {
|
||||
transform: scale(1); } }
|
||||
|
||||
@-ms-keyframes bounceG {
|
||||
/* line 209, admin-theme/_admin-dashboard.sass */
|
||||
/* line 215, admin-theme/_admin-dashboard.sass */
|
||||
0% {
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
@@ -10190,7 +10199,7 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
|
||||
/* line 212, admin-theme/_admin-dashboard.sass */
|
||||
/* line 218, admin-theme/_admin-dashboard.sass */
|
||||
100% {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
@@ -10199,7 +10208,7 @@ li.sortable-placeholder {
|
||||
transform: scale(1); } }
|
||||
|
||||
@-o-keyframes bounceG {
|
||||
/* line 209, admin-theme/_admin-dashboard.sass */
|
||||
/* line 215, admin-theme/_admin-dashboard.sass */
|
||||
0% {
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
@@ -10207,7 +10216,7 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
|
||||
/* line 212, admin-theme/_admin-dashboard.sass */
|
||||
/* line 218, admin-theme/_admin-dashboard.sass */
|
||||
100% {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
@@ -10216,7 +10225,7 @@ li.sortable-placeholder {
|
||||
transform: scale(1); } }
|
||||
|
||||
@keyframes bounceG {
|
||||
/* line 209, admin-theme/_admin-dashboard.sass */
|
||||
/* line 215, admin-theme/_admin-dashboard.sass */
|
||||
0% {
|
||||
opacity: 0;
|
||||
filter: alpha(opacity=0);
|
||||
@@ -10224,7 +10233,7 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(0.1);
|
||||
transform: scale(0.1); }
|
||||
|
||||
/* line 212, admin-theme/_admin-dashboard.sass */
|
||||
/* line 218, admin-theme/_admin-dashboard.sass */
|
||||
100% {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
@@ -10232,11 +10241,11 @@ li.sortable-placeholder {
|
||||
-ms-transform: scale(1);
|
||||
transform: scale(1); } }
|
||||
|
||||
/* line 216, admin-theme/_admin-dashboard.sass */
|
||||
/* line 222, admin-theme/_admin-dashboard.sass */
|
||||
#dash_version {
|
||||
padding: 0 !important;
|
||||
overflow: hidden; }
|
||||
/* line 220, admin-theme/_admin-dashboard.sass */
|
||||
/* line 226, admin-theme/_admin-dashboard.sass */
|
||||
#dash_version iframe {
|
||||
height: 140px;
|
||||
width: 100%; }
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
margin-right: 4px
|
||||
font-family: FontAwesome
|
||||
content: "\f0aa"
|
||||
.dash_trend_right
|
||||
color: darkblue
|
||||
&:before
|
||||
margin-right: 4px
|
||||
font-family: FontAwesome
|
||||
content: "\f0a9"
|
||||
|
||||
.box-stats
|
||||
height: 70px
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<a class="link-social link-github" href="https://github.com/PrestaShop/PrestaShop/" target="_blank" title="Github">
|
||||
<i class="icon-github"></i>
|
||||
</a>
|
||||
<a class="link-social link-google" href="https://plus.google.com/communities/106282122101569374397" target="_blank" title="Google">
|
||||
<a class="link-social link-google" href="https://plus.google.com/+prestashop/" target="_blank" title="Google">
|
||||
<i class="icon-google-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -215,10 +215,12 @@ class AdminDashboardControllerCore extends AdminController
|
||||
if (Validate::isLoadedObject($module_obj))
|
||||
$id_module = $module_obj->id;
|
||||
}
|
||||
|
||||
|
||||
$params = array(
|
||||
'date_from' => $this->context->employee->stats_date_from,
|
||||
'date_to' => $this->context->employee->stats_date_to,
|
||||
'compare_from' => $this->context->employee->stats_compare_from,
|
||||
'compare_to' => $this->context->employee->stats_compare_to,
|
||||
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
|
||||
);
|
||||
|
||||
|
||||
@@ -124,10 +124,12 @@ function data_trends(widget_name, data)
|
||||
for (var data_id in data)
|
||||
{
|
||||
$('#'+data_id).html(data[data_id]['value']);
|
||||
if (data[data_id]['way'] == 'down')
|
||||
$('#'+data_id).parent().removeClass('dash_trend_up').addClass('dash_trend_down');
|
||||
if (data[data_id]['way'] == 'up')
|
||||
$('#'+data_id).parent().removeClass('dash_trend_down').removeClass('dash_trend_right').addClass('dash_trend_up');
|
||||
else if (data[data_id]['way'] == 'down')
|
||||
$('#'+data_id).parent().removeClass('dash_trend_up').removeClass('dash_trend_right').addClass('dash_trend_down');
|
||||
else
|
||||
$('#'+data_id).parent().removeClass('dash_trend_down').addClass('dash_trend_up');
|
||||
$('#'+data_id).parent().removeClass('dash_trend_down').removeClass('dash_trend_up').addClass('dash_trend_right');
|
||||
$('#'+data_id).closest('section').removeClass('loading');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,11 @@ if (!defined('_PS_VERSION_'))
|
||||
|
||||
class Dashtrends extends Module
|
||||
{
|
||||
protected $dashboard_data;
|
||||
protected $dashboard_data_compare;
|
||||
protected $dashboard_data_sum;
|
||||
protected $dashboard_data_sum_compare;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'dashtrends';
|
||||
@@ -57,25 +62,8 @@ class Dashtrends extends Module
|
||||
{
|
||||
return $this->display(__FILE__, 'dashboard_zone_two.tpl');
|
||||
}
|
||||
|
||||
protected $dashboard_data = array(
|
||||
'sales' => array(),
|
||||
'orders' => array(),
|
||||
'average_cart_value' => array(),
|
||||
'visits' => array(),
|
||||
'conversion_rate' => array(),
|
||||
'net_profits' => array()
|
||||
);
|
||||
protected $dashboard_data_sum = array(
|
||||
'sales' => 0,
|
||||
'orders' => 0,
|
||||
'average_cart_value' => 0,
|
||||
'visits' => 0,
|
||||
'conversion_rate' => 0,
|
||||
'net_profits' => 0
|
||||
);
|
||||
|
||||
public function hookDashboardData($params)
|
||||
|
||||
protected function getData($date_from, $date_to)
|
||||
{
|
||||
// We need the following figures to calculate our stats
|
||||
$tmp_data = array(
|
||||
@@ -93,7 +81,7 @@ class Dashtrends extends Module
|
||||
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
|
||||
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
|
||||
{
|
||||
if ($result = $gapi->requestReportData('ga:date', 'ga:visits', $params['date_from'], $params['date_to'].' 23:59:59', null, null, 1, 9999))
|
||||
if ($result = $gapi->requestReportData('ga:date', 'ga:visits', $date_from.' 00:00:00', $date_to.' 23:59:59', null, null, 1, 9999))
|
||||
foreach ($result as $row)
|
||||
$tmp_data['visits_score'][strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-$3', $row['dimensions']['date']))] = $row['metrics']['visits'];
|
||||
}
|
||||
@@ -104,7 +92,7 @@ class Dashtrends extends Module
|
||||
LEFT(`date_add`, 10) as date,
|
||||
COUNT(*) as visits_score
|
||||
FROM `'._DB_PREFIX_.'connections`
|
||||
WHERE `date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to'].' 23:59:59').'"
|
||||
WHERE `date_add` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to.' 23:59:59').'"
|
||||
'.Shop::addSqlRestriction(false).'
|
||||
GROUP BY LEFT(`date_add`, 10)');
|
||||
foreach ($result as $row)
|
||||
@@ -118,7 +106,7 @@ class Dashtrends extends Module
|
||||
SUM(`total_paid_tax_excl` / `conversion_rate`) as total_paid_tax_excl,
|
||||
SUM(`total_discounts_tax_excl` / `conversion_rate`) as total_discounts_tax_excl
|
||||
FROM `'._DB_PREFIX_.'orders`
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to'].' 23:59:59').'"
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to.' 23:59:59').'"
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER).'
|
||||
GROUP BY LEFT(`invoice_date`, 10)');
|
||||
foreach ($result as $row)
|
||||
@@ -132,7 +120,7 @@ class Dashtrends extends Module
|
||||
SUM(os.`shipping_cost_amount` / o.`conversion_rate`) as total_credit_shipping_tax_excl
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_slip` os ON o.id_order = os.id_order
|
||||
WHERE os.`date_add` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to'].' 23:59:59').'"
|
||||
WHERE os.`date_add` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to.' 23:59:59').'"
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
||||
GROUP BY LEFT(os.`date_add`, 10)');
|
||||
foreach ($result as $row)
|
||||
@@ -146,70 +134,138 @@ class Dashtrends extends Module
|
||||
SUM(od.`product_quantity` * od.`purchase_supplier_price` / `conversion_rate`) as total_purchase_price
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($params['date_from']).'" AND "'.pSQL($params['date_to'].' 23:59:59').'"
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to.' 23:59:59').'"
|
||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
||||
GROUP BY LEFT(`invoice_date`, 10)');
|
||||
foreach ($result as $row)
|
||||
foreach (array('total_product_price_tax_excl', 'total_purchase_price') as $var)
|
||||
$tmp_data[$var][strtotime($row['date'])] = $row[$var];
|
||||
|
||||
$from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), strtotime($params['date_from'].' 00:00:00'));
|
||||
$to = min(time(), strtotime($params['date_to'].' 23:59:59'));
|
||||
return $tmp_data;
|
||||
}
|
||||
|
||||
protected function refineData($date_from, $date_to, $gross_data)
|
||||
{
|
||||
$refined_data = array(
|
||||
'sales' => array(),
|
||||
'orders' => array(),
|
||||
'average_cart_value' => array(),
|
||||
'visits' => array(),
|
||||
'conversion_rate' => array(),
|
||||
'net_profits' => array()
|
||||
);
|
||||
$from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), strtotime($date_from.' 00:00:00'));
|
||||
$to = min(time(), strtotime($date_to.' 23:59:59'));
|
||||
for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date))
|
||||
{
|
||||
$this->dashboard_data['sales'][$date] = 0;
|
||||
if (isset($tmp_data['total_paid_tax_excl'][$date]))
|
||||
$this->dashboard_data['sales'][$date] += $tmp_data['total_paid_tax_excl'][$date];
|
||||
if (isset($tmp_data['total_credit_tax_excl'][$date]))
|
||||
$this->dashboard_data['sales'][$date] -= $tmp_data['total_credit_tax_excl'][$date];
|
||||
if (isset($tmp_data['total_credit_shipping_tax_excl'][$date]))
|
||||
$this->dashboard_data['sales'][$date] -= $tmp_data['total_credit_shipping_tax_excl'][$date];
|
||||
$refined_data['sales'][$date] = 0;
|
||||
if (isset($gross_data['total_paid_tax_excl'][$date]))
|
||||
$refined_data['sales'][$date] += $gross_data['total_paid_tax_excl'][$date];
|
||||
if (isset($gross_data['total_credit_tax_excl'][$date]))
|
||||
$refined_data['sales'][$date] -= $gross_data['total_credit_tax_excl'][$date];
|
||||
if (isset($gross_data['total_credit_shipping_tax_excl'][$date]))
|
||||
$refined_data['sales'][$date] -= $gross_data['total_credit_shipping_tax_excl'][$date];
|
||||
|
||||
$this->dashboard_data['orders'][$date] = isset($tmp_data['orders_score'][$date]) ? $tmp_data['orders_score'][$date] : 0;
|
||||
$refined_data['orders'][$date] = isset($gross_data['orders_score'][$date]) ? $gross_data['orders_score'][$date] : 0;
|
||||
|
||||
$this->dashboard_data['average_cart_value'][$date] = $this->dashboard_data['orders'][$date] ? $this->dashboard_data['sales'][$date] / $this->dashboard_data['orders'][$date] : 0;
|
||||
$refined_data['average_cart_value'][$date] = $refined_data['orders'][$date] ? $refined_data['sales'][$date] / $refined_data['orders'][$date] : 0;
|
||||
|
||||
$this->dashboard_data['visits'][$date] = isset($tmp_data['visits_score'][$date]) ? $tmp_data['visits_score'][$date] : 0;
|
||||
$refined_data['visits'][$date] = isset($gross_data['visits_score'][$date]) ? $gross_data['visits_score'][$date] : 0;
|
||||
|
||||
$this->dashboard_data['conversion_rate'][$date] = $this->dashboard_data['visits'][$date] ? $this->dashboard_data['orders'][$date] / $this->dashboard_data['visits'][$date] : 0;
|
||||
$refined_data['conversion_rate'][$date] = $refined_data['visits'][$date] ? $refined_data['orders'][$date] / $refined_data['visits'][$date] : 0;
|
||||
|
||||
$this->dashboard_data['net_profits'][$date] = 0;
|
||||
if (isset($tmp_data['total_product_price_tax_excl'][$date]))
|
||||
$this->dashboard_data['net_profits'][$date] += $tmp_data['total_product_price_tax_excl'][$date];
|
||||
if (isset($tmp_data['total_discounts_tax_excl'][$date]))
|
||||
$this->dashboard_data['net_profits'][$date] -= $tmp_data['total_discounts_tax_excl'][$date];
|
||||
if (isset($tmp_data['total_purchase_price'][$date]))
|
||||
$this->dashboard_data['net_profits'][$date] -= $tmp_data['total_purchase_price'][$date];
|
||||
if (isset($tmp_data['total_credit_tax_excl'][$date]))
|
||||
$this->dashboard_data['net_profits'][$date] -= $tmp_data['total_credit_tax_excl'][$date];
|
||||
$refined_data['net_profits'][$date] = 0;
|
||||
if (isset($gross_data['total_product_price_tax_excl'][$date]))
|
||||
$refined_data['net_profits'][$date] += $gross_data['total_product_price_tax_excl'][$date];
|
||||
if (isset($gross_data['total_discounts_tax_excl'][$date]))
|
||||
$refined_data['net_profits'][$date] -= $gross_data['total_discounts_tax_excl'][$date];
|
||||
if (isset($gross_data['total_purchase_price'][$date]))
|
||||
$refined_data['net_profits'][$date] -= $gross_data['total_purchase_price'][$date];
|
||||
if (isset($gross_data['total_credit_tax_excl'][$date]))
|
||||
$refined_data['net_profits'][$date] -= $gross_data['total_credit_tax_excl'][$date];
|
||||
}
|
||||
$this->dashboard_data_sum['sales'] = array_sum($this->dashboard_data['sales']);
|
||||
$this->dashboard_data_sum['orders'] = array_sum($this->dashboard_data['orders']);
|
||||
$this->dashboard_data_sum['average_cart_value'] = $this->dashboard_data_sum['sales'] ? $this->dashboard_data_sum['sales'] / $this->dashboard_data_sum['orders'] : 0;
|
||||
$this->dashboard_data_sum['visits'] = array_sum($this->dashboard_data['visits']);
|
||||
$this->dashboard_data_sum['conversion_rate'] = $this->dashboard_data_sum['visits'] ? $this->dashboard_data_sum['orders'] / $this->dashboard_data_sum['visits'] : 0;
|
||||
$this->dashboard_data_sum['net_profits'] = array_sum($this->dashboard_data['net_profits']);
|
||||
return $refined_data;
|
||||
}
|
||||
|
||||
protected function addupData($data)
|
||||
{
|
||||
$summing = array(
|
||||
'sales' => 0,
|
||||
'orders' => 0,
|
||||
'average_cart_value' => 0,
|
||||
'visits' => 0,
|
||||
'conversion_rate' => 0,
|
||||
'net_profits' => 0
|
||||
);
|
||||
|
||||
$summing['sales'] = array_sum($data['sales']);
|
||||
$summing['orders'] = array_sum($data['orders']);
|
||||
$summing['average_cart_value'] = $summing['sales'] ? $summing['sales'] / $summing['orders'] : 0;
|
||||
$summing['visits'] = array_sum($data['visits']);
|
||||
$summing['conversion_rate'] = $summing['visits'] ? $summing['orders'] / $summing['visits'] : 0;
|
||||
$summing['net_profits'] = array_sum($data['net_profits']);
|
||||
return $summing;
|
||||
}
|
||||
|
||||
protected function compareData($data1, $data2)
|
||||
{
|
||||
return array(
|
||||
'sales_score_trends' => array(
|
||||
'way' => ($data1['sales'] == $data2['sales'] ? 'right' : ($data1['sales'] > $data2['sales'] ? 'up' : 'down')),
|
||||
'value' => ($data1['sales'] > $data2['sales'] ? '+' : '').($data2['sales'] ? round(100 * $data1['sales'] / $data2['sales'] - 100, 2).'%' : '∞')
|
||||
),
|
||||
'orders_score_trends' => array(
|
||||
'way' => ($data1['orders'] == $data2['orders'] ? 'right' : ($data1['orders'] > $data2['orders'] ? 'up' : 'down')),
|
||||
'value' => ($data1['orders'] > $data2['orders'] ? '+' : '').($data2['orders'] ? round(100 * $data1['orders'] / $data2['orders'] - 100, 2).'%' : '∞')
|
||||
),
|
||||
'cart_value_score_trends' => array(
|
||||
'way' => ($data1['average_cart_value'] == $data2['average_cart_value'] ? 'right' : ($data1['average_cart_value'] > $data2['average_cart_value'] ? 'up' : 'down')),
|
||||
'value' => ($data1['average_cart_value'] > $data2['average_cart_value'] ? '+' : '').($data2['average_cart_value'] ? round(100 * $data1['average_cart_value'] / $data2['average_cart_value'] - 100, 2).'%' : '∞')
|
||||
),
|
||||
'visits_score_trends' => array(
|
||||
'way' => ($data1['visits'] == $data2['visits'] ? 'right' : ($data1['visits'] > $data2['visits'] ? 'up' : 'down')),
|
||||
'value' => ($data1['visits'] > $data2['visits'] ? '+' : '').($data2['visits'] ? round(100 * $data1['visits'] / $data2['visits'] - 100, 2).'%' : '+∞')
|
||||
),
|
||||
'conversion_rate_score_trends' => array(
|
||||
'way' => ($data1['conversion_rate'] == $data2['conversion_rate'] ? 'right' : ($data1['conversion_rate'] > $data2['conversion_rate'] ? 'up' : 'down')),
|
||||
'value' => ($data1['conversion_rate'] > $data2['conversion_rate'] ? '+' : '').($data2['conversion_rate'] ? round($data1['visits_score'] - $data2['visits_score'], 2).$this->l('pts') : '∞')
|
||||
),
|
||||
'net_profits_score_trends' => array(
|
||||
'way' => ($data1['net_profits'] == $data2['net_profits'] ? 'right' : ($data1['net_profits'] > $data2['net_profits'] ? 'up' : 'down')),
|
||||
'value' => ($data1['net_profits'] > $data2['net_profits'] ? '+' : '').($data2['net_profits'] ? round(100 * $data1['net_profits'] / $data2['net_profits'] - 100, 2).'%' : '∞')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function hookDashboardData($params)
|
||||
{
|
||||
// Artificially remove the decimals in order to get a cleaner Dashboard
|
||||
$currency = clone $this->context->currency;
|
||||
$currency->decimals = 0;
|
||||
|
||||
// Retrieve, refine and add up data for the selected period
|
||||
$tmp_data = $this->getData($params['date_from'], $params['date_to']);
|
||||
$this->dashboard_data = $this->refineData($params['date_from'], $params['date_to'], $tmp_data);
|
||||
$this->dashboard_data_sum = $this->addupData($this->dashboard_data);
|
||||
|
||||
// Retrieve, refine and add up data for the comparison period
|
||||
$tmp_data_compare = $this->getData($params['compare_from'], $params['compare_to']);
|
||||
$this->dashboard_data_compare = $this->refineData($params['compare_from'], $params['compare_to'], $tmp_data_compare);
|
||||
$this->dashboard_data_sum_compare = $this->addupData($this->dashboard_data_compare);
|
||||
|
||||
$data_trends = $this->compareData($this->dashboard_data_sum, $this->dashboard_data_sum_compare);
|
||||
|
||||
return array(
|
||||
'data_value' => array(
|
||||
'sales_score' => Tools::displayPrice(round($this->dashboard_data_sum['sales'])),
|
||||
'sales_score' => Tools::displayPrice(round($this->dashboard_data_sum['sales']), $currency),
|
||||
'orders_score' => $this->dashboard_data_sum['orders'],
|
||||
'cart_value_score' => Tools::displayPrice($this->dashboard_data_sum['average_cart_value']),
|
||||
'cart_value_score' => Tools::displayPrice($this->dashboard_data_sum['average_cart_value'], $currency),
|
||||
'visits_score' => $this->dashboard_data_sum['visits'],
|
||||
'convertion_rate_score' => round(100 * $this->dashboard_data_sum['conversion_rate'], 2),
|
||||
'net_profits_score' => Tools::displayPrice(round($this->dashboard_data_sum['net_profits'])),
|
||||
),
|
||||
'data_trends' => array(
|
||||
'sales_score_trends' => array('way' => 'up', 'value' => 0.42),
|
||||
'orders_score_trends' => array('way' => 'down', 'value' => 0.42),
|
||||
'cart_value_score_trends' => array('way' => 'up', 'value' => 0.42),
|
||||
'visits_score_trends' => array('way' => 'down', 'value' => 0.42),
|
||||
'convertion_rate_score_trends' => array('way' => 'up', 'value' => 0.42),
|
||||
'net_profits_score_trends' => array('way' => 'up', 'value' => 0.42)
|
||||
),
|
||||
'data_chart' => array(
|
||||
'dash_trends_chart1' => $this->getChartTrends(),
|
||||
'conversion_rate_score' => round(100 * $this->dashboard_data_sum['conversion_rate'], 2).'%',
|
||||
'net_profits_score' => Tools::displayPrice(round($this->dashboard_data_sum['net_profits']), $currency),
|
||||
),
|
||||
'data_trends' => $data_trends,
|
||||
'data_chart' => array('dash_trends_chart1' => $this->getChartTrends()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,32 +39,32 @@
|
||||
<dl class="col-xs-4 col-lg-2 active">
|
||||
<dt>{l s='Sales'}</dt>
|
||||
<dd class="data_value size_l"><span id="sales_score"></span></dd>
|
||||
<dd class="dash_trend dash_trend_up"><span id="sales_score_trends"></span>%</dd>
|
||||
<dd class="dash_trend"><span id="sales_score_trends"></span></dd>
|
||||
</dl>
|
||||
<dl class="col-xs-4 col-lg-2">
|
||||
<dt>{l s='Orders'}</dt>
|
||||
<dd class="data_value size_l"><span id="orders_score"></span></dd>
|
||||
<dd class="dash_trend dash_trend_down"><span id="orders_score_trends"></span>%</dd>
|
||||
<dd class="dash_trend"><span id="orders_score_trends"></span></dd>
|
||||
</dl>
|
||||
<dl class="col-xs-4 col-lg-2">
|
||||
<dt>{l s='Cart Value'}</dt>
|
||||
<dd class="data_value size_l"><span id="cart_value_score"></span></dd>
|
||||
<dd class="dash_trend dash_trend_up"><span id="cart_value_score_trends"></span>%</dd>
|
||||
<dd class="dash_trend"><span id="cart_value_score_trends"></span></dd>
|
||||
</dl>
|
||||
<dl class="col-xs-4 col-lg-2">
|
||||
<dt>{l s='Visits'}</dt>
|
||||
<dd class="data_value size_l"><span id="visits_score"></span></dd>
|
||||
<dd class="dash_trend dash_trend_down"><span id="visits_score_trends"></span>%</dd>
|
||||
<dd class="dash_trend"><span id="visits_score_trends"></span></dd>
|
||||
</dl>
|
||||
<dl class="col-xs-4 col-lg-2">
|
||||
<dt>{l s='Conversion Rate'}</dt>
|
||||
<dd class="data_value size_l"><span id="convertion_rate_score"></span>%</dd>
|
||||
<dd class="dash_trend dash_trend_up"><span id="convertion_rate_score_trends"></span>%</dd>
|
||||
<dd class="data_value size_l"><span id="conversion_rate_score"></span></dd>
|
||||
<dd class="dash_trend"><span id="conversion_rate_score_trends"></span></dd>
|
||||
</dl>
|
||||
<dl class="col-xs-4 col-lg-2">
|
||||
<dt>{l s='Net Profits'}</dt>
|
||||
<dd class="data_value size_l"><span id="net_profits_score"></span></dd>
|
||||
<dd class="dash_trend dash_trend_up"><span id="net_profits_score_trends"></span>%</dd>
|
||||
<dd class="dash_trend"><span id="net_profits_score_trends"></span></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user