//bankwire module configuration is now using bootstrap design

This commit is contained in:
Vincent Augagneur
2013-09-19 16:39:22 +02:00
parent 33943ef66a
commit ef063db2f0
2 changed files with 106 additions and 44 deletions
+75 -44
View File
@@ -92,9 +92,9 @@ class BankWire extends PaymentModule
{
if (Tools::isSubmit('btnSubmit'))
{
if (!Tools::getValue('details'))
if (!Tools::getValue('BANK_WIRE_DETAILS'))
$this->_postErrors[] = $this->l('Account details are required.');
elseif (!Tools::getValue('owner'))
elseif (!Tools::getValue('BANK_WIRE_OWNER'))
$this->_postErrors[] = $this->l('Account owner is required.');
}
}
@@ -103,52 +103,20 @@ class BankWire extends PaymentModule
{
if (Tools::isSubmit('btnSubmit'))
{
Configuration::updateValue('BANK_WIRE_DETAILS', Tools::getValue('details'));
Configuration::updateValue('BANK_WIRE_OWNER', Tools::getValue('owner'));
Configuration::updateValue('BANK_WIRE_ADDRESS', Tools::getValue('address'));
Configuration::updateValue('BANK_WIRE_DETAILS', Tools::getValue('BANK_WIRE_DETAILS'));
Configuration::updateValue('BANK_WIRE_OWNER', Tools::getValue('BANK_WIRE_OWNER'));
Configuration::updateValue('BANK_WIRE_ADDRESS', Tools::getValue('BANK_WIRE_ADDRESS'));
}
$this->_html .= '<div class="conf confirm"> '.$this->l('Settings updated').'</div>';
$this->_html .= '<div class="alert alert-success"> '.$this->l('Settings updated').'</div>';
}
private function _displayBankWire()
{
$this->_html .= '<img src="../modules/bankwire/bankwire.jpg" style="float:left; margin-right:15px;" width="86" height="49"><b>'.$this->l('This module allows you to accept secure payments by bank wire.').'</b><br /><br />
'.$this->l('If the client chooses to pay by bank wire, the order\'s status will change to "Waiting for Payment."').'<br />
'.$this->l('That said, you must manually confirm the order upon receiving the bank wire. ').'<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 bank wire account details for customers.').'.<br /><br /></td></tr>
<tr><td width="130" style="height: 35px;">'.$this->l('Account owner').'</td><td><input type="text" name="owner" value="'.htmlentities(Tools::getValue('owner', $this->owner), ENT_COMPAT, 'UTF-8').'" style="width: 300px;" /></td></tr>
<tr>
<td width="130" style="vertical-align: top;">'.$this->l('Details').'</td>
<td style="padding-bottom:15px;">
<textarea name="details" rows="4" cols="53">'.htmlentities(Tools::getValue('details', $this->details), ENT_COMPAT, 'UTF-8').'</textarea>
<p>'.$this->l('Such as bank branch, IBAN number, BIC, etc...').'</p>
</td>
</tr>
<tr>
<td width="130" style="vertical-align: top;">'.$this->l('Bank address').'</td>
<td style="padding-bottom:15px;">
<textarea name="address" rows="4" cols="53">'.htmlentities(Tools::getValue('address', $this->address), ENT_COMPAT, 'UTF-8').'</textarea>
</td>
</tr>
<tr><td colspan="2" align="center"><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>';
if (Tools::isSubmit('btnSubmit'))
{
$this->_postValidation();
@@ -156,13 +124,13 @@ class BankWire extends PaymentModule
$this->_postProcess();
else
foreach ($this->_postErrors as $err)
$this->_html .= '<div class="alert error">'.$err.'</div>';
$this->_html .= '<div class="alert alert-danger">'.$err.'</div>';
}
else
$this->_html .= '<br />';
$this->_displayBankWire();
$this->_displayForm();
$this->_html .= $this->_displayBankWire();
$this->_html .= $this->renderForm();
return $this->_html;
}
@@ -218,4 +186,67 @@ class BankWire extends PaymentModule
return true;
return false;
}
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Contact details'),
'icon' => 'icon-envelope'
),
'id_form' => 'step_carrier_general',
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Account owner'),
'name' => 'BANK_WIRE_OWNER',
),
array(
'type' => 'textarea',
'label' => $this->l('Details'),
'name' => 'BANK_WIRE_DETAILS',
'desc' => $this->l('Such as bank branch, IBAN number, BIC, etc...')
),
array(
'type' => 'textarea',
'label' => $this->l('Bank address'),
'name' => 'BANK_WIRE_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(
'BANK_WIRE_DETAILS' => Tools::getValue('BANK_WIRE_DETAILS', Configuration::get('BANK_WIRE_DETAILS')),
'BANK_WIRE_OWNER' => Tools::getValue('BANK_WIRE_OWNER', Configuration::get('BANK_WIRE_OWNER')),
'BANK_WIRE_ADDRESS' => Tools::getValue('BANK_WIRE_ADDRESS', Configuration::get('BANK_WIRE_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/bankwire/bankwire.jpg" style="float:left; margin-right:15px;" width="86" height="49">
<p><strong>{l s="This module allows you to accept secure payments by bank wire."}</strong></p>
<p>{l s="If the client chooses to pay by bank wire, the order\'s status will change to 'Waiting for Payment.'"}</p>
<p>{l s="That said, you must manually confirm the order upon receiving the bank wire."}</p>
</div>