//added dashactivity config

This commit is contained in:
Vincent Augagneur
2013-09-11 12:25:07 +02:00
parent 913ee1007c
commit 937ce38a1f
2 changed files with 81 additions and 0 deletions
+70
View File
@@ -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);
@@ -36,6 +36,7 @@
</div>
<section id="dashactivity" class="dash_config hide">
<header><i class="icon-wrench"></i> {l s='Configuration'}</header>
{$dashactivity_config_form}
</section>
<section id="dash_orders" class="loading">
<ul class="data_list_large">
@@ -52,6 +53,7 @@
</li>
</ul>
</section>
{if $DASHACTIVITY_SHOW_PENDING}
<section id="dash_pending" class="loading">
<header><i class="icon-time"></i> {l s='Pending'}</header>
<ul class="data_list">
@@ -81,6 +83,8 @@
</li>
</ul>
</section>
{/if}
{if $DASHACTIVITY_SHOW_NOTIFICATION}
<section id="dash_notifications" class="loading">
<header><i class="icon-exclamation-sign"></i> {l s='Notification'}</header>
<ul class="data_list_vertical">
@@ -104,6 +108,8 @@
</li>
</ul>
</section>
{/if}
{if $DASHACTIVITY_SHOW_CUSTOMERS}
<section id="dash_customers" class="loading">
<header><i class="icon-user"></i> {l s='Customers'}</header>
<ul class="data_list">
@@ -132,6 +138,8 @@
</li>
</ul>
</section>
{/if}
{if $DASHACTIVITY_SHOW_NEWSLETTER}
<section id="dash_newsletter" class="loading">
<header><i class="icon-envelope"></i> {l s='Newsletter'}</header>
<ul class="data_list">
@@ -149,6 +157,8 @@
</li>
</ul>
</section>
{/if}
{if $DASHACTIVITY_SHOW_TRAFFIC}
<section id="dash_traffic" class="loading">
<header><i class="icon-globe"></i> {l s='Traffic'}</header>
<ul class="data_list">
@@ -174,4 +184,5 @@
</li>
</ul>
</section>
{/if}
</section>