// Code cleaning and dashgoals improvements (part 1 - not finished yet)

This commit is contained in:
Damien Metzger
2013-11-04 18:52:27 +01:00
parent 8aedd4eb04
commit 8dc29b20f0
7 changed files with 82 additions and 31 deletions
@@ -157,7 +157,7 @@ $(function() {
<tbody> <tbody>
{foreach $addons key=key item=addon} {foreach $addons key=key item=addon}
<tr> <tr>
<td><a href="{$addon.href|escape:'htmlall':'UTF-8'}" target="_blank"><strong>{$addon.title|escape:'htmlall':'UTF-8'}</strong></a></td> <td><a href="{$addon.href|escape:'htmlall':'UTF-8'}" target="_blank"><strong><i class="icon-external-link-sign"></i> {$addon.title|escape:'htmlall':'UTF-8'}</strong></a></td>
<td><a href="{$addon.href|escape:'htmlall':'UTF-8'}" target="_blank">{$addon.description|truncate:256:'...'|escape:'htmlall':'UTF-8'}</a></td> <td><a href="{$addon.href|escape:'htmlall':'UTF-8'}" target="_blank">{$addon.description|truncate:256:'...'|escape:'htmlall':'UTF-8'}</a></td>
</tr> </tr>
{/foreach} {/foreach}
@@ -303,7 +303,8 @@ class AdminDashboardControllerCore extends AdminController
'date_to' => $this->context->employee->stats_date_to, 'date_to' => $this->context->employee->stats_date_to,
'compare_from' => $this->context->employee->stats_compare_from, 'compare_from' => $this->context->employee->stats_compare_from,
'compare_to' => $this->context->employee->stats_compare_to, 'compare_to' => $this->context->employee->stats_compare_to,
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push') 'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push'),
'extra' => (int)Tools::getValue('extra')
); );
die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push')))); die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
+3 -18
View File
@@ -31,7 +31,6 @@ $(document).ready( function () {
$(".preactivationLink").click(function() { $(".preactivationLink").click(function() {
preactivationLinkClick($(this).attr("rel")); preactivationLinkClick($(this).attr("rel"));
}); });
refreshDashboard(false, false); refreshDashboard(false, false);
getBlogRss(); getBlogRss();
@@ -40,7 +39,7 @@ $(document).ready( function () {
}); });
function refreshDashboard(module_name, use_push) function refreshDashboard(module_name, use_push, extra)
{ {
module_list = new Array(); module_list = new Array();
@@ -72,7 +71,8 @@ function refreshDashboard(module_name, use_push)
ajax:true, ajax:true,
action:'refreshDashboard', action:'refreshDashboard',
module:module_list[module_id], module:module_list[module_id],
dashboard_use_push:Number(use_push) dashboard_use_push:Number(use_push),
extra:extra
}, },
dataType: 'json', dataType: 'json',
success : function(widgets){ success : function(widgets){
@@ -82,9 +82,6 @@ function refreshDashboard(module_name, use_push)
if (parseInt(dashboard_use_push) == 1) if (parseInt(dashboard_use_push) == 1)
refreshDashboard(false, true); refreshDashboard(false, true);
},
error : function(data){
//@TODO display errors
} }
}); });
} }
@@ -108,9 +105,6 @@ function setDashboardDateRange(action)
} }
else else
$('#datepickerFrom, #datepickerTo').parent('.input-group').addClass('has-error'); $('#datepickerFrom, #datepickerTo').parent('.input-group').addClass('has-error');
},
error : function(data){
//@TODO display errors
} }
}); });
} }
@@ -218,9 +212,6 @@ function getBlogRss()
else { else {
$('.dash_news').hide(); $('.dash_news').hide();
} }
},
error : function(data){
//@TODO display errors
} }
}); });
} }
@@ -280,9 +271,6 @@ function saveDashConfig(widget_name)
refreshDashboard(widget_name); refreshDashboard(widget_name);
toggleDashConfig(widget_name); toggleDashConfig(widget_name);
} }
},
error : function(data){
//@TODO display errors
} }
}); });
} }
@@ -300,9 +288,6 @@ function preactivationLinkClick(module)
type: 'POST', type: 'POST',
success : function(jsonData){ success : function(jsonData){
},
error : function(data){
//@TODO display errors
} }
}); });
} }
@@ -0,0 +1,36 @@
<?php
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @version Release: $Revision: 13573 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class DashGoalsAjaxModuleAdminController extends ModuleAdminController
{
public function initContent()
{
parent::initContent();
die ('Todo');
}
}
+6 -7
View File
@@ -111,16 +111,15 @@ class Dashgoals extends Module
public function hookDashboardData($params) public function hookDashboardData($params)
{ {
return array('data_chart' => array('dash_goals_chart1' => $this->getChartData())); $year = ((isset($params['extra']) && $params['extra'] > 1970 && $params['extra'] < 2999) ? $params['extra'] : date('Y'));
return array('data_chart' => array('dash_goals_chart1' => $this->getChartData($year)));
} }
public function getChartData() public function getChartData($year)
{ {
$year = date('Y'); $visits = AdminStatsController::getVisits(false, $year.date('-01-01'), $year.date('-12-31'), 'month');
$orders = AdminStatsController::getOrders($year.date('-01-01'), $year.date('-12-31'), 'month');
$visits = AdminStatsController::getVisits(false, date('Y-01-01'), date('Y-12-31'), 'month'); $sales = AdminStatsController::getTotalSales($year.date('-01-01'), $year.date('-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()); $stream1 = array('key' => $this->l('Traffic'), 'values' => array());
$stream2 = array('key' => $this->l('Conversion Rate'), 'values' => array()); $stream2 = array('key' => $this->l('Conversion Rate'), 'values' => array());
+22
View File
@@ -28,6 +28,28 @@ function dashgoals_calc_sales()
}); });
} }
function dashgoals_changeYear(xward)
{
var new_year = dashgoals_year;
if (xward == 'forward')
new_year = dashgoals_year + 1;
else if (xward == 'backward')
new_year = dashgoals_year - 1;
$('#dashgoals_title').text($('#dashgoals_title').text().replace(dashgoals_year, new_year));
dashgoals_year = new_year;
refreshDashboard('dashgoals', false, dashgoals_year);
}
function dashgoals_changeConfYear(xward)
{
// Todo
// getModuleLink('dashgoals', 'ajax', array('year' => $('#dashgoals_conftitle').text()), $ssl = null, $id_lang = null, $id_shop = null)
if (xward == 'forward')
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) + 1);
else if (xward == 'backward')
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) - 1);
}
$(document).ready(function() { $(document).ready(function() {
$('.dashgoals_config_input').keyup(function() { $('.dashgoals_config_input').keyup(function() {
dashgoals_calc_sales(); dashgoals_calc_sales();
@@ -28,16 +28,20 @@
var currency_sign = '{$currency->sign|addslashes}'; var currency_sign = '{$currency->sign|addslashes}';
var currency_blank = {$currency->blank|intval}; var currency_blank = {$currency->blank|intval};
var priceDisplayPrecision = 0; var priceDisplayPrecision = 0;
var dashgoals_year = {$goals_year|intval};
</script> </script>
<section id="dashgoals" class="panel widget"> <section id="dashgoals" class="panel widget">
<header class="panel-heading"> <header class="panel-heading">
<i class="icon-bar-chart"></i> {l s='Goals' mod='dashgoals'} <i class="icon-bar-chart"></i> <span id="dashgoals_title">{l s='Your %s Forecast' mod='dashgoals' sprintf=$goals_year}</span>
<a href="javascript:void(0);" onclick="dashgoals_changeYear('backward');" class="icon-backward"></a>
<a href="javascript:void(0);" onclick="dashgoals_changeYear('forward');" class="icon-forward"></a>
<span class="panel-heading-action"> <span class="panel-heading-action">
<a class="list-toolbar-btn" href="javascript:toggleDashConfig('dashgoals');" title="configure"> <a class="list-toolbar-btn" href="javascript:void(0);" onclick="toggleDashConfig('dashgoals');" title="configure">
<i class="process-icon-configure"></i> <i class="process-icon-configure"></i>
</a> </a>
<a class="list-toolbar-btn" href="#" onclick="refreshDashboard('dashgoals');" title="refresh"> <a class="list-toolbar-btn" href="javascript:void(0);" onclick="refreshDashboard('dashgoals');" title="refresh">
<i class="process-icon-refresh"></i> <i class="process-icon-refresh"></i>
</a> </a>
</span> </span>
@@ -48,7 +52,11 @@
<table class="table table-condensed table-striped table-bordered"> <table class="table table-condensed table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th>{$goals_year}</th> <th>
<a href="javascript:void(0);" onclick="dashgoals_changeConfYear('backward');" class="icon-backward"></a>
<span id="dashgoals_conftitle">{$goals_year}</span>
<a href="javascript:void(0);" onclick="dashgoals_changeConfYear('forward');" class="icon-forward"></a>
</th>
<th>{l s='Traffic' mod='dashgoals'}</th> <th>{l s='Traffic' mod='dashgoals'}</th>
<th>{l s='Conversion Rate' mod='dashgoals'}</th> <th>{l s='Conversion Rate' mod='dashgoals'}</th>
<th>{l s='Average Cart Value' mod='dashgoals'}</th> <th>{l s='Average Cart Value' mod='dashgoals'}</th>