From cbd44d167a5a8dd239a9ca056e38e9822ee243be Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 13 Jul 2024 14:46:58 +0200 Subject: [PATCH] rework paketmarke contact fields --- www/lib/class.versanddienstleister.php | 32 ++++++++++++++---- .../versandarten/content/createshipment.tpl | 33 ++++++++++--------- www/lib/versandarten/dhl.php | 28 +++++++++++++++- www/lib/versandarten/sendcloud.php | 33 +++++++++++++++++-- 4 files changed, 99 insertions(+), 27 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index c0fc16a6..921eccf6 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -68,6 +68,9 @@ abstract class Versanddienstleister $auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1"); if ($sid === 'rechnung' || $sid === 'lieferschein' || $sid === 'adresse') { + + $ret['addresstype'] = 0; // 0 = firma, 1 = packstation, 2 = postfiliale, 3 = privatadresse + $docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $id LIMIT 1"); $ret['addressId'] = $docArr['adresse']; $ret['auftragId'] = $auftragId; @@ -79,12 +82,28 @@ abstract class Versanddienstleister $ret['original'] = array_filter($docArr, fn($key) => in_array($key, $addressfields), ARRAY_FILTER_USE_KEY); - $ret['name'] = empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : trim($docArr['ansprechpartner']); - $ret['name2'] = !empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : ''; - $ret['name3'] = join(';', array_filter([ - $docArr['abteilung'], - $docArr['unterabteilung'] - ], fn(string $item) => !empty(trim($item)))); + if ($docArr['typ'] == "firma") { + $ret['company_name'] = $docArr['name']; + $ret['addresstype'] = 0; + } else { + $ret['addresstype'] = 3; + } + + $ret['contact_name'] = $docArr['ansprechpartner']; + + $ret['company_division'] = join( + ';', + array_filter( + [ + $docArr['abteilung'], + $docArr['unterabteilung'] + ], + fn(string $item) => !empty(trim($item)) + ) + ); + + $ret['name'] = $docArr['name']; + $ret['address2'] = $docArr['adresszusatz']; $ret['city'] = $docArr['ort']; @@ -92,7 +111,6 @@ abstract class Versanddienstleister $ret['country'] = $docArr['land']; $ret['phone'] = $docArr['telefon']; $ret['email'] = $docArr['email']; - $ret['addresstype'] = 0; $strasse = trim($docArr['strasse']); $ret['streetwithnumber'] = $strasse; diff --git a/www/lib/versandarten/content/createshipment.tpl b/www/lib/versandarten/content/createshipment.tpl index d524c75f..db8e88da 100644 --- a/www/lib/versandarten/content/createshipment.tpl +++ b/www/lib/versandarten/content/createshipment.tpl @@ -18,29 +18,34 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Adresstyp|}: - - {|Name / Zeile 1|}: - + + {|Firma|}: + - {|Firmenname / Zeile 2|}: - + {|Abteilung|}: + + + + {|Name|}: + + + + {|Ansprechpartner|}: + {|Postnummer|}: - - {|Firmenname / Zeile 3|}: - - - + {|Strasse/Hausnummer|}: @@ -55,7 +60,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Postfilialnummer|}: - + {|Adresszeile 2|}: @@ -77,10 +82,6 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 - - {|Ansprechpartner|}: - - {|E-Mail|}: diff --git a/www/lib/versandarten/dhl.php b/www/lib/versandarten/dhl.php index ad065d86..9ed5e7ee 100644 --- a/www/lib/versandarten/dhl.php +++ b/www/lib/versandarten/dhl.php @@ -102,7 +102,19 @@ class Versandart_dhl extends Versanddienstleister{ switch ($json->addresstype) { case 0: $shipment->Receiver->Address = new ReceiverNativeAddress(); - $shipment->Receiver->Address->name2 = $json->name2; + + $shipment->Receiver->name1 = $json->company_name; + $shipment->Receiver->Address->name2 = join( + ';', + array_filter( + [ + $json->contact_name, + $json->company_division + ], + fn(string $item) => !empty(trim($item)) + ) + ); + $shipment->Receiver->Address->streetName = $json->street ?? ''; $shipment->Receiver->Address->streetNumber = $json->streetnumber; $shipment->Receiver->Address->city = $json->city ?? ''; @@ -127,6 +139,20 @@ class Versandart_dhl extends Versanddienstleister{ $shipment->Receiver->Postfiliale->zip = $json->zip ?? ''; $shipment->Receiver->Postfiliale->Origin = Country::Create($json->country ?? 'DE', $json->state); break; + case 3: + $shipment->Receiver->Address = new ReceiverNativeAddress(); + + $shipment->Receiver->name1 = $json->name; + $shipment->Receiver->Address->name2 = $json->contact_name; + + $shipment->Receiver->Address->streetName = $json->street ?? ''; + $shipment->Receiver->Address->streetNumber = $json->streetnumber; + $shipment->Receiver->Address->city = $json->city ?? ''; + $shipment->Receiver->Address->zip = $json->zip ?? ''; + $shipment->Receiver->Address->Origin = Country::Create($json->country ?? 'DE', $json->state); + if (isset($json->address2) && !empty($json->address2)) + $shipment->Receiver->Address->addressAddition[] = $json->address2; + break; } $shipment->Receiver->Communication = new Communication(); $shipment->Receiver->Communication->email = $json->email; diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index cdda1cce..172a3116 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -82,8 +82,18 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->ShippingMethodId = $json->product; $parcel->Name = $json->name; switch ($json->addresstype) { - case 0: - $parcel->CompanyName = trim("$json->name2 $json->name3"); + case 0: + $parcel->CompanyName = $json->company_name; + $parcel->Name = join( + ';', + array_filter( + [ + $json->contact_name, + $json->company_division + ], + fn(string $item) => !empty(trim($item)) + ) + ); $parcel->Address = $json->street; $parcel->Address2 = $json->address2; $parcel->HouseNumber = $json->streetnumber; @@ -98,6 +108,23 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->Address = "Postfiliale"; $parcel->HouseNumber = $json->postofficeNumber; break; + case 3: + $parcel->Name = join( + ';', + array_filter( + [ + $json->name, + $json->contact_name + ], + fn(string $item) => !empty(trim($item)) + ) + ); + + $parcel->Address = $json->street; + $parcel->Address2 = $json->address2; + $parcel->HouseNumber = $json->streetnumber; + break; + } $parcel->Country = $json->country; $parcel->PostalCode = $json->zip; @@ -164,4 +191,4 @@ class Versandart_sendcloud extends Versanddienstleister } -} \ No newline at end of file +}