848 lines
44 KiB
PHP
848 lines
44 KiB
PHP
<?php
|
|
require_once __DIR__.'/src/EpakaApi.php';
|
|
require_once __DIR__.'/src/EpakaDB.php';
|
|
require_once __DIR__.'/src/EpakaOrder.php';
|
|
|
|
if (!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
|
|
class Epaka extends Module
|
|
{
|
|
public $api = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->name = 'epaka';
|
|
$this->tab = 'others';
|
|
$this->version = '1.0.0';
|
|
$this->author = 'epaka.pl';
|
|
$this->need_instance = 0;
|
|
$this->ps_versions_compliancy = [
|
|
'min' => '1.6.1',
|
|
'max' => _PS_VERSION_
|
|
];
|
|
$this->bootstrap = true;
|
|
$this->display = 'view';
|
|
|
|
parent::__construct();
|
|
|
|
$this->displayName = $this->l('epaka.pl');
|
|
$this->description = $this->l('Integracja z www.epaka.pl');
|
|
|
|
$this->confirmUninstall = $this->l('Czy na pewno chcesz usunąć?');
|
|
|
|
$this->api = new EpakaApi();
|
|
}
|
|
|
|
public function install()
|
|
{
|
|
return parent::install() && $this->installHooks() && $this->installDB() && $this->setRelationsDB();
|
|
}
|
|
|
|
public function installHooks()
|
|
{
|
|
$return = true;
|
|
|
|
if (!$this->registerHook('actionAdminControllerSetMedia')) {
|
|
$return = false;
|
|
}
|
|
if (!$this->registerHook('displayAdminOrder')) {
|
|
$return = false;
|
|
}
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '<')){
|
|
if (!$this->registerHook('displayFooter')) {
|
|
$return = false;
|
|
}
|
|
}
|
|
if (!$this->registerHook('header')) {
|
|
$return = false;
|
|
}
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '>=')){
|
|
if (!$this->registerHook('displayAfterCarrier')) {
|
|
$return = false;
|
|
}
|
|
} else {
|
|
if (!$this->registerHook('displayCarrierList')) {
|
|
$return = false;
|
|
}
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
public function installDB()
|
|
{
|
|
$return = true;
|
|
|
|
// relacje kurierow
|
|
$return &= EpakaDB::createTable(
|
|
'epaka_carriers_relations',
|
|
array(
|
|
'prestashop_id' => 'INT(11) NOT NULL',
|
|
'epaka_id' => 'INT(11) NOT NULL',
|
|
'epaka_carrier_delivery_type' => 'VARCHAR(3) NULL DEFAULT NULL',
|
|
),
|
|
null,
|
|
'InnoDB'
|
|
);
|
|
|
|
// relacje zamowień w koszyku z kurierami epaki
|
|
$return &= EpakaDB::createTable(
|
|
'epaka_delivery',
|
|
array(
|
|
'id_cart' => 'INT(11) NOT NULL',
|
|
'id_carrier_prestashop' => 'INT(11) NOT NULL',
|
|
'id_carrier_epaka' => 'INT(11) NOT NULL',
|
|
'point_code' => 'VARCHAR(255) NULL DEFAULT NULL',
|
|
'point_name' => 'VARCHAR(255) NULL DEFAULT NULL',
|
|
'id_epaka_order' => 'INT(11) NULL DEFAULT NULL',
|
|
),
|
|
array('id_cart'),
|
|
'InnoDB'
|
|
);
|
|
|
|
EpakaDB::addAdminController('AdminEpaka', $this->name);
|
|
return $return;
|
|
}
|
|
|
|
public function setRelationsDB()
|
|
{
|
|
$return = true;
|
|
|
|
$unfinishedPrestaOrders = EpakaDB::getUnfinishedPrestaOrders();
|
|
|
|
foreach ($unfinishedPrestaOrders as $order) {
|
|
if (!EpakaDB::insertRelation($order['id_cart'], $order['id_carrier'], 0, NULL, NULL, NULL)) {
|
|
$return = false;
|
|
}
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
public function uninstall()
|
|
{
|
|
// Call uninstall parent method
|
|
if (!parent::uninstall()) {
|
|
return false;
|
|
}
|
|
|
|
// Execute module install SQL statements
|
|
if (!$this->uninstallDB()) {
|
|
return false;
|
|
}
|
|
|
|
// Delete configuration values
|
|
// if(!Configuration::deleteByName($this->name)
|
|
if(!Configuration::deleteByName("EPAKA_API_EMAIL")
|
|
|| !Configuration::deleteByName("EPAKA_API_PASSWORD")
|
|
|| !Configuration::deleteByName("EPAKA_API_SESSION")) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function uninstallDB()
|
|
{
|
|
$return = true;
|
|
|
|
// relacje kurierow
|
|
$return &= EpakaDB::dropTable('epaka_carriers_relations');
|
|
|
|
// relacje zamowień w koszyku z kurierami epaki
|
|
$return &= EpakaDB::dropTable('epaka_delivery');
|
|
|
|
// usuwanie rekordow z tabeli konfiguracyjnej presty
|
|
// $return &= EpakaDB::deleteFromTable('configuration', 'name', 'EPAKA_API_EMAIL');
|
|
// $return &= EpakaDB::deleteFromTable('configuration', 'name', 'EPAKA_API_PASSWORD');
|
|
// $return &= EpakaDB::deleteFromTable('configuration', 'name', 'EPAKA_API_SESSION');
|
|
|
|
return $return;
|
|
}
|
|
|
|
public function existsDB()
|
|
{
|
|
$return = true;
|
|
|
|
// relacje kurierow
|
|
$return &= EpakaDB::existsTable('epaka_carriers_relations');
|
|
|
|
// relacje zamowień w koszyku z kurierami epaki
|
|
$return &= EpakaDB::existsTable('epaka_delivery');
|
|
|
|
return $return;
|
|
}
|
|
|
|
public function getContent()
|
|
{
|
|
// $this->setRelationsDB();
|
|
// $this->installHooks();
|
|
if (!$this->existsDB()) {
|
|
$this->installDB();
|
|
}
|
|
|
|
if (!empty($epaka_api_email = Configuration::get('EPAKA_API_EMAIL')) &&
|
|
!empty($epaka_api_password = Configuration::get('EPAKA_API_PASSWORD')) &&
|
|
!empty($epaka_api_session = Configuration::get('EPAKA_API_SESSION'))) {
|
|
$this->api->init($epaka_api_email, $epaka_api_password, $epaka_api_session);
|
|
}
|
|
|
|
$this->postConfiguration();
|
|
$this->viewConfiguration();
|
|
|
|
$view1 = $this->display(__FILE__, '/views/templates/admin/configuration.tpl');
|
|
$view2 = '';
|
|
|
|
if ($this->api->connected()) {
|
|
// add CSS
|
|
$this->context->controller->addCSS($this->_path.'views/css/loading.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/css/map-popup.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/leaflet/leaflet.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/leaflet/MarkerCluster.Default.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/fontawesome-5.15.1/css/fontawesome.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/fontawesome-5.15.1/css/all.css', 'all');
|
|
// add JS
|
|
$this->context->controller->addJS($this->_path.'views/js/leaflet/leaflet.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/leaflet/leaflet.markercluster.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/parseXML.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/fontawesome-5.15.1/js/fontawesome.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/scrollTo/jquery.scrollTo.js', 'all');
|
|
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-map.js', 'all');
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '>=')){
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-front-17.js', 'all');
|
|
} else {
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-front-16.js', 'all');
|
|
}
|
|
|
|
$linkGetMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'getMachinesPoints'));
|
|
Media::addJsDef(array('epakaGetMachinesPointsAjax' => $linkGetMPoints));
|
|
$linkValidateMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'validateMachinePoints'));
|
|
Media::addJsDef(array('epakaValidateMachinesPointsAjax' => $linkValidateMPoints));
|
|
$linkSaveMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'saveMachinePoints'));
|
|
Media::addJsDef(array('epakaSaveMachinesPointsAjax' => $linkSaveMPoints));
|
|
|
|
// Epaka full URL
|
|
Media::addJsDef(array('EPAKA_API_URL_FULL' => EpakaApi::getUrlFull()));
|
|
|
|
// tlumaczajki
|
|
$module = Module::getInstanceByName('epaka');
|
|
$this->context->smarty->assign('translate', (object)[
|
|
'menu' => $this->translateForClient('menu', $module),
|
|
'wybierz_punkt_odbioru' => $this->translateForClient('wybierz_punkt_odbioru', $module),
|
|
'zlokalizuj_mnie' => $this->translateForClient('zlokalizuj_mnie', $module),
|
|
'wyszukaj' => $this->translateForClient('wyszukaj', $module),
|
|
'trwa_wyszukiwanie' => $this->translateForClient('trwa_wyszukiwanie', $module),
|
|
'brak_punktow' => $this->translateForClient('brak_punktow', $module),
|
|
'nie_znaleziono_lokalizacji' => $this->translateForClient('nie_znaleziono_lokalizacji', $module),
|
|
]);
|
|
|
|
$view2 = $this->display(__FILE__,'/views/templates/map-html.tpl');
|
|
}
|
|
|
|
return $view1 . $view2;
|
|
}
|
|
|
|
public function viewConfiguration()
|
|
{
|
|
$epaka_api_email = $this->api->getSessionLogin();
|
|
$epaka_api_password = $this->api->getSessionPassword();
|
|
|
|
$this->context->smarty->assign('EPAKA_API_EMAIL', $epaka_api_email);
|
|
$this->context->smarty->assign('EPAKA_API_PASSWORD', $epaka_api_password);
|
|
|
|
$this->context->smarty->assign('EPAKA_API_STATUS', $this->getConnectionStatus());
|
|
|
|
if ($epaka_api_email && $epaka_api_password) {
|
|
if ( ! ($epaka_api_connected = $this->api->connected())) {
|
|
$epaka_api_connected = $this->api->getApiTokenAuth($epaka_api_email, $epaka_api_password);
|
|
}
|
|
} else {
|
|
$epaka_api_connected = false;
|
|
}
|
|
$this->context->smarty->assign('EPAKA_API_CONNECTED', $epaka_api_connected);
|
|
|
|
|
|
if ($epaka_api_connected) {
|
|
// pobranie danych usera z API
|
|
$userData = $this->api->getApiUserData();
|
|
|
|
$this->context->smarty->assign('EPAKA_INVOICE_NAME', !empty((array)$userData->name) ? $userData->name : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_SURENAME', !empty((array)$userData->lastName) ? $userData->lastName : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_COMPANY', !empty((array)$userData->company) ? $userData->company : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_TIN', !empty((array)$userData->tin) ? $userData->tin : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_CITY', !empty((array)$userData->city) ? $userData->city : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_POSTCODE', !empty((array)$userData->postCode) ? $userData->postCode : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_STREET', !empty((array)$userData->street) ? $userData->street : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_HOUSENUMBER', !empty((array)$userData->houseNumber) ? $userData->houseNumber : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_FLATNUMBER', !empty((array)$userData->flatNumber) ? $userData->flatNumber : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_PHONE', !empty((array)$userData->phone) ? $userData->phone : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_COUNTRY', !empty((array)$userData->country) ? $userData->country : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE_IBAN', !empty((array)$userData->bankAccount) ? $userData->bankAccount : null);
|
|
$this->context->smarty->assign('EPAKA_INVOICE', !empty((array)$userData->invoices) ? $userData->invoices : null);
|
|
|
|
$this->context->smarty->assign('EPAKA_SENDER_NAME', !empty((array)$userData->senderName) ? $userData->senderName : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_SURENAME', !empty((array)$userData->senderLastName) ? $userData->senderLastName : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_COMPANY', !empty((array)$userData->senderCompany) ? $userData->senderCompany : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_CITY', !empty((array)$userData->senderCity) ? $userData->senderCity : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_POSTCODE', !empty((array)$userData->senderPostCode) ? $userData->senderPostCode : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_STREET', !empty((array)$userData->senderStreet) ? $userData->senderStreet : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_HOUSENUMBER', !empty((array)$userData->senderHouseNumber) ? $userData->senderHouseNumber : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_FLATNUMBER', !empty((array)$userData->senderFlatNumber) ? $userData->senderFlatNumber : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_PHONE', !empty((array)$userData->senderPhone) ? $userData->senderPhone : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_COUNTRY', !empty((array)$userData->senderCountry) ? $userData->senderCountry : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PACZKOMAT', !empty((array)$userData->defaultPaczkomat) ? $userData->defaultPaczkomat : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PACZKOMAT_DESCRIPTION', !empty((array)$userData->defaultPaczkomatDescription) ? $userData->defaultPaczkomatDescription : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PWR', !empty((array)$userData->defaultPunktRuchu) ? $userData->defaultPunktRuchu : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PWR_DESCRIPTION', !empty((array)$userData->defaultPunktRuchuDescription) ? $userData->defaultPunktRuchuDescription : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PACZKA48', !empty((array)$userData->defaultPunktPaczka48) ? $userData->defaultPunktPaczka48 : null);
|
|
$this->context->smarty->assign('EPAKA_SENDER_DEFAULT_PACZKA48_DESCRIPTION', !empty((array)$userData->defaultPunktPaczka48Description) ? $userData->defaultPunktPaczka48Description : null);
|
|
|
|
// konfiguracja mapek punktow odbioru
|
|
$carriersPresta = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS);
|
|
$this->context->smarty->assign('carriersPresta', !empty($carriersPresta) ? $carriersPresta : null);
|
|
|
|
$carriersEpaka = $this->api->getCarriersEpaka();
|
|
|
|
$carriersRelations = EpakaDB::getCourriersRelations();
|
|
$carriers = [];
|
|
foreach ($carriersEpaka->couriers as $cE => $cETmp) {
|
|
$carriers[$cE] = [
|
|
'epaka_id' => $cETmp->courierId,
|
|
'epaka_name' => $cETmp->courierName,
|
|
'epaka_source_map_id' => $cETmp->courierMapSourceId,
|
|
'epaka_source_map_name' => $cETmp->courierMapSourceName,
|
|
'epaka_source_map_url' => $cETmp->courierMapSourceUrl,
|
|
];
|
|
foreach ($carriersRelations as $cRTmp) {
|
|
if ($cETmp->courierId == $cRTmp['epaka_id']) {
|
|
$carriers[$cE]['relacje'][] = $cRTmp['prestashop_id'];
|
|
}
|
|
}
|
|
}
|
|
$this->context->smarty->assign('carriers', !empty($carriers) ? $carriers : null);
|
|
|
|
// punkty na mapie
|
|
$sources = [];
|
|
foreach ($carriersEpaka->couriers as $cE => $cETmp) {
|
|
if (!empty((array)$cETmp->courierMapSourceId)) {
|
|
$sources[(int)$cETmp->courierMapSourceId] = (object)[
|
|
'autoClose' => true,
|
|
'sourceName' => $cETmp->courierMapSourceName,
|
|
'sourceUrl' => $cETmp->courierMapSourceUrl,
|
|
'type' => 'point',
|
|
'title' => 'Wybierz punkt nadania',
|
|
'country' => 'PL',
|
|
];
|
|
}
|
|
}
|
|
Media::addJsDef(array('sources' => $sources));
|
|
}
|
|
}
|
|
public function postConfiguration()
|
|
{
|
|
$messages = null;
|
|
|
|
if (Tools::isSubmit('EPAKA_API'))
|
|
{
|
|
$epaka_api_email = strval(Tools::getValue('EPAKA_API_EMAIL'));
|
|
$epaka_api_password = strval(Tools::getValue('EPAKA_API_PASSWORD'));
|
|
|
|
$error = false;
|
|
if (!$epaka_api_email || empty($epaka_api_email) || !Validate::isEmail($epaka_api_email)) {
|
|
$messages .= $this->displayError($this->l('Nieprawidłowy email.'));
|
|
$error = true;
|
|
}
|
|
if (!$epaka_api_password || empty($epaka_api_password) || !Validate::isGenericName($epaka_api_password)) {
|
|
$messages .= $this->displayError($this->l('Nieprawidłowe dane logowania.'));
|
|
$error = true;
|
|
}
|
|
if ( ! ($epaka_api_session = $this->api->getApiTokenAuth($epaka_api_email, $epaka_api_password))) {
|
|
$error = true;
|
|
}
|
|
|
|
if (!$error) {
|
|
Configuration::updateValue('EPAKA_API_EMAIL', $epaka_api_email);
|
|
Configuration::updateValue('EPAKA_API_PASSWORD', $epaka_api_password);
|
|
Configuration::updateValue('EPAKA_API_SESSION', $epaka_api_session);
|
|
|
|
$messages .= $this->displayConfirmation($this->l('Dane dostępowe do API są prawidłowe. Sprawdź dane adresowe i zapisz formularz.'));
|
|
$this->context->smarty->assign('confirmation', 1);
|
|
|
|
} else {
|
|
Configuration::updateValue('EPAKA_API_EMAIL', $epaka_api_email);
|
|
Configuration::updateValue('EPAKA_API_PASSWORD', $epaka_api_password);
|
|
Configuration::updateValue('EPAKA_API_SESSION', null);
|
|
|
|
$messages .= $this->displayError($this->l('Dane dostępowe do API są nieprawidłowe.'));
|
|
$this->context->smarty->assign('confirmation', 0);
|
|
}
|
|
}
|
|
|
|
if ($this->api->connected() && Tools::isSubmit('EPAKA_ADDRESSES'))
|
|
{
|
|
// pobranie danych z Formularza
|
|
$epaka_invoice_name = strval(Tools::getValue('EPAKA_INVOICE_NAME'));
|
|
$epaka_invoice_surname = strval(Tools::getValue('EPAKA_INVOICE_SURENAME'));
|
|
$epaka_invoice_company = strval(Tools::getValue('EPAKA_INVOICE_COMPANY'));
|
|
$epaka_invoice_tin = strval(Tools::getValue('EPAKA_INVOICE_TIN'));
|
|
$epaka_invoice_postcode = strval(Tools::getValue('EPAKA_INVOICE_POSTCODE'));
|
|
$epaka_invoice_city = strval(Tools::getValue('EPAKA_INVOICE_CITY'));
|
|
$epaka_invoice_street = strval(Tools::getValue('EPAKA_INVOICE_STREET'));
|
|
$epaka_invoice_housenumber = strval(Tools::getValue('EPAKA_INVOICE_HOUSENUMBER'));
|
|
$epaka_invoice_flatnumber = strval(Tools::getValue('EPAKA_INVOICE_FLATNUMBER'));
|
|
$epaka_invoice_phone = strval(Tools::getValue('EPAKA_INVOICE_PHONE'));
|
|
$epaka_invoice_country = strval(Tools::getValue('EPAKA_INVOICE_COUNTRY'));
|
|
$epaka_invoice_iban = strval(Tools::getValue('EPAKA_INVOICE_IBAN'));
|
|
$epaka_invoice = strval(Tools::getValue('EPAKA_INVOICE'));
|
|
|
|
$epaka_sender_name = strval(Tools::getValue('EPAKA_SENDER_NAME'));
|
|
$epaka_sender_surname = strval(Tools::getValue('EPAKA_SENDER_SURENAME'));
|
|
$epaka_sender_company = strval(Tools::getValue('EPAKA_SENDER_COMPANY'));
|
|
$epaka_sender_postcode = strval(Tools::getValue('EPAKA_SENDER_POSTCODE'));
|
|
$epaka_sender_city = strval(Tools::getValue('EPAKA_SENDER_CITY'));
|
|
$epaka_sender_street = strval(Tools::getValue('EPAKA_SENDER_STREET'));
|
|
$epaka_sender_housenumber = strval(Tools::getValue('EPAKA_SENDER_HOUSENUMBER'));
|
|
$epaka_sender_flatnumber = strval(Tools::getValue('EPAKA_SENDER_FLATNUMBER'));
|
|
$epaka_sender_phone = strval(Tools::getValue('EPAKA_SENDER_PHONE'));
|
|
$epaka_sender_country = strval(Tools::getValue('EPAKA_SENDER_COUNTRY'));
|
|
$epaka_sender_default_paczkomat = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PACZKOMAT'));
|
|
$epaka_sender_default_paczkomat_description = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PACZKOMAT_DESCRIPTION'));
|
|
$epaka_sender_default_pwr = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PWR'));
|
|
$epaka_sender_default_pwr_description = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PWR_DESCRIPTION'));
|
|
$epaka_sender_default_paczka48 = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PACZKA48'));
|
|
$epaka_sender_default_paczka48_description = strval(Tools::getValue('EPAKA_SENDER_DEFAULT_PACZKA48_DESCRIPTION'));
|
|
|
|
// zapis do API Epaka
|
|
$saveData['email'] = Configuration::get('EPAKA_API_EMAIL');
|
|
$saveData['name'] = $epaka_invoice_name;
|
|
$saveData['lastName'] = $epaka_invoice_surname;
|
|
$saveData['company'] = $epaka_invoice_company;
|
|
$saveData['tin'] = $epaka_invoice_tin;
|
|
$saveData['postCode'] = $epaka_invoice_postcode;
|
|
$saveData['city'] = $epaka_invoice_city;
|
|
$saveData['street'] = $epaka_invoice_street;
|
|
$saveData['houseNumber'] = $epaka_invoice_housenumber;
|
|
$saveData['flatNumber'] = $epaka_invoice_flatnumber;
|
|
$saveData['phone'] = $epaka_invoice_phone;
|
|
$saveData['country'] = $epaka_invoice_country;
|
|
$saveData['bankAccount'] = $epaka_invoice_iban;
|
|
$saveData['invoices'] = intval($epaka_invoice);
|
|
|
|
$saveData['senderName'] = $epaka_sender_name;
|
|
$saveData['senderLastName'] = $epaka_sender_surname;
|
|
$saveData['senderCompany'] = $epaka_sender_company;
|
|
$saveData['senderStreet'] = $epaka_sender_street;
|
|
$saveData['senderHouseNumber'] = $epaka_sender_housenumber;
|
|
$saveData['senderFlatNumber'] = $epaka_sender_flatnumber;
|
|
$saveData['senderPostCode'] = $epaka_sender_postcode;
|
|
$saveData['senderCity'] = $epaka_sender_city;
|
|
$saveData['senderCountry'] = $epaka_sender_country;
|
|
$saveData['senderPhone'] = $epaka_sender_phone;
|
|
$saveData['defaultPaczkomat'] = $epaka_sender_default_paczkomat;
|
|
$saveData['defaultPaczkomatDescription'] = $epaka_sender_default_paczkomat_description;
|
|
$saveData['defaultPunktRuchu'] = $epaka_sender_default_pwr;
|
|
$saveData['defaultPunktRuchuDescription'] = $epaka_sender_default_pwr_description;
|
|
$saveData['defaultPunktPaczka48'] = $epaka_sender_default_paczka48;
|
|
$saveData['defaultPunktPaczka48Description'] = $epaka_sender_default_paczka48_description;
|
|
|
|
$apiResult = $this->api->setApiUserData($saveData);
|
|
|
|
// zapis do DB Prestashopa
|
|
if ($apiResult) {
|
|
Configuration::updateValue('EPAKA_INVOICE_NAME', $epaka_invoice_name);
|
|
Configuration::updateValue('EPAKA_INVOICE_SURENAME', $epaka_invoice_surname);
|
|
Configuration::updateValue('EPAKA_INVOICE_COMPANY', $epaka_invoice_company);
|
|
Configuration::updateValue('EPAKA_INVOICE_POSTCODE', $epaka_invoice_postcode);
|
|
Configuration::updateValue('EPAKA_INVOICE_CITY', $epaka_invoice_city);
|
|
Configuration::updateValue('EPAKA_INVOICE_STREET', $epaka_invoice_street);
|
|
Configuration::updateValue('EPAKA_INVOICE_PHONE', $epaka_invoice_phone);
|
|
Configuration::updateValue('EPAKA_INVOICE_COUNTRY', $epaka_invoice_country);
|
|
Configuration::updateValue('EPAKA_INVOICE_IBAN', $epaka_invoice_iban);
|
|
Configuration::updateValue('EPAKA_INVOICE_TIN', $epaka_invoice_tin);
|
|
Configuration::updateValue('EPAKA_INVOICE_HOUSENUMBER', $epaka_invoice_housenumber);
|
|
Configuration::updateValue('EPAKA_INVOICE_FLATNUMBER', $epaka_invoice_flatnumber);
|
|
Configuration::updateValue('EPAKA_INVOICE', $epaka_invoice);
|
|
|
|
Configuration::updateValue('EPAKA_SENDER_NAME', $epaka_sender_name);
|
|
Configuration::updateValue('EPAKA_SENDER_SURENAME', $epaka_sender_surname);
|
|
Configuration::updateValue('EPAKA_SENDER_COMPANY', $epaka_sender_company);
|
|
Configuration::updateValue('EPAKA_SENDER_POSTCODE', $epaka_sender_postcode);
|
|
Configuration::updateValue('EPAKA_SENDER_CITY', $epaka_sender_city);
|
|
Configuration::updateValue('EPAKA_SENDER_STREET', $epaka_sender_street);
|
|
Configuration::updateValue('EPAKA_SENDER_HOUSENUMBER', $epaka_sender_housenumber);
|
|
Configuration::updateValue('EPAKA_SENDER_FLATNUMBER', $epaka_sender_flatnumber);
|
|
Configuration::updateValue('EPAKA_SENDER_PHONE', $epaka_sender_phone);
|
|
Configuration::updateValue('EPAKA_SENDER_COUNTRY', $epaka_sender_country);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PACZKOMAT', $epaka_sender_default_paczkomat);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PACZKOMAT_DESCRIPTION', $epaka_sender_default_paczkomat_description);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PWR', $epaka_sender_default_pwr);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PWR_DESCRIPTION', $epaka_sender_default_pwr_description);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PACZKA48', $epaka_sender_default_paczka48);
|
|
Configuration::updateValue('EPAKA_SENDER_DEFAULT_PACZKA48_DESCRIPTION', $epaka_sender_default_paczka48_description);
|
|
|
|
$messages .= $this->displayConfirmation($this->l('Dane adresowe zostały zapisane.'));
|
|
$this->context->smarty->assign('confirmation', 1);
|
|
|
|
} else {
|
|
$messages .= $this->displayError($this->l('Wystąpił błąd zapisu do API Epaka.'));
|
|
$this->context->smarty->assign('confirmation', 0);
|
|
}
|
|
}
|
|
|
|
if ($this->api->connected() && Tools::isSubmit('EPAKA_D2P'))
|
|
{
|
|
$carriersEpaka = $this->api->getCarriersEpaka();
|
|
|
|
$carriersPresta = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::ALL_CARRIERS);
|
|
EpakaDB::clearCourriersRelations();
|
|
foreach ($carriersPresta as $cPresta) {
|
|
$cCarrierId = $cPresta['id_carrier'];
|
|
$cInputValues = Tools::getValue('carriers_presta_'.$cCarrierId);
|
|
if ($cInputValues) {
|
|
foreach ($cInputValues as $val) {
|
|
// polaczone z epaka.pl
|
|
if (!empty($val)) {
|
|
EpakaDB::addCourriersRelation($cCarrierId, $val, $carriersEpaka->couriers);
|
|
}
|
|
// NIE polaczone z epaka.pl
|
|
else {
|
|
EpakaDB::addCourriersRelation($cCarrierId, 0, $carriersEpaka->couriers);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->context->smarty->assign('messages', $messages);
|
|
}
|
|
|
|
private function checkConfiguration()
|
|
{
|
|
$dataConnection = !empty(Configuration::get('EPAKA_API_EMAIL')) && !empty(Configuration::get('EPAKA_API_PASSWORD') && !empty(Configuration::get('EPAKA_API_SESSION')));
|
|
if (!$dataConnection) {
|
|
return NULL;
|
|
}
|
|
|
|
if (!$this->api->connected()) {
|
|
$this->api->getApiTokenAuth(Configuration::get('EPAKA_API_EMAIL'), Configuration::get('EPAKA_API_PASSWORD'));
|
|
}
|
|
|
|
return $this->api->connected();
|
|
}
|
|
|
|
private function getConnectionStatus()
|
|
{
|
|
$module = Module::getInstanceByName('epaka');
|
|
|
|
if ($this->checkConfiguration() == NULL) {
|
|
return '<span style="font-weight:bold; color:red; font-size:12px; vertical-align:-8px;">'.$module->l('WPROWADŹ DANE LOGOWANIA').'</span>';
|
|
} elseif ($this->checkConfiguration() == true) {
|
|
return '<span style="font-weight:bold; color:green; font-size:12px; vertical-align:-8px;">'.$module->l('POŁĄCZONO').'</span>';
|
|
} elseif ($this->checkConfiguration() == false) {
|
|
return '<span style="font-weight:bold; color:red; font-size:12px; vertical-align:-8px;">'.$module->l('NIEPRAWIDŁOWY LOGIN LUB HASŁO').'</span>';
|
|
}
|
|
}
|
|
|
|
public function getOrderControllers()
|
|
{
|
|
return array(
|
|
'supercheckout',
|
|
'orderopc',
|
|
'order'
|
|
);
|
|
}
|
|
|
|
public function hookHeader()
|
|
{
|
|
if (!isset($_GET['controller']) || !in_array($_GET['controller'], $this->getOrderControllers())) {
|
|
return;
|
|
}
|
|
|
|
if (!empty($epaka_api_email = Configuration::get('EPAKA_API_EMAIL')) &&
|
|
!empty($epaka_api_password = Configuration::get('EPAKA_API_PASSWORD')) &&
|
|
!empty($epaka_api_session = Configuration::get('EPAKA_API_SESSION'))) {
|
|
$this->api->init($epaka_api_email, $epaka_api_password, $epaka_api_session);
|
|
}
|
|
|
|
if ($this->api->connected()) {
|
|
// add CSS
|
|
$this->context->controller->addCSS($this->_path.'views/css/loading.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/css/map-popup.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/leaflet/leaflet.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/leaflet/MarkerCluster.Default.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/fontawesome-5.15.1/css/fontawesome.css', 'all');
|
|
$this->context->controller->addCSS($this->_path.'views/js/fontawesome-5.15.1/css/all.css', 'all');
|
|
// add JS
|
|
$this->context->controller->addJS($this->_path.'views/js/leaflet/leaflet.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/leaflet/leaflet.markercluster.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/parseXML.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/fontawesome-5.15.1/js/fontawesome.js', 'all');
|
|
$this->context->controller->addJS($this->_path.'views/js/scrollTo/jquery.scrollTo.js', 'all');
|
|
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-map.js', 'all');
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '>=')){
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-front-17.js', 'all');
|
|
} else {
|
|
$this->context->controller->addJS($this->_path.'views/js/front/epaka-front-16.js', 'all');
|
|
}
|
|
|
|
$linkGetMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'getMachinesPoints'));
|
|
Media::addJsDef(array('epakaGetMachinesPointsAjax' => $linkGetMPoints));
|
|
$linkValidateMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'validateMachinePoints'));
|
|
Media::addJsDef(array('epakaValidateMachinesPointsAjax' => $linkValidateMPoints));
|
|
$linkSaveMPoints = $this->context->link->getModuleLink('epaka','map',array('ajax' => 1, 'action' => 'saveMachinePoints'));
|
|
Media::addJsDef(array('epakaSaveMachinesPointsAjax' => $linkSaveMPoints));
|
|
|
|
// punkty na mapie
|
|
$sources = [];
|
|
$carriersEpaka = $this->api->getCarriersEpaka();
|
|
foreach ($carriersEpaka->couriers as $cE => $cETmp) {
|
|
if (!empty((array)$cETmp->courierMapSourceId)) {
|
|
$sources[(int)$cETmp->courierMapSourceId] = (object)[
|
|
'autoClose' => true,
|
|
'sourceName' => $cETmp->courierMapSourceName,
|
|
'sourceUrl' => $cETmp->courierMapSourceUrl,
|
|
'type' => 'point',
|
|
'title' => 'Wybierz punkt nadania',
|
|
'country' => 'PL',
|
|
];
|
|
}
|
|
}
|
|
Media::addJsDef(array('sources' => $sources));
|
|
|
|
// cart ID
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '<')){
|
|
$carriersRelations = EpakaDB::getCourriersRelations((int)$this->context->cart->id_carrier);
|
|
Media::addJsDef(array('carriers_relations' => (object)[
|
|
'presta_carrier_id' => $this->context->cart->id_carrier,
|
|
'epaka_carrier_id' => ($carriersRelations) ? (int)$carriersRelations[0]['epaka_id'] : 0,
|
|
]));
|
|
}
|
|
|
|
// Epaka full URL
|
|
Media::addJsDef(array('EPAKA_API_URL_FULL' => EpakaApi::getUrlFull()));
|
|
}
|
|
}
|
|
|
|
public function hookDisplayCarrierList($params)
|
|
{
|
|
return $this->hookDisplayAfterCarrier($params);
|
|
}
|
|
|
|
public function hookDisplayAfterCarrier($params)
|
|
{
|
|
if (!empty($epaka_api_email = Configuration::get('EPAKA_API_EMAIL')) &&
|
|
!empty($epaka_api_password = Configuration::get('EPAKA_API_PASSWORD')) &&
|
|
!empty($epaka_api_session = Configuration::get('EPAKA_API_SESSION'))) {
|
|
$this->api->init($epaka_api_email, $epaka_api_password, $epaka_api_session);
|
|
}
|
|
|
|
$view1 = '';
|
|
$view2 = '';
|
|
|
|
if ($this->api->connected()) {
|
|
$idAddress = $this->context->cart->id_address_delivery;
|
|
$address = new Address($idAddress);
|
|
|
|
$basketCartDelivery = EpakaDB::getBasketDelivery($this->context->cart->id);
|
|
|
|
$carriersRelations = EpakaDB::getCourriersRelations();
|
|
$ep4kaCarriersOnPresta = [];
|
|
foreach ($carriersRelations as $itemTmp) {
|
|
if ($itemTmp['epaka_carrier_delivery_type'] == "p2p") {
|
|
if (!array_key_exists($itemTmp['prestashop_id'], $ep4kaCarriersOnPresta)) {
|
|
$ep4kaCarriersOnPresta['p2p'][$itemTmp['prestashop_id']] = $itemTmp['epaka_id'];
|
|
} else {
|
|
$ep4kaCarriersOnPresta['p2p'][$itemTmp['prestashop_id']] .= ','.$itemTmp['epaka_id'];
|
|
}
|
|
} elseif ($itemTmp['epaka_carrier_delivery_type'] == "d2d") {
|
|
if (!array_key_exists($itemTmp['prestashop_id'], $ep4kaCarriersOnPresta)) {
|
|
$ep4kaCarriersOnPresta['d2d'][$itemTmp['prestashop_id']] = $itemTmp['epaka_id'];
|
|
} else {
|
|
$ep4kaCarriersOnPresta['d2d'][$itemTmp['prestashop_id']] .= ','.$itemTmp['epaka_id'];
|
|
}
|
|
} elseif ($itemTmp['epaka_carrier_delivery_type'] == "onp") {
|
|
if (!array_key_exists($itemTmp['prestashop_id'], $ep4kaCarriersOnPresta)) {
|
|
$ep4kaCarriersOnPresta['onp'][$itemTmp['prestashop_id']] = $itemTmp['epaka_id'];
|
|
} else {
|
|
$ep4kaCarriersOnPresta['onp'][$itemTmp['prestashop_id']] .= ','.$itemTmp['epaka_id'];
|
|
}
|
|
}
|
|
}
|
|
$this->context->smarty->assign('ep4kaCarriersOnPresta', $ep4kaCarriersOnPresta);
|
|
|
|
$pointName = '';
|
|
$carrierPrestaId = '';
|
|
if(!empty($basketCartDelivery)){
|
|
$pointName = $basketCartDelivery['point_name'];
|
|
$carrierPrestaId = $basketCartDelivery['id_carrier_prestashop'];
|
|
}
|
|
$this->context->smarty->assign('pointName', $pointName);
|
|
$this->context->smarty->assign('carrierPrestaId', $carrierPrestaId);
|
|
|
|
// widoki + tlumaczenia
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '>=')){
|
|
$this->context->smarty->assign('presta_version',17);
|
|
// translate
|
|
$module = Module::getInstanceByName('epaka');
|
|
$this->context->smarty->assign('translate', (object)[
|
|
'menu' => $this->translateForClient('menu', $module),
|
|
'wybierz_punkt_odbioru' => $this->translateForClient('wybierz_punkt_odbioru', $module),
|
|
'zlokalizuj_mnie' => $this->translateForClient('zlokalizuj_mnie', $module),
|
|
'wyszukaj' => $this->translateForClient('wyszukaj', $module),
|
|
'trwa_wyszukiwanie' => $this->translateForClient('trwa_wyszukiwanie', $module),
|
|
'brak_punktow' => $this->translateForClient('brak_punktow', $module),
|
|
'nie_znaleziono_lokalizacji' => $this->translateForClient('nie_znaleziono_lokalizacji', $module),
|
|
]);
|
|
// view
|
|
$view1 = $this->display(__FILE__, 'views/templates/front/map-popup.tpl');
|
|
$view2 = $this->display(__FILE__,'/views/templates/map-html.tpl');
|
|
} else {
|
|
$this->context->smarty->assign('presta_version',16);
|
|
// translate
|
|
$module = Module::getInstanceByName('epaka');
|
|
$this->context->smarty->assign('translate', (object)[
|
|
'wybierz_punkt_odbioru' => $this->translateForClient('wybierz_punkt_odbioru', $module),
|
|
]);
|
|
// view
|
|
$view1 = $this->display(__FILE__, 'views/templates/front/map-popup.tpl');
|
|
}
|
|
}
|
|
return $view1 . $view2;
|
|
}
|
|
|
|
public function hookActionAdminControllerSetMedia($params)
|
|
{
|
|
$this->context->controller->addJS($this->_path.'views/js/admin/epaka-admin.js', 'all');
|
|
}
|
|
|
|
public function hookDisplayAdminOrder($params)
|
|
{
|
|
if (!empty($epaka_api_email = Configuration::get('EPAKA_API_EMAIL')) &&
|
|
!empty($epaka_api_password = Configuration::get('EPAKA_API_PASSWORD')) &&
|
|
!empty($epaka_api_session = Configuration::get('EPAKA_API_SESSION'))) {
|
|
$this->api->init($epaka_api_email, $epaka_api_password, $epaka_api_session);
|
|
}
|
|
|
|
if ($this->api->connected()) {
|
|
if (!function_exists('array_key_first')) {
|
|
function array_key_first(array $arr) {
|
|
foreach($arr as $key => $unused) {
|
|
return $key;
|
|
}
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
$prestaOrder = new Order((int)$params['id_order']);
|
|
$prestaProducts = $prestaOrder->getProducts();
|
|
$prestaProductFirst = new Product($prestaProducts[array_key_first($prestaProducts)]['product_id'], true, $this->context->language->id, $this->context->shop->id);
|
|
$prestaAddressDelivery = new Address((int)$prestaOrder->id_address_delivery);
|
|
$prestaCustomer = new Customer((int)$prestaOrder->id_customer);
|
|
$prestaAddressDelivery->email = $prestaCustomer->email;
|
|
$epakaOrder = new EpakaOrder();
|
|
$prestaAddressDelivery->prepared_address = $epakaOrder->prepareAddress($prestaAddressDelivery->address1 . ' ' . $prestaAddressDelivery->address2);
|
|
$carrierReference = EpakaDB::checkIfIsOrderReferenceIsOK((int)$prestaOrder->id_cart, (int)$prestaOrder->id_carrier);
|
|
$epakaOrderDetails = $epakaOrder->getOrderDetails((int)$carrierReference['id_epaka_order']);
|
|
$epakaOrderPaymentCheck = $epakaOrder->getOrderPayment((int)$carrierReference['id_epaka_order'], 'check');
|
|
$epakaOrderPaymentGet = $epakaOrder->getOrderPayment((int)$carrierReference['id_epaka_order'], 'get');
|
|
|
|
$linkHtml = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=getEpakaOrderHtml&id_order='.(int)$prestaOrder->id;
|
|
$linkIframe = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=getEpakaOrderIframe&id_order='.(int)$prestaOrder->id;
|
|
$linkSendOrder = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=sendOrder&id_order='.(int)$prestaOrder->id;
|
|
$linkChangeOrderState = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=changeOrderState&id_order='.(int)$prestaOrder->id;
|
|
$linkOrderLabel = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=getOrderLabel&id_order='.(int)$prestaOrder->id;
|
|
$linkOrderProtocol = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=getOrderProtocol&id_order='.(int)$prestaOrder->id;
|
|
$linkOrderCancel = $this->context->link->getAdminLink('AdminEpaka',true).'&ajax=1&action=getOrderCancel&id_order='.(int)$prestaOrder->id;
|
|
$linkOrderTraking = EpakaApi::getUrlFull().'sledzenie-przesylek/'.$carrierReference['id_epaka_order'];
|
|
|
|
$this->context->smarty->assign(array(
|
|
'api_session' => $this->api->getSessionToken(),
|
|
'order_presta' => $prestaOrder,
|
|
'order_presta_product_first' => $prestaProductFirst,
|
|
'order_epaka' => $epakaOrderDetails,
|
|
'order_epaka_payment_check' => $epakaOrderPaymentCheck,
|
|
'order_epaka_payment_get' => $epakaOrderPaymentGet,
|
|
'carrier_reference' => $carrierReference,
|
|
'address_delivery' => $prestaAddressDelivery,
|
|
'url_html' => $linkHtml,
|
|
'url_iframe' => $linkIframe,
|
|
'url_sender' => $linkSendOrder,
|
|
'url_change_order_state' => $linkChangeOrderState,
|
|
'url_label' => $linkOrderLabel,
|
|
'url_protocol' => $linkOrderProtocol,
|
|
'url_cancel_order' => $linkOrderCancel,
|
|
'url_order_traking' => $linkOrderTraking,
|
|
));
|
|
|
|
if (Tools::version_compare(_PS_VERSION_, '1.7', '<')) {
|
|
return $this->display(__FILE__,'/views/templates/admin/order-admin-16.tpl');
|
|
}
|
|
return $this->display(__FILE__,'/views/templates/admin/order-admin-17.tpl');
|
|
}
|
|
// return null;
|
|
}
|
|
|
|
public function hookDisplayFooter($params)
|
|
{
|
|
if (!empty($epaka_api_email = Configuration::get('EPAKA_API_EMAIL')) &&
|
|
!empty($epaka_api_password = Configuration::get('EPAKA_API_PASSWORD')) &&
|
|
!empty($epaka_api_session = Configuration::get('EPAKA_API_SESSION'))) {
|
|
$this->api->init($epaka_api_email, $epaka_api_password, $epaka_api_session);
|
|
}
|
|
|
|
// translate
|
|
if ($this->api->connected()) {
|
|
$module = Module::getInstanceByName('epaka');
|
|
$this->context->smarty->assign('translate', (object)[
|
|
'menu' => $this->translateForClient('menu', $module),
|
|
'wybierz_punkt_odbioru' => $this->translateForClient('wybierz_punkt_odbioru', $module),
|
|
'zlokalizuj_mnie' => $this->translateForClient('zlokalizuj_mnie', $module),
|
|
'wyszukaj' => $this->translateForClient('wyszukaj', $module),
|
|
'trwa_wyszukiwanie' => $this->translateForClient('trwa_wyszukiwanie', $module),
|
|
'brak_punktow' => $this->translateForClient('brak_punktow', $module),
|
|
'nie_znaleziono_lokalizacji' => $this->translateForClient('nie_znaleziono_lokalizacji', $module),
|
|
]);
|
|
|
|
return $this->display(__FILE__,'/views/templates/map-html.tpl');
|
|
}
|
|
// return null;
|
|
}
|
|
|
|
public function translateForClient($sentence, $module) {
|
|
switch ($sentence) {
|
|
case "menu":
|
|
$transentence = $module->l('Menu');
|
|
break;
|
|
case "wybierz_punkt_odbioru":
|
|
$transentence = $module->l('Wybierz punkt odbioru');
|
|
break;
|
|
case "zlokalizuj_mnie":
|
|
$transentence = $module->l('Zlokalizuj mnie');
|
|
break;
|
|
case "wyszukaj":
|
|
$transentence = $module->l('Wyszukaj lub wybierz lokalizację<br />aby wyświetlić listę punktów');
|
|
break;
|
|
case "trwa_wyszukiwanie":
|
|
$transentence = $module->l('Trwa wyszukiwanie punktów, proszę czekać...');
|
|
break;
|
|
case "brak_punktow":
|
|
$transentence = $module->l('Brak punktów w wybranym obszarze. Zmień obszar lub zmniejsz przybliżenie mapy.');
|
|
break;
|
|
case "nie_znaleziono_lokalizacji":
|
|
$transentence = $module->l('Nie znaleziono wybranej lokalizacji');
|
|
break;
|
|
}
|
|
return $transentence;
|
|
}
|
|
|
|
public function prf($data)
|
|
{
|
|
echo'<pre>';
|
|
var_dump($data);
|
|
echo'</pre>';
|
|
}
|
|
} |