Merge branch 'bootstrap' of https://github.com/PrestaShop/PrestaShop into bootstrap

This commit is contained in:
Jerome Nadaud
2013-10-23 16:49:05 +02:00
9 changed files with 215 additions and 99 deletions
+24 -21
View File
@@ -10317,7 +10317,10 @@ li.sortable-placeholder {
/* line 158, admin-theme/_admin-dashboard.sass */ /* line 158, admin-theme/_admin-dashboard.sass */
#dashboard #dashtrends svg { #dashboard #dashtrends svg {
height: 350px; } height: 350px; }
/* line 163, admin-theme/_admin-dashboard.sass */ /* line 162, admin-theme/_admin-dashboard.sass */
#dashboard #dashgoals svg {
height: 250px; }
/* line 167, admin-theme/_admin-dashboard.sass */
#dashboard #dashaddons { #dashboard #dashaddons {
background-color: white; background-color: white;
border: 1px dashed #dfdfdf; border: 1px dashed #dfdfdf;
@@ -10327,33 +10330,33 @@ li.sortable-placeholder {
-o-border-radius: 3px; -o-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
padding: 10px 20px; } padding: 10px 20px; }
/* line 167, admin-theme/_admin-dashboard.sass */ /* line 171, admin-theme/_admin-dashboard.sass */
#dashboard #dashaddons a { #dashboard #dashaddons a {
display: block; } display: block; }
/* line 169, admin-theme/_admin-dashboard.sass */ /* line 173, admin-theme/_admin-dashboard.sass */
#dashboard #dashaddons a:hover { #dashboard #dashaddons a:hover {
text-decoration: none; } text-decoration: none; }
/* line 174, admin-theme/_admin-dashboard.sass */ /* line 178, admin-theme/_admin-dashboard.sass */
#dashboard #dashactivity svg { #dashboard #dashactivity svg {
height: 150px; } height: 150px; }
/* line 181, admin-theme/_admin-dashboard.sass */ /* line 185, admin-theme/_admin-dashboard.sass */
#dashboard .loading .data_value { #dashboard .loading .data_value {
min-width: 30px; min-width: 30px;
text-align: center; } text-align: center; }
/* line 184, admin-theme/_admin-dashboard.sass */ /* line 188, admin-theme/_admin-dashboard.sass */
#dashboard .loading .data_value:before { #dashboard .loading .data_value:before {
font-size: 0.7em; font-size: 0.7em;
font-family: FontAwesome; font-family: FontAwesome;
content: "\f021"; content: "\f021";
color: #cccccc; } color: #cccccc; }
/* line 190, admin-theme/_admin-dashboard.sass */ /* line 194, admin-theme/_admin-dashboard.sass */
#dashboard .loading .data_value span, #dashboard .loading .data_value small { #dashboard .loading .data_value span, #dashboard .loading .data_value small {
display: none; } display: none; }
/* line 192, admin-theme/_admin-dashboard.sass */ /* line 196, admin-theme/_admin-dashboard.sass */
#dashboard .loading .data_trend { #dashboard .loading .data_trend {
display: none; } display: none; }
/* line 217, admin-theme/_admin-dashboard.sass */ /* line 221, admin-theme/_admin-dashboard.sass */
.data_loading, #dashboard .data_value span, #dashboard .data_value .dash_trend { .data_loading, #dashboard .data_value span, #dashboard .data_value .dash_trend {
opacity: 1; opacity: 1;
-webkit-animation-name: bounceG; -webkit-animation-name: bounceG;
@@ -10367,7 +10370,7 @@ li.sortable-placeholder {
transform: scale(0.7); } transform: scale(0.7); }
@-webkit-keyframes bounceG { @-webkit-keyframes bounceG {
/* line 225, admin-theme/_admin-dashboard.sass */ /* line 229, admin-theme/_admin-dashboard.sass */
0% { 0% {
opacity: 0; opacity: 0;
filter: alpha(opacity=0); filter: alpha(opacity=0);
@@ -10375,7 +10378,7 @@ li.sortable-placeholder {
-ms-transform: scale(0.1); -ms-transform: scale(0.1);
transform: scale(0.1); } transform: scale(0.1); }
/* line 228, admin-theme/_admin-dashboard.sass */ /* line 232, admin-theme/_admin-dashboard.sass */
100% { 100% {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
@@ -10384,7 +10387,7 @@ li.sortable-placeholder {
transform: scale(1); } } transform: scale(1); } }
@-moz-keyframes bounceG { @-moz-keyframes bounceG {
/* line 225, admin-theme/_admin-dashboard.sass */ /* line 229, admin-theme/_admin-dashboard.sass */
0% { 0% {
opacity: 0; opacity: 0;
filter: alpha(opacity=0); filter: alpha(opacity=0);
@@ -10392,7 +10395,7 @@ li.sortable-placeholder {
-ms-transform: scale(0.1); -ms-transform: scale(0.1);
transform: scale(0.1); } transform: scale(0.1); }
/* line 228, admin-theme/_admin-dashboard.sass */ /* line 232, admin-theme/_admin-dashboard.sass */
100% { 100% {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
@@ -10401,7 +10404,7 @@ li.sortable-placeholder {
transform: scale(1); } } transform: scale(1); } }
@-ms-keyframes bounceG { @-ms-keyframes bounceG {
/* line 225, admin-theme/_admin-dashboard.sass */ /* line 229, admin-theme/_admin-dashboard.sass */
0% { 0% {
opacity: 0; opacity: 0;
filter: alpha(opacity=0); filter: alpha(opacity=0);
@@ -10409,7 +10412,7 @@ li.sortable-placeholder {
-ms-transform: scale(0.1); -ms-transform: scale(0.1);
transform: scale(0.1); } transform: scale(0.1); }
/* line 228, admin-theme/_admin-dashboard.sass */ /* line 232, admin-theme/_admin-dashboard.sass */
100% { 100% {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
@@ -10418,7 +10421,7 @@ li.sortable-placeholder {
transform: scale(1); } } transform: scale(1); } }
@-o-keyframes bounceG { @-o-keyframes bounceG {
/* line 225, admin-theme/_admin-dashboard.sass */ /* line 229, admin-theme/_admin-dashboard.sass */
0% { 0% {
opacity: 0; opacity: 0;
filter: alpha(opacity=0); filter: alpha(opacity=0);
@@ -10426,7 +10429,7 @@ li.sortable-placeholder {
-ms-transform: scale(0.1); -ms-transform: scale(0.1);
transform: scale(0.1); } transform: scale(0.1); }
/* line 228, admin-theme/_admin-dashboard.sass */ /* line 232, admin-theme/_admin-dashboard.sass */
100% { 100% {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
@@ -10435,7 +10438,7 @@ li.sortable-placeholder {
transform: scale(1); } } transform: scale(1); } }
@keyframes bounceG { @keyframes bounceG {
/* line 225, admin-theme/_admin-dashboard.sass */ /* line 229, admin-theme/_admin-dashboard.sass */
0% { 0% {
opacity: 0; opacity: 0;
filter: alpha(opacity=0); filter: alpha(opacity=0);
@@ -10443,7 +10446,7 @@ li.sortable-placeholder {
-ms-transform: scale(0.1); -ms-transform: scale(0.1);
transform: scale(0.1); } transform: scale(0.1); }
/* line 228, admin-theme/_admin-dashboard.sass */ /* line 232, admin-theme/_admin-dashboard.sass */
100% { 100% {
opacity: 1; opacity: 1;
filter: alpha(opacity=100); filter: alpha(opacity=100);
@@ -10451,11 +10454,11 @@ li.sortable-placeholder {
-ms-transform: scale(1); -ms-transform: scale(1);
transform: scale(1); } } transform: scale(1); } }
/* line 232, admin-theme/_admin-dashboard.sass */ /* line 236, admin-theme/_admin-dashboard.sass */
#dash_version { #dash_version {
padding: 0 !important; padding: 0 !important;
overflow: hidden; } overflow: hidden; }
/* line 236, admin-theme/_admin-dashboard.sass */ /* line 240, admin-theme/_admin-dashboard.sass */
#dash_version iframe { #dash_version iframe {
height: 80px; height: 80px;
width: 100%; } width: 100%; }
@@ -157,6 +157,10 @@
font: 300 1.1em/120% $headings-font-family font: 300 1.1em/120% $headings-font-family
svg svg
height: 350px height: 350px
#dashgoals
svg
height: 250px
#dashproducts #dashproducts
@@ -86,7 +86,7 @@
</div> </div>
<div class="col-lg-7" id="hookDashboardZoneTwo"> <div class="col-lg-7" id="hookDashboardZoneTwo">
{$hookDashboardZoneTwo} {$hookDashboardZoneTwo}
<div id="dashaddons" class="widget"> <div id="dashaddons">
<a href="http://addons.prestashop.com/208-dashboards?utm_source=backoffice_dashboard" target="_blank"> <a href="http://addons.prestashop.com/208-dashboards?utm_source=backoffice_dashboard" target="_blank">
<i class="icon-plus"></i> {l s='Add more graph and data'} <i class="icon-plus"></i> {l s='Add more graph and data'}
</a> </a>
@@ -139,4 +139,4 @@
$('#date-end').focus(); $('#date-end').focus();
}); });
}); });
</script> </script>
+46 -3
View File
@@ -28,16 +28,22 @@ class AdminStatsControllerCore extends AdminStatsTabController
{ {
public static function getVisits($unique = false, $date_from, $date_to, $granularity = false) public static function getVisits($unique = false, $date_from, $date_to, $granularity = false)
{ {
$visits = array(); $visits = ($granularity == false) ? 0 : array();
$gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false; $gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false;
if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) if (Validate::isLoadedObject($gapi) && $gapi->isConfigured())
{ {
$metric = $unique ? 'visitors' : 'visits'; $metric = $unique ? 'visitors' : 'visits';
if ($result = $gapi->requestReportData($granularity ? 'ga:date' : '', 'ga:'.$metric, $date_from, $date_to, null, null, 1, 30)) if ($result = $gapi->requestReportData($granularity ? 'ga:date' : '', 'ga:'.$metric, $date_from, $date_to, null, null, 1, 5000))
foreach ($result as $row) foreach ($result as $row)
if ($granularity == 'day') if ($granularity == 'day')
$visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-$3', $row['dimensions']['date']))] = $row['metrics'][$metric]; $visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-$3', $row['dimensions']['date']))] = $row['metrics'][$metric];
elseif ($granularity == false) elseif ($granularity == 'month')
{
if (!isset($visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))]))
$visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))] = 0;
$visits[strtotime(preg_replace('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', '$1-$2-01', $row['dimensions']['date']))] += $row['metrics'][$metric];
}
else
$visits = $row['metrics'][$metric]; $visits = $row['metrics'][$metric];
} }
else else
@@ -53,6 +59,17 @@ class AdminStatsControllerCore extends AdminStatsTabController
foreach ($result as $row) foreach ($result as $row)
$visits[strtotime($row['date'])] = $row['visits']; $visits[strtotime($row['date'])] = $row['visits'];
} }
elseif ($granularity == 'month')
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT LEFT(`date_add`, 7) as date, COUNT('.($unique ? 'DISTINCT id_guest' : '*').') as visits
FROM `'._DB_PREFIX_.'connections`
WHERE `date_add` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
'.Shop::addSqlRestriction().'
GROUP BY LEFT(`date_add`, 7)');
foreach ($result as $row)
$visits[strtotime($row['date'].'-01')] = $row['visits'];
}
else else
$visits = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' $visits = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT('.($unique ? 'DISTINCT id_guest' : '*').') as visits SELECT COUNT('.($unique ? 'DISTINCT id_guest' : '*').') as visits
@@ -160,6 +177,19 @@ class AdminStatsControllerCore extends AdminStatsTabController
$sales[strtotime($row['date'])] = $row['sales']; $sales[strtotime($row['date'])] = $row['sales'];
return $sales; return $sales;
} }
elseif ($granularity == 'month')
{
$sales = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT LEFT(`invoice_date`, 7) as date, SUM(total_paid_tax_excl / o.conversion_rate) as sales
FROM `'._DB_PREFIX_.'orders` o
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
'.Shop::addSqlRestriction(false, 'o').'
GROUP BY LEFT(`invoice_date`, 7)');
foreach ($result as $row)
$sales[strtotime($row['date'].'-01')] = $row['sales'];
return $sales;
}
else else
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(total_paid_tax_excl / o.conversion_rate) SELECT SUM(total_paid_tax_excl / o.conversion_rate)
@@ -220,6 +250,19 @@ class AdminStatsControllerCore extends AdminStatsTabController
$orders[strtotime($row['date'])] = $row['orders']; $orders[strtotime($row['date'])] = $row['orders'];
return $orders; return $orders;
} }
elseif ($granularity == 'month')
{
$orders = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT LEFT(`invoice_date`, 7) as date, COUNT(*) as orders
FROM `'._DB_PREFIX_.'orders`
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
'.Shop::addSqlRestriction(false).'
GROUP BY LEFT(`invoice_date`, 7)');
foreach ($result as $row)
$orders[strtotime($row['date'].'-01')] = $row['orders'];
return $orders;
}
else else
$orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' $orders = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*) as orders SELECT COUNT(*) as orders
+1
View File
@@ -540,6 +540,7 @@ class InstallModelInstall extends InstallAbstractModel
'cheque', 'cheque',
'dashactivity', 'dashactivity',
'dashtrends', 'dashtrends',
'dashgoals',
'dashproducts', 'dashproducts',
'favoriteproducts', 'favoriteproducts',
'graphartichow', 'graphartichow',
+7 -4
View File
@@ -35,14 +35,14 @@ UPDATE `PREFIX_configuration` SET `value`='-' WHERE `name` = 'PS_ATTRIBUTE_ANCHO
UPDATE `PREFIX_tab` SET class_name = 'AdminDashboard', id_parent = 0, active = 1, module = "" WHERE class_name = 'AdminHome'; UPDATE `PREFIX_tab` SET class_name = 'AdminDashboard', id_parent = 0, active = 1, module = "" WHERE class_name = 'AdminHome';
INSERT INTO `PREFIX_module` (`name`, `active`, `version`) INSERT INTO `PREFIX_module` (`name`, `active`, `version`)
VALUES ('dashactivity', '1', '0.1'), ('dashtrends', '1', '0.1'), ('dashproducts', '1', '0.1'); VALUES ('dashactivity', '1', '0.1'),('dashtrends', '1', '0.1'),('dashgoals', '1', '0.1'),('dashproducts', '1', '0.1');
INSERT INTO `PREFIX_module_access` (`id_profile`, `id_module`, `view`, `configure`) ( INSERT INTO `PREFIX_module_access` (`id_profile`, `id_module`, `view`, `configure`) (
SELECT p.id_profile, m.id_module, 1, 1 FROM `PREFIX_module` m, `PREFIX_profile` p WHERE m.name IN ('dashactivity', 'dashtrends', 'dashproducts') SELECT p.id_profile, m.id_module, 1, 1 FROM `PREFIX_module` m, `PREFIX_profile` p WHERE m.name IN ('dashactivity', 'dashtrends', 'dashgoals', 'dashproducts')
); );
INSERT INTO `PREFIX_module_shop` (`id_module`, `id_shop`) ( INSERT INTO `PREFIX_module_shop` (`id_module`, `id_shop`) (
SELECT m.id_module, s.id_shop FROM `PREFIX_module` m, `PREFIX_shop` s WHERE m.name IN ('dashactivity', 'dashtrends', 'dashproducts') SELECT m.id_module, s.id_shop FROM `PREFIX_module` m, `PREFIX_shop` s WHERE m.name IN ('dashactivity', 'dashtrends', 'dashgoals', 'dashproducts')
); );
INSERT INTO `PREFIX_hook` (`name`, `title`, `position`, `live_edit`) VALUES INSERT INTO `PREFIX_hook` (`name`, `title`, `position`, `live_edit`) VALUES
@@ -60,7 +60,10 @@ INSERT INTO `PREFIX_hook_module` (`id_module`, `id_shop`, `id_hook`, `position`)
SELECT m.id_module, s.id_shop, h.id_hook, 1 FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h WHERE m.name IN ('dashtrends') AND h.name IN ('dashboardZoneTwo') SELECT m.id_module, s.id_shop, h.id_hook, 1 FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h WHERE m.name IN ('dashtrends') AND h.name IN ('dashboardZoneTwo')
); );
INSERT INTO `PREFIX_hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) ( INSERT INTO `PREFIX_hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) (
SELECT m.id_module, s.id_shop, h.id_hook, 2 FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h WHERE m.name IN ('dashproducts') AND h.name IN ('dashboardZoneTwo') SELECT m.id_module, s.id_shop, h.id_hook, 2 FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h WHERE m.name IN ('dashgoals') AND h.name IN ('dashboardZoneTwo')
);
INSERT INTO `PREFIX_hook_module` (`id_module`, `id_shop`, `id_hook`, `position`) (
SELECT m.id_module, s.id_shop, h.id_hook, 3 FROM `PREFIX_module` m, `PREFIX_shop` s, `PREFIX_hook` h WHERE m.name IN ('dashproducts') AND h.name IN ('dashboardZoneTwo')
); );
/* PHP:update_order_messages(); */; /* PHP:update_order_messages(); */;
+64 -21
View File
@@ -29,6 +29,9 @@ if (!defined('_PS_VERSION_'))
class Dashgoals extends Module class Dashgoals extends Module
{ {
protected static $month_labels = array();
protected static $types = array('traffic', 'conversion', 'avg_cart_value');
public function __construct() public function __construct()
{ {
$this->name = 'dashgoals'; $this->name = 'dashgoals';
@@ -38,6 +41,21 @@ class Dashgoals extends Module
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
parent::__construct(); parent::__construct();
Dashgoals::$month_labels = array(
'01' => $this->l('January'),
'02' => $this->l('February'),
'03' => $this->l('March'),
'04' => $this->l('April'),
'05' => $this->l('May'),
'06' => $this->l('June'),
'07' => $this->l('July'),
'08' => $this->l('August'),
'09' => $this->l('September'),
'10' => $this->l('October'),
'11' => $this->l('November'),
'12' => $this->l('December')
);
} }
public function install() public function install()
@@ -59,37 +77,62 @@ class Dashgoals extends Module
public function hookDashboardZoneTwo($params) public function hookDashboardZoneTwo($params)
{ {
$year = date('Y'); $year = date('Y');
$this->context->smarty->assign('goals_months', array( $months = array();
'01_'.$year => sprintf($this->l('January, %s'), $year), for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1))
'02_'.$year => sprintf($this->l('February, %s'), $year), $months[$i.'_'.$year] = array('label' => Dashgoals::$month_labels[$i], 'values' => array());
'03_'.$year => sprintf($this->l('March, %s'), $year),
'04_'.$year => sprintf($this->l('April, %s'), $year), foreach (Dashgoals::$types as $type)
'05_'.$year => sprintf($this->l('May, %s'), $year), foreach ($months as $month => &$month_row)
'06_'.$year => sprintf($this->l('June, %s'), $year), {
'07_'.$year => sprintf($this->l('July, %s'), $year), $key = 'dashgoals_'.$type.'_'.$month;
'08_'.$year => sprintf($this->l('August, %s'), $year), if (Tools::isSubmit('submitDashGoals'))
'09_'.$year => sprintf($this->l('September, %s'), $year), ConfigurationKPI::updateValue(strtoupper($key), (float)Tools::getValue($key));
'10_'.$year => sprintf($this->l('October, %s'), $year), $month_row['values'][$type] = ConfigurationKPI::get(strtoupper($key));
'11_'.$year => sprintf($this->l('November, %s'), $year), }
'12_'.$year => sprintf($this->l('December, %s'), $year),
)); $this->context->smarty->assign('currency_code', $this->context->currency->iso_code);
$this->context->smarty->assign('goals_year', $year);
$this->context->smarty->assign('goals_months', $months);
return $this->display(__FILE__, 'dashboard_zone_two.tpl'); return $this->display(__FILE__, 'dashboard_zone_two.tpl');
} }
public function hookDashboardData($params) public function hookDashboardData($params)
{ {
return array(); return array('data_chart' => array('dash_goals_chart1' => $this->getChartData()));
// 'data_chart' => array('dash_goals_chart1' => $this->getChartData()),
// );
} }
public function getChartData() public function getChartData()
{ {
return array(); $year = date('Y');
}
public function renderConfigForm() $visits = AdminStatsController::getVisits(false, date('Y-01-01'), date('Y-12-31'), 'month');
{ $orders = AdminStatsController::getOrders(date('Y-01-01'), date('Y-12-31'), 'month');
$sales = AdminStatsController::getTotalSales(date('Y-01-01'), date('Y-12-31'), 'month');
$stream1 = array('key' => $this->l('Traffic'), 'values' => array());
$stream2 = array('key' => $this->l('Conversion Rate'), 'values' => array());
$stream3 = array('key' => $this->l('Average Cart Value'), 'values' => array());
for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1))
{
$timestamp = strtotime($year.'-'.$i.'-01');
$goal = ConfigurationKPI::get(strtoupper('dashgoals_traffic_'.$i.'_'.$year));
$stream1['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => ($goal ? $visits[$timestamp] / $goal : 0));
$goal = ConfigurationKPI::get(strtoupper('dashgoals_conversion_'.$i.'_'.$year));
$value = 0;
if ($goal && isset($visits[$timestamp]) && $visits[$timestamp] && isset($orders[$timestamp]) && $orders[$timestamp])
$value = (100 * $orders[$timestamp] / $visits[$timestamp]) / $goal;
$stream2['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value);
$goal = ConfigurationKPI::get(strtoupper('dashgoals_avg_cart_value_'.$i.'_'.$year));
$value = 0;
if ($goal && isset($orders[$timestamp]) && $orders[$timestamp] && isset($sales[$timestamp]) && $sales[$timestamp])
$value = ($sales[$timestamp] / $orders[$timestamp]) / $goal;
$stream3['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value);
}
return array('chart_type' => 'bar_chart_goals', 'data' => array($stream1, $stream2, $stream3));
} }
} }
+22 -24
View File
@@ -1,38 +1,36 @@
function line_chart_goals(widget_name, chart_details) function bar_chart_goals(widget_name, chart_details)
{ {
nv.addGraph(function() { nv.addGraph(function() {
var chart = nv.models.lineChart() var chart = nv.models.multiBarChart();
.useInteractiveGuideline(true)
.x(function(d) { return d[0] }) chart.yAxis.tickFormat(d3.format('%'));
.y(function(d) { return d[1]/100 })
.color(d3.scale.category10().range());
chart.xAxis
.tickFormat(function(d) {
return d3.time.format('%m/%d/%y')(new Date(d))
});
chart.yAxis
.tickFormat(d3.format(',.1%'));
d3.select('#dash_goals_chart1 svg') d3.select('#dash_goals_chart1 svg')
.datum(chart_details.data) .datum(chart_details.data)
.transition()
.call(chart); .call(chart);
nv.utils.windowResize(chart.update); nv.utils.windowResize(chart.update);
return chart; return chart;
}); });
} }
function dashgoals_calc_sales()
{
$('.dashgoals_sales').each(function() {
var key = $(this).attr('id').substr(16);
var sales = parseFloat($('#dashgoals_traffic_' + key).val()) * parseFloat($('#dashgoals_avg_cart_value_' + key).val()) * parseFloat($('#dashgoals_conversion_' + key).val()) / 100;
if (isNaN(sales))
$(this).text('0');
else
$(this).text(parseInt(sales));
});
}
$(document).ready(function() { $(document).ready(function() {
$('.dashgoals_config_input').keyup(function() { $('.dashgoals_config_input').keyup(function() {
$('.dashgoals_sales').each(function() { dashgoals_calc_sales();
var key = $(this).attr('id').substr(16);
var sales = parseFloat($('#dashgoals_traffic_' + key).val()) * parseFloat($('#dashgoals_average_cart_value_' + key).val()) * parseFloat($('#dashgoals_conversion_rate_' + key).val()) / 100;
if (isNaN(sales))
$(this).text('0');
else
$(this).text(parseInt(sales));
});
}); });
}); dashgoals_calc_sales();
});
@@ -35,32 +35,53 @@
</a> </a>
</span> </span>
</header> </header>
<section id="dashgoals_config" class="dash_config"> <section id="dashgoals_config" class="dash_config hide">
<header><i class="icon-wrench"></i> {l s='Configuration' mod='dashgoals'}</header> <header><i class="icon-wrench"></i> {l s='Configuration' mod='dashgoals'}</header>
<table class="table table-condensed table-striped table-bordered"> <form class="defaultForm form-horizontal" method="post" action="{$link->getAdminLink('AdminDashboard')}">
<thead> <table class="table table-condensed table-striped table-bordered">
<tr> <thead>
<th>-</th> <tr>
<th>{l s='Traffic' mod='dashgoals'}</th> <th>{$goals_year}</th>
<th>{l s='Conversion Rate' mod='dashgoals'}</th> <th>{l s='Traffic' mod='dashgoals'}</th>
<th>{l s='Average Cart Value' mod='dashgoals'}</th> <th>{l s='Conversion Rate' mod='dashgoals'}</th>
<th>{l s='Sales' mod='dashgoals'}</th> <th>{l s='Average Cart Value' mod='dashgoals'}</th>
</tr> <th>{l s='Sales' mod='dashgoals'}</th>
</thead> </tr>
<tbody> </thead>
{foreach $goals_months as $month} <tbody>
<tr> {foreach $goals_months as $month}
<td>{$month}</td> <tr>
<td><input id="dashgoals_traffic_{$month@key}" name="dashgoals_traffic_{$month@key}" class="dashgoals_config_input form-control" value="" /></td> <td>
<td><input id="dashgoals_conversion_rate_{$month@key}" name="dashgoals_conversion_rate_{$month@key}" class="dashgoals_config_input form-control" value="" /></td> {$month.label}
<td><input id="dashgoals_average_cart_value_{$month@key}" name="dashgoals_average_cart_value_{$month@key}" class="dashgoals_config_input form-control" value="" /></td> </td>
<td id="dashgoals_sales_{$month@key}" class="dashgoals_sales">0</td> <td>
</tr> <input id="dashgoals_traffic_{$month@key}" name="dashgoals_traffic_{$month@key}" class="dashgoals_config_input form-control"
{/foreach} value="{$month.values.traffic|intval}" />
</tbody> </td>
</table> <td>
<div class="input-group">
<input id="dashgoals_conversion_{$month@key}" name="dashgoals_conversion_{$month@key}" class="dashgoals_config_input form-control"
value="{$month.values.conversion|floatval}" />
<span class="input-group-addon">%</span>
</div>
</td>
<td>
<div class="input-group">
<span class="input-group-addon">{$currency_code|escape}</span>
<input id="dashgoals_avg_cart_value_{$month@key}" name="dashgoals_avg_cart_value_{$month@key}" class="dashgoals_config_input form-control"
value="{$month.values.avg_cart_value|intval}" />
</div>
</td>
<td id="dashgoals_sales_{$month@key}" class="dashgoals_sales">
</td>
</tr>
{/foreach}
</tbody>
</table>
<input class="btn btn-default" name="submitDashGoals" type="submit" value="{l s='Save' mod='dashgoals'}" />
</form>
</section> </section>
<section class="loading hide"> <section class="loading">
<div id="dash_goals_chart1" class="chart with-transitions"> <div id="dash_goals_chart1" class="chart with-transitions">
<svg></svg> <svg></svg>
</div> </div>