Related
I have problem with prestashop and form helper. I have form with two input text, i could add default value with fields_value. Unfortunately it doesn't work. My form:
public function displayForm()
{
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$fields_form = array();
$fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->l('My module settings')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Box Description: '),
'name' => 'description',
'lang' => true,
),
array(
'type' => 'text',
'label' => $this->l('Box Description: '),
'name' => 'test_name',
'lang' => true,
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
)
);
$languages = Language::getLanguages();
$helper = new HelperForm();
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
$helper->languages = $this->context->controller->getLanguages();
$helper->title = $this->l('tester2');
$helper->show_toolbar = true; // false -> remove toolbar
$helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen.
$helper->submit_action = 'homepage_settings';
$helper->tpl_vars = array(
'fields_value' => array('description' => $this->l('hello'), 'test_name' => 'tester2'),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
return $helper->generateForm($fields_form);
}
When i install module, and go to module configuration then i see 2 form input text with single char instead my text
What am I doing wrong? Next question is what i can do, to my module to make my module work in multi store mode? In the final version, the data in the form will be supplemented from the database, but I want to find out why it does not complete the fields with the whole text.
Your fields are multi languages.
try this:
'fields_value' => array(
'description' => array(1 => $this->l('hello')), 'test_name' => array(1 => 'tester2')),
I have an admin controller which displays the list of data on clicking edit on an entry or adding a new entry I am showing renderForm() but after saving the data (either by edit or add) I want to redirect the user to another controller in place of showing the same controller list.
Bellow is the code which I am currently using for example of my requirements I trying to do something which I have done below in initcontent() but that is not working so I want to know where should I call this in place of initcontent()
<?php
/**
* The file is controller. Do not modify the file if you want to upgrade the module in future
*
* #author Globo Jsc <contact#globosoftware.net>
* #copyright 2016 Globo., Jsc
* #link http://www.globosoftware.net
* #license please read license in file license.txt
*/
include_once(_PS_MODULE_DIR_ . 'cardelivery/classes/AdditionalServicesModel.php');
class AdminAdditionalServiceController extends ModuleAdminControllerCore {
public $name;
public function __construct() {
$this->name = 'AdminAdditionalService';
$this->className = 'AdditionalServicesModel';
$this->table = 'additional_service';
$this->meta_title = $this->l('Additional Services');
$this->deleted = false;
$this->explicitSelect = true;
$this->context = Context::getContext();
$this->bootstrap = true;
$this->_defaultOrderBy = 'id_additional_service';
$this->filter = true;
if (Shop::isFeatureActive()) {
Shop::addTableAssociation($this->table, array('type' => 'shop'));
}
$this->position_identifier = 'id_additional_service';
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->fields_list = array(
'id_additional_service' => array(
'title' => $this->l('ID'),
'type' => 'int',
'width' => 'auto',
'orderby' => false),
'service_name' => array(
'title' => $this->l('Icon'),
'width' => 'auto',
'orderby' => false,
),
'service_desc' => array(
'title' => $this->l('service_desc'),
'type' => 'text'
),
'active' => array(
'title' => $this->l('Status'),
'width' => 'auto',
'active' => 'status',
'type' => 'bool',
'orderby' => false),
);
parent::__construct();
}
function initContent() {
parent::initContent();
if (Tools::isSubmit('submit')) {
Tools::redirectAdmin(self::$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminCategories') . '&conf=7');
}
}
public function initPageHeaderToolbar() {
$this->page_header_toolbar_btn['back_to_list'] = array(
'href' => Context::getContext()->link->getAdminLink('AdminGCardeliverycity', true),
'desc' => $this->l('Back to list', null, null, false),
'icon' => 'process-icon-back'
);
parent::initPageHeaderToolbar();
}
public function renderForm() {
$id_citydelivery = (int) Tools::getValue('id_citydelivery');
if ($id_citydelivery == 0) {
$addSerModObj = new AdditionalServicesModel((int) Tools::getValue('id_additional_service'));
$id_citydelivery = $addSerModObj->id_citydelivery;
}
$fields_form_1 = array(
'form' => array(
'legend' => array('title' => $this->l('Additional Service'), 'icon' => 'icon-cogs'),
'input' => array(
array(
'type' => 'hidden',
'name' => 'id_citydelivery'
),
array(
'type' => 'text',
'label' => $this->l('Service_name'),
'name' => 'service_name',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'text',
'label' => $this->l('service_desc'),
'name' => 'service_desc',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'text',
'label' => $this->l('charge'),
'name' => 'charge',
'size' => 255,
'required' => true,
'desc' => $this->l('Enter name of Arrival port')
),
array(
'type' => 'switch',
'label' => $this->l('Active'),
'name' => 'active',
'required' => false,
'is_bool' => true,
'values' => array(array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Active')), array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Inactive')))),
),
'submit' => array('title' => $this->l('Save')),
'buttons' => array(
array(
'href' => Context::getContext()->link->getAdminLink('AdminGCardeliverycity', true) . '&updatecitydelivery&id_citydelivery=' . $id_citydelivery,
'title' => $this->l('Cancle'),
'icon' => 'process-icon-cancel'
)
)
)
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->toolbar_scroll = true;
$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->identifier = $this->identifier;
$helper->submit_action = 'submit';
$helper->currentIndex = AdminController::$currentIndex;
$helper->token = Tools::getAdminTokenLite($this->name);
$id_additional_service = (int) Tools::getValue('id_additional_service');
$additionalServiceObj = new AdditionalServicesModel($id_additional_service);
$helper->tpl_vars = array(
'fields_value' => $this->getFormValues($additionalServiceObj),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
$_1 = $helper->generateForm(array($fields_form_1));
$return = $_1;
return $return;
}
function getFormValues($additionalServiceObj) {
return array(
'service_name' => Tools::getValue('service_name ', $additionalServiceObj->service_name),
'service_desc' => Tools::getValue('service_desc', $additionalServiceObj->service_desc),
'charge' => Tools::getValue('charge', $additionalServiceObj->charge),
'active' => Tools::getValue('active', $additionalServiceObj->active)
);
}
}
First of all, it seems that you redirect your page to the same URL. Try to use this
Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
where
AdminHome
is a redirect URL, you need to replace it with yours.
And second, try to use
Tools::getIsset('yourButtonName')
instead of
Tools::isSubmit('yourButtonName')
and the last, if nothing mentioned above will not help, try to move
parent::initContent();
and put it after your condition
Probably redirect_after may be useful
$this->redirect_after = 'Your custom address';
it's my first post so sorry in case i will do some mistakes. I am getting mad from this morning because of this function:
public function viewpdf0($agent_id = null, $month = null, $year = null){
if(!empty($agent_id)){
$this->create_remittance($agent_id, $month, $year);
$this->layout = '/pdf/default';
$this->render('/Pdf/remittance_0');
sleep(1);
$this->redirect('/files/remittances/STAT_'.str_pad($month, 2, '0', STR_PAD_LEFT).'_'.str_pad($year, 0, '0', STR_PAD_LEFT).'_'.$agent['Registry']['hash'].'_TEMP.pdf');
}
}
The problem started when i decided to take off the calculations from the viewpdf0 function and putting it into the create_remittance function.
When i click on the button "Print Pdf" i get the following error:
Missind Controller for files. This mean that the Cakephp is processing the redirect thinking to find a controller called files!!!!
It's very strange, because if i put again the calculation functions directly inside the viewpdf0 function it works.
Below part of the create_remittance function:
public function create_remittance($agent_id = null, $month = null, $year = null) {
$agent = $this->Registry->findById($agent_id);
$this->set('agent', $agent);
$conditions = array();
array_push($conditions , array('Dossier.active' => '1'));
array_push($conditions , array('Edossier.active' => '1'));
array_push($conditions , array('OR' =>
array(
array(
'Dossier.item_parent_id' => '43'
),
array(
'Dossier.item_parent_id' => '44'
)
)
));
//20:POLIZZA EMESSA - 17:PERFEZIONATA - 14:ATTESA DOC. ORIGINALI - 18:CARICATA
array_push($conditions , array('Dossier.state_id' => array(20,17,14,18)));
array_push($conditions , array('EXTRACT(MONTH FROM "Edossier"."date_emissione") =' => $month));
array_push($conditions , array('EXTRACT(YEAR FROM "Edossier"."date_emissione") =' => $year));
array_push($conditions , array('Dossier.agent_id' => $agent_id));
$query = array(
'fields' => array( 'DISTINCT Dossier.id',
'Agent.surname'
),
'joins' => array(
array('table' => 'items',
'alias' => 'Item',
'type' => 'LEFT',
'conditions' => array('Dossier.item_id = Item.id'),
),
array('table' => 'edossiers',
'alias' => 'Edossier',
'type' => 'LEFT',
'conditions' => array('Edossier.dossier_id = Dossier.id'),
),
array('table' => 'registries',
'alias' => 'Registry',
'type' => 'LEFT',
'conditions' => array('Dossier.registry_id = Registry.id'),
),
array('table' => 'registries',
'alias' => 'Agency',
'type' => 'LEFT',
'conditions' => array('Dossier.insurance_agency_id = Agency.id'),
),
array('table' => 'registries',
'alias' => 'Company',
'type' => 'LEFT',
'conditions' => array('Dossier.insurance_company_id = Company.id'),
),
array('table' => 'states',
'alias' => 'State',
'type' => 'LEFT',
'conditions' => array('Dossier.state_id = State.id'),
),
array('table' => 'categories',
'alias' => 'Product',
'type' => 'LEFT',
'conditions' => array('Dossier.item_parent_id = Product.id'),
),
array('table' => 'registries',
'alias' => 'Agent',
'type' => 'LEFT',
'conditions' => array('Dossier.agent_id = Agent.id'),
),
array('table' => 'states',
'alias' => 'RenewedState',
'type' => 'LEFT',
'conditions' => array('Dossier.renewed_state_id = RenewedState.id'),
),
),
'conditions' => $conditions,
'recursive' => -1
);
$dossiers = $this->Dossier->find('all', $query);
$this->set('dossiers', $dossiers);
$debug_dossier = '';
$edossiers = array();
$edossiers3 = array();
$dossier_ids = array();
$total_gross = 0;
$total_taxes = 0;
$total_equity = 0;
$total_fees_gross = 0;
$total_bill_tax = 0;
foreach($dossiers as $dossier){
// Query su type=1 ossia rata di pagamento
$edossier_all = $this->Edossier->find('all', array(
'conditions' => array(
'Edossier.active' => '1',
'Edossier.dossier_id' => $dossier['Dossier']['id'],
'Edossier.type' => '1',
'Edossier.month' => $month,
'Edossier.year' => $year
),
'order' => array(
'Edossier.id ASC'
)
));
// Query su type=2 ossia storno di pagamento
$edossier3_all = $this->Edossier->find('all', array(
'conditions' => array(
'Edossier.active' => '1',
'Edossier.dossier_id' => $dossier['Dossier']['id'],
'Edossier.type' => '2',
'Edossier.month' => $month,
'Edossier.year' => $year
),
'order' => array(
'Edossier.id ASC'
)
));
foreach($edossier_all as $edossier){
if(!empty($edossier)){
$item = $this->Item->findById($edossier['Dossier']['item_id']);
$agent_name = $this->Registry->findById($edossier['Dossier']['agent_id']);
$state = $this->State->findById($edossier['Dossier']['state_id']);
$registry = $this->Registry->findById($edossier['Dossier']['registry_id']);
$cashflow = $this->Cashflow->findByHash($edossier['Edossier']['cashflow_hash']);
$edossier['Agent'] = $agent_name;
$edossier['Item'] = $item;
$edossier['State'] = $state;
$edossier['Registry'] = $registry;
$edossier['Cashflow'] = $cashflow;
array_push($edossiers, $edossier);
$total_gross = $total_gross + $edossier['Edossier']['gross'];
$total_taxes = $total_taxes + $edossier['Edossier']['taxes'];
$total_equity = $total_equity + $edossier['Edossier']['equity'];
$total_fees_gross = $total_fees_gross + $edossier['Edossier']['fees_gross'];
$total_bill_tax = $total_bill_tax + $edossier['Edossier']['bill_tax'];
}
}
foreach($edossier3_all as $edossier3){
if(!empty($edossier3)){
$total_gross = $total_gross - $edossier3['Edossier']['value'];
$total_taxes = $total_taxes - $edossier3['Edossier']['taxes'];
$total_equity = $total_equity - $edossier3['Edossier']['equity'];
$total_fees_gross = $total_fees_gross - $edossier3['Edossier']['fees_gross'];
$total_bill_tax = $total_bill_tax - $edossier3['Edossier']['bill_tax'];
array_push($edossiers3, $edossier3);
}
}
array_push($dossier_ids, $dossier['Dossier']['id']);
$debug_dossier .= $dossier['Dossier']['id'] .',';
}
//Trovo tutte le rate pagate per conteggiare il totale pagato, nelle successive righe
$edossiers2 = $this->Edossier->find('all', array(
'conditions' => array(
'Edossier.active' => '1',
'Edossier.dossier_id' => $dossier_ids,
'Edossier.payed' => '1',
'Edossier.month' => $month,
'Edossier.year' => $year
)
));
$edossier_ids = array();
foreach($edossiers as $edossier){
array_push($edossier_ids, $edossier['Edossier']['id']);
}
$total_payed = 0;
foreach($edossiers2 as $edossier2){
//$cashflow = $this->Cashflow->findByHash($edossier2['Edossier']['cashflow_hash']);
//$total_payed = $total_payed + $cashflow['Cashflow']['qty'];
$cashflows = $this->Cashflow->find('all', array(
'conditions' => array(
'Cashflow.edossier_id' => $edossier2['Edossier']['id'],
'Cashflow.active' => '1'
)
));
foreach ($cashflows as $cashflow) {
$total_payed = $total_payed + $cashflow['Cashflow']['qty'];
}
}
$this->set('total_gross', $total_gross);
$this->set('total_taxes', $total_taxes);
$this->set('total_equity', $total_equity);
$this->set('total_fees_gross', $total_fees_gross);
$this->set('total_bill_tax', $total_bill_tax);
$this->set('total_payed', $total_payed);
$this->set('edossiers3', $edossiers3);
$this->set('edossiers2', $edossiers2);
$this->set('edossiers', $edossiers);
$this->set('agent', $agent);
$this->set('dossier_ids', $dossier_ids);
$this->set('edossier_ids', $edossier_ids);
$this->set('month', $month);
$this->set('year', $year);
$this->set('debug_dossier', $debug_dossier);
}
I solved the issue just inserting an array return in the function create_remittance and in the function viewpdf0 i fixed in this way:
$remittance = $this->create_remittance($agent_id, $month, $year);
Thank you.
I'm usually working with WP, but I need to manipulate a module blockcontactinfos on Prestashop - just simply add two more fields which will be shown on the front end, but somehow it's not working.
I have carrefully copied one of the fields, changed it everywhere but I when trying to clear the cache (in the Performance menu):
2 errors
blockcontactinfos (parse error in /modules/blockcontactinfos/blockcontactinfos.php)
blockcontactinfos (class missing in /modules/blockcontactinfos/blockcontactinfos.php)
Could anybody help me out of this? Thanks a lot in advance. Prestashop is 1.6. Fields are displayed correctly in settings, values saved, but there is the error above and I just can't force the web page to load changed template file.
blockcontactinfos.php (added the ones with _url), lines 31-141, changes marked with // KV:
<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
class Blockcontactinfos extends Module
{
protected static $contact_fields = array(
'BLOCKCONTACTINFOS_COMPANY',
'BLOCKCONTACTINFOS_ADDRESS',
'BLOCKCONTACTINFOS_ADDRESS_URL',
'BLOCKCONTACTINFOS_PHONE',
'BLOCKCONTACTINFOS_PHONE_URL',
'BLOCKCONTACTINFOS_EMAIL',
);
public function __construct()
{
$this->name = 'blockcontactinfos';
$this->author = 'PrestaShop';
$this->tab = 'front_office_features';
$this->version = '1.2.0';
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Contact information block');
$this->description = $this->l('This module will allow you to display your e-store\'s contact information in a customizable block.');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
public function install()
{
Configuration::updateValue('BLOCKCONTACTINFOS_COMPANY', Configuration::get('PS_SHOP_NAME'));
Configuration::updateValue('BLOCKCONTACTINFOS_ADDRESS', trim(preg_replace('/ +/', ' ', Configuration::get('PS_SHOP_ADDR1').' '.Configuration::get('PS_SHOP_ADDR2')."\n".Configuration::get('PS_SHOP_CODE').' '.Configuration::get('PS_SHOP_CITY')."\n".Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), Configuration::get('PS_SHOP_COUNTRY_ID')))));
Configuration::updateValue('BLOCKCONTACTINFOS_ADDRESS_URL', Configuration::get('PS_SHOP_ADDRESS_URL'));
Configuration::updateValue('BLOCKCONTACTINFOS_PHONE', Configuration::get('PS_SHOP_PHONE'));
Configuration::updateValue('BLOCKCONTACTINFOS_PHONE_URL', Configuration::get('PS_SHOP_PHONE_URL'));
Configuration::updateValue('BLOCKCONTACTINFOS_EMAIL', Configuration::get('PS_SHOP_EMAIL'));
$this->_clearCache('blockcontactinfos.tpl');
return (parent::install() && $this->registerHook('header') && $this->registerHook('footer'));
}
public function uninstall()
{
foreach (Blockcontactinfos::$contact_fields as $field)
Configuration::deleteByName($field);
return (parent::uninstall());
}
public function getContent()
{
$html = '';
if (Tools::isSubmit('submitModule'))
{
foreach (Blockcontactinfos::$contact_fields as $field)
Configuration::updateValue($field, Tools::getValue($field));
$this->_clearCache('blockcontactinfos.tpl');
$html = $this->displayConfirmation($this->l('Configuration updated'));
}
return $html.$this->renderForm();
}
public function hookHeader()
{
$this->context->controller->addCSS(($this->_path).'blockcontactinfos.css', 'all');
}
public function hookFooter($params)
{
if (!$this->isCached('blockcontactinfos.tpl', $this->getCacheId()))
foreach (Blockcontactinfos::$contact_fields as $field)
$this->smarty->assign(strtolower($field), Configuration::get($field));
return $this->display(__FILE__, 'blockcontactinfos.tpl', $this->getCacheId());
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Company name'),
'name' => 'BLOCKCONTACTINFOS_COMPANY',
),
array(
'type' => 'textarea',
'label' => $this->l('Address'),
'name' => 'BLOCKCONTACTINFOS_ADDRESS',
),
array(
'type' => 'text',
'label' => $this->l('URL na Google mapy'),
'name' => 'BLOCKCONTACTINFOS_ADDRESS_URL',
),
array(
'type' => 'text',
'label' => $this->l('Phone number'),
'name' => 'BLOCKCONTACTINFOS_PHONE',
),
array(
'type' => 'text',
'label' => $this->l('Telefonní číslo bez mezer'),
'name' => 'BLOCKCONTACTINFOS_PHONE_URL',
),
array(
'type' => 'text',
'label' => $this->l('Email'),
'name' => 'BLOCKCONTACTINFOS_EMAIL',
),
),
'submit' => array(
'title' => $this->l('Save')
)
),
);
$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->identifier = $this->identifier;
$helper->submit_action = 'submitModule';
$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' => array(),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id
);
foreach (Blockcontactinfos::$contact_fields as $field)
$helper->tpl_vars['fields_value'][$field] = Tools::getValue($field, Configuration::get($field));
return $helper->generateForm(array($fields_form));
}
}
blockcontactinfos.tpl (added the ones with _url), lines 32-33:
{if $blockcontactinfos_address != ''}<li><pre> {$blockcontactinfos_address|escape:'html':'UTF-8'|nl2br}</pre></li>{/if}
{if $blockcontactinfos_phone != ''}<li>{l s='Tel' mod='blockcontactinfos'} {$blockcontactinfos_phone|escape:'html':'UTF-8'}</li>{/if}
I need to integrate Easypay.pt with opengateway so if any one know somehting about this i would like to know if some one can help for this i will appreciate thanks
function Settings () {
$settings = array();
$settings['name'] = 'Easypay';
$settings['class_name'] = 'easypay';
$settings['external'] = FALSE;
$settings['no_credit_card'] = FALSE;
$settings['description'] =
'Easypay is a portuguese company that offers a universal payment
platform and is certified by SIBS, Unicre, Visa and MasterCard. Our
primary mission is helping the market to shorten the payment
processing time and offer greater flexibility and convenience in
payment.';
$settings['is_preferred'] = 1;
$settings['setup_fee'] = '$0.00';
$settings['monthly_fee'] = '$30.00';
$settings['transaction_fee'] = '2.5% + $0.30';
$settings['purchase_link'] = 'https://www.easypay.pt/_s/api_easypay_01BG.php';
$settings['allows_updates'] = 0;
$settings['url_live'] = 'https://www.easypay.pt/_s/api_easypay_01BG.php ';
$settings['url_test'] = 'http://test.easypay.pt/_s/api_easypay_01BG.php';
$settings['allows_refunds'] = 1;
$settings['requires_customer_information'] = 1;
$settings['requires_customer_ip'] = 1;
$settings['required_fields'] = array(
'enabled',
'mode',
'ep_cin',
'ep_user',
'ep_ref_type',
'ep_entity',
't_key',
'ep_language',
'ep_country'
);
$settings['field_details'] = array(
'enabled' => array(
'text' => 'Enable this gateway?',
'type' => 'radio',
'options' => array(
'1' => 'Enabled',
'0' => 'Disabled'
)
),
'mode' => array(
'text' => 'Mode',
'type' => 'select',
'options' => array(
'live' => 'Live Mode',
'test' => 'Test Mode'
)
),
'ep_cin' => array(
'text' => 'Client Identification Number',
'type' => 'text'
),
'ep_user' => array(
'text' => 'Username',
'type' => 'text'
),
'ep_ref_type' => array(
'text' => 'Type of Identifier',
'type' => 'select',
'options' => array(
'auto' => 'Auto',
)
),
'ep_type' => array(
'text' => 'Type',
'type' => 'select',
'options' => array(
'boleto' => 'Boleto',
)
),
'ep_entity' => array(
'text' => 'Entity in use by Your Account.',
'type' => 'text',
),
't_key' => array(
'text' => 'Transaction key',
'type' => 'text',
),
'ep_language' => array(
'text' => 'Language',
'type' => 'select',
'options' => array(
'PT' => 'PT',
)
),
'ep_country' => array(
'text' => 'Currency',
'type' => 'select',
'options' => array(
'PT' => 'PT',
)
)
);
return $settings;
}
function TestConnection($client_id, $gateway) {
// Get the proper URL
switch($gateway['mode']) {
case 'live':
$post_url = $gateway['url_live'];
break;
case 'test':
$post_url = $gateway['url_test'];
break;
}
$post = array();
$post['ep_cin'] = $gateway['ep_cin'];
$post['ep_user'] = $gateway['ep_user'];
$post['ep_entity'] = $gateway['ep_entity'];
$post['ep_ref_type'] = $gateway['ep_ref_type'];
$post['ep_type'] = 'boleto';
$post['t_value'] = '504.4';
$post['ep_country'] = $gateway['ep_country'];
$post['ep_language'] = $gateway['ep_language'];
$post['s_code'] = 'sssssssssssyour code ddddddd';
$post['t_key'] = $gateway['t_key'];;
$response = $this->Process($post_url, $post);
$status=$response->ep_status;
//$CI =& get_instance();
if($status != 'err1') {
return TRUE;
} else {
return FALSE;
}
}
//--------------------------------------------------------------------
function Process($url, $post, $order_id = FALSE) {
$response = simplexml_load_file(
$url . "ep_cin=" . $post['ep_cin'] . "&ep_user=" . $post['ep_user']
. "&ep_entity=" . $post['ep_entity'] . "&ep_ref_type=" . $post['ep_ref_type']
. "&ep_type=" . $post['ep_type'] . "&ep_country=" . $post['ep_country']
. "&ep_language='" . $post['ep_language'] . "'&s_code=" . $post['s_code']
. "&t_key=" . $post['t_key'] . "&t_value=" . $post['t_value']
);
return $response;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
private function response_to_array($string) {
$string = urldecode($string);
$pairs = explode('&', $string);
$values = array();
foreach($pairs as $pair) {
list($key, $value) = explode('=', $pair);
$values[$key] = $value;
}
return $values;
}