* @copyright 2007-2019 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 GeisLogistic extends Module
{
protected $config_form = false;
public function __construct()
{
$this->name = 'GeisLogistic';
$this->tab = 'shipping_logistics';
$this->version = '1.0.0';
$this->author = 'europasaz.pl';
$this->need_instance = 1;
/**
* Set $this->bootstrap to true if your module is compliant with bootstrap (PrestaShop 1.6)
*/
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('GeisLogistic');
$this->description = $this->l('Module to integrate Geis Logistic with PrestaShop');
$this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_);
$this->confirmUninstall = $this->l('Are you shure?');
$this->secure_key = $this->name;
}
public function install()
{
if (extension_loaded('curl') == false)
{
$this->_errors[] = $this->l('You have to enable the cURL extension on your server to install this module');
return false;
}
Configuration::updateValue('GEISLOGISTIC_TEST', '1') //TRYB TEST RADIO
&& Configuration::updateValue('GEISLOGISTIC_COUNTRY', 'PL') //KRAJ S ok lang i url
&& Configuration::updateValue('GEISLOGISTIC_TYPE', '10') //TYP NADANIA
&& Configuration::updateValue('GEISLOGISTIC_CHANNEL', '1') //DistributionChannel
//&& Configuration::updateValue('GEISLOGISTIC_ROD', '0') //zwrot dokumentow
&& Configuration::updateValue('GEISLOGISTIC_COUNTER', '1') //ilosc paczek
//&& Configuration::updateValue('GEISLOGISTIC_ROD_TXT', 'RUA') //zwrot dokumentow
&& Configuration::updateValue('GEISLOGISTIC_DESCRIPTION', 'DESCRIPTION')
&& Configuration::updateValue('GEISLOGISTIC_WRAP', 'FP')
&& Configuration::updateValue('GEISLOGISTIC_WEIGHT', '5')
&& Configuration::updateValue('GEISLOGISTIC_WEIGHT_1', '5')
&& Configuration::updateValue('GEISLOGISTIC_WEIGHT_2', '5')
&& Configuration::updateValue('GEISLOGISTIC_FORMAT', '1')
&& Configuration::updateValue('GEISLOGISTIC_RESOLUTION', '200');
return parent::install() &&
$this->registerHook('adminOrder');
}
public function uninstall()
{
Configuration::deleteByName('GEISLOGISTIC_TEST')
&& Configuration::deleteByName('GEISLOGISTIC_CODE') //ok
&& Configuration::deleteByName('GEISLOGISTIC_API') //ok
&& Configuration::deleteByName('GEISLOGISTIC_EMAILSENDER')
&& Configuration::deleteByName('GEISLOGISTIC_NAMESENDER')
&& Configuration::deleteByName('GEISLOGISTIC_PHONESENDER')
&& Configuration::deleteByName('GEISLOGISTIC_COUNTRY') //ok
&& Configuration::deleteByName('GEISLOGISTIC_TYPE') //ok
&& Configuration::deleteByName('GEISLOGISTIC_CHANNEL') //ok
&& Configuration::deleteByName('GEISLOGISTIC_NOTE') // NOTATKA MAX50 ok
&& Configuration::deleteByName('GEISLOGISTIC_NOTEDRIVER') // NOTATKA KIEROWCA MAX50 ok
&& Configuration::deleteByName('GEISLOGISTIC_OID') //ok
//&& Configuration::deleteByName('GEISLOGISTIC_ROD') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_ROD_TXT') //ok
//&& Configuration::deleteByName('GEISLOGISTIC_ROD_CODE') // OK
//&& Configuration::deleteByName('GEISLOGISTIC_ADL') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_ADL_TXT') //ok
&& Configuration::deleteByName('GEISLOGISTIC_ADZ') //ok
&& Configuration::deleteByName('GEISLOGISTIC_ADZ_TXT') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_AOZ') //ok
//&& Configuration::deleteByName('GEISLOGISTIC_AOZ_TXT') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_APZ') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_APZ_TXT') //ok
&& Configuration::deleteByName('GEISLOGISTIC_COD') // ok
&& Configuration::deleteByName('GEISLOGISTIC_COD_IBAN') // ok
&& Configuration::deleteByName('GEISLOGISTIC_POJ') // insurance
&& Configuration::deleteByName('GEISLOGISTIC_POJ_VAL') //ok
&& Configuration::deleteByName('GEISLOGISTIC_POJ_ISO') //ok
&& Configuration::deleteByName('GEISLOGISTIC_AVI') //ok
&& Configuration::deleteByName('GEISLOGISTIC_SMS') // ok
//&& Configuration::deleteByName('GEISLOGISTIC_GAR')//ok
&& Configuration::deleteByName('GEISLOGISTIC_EMA')//ok
&& Configuration::deleteByName('GEISLOGISTIC_DON')//ok
&& Configuration::deleteByName('GEISLOGISTIC_COUNTER')// il paczek standard 1
&& Configuration::deleteByName('GEISLOGISTIC_DESCRIPTION')//ok
&& Configuration::deleteByName('GEISLOGISTIC_WRAP')//ok wrap list services
&& Configuration::deleteByName('GEISLOGISTIC_WEIGHT')// waga wymagana dla pl
&& Configuration::deleteByName('GEISLOGISTIC_WEIGHT_1') //ok
&& Configuration::deleteByName('GEISLOGISTIC_WEIGHT_2')
&& Configuration::deleteByName('GEISLOGISTIC_FORMAT')
&& Configuration::deleteByName('GEISLOGISTIC_RESOLUTION'); // szerokosc w m 0.4 tylko 1
return parent::uninstall();
}
/**
* Load the configuration form
*/
public function getContent()
{
/**
* If values have been submitted in the form, process.
*/
$output = '';
$this->context->controller->addJqueryUI('ui.slider');
$this->context->controller->addJqueryUI('ui.datepicker');
$this->context->controller->addCSS($this->_path . 'css/jquery-ui-timepicker-addon.css', 'all');
$this->context->controller->addJS($this->_path . 'js/jquery-ui-timepicker-addon.js');
if (((bool)Tools::isSubmit('submitGeisLogisticModule')) == true) {
$this->postProcess();
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
$this->uri = ToolsCore::getCurrentUrlProtocolPrefix() . $this->context->shop->domain_ssl . $this->context->shop->physical_uri;
$get_file_url = $this->uri . 'modules/GeisLogistic/views/lib/';
$this->context->smarty->assign('geisurl',$get_file_url);
$this->context->smarty->assign('geistoken', $this->secure_key);
$this->context->smarty->assign('healty', $this->ishealty());
$this->context->smarty->assign('wraplist', $this->WrapList());
$this->context->smarty->assign('services', $this->ServiceList());
$output .= $this->context->smarty->fetch($this->local_path .'views/templates/admin/module.tpl');
return $output.$this->renderForm();
}
/**
* Create the form that will be displayed in the configuration of your module.
*/
protected function renderForm()
{
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->table;
$helper->module = $this;
$helper->default_form_language = $this->context->language->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitGeisLogisticModule';
$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->getConfigFormValues(), /* Add values for your inputs */
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
return $helper->generateForm(array($this->getConfigForm()));
}
protected function createSelectOptions()
{
$selectOption['country'] = array(
array('id_option' => 'PL', 'name' => $this->l('Poland')),
array('id_option' => 'CZ', 'name' => $this->l('Czech')),
array('id_option' => 'SK', 'name' => $this->l('Slovakia')),
);
$selectOption['count'] = array(
array('id_option' => '1', 'name' => $this->l('One')),
array('id_option' => '2', 'name' => $this->l('Two')),
array('id_option' => '3', 'name' => $this->l('Three')),
);
$selectOption['channel'] = array(
array('id_option' => '1', 'name' => $this->l('Parcel')),
array('id_option' => '2', 'name' => $this->l('Cargo')),
);
$selectOption['rod'] = array(
array('id_option' => 'false', 'name' => $this->l('No')),
array('id_option' => 'RUA', 'name' => $this->l('RUA')),
array('id_option' => 'RWZ', 'name' => $this->l('RWZ')),
array('id_option' => 'RIM', 'name' => $this->l('RIM')),
array('id_option' => 'RAN', 'name' => $this->l('RAN')),
array('id_option' => 'RDW', 'name' => $this->l('RDW')),
array('id_option' => 'ROD', 'name' => $this->l('ROD')),
array('id_option' => 'RIN', 'name' => $this->l('RIN')),
array('id_option' => 'RUM', 'name' => $this->l('RUM')),
);
$selectOption['format'] = array(
array('id_option' => '1', 'name' => $this->l('PDF')),
array('id_option' => '2', 'name' => $this->l('EPL')),
array('id_option' => '3', 'name' => $this->l('ZPL')),
array('id_option' => '4', 'name' => $this->l('BMP')),
array('id_option' => '5', 'name' => $this->l('PDF 10x15')),
);
$selectOption['resolution'] = array(
array('id_option' => '200', 'name' => $this->l('200 DPI')),
array('id_option' => '300', 'name' => $this->l('300 DPI')),
);
$states = array();
$statesname = array();
$id_lang = configuration::get('PS_LANG_DEFAULT');
$order_states = OrderState::getOrderStates($id_lang);
foreach ($order_states as $value) {
$states['id_option'] = $value['id_order_state'];
$states['name'] = $value['name'];
$statesname[] = $states;
}
$selectOption['states'] = $statesname;
return $selectOption;
}
protected function getConfigForm()
{
$selectOption = $this->createSelectOptions();
$icon = 'icon-cogs';
$type = 'icon';
$radio = 'switch';
$class = '';
if (version_compare(_PS_VERSION_, '1.6.0.0', '<'))
{
$icon = _PS_ADMIN_IMG_ . 'cog.gif';
$type = 'image';
$class = 't';
$radio = 'radio';
}
return array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Test mode'),
'name' => 'GEISLOGISTIC_TEST',
'is_bool' => true,
'desc' => $this->l('Use this module in test mode'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Enter a valid customer sender code ex. xxxxxxxx '),
'name' => 'GEISLOGISTIC_CODE',
'label' => $this->l('Code'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Enter a valid API key ex. xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxx'),
'name' => 'GEISLOGISTIC_API',
'label' => $this->l('Api - Password'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Sender email for pickup'),
'name' => 'GEISLOGISTIC_EMAILSENDER',
'label' => $this->l('Email '),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Sender name for pickup'),
'name' => 'GEISLOGISTIC_NAMESENDER',
'label' => $this->l('Name'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Sender phone for pickup'),
'name' => 'GEISLOGISTIC_PHONESENDER',
'label' => $this->l('Phone'),
),
array(
'name' => 'GEISLOGISTIC_CHANNEL',
'type' => 'select',
'label' => $this->l('Distribution Channel'),
'desc' => $this->l('Type of transport service (1 – Parcel, 2 – Cargo)'),
'required' => true,
'options' => array(
'query' => $selectOption['channel'],
'id' => 'id_option',
'name' => 'name')),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Type of used service'),
'name' => 'GEISLOGISTIC_TYPE',
'label' => $this->l('Type of service ex. 10 - Parcel'),
),
array(
'col' => 3,
'type' => 'text',
'required' => false,
'prefix' => '',
'desc' => $this->l('Type of wrap'),
'name' => 'GEISLOGISTIC_WRAP',
'label' => $this->l('Type of wrap ex. EP'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Enter a description max 50 char.'),
'name' => 'GEISLOGISTIC_NOTE',
'label' => $this->l('Note to recipient'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'prefix' => '',
'desc' => $this->l('Enter a note for courier max 50 char.'),
'name' => 'GEISLOGISTIC_NOTEDRIVER',
'label' => $this->l('Note for courier'),
),
array(
'name' => 'GEISLOGISTIC_COUNTRY',
'type' => 'select',
'label' => $this->l('Country'),
'desc' => $this->l('Company country'),
'required' => true,
'options' => array(
'query' => $selectOption['country'],
'id' => 'id_option',
'name' => 'name')),
// array(
// 'type' => $radio,
// 'class' => $class,
// 'label' => $this->l('Rod'),
// 'name' => 'GEISLOGISTIC_ROD',
// 'is_bool' => true,
// 'desc' => $this->l('Return of documents'),
// 'values' => array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// ),
// ),
// array(
// 'col' => 3,
// 'type' => 'text',
// 'desc' => $this->l('ROD code address for documents'),
// 'name' => 'GEISLOGISTIC_ROD_CODE',
// 'label' => $this->l('ROD code'),
// ),
// array(
// 'name' => 'GEISLOGISTIC_ROD_TXT',
// 'type' => 'select',
// 'label' => $this->l('Guaranteed delivery documents - only Parcel'),
// 'desc' => $this->l('Type: RUA, RWZ, RIM, RAN, RDW, ROD, RIN, RUM'),
// 'required' => true,
// 'options' => array(
// 'query' => $selectOption['rod'],
// 'id' => 'id_option',
// 'name' => 'name')),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Order number'),
'name' => 'GEISLOGISTIC_OID',
'is_bool' => true,
'desc' => $this->l('Order Reference in label'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
// array(
// 'type' => $radio,
// 'class' => $class,
// 'label' => $this->l('ADL'),
// 'name' => 'GEISLOGISTIC_ADL',
// 'is_bool' => true,
// 'desc' => $this->l('Scan to email returned documents - without VM'),
// 'values' => array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// ),
// ),
// array(
// 'col' => 3,
// 'type' => 'text',
// 'desc' => $this->l('Enter a email for scan - only Parcel'),
// 'name' => 'GEISLOGISTIC_ADL_TXT',
// 'label' => $this->l('Email'),
// ),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('ADZ'),
'name' => 'GEISLOGISTIC_ADZ',
'is_bool' => true,
'desc' => $this->l('Confirmation delivery shipment'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'col' => 3,
'type' => 'text',
'desc' => $this->l('Enter a email or phone number with prefix - only Parcel'),
'name' => 'GEISLOGISTIC_ADZ_TXT',
'label' => $this->l('Email or phone'),
),
//array(
// 'type' => $radio,
// 'class' => $class,
// 'label' => $this->l('AOZ'),
// 'name' => 'GEISLOGISTIC_AOZ',
// 'is_bool' => true,
// 'desc' => $this->l('Notification damage on shipment'),
// 'values' => array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// ),
// ),
// array(
// 'col' => 3,
// 'type' => 'text',
// 'desc' => $this->l('Enter a email or phone number with prefix'),
// 'name' => 'GEISLOGISTIC_AOZ_TXT',
// 'label' => $this->l('Email or phone'),
// ),
//array(
// 'type' => $radio,
// 'class' => $class,
// 'label' => $this->l('APZ'),
// 'name' => 'GEISLOGISTIC_APZ',
// 'is_bool' => true,
// 'desc' => $this->l('Advising on a problematic shipment'),
// 'values' => array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// ),
// ),
// array(
// 'col' => 3,
// 'type' => 'text',
// 'desc' => $this->l('Enter a email or phone number with prefix - only Parcel'),
// 'name' => 'GEISLOGISTIC_APZ_TXT',
// 'label' => $this->l('Email or phone'),
// ),
array(
'name' => 'GEISLOGISTIC_COD',
'type' => 'select',
'label' => $this->l('COD state'),
'desc' => $this->l('Cash on delivery'),
'required' => true,
'options' => array(
'query' => $selectOption['states'],
'id' => 'id_option',
'name' => 'name')),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'desc' => $this->l('Enter a account number in IBAN FORMAT'),
'name' => 'GEISLOGISTIC_COD_TXT',
'label' => $this->l('IBAN'),
),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Insurance'),
'name' => 'GEISLOGISTIC_POJ',
'is_bool' => true,
'desc' => $this->l('Insurance - POJ'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'col' => 3,
'type' => 'text',
'desc' => $this->l('Value of the insurance'),
'name' => 'GEISLOGISTIC_POJ_VAL',
'label' => $this->l('Value'),
),
array(
'col' => 3,
'type' => 'text',
'desc' => $this->l('ISO code for value insurance'),
'name' => 'GEISLOGISTIC_POJ_ISO',
'label' => $this->l('Iso code'),
),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Phone advice'),
'name' => 'GEISLOGISTIC_AVI',
'is_bool' => true,
'desc' => $this->l('Telephone advice - recipient phone with prefix'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('SMS advice'),
'name' => 'GEISLOGISTIC_SMS',
'is_bool' => true,
'desc' => $this->l('Telephone advice - recipient phone without prefix'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
//array(
// 'type' => $radio,
// 'class' => $class,
// 'label' => $this->l('Guaranteed delivery'),
// 'name' => 'GEISLOGISTIC_GAR',
// 'is_bool' => true,
// 'desc' => $this->l('Guaranteed delivery - required phone or email recipient'),
// 'values' => array(
// array(
// 'id' => 'active_on',
// 'value' => 1,
// 'label' => $this->l('Enabled')
// ),
// array(
// 'id' => 'active_off',
// 'value' => 0,
// 'label' => $this->l('Disabled')
// )
// ),
// ),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Email to recipient'),
'name' => 'GEISLOGISTIC_EMA',
'is_bool' => true,
'desc' => $this->l('Required recipient, customer email'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'type' => $radio,
'class' => $class,
'label' => $this->l('Additional fee'),
'name' => 'GEISLOGISTIC_DON',
'is_bool' => true,
'desc' => $this->l('Additional fee for nonstandard packagigng'),
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
),
array(
'name' => 'GEISLOGISTIC_COUNTER',
'type' => 'select',
'label' => $this->l('Number of packages'),
'desc' => $this->l('Select number of packages'),
'required' => true,
'options' => array(
'query' => $selectOption['count'],
'id' => 'id_option',
'name' => 'name')),
array(
'col' => 3,
'type' => 'text',
'desc' => $this->l('Adidtional description'),
'name' => 'GEISLOGISTIC_DESCRIPTION',
'label' => $this->l('Description'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'desc' => $this->l('Weight '),
'name' => 'GEISLOGISTIC_WEIGHT',
'label' => $this->l('Weight 1 package - 0.4'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'desc' => $this->l('Weight 2'),
'name' => 'GEISLOGISTIC_WEIGHT_1',
'label' => $this->l('Weight 2 package - 0.4'),
),
array(
'col' => 3,
'type' => 'text',
'required' => true,
'desc' => $this->l('Weight 3'),
'name' => 'GEISLOGISTIC_WEIGHT_2',
'label' => $this->l('Weight 3 package - 0.3'),
),
array(
'name' => 'GEISLOGISTIC_FORMAT',
'type' => 'select',
'label' => $this->l('Label format'),
'desc' => $this->l('Select format for printed label'),
'required' => true,
'options' => array(
'query' => $selectOption['format'],
'id' => 'id_option',
'name' => 'name')),
array(
'name' => 'GEISLOGISTIC_RESOLUTION',
'type' => 'select',
'label' => $this->l('Label resolution'),
'desc' => $this->l('Select resolution for printed label only valid for EPL and ZPL'),
'required' => true,
'options' => array(
'query' => $selectOption['resolution'],
'id' => 'id_option',
'name' => 'name')),
),
'submit' => array(
'title' => $this->l('Save'),
),
),
);
}
/**
* Set values for the inputs.
*/
protected function getConfigFormValues()
{
return array(
'GEISLOGISTIC_CODE' => Configuration::get('GEISLOGISTIC_CODE'),
'GEISLOGISTIC_API' => Configuration::get('GEISLOGISTIC_API'),
'GEISLOGISTIC_EMAILSENDER' => Configuration::get('GEISLOGISTIC_EMAILSENDER'),
'GEISLOGISTIC_NAMESENDER' => Configuration::get('GEISLOGISTIC_NAMESENDER'),
'GEISLOGISTIC_PHONESENDER' => Configuration::get('GEISLOGISTIC_PHONESENDER'),
'GEISLOGISTIC_TEST' => Configuration::get('GEISLOGISTIC_TEST'),
'GEISLOGISTIC_COUNTRY' => Configuration::get('GEISLOGISTIC_COUNTRY'),
'GEISLOGISTIC_TYPE' => Configuration::get('GEISLOGISTIC_TYPE'), //ok
'GEISLOGISTIC_CHANNEL' => Configuration::get('GEISLOGISTIC_CHANNEL'),
//'GEISLOGISTIC_ROD' => Configuration::get('GEISLOGISTIC_ROD'), //ok
//'GEISLOGISTIC_ROD_TXT' => Configuration::get('GEISLOGISTIC_ROD_TXT'), //ok
//'GEISLOGISTIC_ROD_CODE' => Configuration::get('GEISLOGISTIC_ROD_CODE'), //ok
'GEISLOGISTIC_NOTE' => Configuration::get('GEISLOGISTIC_NOTE'), //ok
'GEISLOGISTIC_NOTEDRIVER' => Configuration::get('GEISLOGISTIC_NOTEDRIVER'), //ok
'GEISLOGISTIC_OID' => Configuration::get('GEISLOGISTIC_OID'), //ok
//'GEISLOGISTIC_ADL' => Configuration::get('GEISLOGISTIC_ADL'), //ok
//'GEISLOGISTIC_ADL_TXT' => Configuration::get('GEISLOGISTIC_ADL_TXT'), //ok
'GEISLOGISTIC_ADZ' => Configuration::get('GEISLOGISTIC_ADZ'), //ok
'GEISLOGISTIC_ADZ_TXT' => Configuration::get('GEISLOGISTIC_ADZ_TXT'), //ok
//'GEISLOGISTIC_AOZ' => Configuration::get('GEISLOGISTIC_AOZ'), //ok
//'GEISLOGISTIC_AOZ_TXT' => Configuration::get('GEISLOGISTIC_AOZ_TXT'), //ok
//'GEISLOGISTIC_APZ' => Configuration::get('GEISLOGISTIC_APZ'), //ok
//'GEISLOGISTIC_APZ_TXT' => Configuration::get('GEISLOGISTIC_APZ_TXT'), //ok
'GEISLOGISTIC_COD' => Configuration::get('GEISLOGISTIC_COD'), //ok
'GEISLOGISTIC_COD_TXT' => Configuration::get('GEISLOGISTIC_COD_TXT'), //iban from config
'GEISLOGISTIC_POJ' => Configuration::get('GEISLOGISTIC_POJ'), // ubezp from config
'GEISLOGISTIC_POJ_VAL' => Configuration::get('GEISLOGISTIC_POJ_VAL'), // jw
'GEISLOGISTIC_POJ_ISO' => Configuration::get('GEISLOGISTIC_POJ_ISO'), //jw
'GEISLOGISTIC_AVI' => Configuration::get('GEISLOGISTIC_AVI'), // ok +phone prefix
'GEISLOGISTIC_SMS' => Configuration::get('GEISLOGISTIC_SMS'), // ok without prefix
'GEISLOGISTIC_EMA' => Configuration::get('GEISLOGISTIC_EMA'), // ok with email
'GEISLOGISTIC_DON' => Configuration::get('GEISLOGISTIC_DON'), //ok
//'GEISLOGISTIC_GAR' => Configuration::get('GEISLOGISTIC_GAR'), //ok guaranted del with email or phone
'GEISLOGISTIC_COUNTER' => Configuration::get('GEISLOGISTIC_COUNTER'), //ok il pacz
'GEISLOGISTIC_DESCRIPTION' => Configuration::get('GEISLOGISTIC_DESCRIPTION'), //ok
'GEISLOGISTIC_WRAP' => Configuration::get('GEISLOGISTIC_WRAP'), //ok
'GEISLOGISTIC_WEIGHT' => Configuration::get('GEISLOGISTIC_WEIGHT'), //ok
'GEISLOGISTIC_WEIGHT_1' => Configuration::get('GEISLOGISTIC_WEIGHT_1'), //ok
'GEISLOGISTIC_WEIGHT_2' => Configuration::get('GEISLOGISTIC_WEIGHT_2'),
'GEISLOGISTIC_FORMAT' => Configuration::get('GEISLOGISTIC_FORMAT'), //ok
'GEISLOGISTIC_RESOLUTION' => Configuration::get('GEISLOGISTIC_RESOLUTION'),
);
}
/**
* Save form data.
*/
protected function postProcess()
{
$form_values = $this->getConfigFormValues();
foreach (array_keys($form_values) as $key) {
Configuration::updateValue($key, Tools::getValue($key));
}
}
public function hookDisplayAdminOrder($params)
{
$this->uri = ToolsCore::getCurrentUrlProtocolPrefix() . $this->context->shop->domain_ssl . $this->context->shop->physical_uri;
$get_file_url = $this->uri . 'modules/GeisLogistic/views/lib/';
$Order = new Order($params['id_order']);
$id_order = Tools::getValue('id_order');
$customer = new Customer($Order->id_customer);
$address = new Address($Order->id_address_delivery);
if (empty($address->company))
{
$namew = $address->firstname . ' ' . $address->lastname;
$geisb2c = 0;
} else
{
$namew = $address->company;
$geisb2c = 1;
}
if (empty($address->phone_mobile))
{
$this->context->smarty->assign(array('geisphone' => $address->phone));
} else
{
$this->context->smarty->assign(array('geisphone' => $address->phone_mobile));
} //ok
$trackingnumber = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `tracking_number` FROM `' . _DB_PREFIX_ . 'order_carrier` WHERE `id_order` = ' . $id_order);
$totalorder = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `total_paid_tax_incl` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_order` = ' . $id_order);
$id_order_state = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `current_state` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_order` = ' . $id_order);
$geiscountry = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `iso_code` FROM `' . _DB_PREFIX_ . 'country` WHERE `id_country` = ' . (int)($address->id_country));
$reference = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `reference` FROM `' . _DB_PREFIX_ . 'orders` WHERE `id_order` = ' . $id_order);
$currency = $Order->id_currency;
$currencyiso = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT `iso_code` FROM `' . _DB_PREFIX_ . 'currency` WHERE `id_currency` = ' . (int)$currency);
$this->context->smarty->assign(array(
'secure_key' => $this->secure_key, //ok
'liburl' => $get_file_url, //ok
'trackingnumber' => $trackingnumber,
'geistotal' => Tools::ps_round($totalorder, '2'), //ok
'curentstate' => $id_order_state, //ok
'geisname' => $address->firstname .' '. $address->lastname, //ok fullname
'geisnazwa' => $namew, //d name
'geiszipcode' => $address->postcode, //ok
'geiscity' => $address->city, //ok
'geiscountry' => $geiscountry, //ok
'geisstreet' => $address->address1 .' '. $address->address2, //ok
'geisemail' => $this->context->customer->email, //ok
'geisidorder' => $reference, //ok hidden
'geisorder' => $id_order,
'geisprivate' => $geisb2c,
'geistype' => Configuration::get('GEISLOGISTIC_TYPE'), //ok
'geischannel' => Configuration::get('GEISLOGISTIC_CHANNEL'), //ok
'geiswrap' => Configuration::get('GEISLOGISTIC_WRAP'),//ok
//'geisrod' => Configuration::get('GEISLOGISTIC_ROD'), //ok
'geisnote' => Configuration::get('GEISLOGISTIC_NOTE'), //ok
'geisnotedriver' => Configuration::get('GEISLOGISTIC_NOTEDRIVER'), //ok
//'geisadl' => Configuration::get('GEISLOGISTIC_ADL'), //ok
'geisadz' => Configuration::get('GEISLOGISTIC_ADZ'), //ok
//'geisaoz' => Configuration::get('GEISLOGISTIC_AOZ'), //ok
//'geisapz' => Configuration::get('GEISLOGISTIC_APZ'), //ok
'geiscod' => Configuration::get('GEISLOGISTIC_COD'), //ok
'geisavi' => Configuration::get('GEISLOGISTIC_AVI'), //ok
'geissms' => Configuration::get('GEISLOGISTIC_SMS'), //ok
'geissemail' => Configuration::get('GEISLOGISTIC_EMA'), //ok
'geisaddfee' => Configuration::get('GEISLOGISTIC_DON'), //ok
//'geisguaranted' => Configuration::get('GEISLOGISTIC_GAR'), //ok
'geiscounter' => Configuration::get('GEISLOGISTIC_COUNTER'), //ok
'geisdecription' => Configuration::get('GEISLOGISTIC_DESCRIPTION'), //ok
'geisweight' => Configuration::get('GEISLOGISTIC_WEIGHT'), //ok
'geisweight1' => Configuration::get('GEISLOGISTIC_WEIGHT_1'), //ok
'geisweight2' => Configuration::get('GEISLOGISTIC_WEIGHT_2'), //ok
'geiscurrencyiso' => $currencyiso,
));
$outputorder = $this->context->smarty->fetch($this->local_path . 'views/templates/admin/configure.tpl');
return $outputorder;
}
public function ishealty()
{
ini_set("soap.wsdl_cache_enabled", "0");
try
{
$client = new SoapClient($this->wsdl(), array("trace" => 1));
$result = $client->IsHealthy();
}
catch (exception $ex)
{
return "BLAD: .$ex->faultcode .$ex->faultstring. \n\n";
}
if (isset($result->IsHealthyResult)) {
return $result->IsHealthyResult;
}else{
return false;
}
}
public function WrapList()
{
$apicode = Configuration::get('GEISLOGISTIC_CODE'); // CustomerCode
$apikey = Configuration::get('GEISLOGISTIC_API'); //Password
$country = Configuration::get('GEISLOGISTIC_COUNTRY');
if (empty($apicode) || empty($apikey) ) {
$result = 'No creditentials entered';
return $result;
}else{
ini_set("soap.wsdl_cache_enabled", "0");
try
{
$client = new SoapClient($this->wsdl(), array("trace" => 1));
$data['Request']['Header'] = array(
'CustomerCode' => $apicode,
'Language' => $country,
'Password' => $apikey,
);
$result = $client->WrapList($data);
}
catch (exception $ex)
{
return "BLAD: .$ex->faultcode .$ex->faultstring. \n\n";
}
if (isset($result->WrapListResult->ResponseObject->Wrap)) {
return $result->WrapListResult->ResponseObject->Wrap;
}else{
$result = false;
return $result;
}
}
}
public function ServiceList()
{
$apicode = Configuration::get('GEISLOGISTIC_CODE'); // CustomerCode
$apikey = Configuration::get('GEISLOGISTIC_API'); //Password
$country = Configuration::get('GEISLOGISTIC_COUNTRY');
if (empty($apicode) || empty($apikey) ) {
$result = 'No creditentials entered';
return $result;
}else{
ini_set("soap.wsdl_cache_enabled", "0");
try
{
$client = new SoapClient($this->wsdl(), array("trace" => 1));
$data['Request']['Header'] = array(
'CustomerCode' => $apicode,
'Language' => $country,
'Password' => $apikey,
);
$result = $client->ServiceList($data);
}
catch (exception $ex)
{
return "BLAD: .$ex->faultcode .$ex->faultstring. \n\n";
}
if (isset($result->ServiceListResult->ResponseObject->Service)) {
return $result->ServiceListResult->ResponseObject->Service;
}else{
$result = false;
return $result;
}
}
}
public function wsdl()
{
$testmode = Configuration::get('GEISLOGISTIC_TEST');
$country = Configuration::get('GEISLOGISTIC_COUNTRY');
if ($testmode == '0') {
if ($country == 'PL') {
$wsdl = 'https://gclient.geis.pl/GService/GService.svc?wsdl';
}else{
$wsdl = 'https://gclient.geis.cz/GService/GService.svc?wsdl';
}
}else{
if ($country == 'PL') {
$wsdl = 'https://gclient.geis.pl/GServiceTest/GService.svc?wsdl';
}else{
$wsdl = 'https://gclient.geis.cz/GServiceTest/GService.svc?wsdl';
}
}
return $wsdl;
}
}//end