From 35fc864e0bafd954c67722fbe4dfb0462e67d88c Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Wed, 27 Nov 2013 18:20:47 +0100 Subject: [PATCH 1/2] // Fixed potential warning --- controllers/admin/AdminModulesController.php | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index fe73d44b9..e1e5f4be2 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -627,23 +627,23 @@ class AdminModulesControllerCore extends AdminController { $file = $f['file']; $content = Tools::file_get_contents(_PS_ROOT_DIR_.$file); - $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA); - foreach ($xml->module as $modaddons) - if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0)) - { - $download_ok = false; - if ($f['loggedOnAddons'] == 0) - if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id))))) - $download_ok = true; - elseif ($f['loggedOnAddons'] == 1 && $this->logged_on_addons) - if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) - $download_ok = true; + if ($xml = @simplexml_load_string($content, null, LIBXML_NOCDATA)) + foreach ($xml->module as $modaddons) + if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0)) + { + $download_ok = false; + if ($f['loggedOnAddons'] == 0) + if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id))))) + $download_ok = true; + elseif ($f['loggedOnAddons'] == 1 && $this->logged_on_addons) + if (file_put_contents(_PS_MODULE_DIR_.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons)))))) + $download_ok = true; - if (!$download_ok) - $this->errors[] = $this->l('Error on downloading the lastest version'); - elseif (!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) - $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); - } + if (!$download_ok) + $this->errors[] = $this->l('Error on downloading the lastest version'); + elseif (!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) + $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); + } } } From 51bd377a675a5f6e9edae8fdc628a97584e553e1 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Thu, 28 Nov 2013 14:29:23 +0100 Subject: [PATCH 2/2] // Dashgoals improvements --- modules/dashgoals/dashgoals.php | 13 +++++++++++-- .../views/templates/hook/dashboard_zone_two.tpl | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/dashgoals/dashgoals.php b/modules/dashgoals/dashgoals.php index 98f227fb8..d3376b6f0 100644 --- a/modules/dashgoals/dashgoals.php +++ b/modules/dashgoals/dashgoals.php @@ -153,9 +153,10 @@ class Dashgoals extends Module $orders = AdminStatsController::getOrders($year.date('-01-01'), $year.date('-12-31'), 'month'); $sales = AdminStatsController::getTotalSales($year.date('-01-01'), $year.date('-12-31'), 'month'); - $stream1 = array('key' => $this->l('Traffic'), 'values' => array()); + $stream1 = array('key' => $this->l('Traffic'), 'values' => array(), 'disabled' => true); $stream2 = array('key' => $this->l('Conversion Rate'), 'values' => array()); $stream3 = array('key' => $this->l('Average Cart Value'), 'values' => array()); + $stream4 = array('key' => $this->l('Sales'), 'values' => array()); for ($i = '01'; $i <= 12; $i = sprintf('%02d', $i + 1)) { @@ -178,7 +179,15 @@ class Dashgoals extends Module if ($goal && isset($orders[$timestamp]) && $orders[$timestamp] && isset($sales[$timestamp]) && $sales[$timestamp]) $value = round(($sales[$timestamp] / $orders[$timestamp]) / $goal, 2); $stream3['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value); + + $goal = ConfigurationKPI::get(strtoupper('dashgoals_traffic_'.$i.'_'.$year)) + * ConfigurationKPI::get(strtoupper('dashgoals_conversion_'.$i.'_'.$year)) / 100 + * ConfigurationKPI::get(strtoupper('dashgoals_avg_cart_value_'.$i.'_'.$year)); + $value = 0; + if ($goal && isset($sales[$timestamp]) && $sales[$timestamp]) + $value = round($sales[$timestamp] / $goal, 2); + $stream4['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value); } - return array('chart_type' => 'bar_chart_goals', 'data' => array($stream1, $stream2, $stream3)); + return array('chart_type' => 'bar_chart_goals', 'data' => array($stream1, $stream2, $stream3, $stream4)); } } \ 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 index ae8938c2d..23aa63eba 100644 --- a/modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl +++ b/modules/dashgoals/views/templates/hook/dashboard_zone_two.tpl @@ -36,8 +36,9 @@
- {l s='Your %s Forecast' mod='dashgoals' sprintf=$goals_year} + {l s='Your forecast' mod='dashgoals'} + {$goals_year}