Files
2024-10-25 14:16:28 +02:00

108 lines
4.3 KiB
PHP

<?php
/**
* 2007-2019 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-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
*/
include (dirname(__file__) . '/../../../../config/config.inc.php');
include (dirname(__file__) . '/../../../../init.php');
const CHARSET = 'UTF-8';
const REPLACE_FLAGS = ENT_COMPAT;
$geistoken = Tools::getValue('geistoken');
if ($geistoken == 'GeisLogistic') {
$apicode = Configuration::get('GEISLOGISTIC_CODE'); // CustomerCode
$apikey = Configuration::get('GEISLOGISTIC_API'); //Password
$format = Configuration::get('GEISLOGISTIC_FORMAT');
if($format == '3' || $format == '4') {$resolution = Configuration::get('GEISLOGISTIC_RESOLUTION');}else{$resolution = '';}
$trackingnumber = Tools::getValue('trackingnumber');
$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';
}
}
ini_set("soap.wsdl_cache_enabled", "0");
try
{
$client = new SoapClient($wsdl, array("trace" => 1));
$data['Request']['Header'] = array(
'CustomerCode' => $apicode,
'Language' => $country,
'Password' => $apikey,
);
$data['Request']['RequestObject'] = array(
'DistributionChannel' => Configuration::get('GEISLOGISTIC_CHANNEL'),
'Format' => $format,
'Position' => '1',
'Resolution' => $resolution,
);
$data['Request']['RequestObject']['ShipmentNumbers']['LabelItem']['ShipmentNumber'] = $trackingnumber;
$result = $client->GetLabel($data);
}
catch (exception $ex)
{
print "BLAD: .$ex->faultcode .$ex->faultstring. \n\n";
}
if ($result->GetLabelResult->ErrorCode != '0000' ){
print_r($result->GetLabelResult->ErrorMessage);
}else{
$nr = $result->GetLabelResult->ResponseObject->LabelData->LabelItemData->Data;
header('Content-type: application/pdf');
if($format == '1' || $format == '5') {
header('Content-Disposition: attachment; filename="etykieta.pdf"');
}
if($format == '2') {
header('Content-Disposition: attachment; filename="etykieta.epl"');
}
if($format == '3') {
header('Content-Disposition: attachment; filename="etykieta.zpl"');
}
if($format == '4') {
header('Content-Disposition: attachment; filename="etykieta.bmp"');
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
print_r($nr);
}
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
print "\n\n <a href='$url'>Powrót</a>";
}else{
die();
}