From 937ce38a1f717ab5a14732eab9f074dd9e42d83b Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 11 Sep 2013 12:25:07 +0200 Subject: [PATCH] //added dashactivity config --- modules/dashactivity/dashactivity.php | 70 +++++++++++++++++++ .../templates/hook/dashboard_zone_one.tpl | 11 +++ 2 files changed, 81 insertions(+) diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index 73c27836b..ae3f3c86a 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -45,6 +45,9 @@ class Dashactivity extends Module public function install() { + foreach ($this->getConfigFieldsValues() as $conf_name => $conf) + Configuration::updateValue($conf_name, true); + if (!parent::install() || !$this->registerHook('dashboardZoneOne') || !$this->registerHook('dashboardData') @@ -67,6 +70,7 @@ class Dashactivity extends Module public function hookDashboardZoneOne($params) { + $this->context->smarty->assign(array_merge(array('dashactivity_config_form' => $this->renderConfigForm()), $this->getConfigFieldsValues())); return $this->display(__FILE__, 'dashboard_zone_one.tpl'); } @@ -252,6 +256,72 @@ class Dashactivity extends Module return $websites; } + public function renderConfigForm() + { + $fields_form = array( + 'form' => array( + 'id_form' => 'step_carrier_general', + 'input' => array() + ), + ); + + $sub_widget = array( + array('label' => $this->l('Show Pending'), 'config_name' => 'DASHACTIVITY_SHOW_PENDING'), + array('label' => $this->l('Show Notification'), 'config_name' => 'DASHACTIVITY_SHOW_NOTIFICATION'), + array('label' => $this->l('Show Customers'), 'config_name' => 'DASHACTIVITY_SHOW_CUSTOMERS'), + array('label' => $this->l('Show Newsletter'), 'config_name' => 'DASHACTIVITY_SHOW_NEWSLETTER'), + array('label' => $this->l('Show Traffic'), 'config_name' => 'DASHACTIVITY_SHOW_TRAFFIC'), + ); + + foreach($sub_widget as $widget) + $fields_form['form']['input'][] = array( + 'type' => 'switch', + 'label' => $widget['label'], + 'name' => $widget['config_name'], + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'active_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'active_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ); + + $helper = new HelperForm(); + $helper->show_toolbar = false; + $helper->table = $this->table; + $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); + $helper->default_form_language = $lang->id; + $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; + $this->fields_form = array(); + $helper->id = (int)Tools::getValue('id_carrier'); + $helper->identifier = $this->identifier; + $helper->tpl_vars = array( + 'fields_value' => $this->getConfigFieldsValues(), + 'languages' => $this->context->controller->getLanguages(), + 'id_language' => $this->context->language->id + ); + + return $helper->generateForm(array($fields_form)); + } + + public function getConfigFieldsValues() + { + return array( + 'DASHACTIVITY_SHOW_PENDING' => Tools::getValue('DASHACTIVITY_SHOW_PENDING', Configuration::get('DASHACTIVITY_SHOW_PENDING')), + 'DASHACTIVITY_SHOW_NOTIFICATION' => Tools::getValue('DASHACTIVITY_SHOW_NOTIFICATION', Configuration::get('DASHACTIVITY_SHOW_NOTIFICATION')), + 'DASHACTIVITY_SHOW_CUSTOMERS' => Tools::getValue('DASHACTIVITY_SHOW_CUSTOMERS', Configuration::get('DASHACTIVITY_SHOW_CUSTOMERS')), + 'DASHACTIVITY_SHOW_NEWSLETTER' => Tools::getValue('DASHACTIVITY_SHOW_NEWSLETTER', Configuration::get('DASHACTIVITY_SHOW_NEWSLETTER')), + 'DASHACTIVITY_SHOW_TRAFFIC' => Tools::getValue('DASHACTIVITY_SHOW_TRAFFIC', Configuration::get('DASHACTIVITY_SHOW_TRAFFIC')), + ); + } + public function hookActionObjectCustomerMessageAddAfter($params) { return $this->hookActionObjectOrderAddAfter($params); diff --git a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl index cfdca1568..29c8edaac 100644 --- a/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl +++ b/modules/dashactivity/views/templates/hook/dashboard_zone_one.tpl @@ -36,6 +36,7 @@
{l s='Configuration'}
+ {$dashactivity_config_form}
+ {if $DASHACTIVITY_SHOW_PENDING}
{l s='Pending'}
+ {/if} + {if $DASHACTIVITY_SHOW_NOTIFICATION}
{l s='Notification'}
+ {/if} + {if $DASHACTIVITY_SHOW_CUSTOMERS}
{l s='Customers'}
+ {/if} + {if $DASHACTIVITY_SHOW_NEWSLETTER}
{l s='Newsletter'}
+ {/if} + {if $DASHACTIVITY_SHOW_TRAFFIC}
{l s='Traffic'}
+ {/if}