From a2be0364da70755a0096dc3471bf8730ce7438eb Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 22 Oct 2013 19:59:04 +0200 Subject: [PATCH] // First draft goals --- js/admin_order.js | 4 +- modules/dashactivity/dashactivity.php | 2 +- modules/dashgoals/config.xml | 12 +++ modules/dashgoals/dashgoals.php | 95 +++++++++++++++++++ modules/dashgoals/index.php | 35 +++++++ modules/dashgoals/translations/index.php | 35 +++++++ modules/dashgoals/views/index.php | 35 +++++++ modules/dashgoals/views/js/dashgoals.js | 38 ++++++++ .../templates/hook/dashboard_zone_two.tpl | 68 +++++++++++++ .../dashgoals/views/templates/hook/index.php | 35 +++++++ modules/dashgoals/views/templates/index.php | 35 +++++++ 11 files changed, 390 insertions(+), 4 deletions(-) create mode 100644 modules/dashgoals/config.xml create mode 100644 modules/dashgoals/dashgoals.php create mode 100644 modules/dashgoals/index.php create mode 100644 modules/dashgoals/translations/index.php create mode 100644 modules/dashgoals/views/index.php create mode 100644 modules/dashgoals/views/js/dashgoals.js create mode 100644 modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl create mode 100644 modules/dashgoals/views/templates/hook/index.php create mode 100644 modules/dashgoals/views/templates/index.php diff --git a/js/admin_order.js b/js/admin_order.js index fec384c24..2f9ea14bf 100644 --- a/js/admin_order.js +++ b/js/admin_order.js @@ -666,9 +666,7 @@ function init() $('button.submitProductChange').unbind('click'); $('button.submitProductChange').click(function(e) { e.preventDefault(); - //console.log($(this).closest('tr.product-line-row').find('td .edit_product_quantity').val()); - //console.log($(this).closest('tr.product-line-row').find('td .edit_product_price').val()); - //return false; + if ($(this).closest('tr.product-line-row').find('td .edit_product_quantity').val() <= 0) { jAlert(txt_add_product_no_product_quantity); diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index 1f27c1207..121e5ceb0 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -78,7 +78,7 @@ class Dashactivity extends Module { $this->context->smarty->assign(array_merge(array( 'dashactivity_config_form' => $this->renderConfigForm(), - 'date_subtitle' => $this->l('From %s to %s'), + 'date_subtitle' => $this->l('from %s to %s'), 'date_format' => $this->context->language->date_format_lite ), $this->getConfigFieldsValues())); return $this->display(__FILE__, 'dashboard_zone_one.tpl'); diff --git a/modules/dashgoals/config.xml b/modules/dashgoals/config.xml new file mode 100644 index 000000000..e046a44e7 --- /dev/null +++ b/modules/dashgoals/config.xml @@ -0,0 +1,12 @@ + + + dashgoals + + + + + + 0 + 1 + + \ No newline at end of file diff --git a/modules/dashgoals/dashgoals.php b/modules/dashgoals/dashgoals.php new file mode 100644 index 000000000..1c5eb26d9 --- /dev/null +++ b/modules/dashgoals/dashgoals.php @@ -0,0 +1,95 @@ + +* @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 +*/ + +if (!defined('_PS_VERSION_')) + exit; + +class Dashgoals extends Module +{ + public function __construct() + { + $this->name = 'dashgoals'; + $this->displayName = 'Dashboard Goals'; + $this->tab = ''; + $this->version = '0.1'; + $this->author = 'PrestaShop'; + + parent::__construct(); + } + + public function install() + { + return ( + parent::install() + && $this->registerHook('dashboardZoneTwo') + && $this->registerHook('dashboardData') + && $this->registerHook('displayBackOfficeHeader') + ); + } + + public function hookDisplayBackOfficeHeader() + { + if (get_class($this->context->controller) == 'AdminDashboardController') + $this->context->controller->addJs($this->_path.'views/js/'.$this->name.'.js'); + } + + public function hookDashboardZoneTwo($params) + { + $year = date('Y'); + $this->context->smarty->assign('goals_months', array( + '01_'.$year => sprintf($this->l('January, %s'), $year), + '02_'.$year => sprintf($this->l('February, %s'), $year), + '03_'.$year => sprintf($this->l('March, %s'), $year), + '04_'.$year => sprintf($this->l('April, %s'), $year), + '05_'.$year => sprintf($this->l('May, %s'), $year), + '06_'.$year => sprintf($this->l('June, %s'), $year), + '07_'.$year => sprintf($this->l('July, %s'), $year), + '08_'.$year => sprintf($this->l('August, %s'), $year), + '09_'.$year => sprintf($this->l('September, %s'), $year), + '10_'.$year => sprintf($this->l('October, %s'), $year), + '11_'.$year => sprintf($this->l('November, %s'), $year), + '12_'.$year => sprintf($this->l('December, %s'), $year), + )); + return $this->display(__FILE__, 'dashboard_zone_two.tpl'); + } + + public function hookDashboardData($params) + { + return array(); + // 'data_chart' => array('dash_goals_chart1' => $this->getChartData()), + // ); + } + + public function getChartData() + { + return array(); + } + + public function renderConfigForm() + { + + } +} \ No newline at end of file diff --git a/modules/dashgoals/index.php b/modules/dashgoals/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/dashgoals/index.php @@ -0,0 +1,35 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/dashgoals/translations/index.php b/modules/dashgoals/translations/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/dashgoals/translations/index.php @@ -0,0 +1,35 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/dashgoals/views/index.php b/modules/dashgoals/views/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/dashgoals/views/index.php @@ -0,0 +1,35 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/dashgoals/views/js/dashgoals.js b/modules/dashgoals/views/js/dashgoals.js new file mode 100644 index 000000000..7b19c060e --- /dev/null +++ b/modules/dashgoals/views/js/dashgoals.js @@ -0,0 +1,38 @@ +function line_chart_goals(widget_name, chart_details) +{ + nv.addGraph(function() { + var chart = nv.models.lineChart() + .useInteractiveGuideline(true) + .x(function(d) { return d[0] }) + .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') + .datum(chart_details.data) + .call(chart); + nv.utils.windowResize(chart.update); + + return chart; + }); +} + +$(document).ready(function() { + $('.dashgoals_config_input').keyup(function() { + $('.dashgoals_sales').each(function() { + 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)); + }); + }); +}); \ No newline at end of file diff --git a/modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl b/modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl new file mode 100644 index 000000000..1e361cd00 --- /dev/null +++ b/modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl @@ -0,0 +1,68 @@ +{* +* 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 +* @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 +*} + +
+
+ {l s='Goals' mod='dashgoals'} + + + + + + + + +
+
+
{l s='Configuration' mod='dashgoals'}
+ + + + + + + + + + + + {foreach $goals_months as $month} + + + + + + + + {/foreach} + +
-{l s='Traffic' mod='dashgoals'}{l s='Conversion Rate' mod='dashgoals'}{l s='Average Cart Value' mod='dashgoals'}{l s='Sales' mod='dashgoals'}
{$month}0
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/modules/dashgoals/views/templates/hook/index.php b/modules/dashgoals/views/templates/hook/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/dashgoals/views/templates/hook/index.php @@ -0,0 +1,35 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/dashgoals/views/templates/index.php b/modules/dashgoals/views/templates/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/dashgoals/views/templates/index.php @@ -0,0 +1,35 @@ + +* @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 +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file