* @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
*/
if (!defined('_PS_VERSION_'))
exit;
class Cheque extends PaymentModule
{
private $_html = '';
private $_postErrors = array();
public $chequeName;
public $address;
public $extra_mail_vars;
public function __construct()
{
$this->name = 'cheque';
$this->tab = 'payments_gateways';
$this->version = '2.3';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$config = Configuration::getMultiple(array('CHEQUE_NAME', 'CHEQUE_ADDRESS'));
if (isset($config['CHEQUE_NAME']))
$this->chequeName = $config['CHEQUE_NAME'];
if (isset($config['CHEQUE_ADDRESS']))
$this->address = $config['CHEQUE_ADDRESS'];
parent::__construct();
$this->displayName = $this->l('Check');
$this->description = $this->l('Module for accepting payments by check.');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
if ((!isset($this->chequeName) || !isset($this->address) || empty($this->chequeName) || empty($this->address)))
$this->warning = $this->l('\'To the order of\' and address must be configured in order to use this module correctly.');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
$this->extra_mail_vars = array(
'{cheque_name}' => Configuration::get('CHEQUE_NAME'),
'{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
'{cheque_address_html}' => str_replace("\n", '
', Configuration::get('CHEQUE_ADDRESS'))
);
}
public function install()
{
if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn'))
return false;
return true;
}
public function uninstall()
{
if (!Configuration::deleteByName('CHEQUE_NAME') || !Configuration::deleteByName('CHEQUE_ADDRESS') || !parent::uninstall())
return false;
return true;
}
private function _postValidation()
{
if (Tools::isSubmit('btnSubmit'))
{
if (!Tools::getValue('name'))
$this->_postErrors[] = $this->l('\'To the order of\' field is required.');
elseif (!Tools::getValue('address'))
$this->_postErrors[] = $this->l('Address is required.');
}
}
private function _postProcess()
{
if (Tools::isSubmit('btnSubmit'))
{
Configuration::updateValue('CHEQUE_NAME', Tools::getValue('name'));
Configuration::updateValue('CHEQUE_ADDRESS', Tools::getValue('address'));
}
$this->_html .= '
'.$this->l('This module allows you to accept payments by check.').'