From 12f67a825bb2b3a7071f9051649ac67d89068fb4 Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Mon, 23 Sep 2013 10:24:26 +0200 Subject: [PATCH] //carriercompare now use bootstrap design --- modules/carriercompare/carriercompare.php | 83 +++++++++++++++++------ 1 file changed, 64 insertions(+), 19 deletions(-) diff --git a/modules/carriercompare/carriercompare.php b/modules/carriercompare/carriercompare.php index 8b82e30a6..a4a7a419a 100755 --- a/modules/carriercompare/carriercompare.php +++ b/modules/carriercompare/carriercompare.php @@ -68,27 +68,14 @@ class CarrierCompare extends Module public function getContent() { - if (!empty($_POST)) - $this->postProcess(); + $output = ''; + if (Tools::isSubmit('setGlobalConfiguration')) + if (Configuration::updateValue('SE_RERESH_METHOD', (int)Tools::getValue('SE_RERESH_METHOD'))) + $output .= $this->displayConfirmation('Configuration updated'); - $this->smarty->assign('refresh_method', Configuration::get('SE_RERESH_METHOD')); - return $this->display(__FILE__, 'template/configuration.tpl'); + return $output.$this->renderForm(); } - public function postProcess() - { - $errors = array(); - - if (Tools::isSubmit('setGlobalConfiguration')) - { - $method = (int)Tools::getValue('refresh_method'); - Configuration::updateValue('SE_RERESH_METHOD', $method); - } - - $this->smarty->assign(array( - 'display_error' => count($errors) ? $errors : false)); - } - public function hookHeader($params) { if (!$this->isModuleAvailable()) @@ -290,6 +277,64 @@ class CarrierCompare extends Module /*if (Context::getContext()->customer->id) return false;*/ return true; -} + } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Settings'), + 'icon' => 'icon-cogs' + ), + 'input' => array( + array( + 'type' => 'select', + 'label' => $this->l('Refresh carrier list method'), + 'name' => 'SE_RERESH_METHOD', + 'required' => false, + 'desc' => $this->l('How would you like to refresh information for a customer?'), + 'default_value' => (int)$this->context->country->id, + 'options' => array( + 'query' => array( + array('id' => 0, 'name' => $this->l('Anytime')), + array('id' => 1, 'name' => $this->l('The required information is set.')) + ), + 'id' => 'id', + 'name' => 'name', + ), + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + 'class' => 'btn btn-primary') + ), + ); + + $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; + $helper->identifier = $this->identifier; + $helper->submit_action = 'setGlobalConfiguration'; + $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; + $helper->token = Tools::getAdminTokenLite('AdminModules'); + $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( + 'SE_RERESH_METHOD' => Tools::getValue('SE_RERESH_METHOD', Configuration::get('SE_RERESH_METHOD')), + ); + } }