From 642ff59bef343e1dd32b05ed976c7df7f9b6870d Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Mon, 23 Sep 2013 15:10:46 +0200 Subject: [PATCH] //cheque module now use boostrap design --- modules/cheque/cheque.php | 99 ++++++++++++------- modules/cheque/views/templates/hook/infos.tpl | 31 ++++++ 2 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 modules/cheque/views/templates/hook/infos.tpl diff --git a/modules/cheque/cheque.php b/modules/cheque/cheque.php index c008e249d..eea1aa831 100644 --- a/modules/cheque/cheque.php +++ b/modules/cheque/cheque.php @@ -88,9 +88,9 @@ class Cheque extends PaymentModule { if (Tools::isSubmit('btnSubmit')) { - if (!Tools::getValue('name')) + if (!Tools::getValue('CHEQUE_NAME')) $this->_postErrors[] = $this->l('\'The "To the order of" field is required.'); - elseif (!Tools::getValue('address')) + elseif (!Tools::getValue('CHEQUE_ADDRESS')) $this->_postErrors[] = $this->l('Address is required.'); } } @@ -99,41 +99,20 @@ class Cheque extends PaymentModule { if (Tools::isSubmit('btnSubmit')) { - Configuration::updateValue('CHEQUE_NAME', Tools::getValue('name')); - Configuration::updateValue('CHEQUE_ADDRESS', Tools::getValue('address')); + Configuration::updateValue('CHEQUE_NAME', Tools::getValue('CHEQUE_NAME')); + Configuration::updateValue('CHEQUE_ADDRESS', Tools::getValue('CHEQUE_ADDRESS')); } - $this->_html .= '
'.$this->l('Settings updated').'
'; + $this->_html .= $this->displayConfirmation($this->l('Settings updated')); } private function _displayCheque() { - $this->_html .= ''.$this->l('This module allows you to accept payments by check.').'

- '.$this->l('If the client chooses this payment method, the order status will change to "Waiting for payment."').'
- '.$this->l('You will need to manually confirm the order as soon as you receive a check.').'


'; - } - - private function _displayForm() - { - $this->_html .= - '
-
- '.$this->l('Contact details').' - - - - - - - - -
'.$this->l('Please specify the name and address required for the customer to send payment.').'.

'.$this->l('To the order of').'
'.$this->l('Address').'

-
-
'; + return $this->display(__FILE__, 'infos.tpl'); } public function getContent() { - $this->_html = '

'.$this->displayName.'

'; + $this->_html = ''; if (Tools::isSubmit('btnSubmit')) { @@ -142,13 +121,11 @@ class Cheque extends PaymentModule $this->_postProcess(); else foreach ($this->_postErrors as $err) - $this->_html .= '
'.$err.'
'; + $this->_html .= $this->displayErrors($err); } - else - $this->_html .= '
'; - $this->_displayCheque(); - $this->_displayForm(); + $this->_html .= $this->_displayCheque(); + $this->_html .= $this->renderForm(); return $this->_html; } @@ -202,4 +179,60 @@ class Cheque extends PaymentModule return true; return false; } + + public function renderForm() + { + $fields_form = array( + 'form' => array( + 'legend' => array( + 'title' => $this->l('Contact details'), + 'icon' => 'icon-envelope' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('To the order of'), + 'name' => 'CHEQUE_NAME', + ), + array( + 'type' => 'textarea', + 'label' => $this->l('Details'), + 'name' => 'CHEQUE_ADDRESS', + ), + ), + '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; + $this->fields_form = array(); + $helper->id = (int)Tools::getValue('id_carrier'); + $helper->identifier = $this->identifier; + $helper->submit_action = 'btnSubmit'; + $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( + 'CHEQUE_NAME' => Tools::getValue('CHEQUE_NAME', Configuration::get('CHEQUE_NAME')), + 'CHEQUE_ADDRESS' => Tools::getValue('CHEQUE_ADDRESS', Configuration::get('CHEQUE_ADDRESS')), + ); + } + } diff --git a/modules/cheque/views/templates/hook/infos.tpl b/modules/cheque/views/templates/hook/infos.tpl new file mode 100644 index 000000000..88d2bdb6f --- /dev/null +++ b/modules/cheque/views/templates/hook/infos.tpl @@ -0,0 +1,31 @@ +{* +* 2007-2013 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} + +
+ +

{l s="This module allows you to accept payments by check."}

+

{l s="If the client chooses this payment method, the order status will change to 'Waiting for payment.'"}

+

{l s="You will need to manually confirm the order as soon as you receive a check."}

+
\ No newline at end of file