From 153580eb17686dafc926029af6409deff8e9abef Mon Sep 17 00:00:00 2001 From: Marijus Kundelis Date: Wed, 15 May 2024 11:06:53 +0300 Subject: [PATCH 1/4] Fix locations filter by type and adapt to PHP 5.6 --- CHANGELOG.md | 4 ++++ src/Locations/PickupPoints.php | 2 +- src/Shipment/CallCourier.php | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc84ad2..6efa1de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [Unreleased] +- fixed filtering of locations by type +- adapted to work with PHP 5.6 + ## [1.0.17] - Improvements - added error message when receiving a "401 Unauthorized" error - added debug to all functions in Request class diff --git a/src/Locations/PickupPoints.php b/src/Locations/PickupPoints.php index 22ccc10..454b143 100644 --- a/src/Locations/PickupPoints.php +++ b/src/Locations/PickupPoints.php @@ -57,7 +57,7 @@ public function getFilteredLocations($country = '', $type = '', $county = '') $filters = []; if($country) $filters['A0_NAME'] = $country; - if($type) + if($type !== '') $filters['TYPE'] = $type; if($county) $filters['A1_NAME'] = $county; diff --git a/src/Shipment/CallCourier.php b/src/Shipment/CallCourier.php index da6af5a..0ddc7a6 100644 --- a/src/Shipment/CallCourier.php +++ b/src/Shipment/CallCourier.php @@ -120,6 +120,7 @@ private function buildXml() $pickDay = date('Y-m-d', strtotime($pickDay . "+1 days")); } $shop_address = $this->sender->getAddress(); + $shop_phone = (! empty($this->sender->getPhone())) ? $this->sender->getPhone() : $this->sender->getMobile(); $serviceCode = $this->getServiceCode(); $xml = ' @@ -132,17 +133,17 @@ private function buildXml() ' . $this->sender->getPersonName() . ' - ' . ($this->sender->getPhone() ?? $this->sender->getMobile()) . ' + ' . $shop_phone . '
' . $this->sender->getPersonName() . ' - ' . ($this->sender->getPhone() ?? $this->sender->getMobile()) . ' + ' . $shop_phone . '
' . $this->sender->getPersonName() . ' - ' . ($this->sender->getPhone() ?? $this->sender->getMobile()) . ' + ' . $shop_phone . '
From 4114ac83a18e1ba8ca8e1ea4eb693e7f21380e61 Mon Sep 17 00:00:00 2001 From: Marijus Kundelis Date: Wed, 29 May 2024 10:46:20 +0300 Subject: [PATCH 2/4] Fix barcode for TCPDF 6.7.5 --- src/Shipment/Manifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shipment/Manifest.php b/src/Shipment/Manifest.php index 48eb941..890c5c4 100644 --- a/src/Shipment/Manifest.php +++ b/src/Shipment/Manifest.php @@ -134,7 +134,7 @@ public function downloadManifest($mode = 'I', $name = 'Omniva manifest') { $count++; $cell_shipment_number = '' . $order->getTracking() . ''; if ($this->show_barcode) { - $cell_shipment_number = ''; + $cell_shipment_number = ''; } $order_table .= ' ' . $count . '. From 1f892c833fa0b6e08f00a528f37f960ccc5da056 Mon Sep 17 00:00:00 2001 From: Marijus Kundelis Date: Mon, 17 Jun 2024 16:21:48 +0300 Subject: [PATCH 3/4] Fix barcode show when use TCPDF 6.7.4+ --- CHANGELOG.md | 1 + overrides/tcpdf/tcpdf_config.php | 1 + src/Shipment/Manifest.php | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6efa1de..5af85b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## [Unreleased] - fixed filtering of locations by type - adapted to work with PHP 5.6 +- fixed the barcode show when using TCPDF library version 6.7.4 or newer ## [1.0.17] - Improvements - added error message when receiving a "401 Unauthorized" error diff --git a/overrides/tcpdf/tcpdf_config.php b/overrides/tcpdf/tcpdf_config.php index 5c2f263..6c6c111 100644 --- a/overrides/tcpdf/tcpdf_config.php +++ b/overrides/tcpdf/tcpdf_config.php @@ -4,3 +4,4 @@ /* Allow generate barcode image */ define('K_TCPDF_CALLS_IN_HTML', true); +define('K_ALLOWED_TCPDF_TAGS', '|write1DBarcode|'); diff --git a/src/Shipment/Manifest.php b/src/Shipment/Manifest.php index 890c5c4..b1c8258 100644 --- a/src/Shipment/Manifest.php +++ b/src/Shipment/Manifest.php @@ -133,8 +133,12 @@ public function downloadManifest($mode = 'I', $name = 'Omniva manifest') { foreach ($this->orders as $order) { $count++; $cell_shipment_number = '' . $order->getTracking() . ''; - if ($this->show_barcode) { - $cell_shipment_number = ''; + if ($this->show_barcode && defined('K_TCPDF_CALLS_IN_HTML') && K_TCPDF_CALLS_IN_HTML === true) { + if (method_exists($pdf, 'serializeTCPDFtagParameters')) { + $cell_shipment_number = ''; + } elseif (method_exists($pdf, 'serializeTCPDFtag')) { + $cell_shipment_number = ''; + } } $order_table .= ' ' . $count . '. From f253b1a8aa13ca7aefca73d7176001f941617fa7 Mon Sep 17 00:00:00 2001 From: Marijus Kundelis Date: Mon, 17 Jun 2024 16:39:38 +0300 Subject: [PATCH 4/4] Release v1.0.18 --- CHANGELOG.md | 2 +- README.md | 6 +++--- composer.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af85b0..9af9844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## [Unreleased] +## [1.0.18] - Fixes - fixed filtering of locations by type - adapted to work with PHP 5.6 - fixed the barcode show when using TCPDF library version 6.7.4 or newer diff --git a/README.md b/README.md index 81a6d7a..e67169c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Omniva API library, to help to integrate with other systems - List parcel terminals. ## Requirements -- Minimum PHP 7.0, tested up to PHP 7.4 +- Minimum PHP 5.6, tested up to PHP 7.4 ## Instalation @@ -59,7 +59,7 @@ Use `example/config.php` to enter your API username and password for testing the //new shipment package object, required $package = new Package(); $package - ->setId('54155454') //id number, optional + ->setId('5454') //id number, optional. Use same ID for several Package if want use multiparcels service ->setService('QH'); //service code of package //create additional services and add to package, optional @@ -82,7 +82,7 @@ Use `example/config.php` to enter your API username and password for testing the ->setAmount(66.72) //set cod amount ->setBankAccount('GB33BUKB20201555555555') //set bank account ->setReceiverName('Test Company') //set company name - ->setReferenceNumber('23232323232323'); //set reference number of cod + ->setReferenceNumber('2323'); //set reference number of COD. For Estonia the number is generated according to Method 7-3-1 (https://www.pangaliit.ee/arveldused/viitenumber/7-3-1meetod) $package->setCod($cod); //assign cod to package //set sender and reeiver address diff --git a/composer.json b/composer.json index d438515..0989e88 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mijora/omniva-api", "description": "Omniva API wrapper", "type": "library", - "version": "1.0.17", + "version": "1.0.18", "authors": [ { "name": "Modestas",