From a1df97776a3cfd61b59a1ab0c9042908c4edae4c Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Thu, 24 Oct 2013 13:54:39 +0200 Subject: [PATCH] // Set default values --- classes/PaymentModule.php | 9 ++++++++ .../admin/AdminDashboardController.php | 18 +++++++-------- install-dev/data/theme.sql | 1 + modules/dashgoals/dashgoals.php | 22 ++++++++++++++++--- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 34a13c56d..219a5a8dd 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -52,6 +52,15 @@ abstract class PaymentModuleCore extends Module // Insert countries availability $return = $this->addCheckboxCountryRestrictionsForModule(); + + if (!Configuration::get('CONF_'.strtoupper($this->name).'_FIXED')) + Configuration::updateValue('CONF_'.strtoupper($this->name).'_FIXED', '0.2'); + if (!Configuration::get('CONF_'.strtoupper($this->name).'_VAR')) + Configuration::updateValue('CONF_'.strtoupper($this->name).'_VAR', '2'); + if (!Configuration::get('CONF_'.strtoupper($this->name).'_FIXED_FOREIGN')) + Configuration::updateValue('CONF_'.strtoupper($this->name).'_FIXED_FOREIGN', '0.2'); + if (!Configuration::get('CONF_'.strtoupper($this->name).'_VAR_FOREIGN')) + Configuration::updateValue('CONF_'.strtoupper($this->name).'_VAR_FOREIGN', '2'); return $return; } diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index 56f29fa3c..7b2cc5398 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -90,7 +90,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => $currency->iso_code ); $forms['payment']['fields']['CONF_'.strtoupper($module->name).'_VAR'] = array( @@ -99,7 +99,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => '%' ); @@ -111,7 +111,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => $currency->iso_code ); $forms['payment']['fields']['CONF_'.strtoupper($module->name).'_VAR_FOREIGN'] = array( @@ -120,7 +120,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => '%' ); } @@ -134,7 +134,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => '%' ); $forms['carriers']['fields']['CONF_'.strtoupper($carrier['id_reference']).'_SHIP_OVERSEAS'] = array( @@ -143,7 +143,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => '%' ); } @@ -154,7 +154,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => '%' ); @@ -163,7 +163,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => $currency->iso_code ); @@ -182,7 +182,7 @@ class AdminDashboardControllerCore extends AdminController 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', - 'default' => '0', + 'defaultValue' => '0', 'suffix' => $currency->iso_code ); diff --git a/install-dev/data/theme.sql b/install-dev/data/theme.sql index 473042a67..82e32c790 100644 --- a/install-dev/data/theme.sql +++ b/install-dev/data/theme.sql @@ -66,6 +66,7 @@ UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SUPPLIER_DISPLAY_FOR UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'BLOCK_CATEG_NBR_COLUMN_FOOTER'; UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPDB_FILENAME'; UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPFILES_FILENAME'; +UPDATE `PREFIX_configuration` SET value = '40' WHERE name = 'CONF_AVERAGE_PRODUCT_MARGIN'; /* No right column */ DELETE FROM `PREFIX_hook_module` WHERE id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayRightColumn'); diff --git a/modules/dashgoals/dashgoals.php b/modules/dashgoals/dashgoals.php index 9d6d57c9b..6c157c12b 100644 --- a/modules/dashgoals/dashgoals.php +++ b/modules/dashgoals/dashgoals.php @@ -60,6 +60,19 @@ class Dashgoals extends Module public function install() { + for ($month = '01'; $month <= 12; $month = sprintf('%02d', $month + 1)) + { + $key = strtoupper('dashgoals_traffic_'.$month.'_'.date('Y')); + if (!ConfigurationKPI::get($key)) + ConfigurationKPI::updateValue($key, 600); + $key = strtoupper('dashgoals_conversion_'.$month.'_'.date('Y')); + if (!ConfigurationKPI::get($key)) + ConfigurationKPI::updateValue($key, 2); + $key = strtoupper('dashgoals_avg_cart_value_'.$month.'_'.date('Y')); + if (!ConfigurationKPI::get($key)) + ConfigurationKPI::updateValue($key, 80); + } + return ( parent::install() && $this->registerHook('dashboardZoneTwo') @@ -118,18 +131,21 @@ class Dashgoals extends Module $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)); + $value = 0; + if ($goal && isset($visits[$timestamp])) + $value = round($visits[$timestamp] / $goal); + $stream1['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value); $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; + $value = round((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; + $value = round(($sales[$timestamp] / $orders[$timestamp]) / $goal); $stream3['values'][] = array('x' => Dashgoals::$month_labels[$i], 'y' => $value); }