// Improved dashgoals configuration (tmp)
This commit is contained in:
+12
-4
@@ -25,12 +25,20 @@
|
|||||||
* International Registered Trademark & Property of PrestaShop SA
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DashGoalsAjaxModuleAdminController extends ModuleAdminController
|
class AdminDashgoalsController extends ModuleAdminController
|
||||||
{
|
{
|
||||||
public function initContent()
|
public function ajaxProcessChangeConfYear()
|
||||||
{
|
{
|
||||||
parent::initContent();
|
$year = (int)Tools::getValue('year');
|
||||||
|
$months = $this->module->setMonths($year);
|
||||||
|
|
||||||
die ('Todo');
|
$this->context->smarty->assign(array(
|
||||||
|
'currency' => $this->context->currency,
|
||||||
|
'goals_year' => $year,
|
||||||
|
'goals_months' => $months,
|
||||||
|
'link' => $this->context->link
|
||||||
|
));
|
||||||
|
|
||||||
|
echo $this->module->display(_PS_MODULE_DIR_.$this->module->name.DIRECTORY_SEPARATOR.$this->module->name.'.php', 'config.tpl');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,23 +73,44 @@ class Dashgoals extends Module
|
|||||||
ConfigurationKPI::updateValue($key, 80);
|
ConfigurationKPI::updateValue($key, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepare tab
|
||||||
|
$tab = new Tab();
|
||||||
|
$tab->active = 1;
|
||||||
|
$tab->class_name = "AdminDashgoals";
|
||||||
|
$tab->name = array();
|
||||||
|
foreach (Language::getLanguages(true) as $lang)
|
||||||
|
$tab->name[$lang['id_lang']] = 'Dashgoals';
|
||||||
|
$tab->id_parent = -1;
|
||||||
|
$tab->module = $this->name;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
parent::install()
|
$tab->add()
|
||||||
|
&& parent::install()
|
||||||
&& $this->registerHook('dashboardZoneTwo')
|
&& $this->registerHook('dashboardZoneTwo')
|
||||||
&& $this->registerHook('dashboardData')
|
&& $this->registerHook('dashboardData')
|
||||||
&& $this->registerHook('displayBackOfficeHeader')
|
&& $this->registerHook('displayBackOfficeHeader')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uninstall()
|
||||||
|
{
|
||||||
|
$id_tab = (int)Tab::getIdFromClassName('AdminDashgoals');
|
||||||
|
if ($id_tab)
|
||||||
|
{
|
||||||
|
$tab = new Tab($id_tab);
|
||||||
|
$tab->delete();
|
||||||
|
}
|
||||||
|
return parent::uninstall();
|
||||||
|
}
|
||||||
|
|
||||||
public function hookDisplayBackOfficeHeader()
|
public function hookDisplayBackOfficeHeader()
|
||||||
{
|
{
|
||||||
if (get_class($this->context->controller) == 'AdminDashboardController')
|
if (get_class($this->context->controller) == 'AdminDashboardController')
|
||||||
$this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js');
|
$this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookDashboardZoneTwo($params)
|
public function setMonths($year)
|
||||||
{
|
{
|
||||||
$year = date('Y');
|
|
||||||
$months = array();
|
$months = array();
|
||||||
for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1))
|
for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1))
|
||||||
$months[$i.'_'.$year] = array('label' => Dashgoals::$month_labels[$i], 'values' => array());
|
$months[$i.'_'.$year] = array('label' => Dashgoals::$month_labels[$i], 'values' => array());
|
||||||
@@ -102,10 +123,20 @@ class Dashgoals extends Module
|
|||||||
ConfigurationKPI::updateValue(strtoupper($key), (float)Tools::getValue($key));
|
ConfigurationKPI::updateValue(strtoupper($key), (float)Tools::getValue($key));
|
||||||
$month_row['values'][$type] = ConfigurationKPI::get(strtoupper($key));
|
$month_row['values'][$type] = ConfigurationKPI::get(strtoupper($key));
|
||||||
}
|
}
|
||||||
|
return $months;
|
||||||
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign('currency', $this->context->currency);
|
public function hookDashboardZoneTwo($params)
|
||||||
$this->context->smarty->assign('goals_year', $year);
|
{
|
||||||
$this->context->smarty->assign('goals_months', $months);
|
$year = date('Y');
|
||||||
|
$months = $this->setMonths($year);
|
||||||
|
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'currency' => $this->context->currency,
|
||||||
|
'goals_year' => $year,
|
||||||
|
'goals_months' => $months,
|
||||||
|
'dashgoals_ajax_link' => $this->context->link->getAdminLink('AdminDashgoals')
|
||||||
|
));
|
||||||
return $this->display(__FILE__, 'dashboard_zone_two.tpl');
|
return $this->display(__FILE__, 'dashboard_zone_two.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,12 +42,24 @@ function dashgoals_changeYear(xward)
|
|||||||
|
|
||||||
function dashgoals_changeConfYear(xward)
|
function dashgoals_changeConfYear(xward)
|
||||||
{
|
{
|
||||||
// Todo
|
|
||||||
// getModuleLink('dashgoals', 'ajax', array('year' => $('#dashgoals_conftitle').text()), $ssl = null, $id_lang = null, $id_shop = null)
|
|
||||||
if (xward == 'forward')
|
if (xward == 'forward')
|
||||||
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) + 1);
|
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) + 1);
|
||||||
else if (xward == 'backward')
|
else if (xward == 'backward')
|
||||||
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) - 1);
|
$('#dashgoals_conftitle').text(parseInt($('#dashgoals_conftitle').text()) - 1);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: dashgoals_ajax_link,
|
||||||
|
data: {
|
||||||
|
ajax: true,
|
||||||
|
action: 'changeconfyear',
|
||||||
|
year: parseInt($('#dashgoals_conftitle').text())
|
||||||
|
},
|
||||||
|
success : function(result){
|
||||||
|
$('#dashgoals_config').fadeOut();
|
||||||
|
$('#dashgoals_config').replaceWith(result);
|
||||||
|
$('#dashgoals_config').removeClass('hide').fadeIn();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
{*
|
||||||
|
* 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
|
||||||
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*}
|
||||||
|
|
||||||
|
<section id="dashgoals_config" class="dash_config hide">
|
||||||
|
<header><i class="icon-wrench"></i> {l s='Configuration' mod='dashgoals'}</header>
|
||||||
|
<form class="defaultForm form-horizontal" method="post" action="{$link->getAdminLink('AdminDashboard')}">
|
||||||
|
<table class="table table-condensed table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<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='Conversion Rate' mod='dashgoals'}</th>
|
||||||
|
<th>{l s='Average Cart Value' mod='dashgoals'}</th>
|
||||||
|
<th>{l s='Sales' mod='dashgoals'}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach $goals_months as $month}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{$month.label}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="dashgoals_traffic_{$month@key}" name="dashgoals_traffic_{$month@key}" class="dashgoals_config_input form-control"
|
||||||
|
value="{$month.values.traffic|intval}" />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<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->iso_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>
|
||||||
@@ -30,6 +30,8 @@
|
|||||||
var priceDisplayPrecision = 0;
|
var priceDisplayPrecision = 0;
|
||||||
|
|
||||||
var dashgoals_year = {$goals_year|intval};
|
var dashgoals_year = {$goals_year|intval};
|
||||||
|
|
||||||
|
var dashgoals_ajax_link = '{$dashgoals_ajax_link|addslashes}';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section id="dashgoals" class="panel widget">
|
<section id="dashgoals" class="panel widget">
|
||||||
@@ -46,58 +48,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</header>
|
</header>
|
||||||
<section id="dashgoals_config" class="dash_config hide">
|
{include file='./config.tpl'}
|
||||||
<header><i class="icon-wrench"></i> {l s='Configuration' mod='dashgoals'}</header>
|
|
||||||
<form class="defaultForm form-horizontal" method="post" action="{$link->getAdminLink('AdminDashboard')}">
|
|
||||||
<table class="table table-condensed table-striped table-bordered">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<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='Conversion Rate' mod='dashgoals'}</th>
|
|
||||||
<th>{l s='Average Cart Value' mod='dashgoals'}</th>
|
|
||||||
<th>{l s='Sales' mod='dashgoals'}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{foreach $goals_months as $month}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{$month.label}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="input-group">
|
|
||||||
<input id="dashgoals_traffic_{$month@key}" name="dashgoals_traffic_{$month@key}" class="dashgoals_config_input form-control"
|
|
||||||
value="{$month.values.traffic|intval}" />
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<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->iso_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 class="loading">
|
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user