//cheque module now use boostrap design

This commit is contained in:
Vincent Augagneur
2013-09-23 15:10:46 +02:00
parent e8420f24d1
commit 642ff59bef
2 changed files with 97 additions and 33 deletions
+66 -33
View File
@@ -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 .= '<div class="conf confirm"> '.$this->l('Settings updated').'</div>';
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
}
private function _displayCheque()
{
$this->_html .= '<img src="../modules/cheque/cheque.jpg" style="float:left; margin-right:15px;"><b>'.$this->l('This module allows you to accept payments by check.').'</b><br /><br />
'.$this->l('If the client chooses this payment method, the order status will change to "Waiting for payment."').'<br />
'.$this->l('You will need to manually confirm the order as soon as you receive a check.').'<br /><br /><br />';
}
private function _displayForm()
{
$this->_html .=
'<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post">
<fieldset>
<legend><img src="../img/admin/contact.gif" />'.$this->l('Contact details').'</legend>
<table border="0" width="500" cellpadding="0" cellspacing="0" id="form">
<tr><td colspan="2">'.$this->l('Please specify the name and address required for the customer to send payment.').'.<br /><br /></td></tr>
<tr><td width="130" style="height: 35px;">'.$this->l('To the order of').'</td><td><input type="text" name="name" value="'.Tools::htmlentitiesUTF8(Tools::getValue('name', $this->chequeName)).'" style="width: 300px;" /></td></tr>
<tr>
<td width="130" style="vertical-align: top;">'.$this->l('Address').'</td>
<td><textarea name="address" rows="3" cols="53">'.Tools::htmlentitiesUTF8(Tools::getValue('address', $this->address)).'</textarea></td>
</tr>
<tr><td colspan="2" align="center"><br /><input class="button" name="btnSubmit" value="'.$this->l('Update settings').'" type="submit" /></td></tr>
</table>
</fieldset>
</form>';
return $this->display(__FILE__, 'infos.tpl');
}
public function getContent()
{
$this->_html = '<h2>'.$this->displayName.'</h2>';
$this->_html = '';
if (Tools::isSubmit('btnSubmit'))
{
@@ -142,13 +121,11 @@ class Cheque extends PaymentModule
$this->_postProcess();
else
foreach ($this->_postErrors as $err)
$this->_html .= '<div class="alert error">'.$err.'</div>';
$this->_html .= $this->displayErrors($err);
}
else
$this->_html .= '<br />';
$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')),
);
}
}
@@ -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 <contact@prestashop.com>
* @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
*}
<div class="alert alert-info">
<img src="../modules/cheque/cheque.jpg" style="float:left; margin-right:15px;" width="86" height="49">
<p><strong>{l s="This module allows you to accept payments by check."}</strong></p>
<p>{l s="If the client chooses this payment method, the order status will change to 'Waiting for payment.'"}</p>
<p>{l s="You will need to manually confirm the order as soon as you receive a check."}</p>
</div>