From cd93d643f89fd5dce17ee50b146138ce3d3c5e08 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 21 Oct 2022 10:46:09 +0200 Subject: [PATCH 01/16] Basic Sendcloud integration with Shipment rework --- classes/Carrier/SendCloud/Data/Document.php | 25 + classes/Carrier/SendCloud/Data/ParcelBase.php | 36 + .../Carrier/SendCloud/Data/ParcelCreation.php | 41 + .../SendCloud/Data/ParcelCreationError.php | 10 + classes/Carrier/SendCloud/Data/ParcelItem.php | 51 + .../Carrier/SendCloud/Data/ParcelResponse.php | 76 ++ .../Carrier/SendCloud/Data/SenderAddress.php | 52 + .../Carrier/SendCloud/Data/ShippingMethod.php | 28 + .../SendCloud/Data/ShippingProduct.php | 28 + classes/Carrier/SendCloud/SendCloudApi.php | 124 ++ .../www/js/shipping_method_create.js | 35 +- www/lib/class.erpapi.php | 626 ++++------ www/lib/class.versanddienstleister.php | 112 +- .../content/versandarten_sendcloud.tpl | 130 +- www/lib/versandarten/{dhl.php => dhl.php_} | 0 .../{dhlversenden.php => dhlversenden.php_} | 0 .../{internetmarke.php => internetmarke.php_} | 0 .../{parcelone.php => parcelone.php_} | 0 www/lib/versandarten/sendcloud.php | 151 +++ .../{sonstiges.php => sonstiges.php_} | 0 www/pages/content/versandarten_edit.tpl | 120 +- www/pages/content/versandarten_neu.tpl | 9 +- www/pages/lieferschein.php | 36 +- www/pages/versandarten.php | 1058 +++++------------ 24 files changed, 1358 insertions(+), 1390 deletions(-) create mode 100644 classes/Carrier/SendCloud/Data/Document.php create mode 100644 classes/Carrier/SendCloud/Data/ParcelBase.php create mode 100644 classes/Carrier/SendCloud/Data/ParcelCreation.php create mode 100644 classes/Carrier/SendCloud/Data/ParcelCreationError.php create mode 100644 classes/Carrier/SendCloud/Data/ParcelItem.php create mode 100644 classes/Carrier/SendCloud/Data/ParcelResponse.php create mode 100644 classes/Carrier/SendCloud/Data/SenderAddress.php create mode 100644 classes/Carrier/SendCloud/Data/ShippingMethod.php create mode 100644 classes/Carrier/SendCloud/Data/ShippingProduct.php create mode 100644 classes/Carrier/SendCloud/SendCloudApi.php rename www/lib/versandarten/{dhl.php => dhl.php_} (100%) rename www/lib/versandarten/{dhlversenden.php => dhlversenden.php_} (100%) rename www/lib/versandarten/{internetmarke.php => internetmarke.php_} (100%) rename www/lib/versandarten/{parcelone.php => parcelone.php_} (100%) create mode 100644 www/lib/versandarten/sendcloud.php rename www/lib/versandarten/{sonstiges.php => sonstiges.php_} (100%) diff --git a/classes/Carrier/SendCloud/Data/Document.php b/classes/Carrier/SendCloud/Data/Document.php new file mode 100644 index 00000000..fa2f0fe8 --- /dev/null +++ b/classes/Carrier/SendCloud/Data/Document.php @@ -0,0 +1,25 @@ +Type = $data->type; + $obj->Size = $data->size; + $obj->Link = $data->link; + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/ParcelBase.php b/classes/Carrier/SendCloud/Data/ParcelBase.php new file mode 100644 index 00000000..944288b1 --- /dev/null +++ b/classes/Carrier/SendCloud/Data/ParcelBase.php @@ -0,0 +1,36 @@ + $this->Name, + 'company_name' => $this->CompanyName, + 'address' => $this->Address, + 'address_2' => $this->Address2, + 'house_number' => $this->HouseNumber, + 'city' => $this->City, + 'postal_code' => $this->PostalCode, + 'telephone' => $this->Telephone, + 'request_label' => $this->RequestLabel, + 'email' => $this->EMail, + 'country' => $this->Country, + 'shipment' => ['id' => $this->ShippingMethodId], + 'weight' => number_format($this->Weight / 1000, 3, '.', null), + 'order_number' => $this->OrderNumber, + 'total_order_value_currency' => $this->TotalOrderValueCurrency, + 'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null), + 'country_state' => $this->CountryState, + 'sender_address' => $this->SenderAddressId, + 'customs_invoice_nr' => $this->CustomsInvoiceNr, + 'customs_shipment_type' => $this->CustomsShipmentType, + 'external_reference' => $this->ExternalReference, + 'total_insured_value' => $this->TotalInsuredValue, + 'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems), + 'is_return' => $this->IsReturn, + 'length' => $this->Length, + 'width' => $this->Width, + 'height' => $this->Height, + ]; + } + +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/ParcelCreationError.php b/classes/Carrier/SendCloud/Data/ParcelCreationError.php new file mode 100644 index 00000000..2d2946ea --- /dev/null +++ b/classes/Carrier/SendCloud/Data/ParcelCreationError.php @@ -0,0 +1,10 @@ + $this->HsCode, + 'weight' => number_format($this->Weight / 1000, 3, '.', null), + 'quantity' => $this->Quantity, + 'description' => $this->Description, + 'price' => [ + 'value' => $this->Price, + 'currency' => $this->PriceCurrency, + ], + 'origin_country' => $this->OriginCountry, + 'sku' => $this->Sku, + 'product_id' => $this->ProductId, + ]; + } + + public static function fromApiResponse(object $data): ParcelItem + { + $obj = new ParcelItem(); + $obj->HsCode = $data->hs_code; + $obj->Weight = intval(floatval($data->weight)*1000); + $obj->Quantity = $data->quantity; + $obj->Description = $data->description; + $obj->Price = $data->price->value; + $obj->PriceCurrency = $data->price->currency; + $obj->OriginCountry = $data->origin_country; + $obj->Sku = $data->sku; + $obj->ProductId = $data->product_id; + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/ParcelResponse.php b/classes/Carrier/SendCloud/Data/ParcelResponse.php new file mode 100644 index 00000000..cfca07e2 --- /dev/null +++ b/classes/Carrier/SendCloud/Data/ParcelResponse.php @@ -0,0 +1,76 @@ +Documents as $item) + if ($item->Type == $type) + return $item; + return null; + } + + /** + * @throws Exception + */ + public static function fromApiResponse(object $data): ParcelResponse + { + $obj = new ParcelResponse(); + $obj->Address = $data->address_divided->street; + $obj->Address2 = $data->address_2; + $obj->HouseNumber = $data->address_divided->house_number; + $obj->CarrierCode = $data->carrier->code; + $obj->City = $data->city; + $obj->CompanyName = $data->company_name; + $obj->Country = $data->country->iso_2; + $obj->CustomsInvoiceNr = $data->customs_invoice_nr; + $obj->CustomsShipmentType = $data->customs_shipment_type; + $obj->DateCreated = new DateTimeImmutable($data->date_created); + $obj->DateUpdated = new DateTimeImmutable($data->date_updated); + $obj->DateAnnounced = new DateTimeImmutable($data->date_announced); + $obj->EMail = $data->email; + $obj->Id = $data->id; + $obj->Name = $data->name; + $obj->OrderNumber = $data->order_number; + $obj->ParcelItems = array_map(fn($item)=>ParcelItem::fromApiResponse($item), $data->parcel_items); + $obj->PostalCode = $data->postal_code; + $obj->ExternalReference = $data->external_reference; + $obj->ShippingMethodId = $data->shipment->id; + $obj->ShipmentMethodName = $data->shipment->name; + $obj->StatusId = $data->status->id; + $obj->StatusMessage = $data->status->message; + $obj->Documents = array_map(fn($item)=>Document::fromApiResponse($item), $data->documents); + $obj->Telephone = $data->telephone; + $obj->TotalInsuredValue = $data->total_insured_value; + $obj->TotalOrderValue = $data->total_order_value; + $obj->TotalOrderValueCurrency = $data->total_order_value_currency; + $obj->TrackingNumber = $data->tracking_number; + $obj->TrackingUrl = $data->tracking_url; + $obj->Weight = $data->weight; + $obj->Length = $data->length; + $obj->Height = $data->height; + $obj->Width = $data->width; + $obj->IsReturn = $data->is_return; + $obj->Errors = $data->errors->non_field_errors; + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/SenderAddress.php b/classes/Carrier/SendCloud/Data/SenderAddress.php new file mode 100644 index 00000000..e6004064 --- /dev/null +++ b/classes/Carrier/SendCloud/Data/SenderAddress.php @@ -0,0 +1,52 @@ +CompanyName; $this->ContactName; $this->Street $this->HouseNumber; $this->PostalCode; $this->City"; + } + + + public static function fromApiResponse(object $data): SenderAddress { + $obj = new SenderAddress(); + $obj->City = $data->city; + $obj->CompanyName = $data->company_name; + $obj->ContactName = $data->contact_name; + $obj->Country = $data->country; + $obj->CountryState = $data->country_state; + $obj->Email = $data->email; + $obj->HouseNumber = $data->house_number; + $obj->Id = $data->id; + $obj->PostalBox = $data->postal_box; + $obj->PostalCode = $data->postal_code; + $obj->Street = $data->street; + $obj->Telephone = $data->telephone; + $obj->VatNumber = $data->vat_number; + $obj->EoriNumber = $data->eori_number; + $obj->BrandId = $data->brand_id; + $obj->Label = $data->label; + $obj->SignatureFullName = $data->signature_full_name; + $obj->SignatureInitials = $data->signature_initials; + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/ShippingMethod.php b/classes/Carrier/SendCloud/Data/ShippingMethod.php new file mode 100644 index 00000000..04617f5d --- /dev/null +++ b/classes/Carrier/SendCloud/Data/ShippingMethod.php @@ -0,0 +1,28 @@ +Id = $data->id; + $obj->Name = $data->name; + $obj->Carrier = $data->carrier ?? null; + $obj->MinWeight = $data->properties->min_weight; + $obj->MaxWeight = $data->properties->max_weight; + $obj->MaxLength = $data->properties->max_dimensions->length; + $obj->MaxWidth = $data->properties->max_dimensions->width; + $obj->MaxHeight = $data->properties->max_dimensions->height; + $obj->Unit = $data->properties->max_dimensions->unit; + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/Data/ShippingProduct.php b/classes/Carrier/SendCloud/Data/ShippingProduct.php new file mode 100644 index 00000000..92f7f8da --- /dev/null +++ b/classes/Carrier/SendCloud/Data/ShippingProduct.php @@ -0,0 +1,28 @@ +Name = $data->name; + $obj->Carrier = $data->carrier; + $obj->ServicePointsCarrier = $data->service_points_carrier; + $obj->Code = $data->code; + $obj->MinWeight = $data->weight_range->min_weight; + $obj->MaxWeight = $data->weight_range->max_weight; + foreach ($data->methods as $method) { + $child = ShippingMethod::fromApiResponse($method); + $child->Carrier = $obj->Carrier; + $obj->ShippingMethods[] = $child; + } + return $obj; + } +} \ No newline at end of file diff --git a/classes/Carrier/SendCloud/SendCloudApi.php b/classes/Carrier/SendCloud/SendCloudApi.php new file mode 100644 index 00000000..e4c79f8b --- /dev/null +++ b/classes/Carrier/SendCloud/SendCloudApi.php @@ -0,0 +1,124 @@ +public_key = $public_key; + $this->private_key = $private_key; + } + + public function GetSenderAddresses(): array + { + $uri = self::PROD_BASE_URI . '/user/addresses/sender'; + $response = $this->sendRequest($uri); + $res = array(); + foreach ($response->sender_addresses as $item) + $res[] = SenderAddress::fromApiResponse($item); + return $res; + } + + public function GetShippingProducts(string $sourceCountry, ?string $targetCountry = null, ?int $weight = null, + ?int $height = null, ?int $length = null, ?int $width = null): array + { + $uri = self::PROD_BASE_URI . '/shipping-products'; + $params = ['from_country' => $sourceCountry]; + if ($targetCountry !== null) + $params['to_country'] = $targetCountry; + if ($weight !== null && $weight > 0) + $params['weight'] = $weight; + if ($height !== null && $height > 0) { + $params['height'] = $height; + $params['height_unit'] = 'centimeter'; + } + if ($length !== null && $length > 0) { + $params['length'] = $length; + $params['length_unit'] = 'centimeter'; + } + if ($width !== null && $width > 0) { + $params['width'] = $width; + $params['width_unit'] = 'centimeter'; + } + $response = $this->sendRequest($uri, $params); + return array_map(fn($x) => ShippingProduct::fromApiResponse($x), $response ?? []); + } + + /** + * @throws Exception + */ + public function CreateParcel(ParcelCreation $parcel): ParcelResponse|string|null + { + $uri = self::PROD_BASE_URI . '/parcels'; + $response = $this->sendRequest($uri, null, true, [ + 'parcel' => $parcel->toApiRequest() + ]); + if (isset($response->parcel)) + return ParcelResponse::fromApiResponse($response->parcel); + if (isset($response->error)) + return $response->error->message; + return null; + } + + public function DownloadDocument(Document $document): string + { + $curl = curl_init(); + curl_setopt_array($curl, [ + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $document->Link, + CURLOPT_HTTPHEADER => [ + "Authorization: Basic " . base64_encode($this->public_key . ':' . $this->private_key) + ], + ]); + return curl_exec($curl); + } + + function sendRequest(string $uri, array $query_params = null, bool $post = false, array $postFields = null) + { + if (empty($this->public_key) || empty($this->private_key)) + return null; + + $curl = curl_init(); + if (is_array($query_params)) { + $uri .= '?' . http_build_query($query_params); + } + curl_setopt_array($curl, [ + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $uri, + CURLOPT_HTTPHEADER => [ + "Authorization: Basic " . base64_encode($this->public_key . ':' . $this->private_key), + 'Content-Type: application/json' + ], + ]); + if ($post === true) { + curl_setopt_array($curl, [ + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => json_encode($postFields) + ]); + } + + $output = curl_exec($curl); + curl_close($curl); + + return json_decode($output); + } +} \ No newline at end of file diff --git a/classes/Modules/ShippingMethod/www/js/shipping_method_create.js b/classes/Modules/ShippingMethod/www/js/shipping_method_create.js index a7b6a50e..d8d56fad 100644 --- a/classes/Modules/ShippingMethod/www/js/shipping_method_create.js +++ b/classes/Modules/ShippingMethod/www/js/shipping_method_create.js @@ -11,35 +11,14 @@ var ShippingMethodCreate = function ($) { vueElementId: '#shipment-create', }, search: function (el) { - $.ajax({ - url: 'index.php?module=versandarten&action=create&cmd=suche', - type: 'POST', - dataType: 'json', - data: { - val: $(el).val() - } + let val = $(el).val().toLowerCase(); + $('.createbutton').each(function() { + let desc = $(this).find('.tilegrid-tile-title').text(); + if (desc.toLowerCase().indexOf(val)>=0) + $(this).show(); + else + $(this).hide(); }) - .done(function (data) { - if (typeof data != 'undefined' && data != null) { - if (typeof data.ausblenden != 'undefined' && data.ausblenden != null) { - me.storage.hideElements = data.ausblenden.split(';'); - $.each(me.storage.hideElements, function (k, v) { - if (v != '') { - $('#' + v).hide(); - } - }); - - } - if (typeof data.anzeigen != 'undefined' && data.anzeigen != null) { - me.storage.showElements = data.anzeigen.split(';'); - $.each(me.storage.showElements, function (k, v) { - if (v != '') { - $('#' + v).show(); - } - }); - } - } - }); }, init: function () { if ($(me.selector.vueElementId).length === 0) { diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index b915d780..624cf772 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -20463,33 +20463,11 @@ if($id > 0) } //@refactor ApplicationCore -function LoadVersandModul($modul, $id) +function LoadVersandModul(string $modul, int $id): Versanddienstleister { - if(empty($modul) || - strpos($modul,'..') !== false || - !@is_file(__DIR__.'/versandarten/'.$modul.'.php') - ) - { - return; - } - $class_name = 'Versandart_'.$modul; - $class_name_custom = 'Versandart_'.$modul.'Custom'; - if(!class_exists($class_name)) - { - if(@is_file(__DIR__.'/versandarten/'.$modul.'_custom.php')) - { - include_once(__DIR__.'/versandarten/'.$modul.'_custom.php'); - }else{ - include_once(__DIR__.'/versandarten/'.$modul.'.php'); - } - } - if(class_exists($class_name_custom)) - { - return new $class_name_custom($this->app, $id); - }elseif(class_exists($class_name)) - { - return new $class_name($this->app, $id); - } + /** @var Versandarten $versandarten */ + $versandarten = $this->app->loadModule('versandarten'); + return $versandarten->loadModule($modul, $id); } //@refactor versanddiestleister Modul @@ -20562,131 +20540,131 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") } } - if($sid=="versand") - { - // falche tracingnummer bei DHL da wir in der Funktion PaketmarkeDHLEmbedded sind - if((strlen($tracking) < 12 || strlen($tracking) > 21) && $trackingsubmitcancel=="" && ($typ=="DHL" || $typ=="Intraship")) + if($sid=="versand") { - header("Location: index.php?module=versanderzeugen&action=frankieren&id=$id&land=$land&tracking_again=1"); - exit; - } - else - { -/* $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul,bezeichnung FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($typ)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); - if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php')) + // falche tracingnummer bei DHL da wir in der Funktion PaketmarkeDHLEmbedded sind + if((strlen($tracking) < 12 || strlen($tracking) > 21) && $trackingsubmitcancel=="" && ($typ=="DHL" || $typ=="Intraship")) { - $obj = $this->LoadVersandModul($versandartenmodul[0]['modul'], $versandartenmodul[0]['id']); - if(!empty($obj) && method_exists($obj, 'TrackingReplace')) - { - $tracking = $obj->TrackingReplace($tracking); - } + header("Location: index.php?module=versanderzeugen&action=frankieren&id=$id&land=$land&tracking_again=1"); + exit; } + else + { + /* $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul,bezeichnung FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($typ)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); + if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php')) + { + $obj = $this->LoadVersandModul($versandartenmodul[0]['modul'], $versandartenmodul[0]['id']); + if(!empty($obj) && method_exists($obj, 'TrackingReplace')) + { + $tracking = $obj->TrackingReplace($tracking); + } + } */ - $trackingUser = !empty($this->app->User) && method_exists($this->app->User,'GetParameter')? - $this->app->User->GetParameter('versand_lasttracking'):''; + $trackingUser = !empty($this->app->User) && method_exists($this->app->User,'GetParameter')? + $this->app->User->GetParameter('versand_lasttracking'):''; - if(!empty($trackingUser) && in_array($trackingUser,[$trackingBefore,$tracking])) { - $this->app->User->SetParameter('versand_lasttracking',''); - $this->app->User->SetParameter('versand_lasttracking_link',''); - $this->app->User->SetParameter('versand_lasttracking_versand', ''); - $this->app->User->SetParameter('versand_lasttracking_lieferschein', ''); - } + if(!empty($trackingUser) && in_array($trackingUser,[$trackingBefore,$tracking])) { + $this->app->User->SetParameter('versand_lasttracking',''); + $this->app->User->SetParameter('versand_lasttracking_link',''); + $this->app->User->SetParameter('versand_lasttracking_versand', ''); + $this->app->User->SetParameter('versand_lasttracking_lieferschein', ''); + } - $this->app->DB->Update("UPDATE versand SET versandunternehmen='$versand', tracking='$tracking', - versendet_am=NOW(),versendet_am_zeitstempel=NOW(), abgeschlossen='1',logdatei=NOW() WHERE id='$id' LIMIT 1"); - if($lieferschein = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id = '$id' LIMIT 1")) { - $this->app->erp->LieferscheinProtokoll($lieferschein,'Verarbeitung im Versandzentrum'); - } - $rechnung = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id = '$id' LIMIT 1"); - if($lieferschein && ($auftrag = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id = '$lieferschein'"))) { - $this->app->erp->AuftragProtokoll($auftrag,'Verarbeitung im Versandzentrum'); + $this->app->DB->Update("UPDATE versand SET versandunternehmen='$versand', tracking='$tracking', + versendet_am=NOW(),versendet_am_zeitstempel=NOW(), abgeschlossen='1',logdatei=NOW() WHERE id='$id' LIMIT 1"); + if($lieferschein = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id = '$id' LIMIT 1")) { + $this->app->erp->LieferscheinProtokoll($lieferschein,'Verarbeitung im Versandzentrum'); + } + $rechnung = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id = '$id' LIMIT 1"); + if($lieferschein && ($auftrag = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id = '$lieferschein'"))) { + $this->app->erp->AuftragProtokoll($auftrag,'Verarbeitung im Versandzentrum'); - if(empty($rechnung)) { - $rechnung = $this->app->DB->Select( - sprintf( - "SELECT id FROM rechnung WHERE auftragid = %d AND status <> 'storniert' AND belegnr <> '' LIMIT 1", - $auftrag - ) - ); - if($rechnung) { - $this->app->DB->Update( + if(empty($rechnung)) { + $rechnung = $this->app->DB->Select( sprintf( - 'UPDATE versand SET rechnung = %d WHERE id = %d AND rechnung = 0', - $rechnung, $id + "SELECT id FROM rechnung WHERE auftragid = %d AND status <> 'storniert' AND belegnr <> '' LIMIT 1", + $auftrag ) ); + if($rechnung) { + $this->app->DB->Update( + sprintf( + 'UPDATE versand SET rechnung = %d WHERE id = %d AND rechnung = 0', + $rechnung, $id + ) + ); + } } } - } - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id = '$lieferschein' LIMIT 1"); - if($lieferschein) { + $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id = '$lieferschein' LIMIT 1"); + if($lieferschein) { - $this->PDFArchivieren('lieferschein', $lieferschein, true); - } - $proformaPrinted = false; - $druckennachtracking = $this->app->erp->Projektdaten($projekt,'druckennachtracking'); - if($druckennachtracking - && !($proformarechnung = $this->app->DB->Select( - sprintf( - 'SELECT id FROM proformarechnung WHERE lieferschein = %d LIMIT 1', - $lieferschein + $this->PDFArchivieren('lieferschein', $lieferschein, true); + } + $proformaPrinted = false; + $druckennachtracking = $this->app->erp->Projektdaten($projekt,'druckennachtracking'); + if($druckennachtracking + && !($proformarechnung = $this->app->DB->Select( + sprintf( + 'SELECT id FROM proformarechnung WHERE lieferschein = %d LIMIT 1', + $lieferschein + ) ) - ) - ) - ) { - /** @var Versanderzeugen $versandObj */ - $versandObj = $this->LoadModul('versanderzeugen'); - if($versandObj !== null && method_exists($versandObj, 'checkPrintCreateProformaInvoice')) { - $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); + ) + ) { + /** @var Versanderzeugen $versandObj */ + $versandObj = $this->LoadModul('versanderzeugen'); + if($versandObj !== null && method_exists($versandObj, 'checkPrintCreateProformaInvoice')) { + $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); - if($druckercode <=0) { - $druckercode = $this->app->erp->Firmendaten('standardversanddrucker'); // standard = 3 // 2 buchhaltung // 1 empfang + if($druckercode <=0) { + $druckercode = $this->app->erp->Firmendaten('standardversanddrucker'); // standard = 3 // 2 buchhaltung // 1 empfang + } + $userversanddrucker = $this->app->DB->Select("SELECT standardversanddrucker FROM user WHERE id='".$this->app->User->GetID()."'"); + if($userversanddrucker>0) { + $druckercode = $userversanddrucker; + } + $deliveryArr = $this->app->DB->SelectRow( + sprintf('SELECT land FROM lieferschein WHERE id = %d', $lieferschein) + ); + $country = $deliveryArr['land']; + $versandObj->checkPrintCreateProformaInvoice($lieferschein,$country,$projekt,$druckercode,true); + $proformaPrinted = $druckercode > 0; } - $userversanddrucker = $this->app->DB->Select("SELECT standardversanddrucker FROM user WHERE id='".$this->app->User->GetID()."'"); - if($userversanddrucker>0) { - $druckercode = $userversanddrucker; - } - $deliveryArr = $this->app->DB->SelectRow( - sprintf('SELECT land FROM lieferschein WHERE id = %d', $lieferschein) + } + if($rechnung) { + $this->PDFArchivieren('rechnung', $rechnung, true); + } + elseif($auftrag && $druckennachtracking + && $this->app->DB->Select( + sprintf( + "SELECT id FROM auftrag WHERE id = %d AND art <> 'lieferung'", + $auftrag + ) + ) + ) { + $rechnung = $this->WeiterfuehrenAuftragZuRechnung($auftrag); + $this->BelegFreigabe('rechnung', $rechnung); + $this->app->DB->Update( + sprintf( + 'UPDATE versand SET rechnung = %d WHERE id = %d LIMIT 1', + $rechnung, $id + ) ); - $country = $deliveryArr['land']; - $versandObj->checkPrintCreateProformaInvoice($lieferschein,$country,$projekt,$druckercode,true); - $proformaPrinted = $druckercode > 0; + $this->app->DB->Update( + sprintf( + "UPDATE rechnung SET schreibschutz = 1, status = 'versendet' WHERE id = %d", + $rechnung + ) + ); + $this->PDFArchivieren('rechnung', $rechnung, true); } - } - if($rechnung) { - $this->PDFArchivieren('rechnung', $rechnung, true); - } - elseif($auftrag && $druckennachtracking - && $this->app->DB->Select( - sprintf( - "SELECT id FROM auftrag WHERE id = %d AND art <> 'lieferung'", - $auftrag - ) - ) - ) { - $rechnung = $this->WeiterfuehrenAuftragZuRechnung($auftrag); - $this->BelegFreigabe('rechnung', $rechnung); - $this->app->DB->Update( - sprintf( - 'UPDATE versand SET rechnung = %d WHERE id = %d LIMIT 1', - $rechnung, $id - ) - ); - $this->app->DB->Update( - sprintf( - "UPDATE rechnung SET schreibschutz = 1, status = 'versendet' WHERE id = %d", - $rechnung - ) - ); - $this->PDFArchivieren('rechnung', $rechnung, true); - } - if($rechnung > 0 && $druckennachtracking - && $this->app->DB->Select("SELECT count(id) FROM versand WHERE lieferschein = '$lieferschein'") <= 1) { - $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); + if($rechnung > 0 && $druckennachtracking + && $this->app->DB->Select("SELECT count(id) FROM versand WHERE lieferschein = '$lieferschein'") <= 1) { + $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); if($druckercode <=0) $druckercode = $this->app->erp->Firmendaten("standardversanddrucker"); // standard = 3 // 2 buchhaltung // 1 empfang @@ -20695,32 +20673,12 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") if($userversanddrucker>0) $druckercode = $userversanddrucker; - $this->app->erp->BriefpapierHintergrundDisable($druckercode); + $this->app->erp->BriefpapierHintergrundDisable($druckercode); - $addressId = $this->app->DB->Select("SELECT `adresse` FROM `rechnung` WHERE `id` = '{$rechnung}' LIMIT 1"); - $printInvoice = $this->app->DB->Select("SELECT `rechnung_papier` FROM `adresse` WHERE `id` = '{$addressId}' LIMIT 1"); - $amountPrintedInvoices = $this->app->DB->Select("SELECT `rechnung_anzahlpapier` FROM `adresse` WHERE `id` = '{$addressId}' LIMIT 1"); - if($printInvoice === '1' && $amountPrintedInvoices > 0){ - if(class_exists('RechnungPDFCustom')) - { - $Brief = new RechnungPDFCustom($this->app,$projekt); - }else{ - $Brief = new RechnungPDF($this->app,$projekt); - } - $Brief->GetRechnung($rechnung); - $tmpfile = $Brief->displayTMP(); - - for($i = 1; $i <= $amountPrintedInvoices; $i++) { - $this->app->printer->Drucken($druckercode,$tmpfile); - } - } else { - $autodruckrechnungmenge = $this->app->erp->Projektdaten($projekt,"autodruckrechnungmenge"); - $autodruckrechnung= $this->app->erp->Projektdaten($projekt,"autodruckrechnung"); - - if($autodruckrechnungmenge < 0)$autodruckrechnungmenge = 1; - - if($autodruckrechnung > 0) - { + $addressId = $this->app->DB->Select("SELECT `adresse` FROM `rechnung` WHERE `id` = '{$rechnung}' LIMIT 1"); + $printInvoice = $this->app->DB->Select("SELECT `rechnung_papier` FROM `adresse` WHERE `id` = '{$addressId}' LIMIT 1"); + $amountPrintedInvoices = $this->app->DB->Select("SELECT `rechnung_anzahlpapier` FROM `adresse` WHERE `id` = '{$addressId}' LIMIT 1"); + if($printInvoice === '1' && $amountPrintedInvoices > 0){ if(class_exists('RechnungPDFCustom')) { $Brief = new RechnungPDFCustom($this->app,$projekt); @@ -20730,88 +20688,108 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") $Brief->GetRechnung($rechnung); $tmpfile = $Brief->displayTMP(); - for($i = 1; $i <= $autodruckrechnungmenge; $i++) { + for($i = 1; $i <= $amountPrintedInvoices; $i++) { $this->app->printer->Drucken($druckercode,$tmpfile); } + } else { + $autodruckrechnungmenge = $this->app->erp->Projektdaten($projekt,"autodruckrechnungmenge"); + $autodruckrechnung= $this->app->erp->Projektdaten($projekt,"autodruckrechnung"); + + if($autodruckrechnungmenge < 0)$autodruckrechnungmenge = 1; + + if($autodruckrechnung > 0) + { + if(class_exists('RechnungPDFCustom')) + { + $Brief = new RechnungPDFCustom($this->app,$projekt); + }else{ + $Brief = new RechnungPDF($this->app,$projekt); + } + $Brief->GetRechnung($rechnung); + $tmpfile = $Brief->displayTMP(); + + for($i = 1; $i <= $autodruckrechnungmenge; $i++) { + $this->app->printer->Drucken($druckercode,$tmpfile); + } + } } - } - // Print additional invoices for export - $exportdruckrechnung = $this->app->erp->Projektdaten($projekt,"exportdruckrechnung"); - if($exportdruckrechnung) - { - $exportland = $this->app->DB->Select("SELECT land FROM rechnung WHERE id = '$rechnung' LIMIT 1"); - $exportdruckrechnung = $this->app->erp->Export($exportland); + // Print additional invoices for export + $exportdruckrechnung = $this->app->erp->Projektdaten($projekt,"exportdruckrechnung"); if($exportdruckrechnung) { - $mengedruck = $this->app->erp->Projektdaten($projekt,"exportdruckrechnungmenge"); - for($mengedruck;$mengedruck > 0;$mengedruck--) + $exportland = $this->app->DB->Select("SELECT land FROM rechnung WHERE id = '$rechnung' LIMIT 1"); + $exportdruckrechnung = $this->app->erp->Export($exportland); + if($exportdruckrechnung) { - $this->app->printer->Drucken($druckercode,$tmpfile); + $mengedruck = $this->app->erp->Projektdaten($projekt,"exportdruckrechnungmenge"); + for($mengedruck;$mengedruck > 0;$mengedruck--) + { + $this->app->printer->Drucken($druckercode,$tmpfile); + } } } - } - unlink($tmpfile); - if($this->app->erp->Projektdaten($projekt,"automailrechnung")=="1") - { - // aber nur das erste mal also wenn es einen eintrag in der versand tabelle gibt - $rechnungbereitsversendet = $this->app->DB->Select("SELECT versendet FROM rechnung WHERE id = '$rechnung' LIMIT 1"); - if($rechnungbereitsversendet!="1") + unlink($tmpfile); + if($this->app->erp->Projektdaten($projekt,"automailrechnung")=="1") { - $this->app->erp->Rechnungsmail($rechnung); - } - } - $this->BriefpapierHintergrundEnable(); - } - - if($druckennachtracking && $lieferschein && $this->Export($land) - && $this->Projektdaten($projekt, 'proformainvoice_amount') && $proformaRechnungId = $this->app->DB->Select( - sprintf( - "SELECT id FROM proformarechnung WHERE lieferschein = %d AND status <> 'storniert' LIMIT 1", - $lieferschein - )) - ) { - /** @var Versanderzeugen $objProforma */ - $objVersand = $this->LoadModul('versanderzeugen'); - if($objVersand && method_exists($objVersand,'checkPrintCreateProformaInvoice')){ - if(empty($druckercode)) { - $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); - - if($druckercode <= 0) { - $druckercode = $this->app->erp->Firmendaten('standardversanddrucker'); // standard = 3 // 2 buchhaltung // 1 empfang - } - $userversanddrucker = $this->app->DB->Select("SELECT standardversanddrucker FROM user WHERE id='" . $this->app->User->GetID() . "'"); - if($userversanddrucker > 0) { - $druckercode = $userversanddrucker; + // aber nur das erste mal also wenn es einen eintrag in der versand tabelle gibt + $rechnungbereitsversendet = $this->app->DB->Select("SELECT versendet FROM rechnung WHERE id = '$rechnung' LIMIT 1"); + if($rechnungbereitsversendet!="1") + { + $this->app->erp->Rechnungsmail($rechnung); } } - $objVersand->checkPrintCreateProformaInvoice($lieferschein, $land, $projekt, $druckercode, empty($proformaPrinted)); + $this->BriefpapierHintergrundEnable(); } - } - if(!$this->app->erp->Firmendaten('versandmail_zwischenspeichern') || !$this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'versandmailsundrueckmeldung' AND aktiv = 1")) - { - $this->VersandAbschluss($id); - $this->RunHook('versanderzeugen_frankieren_hook1', 1, $id); - //versand mail an kunden - $this->Versandmail($id); - }else{ - $this->app->DB->Update("UPDATE versand SET cronjob = 1 WHERE id = '$id' LIMIT 1"); - } - $weiterespaket=$this->app->Secure->GetPOST("weiterespaket"); - $lieferscheinkopie=$this->app->Secure->GetPOST("lieferscheinkopie"); - if($weiterespaket=="1") - { - if($lieferscheinkopie=="1") $lieferscheinkopie=0; else $lieferscheinkopie=1; - //$this->app->erp->LogFile("Lieferscheinkopie $lieferscheinkopie"); - $all = $this->app->DB->SelectArr("SELECT * FROM versand WHERE id='$id' LIMIT 1"); - $this->app->DB->Insert("INSERT INTO versand (id,adresse,rechnung,lieferschein,versandart,projekt,bearbeiter,versender,versandunternehmen,firma, - keinetrackingmail,gelesen,paketmarkegedruckt,papieregedruckt,weitererlieferschein) - VALUES ('','{$all[0]['adresse']}','{$all[0]['rechnung']}','{$all[0]['lieferschein']}','{$all[0]['versandart']}','{$all[0]['projekt']}', - '{$all[0]['bearbeiter']}','{$all[0]['versender']}','{$all[0]['versandunternehmen']}', - '{$all[0]['firma']}','{$all[0]['keinetrackingmail']}','{$all[0]['gelesen']}',0,$lieferscheinkopie,1)"); + if($druckennachtracking && $lieferschein && $this->Export($land) + && $this->Projektdaten($projekt, 'proformainvoice_amount') && $proformaRechnungId = $this->app->DB->Select( + sprintf( + "SELECT id FROM proformarechnung WHERE lieferschein = %d AND status <> 'storniert' LIMIT 1", + $lieferschein + )) + ) { + /** @var Versanderzeugen $objProforma */ + $objVersand = $this->LoadModul('versanderzeugen'); + if($objVersand && method_exists($objVersand,'checkPrintCreateProformaInvoice')){ + if(empty($druckercode)) { + $druckercode = $this->app->DB->Select("SELECT druckerlogistikstufe2 FROM projekt WHERE id='$projekt' LIMIT 1"); + + if($druckercode <= 0) { + $druckercode = $this->app->erp->Firmendaten('standardversanddrucker'); // standard = 3 // 2 buchhaltung // 1 empfang + } + $userversanddrucker = $this->app->DB->Select("SELECT standardversanddrucker FROM user WHERE id='" . $this->app->User->GetID() . "'"); + if($userversanddrucker > 0) { + $druckercode = $userversanddrucker; + } + } + $objVersand->checkPrintCreateProformaInvoice($lieferschein, $land, $projekt, $druckercode, empty($proformaPrinted)); + } + } + + if(!$this->app->erp->Firmendaten('versandmail_zwischenspeichern') || !$this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'versandmailsundrueckmeldung' AND aktiv = 1")) + { + $this->VersandAbschluss($id); + $this->RunHook('versanderzeugen_frankieren_hook1', 1, $id); + //versand mail an kunden + $this->Versandmail($id); + }else{ + $this->app->DB->Update("UPDATE versand SET cronjob = 1 WHERE id = '$id' LIMIT 1"); + } + $weiterespaket=$this->app->Secure->GetPOST("weiterespaket"); + $lieferscheinkopie=$this->app->Secure->GetPOST("lieferscheinkopie"); + if($weiterespaket=="1") + { + if($lieferscheinkopie=="1") $lieferscheinkopie=0; else $lieferscheinkopie=1; + //$this->app->erp->LogFile("Lieferscheinkopie $lieferscheinkopie"); + $all = $this->app->DB->SelectArr("SELECT * FROM versand WHERE id='$id' LIMIT 1"); + $this->app->DB->Insert("INSERT INTO versand (id,adresse,rechnung,lieferschein,versandart,projekt,bearbeiter,versender,versandunternehmen,firma, + keinetrackingmail,gelesen,paketmarkegedruckt,papieregedruckt,weitererlieferschein) + VALUES ('','{$all[0]['adresse']}','{$all[0]['rechnung']}','{$all[0]['lieferschein']}','{$all[0]['versandart']}','{$all[0]['projekt']}', + '{$all[0]['bearbeiter']}','{$all[0]['versender']}','{$all[0]['versandunternehmen']}', + '{$all[0]['firma']}','{$all[0]['keinetrackingmail']}','{$all[0]['gelesen']}',0,$lieferscheinkopie,1)"); $newid = $this->app->DB->GetInsertID(); @@ -20849,7 +20827,7 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") $this->app->DB->Insert("INSERT INTO versand (id,versandunternehmen, tracking, versendet_am,abgeschlossen,retoure, freigegeben,firma,adresse,projekt,gewicht,paketmarkegedruckt,anzahlpakete) - VALUES ('','$versand','$tracking',NOW(),1,'$id',1,'".$this->app->User->GetFirma()."','$adresse','$projekt','$kg','1','1') "); + VALUES ('','$versand','$tracking',NOW(),1,'$id',1,'".$this->app->User->GetFirma()."','$adresse','$projekt','$kg','1','1') "); $versandid = $this->app->DB->GetInsertID(); if($this->app->DB->Select("SELECT automailversandbestaetigung FROM projekt WHERE id = '$projekt' LIMIT 1"))$this->Versandmail($versandid); @@ -20878,23 +20856,6 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") if($kg=="") { $kg = $this->VersandartMindestgewicht($id); } -/* - //Brauchen wir nicht - $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul,bezeichnung FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($versand)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); - if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php')) - { - $class_name = 'Versandart_'.$versandartenmodul[0]['modul']; - if(!class_exists($class_name))include_once(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php'); - if(class_exists($class_name)) - { - $obj = new $class_name($this->app, $versandartenmodul[0]['id']); - if(method_exists($obj, 'TrackingReplace')){ - $tracking = $obj->TrackingReplace($tracking); - } - } - } -*/ - $trackingUser = !empty($this->app->User) && method_exists($this->app->User,'GetParameter')? $this->app->User->GetParameter('versand_lasttracking'):''; @@ -20905,9 +20866,9 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") $this->app->User->SetParameter('versand_lasttracking_lieferschein', ''); } - $this->app->DB->Insert("INSERT INTO versand (id,versandunternehmen, tracking, tracking_link, - versendet_am,abgeschlossen,lieferschein, - freigegeben,firma,adresse,projekt,gewicht,paketmarkegedruckt,anzahlpakete) + $this->app->DB->Insert("INSERT INTO versand (id,versandunternehmen, tracking, tracking_link, + versendet_am,abgeschlossen,lieferschein, + freigegeben,firma,adresse,projekt,gewicht,paketmarkegedruckt,anzahlpakete) VALUES ('','$versand','$tracking', '{$trackingLink}',NOW(),1,'$id',1,'".$this->app->User->GetFirma()."','$adresse','$projekt','$kg','1','1') "); $versandid = $this->app->DB->GetInsertID(); @@ -20928,8 +20889,7 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") 'SELECT zahlweise FROM rechnung WHERE id = %d', $rechnung ) ); - } - else{ + } else { $rechnung_projekt = $this->app->DB->Select( sprintf( 'SELECT projekt FROM auftrag WHERE id = %d', $auftrag @@ -21064,176 +21024,17 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") if($kg=="") $kg=$this->VersandartMindestgewicht($lieferschein); - //$versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul FROM versanddienstleister WHERE aktiv = 1 AND modul = '".$this->app->DB->real_escape_string($typ)."' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); - $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul,bezeichnung, einstellungen_json FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($typ)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); - if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php')) - { - $obj = $this->LoadVersandModul($versandartenmodul[0]['modul'], $versandartenmodul[0]['id']); - $this->app->Tpl->Set("ZUSATZ",$versandartenmodul[0]['bezeichnung']); - - if(!empty($obj) && method_exists($obj, 'Paketmarke')) + $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul,bezeichnung, einstellungen_json FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($typ)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"); + if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php')) { - $error = $obj->Paketmarke($sid!=''?$sid:'lieferschein',$id); - }else $error[] = 'Versandmodul '.$typ.' fehlerhaft!'; - }else{ - switch($typ) - { - case "DHL": - if($nachnahme=="" && $versichert=="" && $extraversichert=="") - { - $this->EasylogPaketmarkeStandard($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg); - } else if ($nachnahme=="1" && $versichert=="" && $extraversichert=="") - { - $this->EasylogPaketmarkeNachnahme($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer); - } else if ($versichert=="1" && $extraversichert=="" && $nachnahme=="") - { - $this->EasylogPaketmarke2500($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg); - } else if ($versichert=="1" && $extraversichert=="" && $nachnahme=="1") - { - $this->EasylogPaketmarkeNachnahme2500($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer); - } else if ($versichert=="" && $extraversichert=="1" && $nachnahme=="1") - { - $this->EasylogPaketmarkeNachnahme25000($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer); - } else if ($extraversichert=="1" && $versichert=="" && $nachnahme=="") - { - $this->EasylogPaketmarke25000($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg); - } - break; - case "Intraship": - $kg = (float)str_replace(',','.',$kg); + $obj = $this->LoadVersandModul($versandartenmodul[0]['modul'], $versandartenmodul[0]['id']); + $this->app->Tpl->Set("ZUSATZ",$versandartenmodul[0]['bezeichnung']); - $abholdatum = $this->app->Secure->GetPOST("abholdatum"); - $retourenlabel= $this->app->Secure->GetPOST("retourenlabel"); - if($retourenlabel) - { - $this->app->Tpl->Set('RETOURENLABEL', ' checked="checked" '); - $zusaetzlich['retourenlabel'] = 1; - } - if($abholdatum){ - $this->app->Tpl->Set('ABHOLDATUM',$abholdatum); - $zusaetzlich['abholdatum'] = date('Y-m-d', strtotime($abholdatum)); - $this->app->User->SetParameter("paketmarke_abholdatum",$zusaetzlich['abholdatum']); - } - if($altersfreigabe)$zusaetzlich['altersfreigabe'] = 1; - if($nachnahme=="1") - $error = $this->IntrashipPaketmarkeNachnahme($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer,$zusaetzlich); - else - $error = $this->IntrashipPaketmarkeStandard($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,"",$rechnungsnummer,$zusaetzlich); - break; - case "UPS": - $error = $this->UPSPaketmarke($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer); - break; - case "FEDEX": - $error = $this->FEDEXPaketmarke($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer); - break; - case 'Go': - if($name && $strasse && $plz && $ort && (($hausnummer && (!$land || $land == 'DE') || ($land && $land != 'DE')))) - { - $kg = $this->app->Secure->GetPOST("kg"); - if($kg=="") $kg=$this->VersandartMindestgewicht($lieferschein); - $kg = str_replace(',','.',$kg); - $frei = $this->app->Secure->GetPOST("frei")==1?1:0; - $auftragid = $this->app->DB->Select("SELECT auftragid FROM lieferschein where id = ".(int)$lieferschein." limit 1"); - - if($frei){ - $this->app->Tpl->Set('FREI',' checked="checked" '); - $zusaetzlich['frei'] = 1; - } - $selbstabholung = $this->app->Secure->GetPOST("selbstabholung"); - if($selbstabholung){ - $this->app->Tpl->Set('SELBSTABHOLUNG',' checked="checked" '); - $zusaetzlich['selbstabholung'] = 1; - } - $landesvorwahl = $this->app->Secure->GetPOST("landesvorwahl"); - if($landesvorwahl){ - $this->app->Tpl->Set('LANDESVORWAHL',$landesvorwahl); - $zusaetzlich['landesvorwahl'] = $landesvorwahl; - } - $ortsvorwahl = $this->app->Secure->GetPOST("ortsvorwahl"); - if($ortsvorwahl){ - $this->app->Tpl->Set('ORTSVORWAHL',$ortsvorwahl); - $zusaetzlich['ortsvorwahl'] = $ortsvorwahl; - } - if($telefon) - { - $this->app->Tpl->Set('TELEFON',$telefon); - $zusaetzlich['telefon'] = $telefon; - } - if($email) - { - $this->app->Tpl->Set('EMAIL',trim($email)); - $zusaetzlich['email'] = trim($email); - } - - - $selbstanlieferung = $this->app->Secure->GetPOST("selbstanlieferung"); - if($selbstanlieferung){ - $this->app->Tpl->Set('SELBSTANLIEFERUNG',' checked="checked" '); - $zusaetzlich['selbstanlieferung'] = 1; - } - $abholdatum = $this->app->Secure->GetPOST("abholdatum"); - if($abholdatum){ - $this->app->Tpl->Set('ABHOLDATUM',$abholdatum); - $zusaetzlich['abholdatum'] = $abholdatum; - $this->app->User->SetParameter("paketmarke_abholdatum",$zusaetzlich['abholdatum']); - } - $zustelldatum = $this->app->Secure->GetPOST("zustelldatum"); - if(!$zustelldatum) - { - //$zustelldatum = $this->app->DB->Select("SELECT lieferdatum FROM rechnung where id = ".(int)$rechnungid." and lieferdatum > now() limit 1"); - $zustelldatum = $this->app->DB->Select("SELECT lieferdatum FROM auftrag where id = ".(int)$auftragid." limit 1"); - } - if($zustelldatum){ - $this->app->Tpl->Set('ZUSTELLDATUM',$zustelldatum); - $zusaetzlich['zustelldatum'] = $zustelldatum; - } - - if(!$abholdatum) - { - //$abholdatum = $this->app->DB->Select("SELECT tatsaechlicheslieferdatum FROM rechnung where id = ".(int)$rechnungid." and tatsaechlicheslieferdatum > now() limit 1"); - $abholdatum = $this->app->DB->Select("SELECT date_format(now(),'%d.%m.%Y')"); - /*if(!$abholdatum) - { - $projekt = $this->app->DB->Select("SELECT projekt FROM auftrag WHERE id='$auftragid' LIMIT 1"); - $differenztage = $this->Projektdaten($projekt,"differenz_auslieferung_tage"); - if($differenztage<0) $differenztage=2; - $abholdatum = $this->app->DB->Select("SELECT DATE_SUB(lieferdatum, INTERVAL $differenztage DAY) from auftrag WHERE id='$auftragid' and DATE_SUB(lieferdatum, INTERVAL $differenztage DAY) > now() LIMIT 1"); - }*/ - if($abholdatum) - { - $this->app->Tpl->Set('ABHOLDATUM',$abholdatum); - $zusaetzlich['abholdatum'] = $abholdatum; - $this->app->User->SetParameter("paketmarke_abholdatum",$zusaetzlich['abholdatum']); - } - } - - - $Zustellhinweise = $this->app->Secure->GetPOST("Zustellhinweise"); - if($Zustellhinweise){ - $this->app->Tpl->Set('ZUSTELLHINWEISE',$Zustellhinweise); - $zusaetzlich['Zustellhinweise'] = $Zustellhinweise; - } - $Abholhinweise = $this->app->Secure->GetPOST("Abholhinweise"); - if($Abholhinweise){ - $this->app->Tpl->Set('ABHOLHINWEISE',$Abholhinweise); - $zusaetzlich['Abholhinweise'] = $Abholhinweise; - } - - - if($anzahl)$zusaetzlich['menge'] = $anzahl; - $inhalt = $this->app->Secure->GetPOST("inhalt"); - if($inhalt){ - $this->app->Tpl->Set('INHALT',$inhalt); - $zusaetzlich['inhalt'] = $inhalt; - } - if(isset($nachnahme))$zusaetzlich['nachnahme'] = $nachnahme; - $this->GoPaketmarke($id,$name,$name2,$name3,$strasse,$hausnummer,$plz,$ort,$land,$kg,$betrag,$rechnungsnummer, $zusaetzlich); - } else header("Location: index.php?module=lieferschein&action=paketmarke&id=$id"); - break; - - } + if(!empty($obj) && method_exists($obj, 'Paketmarke')) + { + $error = $obj->Paketmarke($sid!=''?$sid:'lieferschein',$id); + }else $error[] = 'Versandmodul '.$typ.' fehlerhaft!'; } - if(!isset($error) || !$error)$this->app->DB->Update("UPDATE versand SET gewicht='$kg',paketmarkegedruckt=1,anzahlpakete='$anzahl' WHERE id='$id' LIMIT 1"); } if(!$error) @@ -21266,8 +21067,7 @@ function Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") break; } - $this->app->DB->Insert("INSERT INTO versandpakete (id,versand,gewicht,nr,versender) VALUES ('','$id','$kg','$anzahli','".$this->app->User->GetName()."')"); - } + $this->app->DB->Insert("INSERT INTO versandpakete (id,versand,gewicht,nr,versender) VALUES ('','$id','$kg','$anzahli','".$this->app->User->GetName()."')"); } } diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 9ebae57e..d744b05d 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -1,65 +1,69 @@ app->DB->Select("SELECT lieferschein FROM versand WHERE id='$id' LIMIT 1"); - $rechnung = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$id' LIMIT 1"); + $lieferscheinId = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$id' LIMIT 1"); + $rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$id' LIMIT 1"); $sid = 'lieferschein'; } else { - $tid = $id; + $lieferscheinId = $id; if($sid === 'lieferschein'){ - $rechnung = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein = '$tid' LIMIT 1"); + $rechnungId = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein = '$lieferscheinId' LIMIT 1"); } - if($rechnung<=0) { - $rechnung = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$tid' LIMIT 1"); + if($rechnungId<=0) { + $rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1"); } } - $ret['tid'] = $tid; - $ret['rechnung'] = $rechnung; + $ret['lieferscheinId'] = $lieferscheinId; + $ret['rechnungId'] = $rechnungId; - if($rechnung){ - $artikel_positionen = $this->app->DB->SelectArr("SELECT * FROM rechnung_position WHERE rechnung='$rechnung'"); + if($rechnungId){ + $artikel_positionen = $this->app->DB->SelectArr("SELECT * FROM rechnung_position WHERE rechnung='$rechnungId'"); } else { - $artikel_positionen = $this->app->DB->SelectArr(sprintf('SELECT * FROM `%s` WHERE `%s` = %d',$sid.'_position',$sid,$tid)); + $artikel_positionen = $this->app->DB->SelectArr(sprintf('SELECT * FROM `%s` WHERE `%s` = %d',$sid.'_position',$sid,$lieferscheinId)); } if($sid==='rechnung' || $sid==='lieferschein' || $sid==='adresse') { - $docArr = $this->app->DB->SelectRow(sprintf('SELECT * FROM `%s` WHERE id = %d LIMIT 1',$sid, $tid)); + $docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $lieferscheinId LIMIT 1"); - $name = trim($docArr['name']);//trim($this->app->DB->Select("SELECT name FROM $sid WHERE id='$tid' LIMIT 1")); - $name2 = trim($docArr['adresszusatz']);//trim($this->app->DB->Select("SELECT adresszusatz FROM $sid WHERE id='$tid' LIMIT 1")); + $name = trim($docArr['name']); + $name2 = trim($docArr['adresszusatz']); $abt = 0; if($name2==='') { - $name2 = trim($docArr['abteilung']);//trim($this->app->DB->Select("SELECT abteilung FROM $sid WHERE id='$tid' LIMIT 1")); + $name2 = trim($docArr['abteilung']); $abt=1; } - $name3 = trim($docArr['ansprechpartner']);//trim($this->app->DB->Select("SELECT ansprechpartner FROM $sid WHERE id='$tid' LIMIT 1")); + $name3 = trim($docArr['ansprechpartner']); if($name3==='' && $abt!==1){ - $name3 = trim($docArr['abteilung']);//trim($this->app->DB->Select("SELECT abteilung FROM $sid WHERE id='$tid' LIMIT 1")); + $name3 = trim($docArr['abteilung']); } //unterabteilung versuchen einzublenden if($name2==='') { - $name2 = trim($docArr['unterabteilung']);//trim($this->app->DB->Select("SELECT unterabteilung FROM $sid WHERE id='$tid' LIMIT 1")); + $name2 = trim($docArr['unterabteilung']); } else if ($name3==='') { - $name3 = trim($docArr['unterabteilung']);//trim($this->app->DB->Select("SELECT unterabteilung FROM $sid WHERE id='$tid' LIMIT 1")); + $name3 = trim($docArr['unterabteilung']); } if($name3!=='' && $name2==='') { @@ -67,10 +71,10 @@ class Versanddienstleister { $name3=''; } - $ort = trim($docArr['ort']);//trim($this->app->DB->Select("SELECT ort FROM $sid WHERE id='$tid' LIMIT 1")); - $plz = trim($docArr['plz']);//trim($this->app->DB->Select("SELECT plz FROM $sid WHERE id='$tid' LIMIT 1")); - $land = trim($docArr['land']);//trim($this->app->DB->Select("SELECT land FROM $sid WHERE id='$tid' LIMIT 1")); - $strasse = trim($docArr['strasse']);//trim($this->app->DB->Select("SELECT strasse FROM $sid WHERE id='$tid' LIMIT 1")); + $ort = trim($docArr['ort']); + $plz = trim($docArr['plz']); + $land = trim($docArr['land']); + $strasse = trim($docArr['strasse']); $strassekomplett = $strasse; $hausnummer = trim($this->app->erp->ExtractStreetnumber($strasse)); @@ -82,26 +86,22 @@ class Versanddienstleister { $strasse = trim($hausnummer); $hausnummer = ''; } - $telefon = trim($docArr['telefon']);//trim($this->app->DB->Select("SELECT telefon FROM $sid WHERE id='$tid' LIMIT 1")); - $email = trim($docArr['email']);//trim($this->app->DB->Select("SELECT email FROM $sid WHERE id='$tid' LIMIT 1")); + $telefon = trim($docArr['telefon']); + $email = trim($docArr['email']); + $ret['order_number'] = $docArr['auftrag']; + $ret['addressId'] = $docArr['adresse']; } // wenn rechnung im spiel entweder durch versand oder direkt rechnung - if($rechnung >0) + if($rechnungId >0) { - $zahlungsweise = $this->app->DB->Select("SELECT zahlungsweise FROM rechnung WHERE id='$rechnung' LIMIT 1"); - $soll = $this->app->DB->Select("SELECT soll FROM rechnung WHERE id='$rechnung' LIMIT 1"); + $invoice_data = $this->app->DB->SelectRow("SELECT zahlungsweise, soll, belegnr FROM rechnung WHERE id='$rechnungId' LIMIT 1"); + $ret['zahlungsweise'] = $invoice_data['zahlungsweise']; + $ret['betrag'] = $invoice_data['soll']; + $ret['invoice_number'] = $invoice_data['belegnr']; - if($zahlungsweise==='nachnahme'){ - $nachnahme = true; - } - - if($soll >= 500 && $soll <= 2500){ - $versichert = true; - } - - if($soll > 2500) { - $extraversichert = true; + if($invoice_data['zahlungsweise']==='nachnahme'){ + $ret['nachnahme'] = true; } } @@ -109,11 +109,8 @@ class Versanddienstleister { if(isset($inhalt))$ret['inhalt'] = $inhalt; if(isset($keinealtersabfrage))$ret['keinealtersabfrage'] = $keinealtersabfrage; if(isset($altersfreigabe))$ret['altersfreigabe'] = $altersfreigabe; - if(isset($zahlungsweise))$ret['zahlungsweise'] = $zahlungsweise; if(isset($versichert))$ret['versichert'] = $versichert; - if(isset($soll))$ret['betrag'] = $soll; if(isset($extraversichert))$ret['extraversichert'] = $extraversichert; - if(isset($nachnahme))$ret['nachnahme'] = $nachnahme; $ret['name'] = $name; $ret['name2'] = $name2; $ret['name3'] = $name3; @@ -139,12 +136,11 @@ class Versanddienstleister { } if($sid==="lieferschein"){ - $standardkg = $this->app->erp->VersandartMindestgewicht($tid); + $standardkg = $this->app->erp->VersandartMindestgewicht($lieferscheinId); } else{ $standardkg = $this->app->erp->VersandartMindestgewicht(); } - //$this->app->erp->PaketmarkeGewichtForm($anzahl, $standardkg, $this->VersandartMindestgewicht()); $ret['standardkg'] = $standardkg; $ret['anzahl'] = $anzahl; return $ret; @@ -328,29 +324,15 @@ class Versanddienstleister { return ''; } + protected abstract function EinstellungenStruktur(); + /** * @param string $target * * @return bool */ - public function checkInputParameters($target = '') + public function checkInputParameters(string $target = ''): bool { - $error = ''; - if (trim($this->app->Secure->GetPOST('bezeichnung')) === '') { - $error = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGBEZEICHNUNG','Pflichtfeld!'); - } - if (trim($this->app->Secure->GetPOST('typ')) === '') { - $error = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGTYP','Pflichtfeld!'); - } - - if ($error !== '') { - $this->app->Tpl->Add($target, sprintf('
%s
', $error)); - - return false; - } - return true; } @@ -414,5 +396,9 @@ class Versanddienstleister { $link = ''; return true; } + + public function Paketmarke(string $target, string $doctype, int $docid): void { + + } } diff --git a/www/lib/versandarten/content/versandarten_sendcloud.tpl b/www/lib/versandarten/content/versandarten_sendcloud.tpl index b52f65b5..4881a604 100644 --- a/www/lib/versandarten/content/versandarten_sendcloud.tpl +++ b/www/lib/versandarten/content/versandarten_sendcloud.tpl @@ -1,79 +1,57 @@ -

- -
-
-
-[ERROR] -

{|Paketmarken Drucker für|} [ZUSATZ]

-
-{|Empfänger|} -
-
- -
+
+
+
+ + [ERROR] +

{|Paketmarken Drucker für|} SendCloud

+
+
+

{|Empfänger|}

+ + + + + + + -
{|Name|}:
{|Name 2|}:
{|Name 3|}:
{|Land|}:
{|PLZ/Ort|}: 
{|Strasse/Hausnummer|}: 
- - - + + - - - - - - - -[PRODUCT_LIST] - - - - - - - - - -
{|Name|}:
{|Name 2|}:
{|Name 3|}:
{|E-Mail|}:
{|Telefon|}:
{|Land|}:[EPROO_SELECT_LAND]
{|PLZ/Ort|}: 
{|Strasse/Hausnummer|}: 
{|E-Mail|}:
{|Telefon|}:
 
{|Bundesland|}:[EPROO_SELECT_BUNDESSTAAT]
{|Bundesland|}:
{|Rechnungsnummer|}:
{|Sendungsart|}:
{|Extra Versicherung|}:
{|Versicherungssumme|}:
- - -[GEWICHT] - - - - - - - - - - - - -
{|Höhe (in cm)|}: - -
{|Breite (in cm)|}: - -
{|Länge (in cm)|}: - -
- -
- -

-
  -[TRACKINGMANUELL] -   -
-
-
- -

-
+ {|Bundesland|}: + + +
+

{|Paket|}

+ + + + + + +
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}:[METHODS]
+
+
+
+

{|Bestellung|}

+ + + + + +
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}:
{|Versicherungssumme|}:
+
+
+   + [TRACKINGMANUELL] +   +
+ + \ No newline at end of file diff --git a/www/lib/versandarten/dhl.php b/www/lib/versandarten/dhl.php_ similarity index 100% rename from www/lib/versandarten/dhl.php rename to www/lib/versandarten/dhl.php_ diff --git a/www/lib/versandarten/dhlversenden.php b/www/lib/versandarten/dhlversenden.php_ similarity index 100% rename from www/lib/versandarten/dhlversenden.php rename to www/lib/versandarten/dhlversenden.php_ diff --git a/www/lib/versandarten/internetmarke.php b/www/lib/versandarten/internetmarke.php_ similarity index 100% rename from www/lib/versandarten/internetmarke.php rename to www/lib/versandarten/internetmarke.php_ diff --git a/www/lib/versandarten/parcelone.php b/www/lib/versandarten/parcelone.php_ similarity index 100% rename from www/lib/versandarten/parcelone.php rename to www/lib/versandarten/parcelone.php_ diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php new file mode 100644 index 00000000..c61bfb3a --- /dev/null +++ b/www/lib/versandarten/sendcloud.php @@ -0,0 +1,151 @@ +app = $app; + $this->id = $id; + + //TODO move to better place + $res = $this->app->DB->SelectRow("SELECT * FROM versandarten WHERE id=$this->id"); + $this->settings = json_decode($res['einstellungen_json']); + $this->type = $res['type']; + $this->paketmarke_drucker = $res['paketmarke_drucker']; + + $this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key); + } + + protected function FetchOptionsFromApi() + { + $list = $this->api->GetSenderAddresses(); + foreach ($list as $item) { + /* @var SenderAddress $item */ + $senderAddresses[$item->Id] = $item; + } + $senderCountry = $senderAddresses[$this->settings->sender_address]->Country ?? 'DE'; + $list = $this->api->GetShippingProducts($senderCountry); + foreach ($list as $item) { + /* @var ShippingProduct $item */ + $shippingProducts[$item->Code] = $item; + } + + $this->options['senders'] = array_map(fn(SenderAddress $x) => strval($x), $senderAddresses ?? []); + $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); + $this->options['products'][0] = ''; + $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product]; + asort($this->options['products']); + } + + protected function EinstellungenStruktur() + { + $this->FetchOptionsFromApi(); + return [ + 'public_key' => ['typ' => 'text', 'bezeichnung' => 'API Public Key:'], + 'private_key' => ['typ' => 'text', 'bezeichnung' => 'API Private Key:'], + 'sender_address' => ['typ' => 'select', 'bezeichnung' => 'Absender-Adresse:', 'optionen' => $this->options['senders']], + 'shipping_product' => ['typ' => 'select', 'bezeichnung' => 'Versand-Produkt:', 'optionen' => $this->options['products']], + ]; + } + + public function Paketmarke(string $target, string $doctype, int $docid): void + { + $address = $this->GetAdressdaten($docid, $doctype); + $submit = false; + + if ($this->app->Secure->GetPOST('drucken') != '') { + $submit = true; + $parcel = new ParcelCreation(); + $parcel->SenderAddressId = $this->settings->sender_address; + $parcel->ShippingMethodId = $this->app->Secure->GetPOST('method'); + $parcel->Name = $this->app->Secure->GetPOST('name'); + $parcel->CompanyName = $this->app->Secure->GetPOST('name3'); + $parcel->Country = $this->app->Secure->GetPOST('land'); + $parcel->PostalCode = $this->app->Secure->GetPOST('plz'); + $parcel->City = $this->app->Secure->GetPOST('ort'); + $parcel->Address = $this->app->Secure->GetPOST('strasse'); + $parcel->Address2 = $this->app->Secure->GetPOST('name2'); + $parcel->HouseNumber = $this->app->Secure->GetPOST('hausnummer'); + $parcel->EMail = $this->app->Secure->GetPOST('email'); + $parcel->Telephone = $this->app->Secure->GetPOST('phone'); + $parcel->CountryState = $this->app->Secure->GetPOST('state'); + $parcel->CustomsInvoiceNr = $this->app->Secure->GetPOST('rechnungsnummer'); + $parcel->CustomsShipmentType = $this->app->Secure->GetPOST('sendungsart'); + $parcel->TotalInsuredValue = (int)$this->app->Secure->GetPOST('versicherungssumme'); + $parcel->OrderNumber = $this->app->Secure->GetPOST('bestellnummer'); + $weight = $this->app->Secure->GetPOST('weight'); + $parcel->Weight = floatval($weight) * 1000; + $result = $this->api->CreateParcel($parcel); + if ($result instanceof ParcelResponse) { + $sql = "INSERT INTO versand + (adresse, lieferschein, versandunternehmen, gewicht, tracking, tracking_link, anzahlpakete) + VALUES + ({$address['addressId']}, {$address['lieferscheinId']}, '$this->type', + '$weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; + $this->app->DB->Insert($sql); + $this->app->Tpl->addMessage('info', "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"); + + $doc = $result->GetDocumentByType(Document::TYPE_LABEL); + $filename = $this->app->erp->GetTMP().join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]).'.pdf'; + file_put_contents($filename, $this->api->DownloadDocument($doc)); + $this->app->printer->Drucken($this->paketmarke_drucker, $filename); + } else { + $this->app->Tpl->addMessage('error', $result); + } + } + + $this->app->Tpl->Set('NAME', $submit ? $this->app->Secure->GetPOST('name') : $address['name']); + $this->app->Tpl->Set('NAME2', $submit ? $this->app->Secure->GetPOST('name2') : $address['name2']); + $this->app->Tpl->Set('NAME3', $submit ? $this->app->Secure->GetPOST('name3') : $address['name3']); + $this->app->Tpl->Set('LAND', $this->app->erp->SelectLaenderliste($submit ? $this->app->Secure->GetPOST('land') : $address['land'])); + $this->app->Tpl->Set('PLZ', $submit ? $this->app->Secure->GetPOST('plz') : $address['plz']); + $this->app->Tpl->Set('ORT', $submit ? $this->app->Secure->GetPOST('ort') : $address['ort']); + $this->app->Tpl->Set('STRASSE', $submit ? $this->app->Secure->GetPOST('strasse') : $address['strasse']); + $this->app->Tpl->Set('HAUSNUMMER', $submit ? $this->app->Secure->GetPOST('hausnummer') : $address['hausnummer']); + $this->app->Tpl->Set('EMAIL', $submit ? $this->app->Secure->GetPOST('email') : $address['email']); + $this->app->Tpl->Set('TELEFON', $submit ? $this->app->Secure->GetPOST('phone') : $address['phone']); + $this->app->Tpl->Set('WEIGHT', $submit ? $this->app->Secure->GetPOST('weight') : $address['standardkg']); + $this->app->Tpl->Set('LENGTH', $submit ? $this->app->Secure->GetPOST('length') : ''); + $this->app->Tpl->Set('WIDTH', $submit ? $this->app->Secure->GetPOST('width') : ''); + $this->app->Tpl->Set('HEIGHT', $submit ? $this->app->Secure->GetPOST('height') : ''); + $this->app->Tpl->Set('ORDERNUMBER', $submit ? $this->app->Secure->GetPOST('order_number') : $address['order_number']); + $this->app->Tpl->Set('INVOICENUMBER', $submit ? $this->app->Secure->GetPOST('invoice_number') : $address['invoice_number']); + + $method = $this->app->Secure->GetPOST('method'); + $this->FetchOptionsFromApi(); + /** @var ShippingProduct $product */ + $product = $this->options['selectedProduct']; + $methods = []; + /** @var ShippingMethod $item */ + foreach ($product->ShippingMethods as $item) + $methods[$item->Id] = $item->Name; + $this->app->Tpl->addSelect('METHODS', 'method', 'method', $methods, $method); + $this->app->Tpl->Parse($target, 'versandarten_sendcloud.tpl'); + } + +} \ No newline at end of file diff --git a/www/lib/versandarten/sonstiges.php b/www/lib/versandarten/sonstiges.php_ similarity index 100% rename from www/lib/versandarten/sonstiges.php rename to www/lib/versandarten/sonstiges.php_ diff --git a/www/pages/content/versandarten_edit.tpl b/www/pages/content/versandarten_edit.tpl index 1af4eafb..fcb65535 100644 --- a/www/pages/content/versandarten_edit.tpl +++ b/www/pages/content/versandarten_edit.tpl @@ -1,46 +1,86 @@ -
- -
- [MESSAGE] -
- [FORMHANDLEREVENT] -
- {|Einstellungen|} - - - - - - - - - - - - - [JSON] -
{|Bezeichnung|}: [MSGBEZEICHNUNG]
{|Typ|}:[MSGTYP] {|z.B. dhl,ups,etc.|}
{|Modul|}:
{|Projekt|}:
{|Aktiv|}:{|Aktiv. Nicht mehr verwendete Versandarten können deaktiviert werden.|}
{|Kein Portocheck|}:{|Porto-Check im Auftrag deaktivieren.|}
{|Drucker Paketmarke|}:
{|Drucker Export|}:
{|Versandmail|}:
{|Textvorlage|}:
-
- -
+
    +
  • +
+
+ [MESSAGE] +
+ [FORMHANDLEREVENT] +
+ {|Einstellungen|} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [JSON] +
{|Bezeichnung|}: + + [MSGBEZEICHNUNG] +
{|Typ|}: + + [MSGTYP] + {|z.B. dhl,ups,etc.|} +
{|Modul|}:[SELMODUL]
{|Projekt|}:
{|Aktiv|}: + + {|Aktiv. Nicht mehr verwendete Versandarten können deaktiviert werden.|} +
{|Kein Portocheck|}: + + {|Porto-Check im Auftrag deaktivieren.|} +
{|Drucker Paketmarke|}:[PAKETMARKE_DRUCKER]
{|Drucker Export|}:[EXPORT_DRUCKER]
{|Versandmail|}:[SELVERSANDMAIL]
{|Textvorlage|}:[SELGESCHAEFTSBRIEF_VORLAGE]
+
+ +
-
+
diff --git a/www/pages/content/versandarten_neu.tpl b/www/pages/content/versandarten_neu.tpl index 716f14ab..d6f9727e 100644 --- a/www/pages/content/versandarten_neu.tpl +++ b/www/pages/content/versandarten_neu.tpl @@ -12,17 +12,10 @@
{|Auswahl|}
- +
[MODULEINSTALLIERT]
- [BEFOREMODULESTOBUY] -
- {|Kaufschnittstellen|} - [MODULEVERFUEGBAR] -
-
- [AFTERMODULESTOBUY] [TAB1NEXT] diff --git a/www/pages/lieferschein.php b/www/pages/lieferschein.php index 74a42eb2..b8dc2564 100644 --- a/www/pages/lieferschein.php +++ b/www/pages/lieferschein.php @@ -447,36 +447,20 @@ class Lieferschein extends GenLieferschein function LieferscheinPaketmarke() { - $id = $this->app->Secure->GetGET("id"); + $id = (int)$this->app->Secure->GetGET("id"); - $versandart = $this->app->DB->Select("SELECT versandart FROM lieferschein WHERE id='$id' LIMIT 1"); - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id = '$id' LIMIT 1"); $this->LieferscheinMenu(); $this->app->Tpl->Set('TABTEXT',"Paketmarke"); - $versandart = strtolower($versandart); - $versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND modul != '' AND type = '".$this->app->DB->real_escape_string($versandart)."' AND (projekt = '$projekt' || projekt = 0) ORDER BY projekt DESC LIMIT 1"); - if($versandartenmodul && is_file(dirname(__DIR__).'/lib/versandarten/'.$versandartenmodul[0]['modul'].'.php')) - { - $this->app->erp->Paketmarke('TAB1','lieferschein',"",$versandart); - }else{ - if($versandart=="dpd") - $this->app->erp->PaketmarkeDPDEmbedded('TAB1',"lieferschein"); - else if($versandart=="express_dpd") - $this->app->erp->PaketmarkeDPDEmbedded('TAB1',"lieferschein","express"); - else if($versandart=="export_dpd") - $this->app->erp->PaketmarkeDPDEmbedded('TAB1',"lieferschein","export"); - else if($versandart=="ups") - $this->app->erp->PaketmarkeUPSEmbedded('TAB1',"lieferschein"); - else if($versandart=="fedex") - $this->app->erp->PaketmarkeFEDEXEmbedded('TAB1',"lieferschein"); - else if($versandart=="go") - $this->app->erp->PaketmarkeGo('TAB1',"lieferschein"); - else { - $this->app->erp->Paketmarke('TAB1','lieferschein',"",""); - } - //$this->app->erp->PaketmarkeDHLEmbedded('TAB1',"lieferschein"); - } + $result = $this->app->DB->SelectRow( + "SELECT v.id, v.modul + FROM lieferschein l + LEFT JOIN versandarten v ON (l.versandart=v.type AND v.projekt in (l.projekt, 0)) + WHERE l.id=$id + AND v.aktiv = 1 AND v.ausprojekt = 0 AND v.modul != '' + ORDER BY v.projekt DESC LIMIT 1"); + $versandmodul = $this->app->erp->LoadVersandModul($result['modul'], $result['id']); + $versandmodul->Paketmarke('TAB1', 'lieferschein', $id); $this->app->Tpl->Parse('PAGE',"tabview.tpl"); } diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 890ac976..c80e71a9 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -1,4 +1,4 @@ - +*/ +?> app=$app; + if($intern) { + return; + } + $this->app->ActionHandlerInit($this); + + // ab hier alle Action Handler definieren die das Modul hat + $this->app->ActionHandler("create", "VersandartenCreate"); + $this->app->ActionHandler("edit", "VersandartenEdit"); + $this->app->ActionHandler("list", "VersandartenList"); + $this->app->ActionHandler("delete", "VersandartenDelete"); + $this->app->ActionHandler("copy", 'VersandartenCopy'); + $this->app->ActionHandler('createShipment', 'CreateShipment'); + + $this->app->ActionHandlerListen($app); + } + + public function Install(): void + { + $this->app->erp->GetVersandartAuftrag(); + } + + /** @noinspection PhpUnused */ + public function VersandartenCopy():void + { + $id = (int)$this->app->Secure->GetGET('id'); + $id = $this->app->DB->Select("SELECT `id` FROM `versandarten` WHERE `id` = $id LIMIT 1"); + if(!$id) { + $this->app->Location->execute('index.php?module=versandarten&action=list'); + } + $newId = $this->app->DB->MysqlCopyRow('versandarten', 'id', $id); + if($newId) { + $this->app->DB->Update( + "UPDATE `versandarten` set `aktiv` = 0, `ausprojekt` = 0 WHERE `id` = $newId LIMIT 1" + ); + } + $this->app->Location->execute('index.php?module=versandarten&action=edit&id='.$newId); + } + + /** @noinspection PhpUnused */ + public function VersandartenList(): void + { + $this->app->erp->MenuEintrag('index.php?module=versandarten&action=create','Neue Versandart anlegen'); + $this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Übersicht'); + $this->app->YUI->TableSearch('TAB1','versandarten_list', 'show','','',basename(__FILE__), __CLASS__); + $this->app->Tpl->Parse('PAGE','versandarten_list.tpl'); + } + + public static function TableSearch(Application $app, string $name, array $erlaubtevars): array { // in dieses switch alle lokalen Tabellen (diese Live Tabellen mit Suche etc.) für dieses Modul switch($name) { case 'versandarten_list': - $allowed['versandarten'] = array('list'); - $allowed['einstellungen'] = array('category'); - $isSettingAction = $app->Secure->GetGET('module') === 'einstellungen' + $allowed['versandarten'] = array('list'); + $allowed['einstellungen'] = array('category'); + $isSettingAction = $app->Secure->GetGET('module') === 'einstellungen' || $app->Secure->GetGET('smodule') === 'einstellungen'; - if($isSettingAction) { - $maxrows = 10; - } - $heading = array('Bezeichnung', 'Typ','Modul', 'Projekt', 'Menü'); - $width = array('39%', '20%', '20%','20%','5%'); + if($isSettingAction) { + $maxrows = 10; + } + $heading = array('Bezeichnung', 'Typ','Modul', 'Projekt', 'Menü'); + $width = array('39%', '20%', '20%','20%','5%'); - $findcols = array('v.bezeichnung', 'v.type','v.modul', "if(v.projekt, (SELECT `abkuerzung` FROM `projekt` WHERE `id` = v.projekt), '')",'v.id'); - $searchsql = array('v.bezeichnung', 'v.type','v.modul', 'v.projekt'); + $findcols = array('v.bezeichnung', 'v.type','v.modul', "if(v.projekt, (SELECT `abkuerzung` FROM `projekt` WHERE `id` = v.projekt), '')",'v.id'); + $searchsql = array('v.bezeichnung', 'v.type','v.modul', 'v.projekt'); - $defaultorder = 1; - $defaultorderdesc = 0; + $defaultorder = 1; + $defaultorderdesc = 0; - $menu = "
" - ."" - ."Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">"; - $menu .= " " - ."" - ."Conf->WFconf['defaulttheme']}/images/copy.svg\" border=\"0\">"; - if(!$isSettingAction) { + $menu = "
" + ."" + ."Conf->WFconf['defaulttheme']}/images/edit.svg\" alt=\"edit\" style=\"border: 0\">"; $menu .= " " - . "" - . "Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">"; - } - $menu .= "
"; + ."" + ."Conf->WFconf['defaulttheme']}/images/copy.svg\" alt=\"copy\" style=\"border: 0\">"; + if(!$isSettingAction) { + $menu .= " " + . "" + . "Conf->WFconf['defaulttheme']}/images/delete.svg\" alt=\"delete\" style=\"border: 0\">"; + } + $menu .= "
"; - $where = " v.id > 0 "; + $where = " v.id > 0 "; - $sql = "SELECT SQL_CALC_FOUND_ROWS v.id, if(v.aktiv, v.bezeichnung, CONCAT('',v.bezeichnung,'')), - if(v.aktiv, v.type, CONCAT('',v.type,'')), - if(v.aktiv, v.modul, CONCAT('',v.modul,'')), - if(v.projekt, (SELECT `abkuerzung` FROM `projekt` WHERE `id` = v.projekt), ''), v.id - FROM `versandarten` AS `v`"; + $sql = "SELECT SQL_CALC_FOUND_ROWS v.id, if(v.aktiv, v.bezeichnung, CONCAT('',v.bezeichnung,'')), + if(v.aktiv, v.type, CONCAT('',v.type,'')), + if(v.aktiv, v.modul, CONCAT('',v.modul,'')), + if(v.projekt, (SELECT `abkuerzung` FROM `projekt` WHERE `id` = v.projekt), ''), v.id + FROM `versandarten` AS `v`"; - $count = "SELECT count(v.id) FROM `versandarten` AS `v` WHERE $where"; + $count = "SELECT count(v.id) FROM `versandarten` AS `v` WHERE $where"; break; } @@ -98,494 +145,156 @@ class Versandarten { return $erg; } - /** - * Versandarten constructor. - * - * @param Application $app - * @param bool $intern - */ - public function __construct($app, $intern = false) + /** @noinspection PhpUnused */ + public function VersandartenEdit(): void { - $this->app=$app; - if($intern) { + $id = (int)$this->app->Secure->GetGET('id'); + $save = $this->app->Secure->GetPOST('speichern'); + + if (!$id) return; - } - $this->app->ActionHandlerInit($this); - - // ab hier alle Action Handler definieren die das Modul hat - $this->app->ActionHandler("create", "VersandartenCreate"); - $this->app->ActionHandler("edit", "VersandartenEdit"); - $this->app->ActionHandler("list", "VersandartenList"); - $this->app->ActionHandler("delete", "VersandartenDelete"); - $this->app->ActionHandler("copy", "VersandartenCopy"); - - $this->app->ActionHandlerListen($app); - } - - /** - * @return array - */ - public function getBetaShippingModules(): array - { - /** @var Appstore $appStore */ - $appStore = $this->app->erp->LoadModul('appstore'); - - return $appStore->getBetaModulesByPrefix('versandarten_'); - } - - public function Install(): void - { - $this->app->erp->GetVersandartAuftrag(); - } - - public function VersandartenCopy() - { - $id = (int)$this->app->Secure->GetGET('id'); - $id = $this->app->DB->Select(sprintf('SELECT `id` FROM `versandarten` WHERE `id` = %d LIMIT 1', $id)); - if(!$id) { - $this->app->Location->execute('index.php?module=versandarten&action=list'); - } - $newid = $this->app->DB->MysqlCopyRow('versandarten', 'id', $id); - if($newid) { - $this->app->DB->Update( - sprintf( - 'UPDATE `versandarten` set `aktiv` = 0, `ausprojekt` = 0 WHERE `id` = %d LIMIT 1', - $newid - ) - ); - } - $this->app->Location->execute('index.php?module=versandarten&action=edit&id='.$newid); - } - public function VersandartenMenu() - { - - } - - public function VersandartenList(): void - { - $this->app->erp->MenuEintrag('index.php?module=versandarten&action=create','Neue Versandart anlegen'); - $this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Übersicht'); - $this->app->YUI->TableSearch('TAB1','versandarten_list', 'show','','',basename(__FILE__), __CLASS__); - $this->app->Tpl->Parse('PAGE','versandarten_list.tpl'); - } - - /** - * @param string $value - * @param bool $retarr - * - * @return string|array|null - */ - function VersandartenSelModul($value = '', $retarr = false) - { - $array = null; - $ret = ''; - $pfad = dirname(__DIR__).'/lib/versandarten'; - $beta = $this->getBetaShippingModules(); - if(is_dir($pfad)) { - $handle = opendir($pfad); - if($handle) { - while (false !== ($file = readdir($handle))) { - $files[] = $file; - } - natcasesort($files); - foreach($files as $file) { - if($file[0] !== '.' && substr($file,-4) === '.php' && is_file($pfad.'/'.$file) - && substr($file,-8) !== '.src.php') { - $modul = str_replace('.php','',$file); - if(substr($modul,-7) === '_custom' - && !$this->app->DB->Select( - "SELECT `id` FROM `versandarten` WHERE `modul` = '".$this->app->DB->real_escape_string($modul)."' LIMIT 1" - ) - ) { - continue; - } - if($modul!=='rocketshipit' && $modul!='') { - include_once dirname(__DIR__).'/lib/versandarten/'.$modul.'.php'; - } - $classname = 'Versandart_'.$modul; - if(class_exists($classname)) { - try { - $r = new ReflectionMethod($classname, '__construct'); - $params = $r->getParameters(); - $anzargs = (!empty($params)?count($params):0); - } - catch(Exception $e) { - $anzargs = 1; - } - if($anzargs > 1) { - $obj = new $classname($this->app, 0); - } - else{ - $obj = new $classname($this->app); - } - } - $array[$modul] = (isset($obj->name)?$obj->name:ucfirst($modul)); - $modulKey = $modul; - if(strpos($modulKey,'versandarten_') !== 0) { - $modulKey = 'versandarten_'.$modul; - } - $ret .= ''; - unset($obj); - } - } - closedir($handle); - } - } - if($retarr){ - return $array; - } - - return $ret; - } - - /** - * @param string $module - * @param int $moduleId - * - * @return mixed|null - */ - public function loadModule($module, $moduleId = 0) - { - if(empty($module)) { - return null; - } - if(strpos($module,'versandarten_') === 0) { - $module = substr($module, 13); - if(empty($module)) { - return null; - } - } - if(strpos($module, '.') !== false || strpos($module, '/') !== false || strpos($module, '\\')) { - return null; - } - $path = dirname(__DIR__).'/lib/versandarten/'.$module.'.php'; - if(!is_file($path)) { - return null; - } - - include_once $path ; - $classname = 'Versandart_'.$module; - if(!class_exists($classname)) { - return null; - } - - return new $classname($this->app, $moduleId); - } - - public function VersandartenEdit() - { - $id = (int)$this->app->Secure->GetGET('id'); - $speichern = $this->app->Secure->GetPOST('speichern'); $this->app->erp->MenuEintrag('index.php?module=versandarten&action=edit&id='.$id,'Details'); $this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Zurück zur Übersicht'); $input = $this->GetInput(); - $error = ''; - if(is_numeric($id) && $speichern != ''){ - $modulepath = dirname(__DIR__).'/lib/versandarten/'.$input['selmodul'].'.php'; - if (!empty($input['selmodul']) && is_file($modulepath)) { - include_once($modulepath); - $classname = 'Versandart_'.$input['selmodul']; - if(class_exists($classname)) { - $moduleObject = new $classname($this->app, $id); - } - if(!empty($moduleObject) && method_exists($moduleObject, 'checkInputParameters')) { - if (false === $moduleObject->checkInputParameters('MESSAGE')) { - $error = 'error'; - } - } - } else { - $error = sprintf('Versandart "%s" existiert nicht.', $input['selmodul']); + $error = []; + if($save != ''){ + $moduleObject = $this->loadModule($input['selmodul'], $id); + if ($moduleObject === null) + $error[] = sprintf('Versandart "%s" existiert nicht.', $input['selmodul']); + + if(trim($input['bezeichnung']) == '') { + $error[] = 'Bitte alle Pflichtfelder ausfüllen!'; + $this->app->Tpl->Set('MSGBEZEICHNUNG','Pflichtfeld!'); + } + if(trim($input['typ']) == '') + { + $error[] = 'Bitte alle Pflichtfelder ausfüllen!'; + $this->app->Tpl->Set('MSGTYP','Pflichtfeld!'); } - if($id) { - if($error === '') { - $projektid = 0; - if(!empty($input['projekt'])){ - $projektid = $this->app->DB->Select( - sprintf( - "SELECT `id` FROM `projekt` WHERE `abkuerzung` = '%s' LIMIT 1", - $input['projekt'] - ) - ); - } - - $oldtype = $this->app->DB->Select( - sprintf('SELECT `id` FROM `versandarten` WHERE `id` = %d LIMIT 1', $id) - ); - if($oldtype != $input['typ']) - { - while($this->app->DB->Select( - sprintf( - "SELECT `id` FROM `versandarten` WHERE `type` = '%s' AND `id` <> %d LIMIT 1", - $input['typ'], $id - ) - )) - { - $typa = explode('_', $input['typ']); - if((!empty($typa)?(!empty($typa)?count($typa):0):0) == 1 || !is_numeric($typa[count($typa)-1])) - { - $input['typ'] .= '_1'; - }else{ - $counter = $typa[(!empty($typa)?count($typa):0)-1]+1; - unset($typa[(!empty($typa)?count($typa):0)-1]); - $input['typ'] = implode('_', $typa).'_'.$counter; - } - } - } - - $this->app->DB->Update( - sprintf( - "UPDATE `versandarten` - SET `bezeichnung`='%s', `type` ='%s', - `projekt`=%d, `aktiv`=%d, `modul`='%s', - `export_drucker` = %d, - `paketmarke_drucker` = %d, - `ausprojekt` = %d, `versandmail` = %d, - `geschaeftsbrief_vorlage` = %d, - `keinportocheck`=%d - WHERE `id` = %d LIMIT 1", - $input['bezeichnung'], $input['typ'], $projektid,$input['aktiv'],$input['selmodul'], - $input['export_drucker'], $input['paketmarke_drucker'],$input['ausprojekt'], $input['versandmail'], - $input['geschaeftsbrief_vorlage'], $input['keinportocheck'], $id - ) - ); - if($input['aktiv'] == 1){ - $this->app->Tpl->Set('AKTIV', "checked"); - } - if($input['keinportocheck'] == 1){ - $this->app->Tpl->Set('KEINPORTOCHECK', "checked"); - } - $this->app->Tpl->Set('MESSAGE', "
Die Daten wurden erfolgreich gespeichert!
"); - } + $projektid = 0; + if(!empty($input['projekt'])){ + $projektid = $this->app->DB->Select( + "SELECT `id` FROM `projekt` WHERE `abkuerzung` = '{$input['projekt']}' LIMIT 1" + ); } - else { - $error = ''; - if(trim($input['bezeichnung']) == '') - { - $error = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGBEZEICHNUNG',' Pflichtfeld!'); - } - if(trim($input['typ']) == '') - { - $error = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGTYP',' Pflichtfeld!'); - } - - if($error!=''){ - $this->app->Tpl->Set('MESSAGE', "
$error
"); - }else { - - if(trim($input['projekt']) == ''){ - $projektid = 0; - }else{ - $projektid = $this->app->DB->Select( - sprintf( - "SELECT `id` FROM `projekt` WHERE `abkuerzung` = '%s' LIMIT 1", - $input['projekt'] - ) - ); - } - - while($this->app->DB->Select(sprintf("SELECT `id` FROM `versandarten` WHERE `type` = '%s' LIMIT 1", $input['typ']))) { - $typa = explode('_', $input['typ']); - if((!empty($typa)?(!empty($typa)?count($typa):0):0) == 1 || !is_numeric($typa[count($typa)-1])) - { - $input['typ'] .= '_1'; - }else{ - $counter = $typa[(!empty($typa)?count($typa):0)-1]+1; - unset($typa[(!empty($typa)?count($typa):0)-1]); - $input['typ'] = implode('_', $typa).'_'.$counter; - } - } - - $this->app->DB->Insert( - sprintf( - "INSERT INTO `versandarten` - (`bezeichnung`, `type`, `projekt`, `aktiv`, `keinportocheck`, - `modul`,`export_drucker`, `paketmarke_drucker`, - `ausprojekt`,`versandmail`, `geschaeftsbrief_vorlage`) - VALUES ('%s', '%s', %d, %d,%d, - '%s',%d,%d, - %d,%d,%d)", - $input['bezeichnung'], $input['typ'],$projektid, $input['aktiv'], $input['keinportocheck'], - $input['selmodul'],$input['export_drucker'],$input['paketmarke_drucker'], - $input['ausprojekt'], $input['versandmail'], $input['geschaeftsbrief_vorlage'] - ) - ); - - $newid = $this->app->DB->GetInsertID(); - $msg = $this->app->erp->base64_url_encode("
Die Daten wurden erfolgreich gespeichert!
"); - $this->app->Location->execute("index.php?module=versandarten&action=edit&id=$newid&msg=$msg"); - } - } - } - $ausprojekt = 0; - - $daten = $this->app->DB->SelectRow( - sprintf('SELECT * FROM `versandarten` WHERE `id` = %d LIMIT 1', $id) - ); - if(!empty($daten)) { - $this->app->erp->Headlines('', $daten['bezeichnung']); - $this->app->Tpl->Set('AKTMODUL', $daten['modul']); - /** @var Versanddienstleister $obj */ - $obj = $this->loadModule($daten['modul'], $daten['id']); - $bezeichnung = $daten['bezeichnung']; - $typ = $daten['type']; - $projekt = $daten['projekt']; - $aktiv = $daten['aktiv']; - $keinportocheck = $daten['keinportocheck']; - $ausprojekt = $daten['ausprojekt']; - $projektname = $this->app->DB->Select(sprintf('SELECT `abkuerzung` FROM `projekt` WHERE `id` = %d', $projekt)); - if(!empty($obj) && method_exists($obj, 'Einstellungen')) { - $obj->Einstellungen('JSON'); + if ($this->app->DB->Select( + "SELECT `id` FROM `versandarten` WHERE `type` = '{$input['typ']}' AND `id` <> $id LIMIT 1" + )) { + $error[] = 'Typ ist bereits für eine andere Versandart vergeben'; } - if(!empty($obj) && method_exists($obj, 'isEtikettenDrucker')) { - $etikettendrucker = $obj->isEtikettenDrucker(); + + foreach ($error as $e) { + $this->app->Tpl->addMessage('error', $e); + } + + $inputCheckResult = $moduleObject->checkInputParameters('MESSAGE'); + if (empty($error) && $inputCheckResult) { + $this->app->DB->Update( + "UPDATE `versandarten` + SET `bezeichnung`='{$input['bezeichnung']}', `type` ='{$input['typ']}', + `projekt`=$projektid, `aktiv`={$input['aktiv']}, `modul`='{$input['selmodul']}', + `export_drucker` = {$input['export_drucker']}, + `paketmarke_drucker` = {$input['paketmarke_drucker']}, + `ausprojekt` = {$input['ausprojekt']}, `versandmail` = {$input['versandmail']}, + `geschaeftsbrief_vorlage` = {$input['geschaeftsbrief_vorlage']}, + `keinportocheck`={$input['keinportocheck']} + WHERE `id` = $id LIMIT 1" + ); + + if($input['aktiv'] == 1){ + $this->app->Tpl->Set('AKTIV', "checked"); + } + if($input['keinportocheck'] == 1){ + $this->app->Tpl->Set('KEINPORTOCHECK', "checked"); + } + $this->app->Tpl->Set('MESSAGE', "
Die Daten wurden erfolgreich gespeichert!
"); } } - else { - $this->app->Tpl->Set('AKTMODUL',''); - } + $daten = $this->app->DB->SelectRow("SELECT * FROM `versandarten` WHERE `id` = $id LIMIT 1"); + if (empty($daten)) + $this->app->Location->execute('index.php?module=versandarten&action=list'); + + $this->app->erp->Headlines('', $daten['bezeichnung']); + $this->app->Tpl->Set('AKTMODUL', $daten['modul']); + $obj = $this->loadModule($daten['modul'], $daten['id']); + $bezeichnung = $daten['bezeichnung']; + $typ = $daten['type']; + $projekt = $daten['projekt']; + $aktiv = $daten['aktiv']; + $keinportocheck = $daten['keinportocheck']; + $projektname = $this->app->erp->Projektdaten($projekt, 'abkuerzung'); + $obj->Einstellungen('JSON'); + $etikettendrucker = $obj->isEtikettenDrucker(); $drucker_export = $this->app->erp->GetDrucker(); - $this->app->Tpl->Set('EXPORT_DRUCKER',''); - if(!empty($drucker_export)){ - foreach($drucker_export as $k => $v) { - $this->app->Tpl->Add( - 'EXPORT_DRUCKER', - '' - ); - } - } + $drucker_export[0] = ''; + asort($drucker_export); + $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', + $drucker_export, $daten['export_drucker']); $drucker_paketmarke = $this->app->erp->GetDrucker(); - - if($etikettendrucker) { - $etikettendruckerarr = $this->app->erp->GetEtikettendrucker(); - if($etikettendruckerarr) { - foreach($etikettendruckerarr as $k => $v) { - $drucker_paketmarke[$k] = $v; - } - } - } - $this->app->Tpl->Set('PAKETMARKE_DRUCKER',''); - if($drucker_paketmarke) { - foreach($drucker_paketmarke as $k => $v) { - $this->app->Tpl->Add( - 'PAKETMARKE_DRUCKER', - '' - ); - } - } + if($etikettendrucker) + $drucker_paketmarke = array_merge($drucker_paketmarke, $this->app->erp->GetEtikettendrucker()); + $drucker_paketmarke[0] = ''; + asort($drucker_paketmarke); + $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker', + $drucker_paketmarke, $daten['paketmarke_drucker']); + $this->app->YUI->HideFormular('versandmail', array('0'=>'versandbetreff','1'=>'dummy')); - $this->app->Tpl->Add( - 'SELVERSANDMAIL', - ''); - $this->app->Tpl->Add( - 'SELVERSANDMAIL', - '' - ); - $this->app->Tpl->Add( - 'SELVERSANDMAIL', - '' - ); - - $geschaeftsbrief_vorlagen = $this->app->DB->SelectArr( - "SELECT gv.id, gv.subjekt, p.abkuerzung + $this->app->Tpl->addSelect('SELVERSANDMAIL', 'versandmail', 'versandmail', [ + 0 => 'Standardverhalten', + -1 => 'Keine Versandmail', + 1 => 'Eigene Textvorlage' + ], $daten['versandmail']); + + $geschaeftsbrief_vorlagen = $this->app->DB->SelectPairs( + "SELECT gv.id, CONCAT_WS(' - ', gv.subjekt, p.abkuerzung) as val FROM `geschaeftsbrief_vorlagen` AS `gv` LEFT JOIN `projekt` AS `p` ON gv.projekt = p.id ORDER by gv.subjekt" ); - if($geschaeftsbrief_vorlagen) { - foreach($geschaeftsbrief_vorlagen as $k => $v) { - $this->app->Tpl->Add( - 'SELGESCHAEFTSBRIEF_VORLAGE', - '' - ); - } - } - if($error === ''){ - $selectedModule = isset($daten['modul'])?$daten['modul']:''; + + $this->app->Tpl->addSelect('SELGESCHAEFTSBRIEF_VORLAGE', 'geschaeftsbrief_vorlage', + 'geschaeftsbrief_vorlage', $geschaeftsbrief_vorlagen, $daten['geschaeftsbrief_vorlage']); + + if(empty($error)){ + $selectedModule = $daten['modul'] ?? ''; } else { $selectedModule = $input['selmodul']; } - $this->app->Tpl->Set('SELMODUL', $this->VersandartenSelModul($selectedModule)); - - $this->app->Tpl->Set('BEZEICHNUNG', $error == ''?$bezeichnung:$input['bezeichnung']); - $this->app->Tpl->Set('TYP', $error == ''?$typ:$input['typ']); - $this->app->Tpl->Set('PROJEKT', $error == ''?$projektname:$input['projekt']); - if(($error == '' && $aktiv == 1) || ($error != '' && $input['aktiv'])){ + $this->app->Tpl->addSelect('SELMODUL', 'selmodul', 'selmodul', + $this->VersandartenSelModul(), $selectedModule); + $this->app->Tpl->Set('BEZEICHNUNG', empty($error)?$bezeichnung:$input['bezeichnung']); + $this->app->Tpl->Set('TYP', empty($error)?$typ:$input['typ']); + $this->app->Tpl->Set('PROJEKT', empty($error)?$projektname:$input['projekt']); + if((empty($error) && $aktiv == 1) || (!empty($error) && $input['aktiv'])){ $this->app->Tpl->Set('AKTIV', 'checked'); } - if(($error == '' && $keinportocheck == 1) || ($error != '' && $input['keinportocheck'])){ + if((empty($error) && $keinportocheck == 1) || (!empty($error) && $input['keinportocheck'])){ $this->app->Tpl->Set('KEINPORTOCHECK', 'checked'); } $this->app->YUI->AutoComplete('projekt', 'projektname', 1); - if(!empty($daten['modul'])) { - $beta = $this->getBetaShippingModules(); - if(in_array('versandarten_'.$daten['modul'], $beta)) { - $this->app->Tpl->Add('MESSAGE','
Dieses Modul ist noch im Beta Stadium.
'); - /** @var Appstore $appstore */ - $appstore = $this->app->erp->LoadModul('appstore'); - if($appstore !== null){ - $appstore->addBetaToHeadline(); - } - } - } + if ($obj->Beta ?? false) + $this->app->Tpl->Add('MESSAGE','
Dieses Modul ist noch im Beta Stadium.
'); $this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl'); } - /** - * @param string $shippingModule - * - * @return array - */ - public function getPrinterByModule($shippingModule = '') + protected function getPrinterByModule(Versanddienstleister $obj): array { - /** @var Versanddienstleister $obj */ - $obj = empty($shippingModule)?null:$this->loadModule($shippingModule); - $isLabelPrinter = $obj !== null - && method_exists($obj, 'isEtikettenDrucker') - && $obj->isEtikettenDrucker(); + $isLabelPrinter = $obj->isEtikettenDrucker(); $printer = $this->app->erp->GetDrucker(); - if(!is_array($printer)) { - $printer = []; - } - if(!$isLabelPrinter) { - return $printer; - } - $labelPrinter = $this->app->erp->GetEtikettendrucker(); - if(empty($labelPrinter)) { - return $printer; + if ($isLabelPrinter) { + $labelPrinter = $this->app->erp->GetEtikettendrucker(); + $printer = array_merge($printer ?? [], $labelPrinter ?? []); } - - foreach($labelPrinter as $k => $v) { - $printer[$k] = $v; - } - + natcasesort($printer); return $printer; } @@ -594,55 +303,44 @@ class Versandarten { * * @return array */ - public function getVuePrinterOptions($shippingModule = '') + protected function getVuePrinterOptions(string $shippingModule = ''): array { try{ - return VueUtil::keyValueArrayToVueOptions($this->getPrinterByModule($shippingModule)); + $obj = $this->loadModule($shippingModule); + return VueUtil::keyValueArrayToVueOptions($this->getPrinterByModule($obj)); } - catch(Exception $e) { + catch(Exception) { return []; } } - /** - * @return array - */ - public function getVueExportPrinterOptions() + public function getVueExportPrinterOptions(): array { $printer = $this->app->erp->GetDrucker(); - if(empty($printer)) { - return []; - } try{ - return VueUtil::keyValueArrayToVueOptions($printer); + return VueUtil::keyValueArrayToVueOptions($printer ?? []); } - catch(Exception $e) { + catch(Exception) { return []; } } - /** - * @return array - */ public function getVueProjects(): array { $projects = array_merge( [ 0 => '', ], $this->app->DB->SelectPairs( - sprintf( - 'SELECT p.id, p.abkuerzung + "SELECT p.id, p.abkuerzung FROM `projekt` AS `p` - WHERE p.geloescht = 0 %s - ORDER BY p.abkuerzung', - $this->app->erp->ProjektRechte() - ) + WHERE p.geloescht = 0 {$this->app->erp->ProjektRechte()} + ORDER BY p.abkuerzung" ) ); try{ return VueUtil::keyValueArrayToVueOptions($projects); } - catch(Exception $e) { + catch(Exception) { return []; } } @@ -656,7 +354,7 @@ class Versandarten { * * @return JsonResponse */ - public function getStep2Page($shippingModule, $shippingModuleName, $requiredForSubmit = null): JsonResponse + public function getStep2Page(string $shippingModule, string $shippingModuleName, ?array $requiredForSubmit = null): JsonResponse { if($requiredForSubmit === null) { $requiredForSubmit = $this->app->Secure->POST; @@ -688,12 +386,9 @@ class Versandarten { ); } - /** - * @return array - */ - public function getFeatureForm($shippingModule): array + public function getFeatureForm(string $shippingModule): array { - $ret = [ + return [ [ 'id' => 0, 'name' => 'projectGroup', @@ -734,59 +429,28 @@ class Versandarten { ], ], ]; - - return $ret; } + /** @noinspection PhpUnused */ public function VersandartenDelete(): void { - $id = $this->app->Secure->GetGET('id'); - $this->app->DB->Delete(sprintf('DELETE FROM `versandarten` WHERE `id` = %d LIMIT 1', $id)); + $id = (int)$this->app->Secure->GetGET('id'); + $this->app->DB->Delete("DELETE FROM `versandarten` WHERE `id` = $id LIMIT 1"); $msg = $this->app->erp->base64_url_encode("
Die Versandart wurde gelöscht!
"); $this->app->Location->execute("index.php?module=versandarten&action=list&msg=$msg"); } - /** - * @param string $val - * - * @return array|null - */ - public function getApps($val = ''): ?array + public function getApps(): ?array { - $val = (string)$val; - /** @var Appstore $appstore */ - $appstore = $this->app->loadModule('appstore'); - $module = $appstore->getAppsListWithPrefix('versandarten_'); - $modularr = $this->VersandartenSelModul('', true); - if($module) { - if(!empty($module['installiert'])) { - foreach($module['installiert'] as $k => $v) { - $module['installiert'][$k]['match'] = $appstore->match($v['Bezeichnung'], $val); - $module['installiert'][$k]['md5'] = md5($v['Bezeichnung']); - $found[] = $v['key']; - } - } - if(!empty($module['kauf'])) { - foreach($module['kauf'] as $k => $v) { - $module['kauf'][$k]['match'] = $appstore->match($v['Bezeichnung'], $val); - $module['kauf'][$k]['md5'] = md5($v['Bezeichnung']); - $found[] = $v['key']; - } - } - } - if($modularr) { - foreach($modularr as $k => $v) { - if(!isset($found) || !in_array('versandarten_'.$k,$found)) { - $found[] = 'versandarten_'.$k; - $module['installiert'][] = [ - 'md5'=>md5($v), - 'Bezeichnung'=>$v, - 'key'=>'versandarten_'.$k, - 'match'=>$appstore->match($v, $val), - 'Icon'=>'Icons_dunkel_9.gif' - ]; - } - } + $module = []; + $modularr = $this->VersandartenSelModul(); + foreach($modularr as $k => $v) { + $module['installiert'][$k] = [ + 'md5'=>md5($v), + 'Bezeichnung'=>$v, + 'key'=> $k, + 'Icon'=>'Icons_dunkel_9.gif' + ]; } if(!empty($module['installiert']) && count($module['installiert']) > 0) { $sort = null; @@ -800,14 +464,9 @@ class Versandarten { } - /** - * @var int $shippingMethodId - * - * @return JsonResponse - */ - public function getVueShippingMethodSuccessPage($shippingMethodId): JsonResponse + public function getVueShippingMethodSuccessPage(int $shippingMethodId): JsonResponse { - $succespage = [ + $successpage = [ 'type' => 'defaultPage', 'icon' => 'add-person-icon', 'headline'=> 'Versandart angelegt', @@ -822,7 +481,7 @@ class Versandarten { ]; return new JsonResponse( - ['page'=>$succespage] + ['page'=>$successpage] ); } @@ -839,7 +498,7 @@ class Versandarten { } $form = $obj->getCreateForm(); if(!empty($form)) { - $form[(!empty($form)?count($form):0) - 1]['link'] = [ + $form[(count($form)) - 1]['link'] = [ 'link' => 'index.php?module=versandarten&action=create&auswahl=' . $module, 'title' => 'Expertenmodus', ]; @@ -908,7 +567,7 @@ class Versandarten { } if($step < 2) { $shippingModuleName = $shippingModule; - if(strpos($shippingModuleName, 'versandarten_') === 0) { + if(str_starts_with($shippingModuleName, 'versandarten_')) { $shippingModuleName = substr($shippingModuleName, 13); } $shippingModuleName = str_replace('_', ' ', ucfirst($shippingModuleName)); @@ -946,7 +605,7 @@ class Versandarten { ); } elseif(!empty($createShippingResult['error'])) { - return new JsonResponse($createShippingResult, JsonResponse::HTTP_BAD_REQUEST); + return new JsonResponse($createShippingResult, Response::HTTP_BAD_REQUEST); } } @@ -955,7 +614,7 @@ class Versandarten { return $this->getVueShippingMethodSuccessPage((int)$shippingMethodId); } - return new JsonResponse($data, JsonResponse::HTTP_BAD_REQUEST); + return new JsonResponse($data, Response::HTTP_BAD_REQUEST); } @@ -963,7 +622,7 @@ class Versandarten { * @param int $shippingMethodId * @param null|array $post */ - public function saveCreateData($shippingMethodId, $post = null): void + public function saveCreateData(int $shippingMethodId, ?array $post = null): void { $shippingMethod = $this->app->DB->SelectRow( sprintf('SELECT * FROM `versandarten` WHERE `id` = %d', $shippingMethodId) @@ -983,7 +642,7 @@ class Versandarten { try { $vueFields = VueUtil::getInputNamesFromVuePages($form); } - catch(Exception $e) { + catch(Exception) { $vueFields = []; } foreach($vueFields as $input) { @@ -1005,84 +664,18 @@ class Versandarten { ); } - /** - * @return JsonResponse - */ - public function HandleSearchAjaxAction(): JsonResponse - { - $module = $this->getApps($this->app->Secure->GetPOST('val')); - $anzeigen = ''; - $ausblenden = ''; - if($module) { - if(isset($module['installiert'])) { - foreach($module['installiert'] as $k => $v) { - if($v['match']) - { - if($anzeigen !== '') - { - $anzeigen .= ';'; - } - $anzeigen .= 'm'.md5($v['Bezeichnung']); - }else{ - if($ausblenden !== '') - { - $ausblenden .= ';'; - } - $ausblenden .= 'm'.md5($v['Bezeichnung']); - } - } - } - if(isset($module['kauf'])) { - foreach($module['kauf'] as $k => $v) { - if($v['match']) { - if($anzeigen !== '') - { - $anzeigen .= ';'; - } - $anzeigen .= 'm'.md5($v['Bezeichnung']); - } - else{ - if($ausblenden !== '') - { - $ausblenden .= ';'; - } - $ausblenden .= 'm'.md5($v['Bezeichnung']); - } - } - } - } - $data = [ - 'anzeigen' => $anzeigen, - 'ausblenden' => $ausblenden, - ]; - - return new JsonResponse($data); - } - /** * @param string $shippingMethodModule * * @return array */ - public function createShippingMethodFromModuleName($shippingMethodModule): array + public function createShippingMethodFromModuleName(string $shippingMethodModule): array { - if(!$this->app->erp->ModulVorhanden($shippingMethodModule)) { - return [ - 'success'=>false, - 'error'=>'Modul nicht vorhanden' - ]; - } - $modules = $this->getApps(); - $modul = substr($shippingMethodModule,13); - $name = ucfirst($modul); - if($modules['installiert']) { - foreach($modules['installiert'] as $key => $installedModule) { - if($installedModule['key'] === $shippingMethodModule && $installedModule['Bezeichnung'] != '') { - $name = $installedModule['Bezeichnung']; - } - } - } - $type = $modul; + $obj = $this->loadModule($shippingMethodModule); + if ($obj === null) + return ['success' => false, 'error' => 'Modul nicht vorhanden']; + $name = $obj->name ?? ucfirst($shippingMethodModule); + $type = $shippingMethodModule; $i = 1; $originalName = $name; while( @@ -1094,7 +687,7 @@ class Versandarten { ) ) { $i++; - $type = $modul.'_'.$i; + $type = $shippingMethodModule.'_'.$i; $name = $originalName.' '.$i; } $versandmail = 0; @@ -1102,12 +695,9 @@ class Versandarten { $versandmail = 1; } $this->app->DB->Insert( - sprintf( "INSERT INTO `versandarten` (`bezeichnung`, `type`,`aktiv`, `geloescht`, `modul`,`ausprojekt`, `versandmail`, `einstellungen_json`) - VALUES ('%s','%s','1','0','%s','0', %d,'')", - $name, $type, $modul, $versandmail - ) + VALUES ('$name','$type','1','0','$shippingMethodModule','0', $versandmail,'')" ); $id = $this->app->DB->GetInsertID(); $this->app->erp->RunHook('versandarten_create', 1, $id); @@ -1117,6 +707,7 @@ class Versandarten { /** * @return JsonResponse|void + * @noinspection PhpUnused */ public function VersandartenCreate() { @@ -1128,81 +719,22 @@ class Versandarten { return $this->HandleSaveAssistantAjaxAction(); } - if($cmd === 'suche') { - return $this->HandleSearchAjaxAction(); - } - $module = $this->getApps($this->app->Secure->GetPOST('val')); - if($this->app->Secure->GetGET('auswahl')) { - //$bezeichnung = $this->app->Secure->GetPOST('bezeichnung'); - $auswahlmodul = $this->app->Secure->GetGET('auswahl'); - if($auswahlmodul === 'custom') { - $this->app->DB->Insert( - "INSERT INTO `versandarten` - (`bezeichnung`, `type`,`aktiv`, `geloescht`, `modul`,`ausprojekt`,`einstellungen_json`) - VALUES ('','','1','0','','0','')" - ); - $id = $this->app->DB->GetInsertID(); - $this->app->Location->execute('index.php?module=versandarten&action=edit&id='.$id); - } - if($this->app->erp->ModulVorhanden($auswahlmodul)) { - $ret = $this->createShippingMethodFromModuleName($auswahlmodul); - if(!empty($ret['id'])) { - $this->app->Location->execute('index.php?module=versandarten&action=edit&id='.$ret['id']); - } - $this->app->Location->execute('index.php?module=versandarten&action=create'); + $modulelist = $this->VersandartenSelModul(); + $auswahlmodul = $this->app->Secure->GetGET('auswahl'); + + if($auswahlmodul && isset($modulelist[$auswahlmodul])) { + $ret = $this->createShippingMethodFromModuleName($auswahlmodul); + if(!empty($ret['id'])) { + $this->app->Location->execute('index.php?module=versandarten&action=edit&id='.$ret['id']); } + $this->app->Location->execute('index.php?module=versandarten&action=create'); } - if($this->app->erp->isIoncube() && $this->app->Secure->GetPOST('testen')) { - $modul = $this->app->Secure->GetPOST('modul'); - if($modul) { - $testapp = $modul; - if(is_file(dirname(__DIR__).'/update.php')) { - $result = ''; - include_once(dirname(__DIR__).'/update.php'); - if($result === 'OK') { - $this->app->Tpl->Add( - 'MESSAGE', - '
Das Modul wurde zum Testen angefragt. Bitte Updaten Sie xentral in frühestens 10 Minuten um das Modul zu laden
' - ); - } - else{ - $this->app->Tpl->Add( - 'MESSAGE', - '
Es ist ein Fehler beim Updaten aufgetreten: '.$result.'
' - ); - } - } - } - } - elseif($this->app->erp->isIoncube()) { - $get = $this->app->Secure->GetGET('get'); - if(!empty($get) && !empty($module) && !empty($module['kauf'])) { - foreach($module['kauf'] as $k => $v) { - if($v['md5'] == $get) { - $mods = $this->app->erp->getAppList(); - foreach($mods as $k2 => $v2) { - if(md5($v2['Bezeichnung']) == $get) { - $this->app->Tpl->Add( - 'MESSAGE', - '
Bitte bestätigen:
' - ); - break; - } - } - } - } - } - } /** @var Appstore $appstore */ $appstore = $this->app->loadModule('appstore'); - $modullist = $this->GetApps(); + $modulelist = $this->GetApps(); $appstore->AddModuleHtml( - $modullist, 'versandarten_', 'index.php?module=versandarten&action=create&get=', - [ - 'title' => 'Custom', - 'link' => 'index.php?module=versandarten&action=create&auswahl=custom', - ] + $modulelist, '', 'index.php?module=versandarten&action=create&get=' ); $this->app->ModuleScriptCache->IncludeWidgetNew('ClickByClickAssistant'); $this->app->Tpl->Parse('PAGE', 'versandarten_neu.tpl'); @@ -1230,23 +762,77 @@ class Versandarten { } /** - * @param array $input + * @param string $module + * @param int $moduleId + * + * @return mixed|null */ - public function SetInput($input): void + public function loadModule(string $module, int $moduleId = 0) : ?Versanddienstleister { - $this->app->Tpl->Set('BEZEICHNUNG', $input['bezeichnung']); - $this->app->Tpl->Set('TYP', $input['typ']); - $this->app->Tpl->Set('PROJEKT', $input['projekt']); - if($input['aktiv']==1){ - $this->app->Tpl->Set('AKTIV', 'checked'); + if(str_starts_with($module, 'versandarten_')) { + $module = substr($module, 13); } - if($input['keinportocheck']==1){ - $this->app->Tpl->Set('KEINPORTOCHECK', 'checked'); + if(empty($module)) { + return null; + } + if(str_contains($module, '.') || str_contains($module, '/') || str_contains($module, '\\')) { + return null; } - if($input['ausprojekt']==1){ - $this->app->Tpl->Set('AUSPROJEKT', 'checked'); + $path = dirname(__DIR__).'/lib/versandarten/'.$module.'.php'; + if(!is_file($path)) { + return null; } + + include_once $path ; + $classname = 'Versandart_'.$module; + if(!class_exists($classname)) { + return null; + } + + return new $classname($this->app, $moduleId); } -} + /** + * Retrieve all Versandarten from lib/versandarten/ + * @return array + */ + function VersandartenSelModul() : array + { + $result = []; + $pfad = dirname(__DIR__).'/lib/versandarten'; + if(!is_dir($pfad)) + return $result; + $handle = opendir($pfad); + $files = []; + if($handle) { + while (($file = readdir($handle)) !== false) { + $files[] = $file; + } + } + closedir($handle); + + foreach($files as $file) { + if(str_starts_with($file, '.') || !str_ends_with($file, '.php') || !is_file($pfad.'/'.$file) + || str_ends_with($file, '.src.php')) + continue; + + $modul = str_replace('.php','',$file); + if(str_ends_with($modul, '_custom') + && !$this->app->DB->Select( + "SELECT `id` FROM `versandarten` WHERE `modul` = '".$this->app->DB->real_escape_string($modul)."' LIMIT 1" + ) + ) + continue; + + if($modul == '' || $modul=='rocketshipit') + continue; + + $obj = $this->loadModule($modul); + $result[$modul] = $obj->name ?? ucfirst($modul); + unset($obj); + } + + return $result; + } +} \ No newline at end of file From 1ddee4350cba50f2a0d6f6644a2eb3f7bd0803d7 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 27 Oct 2022 13:17:19 +0200 Subject: [PATCH 02/16] Refactor and improve Versandarten settings --- phpwf/plugins/class.templateparser.php | 27 +--- www/lib/class.versanddienstleister.php | 192 +++++++++++------------- www/lib/intraship.php | 2 +- www/lib/versandarten/sendcloud.php | 34 +---- www/pages/content/versandarten_edit.tpl | 8 +- www/pages/versandarten.php | 136 ++++++++--------- 6 files changed, 172 insertions(+), 227 deletions(-) diff --git a/phpwf/plugins/class.templateparser.php b/phpwf/plugins/class.templateparser.php index 0c626424..bcb99618 100644 --- a/phpwf/plugins/class.templateparser.php +++ b/phpwf/plugins/class.templateparser.php @@ -1,4 +1,4 @@ - +*/ +?> htmlspecialchars($text); } - $ret .= '
'.$text.'
'; + $ret = sprintf('
%s
', $class, $text); if($_var === 'return') - { return $ret; - } - return $this->app->Tpl->Add($_var, $ret); + + $this->app->Tpl->Add($_var, $ret); } public function addSelect($_var, $id, $name, $options, $selected = '', $class = '') diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index d744b05d..12507829 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -1,9 +1,31 @@ app = $app; + if ($id === null || $id === 0) + return; + $this->id = $id; + $row = $this->app->DB->SelectRow("SELECT * FROM versandarten WHERE id=$this->id"); + $this->type = $row['type']; + $this->projectId = $row['projekt']; + $this->labelPrinterId = $row['paketmarke_drucker']; + $this->documentPrinterId = $row['export_drucker']; + $this->shippingMail = $row['versandmail']; + $this->businessLetterTemplateId = $row['geschaeftsbrief_vorlage']; + $this->settings = json_decode($row['einstellungen_json']); + } + public function isEtikettenDrucker(): bool { return false; @@ -147,18 +169,32 @@ abstract class Versanddienstleister { } /** - * @param string $target + * Returns an array of additional field definitions to be stored for this module: + * [ + * 'field_name' => [ + * 'typ' => text(default)|textarea|checkbox|select + * 'default' => default value + * 'optionen' => just for selects [key=>value] + * 'size' => size attribute for text fields + * 'placeholder' => placeholder attribute for text fields + * ] + * ] * - * @return string + * @return array */ - public function Einstellungen($target = 'return') + public function AdditionalSettings(): array { + return []; + } + + /** + * Renders all additional settings as fields into $target + * @param string $target template placeholder for rendered output + * @param array $form data for form values (from database or form submit) + * @return void + */ + public function RenderAdditionalSettings(string $target, array $form): void { - if(!$this->id) - { - return ''; - } - //$id = $this->id; - $struktur = $this->EinstellungenStruktur(); + $fields = $this->AdditionalSettings(); if($this->app->Secure->GetPOST('speichern')) { $json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '".$this->id."' LIMIT 1"); @@ -168,7 +204,7 @@ abstract class Versanddienstleister { $json = @json_decode($json, true); }else{ $json = array(); - foreach($struktur as $name => $val) + foreach($fields as $name => $val) { if(isset($val['default'])) { @@ -180,7 +216,7 @@ abstract class Versanddienstleister { { $json = null; } - foreach($struktur as $name => $val) + foreach($fields as $name => $val) { if($modul === $this->app->Secure->GetPOST('modul_name')) @@ -201,101 +237,53 @@ abstract class Versanddienstleister { $json_str = $this->app->DB->real_escape_string(json_encode($json)); $this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1"); } - $id = $this->id; $html = ''; - $json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '$id' LIMIT 1"); - if($json) + foreach($fields as $name => $val) // set missing default values { - $json = json_decode($json, true); - }else{ - $json = null; - } - - $changed = false; - foreach($struktur as $name => $val) - { - if(isset($val['default']) && !isset($json[$name])) + if(isset($val['default']) && !isset($form[$name])) { - $changed = true; - $json[$name] = $val['default']; + $form[$name] = $val['default']; } } - if($changed) - { - $json_str = $this->app->DB->real_escape_string(json_encode($json)); - $this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1"); - } - $first = true; - foreach($struktur as $name => $val) + foreach($fields as $name => $val) { if(isset($val['heading'])) - { $html .= ''.html_entity_decode($val['heading']).''; - } - $html .= ''.($first?'':'').(empty($val['bezeichnung'])?$name:$val['bezeichnung']).''; - $typ = 'text'; - if(!empty($val['typ'])) - { - $typ = $val['typ']; - } + + $html .= ''.($val['bezeichnung'] ?? $name).''; if(isset($val['replace'])) { switch($val['replace']) { case 'lieferantennummer': - $json[$name] = $this->app->erp->ReplaceLieferantennummer(0,$json[$name],0); - if($target !== 'return') - { - $this->app->YUI->AutoComplete($name, 'lieferant', 1); - } - break; + $form[$name] = $this->app->erp->ReplaceLieferantennummer(0,$form[$name],0); + $this->app->YUI->AutoComplete($name, 'lieferant', 1); + break; case 'shop': - $json[$name] .= ($json[$name]?' '.$this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '".(int)$json[$name]."'"):''); - if($target !== 'return') - { - $this->app->YUI->AutoComplete($name, 'shopnameid'); - } - break; + $form[$name] .= ($form[$name]?' '.$this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '".(int)$form[$name]."'"):''); + $this->app->YUI->AutoComplete($name, 'shopnameid'); + break; case 'etiketten': - //$json[$name] = $this->app->erp->ReplaceLieferantennummer(0,$json[$name],0); - if($target !== 'return') - { - $this->app->YUI->AutoComplete($name, 'etiketten'); - } - break; - + $this->app->YUI->AutoComplete($name, 'etiketten'); + break; } } - /*if(!isset($json[$name]) && isset($val['default'])) - { - $json[$name] = $val['default']; - }*/ - switch($typ) + switch($val['typ'] ?? 'text') { case 'textarea': - $html .= ''; - break; + $html .= ''; + break; case 'checkbox': - $html .= ''; - break; + $html .= ''; + break; case 'select': - $html .= ''; - break; + $html .= $this->app->Tpl->addSelect('return', $name, $name, $val['optionen'], $form[$name]); + break; case 'submit': if(isset($val['text'])) - { $html .= '
'; - } - break; + break; case 'custom': if(isset($val['function'])) { @@ -305,35 +293,31 @@ abstract class Versanddienstleister { $html .= $this->$tmpfunction(); } } - break; + break; default: - - $html .= ''; + $html .= ''; break; } - if(isset($val['info']) && $val['info'])$html .= ' '.$val['info'].''; + if(isset($val['info']) && $val['info']) + $html .= ' '.$val['info'].''; $html .= ''; - $first = false; - } - - if($target === 'return') { - return $html; } $this->app->Tpl->Add($target, $html); - return ''; } - protected abstract function EinstellungenStruktur(); - - /** - * @param string $target - * - * @return bool - */ - public function checkInputParameters(string $target = ''): bool + /** + * Validate form data for this module + * Form data is passed by reference so replacements (id instead of text) can be performed here as well + * @param array $form submitted form data + * @return array + */ + public function CheckInputParameters(array &$form): array { - return true; + return []; } diff --git a/www/lib/intraship.php b/www/lib/intraship.php index 916d7e14..65fc5837 100644 --- a/www/lib/intraship.php +++ b/www/lib/intraship.php @@ -99,7 +99,7 @@ class Versandart_intraship extends Versanddienstleister{ return 'DHL Instrahship'; } - function EinstellungenStruktur() + function AdditionalSettings() { return array( diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index c61bfb3a..c89e413d 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -12,32 +12,14 @@ require_once dirname(__DIR__) . '/class.versanddienstleister.php'; class Versandart_sendcloud extends Versanddienstleister { + protected SendCloudApi $api; + protected array $options; - /* @var SendCloudApi $api */ - protected $api; - - /* @var array $settings */ - protected $settings; - - protected $options; - - /** - * Versandart_sendcloud constructor. - * - * @param ApplicationCore $app - * @param int $id - */ - public function __construct($app, $id) + public function __construct(Application $app, ?int $id) { - $this->app = $app; - $this->id = $id; - - //TODO move to better place - $res = $this->app->DB->SelectRow("SELECT * FROM versandarten WHERE id=$this->id"); - $this->settings = json_decode($res['einstellungen_json']); - $this->type = $res['type']; - $this->paketmarke_drucker = $res['paketmarke_drucker']; - + parent::__construct($app, $id); + if (!isset($this->id)) + return; $this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key); } @@ -59,10 +41,10 @@ class Versandart_sendcloud extends Versanddienstleister $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); $this->options['products'][0] = ''; $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product]; - asort($this->options['products']); + natcasesort($this->options['products']); } - protected function EinstellungenStruktur() + public function AdditionalSettings(): array { $this->FetchOptionsFromApi(); return [ diff --git a/www/pages/content/versandarten_edit.tpl b/www/pages/content/versandarten_edit.tpl index fcb65535..9d6ea025 100644 --- a/www/pages/content/versandarten_edit.tpl +++ b/www/pages/content/versandarten_edit.tpl @@ -14,15 +14,13 @@ {|Bezeichnung|}: - [MSGBEZEICHNUNG] + data-lang="versandart_bezeichnung_[ID]" required> {|Typ|}: - - [MSGTYP] + {|z.B. dhl,ups,etc.|} @@ -64,7 +62,7 @@ {|Textvorlage|}: [SELGESCHAEFTSBRIEF_VORLAGE] - [JSON] + [MODULESETTINGS] diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index c80e71a9..31d2c812 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -149,7 +149,7 @@ class Versandarten { public function VersandartenEdit(): void { $id = (int)$this->app->Secure->GetGET('id'); - $save = $this->app->Secure->GetPOST('speichern'); + $submit = $this->app->Secure->GetPOST('speichern'); if (!$id) return; @@ -157,62 +157,59 @@ class Versandarten { $this->app->erp->MenuEintrag('index.php?module=versandarten&action=edit&id='.$id,'Details'); $this->app->erp->MenuEintrag('index.php?module=versandarten&action=list','Zurück zur Übersicht'); - $input = $this->GetInput(); - $error = []; - if($save != ''){ - $moduleObject = $this->loadModule($input['selmodul'], $id); - if ($moduleObject === null) - $error[] = sprintf('Versandart "%s" existiert nicht.', $input['selmodul']); + if($submit != '') { // handle form submit + $form = $this->GetInput(); + $obj = $this->loadModule($form['modul'], $id); + if ($obj === null) + $error[] = sprintf('Versandart "%s" existiert nicht.', $form['selmodul']); - if(trim($input['bezeichnung']) == '') { - $error[] = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGBEZEICHNUNG','Pflichtfeld!'); - } - if(trim($input['typ']) == '') - { - $error[] = 'Bitte alle Pflichtfelder ausfüllen!'; - $this->app->Tpl->Set('MSGTYP','Pflichtfeld!'); - } + if(trim($form['bezeichnung']) == '') + $error[] = 'Bitte eine Bezeichnung angeben!'; - $projektid = 0; - if(!empty($input['projekt'])){ - $projektid = $this->app->DB->Select( - "SELECT `id` FROM `projekt` WHERE `abkuerzung` = '{$input['projekt']}' LIMIT 1" + if(trim($form['type']) == '') + $error[] = 'Bitte einen Typ angeben!'; + + $projektId = 0; + if(!empty($form['projekt'])){ + $projektId = $this->app->DB->Select( + "SELECT `id` FROM `projekt` WHERE `abkuerzung` = '{$form['projekt']}' LIMIT 1" ); } if ($this->app->DB->Select( - "SELECT `id` FROM `versandarten` WHERE `type` = '{$input['typ']}' AND `id` <> $id LIMIT 1" - )) { + "SELECT `id` FROM `versandarten` WHERE `type` = '{$form['type']}' AND `id` <> $id LIMIT 1" + )) $error[] = 'Typ ist bereits für eine andere Versandart vergeben'; + + foreach ($obj->AdditionalSettings() as $k => $v) { + $form[$k] = $this->app->Secure->GetPOST($k); } + $error = array_merge($error, $obj->CheckInputParameters($form)); + foreach ($obj->AdditionalSettings() as $k => $v) { + $json[$k] = $form[$k]; + } + $json = json_encode($json ?? null); foreach ($error as $e) { $this->app->Tpl->addMessage('error', $e); } - $inputCheckResult = $moduleObject->checkInputParameters('MESSAGE'); - if (empty($error) && $inputCheckResult) { + if (empty($error)) { $this->app->DB->Update( "UPDATE `versandarten` - SET `bezeichnung`='{$input['bezeichnung']}', `type` ='{$input['typ']}', - `projekt`=$projektid, `aktiv`={$input['aktiv']}, `modul`='{$input['selmodul']}', - `export_drucker` = {$input['export_drucker']}, - `paketmarke_drucker` = {$input['paketmarke_drucker']}, - `ausprojekt` = {$input['ausprojekt']}, `versandmail` = {$input['versandmail']}, - `geschaeftsbrief_vorlage` = {$input['geschaeftsbrief_vorlage']}, - `keinportocheck`={$input['keinportocheck']} + SET `bezeichnung`='{$form['bezeichnung']}', `type` ='{$form['type']}', + `projekt`=$projektId, `aktiv`={$form['aktiv']}, `modul`='{$form['modul']}', + `export_drucker` = {$form['export_drucker']}, + `paketmarke_drucker` = {$form['paketmarke_drucker']}, + `ausprojekt` = {$form['ausprojekt']}, `versandmail` = {$form['versandmail']}, + `geschaeftsbrief_vorlage` = {$form['geschaeftsbrief_vorlage']}, + `keinportocheck`={$form['keinportocheck']}, + einstellungen_json='$json' WHERE `id` = $id LIMIT 1" ); - if($input['aktiv'] == 1){ - $this->app->Tpl->Set('AKTIV', "checked"); - } - if($input['keinportocheck'] == 1){ - $this->app->Tpl->Set('KEINPORTOCHECK', "checked"); - } - $this->app->Tpl->Set('MESSAGE', "
Die Daten wurden erfolgreich gespeichert!
"); + $this->app->Tpl->addMessage('success', "Die Daten wurden erfolgreich gespeichert!"); } } $daten = $this->app->DB->SelectRow("SELECT * FROM `versandarten` WHERE `id` = $id LIMIT 1"); @@ -222,28 +219,34 @@ class Versandarten { $this->app->erp->Headlines('', $daten['bezeichnung']); $this->app->Tpl->Set('AKTMODUL', $daten['modul']); $obj = $this->loadModule($daten['modul'], $daten['id']); - $bezeichnung = $daten['bezeichnung']; - $typ = $daten['type']; - $projekt = $daten['projekt']; - $aktiv = $daten['aktiv']; - $keinportocheck = $daten['keinportocheck']; - $projektname = $this->app->erp->Projektdaten($projekt, 'abkuerzung'); - $obj->Einstellungen('JSON'); - $etikettendrucker = $obj->isEtikettenDrucker(); + + if (empty($error) || !isset($form)) { //overwrite form data from database if no validation error is present + $form = json_decode($daten['einstellungen_json'],true); + $form['bezeichnung'] = $daten['bezeichnung']; + $form['type'] = $daten['type']; + $form['projekt'] = $this->app->erp->Projektdaten($daten['projekt'], 'abkuerzung'); + $form['aktiv'] = $daten['aktiv']; + $form['keinportocheck'] = $daten['keinportocheck']; + $form['modul'] = $daten['modul']; + $form['export_drucker'] = $daten['export_drucker']; + $form['paketmarke_drucker'] = $daten['paketmarke_drucker']; + } + + $obj->RenderAdditionalSettings('MODULESETTINGS', $form); $drucker_export = $this->app->erp->GetDrucker(); $drucker_export[0] = ''; - asort($drucker_export); + natcasesort($drucker_export); $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', - $drucker_export, $daten['export_drucker']); + $drucker_export, $form['export_drucker']); $drucker_paketmarke = $this->app->erp->GetDrucker(); - if($etikettendrucker) + if($obj->isEtikettenDrucker()) $drucker_paketmarke = array_merge($drucker_paketmarke, $this->app->erp->GetEtikettendrucker()); $drucker_paketmarke[0] = ''; - asort($drucker_paketmarke); + natcasesort($drucker_paketmarke); $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker', - $drucker_paketmarke, $daten['paketmarke_drucker']); + $drucker_paketmarke, $form['paketmarke_drucker']); $this->app->YUI->HideFormular('versandmail', array('0'=>'versandbetreff','1'=>'dummy')); $this->app->Tpl->addSelect('SELVERSANDMAIL', 'versandmail', 'versandmail', [ @@ -258,30 +261,19 @@ class Versandarten { LEFT JOIN `projekt` AS `p` ON gv.projekt = p.id ORDER by gv.subjekt" ); - $this->app->Tpl->addSelect('SELGESCHAEFTSBRIEF_VORLAGE', 'geschaeftsbrief_vorlage', 'geschaeftsbrief_vorlage', $geschaeftsbrief_vorlagen, $daten['geschaeftsbrief_vorlage']); - if(empty($error)){ - $selectedModule = $daten['modul'] ?? ''; - } - else { - $selectedModule = $input['selmodul']; - } - $this->app->Tpl->addSelect('SELMODUL', 'selmodul', 'selmodul', - $this->VersandartenSelModul(), $selectedModule); - $this->app->Tpl->Set('BEZEICHNUNG', empty($error)?$bezeichnung:$input['bezeichnung']); - $this->app->Tpl->Set('TYP', empty($error)?$typ:$input['typ']); - $this->app->Tpl->Set('PROJEKT', empty($error)?$projektname:$input['projekt']); - if((empty($error) && $aktiv == 1) || (!empty($error) && $input['aktiv'])){ - $this->app->Tpl->Set('AKTIV', 'checked'); - } - if((empty($error) && $keinportocheck == 1) || (!empty($error) && $input['keinportocheck'])){ - $this->app->Tpl->Set('KEINPORTOCHECK', 'checked'); - } + $this->app->Tpl->addSelect('SELMODUL', 'modul', 'modul', + $this->VersandartenSelModul(), $form['modul']); + $this->app->Tpl->Set('BEZEICHNUNG', $form['bezeichnung']); + $this->app->Tpl->Set('TYPE', $form['type']); + $this->app->Tpl->Set('PROJEKT', $form['projekt']); $this->app->YUI->AutoComplete('projekt', 'projektname', 1); + if($form['aktiv']) $this->app->Tpl->Set('AKTIV', 'checked'); + if($form['keinportocheck']) $this->app->Tpl->Set('KEINPORTOCHECK', 'checked'); if ($obj->Beta ?? false) - $this->app->Tpl->Add('MESSAGE','
Dieses Modul ist noch im Beta Stadium.
'); + $this->app->Tpl->addMessage('warning','Dieses Modul ist noch im Beta Stadium'); $this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl'); } @@ -747,9 +739,9 @@ class Versandarten { { $input = []; $input['bezeichnung'] = $this->app->Secure->GetPOST('bezeichnung'); - $input['typ'] = $this->app->Secure->GetPOST('typ'); + $input['type'] = $this->app->Secure->GetPOST('type'); $input['projekt'] = $this->app->Secure->GetPOST('projekt'); - $input['selmodul'] = $this->app->Secure->GetPOST('selmodul'); + $input['modul'] = $this->app->Secure->GetPOST('modul'); $input['aktiv'] = (int)$this->app->Secure->GetPOST('aktiv'); $input['keinportocheck'] = (int)$this->app->Secure->GetPOST('keinportocheck'); $input['ausprojekt'] = (int)$this->app->Secure->GetPOST('ausprojekt'); From 6a2a16c0a685ad372f540f09aa1d096adfa35b43 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sat, 29 Oct 2022 21:38:28 +0200 Subject: [PATCH 03/16] Sendcloud bugfixes and improvements --- .../Carrier/SendCloud/Data/ParcelCreation.php | 2 +- classes/Carrier/SendCloud/Data/ParcelItem.php | 17 +- classes/Carrier/SendCloud/SendCloudApi.php | 15 +- www/lib/class.versanddienstleister.php | 111 +++---- .../content/versandarten_sendcloud.tpl | 296 ++++++++++++++---- www/lib/versandarten/sendcloud.php | 137 ++++---- www/pages/versandarten.php | 19 +- 7 files changed, 383 insertions(+), 214 deletions(-) diff --git a/classes/Carrier/SendCloud/Data/ParcelCreation.php b/classes/Carrier/SendCloud/Data/ParcelCreation.php index b234ed4c..f975ef9a 100644 --- a/classes/Carrier/SendCloud/Data/ParcelCreation.php +++ b/classes/Carrier/SendCloud/Data/ParcelCreation.php @@ -29,7 +29,7 @@ class ParcelCreation extends ParcelBase 'customs_invoice_nr' => $this->CustomsInvoiceNr, 'customs_shipment_type' => $this->CustomsShipmentType, 'external_reference' => $this->ExternalReference, - 'total_insured_value' => $this->TotalInsuredValue, + 'total_insured_value' => $this->TotalInsuredValue ?? 0, 'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems), 'is_return' => $this->IsReturn, 'length' => $this->Length, diff --git a/classes/Carrier/SendCloud/Data/ParcelItem.php b/classes/Carrier/SendCloud/Data/ParcelItem.php index e85439f9..6fe870fe 100644 --- a/classes/Carrier/SendCloud/Data/ParcelItem.php +++ b/classes/Carrier/SendCloud/Data/ParcelItem.php @@ -14,9 +14,8 @@ class ParcelItem public string $Description; public string $OriginCountry; public float $Price; - public string $PriceCurrency; - public string $Sku; - public string $ProductId; + public ?string $Sku = null; + public ?string $ProductId = null; public function toApiRequest(): array { return [ @@ -24,13 +23,10 @@ class ParcelItem 'weight' => number_format($this->Weight / 1000, 3, '.', null), 'quantity' => $this->Quantity, 'description' => $this->Description, - 'price' => [ - 'value' => $this->Price, - 'currency' => $this->PriceCurrency, - ], + 'value' => $this->Price, 'origin_country' => $this->OriginCountry, - 'sku' => $this->Sku, - 'product_id' => $this->ProductId, + 'sku' => $this->Sku ?? '', + 'product_id' => $this->ProductId ?? '', ]; } @@ -41,8 +37,7 @@ class ParcelItem $obj->Weight = intval(floatval($data->weight)*1000); $obj->Quantity = $data->quantity; $obj->Description = $data->description; - $obj->Price = $data->price->value; - $obj->PriceCurrency = $data->price->currency; + $obj->Price = $data->value; $obj->OriginCountry = $data->origin_country; $obj->Sku = $data->sku; $obj->ProductId = $data->product_id; diff --git a/classes/Carrier/SendCloud/SendCloudApi.php b/classes/Carrier/SendCloud/SendCloudApi.php index e4c79f8b..9099f8de 100644 --- a/classes/Carrier/SendCloud/SendCloudApi.php +++ b/classes/Carrier/SendCloud/SendCloudApi.php @@ -63,19 +63,20 @@ class SendCloudApi return array_map(fn($x) => ShippingProduct::fromApiResponse($x), $response ?? []); } - /** - * @throws Exception - */ public function CreateParcel(ParcelCreation $parcel): ParcelResponse|string|null { $uri = self::PROD_BASE_URI . '/parcels'; $response = $this->sendRequest($uri, null, true, [ 'parcel' => $parcel->toApiRequest() ]); - if (isset($response->parcel)) - return ParcelResponse::fromApiResponse($response->parcel); - if (isset($response->error)) - return $response->error->message; + try { + if (isset($response->parcel)) + return ParcelResponse::fromApiResponse($response->parcel); + if (isset($response->error)) + return $response->error->message; + } catch (Exception $e) { + return $e->getMessage(); + } return null; } diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 12507829..567e2b75 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -26,49 +26,41 @@ abstract class Versanddienstleister { $this->settings = json_decode($row['einstellungen_json']); } - public function isEtikettenDrucker(): bool { return false; } public function GetAdressdaten($id, $sid) { - if($sid==='rechnung'){ + $auftragId = $lieferscheinId = $rechnungId = $versandId = 0; + if($sid==='rechnung') $rechnungId = $id; + if($sid==='lieferschein') { + $lieferscheinId = $id; + $auftragId = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id=$lieferscheinId LIMIT 1"); + $rechnungId = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein = '$lieferscheinId' LIMIT 1"); + if($rechnungId <= 0) + $rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1"); } - else - { - $rechnungId =''; - } - if($sid==='versand') { - $lieferscheinId = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$id' LIMIT 1"); - $rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$id' LIMIT 1"); + $versandId = $id; + $lieferscheinId = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$versandId' LIMIT 1"); + $rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$versandId' LIMIT 1"); $sid = 'lieferschein'; - } else { - $lieferscheinId = $id; - if($sid === 'lieferschein'){ - $rechnungId = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein = '$lieferscheinId' LIMIT 1"); - } - if($rechnungId<=0) { - $rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1"); - } } - $ret['lieferscheinId'] = $lieferscheinId; - $ret['rechnungId'] = $rechnungId; - if($rechnungId){ - $artikel_positionen = $this->app->DB->SelectArr("SELECT * FROM rechnung_position WHERE rechnung='$rechnungId'"); - } else { - $artikel_positionen = $this->app->DB->SelectArr(sprintf('SELECT * FROM `%s` WHERE `%s` = %d',$sid.'_position',$sid,$lieferscheinId)); - } + if ($auftragId <= 0 && $rechnungId > 0) + $auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1"); if($sid==='rechnung' || $sid==='lieferschein' || $sid==='adresse') { - $docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $lieferscheinId LIMIT 1"); + $docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $id LIMIT 1"); + + $addressfields = ['name', 'adresszusatz', 'abteilung', 'ansprechpartner', 'unterabteilung', 'ort', 'plz', + 'strasse', 'land', 'telefon', 'email']; + $ret = array_filter($docArr, fn($key)=>in_array($key, $addressfields), ARRAY_FILTER_USE_KEY); - $name = trim($docArr['name']); $name2 = trim($docArr['adresszusatz']); $abt = 0; if($name2==='') @@ -92,14 +84,12 @@ abstract class Versanddienstleister { $name2=$name3; $name3=''; } + $ret['name2'] = $name2; + $ret['name3'] = $name3; - $ort = trim($docArr['ort']); - $plz = trim($docArr['plz']); - $land = trim($docArr['land']); $strasse = trim($docArr['strasse']); - $strassekomplett = $strasse; + $ret['streetwithnumber'] = $strasse; $hausnummer = trim($this->app->erp->ExtractStreetnumber($strasse)); - $strasse = trim(str_replace($hausnummer,'',$strasse)); $strasse = str_replace('.','',$strasse); @@ -108,12 +98,10 @@ abstract class Versanddienstleister { $strasse = trim($hausnummer); $hausnummer = ''; } - $telefon = trim($docArr['telefon']); - $email = trim($docArr['email']); - - $ret['order_number'] = $docArr['auftrag']; - $ret['addressId'] = $docArr['adresse']; + $ret['strasse'] = $strasse; + $ret['hausnummer'] = $hausnummer; } + // wenn rechnung im spiel entweder durch versand oder direkt rechnung if($rechnungId >0) { @@ -127,35 +115,21 @@ abstract class Versanddienstleister { } } - if(isset($frei))$ret['frei'] = $frei; - if(isset($inhalt))$ret['inhalt'] = $inhalt; - if(isset($keinealtersabfrage))$ret['keinealtersabfrage'] = $keinealtersabfrage; - if(isset($altersfreigabe))$ret['altersfreigabe'] = $altersfreigabe; - if(isset($versichert))$ret['versichert'] = $versichert; - if(isset($extraversichert))$ret['extraversichert'] = $extraversichert; - $ret['name'] = $name; - $ret['name2'] = $name2; - $ret['name3'] = $name3; - $ret['ort'] = $ort; - $ret['plz'] = $plz; - $ret['strasse'] = $strasse; - $ret['strassekomplett'] = $strassekomplett; - $ret['hausnummer'] = $hausnummer; - $ret['land'] = $land; - $ret['telefon'] = $telefon; - $ret['phone'] = $telefon; - $ret['email'] = trim($email," \t\n\r\0\x0B\xc2\xa0"); - - $check_date = $this->app->DB->Select("SELECT date_format(now(),'%Y-%m-%d')"); - - $ret['abholdaumt'] = date('d.m.Y', strtotime($check_date)); - - $anzahl = $this->app->Secure->GetGET("anzahl"); - - if($anzahl <= 0) - { - $anzahl=1; - } + $sql = "SELECT + lp.bezeichnung, + lp.menge, + coalesce(nullif(lp.zolltarifnummer, ''), nullif(rp.zolltarifnummer, ''), nullif(a.zolltarifnummer, '')) zolltarifnummer, + coalesce(nullif(lp.herkunftsland, ''), nullif(rp.herkunftsland, ''), nullif(a.herkunftsland, '')) herkunftsland, + coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100)) zolleinzelwert, + coalesce(nullif(lp.zolleinzelgewicht, 0), a.gewicht) zolleinzelgewicht, + lp.zollwaehrung + FROM lieferschein_position lp + JOIN artikel a on lp.artikel = a.id + LEFT JOIN auftrag_position ap on lp.auftrag_position_id = ap.id + LEFT JOIN rechnung_position rp on ap.id = rp.auftrag_position_id + WHERE lp.lieferschein = $lieferscheinId + ORDER BY lp.sort"; + $ret['positions'] = $this->app->DB->SelectArr($sql); if($sid==="lieferschein"){ $standardkg = $this->app->erp->VersandartMindestgewicht($lieferscheinId); @@ -163,8 +137,7 @@ abstract class Versanddienstleister { else{ $standardkg = $this->app->erp->VersandartMindestgewicht(); } - $ret['standardkg'] = $standardkg; - $ret['anzahl'] = $anzahl; + $ret['weight'] = $standardkg; return $ret; } @@ -315,7 +288,7 @@ abstract class Versanddienstleister { * @param array $form submitted form data * @return array */ - public function CheckInputParameters(array &$form): array + public function ValidateSettings(array &$form): array { return []; } @@ -381,7 +354,7 @@ abstract class Versanddienstleister { return true; } - public function Paketmarke(string $target, string $doctype, int $docid): void { + public function Paketmarke(string $target, string $docType, int $docId): void { } diff --git a/www/lib/versandarten/content/versandarten_sendcloud.tpl b/www/lib/versandarten/content/versandarten_sendcloud.tpl index 4881a604..6ca8a33f 100644 --- a/www/lib/versandarten/content/versandarten_sendcloud.tpl +++ b/www/lib/versandarten/content/versandarten_sendcloud.tpl @@ -1,57 +1,241 @@ -
-
-
-
- [ERROR] -

{|Paketmarken Drucker für|} SendCloud

-
-
-

{|Empfänger|}

- - - - +
+ +
+
{{msg.text}}
+
+

{|Paketmarken Drucker für|} SendCloud

+
+
+

{|Empfänger|}

+
{|Name|}:
{|Name 2|}:
{|Name 3|}:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - -
{|Name|}:
{|Firmenname|}:
{|Strasse/Hausnummer|}: + + +
{|Adresszeile 2|}:
{|PLZ/Ort|}: + +
{|Bundesland|}:
{|Land|}: + +
{|E-Mail|}:
{|Telefon|}:
{|Land|}:
{|PLZ/Ort|}: 
{|Strasse/Hausnummer|}: 
{|E-Mail|}:
{|Telefon|}:
{|Bundesland|}:
-
-
-

{|Paket|}

- - - - - - -
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}:[METHODS]
-
-
-
-

{|Bestellung|}

- - - - - -
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}:
{|Versicherungssumme|}:
-
-
-   - [TRACKINGMANUELL] -   -
-
-
\ No newline at end of file + + +
+

vollst. Adresse

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{|Name|}{{form.name}}
{|Ansprechpartner|}{{form.ansprechpartner}}
{|Abteilung|}{{form.abteilung}}
{|Unterabteilung|}{{form.unterabteilung}}
{|Adresszusatz|}{{form.adresszusatz}}
{|Strasse|}{{form.streetwithnumber}}
{|PLZ/Ort|}{{form.plz}} {{form.ort}}
{|Bundesland|}{{form.bundesland}}
{|Land|}{{form.land}}
+
+
+

{|Paket|}

+ + + + + + + + + + + + + + + + + + + + + +
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}: + +
+
+
+
+

{|Bestellung|}

+ + + + + + + + + + + + + + + + + +
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}: + +
{|Versicherungssumme|}:
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{|Bezeichnung|}{|Menge|}{|HSCode|}{|Herkunftsland|}{|Einzelwert|}{|Einzelgewicht|}{|Währung|}{|Gesamtwert|}{|Gesamtgewicht|} +
{{Number(pos.menge*pos.zolleinzelwert || 0).toFixed(2)}}{{Number(pos.menge*pos.zolleinzelgewicht || 0).toFixed(3)}}
{{total_value.toFixed(2)}}{{total_weight.toFixed(3)}}
+
+
+   +   +
+ + + + \ No newline at end of file diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index c89e413d..41392ae5 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -2,6 +2,7 @@ use Xentral\Carrier\SendCloud\Data\Document; use Xentral\Carrier\SendCloud\Data\ParcelCreation; +use Xentral\Carrier\SendCloud\Data\ParcelItem; use Xentral\Carrier\SendCloud\Data\ParcelResponse; use Xentral\Carrier\SendCloud\SendCloudApi; use Xentral\Carrier\SendCloud\Data\SenderAddress; @@ -21,6 +22,13 @@ class Versandart_sendcloud extends Versanddienstleister if (!isset($this->id)) return; $this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key); + $this->options['customs_shipment_types'] = [ + 0 => 'Geschenk', + 1 => 'Dokumente', + 2 => 'Kommerzielle Waren', + 3 => 'Erprobungswaren', + 4 => 'Rücksendung' + ]; } protected function FetchOptionsFromApi() @@ -40,7 +48,7 @@ class Versandart_sendcloud extends Versanddienstleister $this->options['senders'] = array_map(fn(SenderAddress $x) => strval($x), $senderAddresses ?? []); $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); $this->options['products'][0] = ''; - $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product]; + $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product] ?? []; natcasesort($this->options['products']); } @@ -52,73 +60,84 @@ class Versandart_sendcloud extends Versanddienstleister 'private_key' => ['typ' => 'text', 'bezeichnung' => 'API Private Key:'], 'sender_address' => ['typ' => 'select', 'bezeichnung' => 'Absender-Adresse:', 'optionen' => $this->options['senders']], 'shipping_product' => ['typ' => 'select', 'bezeichnung' => 'Versand-Produkt:', 'optionen' => $this->options['products']], + 'default_customs_shipment_type' => ['typ' => 'select', 'bezeichnung' => 'Sendungsart:', 'optionen' => $this->options['customs_shipment_types']], ]; } - public function Paketmarke(string $target, string $doctype, int $docid): void + public function Paketmarke(string $target, string $docType, int $docId): void { - $address = $this->GetAdressdaten($docid, $doctype); - $submit = false; + $address = $this->GetAdressdaten($docId, $docType); - if ($this->app->Secure->GetPOST('drucken') != '') { - $submit = true; - $parcel = new ParcelCreation(); - $parcel->SenderAddressId = $this->settings->sender_address; - $parcel->ShippingMethodId = $this->app->Secure->GetPOST('method'); - $parcel->Name = $this->app->Secure->GetPOST('name'); - $parcel->CompanyName = $this->app->Secure->GetPOST('name3'); - $parcel->Country = $this->app->Secure->GetPOST('land'); - $parcel->PostalCode = $this->app->Secure->GetPOST('plz'); - $parcel->City = $this->app->Secure->GetPOST('ort'); - $parcel->Address = $this->app->Secure->GetPOST('strasse'); - $parcel->Address2 = $this->app->Secure->GetPOST('name2'); - $parcel->HouseNumber = $this->app->Secure->GetPOST('hausnummer'); - $parcel->EMail = $this->app->Secure->GetPOST('email'); - $parcel->Telephone = $this->app->Secure->GetPOST('phone'); - $parcel->CountryState = $this->app->Secure->GetPOST('state'); - $parcel->CustomsInvoiceNr = $this->app->Secure->GetPOST('rechnungsnummer'); - $parcel->CustomsShipmentType = $this->app->Secure->GetPOST('sendungsart'); - $parcel->TotalInsuredValue = (int)$this->app->Secure->GetPOST('versicherungssumme'); - $parcel->OrderNumber = $this->app->Secure->GetPOST('bestellnummer'); - $weight = $this->app->Secure->GetPOST('weight'); - $parcel->Weight = floatval($weight) * 1000; - $result = $this->api->CreateParcel($parcel); - if ($result instanceof ParcelResponse) { - $sql = "INSERT INTO versand + if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) { + $json = json_decode(file_get_contents('php://input')); + $response = []; + if ($json->submit == 'print') { + header('Content-Type: application/json'); + $parcel = new ParcelCreation(); + $parcel->SenderAddressId = $this->settings->sender_address; + $parcel->ShippingMethodId = $json->method; + $parcel->Name = $json->l_name; + $parcel->CompanyName = $json->l_companyname; + $parcel->Country = $json->land; + $parcel->PostalCode = $json->plz; + $parcel->City = $json->ort; + $parcel->Address = $json->strasse; + $parcel->Address2 = $json->l_address2; + $parcel->HouseNumber = $json->hausnummer; + $parcel->EMail = $json->email; + $parcel->Telephone = $json->telefon; + $parcel->CountryState = $json->bundesland; + $parcel->CustomsInvoiceNr = $json->invoice_number; + $parcel->CustomsShipmentType = $json->sendungsart; + $parcel->TotalInsuredValue = $json->total_insured_value; + $parcel->OrderNumber = $json->order_number; + foreach ($json->positions as $pos) { + $item = new ParcelItem(); + $item->HsCode = $pos->zolltarifnummer; + $item->Description = $pos->bezeichnung; + $item->Quantity = $pos->menge; + $item->OriginCountry = $pos->herkunftsland; + $item->Price = $pos->zolleinzelwert; + $item->Weight = $pos->zolleinzelgewicht * 1000; + $parcel->ParcelItems[] = $item; + } + $parcel->Weight = floatval($json->weight) * 1000; + $result = $this->api->CreateParcel($parcel); + if ($result instanceof ParcelResponse) { + $sql = "INSERT INTO versand (adresse, lieferschein, versandunternehmen, gewicht, tracking, tracking_link, anzahlpakete) VALUES ({$address['addressId']}, {$address['lieferscheinId']}, '$this->type', - '$weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; - $this->app->DB->Insert($sql); - $this->app->Tpl->addMessage('info', "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"); + '$json->weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; + $this->app->DB->Insert($sql); + $response['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; + $response['messages'][] = ['class' => 'info', 'text' => print_r($result, true)]; - $doc = $result->GetDocumentByType(Document::TYPE_LABEL); - $filename = $this->app->erp->GetTMP().join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]).'.pdf'; - file_put_contents($filename, $this->api->DownloadDocument($doc)); - $this->app->printer->Drucken($this->paketmarke_drucker, $filename); - } else { - $this->app->Tpl->addMessage('error', $result); + $doc = $result->GetDocumentByType(Document::TYPE_LABEL); + $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $this->api->DownloadDocument($doc)); + $this->app->printer->Drucken($this->labelPrinterId, $filename); + + $doc = $result->GetDocumentByType(Document::TYPE_CN23); + $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $this->api->DownloadDocument($doc)); + $this->app->printer->Drucken($this->documentPrinterId, $filename); + } else { + $response['messages'][] = ['class' => 'error', 'text' => $result]; + } + echo json_encode($response); + $this->app->ExitXentral(); } } - $this->app->Tpl->Set('NAME', $submit ? $this->app->Secure->GetPOST('name') : $address['name']); - $this->app->Tpl->Set('NAME2', $submit ? $this->app->Secure->GetPOST('name2') : $address['name2']); - $this->app->Tpl->Set('NAME3', $submit ? $this->app->Secure->GetPOST('name3') : $address['name3']); - $this->app->Tpl->Set('LAND', $this->app->erp->SelectLaenderliste($submit ? $this->app->Secure->GetPOST('land') : $address['land'])); - $this->app->Tpl->Set('PLZ', $submit ? $this->app->Secure->GetPOST('plz') : $address['plz']); - $this->app->Tpl->Set('ORT', $submit ? $this->app->Secure->GetPOST('ort') : $address['ort']); - $this->app->Tpl->Set('STRASSE', $submit ? $this->app->Secure->GetPOST('strasse') : $address['strasse']); - $this->app->Tpl->Set('HAUSNUMMER', $submit ? $this->app->Secure->GetPOST('hausnummer') : $address['hausnummer']); - $this->app->Tpl->Set('EMAIL', $submit ? $this->app->Secure->GetPOST('email') : $address['email']); - $this->app->Tpl->Set('TELEFON', $submit ? $this->app->Secure->GetPOST('phone') : $address['phone']); - $this->app->Tpl->Set('WEIGHT', $submit ? $this->app->Secure->GetPOST('weight') : $address['standardkg']); - $this->app->Tpl->Set('LENGTH', $submit ? $this->app->Secure->GetPOST('length') : ''); - $this->app->Tpl->Set('WIDTH', $submit ? $this->app->Secure->GetPOST('width') : ''); - $this->app->Tpl->Set('HEIGHT', $submit ? $this->app->Secure->GetPOST('height') : ''); - $this->app->Tpl->Set('ORDERNUMBER', $submit ? $this->app->Secure->GetPOST('order_number') : $address['order_number']); - $this->app->Tpl->Set('INVOICENUMBER', $submit ? $this->app->Secure->GetPOST('invoice_number') : $address['invoice_number']); + $address['l_name'] = empty(trim($address['ansprechpartner'])) ? trim($address['name']) : trim($address['ansprechpartner']); + $address['l_companyname'] = !empty(trim($address['ansprechpartner'])) ? trim($address['name']) : ''; + $address['l_address2'] = join(';', array_filter([ + $address['abteilung'], + $address['unterabteilung'], + $address['adresszusatz'] + ], fn(string $item) => !empty(trim($item)))); - $method = $this->app->Secure->GetPOST('method'); $this->FetchOptionsFromApi(); /** @var ShippingProduct $product */ $product = $this->options['selectedProduct']; @@ -126,7 +145,13 @@ class Versandart_sendcloud extends Versanddienstleister /** @var ShippingMethod $item */ foreach ($product->ShippingMethods as $item) $methods[$item->Id] = $item->Name; - $this->app->Tpl->addSelect('METHODS', 'method', 'method', $methods, $method); + $address['method'] = array_key_first($methods); + $address['sendungsart'] = $this->settings->default_customs_shipment_type; + + $this->app->Tpl->Set('JSON', json_encode($address)); + $this->app->Tpl->Set('JSON_COUNTRIES', json_encode($this->app->erp->GetSelectLaenderliste())); + $this->app->Tpl->Set('JSON_METHODS', json_encode($methods)); + $this->app->Tpl->Set('JSON_CUSTOMS_SHIPMENT_TYPES', json_encode($this->options['customs_shipment_types'])); $this->app->Tpl->Parse($target, 'versandarten_sendcloud.tpl'); } diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 31d2c812..01cbd46d 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -185,7 +185,7 @@ class Versandarten { foreach ($obj->AdditionalSettings() as $k => $v) { $form[$k] = $this->app->Secure->GetPOST($k); } - $error = array_merge($error, $obj->CheckInputParameters($form)); + $error = array_merge($error, $obj->ValidateSettings($form)); foreach ($obj->AdditionalSettings() as $k => $v) { $json[$k] = $form[$k]; } @@ -234,19 +234,11 @@ class Versandarten { $obj->RenderAdditionalSettings('MODULESETTINGS', $form); - $drucker_export = $this->app->erp->GetDrucker(); - $drucker_export[0] = ''; - natcasesort($drucker_export); $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', - $drucker_export, $form['export_drucker']); + $this->getPrinterByModule($obj, false), $form['export_drucker']); - $drucker_paketmarke = $this->app->erp->GetDrucker(); - if($obj->isEtikettenDrucker()) - $drucker_paketmarke = array_merge($drucker_paketmarke, $this->app->erp->GetEtikettendrucker()); - $drucker_paketmarke[0] = ''; - natcasesort($drucker_paketmarke); $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker', - $drucker_paketmarke, $form['paketmarke_drucker']); + $this->getPrinterByModule($obj), $form['paketmarke_drucker']); $this->app->YUI->HideFormular('versandmail', array('0'=>'versandbetreff','1'=>'dummy')); $this->app->Tpl->addSelect('SELVERSANDMAIL', 'versandmail', 'versandmail', [ @@ -277,12 +269,11 @@ class Versandarten { $this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl'); } - protected function getPrinterByModule(Versanddienstleister $obj): array + protected function getPrinterByModule(Versanddienstleister $obj, bool $includeLabelPrinter = true): array { - $isLabelPrinter = $obj->isEtikettenDrucker(); $printer = $this->app->erp->GetDrucker(); - if ($isLabelPrinter) { + if ($includeLabelPrinter && $obj->isEtikettenDrucker()) { $labelPrinter = $this->app->erp->GetEtikettendrucker(); $printer = array_merge($printer ?? [], $labelPrinter ?? []); } From c5b6f01f9c0e14ce53fc7c39c72ceef82a94a8de Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sat, 29 Oct 2022 21:41:13 +0200 Subject: [PATCH 04/16] Remove debug output --- www/lib/versandarten/sendcloud.php | 1 - 1 file changed, 1 deletion(-) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 41392ae5..1b426290 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -111,7 +111,6 @@ class Versandart_sendcloud extends Versanddienstleister '$json->weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; $this->app->DB->Insert($sql); $response['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; - $response['messages'][] = ['class' => 'info', 'text' => print_r($result, true)]; $doc = $result->GetDocumentByType(Document::TYPE_LABEL); $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; From 1c7e84d8f2628929f05f77b88428282c762c2dbd Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 30 Oct 2022 23:02:42 +0100 Subject: [PATCH 05/16] Versanddienstleister Bugfix --- www/lib/class.versanddienstleister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 567e2b75..0de6e944 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -8,7 +8,7 @@ abstract class Versanddienstleister { protected ?int $documentPrinterId; protected bool $shippingMail; protected ?int $businessLetterTemplateId; - protected object $settings; + protected ?object $settings; public function __construct(Application $app, ?int $id) { From d676a1b09a6fc65a7985ebf1e26ef64f759905f5 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Wed, 2 Nov 2022 22:37:04 +0100 Subject: [PATCH 06/16] Improve Sendcloud error handling --- classes/Carrier/SendCloud/SendCloudApi.php | 72 +++++++++++---- .../SendCloud/SendcloudApiException.php | 18 ++++ www/lib/versandarten/sendcloud.php | 92 ++++++++++--------- www/pages/versandarten.php | 1 + 4 files changed, 122 insertions(+), 61 deletions(-) create mode 100644 classes/Carrier/SendCloud/SendcloudApiException.php diff --git a/classes/Carrier/SendCloud/SendCloudApi.php b/classes/Carrier/SendCloud/SendCloudApi.php index 9099f8de..18f87bff 100644 --- a/classes/Carrier/SendCloud/SendCloudApi.php +++ b/classes/Carrier/SendCloud/SendCloudApi.php @@ -28,16 +28,21 @@ class SendCloudApi $this->private_key = $private_key; } + /** + * @throws SendcloudApiException + */ public function GetSenderAddresses(): array { $uri = self::PROD_BASE_URI . '/user/addresses/sender'; $response = $this->sendRequest($uri); - $res = array(); - foreach ($response->sender_addresses as $item) + foreach ($response['body']->sender_addresses as $item) $res[] = SenderAddress::fromApiResponse($item); - return $res; + return $res ?? []; } + /** + * @throws SendcloudApiException + */ public function GetShippingProducts(string $sourceCountry, ?string $targetCountry = null, ?int $weight = null, ?int $height = null, ?int $length = null, ?int $width = null): array { @@ -60,26 +65,36 @@ class SendCloudApi $params['width_unit'] = 'centimeter'; } $response = $this->sendRequest($uri, $params); - return array_map(fn($x) => ShippingProduct::fromApiResponse($x), $response ?? []); + return array_map(fn($x) => ShippingProduct::fromApiResponse($x), $response['body'] ?? []); } + /** + * @throws SendcloudApiException + */ public function CreateParcel(ParcelCreation $parcel): ParcelResponse|string|null { $uri = self::PROD_BASE_URI . '/parcels'; - $response = $this->sendRequest($uri, null, true, [ - 'parcel' => $parcel->toApiRequest() - ]); - try { - if (isset($response->parcel)) - return ParcelResponse::fromApiResponse($response->parcel); - if (isset($response->error)) - return $response->error->message; - } catch (Exception $e) { - return $e->getMessage(); - } - return null; + $response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]); + switch ($response['code']) { + case 200: + if (isset($response->parcel)) + try { + return ParcelResponse::fromApiResponse($response->parcel); + } catch (Exception $e) { + throw new SendcloudApiException(previous: $e); + } + break; + case 400: + if (isset($response->error)) + return $response->error->message; + break; + } + throw SendcloudApiException::fromResponse($response); } + /** + * @throws SendcloudApiException + */ public function DownloadDocument(Document $document): string { $curl = curl_init(); @@ -90,10 +105,18 @@ class SendCloudApi "Authorization: Basic " . base64_encode($this->public_key . ':' . $this->private_key) ], ]); - return curl_exec($curl); + $output = curl_exec($curl); + $code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE); + if ($code != 200) + throw SendcloudApiException::fromResponse(['code' => $code, 'body' => $output]); + return $output; } - function sendRequest(string $uri, array $query_params = null, bool $post = false, array $postFields = null) + /** + * @throws SendcloudApiException + */ + function sendRequest(string $uri, array $query_params = null, bool $post = false, array $postFields = null, + array $allowedResponseCodes = [200]): ?array { if (empty($this->public_key) || empty($this->private_key)) return null; @@ -117,9 +140,18 @@ class SendCloudApi ]); } - $output = curl_exec($curl); + $output = json_decode(curl_exec($curl)); + $code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE); curl_close($curl); - return json_decode($output); + $ret = [ + 'code' => $code, + 'body' => $output, + ]; + + if (!in_array($code, $allowedResponseCodes)) + throw SendcloudApiException::fromResponse($ret); + + return $ret; } } \ No newline at end of file diff --git a/classes/Carrier/SendCloud/SendcloudApiException.php b/classes/Carrier/SendCloud/SendcloudApiException.php new file mode 100644 index 00000000..247fa9af --- /dev/null +++ b/classes/Carrier/SendCloud/SendcloudApiException.php @@ -0,0 +1,18 @@ +error->message ?? '', + $response['body']->error->code ?? 0 + ); + } +} \ No newline at end of file diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 1b426290..a14e6225 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -8,6 +8,7 @@ use Xentral\Carrier\SendCloud\SendCloudApi; use Xentral\Carrier\SendCloud\Data\SenderAddress; use Xentral\Carrier\SendCloud\Data\ShippingProduct; use Xentral\Carrier\SendCloud\Data\ShippingMethod; +use Xentral\Carrier\SendCloud\SendcloudApiException; require_once dirname(__DIR__) . '/class.versanddienstleister.php'; @@ -22,6 +23,32 @@ class Versandart_sendcloud extends Versanddienstleister if (!isset($this->id)) return; $this->api = new SendCloudApi($this->settings->public_key, $this->settings->private_key); + } + + protected function FetchOptionsFromApi() + { + if (isset($this->options)) + return; + try { + $list = $this->api->GetSenderAddresses(); + foreach ($list as $item) { + /* @var SenderAddress $item */ + $senderAddresses[$item->Id] = $item; + } + $senderCountry = $senderAddresses[$this->settings->sender_address]->Country ?? 'DE'; + $list = $this->api->GetShippingProducts($senderCountry); + foreach ($list as $item) { + /* @var ShippingProduct $item */ + $shippingProducts[$item->Code] = $item; + } + } catch (SendcloudApiException $e) { + $this->app->Tpl->addMessage('error', $e->getMessage()); + } + $this->options['senders'] = array_map(fn(SenderAddress $x) => strval($x), $senderAddresses ?? []); + $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); + $this->options['products'][0] = ''; + $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product] ?? []; + natcasesort($this->options['products']); $this->options['customs_shipment_types'] = [ 0 => 'Geschenk', 1 => 'Dokumente', @@ -31,27 +58,6 @@ class Versandart_sendcloud extends Versanddienstleister ]; } - protected function FetchOptionsFromApi() - { - $list = $this->api->GetSenderAddresses(); - foreach ($list as $item) { - /* @var SenderAddress $item */ - $senderAddresses[$item->Id] = $item; - } - $senderCountry = $senderAddresses[$this->settings->sender_address]->Country ?? 'DE'; - $list = $this->api->GetShippingProducts($senderCountry); - foreach ($list as $item) { - /* @var ShippingProduct $item */ - $shippingProducts[$item->Code] = $item; - } - - $this->options['senders'] = array_map(fn(SenderAddress $x) => strval($x), $senderAddresses ?? []); - $this->options['products'] = array_map(fn(ShippingProduct $x) => $x->Name, $shippingProducts ?? []); - $this->options['products'][0] = ''; - $this->options['selectedProduct'] = $shippingProducts[$this->settings->shipping_product] ?? []; - natcasesort($this->options['products']); - } - public function AdditionalSettings(): array { $this->FetchOptionsFromApi(); @@ -102,29 +108,33 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->ParcelItems[] = $item; } $parcel->Weight = floatval($json->weight) * 1000; - $result = $this->api->CreateParcel($parcel); - if ($result instanceof ParcelResponse) { - $sql = "INSERT INTO versand - (adresse, lieferschein, versandunternehmen, gewicht, tracking, tracking_link, anzahlpakete) - VALUES - ({$address['addressId']}, {$address['lieferscheinId']}, '$this->type', - '$json->weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; - $this->app->DB->Insert($sql); - $response['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; + try { + $result = $this->api->CreateParcel($parcel); + if ($result instanceof ParcelResponse) { + $sql = "INSERT INTO versand + (adresse, lieferschein, versandunternehmen, gewicht, tracking, tracking_link, anzahlpakete) + VALUES + ({$address['addressId']}, {$address['lieferscheinId']}, '$this->type', + '$json->weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; + $this->app->DB->Insert($sql); + $response['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; - $doc = $result->GetDocumentByType(Document::TYPE_LABEL); - $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; - file_put_contents($filename, $this->api->DownloadDocument($doc)); - $this->app->printer->Drucken($this->labelPrinterId, $filename); + $doc = $result->GetDocumentByType(Document::TYPE_LABEL); + $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $this->api->DownloadDocument($doc)); + $this->app->printer->Drucken($this->labelPrinterId, $filename); - $doc = $result->GetDocumentByType(Document::TYPE_CN23); - $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; - file_put_contents($filename, $this->api->DownloadDocument($doc)); - $this->app->printer->Drucken($this->documentPrinterId, $filename); - } else { - $response['messages'][] = ['class' => 'error', 'text' => $result]; + $doc = $result->GetDocumentByType(Document::TYPE_CN23); + $filename = $this->app->erp->GetTMP() . join('_', ['Sendcloud', $doc->Type, $doc->Size, $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $this->api->DownloadDocument($doc)); + $this->app->printer->Drucken($this->documentPrinterId, $filename); + } else { + $response['messages'][] = ['class' => 'error', 'text' => $result]; + } + echo json_encode($response); + } catch (SendcloudApiException $e) { + $this->app->Tpl->addMessage('error', $e->getMessage()); } - echo json_encode($response); $this->app->ExitXentral(); } } diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 01cbd46d..a7651401 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -209,6 +209,7 @@ class Versandarten { WHERE `id` = $id LIMIT 1" ); + $this->app->Tpl->Set('MESSAGE', ''); $this->app->Tpl->addMessage('success', "Die Daten wurden erfolgreich gespeichert!"); } } From 8ad45ed7238a99ca62f799f8a71589941cdfd585 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Mon, 14 Nov 2022 22:29:42 +0100 Subject: [PATCH 07/16] Basic DHL implementation, Refactor redundant code --- classes/Carrier/Dhl/Data/Bank.php | 14 + classes/Carrier/Dhl/Data/Communication.php | 10 + classes/Carrier/Dhl/Data/Contact.php | 10 + classes/Carrier/Dhl/Data/Country.php | 18 + .../Dhl/Data/CreateShipmentOrderRequest.php | 14 + .../Dhl/Data/CreateShipmentOrderResponse.php | 10 + classes/Carrier/Dhl/Data/CreationState.php | 11 + classes/Carrier/Dhl/Data/Customer.php | 14 + .../Dhl/Data/DeleteShipmentOrderRequest.php | 9 + .../Dhl/Data/DeleteShipmentOrderResponse.php | 10 + classes/Carrier/Dhl/Data/DeletionState.php | 9 + classes/Carrier/Dhl/Data/DeliveryAddress.php | 12 + classes/Carrier/Dhl/Data/Dimension.php | 11 + .../Carrier/Dhl/Data/ExportDocPosition.php | 13 + classes/Carrier/Dhl/Data/ExportDocument.php | 34 + classes/Carrier/Dhl/Data/LabelData.php | 17 + classes/Carrier/Dhl/Data/Name.php | 10 + classes/Carrier/Dhl/Data/NativeAddress.php | 19 + classes/Carrier/Dhl/Data/NativeAddressNew.php | 12 + classes/Carrier/Dhl/Data/PackStation.php | 13 + classes/Carrier/Dhl/Data/Postfiliale.php | 12 + classes/Carrier/Dhl/Data/Receiver.php | 12 + classes/Carrier/Dhl/Data/Shipment.php | 22 + classes/Carrier/Dhl/Data/ShipmentDetails.php | 28 + classes/Carrier/Dhl/Data/ShipmentItem.php | 11 + .../Carrier/Dhl/Data/ShipmentNotification.php | 9 + classes/Carrier/Dhl/Data/ShipmentOrder.php | 10 + classes/Carrier/Dhl/Data/ShipmentService.php | 7 + classes/Carrier/Dhl/Data/Shipper.php | 16 + classes/Carrier/Dhl/Data/Status.php | 9 + classes/Carrier/Dhl/Data/StatusElement.php | 9 + .../Carrier/Dhl/Data/Statusinformation.php | 13 + classes/Carrier/Dhl/Data/Version.php | 10 + classes/Carrier/Dhl/DhlApi.php | 70 + .../Model/CreateShipmentResult.php | 13 + .../ShippingMethod/Model/CustomsInfo.php | 13 + .../Modules/ShippingMethod/Model/Product.php | 57 + www/lib/class.versanddienstleister.php | 304 ++- www/lib/intraship.php | 1501 ---------- ...arten_sendcloud.tpl => createshipment.tpl} | 99 +- www/lib/versandarten/dhl.php | 169 ++ www/lib/versandarten/dhlversenden.php_ | 2423 ----------------- www/lib/versandarten/sendcloud.php | 159 +- xentral_autoloader.php | 1 - 44 files changed, 1051 insertions(+), 4196 deletions(-) create mode 100644 classes/Carrier/Dhl/Data/Bank.php create mode 100644 classes/Carrier/Dhl/Data/Communication.php create mode 100644 classes/Carrier/Dhl/Data/Contact.php create mode 100644 classes/Carrier/Dhl/Data/Country.php create mode 100644 classes/Carrier/Dhl/Data/CreateShipmentOrderRequest.php create mode 100644 classes/Carrier/Dhl/Data/CreateShipmentOrderResponse.php create mode 100644 classes/Carrier/Dhl/Data/CreationState.php create mode 100644 classes/Carrier/Dhl/Data/Customer.php create mode 100644 classes/Carrier/Dhl/Data/DeleteShipmentOrderRequest.php create mode 100644 classes/Carrier/Dhl/Data/DeleteShipmentOrderResponse.php create mode 100644 classes/Carrier/Dhl/Data/DeletionState.php create mode 100644 classes/Carrier/Dhl/Data/DeliveryAddress.php create mode 100644 classes/Carrier/Dhl/Data/Dimension.php create mode 100644 classes/Carrier/Dhl/Data/ExportDocPosition.php create mode 100644 classes/Carrier/Dhl/Data/ExportDocument.php create mode 100644 classes/Carrier/Dhl/Data/LabelData.php create mode 100644 classes/Carrier/Dhl/Data/Name.php create mode 100644 classes/Carrier/Dhl/Data/NativeAddress.php create mode 100644 classes/Carrier/Dhl/Data/NativeAddressNew.php create mode 100644 classes/Carrier/Dhl/Data/PackStation.php create mode 100644 classes/Carrier/Dhl/Data/Postfiliale.php create mode 100644 classes/Carrier/Dhl/Data/Receiver.php create mode 100644 classes/Carrier/Dhl/Data/Shipment.php create mode 100644 classes/Carrier/Dhl/Data/ShipmentDetails.php create mode 100644 classes/Carrier/Dhl/Data/ShipmentItem.php create mode 100644 classes/Carrier/Dhl/Data/ShipmentNotification.php create mode 100644 classes/Carrier/Dhl/Data/ShipmentOrder.php create mode 100644 classes/Carrier/Dhl/Data/ShipmentService.php create mode 100644 classes/Carrier/Dhl/Data/Shipper.php create mode 100644 classes/Carrier/Dhl/Data/Status.php create mode 100644 classes/Carrier/Dhl/Data/StatusElement.php create mode 100644 classes/Carrier/Dhl/Data/Statusinformation.php create mode 100644 classes/Carrier/Dhl/Data/Version.php create mode 100644 classes/Carrier/Dhl/DhlApi.php create mode 100644 classes/Modules/ShippingMethod/Model/CreateShipmentResult.php create mode 100644 classes/Modules/ShippingMethod/Model/CustomsInfo.php create mode 100644 classes/Modules/ShippingMethod/Model/Product.php delete mode 100644 www/lib/intraship.php rename www/lib/versandarten/content/{versandarten_sendcloud.tpl => createshipment.tpl} (72%) create mode 100644 www/lib/versandarten/dhl.php delete mode 100644 www/lib/versandarten/dhlversenden.php_ diff --git a/classes/Carrier/Dhl/Data/Bank.php b/classes/Carrier/Dhl/Data/Bank.php new file mode 100644 index 00000000..e213e7a1 --- /dev/null +++ b/classes/Carrier/Dhl/Data/Bank.php @@ -0,0 +1,14 @@ +countryISOCode = $isoCode; + $obj->state = $state; + return $obj; + } + +} \ No newline at end of file diff --git a/classes/Carrier/Dhl/Data/CreateShipmentOrderRequest.php b/classes/Carrier/Dhl/Data/CreateShipmentOrderRequest.php new file mode 100644 index 00000000..7c2f39a4 --- /dev/null +++ b/classes/Carrier/Dhl/Data/CreateShipmentOrderRequest.php @@ -0,0 +1,14 @@ +ShipmentDetails = new ShipmentDetails(); + $this->Shipper = new Shipper(); + $this->ShipperReference = ''; + $this->Receiver = new Receiver(); + } +} \ No newline at end of file diff --git a/classes/Carrier/Dhl/Data/ShipmentDetails.php b/classes/Carrier/Dhl/Data/ShipmentDetails.php new file mode 100644 index 00000000..d322793e --- /dev/null +++ b/classes/Carrier/Dhl/Data/ShipmentDetails.php @@ -0,0 +1,28 @@ +shipmentDate = $date->format('Y-m-d'); + } + + public function GetShipmentDate(): DateTimeImmutable { + return DateTimeImmutable::createFromFormat('Y-m-d', $this->shipmentDate); + } +} \ No newline at end of file diff --git a/classes/Carrier/Dhl/Data/ShipmentItem.php b/classes/Carrier/Dhl/Data/ShipmentItem.php new file mode 100644 index 00000000..258a10d4 --- /dev/null +++ b/classes/Carrier/Dhl/Data/ShipmentItem.php @@ -0,0 +1,11 @@ +Name = new Name(); + $this->Address = new NativeAddressNew(); + } +} \ No newline at end of file diff --git a/classes/Carrier/Dhl/Data/Status.php b/classes/Carrier/Dhl/Data/Status.php new file mode 100644 index 00000000..b3f4667f --- /dev/null +++ b/classes/Carrier/Dhl/Data/Status.php @@ -0,0 +1,9 @@ +soapClient = new SoapClient(__DIR__ . '/Wsdl/geschaeftskundenversand-api-3.4.0.wsdl', [ + 'login' => 'ewsp', + 'password' => 'rZ*twrzJ5@wr&$', + 'location' => self::SANDBOX_URL, + 'trace' => 1, + 'connection_timeout' => 30, + 'classmap' => [ + 'CreateShipmentOrderResponse' => CreateShipmentOrderResponse::class, + 'CreationState' => CreationState::class, + 'LabelData' => LabelData::class, + 'Statusinformation' => Statusinformation::class, + 'Version' => Version::class, + ] + ]); + + $authHeader = new SoapHeader(self::NAMESPACE_CIS, 'Authentification', [ + 'user' => $user, + 'signature' => $signature + ]); + $this->soapClient->__setSoapHeaders($authHeader); + } + + public function CreateShipment(Shipment $shipment): CreateShipmentOrderResponse|string + { + $request = new CreateShipmentOrderRequest(); + $request->Version = $this->getVersion(); + $request->ShipmentOrder = new ShipmentOrder(); + $request->ShipmentOrder->Shipment = $shipment; + $request->ShipmentOrder->sequenceNumber = '1'; + $request->labelResponseType = "B64"; + try { + $response = $this->soapClient->createShipmentOrder($request); + return $response; + } catch (\SoapFault $e) { + return $e->getMessage(); + } + } + + private function getVersion() { + $version = new Version(); + $version->majorRelease = '3'; + $version->minorRelease = '4'; + return $version; + } +} \ No newline at end of file diff --git a/classes/Modules/ShippingMethod/Model/CreateShipmentResult.php b/classes/Modules/ShippingMethod/Model/CreateShipmentResult.php new file mode 100644 index 00000000..12ef0414 --- /dev/null +++ b/classes/Modules/ShippingMethod/Model/CreateShipmentResult.php @@ -0,0 +1,13 @@ +Id = $id; + $obj->Name = $name; + return $obj; + } + + public function WithLength(float $min, float $max): Product { + $this->LengthMin = $min; + $this->LengthMax = $max; + return $this; + } + + public function WithWidth(float $min, float $max): Product { + $this->WidthMin = $min; + $this->WidthMax = $max; + return $this; + } + + public function WithHeight(float $min, float $max): Product { + $this->HeightMin = $min; + $this->HeightMax = $max; + return $this; + } + + public function WithWeight(float $min, float $max): Product { + $this->WeightMin = $min; + $this->WeightMax = $max; + return $this; + } + + public function WithServices(array $services): Product { + $this->AvailableServices = $services; + return $this; + } +} \ No newline at end of file diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 0de6e944..46219164 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -1,5 +1,11 @@ -settings = json_decode($row['einstellungen_json']); } - public function isEtikettenDrucker(): bool { + public function isEtikettenDrucker(): bool + { return false; } - public function GetAdressdaten($id, $sid) + public abstract function GetName(): string; + + public function GetAdressdaten($id, $sid): array { $auftragId = $lieferscheinId = $rechnungId = $versandId = 0; - if($sid==='rechnung') + if ($sid === 'rechnung') $rechnungId = $id; - if($sid==='lieferschein') { + if ($sid === 'lieferschein') { $lieferscheinId = $id; $auftragId = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id=$lieferscheinId LIMIT 1"); $rechnungId = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein = '$lieferscheinId' LIMIT 1"); - if($rechnungId <= 0) + if ($rechnungId <= 0) $rechnungId = $this->app->DB->Select("SELECT rechnungid FROM lieferschein WHERE id='$lieferscheinId' LIMIT 1"); } - if($sid==='versand') - { + if ($sid === 'versand') { $versandId = $id; $lieferscheinId = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$versandId' LIMIT 1"); - $rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$versandId' LIMIT 1"); + $rechnungId = $this->app->DB->Select("SELECT rechnung FROM versand WHERE id='$versandId' LIMIT 1"); $sid = 'lieferschein'; } if ($auftragId <= 0 && $rechnungId > 0) $auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1"); - if($sid==='rechnung' || $sid==='lieferschein' || $sid==='adresse') - { + if ($sid === 'rechnung' || $sid === 'lieferschein' || $sid === 'adresse') { $docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $id LIMIT 1"); + $ret['addressId'] = $docArr['adresse']; + $ret['auftragId'] = $auftragId; + $ret['rechnungId'] = $rechnungId; + $ret['lieferscheinId'] = $lieferscheinId; $addressfields = ['name', 'adresszusatz', 'abteilung', 'ansprechpartner', 'unterabteilung', 'ort', 'plz', - 'strasse', 'land', 'telefon', 'email']; - $ret = array_filter($docArr, fn($key)=>in_array($key, $addressfields), ARRAY_FILTER_USE_KEY); + 'strasse', 'land']; + $ret['original'] = array_filter($docArr, fn($key) => in_array($key, $addressfields), ARRAY_FILTER_USE_KEY); - $name2 = trim($docArr['adresszusatz']); - $abt = 0; - if($name2==='') - { - $name2 = trim($docArr['abteilung']); - $abt=1; - } - $name3 = trim($docArr['ansprechpartner']); - if($name3==='' && $abt!==1){ - $name3 = trim($docArr['abteilung']); - } + $ret['name'] = empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : trim($docArr['ansprechpartner']); + $ret['companyname'] = !empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : ''; + $ret['address2'] = join(';', array_filter([ + $docArr['abteilung'], + $docArr['unterabteilung'], + $docArr['adresszusatz'] + ], fn(string $item) => !empty(trim($item)))); - //unterabteilung versuchen einzublenden - if($name2==='') { - $name2 = trim($docArr['unterabteilung']); - } else if ($name3==='') { - $name3 = trim($docArr['unterabteilung']); - } - if($name3!=='' && $name2==='') { - $name2=$name3; - $name3=''; - } - $ret['name2'] = $name2; - $ret['name3'] = $name3; + $ret['city'] = $docArr['ort']; + $ret['zip'] = $docArr['plz']; + $ret['country'] = $docArr['land']; + $ret['phone'] = $docArr['telefon']; + $ret['email'] = $docArr['email']; $strasse = trim($docArr['strasse']); $ret['streetwithnumber'] = $strasse; $hausnummer = trim($this->app->erp->ExtractStreetnumber($strasse)); - $strasse = trim(str_replace($hausnummer,'',$strasse)); - $strasse = str_replace('.','',$strasse); + $strasse = trim(str_replace($hausnummer, '', $strasse)); + $strasse = str_replace('.', '', $strasse); - if($strasse=='') - { + if ($strasse == '') { $strasse = trim($hausnummer); $hausnummer = ''; } - $ret['strasse'] = $strasse; - $ret['hausnummer'] = $hausnummer; + $ret['street'] = $strasse; + $ret['streetnumber'] = $hausnummer; } // wenn rechnung im spiel entweder durch versand oder direkt rechnung - if($rechnungId >0) - { - $invoice_data = $this->app->DB->SelectRow("SELECT zahlungsweise, soll, belegnr FROM rechnung WHERE id='$rechnungId' LIMIT 1"); + if ($rechnungId > 0) { + $invoice_data = $this->app->DB->SelectRow("SELECT zahlungsweise, soll, belegnr FROM rechnung WHERE id='$rechnungId' LIMIT 1"); $ret['zahlungsweise'] = $invoice_data['zahlungsweise']; $ret['betrag'] = $invoice_data['soll']; $ret['invoice_number'] = $invoice_data['belegnr']; - if($invoice_data['zahlungsweise']==='nachnahme'){ + if ($invoice_data['zahlungsweise'] === 'nachnahme') { $ret['nachnahme'] = true; } } @@ -118,10 +116,10 @@ abstract class Versanddienstleister { $sql = "SELECT lp.bezeichnung, lp.menge, - coalesce(nullif(lp.zolltarifnummer, ''), nullif(rp.zolltarifnummer, ''), nullif(a.zolltarifnummer, '')) zolltarifnummer, - coalesce(nullif(lp.herkunftsland, ''), nullif(rp.herkunftsland, ''), nullif(a.herkunftsland, '')) herkunftsland, - coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100)) zolleinzelwert, - coalesce(nullif(lp.zolleinzelgewicht, 0), a.gewicht) zolleinzelgewicht, + coalesce(nullif(lp.zolltarifnummer, ''), nullif(rp.zolltarifnummer, ''), nullif(a.zolltarifnummer, '')) as zolltarifnummer, + coalesce(nullif(lp.herkunftsland, ''), nullif(rp.herkunftsland, ''), nullif(a.herkunftsland, '')) as herkunftsland, + coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100)) as zolleinzelwert, + coalesce(nullif(lp.zolleinzelgewicht, 0), a.gewicht) as zolleinzelgewicht, lp.zollwaehrung FROM lieferschein_position lp JOIN artikel a on lp.artikel = a.id @@ -131,10 +129,9 @@ abstract class Versanddienstleister { ORDER BY lp.sort"; $ret['positions'] = $this->app->DB->SelectArr($sql); - if($sid==="lieferschein"){ + if ($sid === "lieferschein") { $standardkg = $this->app->erp->VersandartMindestgewicht($lieferscheinId); - } - else{ + } else { $standardkg = $this->app->erp->VersandartMindestgewicht(); } $ret['weight'] = $standardkg; @@ -155,7 +152,8 @@ abstract class Versanddienstleister { * * @return array */ - public function AdditionalSettings(): array { + public function AdditionalSettings(): array + { return []; } @@ -168,73 +166,60 @@ abstract class Versanddienstleister { public function RenderAdditionalSettings(string $target, array $form): void { $fields = $this->AdditionalSettings(); - if($this->app->Secure->GetPOST('speichern')) - { - $json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '".$this->id."' LIMIT 1"); - $modul = $this->app->DB->Select("SELECT modul FROM versandarten WHERE id = '".$this->id."' LIMIT 1"); - if(!empty($json)) - { + if ($this->app->Secure->GetPOST('speichern')) { + $json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '" . $this->id . "' LIMIT 1"); + $modul = $this->app->DB->Select("SELECT modul FROM versandarten WHERE id = '" . $this->id . "' LIMIT 1"); + if (!empty($json)) { $json = @json_decode($json, true); - }else{ + } else { $json = array(); - foreach($fields as $name => $val) - { - if(isset($val['default'])) - { + foreach ($fields as $name => $val) { + if (isset($val['default'])) { $json[$name] = $val['default']; } } } - if(empty($json)) - { + if (empty($json)) { $json = null; } - foreach($fields as $name => $val) - { + foreach ($fields as $name => $val) { - if($modul === $this->app->Secure->GetPOST('modul_name')) - { - $json[$name] = $this->app->Secure->GetPOST($name, '','', 1); + if ($modul === $this->app->Secure->GetPOST('modul_name')) { + $json[$name] = $this->app->Secure->GetPOST($name, '', '', 1); } - - if(isset($val['replace'])) - { - switch($val['replace']) - { + + if (isset($val['replace'])) { + switch ($val['replace']) { case 'lieferantennummer': - $json[$name] = $this->app->erp->ReplaceLieferantennummer(1,$json[$name],1); - break; + $json[$name] = $this->app->erp->ReplaceLieferantennummer(1, $json[$name], 1); + break; } } } $json_str = $this->app->DB->real_escape_string(json_encode($json)); - $this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '".$this->id."' LIMIT 1"); + $this->app->DB->Update("UPDATE versandarten SET einstellungen_json = '$json_str' WHERE id = '" . $this->id . "' LIMIT 1"); } $html = ''; - - foreach($fields as $name => $val) // set missing default values + + foreach ($fields as $name => $val) // set missing default values { - if(isset($val['default']) && !isset($form[$name])) - { + if (isset($val['default']) && !isset($form[$name])) { $form[$name] = $val['default']; } } - foreach($fields as $name => $val) - { - if(isset($val['heading'])) - $html .= ''.html_entity_decode($val['heading']).''; + foreach ($fields as $name => $val) { + if (isset($val['heading'])) + $html .= '' . html_entity_decode($val['heading']) . ''; - $html .= ''.($val['bezeichnung'] ?? $name).''; - if(isset($val['replace'])) - { - switch($val['replace']) - { + $html .= '' . ($val['bezeichnung'] ?? $name) . ''; + if (isset($val['replace'])) { + switch ($val['replace']) { case 'lieferantennummer': - $form[$name] = $this->app->erp->ReplaceLieferantennummer(0,$form[$name],0); + $form[$name] = $this->app->erp->ReplaceLieferantennummer(0, $form[$name], 0); $this->app->YUI->AutoComplete($name, 'lieferant', 1); break; case 'shop': - $form[$name] .= ($form[$name]?' '.$this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '".(int)$form[$name]."'"):''); + $form[$name] .= ($form[$name] ? ' ' . $this->app->DB->Select("SELECT bezeichnung FROM shopexport WHERE id = '" . (int)$form[$name] . "'") : ''); $this->app->YUI->AutoComplete($name, 'shopnameid'); break; case 'etiketten': @@ -242,41 +227,38 @@ abstract class Versanddienstleister { break; } } - switch($val['typ'] ?? 'text') - { + switch ($val['typ'] ?? 'text') { case 'textarea': - $html .= ''; + $html .= ''; break; case 'checkbox': - $html .= ''; + $html .= ''; break; case 'select': $html .= $this->app->Tpl->addSelect('return', $name, $name, $val['optionen'], $form[$name]); break; case 'submit': - if(isset($val['text'])) - $html .= '
'; + if (isset($val['text'])) + $html .= '
'; break; case 'custom': - if(isset($val['function'])) - { + if (isset($val['function'])) { $tmpfunction = $val['function']; - if(method_exists($this, $tmpfunction)) - { + if (method_exists($this, $tmpfunction)) { $html .= $this->$tmpfunction(); } } break; default: $html .= ''; - break; + . (!empty($val['size']) ? ' size="' . $val['size'] . '"' : '') + . (!empty($val['placeholder']) ? ' placeholder="' . $val['placeholder'] . '"' : '') + . ' name="' . $name . '" id="' . $name . '" value="' . (isset($form[$name]) ? htmlspecialchars($form[$name]) : '') . '" />'; + break; } - if(isset($val['info']) && $val['info']) - $html .= ' '.$val['info'].''; - + if (isset($val['info']) && $val['info']) + $html .= ' ' . $val['info'] . ''; + $html .= ''; } $this->app->Tpl->Add($target, $html); @@ -290,21 +272,20 @@ abstract class Versanddienstleister { */ public function ValidateSettings(array &$form): array { - return []; + return []; } - /** * @param string $tracking - * @param int $versand - * @param int $lieferschein + * @param int $versand + * @param int $lieferschein */ - public function SetTracking($tracking,$versand=0,$lieferschein=0, $trackingLink = '') + public function SetTracking($tracking, $versand = 0, $lieferschein = 0, $trackingLink = '') { //if($versand > 0) $this->app->DB->Update("UPDATE versand SET tracking=CONCAT(tracking,if(tracking!='',';',''),'".$tracking."') WHERE id='$versand' LIMIT 1"); - $this->app->User->SetParameter('versand_lasttracking',$tracking); - $this->app->User->SetParameter('versand_lasttracking_link',$trackingLink); + $this->app->User->SetParameter('versand_lasttracking', $tracking); + $this->app->User->SetParameter('versand_lasttracking_link', $trackingLink); $this->app->User->SetParameter('versand_lasttracking_versand', $versand); $this->app->User->SetParameter('versand_lasttracking_lieferschein', $lieferschein); } @@ -314,17 +295,17 @@ abstract class Versanddienstleister { */ public function deleteTrackingFromUserdata($tracking) { - if(empty($tracking)) { + if (empty($tracking)) { return; } - $trackingUser = !empty($this->app->User) && method_exists($this->app->User,'GetParameter')? - $this->app->User->GetParameter('versand_lasttracking'):''; - if(empty($trackingUser) || $trackingUser !== $tracking) { + $trackingUser = !empty($this->app->User) && method_exists($this->app->User, 'GetParameter') ? + $this->app->User->GetParameter('versand_lasttracking') : ''; + if (empty($trackingUser) || $trackingUser !== $tracking) { return; } - $this->app->User->SetParameter('versand_lasttracking',''); - $this->app->User->SetParameter('versand_lasttracking_link',''); + $this->app->User->SetParameter('versand_lasttracking', ''); + $this->app->User->SetParameter('versand_lasttracking_link', ''); $this->app->User->SetParameter('versand_lasttracking_versand', ''); $this->app->User->SetParameter('versand_lasttracking_lieferschein', ''); } @@ -341,21 +322,84 @@ abstract class Versanddienstleister { /** * @param string $tracking - * @param int $notsend + * @param int $notsend * @param string $link * @param string $rawlink * * @return bool */ - public function Trackinglink($tracking, &$notsend, &$link, &$rawlink) { + public function Trackinglink($tracking, &$notsend, &$link, &$rawlink) + { $notsend = 0; $rawlink = ''; $link = ''; return true; } - public function Paketmarke(string $target, string $docType, int $docId): void { + public function Paketmarke(string $target, string $docType, int $docId): void + { + $address = $this->GetAdressdaten($docId, $docType); + if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) { + $json = json_decode(file_get_contents('php://input')); + $ret = []; + if ($json->submit == 'print') { + $result = $this->CreateShipment($json, $address); + if ($result->Success) { + $sql = "INSERT INTO versand + (adresse, lieferschein, versandunternehmen, gewicht, tracking, tracking_link, anzahlpakete) + VALUES + ({$address['addressId']}, {$address['lieferscheinId']}, '$this->type', + '$json->weight', '$result->TrackingNumber', '$result->TrackingUrl', 1)"; + print_r($sql); + $this->app->DB->Insert($sql); + $filename = $this->app->erp->GetTMP() . join('_', [$this->type, 'Label', $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $result->Label); + $this->app->printer->Drucken($this->labelPrinterId, $filename); + + if (isset($result->ExportDocuments)) { + $filename = $this->app->erp->GetTMP() . join('_', [$this->type, 'ExportDoc', $result->TrackingNumber]) . '.pdf'; + file_put_contents($filename, $result->ExportDocuments); + $this->app->printer->Drucken($this->documentPrinterId, $filename); + } + $ret['messages'][] = ['class' => 'info', 'text' => "Paketmarke wurde erfolgreich erstellt: $result->TrackingNumber"]; + } else { + $ret['messages'] = array_map(fn(string $item) => ['class' => 'error', 'text' => $item], array_unique($result->Errors)); + } + } + header('Content-Type: application/json'); + echo json_encode($ret); + $this->app->ExitXentral(); + } + + $address['sendungsart'] = CustomsInfo::CUSTOMS_TYPE_GOODS; + $products = $this->GetShippingProducts(); + $products = array_combine(array_column($products, 'Id'), $products); + $address['product'] = $products[0]->Id ?? ''; + + $json['form'] = $address; + $json['countries'] = $this->app->erp->GetSelectLaenderliste(); + $json['products'] = $products; + $json['customs_shipment_types'] = [ + CustomsInfo::CUSTOMS_TYPE_GIFT => 'Geschenk', + CustomsInfo::CUSTOMS_TYPE_DOCUMENTS => 'Dokumente', + CustomsInfo::CUSTOMS_TYPE_GOODS => 'Handelswaren', + CustomsInfo::CUSTOMS_TYPE_SAMPLE => 'Erprobungswaren', + CustomsInfo::CUSTOMS_TYPE_RETURN => 'Rücksendung' + ]; + $json['messages'] = []; + $json['form']['services'] = [ + Product::SERVICE_PREMIUM => false + ]; + $this->app->Tpl->Set('JSON', json_encode($json)); + $this->app->Tpl->Set('CARRIERNAME', $this->GetName()); + $this->app->Tpl->Parse($target, 'createshipment.tpl'); } - + + public abstract function CreateShipment(object $json, array $address): CreateShipmentResult; + + /** + * @return Product[] + */ + public abstract function GetShippingProducts(): array; } diff --git a/www/lib/intraship.php b/www/lib/intraship.php deleted file mode 100644 index 65fc5837..00000000 --- a/www/lib/intraship.php +++ /dev/null @@ -1,1501 +0,0 @@ -id = $id; - $this->app = &$app; - $einstellungen_json = $this->app->DB->Select("SELECT einstellungen_json FROM versandarten WHERE id = '$id' LIMIT 1"); - $this->paketmarke_drucker = $this->app->DB->Select("SELECT paketmarke_drucker FROM versandarten WHERE id = '$id' LIMIT 1"); - $this->export_drucker = $this->app->DB->Select("SELECT export_drucker FROM versandarten WHERE id = '$id' LIMIT 1"); - if($einstellungen_json) - { - $this->einstellungen = json_decode($einstellungen_json,true); - }else{ - $this->einstellungen = array(); - } - $this->einstellungen = $this->einstellungen; - if(isset($this->einstellungen['intraship_partnerid']) && $this->einstellungen['intraship_partnerid'] )$this->einstellungen['partnerid'] = $this->einstellungen['intraship_partnerid']; - if(!isset($this->einstellungen['partnerid'])) - { - $this->einstellungen['partnerid'] = '01'; - } - if(!isset($this->einstellungen['partnerid']) || $this->einstellungen['partnerid']=="") - { - $this->einstellungen['partnerid'] = '01'; - } - - $this->errors = array(); - $data = $this->einstellungen; - $this->info = array( - 'company_name' => $data['intraship_company_name'], - 'street_name' => $data['intraship_street_name'], - 'street_number' => $data['intraship_street_number'], - 'zip' => $data['intraship_zip'], - 'country' => $data['intraship_country'], - 'city' => $data['intraship_city'], - 'email' => $data['intraship_email'], - 'phone' => $data['intraship_phone'], - 'internet' => $data['intraship_internet'], - 'contact_person' => $data['intraship_contact_person'], - 'export_reason' => $data['intraship_exportgrund'] - ); - //function __construct($api_einstellungen, $customer_info) { - - - - if($land!=$this->app->erp->Firmendaten("land")) - { - if(!empty($data['intraship_partnerid_welt']) && !empty($data['intraship_partnerid_welt']))$einstellungen['partnerid'] = $data['intraship_partnerid_welt']; - } - - if(isset($data['intraship_retourenaccount']) && $data['intraship_retourenaccount'])$einstellungen['intraship_retourenaccount'] = $data['intraship_retourenaccount']; - - - /* - - $this->einstellungen = $api_einstellungen; - $this->info = $customer_info; - - if($this->einstellungen['partnerid']=="") $this->einstellungen['partnerid'] = '01'; - - $this->errors = array(); - */ - } - - public function GetBezeichnung() - { - return 'DHL Instrahship'; - } - - function AdditionalSettings() - { - return array( - - - 'user' => array('typ'=>'text','bezeichnung'=>'Benutzer:','info'=>'geschaeftskunden_api (Versenden/Intraship-Benutzername)'), - 'signature' => array('typ'=>'text','bezeichnung'=>'Signature:','info'=>'Dhl_ep_test1 (Versenden/IntrashipPasswort)'), - 'ekp' => array('typ'=>'text','bezeichnung'=>'EKP','info'=>'5000000000 (gültige DHL Kundennummer)'), - 'partnerid' => array('typ'=>'text','bezeichnung'=>'Partner ID Inland:','info'=>'meist 01, manchmal 02, 03 etc.'), - 'partnerid_welt' => array('typ'=>'text','bezeichnung'=>'Partner ID Welt:','info'=>'falls leer wird die inländische Partner ID verwendet.'), - 'api_user' => array('typ'=>'text','bezeichnung'=>'API User:','info'=>'Bitte anfragen beim Support'), - 'api_password' => array('typ'=>'text','bezeichnung'=>'API Passwort:','info'=>'Bitte anfragen beim Support'), - 'intraship_retourenaccount' => array('typ'=>'text','bezeichnung'=>'Retouren Account:','info'=>'14 Stellige DHL-Retoure Abrechnungsnummer'), - 'intraship_retourenlabel'=>array('typ'=>'checkbox','bezeichnung'=>'Vorauswahl Retourenlabel:','info'=>'Druckt Retourenlabel mit'), - - 'intraship_company_name' => array('typ'=>'text','bezeichnung'=>'Versender Firma:'), - 'intraship_street_name' => array('typ'=>'text','bezeichnung'=>'Versender Strasse:'), - 'intraship_street_number' => array('typ'=>'text','bezeichnung'=>'Versender Strasse Nr.:'), - //'intraship_name' => array('typ'=>'text','bezeichnung'=>'Versender Ansprechpartner:'), - 'intraship_zip' => array('typ'=>'text','bezeichnung'=>'Versender PLZ:'), - 'intraship_city' => array('typ'=>'text','bezeichnung'=>'Versender Stadt:'), - 'intraship_country' => array('typ'=>'text','bezeichnung'=>'Versender Land:','info'=>'germany'), - 'intraship_email' => array('typ'=>'text','bezeichnung'=>'Versender E-Mail:'), - 'intraship_phone' => array('typ'=>'text','bezeichnung'=>'Versender Telefon:'), - 'intraship_internet' => array('typ'=>'text','bezeichnung'=>'Versender Web:'), - 'intraship_contact_person' => array('typ'=>'text','bezeichnung'=>'Versender Ansprechpartner:'), - - - 'intraship_account_owner' => array('typ'=>'text','bezeichnung'=>'Nachnahme Bank Inhaber:'), - 'intraship_account_number' => array('typ'=>'text','bezeichnung'=>'Nachnahme Kontonummer:'), - 'intraship_code' => array('typ'=>'text','bezeichnung'=>'Nachnahme BLZ:'), - 'intraship_bank_name' => array('typ'=>'text','bezeichnung'=>'Nachnahme Bank Name:'), - 'intraship_iban' => array('typ'=>'text','bezeichnung'=>'Nachnahme IBAN:'), - - 'intraship_bic' => array('typ'=>'text','bezeichnung'=>'Nachnahme BIC:'), - - 'intraship_exportgrund' => array('typ'=>'text','bezeichnung'=>'Export:','info'=>'z.B. Computer Zubehör'), - - 'intraship_WeightInKG' => array('typ'=>'text','bezeichnung'=>'Standard Gewicht:','info'=>'in KG'), - 'intraship_LengthInCM' => array('typ'=>'text','bezeichnung'=>'Standard Länge:','info'=>'in cm'), - 'intraship_WidthInCM' => array('typ'=>'text','bezeichnung'=>'Standard Breite:','info'=>'in cm'), - 'intraship_HeightInCM' => array('typ'=>'text','bezeichnung'=>'Standard Höhe:','info'=>'in cm'), - 'intraship_PackageType' => array('typ'=>'text','bezeichnung'=>'Standard Paket:','info'=>'z.B. PL'), - - 'log'=>array('typ'=>'checkbox','bezeichnung'=>'Logging') - ); - - } - - - public function Paketmarke($doctyp, $docid, $target = '', $error = false) - { - $id = $docid; - $drucken = $this->app->Secure->GetPOST("drucken"); - $anders = $this->app->Secure->GetPOST("anders"); - $land = $this->app->Secure->GetPOST("land"); - $tracking_again = $this->app->Secure->GetGET("tracking_again"); - - - $versandmit= $this->app->Secure->GetPOST("versandmit"); - $trackingsubmit= $this->app->Secure->GetPOST("trackingsubmit"); - $versandmitbutton = $this->app->Secure->GetPOST("versandmitbutton"); - $tracking= $this->app->Secure->GetPOST("tracking"); - $trackingsubmitcancel= $this->app->Secure->GetPOST("trackingsubmitcancel"); - $retourenlabel = $this->app->Secure->GetPOST("retourenlabel"); - - $kg= $this->app->Secure->GetPOST("kg1"); - $name= $this->app->Secure->GetPOST("name"); - $name2= $this->app->Secure->GetPOST("name2"); - $name3= $this->app->Secure->GetPOST("name3"); - $strasse= $this->app->Secure->GetPOST("strasse"); - $hausnummer= $this->app->Secure->GetPOST("hausnummer"); - $plz= $this->app->Secure->GetPOST("plz"); - $ort= $this->app->Secure->GetPOST("ort"); - $email= $this->app->Secure->GetPOST("email"); - $phone= $this->app->Secure->GetPOST("phone"); - $nummeraufbeleg= $this->app->Secure->GetPOST("nummeraufbeleg"); - - if($sid=="") - $sid= $this->app->Secure->GetGET("sid"); - - if($zusatz=="express") - $this->app->Tpl->Set('ZUSATZ',"Express"); - - if($zusatz=="export") - $this->app->Tpl->Set('ZUSATZ',"Export"); - - $id = $this->app->Secure->GetGET("id"); - $drucken = $this->app->Secure->GetPOST("drucken"); - $anders = $this->app->Secure->GetPOST("anders"); - $land = $this->app->Secure->GetGET("land"); - if($land=="") $land = $this->app->Secure->GetPOST("land"); - $tracking_again = $this->app->Secure->GetGET("tracking_again"); - - - $versandmit= $this->app->Secure->GetPOST("versandmit"); - $trackingsubmit= $this->app->Secure->GetPOST("trackingsubmit"); - $versandmitbutton = $this->app->Secure->GetPOST("versandmitbutton"); - $tracking= $this->app->Secure->GetPOST("tracking"); - $trackingsubmitcancel= $this->app->Secure->GetPOST("trackingsubmitcancel"); - $retourenlabel = $this->app->Secure->GetPOST("retourenlabel"); - if($typ=="DHL" || $typ=="dhl") - $versand = "dhl"; - else if($typ=="Intraship") - $versand = "intraship"; - else $versand = $typ; - - if($sid == "versand") - { - $projekt = $this->app->DB->Select("SELECT projekt FROM versand WHERE id='$id' LIMIT 1"); - }else{ - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id='$id' LIMIT 1"); - } - $intraship_weightinkg = $this->app->DB->Select("SELECT intraship_weightinkg FROM projekt WHERE id='$projekt' LIMIT 1"); - - - if($trackingsubmit!="" || $trackingsubmitcancel!="") - { - - if($sid=="versand") - { - // falche tracingnummer bei DHL da wir in der Funktion PaketmarkeDHLEmbedded sind - if((strlen($tracking) < 12 || strlen($tracking) > 20) && $trackingsubmitcancel=="" && ($typ=="DHL" || $typ=="Intraship")) - { - header("Location: index.php?module=versanderzeugen&action=frankieren&id=$id&land=$land&tracking_again=1"); - exit; - } - else - { - $this->app->DB->Update("UPDATE versand SET versandunternehmen='$versand', tracking='$tracking', - versendet_am=NOW(),versendet_am_zeitstempel=NOW(), abgeschlossen='1',logdatei=NOW() WHERE id='$id' LIMIT 1"); - - $this->app->erp->VersandAbschluss($id); - //versand mail an kunden - $this->app->erp->Versandmail($id); - - $weiterespaket=$this->app->Secure->GetPOST("weiterespaket"); - $lieferscheinkopie=$this->app->Secure->GetPOST("lieferscheinkopie"); - if($weiterespaket=="1") - { - if($lieferscheinkopie=="1") $lieferscheinkopie=0; else $lieferscheinkopie=1; - //$this->app->erp->LogFile("Lieferscheinkopie $lieferscheinkopie"); - $all = $this->app->DB->SelectArr("SELECT * FROM versand WHERE id='$id' LIMIT 1"); - $this->app->DB->Insert("INSERT INTO versand (id,adresse,rechnung,lieferschein,versandart,projekt,bearbeiter,versender,versandunternehmen,firma, - keinetrackingmail,gelesen,paketmarkegedruckt,papieregedruckt,weitererlieferschein) - VALUES ('','{$all[0]['adresse']}','{$all[0]['rechnung']}','{$all[0]['lieferschein']}','{$all[0]['versandart']}','{$all[0]['projekt']}', - '{$all[0]['bearbeiter']}','{$all[0]['versender']}','{$all[0]['versandunternehmen']}', - '{$all[0]['firma']}','{$all[0]['keinetrackingmail']}','{$all[0]['gelesen']}',0,$lieferscheinkopie,1)"); - - $newid = $this->app->DB->GetInsertID(); - header("Location: index.php?module=versanderzeugen&action=einzel&id=$newid"); - } else { - header("Location: index.php?module=versanderzeugen&action=offene"); - } - } - exit; - } else { - //direkt aus dem Lieferschein - if($id > 0) - { - $adresse = $this->app->DB->Select("SELECT adresse FROM lieferschein WHERE id='$id' LIMIT 1"); - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id='$id' LIMIT 1"); - $kg = $this->app->Secure->GetPOST("kg1"); - if($kg=="") { - $kg = $this->app->erp->VersandartMindestgewicht($id); - } - $auftrag = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id = '$id'"); - $this->app->DB->Insert("INSERT INTO versand (id,versandunternehmen, tracking, - versendet_am,abgeschlossen,lieferschein, - freigegeben,firma,adresse,projekt,gewicht,paketmarkegedruckt,anzahlpakete) - VALUES ('','$versand','$tracking',NOW(),1,'$id',1,'".$this->app->User->GetFirma()."', - '$adresse','$projekt','$kg','1','1') "); - $versandId = $this->app->DB->GetInsertID(); - $shop = $this->app->DB->Select("SELECT shop FROM auftrag WHERE id = '$auftrag' LIMIT 1"); - $auftragabgleich=$this->app->DB->Select("SELECT auftragabgleich FROM shopexport WHERE id='$shop' LIMIT 1"); - - if($shop > 0 && $auftragabgleich=="1") - { - //$this->LogFile("Tracking gescannt"); - $this->app->remote->RemoteUpdateAuftrag($shop,$auftrag); - } - $this->app->erp->sendPaymentStatus($versandId); - $this->app->Location->execute('index.php?module=lieferschein&action=paketmarke&id='.$id); - } - } - } - - - if($versandmitbutton!="") - { - - if($sid=="versand") - { - $this->app->DB->Update("UPDATE versand SET versandunternehmen='$versandmit', - versendet_am=NOW(),versendet_am_zeitstempel=NOW(),abgeschlossen='1' WHERE id='$id' LIMIT 1"); - - $this->VersandAbschluss($id); - //versand mail an kunden - $this->Versandmail($id); - - header("Location: index.php?module=versanderzeugen&action=offene"); - exit; - } - } - - if($sid=="versand") - { - // wenn paketmarke bereits gedruckt nur tracking scannen - $paketmarkegedruckt = $this->app->DB->Select("SELECT paketmarkegedruckt FROM versand WHERE id='$id' LIMIT 1"); - - if($paketmarkegedruckt>=1) - $tracking_again=1; - } - - if($anders!="") - { - - } - else if(($drucken!="" || $tracking_again=="1") && !$error) - { - - - - if($tracking_again!="1") - { - $kg = (float)str_replace(',','.',$kg); - - $abholdatum = $this->app->Secure->GetPOST("abholdatum"); - $retourenlabel= $this->app->Secure->GetPOST("retourenlabel"); - if($retourenlabel) - { - $this->app->Tpl->Set('RETOURENLABEL', ' checked="checked" '); - $zusaetzlich['retourenlabel'] = 1; - } - if($abholdatum){ - $this->app->Tpl->Set('ABHOLDATUM',$abholdatum); - $zusaetzlich['abholdatum'] = date('Y-m-d', strtotime($abholdatum)); - $this->app->User->SetParameter("paketmarke_abholdatum",$zusaetzlich['abholdatum']); - } - - $kg = (float)(str_replace(',','.',$kg)); - $kg = round($kg,2); - $name = substr($this->app->erp->ReadyForPDF($name),0,30); - $name2 = $this->app->erp->ReadyForPDF($name2); - $name3 = $this->app->erp->ReadyForPDF($name3); - $strasse = $this->app->erp->ReadyForPDF($strasse); - $hausnummer = $this->app->erp->ReadyForPDF($hausnummer); - $plz = $this->app->erp->ReadyForPDF($plz); - $ort = $this->app->erp->ReadyForPDF(html_entity_decode($ort)); - $land = $this->app->erp->ReadyForPDF($land); - - //SetKonfigurationValue($name,$value) - - $module = $this->app->Secure->GetGET("module"); - //TODO Workarrond fuer lieferschein - if($module=="lieferschein") - { - $lieferschein = $id; - } - else { - $lieferschein = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$id' LIMIT 1"); - if($lieferschein <=0) $lieferschein=$id; - } - - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id='$lieferschein' LIMIT 1"); - $lieferscheinnummer = "LS".$this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferschein' LIMIT 1"); - - //pruefe ob es auftragsnummer gibt dann nehmen diese - $auftragid = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id='$lieferschein' LIMIT 1"); - if($auftragid > 0) - { - $nummeraufbeleg = "AB".$this->app->DB->Select("SELECT belegnr FROM auftrag WHERE id='$auftragid' LIMIT 1"); - } else { - $nummeraufbeleg = $lieferscheinnummer; - } - - $rechnung = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein='$lieferschein' LIMIT 1"); - - $rechnung_data = $this->app->DB->SelectArr("SELECT * FROM rechnung WHERE id='$rechnung' LIMIT 1"); - - // fuer export - $email = $rechnung_data[0]['email']; //XXX - $phone = $rechnung_data[0]['telefon']; //XXX - $rechnungssumme = $rechnung_data[0]['soll']; //XXX - - if($rechnung){ - $artikel_positionen = $this->app->DB->SelectArr("SELECT * FROM rechnung_position WHERE rechnung='$rechnung'"); - } else { - $artikel_positionen = $this->app->DB->SelectArr("SELECT * FROM lieferschein_position WHERE lieferschein='$lieferschein'"); - - } - $altersfreigabe = 0; - for($i=0;$i<(!empty($artikel_positionen)?count($artikel_positionen):0);$i++) - { - $artikelaltersfreigabe = (int)$this->app->DB->Select("SELECT altersfreigabe FROM artikel WHERE id = '".$artikel_positionen[$i]['artikel']."' LIMIT 1"); - if($artikelaltersfreigabe > $altersfreigabe)$altersfreigabe = $artikelaltersfreigabe; - //$lagerartikel = $this->app->DB->Select("SELECT lagerartikel FROM artikel WHERE id='".$artikel_positionen[$i]['artikel']."' LIMIT 1"); - - //if($lagerartikel=="1") - { - if($artikel_positionen[$i]['waehrung']=="") { - $artikel_positionen[$i]['waehrung']="EUR"; - } - $gewicht = $this->app->DB->Select("SELECT gewicht FROM artikel WHERE id='".$artikel_positionen[$i]['artikel']."' LIMIT 1"); - $porto = $this->app->DB->Select("SELECT porto FROM artikel WHERE id='".$artikel_positionen[$i]['artikel']."' LIMIT 1"); - - if($gewicht <=0) $gewicht=0; - - //if($gewicht > 0) $gewicht = $artikel_positionen[$i]['menge']*$gewicht; - //else $gewicht = 1.1*$artikel_positionen[$i]['menge']; - - if($porto!="1") - { - $artikel[] = array( 'description'=>substr($artikel_positionen[$i]['bezeichnung'],0,40), - 'countrycode'=>'DE', - 'commodity_code'=>'95061110', // zoll nummer? - 'amount'=>round($artikel_positionen[$i]['menge']), - 'netweightinkg'=>$gewicht, - 'grossweightinkg'=>$gewicht, - 'value'=>$artikel_positionen[$i]['preis'], - 'currency'=>$artikel_positionen[$i]['waehrung']); - } - } - } - - $data = $this->einstellungen; - - if($phone=="") $phone=$data['intraship_phone']; - - - - if($land!=$this->app->erp->Firmendaten("land")) - { - if(!empty($data['partnerid_welt']) && !empty($data['partnerid_welt']))$this->einstellungen['partnerid'] = $data['partnerid_welt']; - } - - if(isset($data['intraship_retourenaccount']) && $data['intraship_retourenaccount'])$einstellungen['intraship_retourenaccount'] = $data['intraship_retourenaccount']; - - // your company info - $info = array( - 'company_name' => $data['intraship_company_name'], - 'street_name' => $data['intraship_street_name'], - 'street_number' => $data['intraship_street_number'], - 'zip' => $data['intraship_zip'], - 'country' => $data['intraship_country'], - 'city' => $data['intraship_city'], - 'email' => $data['intraship_email'], - 'phone' => $data['intraship_phone'], - 'internet' => $data['intraship_internet'], - 'contact_person' => $data['intraship_contact_person'], - 'export_reason' => $data['intraship_exportgrund'] - ); - - // receiver details - $customer_details = array( - 'name1' => $name, - 'name2' => $name2, - 'c/o' => $name3, - 'name3' => $name3, - 'street_name' => $strasse, - 'street_number' => $hausnummer, - // 'country' => 'germany', - 'country_code' => $land, - 'zip' => $plz, - 'city' => $ort, - 'email' => $email, - 'phone' => $phone, - 'ordernumber' => $nummeraufbeleg, - 'weight' => $kg, - 'amount' => str_replace(",",".",$rechnungssumme), - 'currency' => 'EUR' - ); - if(!is_null($zusatz) && isset($zusatz['abholdatum']))$customer_details['abholdatum'] = $zusatz['abholdatum']; - if(!is_null($zusatz) && isset($zusatz['retourenlabel']))$customer_details['intraship_retourenlabel'] = $zusatz['retourenlabel']; - if($altersfreigabe > 0)$customer_details['altersfreigabe'] = $altersfreigabe; - //$dhl = new DHLBusinessShipment($einstellungen, $info); - - $shipment_details['WeightInKG'] = $data['intraship_WeightInKG']; - $shipment_details['LengthInCM'] = $data['intraship_LengthInCM']; - $shipment_details['WidthInCM'] = $data['intraship_WidthInCM']; - $shipment_details['HeightInCM'] = $data['intraship_HeightInCM']; - $shipment_details['PackageType'] = $data['intraship_PackageType']; - - if($data['intraship_note']=="") $data['intraship_note'] = $rechnungsnummer; - - if($land==$this->app->erp->Firmendaten("land")) - { - if($nachnahme && $betrag > 0) - { - $bank_details = array( - 'account_owner' => $data['intraship_account_owner'], - 'account_number' => $data['intraship_account_number'], - 'bank_code' => $data['intraship_bank_code'], - 'bank_name' => $data['intraship_bank_name'], - 'note' => $data['intraship_note'], - 'iban' => $data['intraship_iban'], - 'bic' => $data['intraship_bic'] - ); - - $cod_details = array( - 'amount'=>str_replace(",",".",$betrag), - 'currency'=>'EUR' - ); - - $response = $this->createNationalShipment($customer_details,$shipment_details,$bank_details,$cod_details,$rechnungsnummer); - } else { - //$customer_details['ordernumber']=""; - $response = $this->createNationalShipment($customer_details,$shipment_details); - } - } else { - $customer_details['EU'] = $this->app->erp->IstEU($land)?1:0; - $response = $this->createWeltShipment($customer_details,null,$bank_details,$cod_details,$artikel); - if($response) - { - // Zoll Papiere - //$dhl = new DHLBusinessShipment($einstellungen, $info); - $response_export = $this->GetExportDocDD($response['shipment_number']); - }else{ - $dump = $this->app->erp->VarAsString($this->errors); - $this->app->erp->Protokoll("Fehler Intraship API beim Erstellen Label fuer Versand $id LS $lieferschein",$dump); - } - } - - $data['intraship_drucker'] = $this->paketmarke_drucker; - $data['druckerlogistikstufe2'] = $this->export_drucker; - - if(!$data['intraship_drucker']) - { - if($this->app->erp->GetStandardPaketmarkendrucker()>0) - $data['intraship_drucker'] = $this->app->erp->GetStandardPaketmarkendrucker(); - } - - if(!$data['druckerlogistikstufe2']) - { - if($this->app->erp->GetInstrashipExport($projekt)>0) - $data['druckerlogistikstufe2'] = $this->app->erp->GetInstrashipExport($projekt); - } - - - - if($response) - { - //$response['label_url'] - //$response['shipment_number'] - $tmppdf = $this->app->erp->DownloadFile($response['label_url'],"Intraship_Versand_".$id."_","pdf"); - $this->app->erp->Protokoll("Erfolg Paketmarke Drucker ".$data['intraship_drucker']," Datei: $tmppdf URL: ".$response['label_url']); - $this->app->printer->Drucken($data['intraship_drucker'],$tmppdf); - unlink($tmppdf); - } else { - $dump = $this->app->erp->VarAsString($this->errors); - $this->app->erp->Protokoll("Fehler Intraship API beim Erstellen Label fuer Versand $id LS $lieferschein",$dump); - } - - if($response_export) - { - $tmppdf = $this->app->erp->DownloadFile($response_export['export_url'],"Export_Intraship_Versand_".$id."_"); - $this->app->erp->Protokoll("Erfolg Export Dokumente Drucker ".$data['druckerlogistikstufe2']," Datei: $tmppdf URL: ".$response_export['export_url']); - $this->app->printer->Drucken($data['druckerlogistikstufe2'],$tmppdf); - unlink($tmppdf); - } else { - $dump = $this->app->erp->VarAsString($this->errors); - $this->app->erp->Protokoll("Fehler Intraship Export Dokument API beim Erstellen fuer Versand $id LS $lieferschein",$dump); - } - - if($response)return false; - return $this->errors; - - } - - - if($this->app->Secure->GetPOST('drucken') || $this->app->Secure->GetPOST('anders')) - { - - - }else{ - if(empty($this->Eintellungen['retourenaccount']) || !$this->Eintellungen['retourenaccount']) - { - $this->app->Tpl->Add('VORRETOURENLABEL', ''); - } - if(isset($this->Eintellungen['retourenlabel']) && $this->Eintellungen['retourenlabel'])$this->app->Tpl->Add('RETOURENLABEL',' checked="checked" '); - } - } - - //$this->info = $customer_info; - if($target)$this->app->Tpl->Parse($target,'versandarten_intraship.tpl'); - } - - public function Export($daten) - { - - } - - function Trackinglink($tracking, &$notsend, &$link, &$rawlink) - { - $notsend = 0; - $rawlink = 'http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc='.$tracking; - $link = 'DHL Versand: '.$tracking.' ('.$rawlink.')'; - return true; - } - - private function log($message) { - - if (isset($this->einstellungen['log'])) { - - if (is_array($message) || is_object($message)) { - - error_log(print_r($message, true)); - - } else { - - error_log($message); - - } - - } - - } - - function buildClient($retoure, $altersfreigabe = false) { - - $header = $this->buildAuthHeader(); - - $location = self::PRODUCTION_URL; - //$location = self::SANDBOX_URL; - - $auth_params = array( - 'login' => $this->einstellungen['api_user'], - 'password' => $this->einstellungen['api_password'], - 'location' => $location, - 'trace' => 1, - 'connection_timeout' => 30 - ); - - $this->log($auth_params); - try { - $this->client = new SoapClient($altersfreigabe?self::API_URL22:($retoure?self::API_URL2:self::API_URL), $auth_params); - } catch(SoapFault $exception) - { - die("Verbindungsfehler: ".$exception->getMessage()); - $this->errors[] = "Verbindungsfehler: ".$exception->getMessage(); - return; - } - try { - $this->client->__setSoapHeaders($header); - } catch(SoapFault $exception) - { - die("Verbindungsfehler: ".$exception->getMessage()); - $this->errors[] = "Verbindungsfehler: ".$exception->getMessage(); - return; - } - - $this->log($this->client); - - } - - function createNationalShipment($customer_details, $shipment_details = null, $bank_details = null, $cod_details = null) { - $api2 = false; - $api22 = isset($customer_details['altersfreigabe']) && $customer_details['altersfreigabe']; - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount'])$api2 = true; - - if(isset($this->einstellungen['leitcodierung']) && $this->einstellungen['leitcodierung'])$api22 = true; - - $this->buildClient($api2, $api22); - - $shipment = array(); - - // Version - $shipment['Version'] = array('majorRelease' => '1', 'minorRelease' => '0'); - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $shipment['Version']['minorRelease'] = '1'; - } - if($api22) - { - $shipment['Version'] = array('majorRelease' => '2', 'minorRelease' => '0'); - } - - if($customer_details['country_code']=="" || $customer_details['country_code']=="DE") - { - $customer_details['country_code']="DE"; - $customer_details['country_zip']="germany"; - } else if ($customer_details['country_code']=="UK"){ - $customer_details['country_zip']="england"; - } else { - $customer_details['country_zip']="other"; - } - - // Order - $shipment['ShipmentOrder'] = array(); - - // Fixme - if($api22) - { - $shipment['ShipmentOrder']['sequenceNumber'] = '01'; - }else{ - $shipment['ShipmentOrder']['SequenceNumber'] = '1'; - } - // Shipment - $s = array(); - if($api22) - { - $s['product'] = "V01PAK"; - }else{ - $s['ProductCode'] = 'EPN'; - } - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $s['ReturnShipmentBillingNumber'] = $this->einstellungen['intraship_retourenaccount']; - } - - if($api22) - { - if(!empty($customer_details['abholdatum']) && $customer_details['abholdatum']!="0000-00-00") - $s['shipmentDate'] = $customer_details['abholdatum']; - else - $s['shipmentDate'] = date('Y-m-d'); - }else{ - if(!empty($customer_details['abholdatum']) && $customer_details['abholdatum']!="0000-00-00") - $s['ShipmentDate'] = $customer_details['abholdatum']; - else - $s['ShipmentDate'] = date('Y-m-d'); - } - - if($api22) - { - $s['accountNumber'] = $this->einstellungen['ekp'].(strlen($this->einstellungen['partnerid'] <= 2)?$this->einstellungen['partnerid']."01":$this->einstellungen['partnerid']); - if ($shipment_details == null) { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['weightInKG'] = '5'; - $s['ShipmentItem']['lengthInCM'] = '50'; - $s['ShipmentItem']['widthInCM'] = '50'; - $s['ShipmentItem']['heightInCM'] = '50'; - } else { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['weightInKG'] = $shipment_details['WeightInKG']; - $s['ShipmentItem']['lengthInCM'] = $shipment_details['LengthInCM']; - $s['ShipmentItem']['widthInCM'] = $shipment_details['WidthInCM']; - $s['ShipmentItem']['heightInCM'] = $shipment_details['HeightInCM']; - } - - // Falls ein Gewicht angegeben worden ist - if($customer_details['weight']!="") - $s['ShipmentItem']['weightInKG'] = $customer_details['weight']; - - - }else{ - $s['EKP'] = $this->einstellungen['ekp']; - - $s['Attendance'] = array(); - $s['Attendance']['partnerID'] = substr($this->einstellungen['partnerid'],0,2); - - - if ($shipment_details == null) { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['WeightInKG'] = '5'; - $s['ShipmentItem']['LengthInCM'] = '50'; - $s['ShipmentItem']['WidthInCM'] = '50'; - $s['ShipmentItem']['HeightInCM'] = '50'; - // FIXME: What is this - $s['ShipmentItem']['PackageType'] = 'PL'; - } else { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['WeightInKG'] = $shipment_details['WeightInKG']; - $s['ShipmentItem']['LengthInCM'] = $shipment_details['LengthInCM']; - $s['ShipmentItem']['WidthInCM'] = $shipment_details['WidthInCM']; - $s['ShipmentItem']['HeightInCM'] = $shipment_details['HeightInCM']; - // FIXME: What is this - $s['ShipmentItem']['PackageType'] = $shipment_details['PackageType']; - } - - // Falls ein Gewicht angegeben worden ist - if($customer_details['weight']!="") - $s['ShipmentItem']['WeightInKG'] = $customer_details['weight']; - - } - - - if($bank_details != null) - { - $s['BankData'] = array(); - $s['BankData']['accountOwner'] = $bank_details['account_owner']; - $s['BankData']['accountNumber'] = $bank_details['account_number']; - $s['BankData']['bankCode'] = $bank_details['bank_code']; - $s['BankData']['bankName'] = $bank_details['bank_name']; - $s['BankData']['iban'] = $bank_details['iban']; - $s['BankData']['bic'] = $bank_details['bic']; - $s['BankData']['note'] = $bank_details['note']; - } - - if($cod_details != null) - { - //$s['Service'] = array(); - //$s['Service']['ServiceGroupOther'] = array(); - $s['Service']['ServiceGroupOther']['COD'] = array(); - $s['Service']['ServiceGroupOther']['COD']['CODAmount'] = $cod_details['amount']; - $s['Service']['ServiceGroupOther']['COD']['CODCurrency'] = $cod_details['currency']; - } - - // Auftragnummer auf Label - if($api22) - { - $s['customerReference']=$customer_details['ordernumber']; - if($customer_details['altersfreigabe'] >= 16) - { - $s['Service']['VisualCheckOfAge'] = array(); - $s['Service']['VisualCheckOfAge']['active'] = 1; - $s['Service']['VisualCheckOfAge']['type'] = $customer_details['altersfreigabe'] > 16?'A18':'A16'; - } - - }else{ - $s['CustomerReference']=$customer_details['ordernumber']; - } - - $shipment['ShipmentOrder']['Shipment']['ShipmentDetails'] = $s; - - //$shipment['ShipmentOrder']['Shipment']['ShipmentDetails'] = $s; - $shipper = array(); - if($api22) - { - $shipper['Name'] = array(); - $shipper['Name']['name1'] = $this->info['company_name']; - }else{ - $shipper['Company'] = array(); - $shipper['Company']['Company'] = array(); - $shipper['Company']['Company']['name1'] = $this->info['company_name']; - } - $shipper['Address'] = array(); - $shipper['Address']['streetName'] = $this->info['street_name']; - $shipper['Address']['streetNumber'] = $this->info['street_number']; - if($api22) - { - $shipper['Address']['zip'] = $this->info['zip']; - }else{ - $shipper['Address']['Zip'] = array(); - $shipper['Address']['Zip'][strtolower($this->info['country'])] = $this->info['zip']; - } - $shipper['Address']['city'] = $this->info['city']; - - $shipper['Address']['Origin'] = array('countryISOCode' => 'DE'); - - $shipper['Communication'] = array(); - if (preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9._-] +)+$/" , $this->info['email'])) { - $shipper['Communication']['email'] = $this->info['email']; - } - $shipper['Communication']['phone'] = $this->info['phone']; - $shipper['Communication']['internet'] = $this->info['internet']; - $shipper['Communication']['contactPerson'] = $this->info['contact_person']; - - - $shipment['ShipmentOrder']['Shipment']['Shipper'] = $shipper; - - if($api22) - { - $receiver = array(); - $receiver['name1'] = $customer_details['name1']; - if($customer_details['name2']!="") - $receiver['name2'] = $customer_details['name2']; - if($customer_details['name3']!="") - $receiver['name3'] = $customer_details['name3']; - - - - - $receiver['Address'] = array(); - if($customer_details['name2']!="") - $receiver['Address']['addressAddition'] = $customer_details['name2']; - $receiver['Address']['streetName'] = $customer_details['street_name']; - $receiver['Address']['streetNumber'] = $customer_details['street_number']; - $receiver['Address']['zip'] = $customer_details['zip']; - $receiver['Address']['city'] = $customer_details['city']; - $receiver['Communication'] = array(); - - if($customer_details['c/o']!="") - $receiver['Communication']['contactPerson'] = $customer_details['c/o']; - - $receiver['Address']['Origin'] = array('countryISOCode' => $customer_details['country_code']); - - $shipment['ShipmentOrder']['Shipment']['Receiver'] = $receiver; - - - }else{ - $receiver = array(); - - $receiver['Company'] = array(); - - /* - $receiver['Company']['Person'] = array(); - $receiver['Company']['Person']['firstname'] = $customer_details['first_name']; - $receiver['Company']['Person']['lastname'] = $customer_details['last_name']; - */ - - $receiver['Company']['Company'] = array(); - $receiver['Company']['Company']['name1'] = $customer_details['name1']; - $receiver['Company']['Company']['name2'] = $customer_details['name2']; - - - $receiver['Address'] = array(); - $receiver['Address']['streetName'] = $customer_details['street_name']; - $receiver['Address']['streetNumber'] = $customer_details['street_number']; - $receiver['Address']['Zip'] = array(); - $receiver['Address']['Zip'][strtolower($customer_details['country_zip'])] = $customer_details['zip']; - $receiver['Address']['city'] = $customer_details['city']; - $receiver['Communication'] = array(); - $receiver['Communication']['contactPerson'] = $customer_details['c/o']; - - $receiver['Address']['Origin'] = array('countryISOCode' => $customer_details['country_code']); - - - $shipment['ShipmentOrder']['Shipment']['Receiver'] = $receiver; - } - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $ReturnReceiver = array(); - $ReturnReceiver['Company'] = array(); - $ReturnReceiver['Company']['Company'] = array(); - $ReturnReceiver['Company']['Company']['name1'] = $this->info['company_name']; - - $ReturnReceiver['Address'] = array(); - $ReturnReceiver['Address']['streetName'] = $this->info['street_name']; - $ReturnReceiver['Address']['streetNumber'] = $this->info['street_number']; - if($api22) - { - $ReturnReceiver['Address']['zip'] = $this->info['zip']; - }else{ - $ReturnReceiver['Address']['Zip'] = array(); - $ReturnReceiver['Address']['Zip'][strtolower($this->info['country'])] = $this->info['zip']; - } - $ReturnReceiver['Address']['city'] = $this->info['city']; - - $ReturnReceiver['Address']['Origin'] = array('countryISOCode' => 'DE'); - - $ReturnReceiver['Communication'] = array(); - if (preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9._-] +)+$/" , $this->info['email'])) { - $shipper['Communication']['email'] = $this->info['email']; - } - $ReturnReceiver['Communication']['phone'] = $this->info['phone']; - $ReturnReceiver['Communication']['internet'] = $this->info['internet']; - $ReturnReceiver['Communication']['contactPerson'] = $this->info['contact_person']; - - - $shipment['ShipmentOrder']['Shipment']['ReturnReceiver'] = $ReturnReceiver; - } - try { - if($api22) - { - $response = $this->client->createShipmentOrder($shipment); - } - else{ - $response = $this->client->CreateShipmentDD($shipment); - } - - } catch(SoapFault $exception) - { - if(trim($exception->getMessage()) == 'Authorization Required') - { - $this->errors[] = 'Fehlerhafte Intraship Zugangsdaten'; - return false; - } - $this->errors[] = "Fehler von Intraship: ".$exception->getMessage(); - return; - } - if (is_soap_fault($response) || (isset($response->status) && $response->status->StatusCode != 0 || isset($response->Status) && $response->Status->statusCode != 0)) { - $this->errors[] = "Fehlermeldung von DHL:"; - - if (is_soap_fault($response)) { - - $this->errors[] = $response->faultstring; - - } else { - - $this->errors[] = isset($response->status)?$response->status->StatusMessage:$response->Status->statusMessage; - - } - if($response->CreationState->StatusMessage) - { - foreach($response->CreationState->StatusMessage as $v) - { - $found = false; - if($this->errors && is_array($this->errors)) - { - foreach($this->errors as $err) - { - if($err == $v)$found = true; - } - } - if(!$found)$this->errors[] = $v; - } - } - return false; - } else { - $r = array(); - if($api22) - { - $r['shipment_number'] = (String) $response->CreationState->LabelData->shipmentNumber; - $r['piece_number'] = (String) $response->CreationState->LabelData->licensePlate; - $r['label_url'] = (String) $response->CreationState->LabelData->labelUrl; - $r['gesamt'] = $response; - }else{ - $r['shipment_number'] = (String) $response->CreationState->ShipmentNumber->shipmentNumber; - $r['piece_number'] = (String) $response->CreationState->PieceInformation->PieceNumber->licensePlate; - $r['label_url'] = (String) $response->CreationState->Labelurl; - } - return $r; - } - - } - - - function createWeltShipment($customer_details, $shipment_details = null, $bank_details = null, $cod_details = null,$artikel=null) { - $api2 = false; - $api22 = isset($customer_details['altersfreigabe']) && $customer_details['altersfreigabe']; - //if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount'])$api2 = true; - $api22 = false; - $this->buildClient($api2); - - $shipment = array(); - - if($customer_details['country_code']=="DE") - { - $customer_details['country']="germany"; - } else if ($customer_details['country_code']=="UK") - { - $customer_details['country']="england"; - } else { - $customer_details['country']="other"; - } - - // Version - if($api22) - { - $shipment['Version'] = array('majorRelease' => '2', 'minorRelease' => '0'); - }else{ - $shipment['Version'] = array('majorRelease' => '1', 'minorRelease' => '0'); - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $shipment['Version']['minorRelease'] = '1'; - } - } - - // Order - $shipment['ShipmentOrder'] = array(); - $s = array(); - // Fixme - if($api22) - { - $shipment['ShipmentOrder']['sequenceNumber'] = '01'; - if(!empty($customer_details['abholdatum']) && $customer_details['abholdatum']!="0000-00-00") - $s['shipmentDate'] = $customer_details['abholdatum']; - else - $s['shipmentDate'] = date('Y-m-d'); - $s['product'] = isset($customer_details['EU'])&&$customer_details['EU']?"V54EPAK": "V53WPAK"; - $s['accountNumber'] =$this->einstellungen['ekp'].$this->einstellungen['partnerid']."01"; - }else{ - $shipment['ShipmentOrder']['SequenceNumber'] = '1'; - $s['ProductCode'] = 'BPI'; - if(!empty($customer_details['abholdatum']) && $customer_details['abholdatum']!="0000-00-00") - $s['ShipmentDate'] = $customer_details['abholdatum']; - else - $s['ShipmentDate'] = date('Y-m-d'); - $s['EKP'] = $this->einstellungen['ekp']; - - $s['Attendance'] = array(); - $s['Attendance']['partnerID'] = $this->einstellungen['partnerid']; - } - - - - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $s['ReturnShipmentBillingNumber'] = $this->einstellungen['intraship_retourenaccount']; - } - - if($api22) - { - if ($shipment_details == null) { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['weightInKG'] = '3'; - $s['ShipmentItem']['lengthInCM'] = '50'; - $s['ShipmentItem']['widthInCM'] = '30'; - $s['ShipmentItem']['heightInCM'] = '15'; - } - }else{ - if ($shipment_details == null) { - $s['ShipmentItem'] = array(); - $s['ShipmentItem']['WeightInKG'] = '3'; - $s['ShipmentItem']['LengthInCM'] = '50'; - $s['ShipmentItem']['WidthInCM'] = '30'; - $s['ShipmentItem']['HeightInCM'] = '15'; - // FIXME: What is this - $s['ShipmentItem']['PackageType'] = 'PK'; - } - - // Falls ein Gewicht angegeben worden ist - if($customer_details['weight']!="") - $s['ShipmentItem']['WeightInKG'] = $customer_details['weight']; - } - //$s['Service']['ServiceGroupBusinessPackInternational']['Economy'] = 'true'; - $s['Service']['ServiceGroupBusinessPackInternational']['Premium'] = 'true'; - - if($bank_details != null) - { - $s['BankData'] = array(); - $s['BankData']['accountOwner'] = $bank_details['account_owner']; - $s['BankData']['accountNumber'] = $bank_details['account_number']; - $s['BankData']['bankCode'] = $bank_details['bank_code']; - $s['BankData']['bankName'] = $bank_details['bank_name']; - $s['BankData']['iban'] = $bank_details['iban']; - $s['BankData']['bic'] = $bank_details['bic']; - $s['BankData']['note'] = $bank_details['note']; - } - - - - if($cod_details != null) - { - //$s['Service'] = array(); - //$s['Service']['ServiceGroupOther'] = array(); - $s['Service']['ServiceGroupOther']['COD'] = array(); - $s['Service']['ServiceGroupOther']['COD']['CODAmount'] = $cod_details['amount']; - $s['Service']['ServiceGroupOther']['COD']['CODCurrency'] = $cod_details['currency']; - } - - // Auftragnummer auf Label - if($api22) - { - $s['customerReference']=$customer_details['ordernumber']; - if($customer_details['altersfreigabe'] >= 16) - { - $s['Service']['VisualCheckOfAge'] = array(); - $s['Service']['VisualCheckOfAge']['active'] = 1; - $s['Service']['VisualCheckOfAge']['type'] = $customer_details['altersfreigabe'] > 16?'A18':'A16'; - } - }else{ - $s['CustomerReference']=$customer_details['ordernumber']; - } - $shipment['ShipmentOrder']['Shipment']['ShipmentDetails'] = $s; - - //$shipment['ShipmentOrder']['Shipment']['ShipmentDetails'] = $s; - - - $shipper = array(); - $shipper['Company'] = array(); - $shipper['Company']['Company'] = array(); - $shipper['Company']['Company']['name1'] = $this->info['company_name']; - - $shipper['Address'] = array(); - $shipper['Address']['streetName'] = $this->info['street_name']; - $shipper['Address']['streetNumber'] = $this->info['street_number']; - if($api22) - { - $shipper['Address']['zip'] = $this->info['zip']; - }else{ - $shipper['Address']['Zip'] = array(); - - $shipper['Address']['Zip'][strtolower($this->info['country'])] = $this->info['zip']; - } - $shipper['Address']['city'] = $this->info['city']; - - $shipper['Address']['Origin'] = array('countryISOCode' => 'DE'); - - - - $shipper['Communication'] = array(); - if (preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9._-] +)+$/" , $this->info['email'])) { - $shipper['Communication']['email'] = $this->info['email']; - } - if(empty($this->info['phone']))$this->info['phone'] = '0'; - $this->info['phone'] = str_replace('+','00',trim($this->info['phone'])); - $this->info['phone'] = preg_replace('![^0-9]!', '', $this->info['phone']); - if(empty($this->info['phone']))$this->info['phone'] = '0'; - - $shipper['Communication']['phone'] = $this->info['phone']; - $shipper['Communication']['internet'] = $this->info['internet']; - - $shipper['Communication']['contactPerson'] = $this->info['contact_person']; - - - $shipment['ShipmentOrder']['Shipment']['Shipper'] = $shipper; - - $receiver = array(); - - - - $receiver['Company']['Company'] = array(); - $receiver['Company']['Company']['name1'] = $customer_details['name1']; - if($customer_details['name2'])$receiver['Company']['Company']['name2'] = $customer_details['name2']; - - if($customer_details['name2']!="") - $tmp_name = explode(' ',$customer_details['name2'],2); - else - $tmp_name = explode(' ',$customer_details['name1'],2); - - if(isset($tmp_name[2]) && $tmp_name[2]){ - $receiver['Company']['Person'] = array(); - $receiver['Company']['Person']['firstname'] = $tmp_name[0]; - $receiver['Company']['Person']['lastname'] = $tmp_name[1]; - } - /* - $receiver['Company'] = array(); - $receiver['Company']['Person'] = array(); - $receiver['Company']['Person']['firstname'] = $customer_details['first_name']; - $receiver['Company']['Person']['lastname'] = $customer_details['last_name']; - */ - $receiver['Address'] = array(); - $receiver['Address']['streetName'] = $customer_details['street_name']; - $receiver['Address']['streetNumber'] = $customer_details['street_number']; - if($api22) - { - $receiver['Address']['zip'] = $customer_details['zip']; - }else{ - $receiver['Address']['Zip'] = array(); - $receiver['Address']['Zip'][strtolower($customer_details['country'])] = $customer_details['zip']; - } - $receiver['Address']['city'] = $customer_details['city']; - $receiver['Communication'] = array(); - if (preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9._-] +)+$/" , $customer_details['email'])) { - $receiver['Communication']['email'] = $customer_details['email']; - } - - if(empty($customer_details['phone']))$customer_details['phone'] = '0'; - $customer_details['phone'] = str_replace('+','00',trim($customer_details['phone'])); - $customer_details['phone'] = preg_replace('![^0-9]!', '', $customer_details['phone']); - if(empty($customer_details['phone']))$customer_details['phone'] = '0'; - $receiver['Communication']['phone'] = $customer_details['phone']; - - if($customer_details['c/o']=="") $customer_details['c/o'] = $customer_details['name2']; - if($customer_details['c/o']=="") $customer_details['c/o'] = $customer_details['name1']; - $receiver['Communication']['contactPerson'] = $customer_details['c/o']; - - $receiver['Address']['Origin'] = array('countryISOCode' => $customer_details['country_code']); - - $shipment['ShipmentOrder']['Shipment']['Receiver'] = $receiver; - - - if(isset($customer_details['intraship_retourenlabel']) && $customer_details['intraship_retourenlabel'] && isset($this->einstellungen['intraship_retourenaccount']) && $this->einstellungen['intraship_retourenaccount']) - { - $ReturnReceiver = array(); - $ReturnReceiver['Company'] = array(); - $ReturnReceiver['Company']['Company'] = array(); - $ReturnReceiver['Company']['Company']['name1'] = $this->info['company_name']; - - $ReturnReceiver['Address'] = array(); - $ReturnReceiver['Address']['streetName'] = $this->info['street_name']; - $ReturnReceiver['Address']['streetNumber'] = $this->info['street_number']; - if($api22) - { - $ReturnReceiver['Address']['zip'] = $this->info['zip']; - }else{ - $ReturnReceiver['Address']['Zip'] = array(); - $ReturnReceiver['Address']['Zip'][strtolower($this->info['country'])] = $this->info['zip']; - } - $ReturnReceiver['Address']['city'] = $this->info['city']; - - $ReturnReceiver['Address']['Origin'] = array('countryISOCode' => $customer_details['country_code']); - - $ReturnReceiver['Communication'] = array(); - if (preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9._-] +)+$/" , $this->info['email'])) { - $shipper['Communication']['email'] = $this->info['email']; - } - $ReturnReceiver['Communication']['phone'] = $this->info['phone']; - $ReturnReceiver['Communication']['internet'] = $this->info['internet']; - $ReturnReceiver['Communication']['contactPerson'] = $this->info['contact_person']; - - - $shipment['ShipmentOrder']['Shipment']['ReturnReceiver'] = $ReturnReceiver; - } - - if($api22) - { - //$export['invoiceType'] = "commercial"; - //$export['invoiceDate'] = date('Y-m-d'); - $export['invoiceNumber'] = $customer_details['ordernumber']; - $export['exportType'] = 0; - $export['exportTypeDescription'] = $this->info['export_reason']; - $export['commodityCode'] = ""; - $export['termsOfTrade'] = "DDP"; - $export['amount'] = (!empty($artikel)?count($artikel):0); - //$export['Description'] = $this->info['export_reason']; - //$export['CountryCodeOrigin'] = "DE"; - $export['additionalFee'] = "10"; - $export['customsValue'] = number_format($customer_details['amount'],2,".",""); - $export['customsCurrency'] = $customer_details['currency']; - //$export['permitNumber'] = ""; - - }else{ - $export['InvoiceType'] = "commercial"; - $export['InvoiceDate'] = date('Y-m-d'); - $export['InvoiceNumber'] = $customer_details['ordernumber']; - $export['ExportType'] = 0; - $export['ExportTypeDescription'] = $this->info['export_reason']; - $export['CommodityCode'] = ""; - $export['TermsOfTrade'] = "DDP"; - $export['Amount'] = (!empty($artikel)?count($artikel):0); - $export['Description'] = $this->info['export_reason']; - $export['CountryCodeOrigin'] = "DE"; - $export['AdditionalFee'] = "10"; - $export['CustomsValue'] = number_format($customer_details['amount'],2,".",""); - $export['CustomsCurrency'] = $customer_details['currency']; - $export['PermitNumber'] = ""; - } - - $p=0; - for($i=0;$i<(!empty($artikel)?count($artikel):0);$i++) - { - if($p>4 && (($export['ExportDocPosition'][4]['CustomsValue'] + $artikel[$i]['value']*$artikel[$i]['amount']) > 0)) { - if($artikel[$i]['currency']=="") $artikel[$i]['currency']="EUR"; - if($api22) - { - $export['ExportDocPosition'][4]['description'] = "Additional Positions"; - $export['ExportDocPosition'][4]['countryCodeOrigin'] = $artikel[$i]['countrycode']; - $export['ExportDocPosition'][4]['commodityCode'] = $artikel[$i]['commodity_code']; - $export['ExportDocPosition'][4]['amount'] += $artikel[$i]['amount']; - $export['ExportDocPosition'][4]['netWeightInKG'] += $artikel[$i]['netweightinkg']; - $export['ExportDocPosition'][4]['grossWeightInKG'] += $artikel[$i]['grossweightinkg']; - $export['ExportDocPosition'][4]['customsValue'] += number_format($artikel[$i]['value']*$artikel[$i]['amount'],2,".",""); - $export['ExportDocPosition'][4]['customsCurrency'] = $artikel[$i]['currency']; - - }else{ - $export['ExportDocPosition'][4]['Description'] = "Additional Positions"; - $export['ExportDocPosition'][4]['CountryCodeOrigin'] = $artikel[$i]['countrycode']; - $export['ExportDocPosition'][4]['CommodityCode'] = $artikel[$i]['commodity_code']; - $export['ExportDocPosition'][4]['Amount'] += $artikel[$i]['amount']; - $export['ExportDocPosition'][4]['NetWeightInKG'] += $artikel[$i]['netweightinkg']; - $export['ExportDocPosition'][4]['GrossWeightInKG'] += $artikel[$i]['grossweightinkg']; - $export['ExportDocPosition'][4]['CustomsValue'] += number_format($artikel[$i]['value']*$artikel[$i]['amount'],2,".",""); - $export['ExportDocPosition'][4]['CustomsCurrency'] = $artikel[$i]['currency']; - } - } else { - - if($artikel[$i]['value']*$artikel[$i]['amount'] > 0) - { - if($artikel[$i]['currency']=="") $artikel[$i]['currency']="EUR"; - if($api22) - { - $export['ExportDocPosition'][$p]['description'] = preg_replace("/[^a-z0-9-.\ \]\[\)\(]/i",'',str_replace(array('ä','Ä','ö','Ö','ü','Ü','ß'),array('ae','Ae','oe','Oe','ue','Ue','ss'),$artikel[$i]['description'])); - $export['ExportDocPosition'][$p]['countryCodeOrigin'] = $artikel[$i]['countrycode']; - $export['ExportDocPosition'][$p]['commodityCode'] = $artikel[$i]['commodity_code']; - $export['ExportDocPosition'][$p]['amount'] = round($artikel[$i]['amount']); - $export['ExportDocPosition'][$p]['netWeightInKG'] = $artikel[$i]['netweightinkg']; - $export['ExportDocPosition'][$p]['grossWeightInKG'] = $artikel[$i]['grossweightinkg']; - - }else{ - $export['ExportDocPosition'][$p]['Description'] = preg_replace("/[^a-z0-9-.\ \]\[\)\(]/i",'',str_replace(array('ä','Ä','ö','Ö','ü','Ü','ß'),array('ae','Ae','oe','Oe','ue','Ue','ss'),$artikel[$i]['description'])); - $export['ExportDocPosition'][$p]['CountryCodeOrigin'] = $artikel[$i]['countrycode']; - $export['ExportDocPosition'][$p]['CommodityCode'] = $artikel[$i]['commodity_code']; - $export['ExportDocPosition'][$p]['Amount'] = round($artikel[$i]['amount']); - $export['ExportDocPosition'][$p]['NetWeightInKG'] = $artikel[$i]['netweightinkg']; - $export['ExportDocPosition'][$p]['GrossWeightInKG'] = $artikel[$i]['grossweightinkg']; - } - - if($artikel[$i]['value']*$artikel[$i]['amount'] > 0) - $export['ExportDocPosition'][$p]['CustomsValue'] = number_format($artikel[$i]['value']*$artikel[$i]['amount'],2,".",""); - $export['ExportDocPosition'][$p]['CustomsCurrency'] = $artikel[$i]['currency']; - $p++; - } - } - } - - $shipment['ShipmentOrder']['Shipment']['ExportDocument'] = $export; - try { - - if($api22) - { - $response = $this->client->createShipmentOrder($shipment); - }else{ - $response = $this->client->CreateShipmentDD($shipment); - } - } catch(SoapFault $exception) - { - if(trim($exception->getMessage()) == 'Authorization Required') - { - $this->errors[] = 'Fehlerhafte Intraship Zugangsdaten'; - return false; - } - $this->errors[] = "Fehler von Intraship: ".$exception->getMessage(); - return; - } - - - - - file_put_contents("request.xml",$this->client->__getLastRequest()); - file_put_contents("response.xml",$this->client->__getLastResponse()); - - if (is_soap_fault($response) || (isset($response->status) && $response->status->StatusCode != 0 || isset($response->Status) && $response->Status->statusCode != 0)) { - $this->errors[] = "Fehlermeldung von DHL:"; - - if (is_soap_fault($response)) { - - $this->errors[] = $response->faultstring; - } else { - - $this->errors[] = isset($response->status)?$response->status->StatusMessage:$response->Status->statusMessage; - - } - if($response->CreationState->StatusMessage) - { - foreach($response->CreationState->StatusMessage as $v) - { - $found = false; - if($this->errors && is_array($this->errors)) - { - foreach($this->errors as $err) - { - if($err == $v)$found = true; - } - } - if(!$found)$this->errors[] = $v; - } - } - - return false; - - } else { - - $r = array(); - $r['shipment_number'] = (String) $response->CreationState->ShipmentNumber->shipmentNumber; - $r['piece_number'] = (String) $response->CreationState->PieceInformation->PieceNumber->licensePlate; - $r['label_url'] = (String) $response->CreationState->Labelurl; - return $r; - } - } - - function GetExportDocDD($shippment_number, $api22 = false) { - - $this->buildClient(); - - $shipment = array(); - - // Version - if($api22) - { - $shipment['Version'] = array('majorRelease' => '2', 'minorRelease' => '0'); - }else{ - $shipment['Version'] = array('majorRelease' => '1', 'minorRelease' => '0'); - } - - // Order - $shipment['ShipmentNumber'] = array('shipmentNumber'=>$shippment_number); - //$shipment['DocType'] = 'PDF'; - $shipment['DocType'] = 'URL'; - - // Fixme - try { - $response = $this->client->GetExportDocDD($shipment); - } catch(SoapFault $exception) - { - if(trim($exception->getMessage()) == 'Authorization Required') - { - $this->errors[] = 'Fehlerhafte Intraship Zugangsdaten'; - return false; - } - - $this->errors[] = "Fehler von Intraship: ".$exception->getMessage(); - return false; - } - - if (is_soap_fault($response) || (isset($response->status) && $response->status->StatusCode != 0 || isset($response->Status) && $response->Status->statusCode != 0)) { - $this->errors[] = "Fehlermeldung von DHL:"; - if (is_soap_fault($response)) { - $this->errors[] = $response->faultstring; - } else { - $this->errors[] = isset($response->status)?$response->status->StatusMessage:$response->Status->statusMessage; - } - return false; - } else { - $r = array(); - $r['export_pdf'] = (String) $response->ExportDocData->ExportDocPDFData; - $r['export_url'] = (String) $response->ExportDocData->ExportDocURL; - return $r; - } - } - - private function buildAuthHeader() { - - $head = $this->einstellungen; - - $auth_params = array( - 'user' => $this->einstellungen['user'], - 'signature' => $this->einstellungen['signature'], - 'type' => 0 - - ); - try{ - $erg = new SoapHeader('http://dhl.de/webservice/cisbase','Authentification', $auth_params); - } catch(SoapFault $exception) - { - $erg = false; - $this->errors[] = "Authentifizierungsfehler: ".$exception->getMessage(); - } - return $erg; - - - } - - -} - -?> diff --git a/www/lib/versandarten/content/versandarten_sendcloud.tpl b/www/lib/versandarten/content/createshipment.tpl similarity index 72% rename from www/lib/versandarten/content/versandarten_sendcloud.tpl rename to www/lib/versandarten/content/createshipment.tpl index 6ca8a33f..f1dd436e 100644 --- a/www/lib/versandarten/content/versandarten_sendcloud.tpl +++ b/www/lib/versandarten/content/createshipment.tpl @@ -1,57 +1,57 @@ -
+
{{msg.text}}
-

{|Paketmarken Drucker für|} SendCloud

+

{|Paketmarken Drucker für|} [CARRIERNAME]

{|Empfänger|}

- + - + - + - - + - + - +
{|Name|}:
{|Firmenname|}:
{|Strasse/Hausnummer|}: - - + +
{|Adresszeile 2|}:
{|PLZ/Ort|}: - + +
{|Bundesland|}:
{|Land|}: -
{|E-Mail|}:
{|Telefon|}:
@@ -61,39 +61,39 @@ - + - + - + - + - + - + - + - + - +
{|Name|}{{form.name}}{{form.original.name}}
{|Ansprechpartner|}{{form.ansprechpartner}}{{form.original.ansprechpartner}}
{|Abteilung|}{{form.abteilung}}{{form.original.abteilung}}
{|Unterabteilung|}{{form.unterabteilung}}{{form.original.unterabteilung}}
{|Adresszusatz|}{{form.adresszusatz}}{{form.original.adresszusatz}}
{|Strasse|}{{form.streetwithnumber}}{{form.original.strasse}}
{|PLZ/Ort|}{{form.plz}} {{form.ort}}{{form.original.plz}} {{form.original.ort}}
{|Bundesland|}{{form.bundesland}}{{form.original.bundesland}}
{|Land|}{{form.land}}{{form.original.land}}
@@ -102,28 +102,32 @@ - + - + - + - + + + + +
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}: - +
{|Premium|}:
@@ -161,25 +165,23 @@ {|Herkunftsland|} {|Einzelwert|} {|Einzelgewicht|} - {|Währung|} {|Gesamtwert|} {|Gesamtgewicht|} - - - - - - - + + + + + + {{Number(pos.menge*pos.zolleinzelwert || 0).toFixed(2)}} {{Number(pos.menge*pos.zolleinzelgewicht || 0).toFixed(3)}} - + {{total_value.toFixed(2)}} {{total_weight.toFixed(3)}} @@ -187,33 +189,27 @@
  -   +
-Name 2: -Name 3: -Land:[EPROO_SELECT_LAND] -PLZ/ort:  -Strasse/Hausnummer:  -E-Mail: -Telefon: - - - - - - -[GEWICHT] - -
- - - -

- - - - - - - - - - - - - - [VORRETOURENLABEL][NACHRETOURENLABEL] - [VORALTERSFREIGABE][NACHALTERSFREIGABE] -
Service
Nachnahme: (Betrag: [BETRAG] EUR)
Extra Versicherung:
Versicherungssumme:
Leitcodierung: ohne Leitcodierung können extra Kosten entstehen
Abholdatum:
Wunschtermin:
Wunschlieferdatum:
Wunschlieferzeitraum: - 18:00 - 20:00 - 19:00 - 21:00 -
Retourenlabel drucken:
Altersfreigabe notwendig:
-

-
  - -[TRACKINGMANUELL] -   -
- - -

- - + + +
+

vollst. Adresse

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{|Name|}{{form.name}}
{|Ansprechpartner|}{{form.ansprechpartner}}
{|Abteilung|}{{form.abteilung}}
{|Unterabteilung|}{{form.unterabteilung}}
{|Adresszusatz|}{{form.adresszusatz}}
{|Strasse|}{{form.streetwithnumber}}
{|PLZ/Ort|}{{form.plz}} {{form.ort}}
{|Bundesland|}{{form.bundesland}}
{|Land|}{{form.land}}
+
+
+

{|Paket|}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}: + +
{|Nachnahme|}: (Betrag: {{ form.codvalue }}
{|Wunschtermin|}:
+
+
+
+

{|Bestellung|}

+ + + + + + + + + + + + + + + + + +
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}: + +
{|Versicherungssumme|}:
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{|Bezeichnung|}{|Menge|}{|HSCode|}{|Herkunftsland|}{|Einzelwert|}{|Einzelgewicht|}{|Währung|}{|Gesamtwert|}{|Gesamtgewicht|} +
{{Number(pos.menge*pos.zolleinzelwert || 0).toFixed(2)}}{{Number(pos.menge*pos.zolleinzelgewicht || 0).toFixed(3)}}
{{total_value.toFixed(2)}}{{total_weight.toFixed(3)}}
+
+
+   +   +
+ + + + \ No newline at end of file diff --git a/www/lib/versandarten/dhl.php b/www/lib/versandarten/dhl.php index 02b1b7a8..e6cf552f 100644 --- a/www/lib/versandarten/dhl.php +++ b/www/lib/versandarten/dhl.php @@ -7,7 +7,9 @@ use Xentral\Carrier\Dhl\Data\Communication; use Xentral\Carrier\Dhl\Data\Country; use Xentral\Carrier\Dhl\Data\CreateShipmentOrderResponse; -use Xentral\Carrier\Dhl\Data\NativeAddress; +use Xentral\Carrier\Dhl\Data\PackStation; +use Xentral\Carrier\Dhl\Data\Postfiliale; +use Xentral\Carrier\Dhl\Data\ReceiverNativeAddress; use Xentral\Carrier\Dhl\Data\Shipment; use Xentral\Carrier\Dhl\Data\ShipmentItem; use Xentral\Carrier\Dhl\DhlApi; @@ -77,7 +79,7 @@ class Versandart_dhl extends Versanddienstleister{ { $shipment = new Shipment(); $shipment->ShipmentDetails->product = $json->product; - $shipment->ShipmentDetails->accountNumber = '22222222220101'; + $shipment->ShipmentDetails->accountNumber = $this->GetAccountNumber($json->product); $shipment->ShipmentDetails->SetShipmentDate(new DateTimeImmutable('today')); $shipment->ShipmentDetails->ShipmentItem = new ShipmentItem(); $shipment->ShipmentDetails->ShipmentItem->weightInKG = $json->weight ?? 0; @@ -95,12 +97,35 @@ class Versandart_dhl extends Versanddienstleister{ $shipment->Shipper->Communication->email = $this->settings->sender_email; $shipment->Shipper->Communication->contactPerson = $this->settings->sender_contact_person; $shipment->Receiver->name1 = $json->name; - $shipment->Receiver->Address = new NativeAddress(); - $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); + switch ($json->addresstype) { + case 0: + $shipment->Receiver->Address = new ReceiverNativeAddress(); + $shipment->Receiver->Address->name2 = $json->name2; + $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; + case 1: + $shipment->Receiver->Packstation = new PackStation(); + $shipment->Receiver->Packstation->postNumber = $json->postnumber; + $shipment->Receiver->Packstation->packstationNumber = $json->parcelstationNumber; + $shipment->Receiver->Packstation->city = $json->city ?? ''; + $shipment->Receiver->Packstation->zip = $json->zip ?? ''; + $shipment->Receiver->Packstation->Origin = Country::Create($json->country ?? 'DE', $json->state); + break; + case 2: + $shipment->Receiver->Postfiliale = new Postfiliale(); + $shipment->Receiver->Postfiliale->postNumber = $json->postnumber; + $shipment->Receiver->Postfiliale->postfilialeNumber = $json->postofficeNumber; + $shipment->Receiver->Postfiliale->city = $json->city ?? ''; + $shipment->Receiver->Postfiliale->zip = $json->zip ?? ''; + $shipment->Receiver->Postfiliale->Origin = Country::Create($json->country ?? 'DE', $json->state); + break; + } $shipment->Receiver->Communication = new Communication(); $shipment->Receiver->Communication->email = $json->email; $shipment->Receiver->Communication->phone = $json->phone; @@ -120,11 +145,13 @@ class Versandart_dhl extends Versanddienstleister{ $ret->Label = base64_decode($result->CreationState->LabelData->labelData); if (isset($result->CreationState->LabelData->exportLabelData)) $ret->ExportDocuments = base64_decode($result->CreationState->LabelData->exportLabelData); - } else { + } else if (isset($result->CreationState)) { if (is_array($result->CreationState->LabelData->Status->statusMessage)) $ret->Errors = $result->CreationState->LabelData->Status->statusMessage; else $ret->Errors[] = $result->CreationState->LabelData->Status->statusMessage; + } else { + $ret->Errors[] = $result->Status->statusText; } return $ret; } @@ -132,38 +159,62 @@ class Versandart_dhl extends Versanddienstleister{ public function GetShippingProducts(): array { $result = []; - $result[] = Product::Create('V01PAK', 'DHL Paket') - ->WithLength(15, 120) - ->WithWidth(11, 60) - ->WithHeight(1, 60) - ->WithWeight(0.01, 31.5); - $result[] = Product::Create('V53WPAK', 'DHL Paket International') - ->WithLength(15, 120) - ->WithWidth(11, 60) - ->WithHeight(1, 60) - ->WithWeight(0.01, 31.5) - ->WithServices([Product::SERVICE_PREMIUM]); - $result[] = Product::Create('V54EPAK', 'DHL Europaket') - ->WithLength(15, 120) - ->WithWidth(11, 60) - ->WithHeight(3.5, 60) - ->WithWeight(0.01, 31.5); - $result[] = Product::Create('V55PAK', 'DHL Paket Connect') - ->WithLength(15, 120) - ->WithWidth(11, 60) - ->WithHeight(3.5, 60) - ->WithWeight(0.01, 31.5); - $result[] = Product::Create('V62WP', 'DHL Warenpost') - ->WithLength(10, 35) - ->WithWidth(7, 25) - ->WithHeight(0.1, 5) - ->WithWeight(0.01, 1); - $result[] = Product::Create('V66WPI', 'DHL Warenpost International') - ->WithLength(10, 35) - ->WithWidth(7, 25) - ->WithHeight(0.1, 10) - ->WithWeight(0.01, 1) - ->WithServices([Product::SERVICE_PREMIUM]); + if ($this->settings->accountnumber) { + $result[] = Product::Create('V01PAK', 'DHL Paket') + ->WithLength(15, 120) + ->WithWidth(11, 60) + ->WithHeight(1, 60) + ->WithWeight(0.01, 31.5); + } + if ($this->settings->accountnumber_int) { + $result[] = Product::Create('V53WPAK', 'DHL Paket International') + ->WithLength(15, 120) + ->WithWidth(11, 60) + ->WithHeight(1, 60) + ->WithWeight(0.01, 31.5) + ->WithServices([Product::SERVICE_PREMIUM]); + } + if ($this->settings->accountnumber_euro) { + $result[] = Product::Create('V54EPAK', 'DHL Europaket') + ->WithLength(15, 120) + ->WithWidth(11, 60) + ->WithHeight(3.5, 60) + ->WithWeight(0.01, 31.5); + } + if ($this->settings->accountnumber_connect) { + $result[] = Product::Create('V55PAK', 'DHL Paket Connect') + ->WithLength(15, 120) + ->WithWidth(11, 60) + ->WithHeight(3.5, 60) + ->WithWeight(0.01, 31.5); + } + if ($this->settings->accountnumber_wp) { + $result[] = Product::Create('V62WP', 'DHL Warenpost') + ->WithLength(10, 35) + ->WithWidth(7, 25) + ->WithHeight(0.1, 5) + ->WithWeight(0.01, 1); + } + if ($this->settings->accountnumber_wpint) { + $result[] = Product::Create('V66WPI', 'DHL Warenpost International') + ->WithLength(10, 35) + ->WithWidth(7, 25) + ->WithHeight(0.1, 10) + ->WithWeight(0.01, 1) + ->WithServices([Product::SERVICE_PREMIUM]); + } return $result; } + + private function GetAccountNumber(string $product):?string { + switch ($product) { + case 'V01PAK': return $this->settings->accountnumber; + case 'V53WPAK': return $this->settings->accountnumber_int; + case 'V54EPAK': return $this->settings->accountnumber_euro; + case 'V55PAK': return $this->settings->accountnumber_connect; + case 'V62WP': return $this->settings->accountnumber_wp; + case 'V66WPI': return $this->settings->accountnumber_wpint; + } + return null; + } } diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 263fbec8..5a44e890 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -75,13 +75,27 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->SenderAddressId = $this->settings->sender_address; $parcel->ShippingMethodId = $json->product; $parcel->Name = $json->name; - $parcel->CompanyName = $json->companyname; + switch ($json->addresstype) { + case 0: + $parcel->CompanyName = trim("$json->name2 $json->name3"); + $parcel->Address = $json->street; + $parcel->Address2 = $json->address2; + $parcel->HouseNumber = $json->streetnumber; + break; + case 1: + $parcel->CompanyName = $json->postnumber; + $parcel->Address = "Packstation"; + $parcel->HouseNumber = $json->parcelstationNumber; + break; + case 2: + $parcel->CompanyName = $json->postnumber; + $parcel->Address = "Postfiliale"; + $parcel->HouseNumber = $json->postofficeNumber; + break; + } $parcel->Country = $json->country; $parcel->PostalCode = $json->zip; $parcel->City = $json->city; - $parcel->Address = $json->street; - $parcel->Address2 = $json->address2; - $parcel->HouseNumber = $json->streetnumber; $parcel->EMail = $json->email; $parcel->Telephone = $json->phone; $parcel->CountryState = $json->state; From 575ab86157e86c87f5a0893de0322ddc88b44385 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 21:11:12 +0100 Subject: [PATCH 09/16] Sendcloud error handling --- classes/Carrier/SendCloud/SendCloudApi.php | 4 ++-- classes/Carrier/SendCloud/SendcloudApiException.php | 6 +++--- www/lib/class.versanddienstleister.php | 2 +- www/lib/versandarten/sendcloud.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/Carrier/SendCloud/SendCloudApi.php b/classes/Carrier/SendCloud/SendCloudApi.php index 18f87bff..140f3984 100644 --- a/classes/Carrier/SendCloud/SendCloudApi.php +++ b/classes/Carrier/SendCloud/SendCloudApi.php @@ -77,9 +77,9 @@ class SendCloudApi $response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]); switch ($response['code']) { case 200: - if (isset($response->parcel)) + if (isset($response['body']->parcel)) try { - return ParcelResponse::fromApiResponse($response->parcel); + return ParcelResponse::fromApiResponse($response['body']->parcel); } catch (Exception $e) { throw new SendcloudApiException(previous: $e); } diff --git a/classes/Carrier/SendCloud/SendcloudApiException.php b/classes/Carrier/SendCloud/SendcloudApiException.php index 247fa9af..8062a1e8 100644 --- a/classes/Carrier/SendCloud/SendcloudApiException.php +++ b/classes/Carrier/SendCloud/SendcloudApiException.php @@ -8,11 +8,11 @@ class SendcloudApiException extends Exception { public static function fromResponse(array $response) : SendcloudApiException { if (!isset($response['body']) || !is_object($response['body'])) - return new SendcloudApiException(); + return new SendcloudApiException(print_r($response,true)); return new SendcloudApiException( - $response['body']->error->message ?? '', - $response['body']->error->code ?? 0 + print_r($response['body'],true), + $response['code'] ); } } \ No newline at end of file diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index a55cfe33..1e569c09 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -353,7 +353,7 @@ abstract class Versanddienstleister public function Paketmarke(string $target, string $docType, int $docId): void { $address = $this->GetAdressdaten($docId, $docType); - if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) { + if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) { $json = json_decode(file_get_contents('php://input')); $ret = []; if ($json->submit == 'print') { diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 5a44e890..51204348 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -131,7 +131,7 @@ class Versandart_sendcloud extends Versanddienstleister $ret->Errors[] = $result; } } catch (SendcloudApiException $e) { - $ret->Errors[] = $e->getMessage(); + $ret->Errors[] = strval($e); } return $ret; } From b14265b49d9bb2e086c169191343832a164b5b5b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 21:18:00 +0100 Subject: [PATCH 10/16] Sendcloud fix error if no export documents are present --- www/lib/versandarten/sendcloud.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 51204348..18bee5cb 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -126,7 +126,8 @@ class Versandart_sendcloud extends Versanddienstleister $ret->Label = $this->api->DownloadDocument($doc); $doc = $result->GetDocumentByType(Document::TYPE_CN23); - $ret->ExportDocuments = $this->api->DownloadDocument($doc); + if ($doc) + $ret->ExportDocuments = $this->api->DownloadDocument($doc); } else { $ret->Errors[] = $result; } From 88eb1757b2ca91f4f8cba2eac373c1e260c99e1a Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 23:33:33 +0100 Subject: [PATCH 11/16] Fix usage of Versandarten by cronjobs --- www/lib/class.versanddienstleister.php | 4 ++-- www/lib/versandarten/sendcloud.php | 2 +- www/pages/versandarten.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 1e569c09..c2cdd179 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -7,7 +7,7 @@ use Xentral\Modules\ShippingMethod\Model\Product; abstract class Versanddienstleister { protected int $id; - protected Application $app; + protected ApplicationCore $app; protected string $type; protected int $projectId; protected ?int $labelPrinterId; @@ -16,7 +16,7 @@ abstract class Versanddienstleister protected ?int $businessLetterTemplateId; protected ?object $settings; - public function __construct(Application $app, ?int $id) + public function __construct(ApplicationCore $app, ?int $id) { $this->app = $app; if ($id === null || $id === 0) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 18bee5cb..0908a79c 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -19,7 +19,7 @@ class Versandart_sendcloud extends Versanddienstleister protected SendCloudApi $api; protected array $options; - public function __construct(Application $app, ?int $id) + public function __construct(ApplicationCore $app, ?int $id) { parent::__construct($app, $id); if (!isset($this->id)) diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index a7651401..b10fb415 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -21,7 +21,7 @@ use Xentral\Widgets\ClickByClickAssistant\VueUtil; class Versandarten { const MODULE_NAME = 'ShippingMethod'; - var Application $app; + var ApplicationCore $app; /** @var string[] $stylesheet */ public array $stylesheet = [ './classes/Modules/Appstore/www/css/tilegrid.css', @@ -35,10 +35,10 @@ class Versandarten { /** * Versandarten constructor. * - * @param Application $app + * @param ApplicationCore $app * @param bool $intern */ - public function __construct(Application $app, bool $intern = false) + public function __construct(ApplicationCore $app, bool $intern = false) { $this->app=$app; if($intern) { From aafcb4130f53deabdd840179e1695770b9cbef0c Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 31 Jan 2023 12:12:01 +0100 Subject: [PATCH 12/16] Versanddienstleister: prefill order number, zolleinzelwert should default to 0 instead of null --- www/lib/class.versanddienstleister.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index c2cdd179..6bde178b 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -113,6 +113,16 @@ abstract class Versanddienstleister $ret['postnumber'] = $match[0]; } + if ($auftragId > 0) { + $internet = $this->app->DB->Select("SELECT internet FROM auftrag WHERE id = $auftragId LIMIT 1"); + if (!empty($internet)) + $orderNumberParts[] = $internet; + } + if (!empty($docArr['ihrebestellnummer'])) { + $orderNumberParts[] = $docArr['ihrebestellnummer']; + } + $orderNumberParts[] = $docArr['belegnr']; + $ret['order_number'] = implode(' / ', $orderNumberParts); } // wenn rechnung im spiel entweder durch versand oder direkt rechnung @@ -132,7 +142,7 @@ abstract class Versanddienstleister lp.menge, coalesce(nullif(lp.zolltarifnummer, ''), nullif(rp.zolltarifnummer, ''), nullif(a.zolltarifnummer, '')) as zolltarifnummer, coalesce(nullif(lp.herkunftsland, ''), nullif(rp.herkunftsland, ''), nullif(a.herkunftsland, '')) as herkunftsland, - coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100)) as zolleinzelwert, + coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100), 0) as zolleinzelwert, coalesce(nullif(lp.zolleinzelgewicht, 0), a.gewicht) as zolleinzelgewicht, lp.zollwaehrung FROM lieferschein_position lp From d84b20fafe6f548e85cf6d15b38b608b12e7eb8b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Wed, 1 Feb 2023 15:42:03 +0100 Subject: [PATCH 13/16] Versandarten: Bugfix shipment_type not transmitted --- www/lib/class.versanddienstleister.php | 2 +- www/lib/versandarten/content/createshipment.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 6bde178b..ed528a2f 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -395,7 +395,7 @@ abstract class Versanddienstleister $this->app->ExitXentral(); } - $address['sendungsart'] = CustomsInfo::CUSTOMS_TYPE_GOODS; + $address['shipment_type'] = CustomsInfo::CUSTOMS_TYPE_GOODS; $products = $this->GetShippingProducts(); $products = array_combine(array_column($products, 'Id'), $products); $address['product'] = $products[0]->Id ?? ''; diff --git a/www/lib/versandarten/content/createshipment.tpl b/www/lib/versandarten/content/createshipment.tpl index 6d545f2e..1723d1a9 100644 --- a/www/lib/versandarten/content/createshipment.tpl +++ b/www/lib/versandarten/content/createshipment.tpl @@ -175,7 +175,7 @@ {|Sendungsart|}: - From ef8b79ff193640e0fac25619812c070ceca9bb5c Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 5 Feb 2023 22:15:54 +0100 Subject: [PATCH 14/16] Versandarten: Bugfix prefill Zolltarifnummer,Herkunftsland --- www/lib/class.versanddienstleister.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index ed528a2f..58f2db63 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -140,8 +140,8 @@ abstract class Versanddienstleister $sql = "SELECT lp.bezeichnung, lp.menge, - coalesce(nullif(lp.zolltarifnummer, ''), nullif(rp.zolltarifnummer, ''), nullif(a.zolltarifnummer, '')) as zolltarifnummer, - coalesce(nullif(lp.herkunftsland, ''), nullif(rp.herkunftsland, ''), nullif(a.herkunftsland, '')) as herkunftsland, + coalesce(nullif(lp.zolltarifnummer, '0'), nullif(rp.zolltarifnummer, '0'), nullif(a.zolltarifnummer, '')) as zolltarifnummer, + coalesce(nullif(lp.herkunftsland, '0'), nullif(rp.herkunftsland, '0'), nullif(a.herkunftsland, '')) as herkunftsland, coalesce(nullif(lp.zolleinzelwert, '0'), rp.preis *(1-rp.rabatt/100), 0) as zolleinzelwert, coalesce(nullif(lp.zolleinzelgewicht, 0), a.gewicht) as zolleinzelgewicht, lp.zollwaehrung @@ -149,7 +149,10 @@ abstract class Versanddienstleister JOIN artikel a on lp.artikel = a.id LEFT JOIN auftrag_position ap on lp.auftrag_position_id = ap.id LEFT JOIN rechnung_position rp on ap.id = rp.auftrag_position_id + LEFT JOIN rechnung r on rp.rechnung = r.id WHERE lp.lieferschein = $lieferscheinId + AND a.lagerartikel = 1 + AND r.status != 'storniert' ORDER BY lp.sort"; $ret['positions'] = $this->app->DB->SelectArr($sql); From 9defde81ae481d322f13385a3f40ea827a74f5cc Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Mon, 6 Feb 2023 13:08:53 +0100 Subject: [PATCH 15/16] Lieferschein/Paketmarke: Check for valid options before loadVersandModul --- www/pages/lieferschein.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/pages/lieferschein.php b/www/pages/lieferschein.php index b8dc2564..c289f3bd 100644 --- a/www/pages/lieferschein.php +++ b/www/pages/lieferschein.php @@ -459,6 +459,10 @@ class Lieferschein extends GenLieferschein WHERE l.id=$id AND v.aktiv = 1 AND v.ausprojekt = 0 AND v.modul != '' ORDER BY v.projekt DESC LIMIT 1"); + if (empty($result['modul']) || empty($result['id'])) { + $this->app->Tpl->addMessage('error', 'Bitte zuerst eine gültige Versandart auswählen', false, 'PAGE'); + return; + } $versandmodul = $this->app->erp->LoadVersandModul($result['modul'], $result['id']); $versandmodul->Paketmarke('TAB1', 'lieferschein', $id); $this->app->Tpl->Parse('PAGE',"tabview.tpl"); From f37ef6e5918adf918ad34090c3a1321c57262be1 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 28 Feb 2023 13:36:25 +0100 Subject: [PATCH 16/16] add copyright/license --- classes/Carrier/Dhl/Data/Bank.php | 6 + classes/Carrier/Dhl/Data/Communication.php | 6 + classes/Carrier/Dhl/Data/Contact.php | 6 + classes/Carrier/Dhl/Data/Country.php | 6 + .../Dhl/Data/CreateShipmentOrderRequest.php | 6 + .../Dhl/Data/CreateShipmentOrderResponse.php | 6 + classes/Carrier/Dhl/Data/CreationState.php | 6 + classes/Carrier/Dhl/Data/Customer.php | 6 + .../Dhl/Data/DeleteShipmentOrderRequest.php | 6 + .../Dhl/Data/DeleteShipmentOrderResponse.php | 6 + classes/Carrier/Dhl/Data/DeletionState.php | 6 + classes/Carrier/Dhl/Data/DeliveryAddress.php | 6 + classes/Carrier/Dhl/Data/Dimension.php | 6 + .../Carrier/Dhl/Data/ExportDocPosition.php | 6 + classes/Carrier/Dhl/Data/ExportDocument.php | 6 + classes/Carrier/Dhl/Data/LabelData.php | 6 + classes/Carrier/Dhl/Data/Name.php | 6 + classes/Carrier/Dhl/Data/NativeAddress.php | 6 + classes/Carrier/Dhl/Data/NativeAddressNew.php | 6 + classes/Carrier/Dhl/Data/PackStation.php | 6 + classes/Carrier/Dhl/Data/Postfiliale.php | 6 + classes/Carrier/Dhl/Data/Receiver.php | 6 + .../Dhl/Data/ReceiverNativeAddress.php | 6 + classes/Carrier/Dhl/Data/Shipment.php | 6 + classes/Carrier/Dhl/Data/ShipmentDetails.php | 6 + classes/Carrier/Dhl/Data/ShipmentItem.php | 6 + .../Carrier/Dhl/Data/ShipmentNotification.php | 6 + classes/Carrier/Dhl/Data/ShipmentOrder.php | 6 + classes/Carrier/Dhl/Data/ShipmentService.php | 6 + classes/Carrier/Dhl/Data/Shipper.php | 6 + classes/Carrier/Dhl/Data/Status.php | 6 + classes/Carrier/Dhl/Data/StatusElement.php | 6 + .../Carrier/Dhl/Data/Statusinformation.php | 6 + classes/Carrier/Dhl/Data/Version.php | 6 + classes/Carrier/Dhl/DhlApi.php | 6 + classes/Carrier/SendCloud/Data/Document.php | 6 + classes/Carrier/SendCloud/Data/ParcelBase.php | 6 + .../Carrier/SendCloud/Data/ParcelCreation.php | 6 + .../SendCloud/Data/ParcelCreationError.php | 6 + classes/Carrier/SendCloud/Data/ParcelItem.php | 6 + .../Carrier/SendCloud/Data/ParcelResponse.php | 6 + .../Carrier/SendCloud/Data/SenderAddress.php | 7 + .../Carrier/SendCloud/Data/ShippingMethod.php | 7 + .../SendCloud/Data/ShippingProduct.php | 7 + classes/Carrier/SendCloud/SendCloudApi.php | 6 + .../SendCloud/SendcloudApiException.php | 6 + .../Model/CreateShipmentResult.php | 6 + .../ShippingMethod/Model/CustomsInfo.php | 6 + .../Modules/ShippingMethod/Model/Product.php | 6 + .../www/js/shipping_method_create.js | 7 + phpwf/plugins/class.templateparser.php | 7 + www/lib/class.erpapi.php | 7 + www/lib/class.versanddienstleister.php | 6 + .../versandarten/content/createshipment.tpl | 6 + .../content/versandarten_dhlversenden.tpl | 249 ------------------ .../content/versandarten_shipcloud.tpl | 69 ----- .../content/versandarten_sonstiges.tpl | 19 -- www/lib/versandarten/dhl.php | 6 +- www/lib/versandarten/sendcloud.php | 6 + www/pages/content/versandarten_edit.tpl | 6 + www/pages/content/versandarten_neu.tpl | 6 + www/pages/lieferschein.php | 8 + www/pages/versandarten.php | 8 + 63 files changed, 368 insertions(+), 339 deletions(-) delete mode 100644 www/lib/versandarten/content/versandarten_dhlversenden.tpl delete mode 100644 www/lib/versandarten/content/versandarten_shipcloud.tpl delete mode 100644 www/lib/versandarten/content/versandarten_sonstiges.tpl diff --git a/classes/Carrier/Dhl/Data/Bank.php b/classes/Carrier/Dhl/Data/Bank.php index e213e7a1..01a0cf76 100644 --- a/classes/Carrier/Dhl/Data/Bank.php +++ b/classes/Carrier/Dhl/Data/Bank.php @@ -1,5 +1,11 @@ +
diff --git a/www/lib/versandarten/content/versandarten_dhlversenden.tpl b/www/lib/versandarten/content/versandarten_dhlversenden.tpl deleted file mode 100644 index 826410a1..00000000 --- a/www/lib/versandarten/content/versandarten_dhlversenden.tpl +++ /dev/null @@ -1,249 +0,0 @@ -
- -
-
{{msg.text}}
-
-

{|Paketmarken Drucker für|} SendCloud

-
-
-

{|Empfänger|}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{|Name|}:
{|Name 2|}:
{|Name 3|}:
{|Strasse/Hausnummer|}: - - -
{|PLZ/Ort|}: - -
{|Bundesland|}:
{|Land|}: - -
{|E-Mail|}:
{|Telefon|}:
-
-
-

vollst. Adresse

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{|Name|}{{form.name}}
{|Ansprechpartner|}{{form.ansprechpartner}}
{|Abteilung|}{{form.abteilung}}
{|Unterabteilung|}{{form.unterabteilung}}
{|Adresszusatz|}{{form.adresszusatz}}
{|Strasse|}{{form.streetwithnumber}}
{|PLZ/Ort|}{{form.plz}} {{form.ort}}
{|Bundesland|}{{form.bundesland}}
{|Land|}{{form.land}}
-
-
-

{|Paket|}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{|Gewicht (in kg)|}:
{|Höhe (in cm)|}:
{|Breite (in cm)|}:
{|Länge (in cm)|}:
{|Produkt|}: - -
{|Nachnahme|}: (Betrag: {{ form.codvalue }}
{|Wunschtermin|}:
-
-
-
-

{|Bestellung|}

- - - - - - - - - - - - - - - - - -
{|Bestellnummer|}:
{|Rechnungsnummer|}:
{|Sendungsart|}: - -
{|Versicherungssumme|}:
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{|Bezeichnung|}{|Menge|}{|HSCode|}{|Herkunftsland|}{|Einzelwert|}{|Einzelgewicht|}{|Währung|}{|Gesamtwert|}{|Gesamtgewicht|} -
{{Number(pos.menge*pos.zolleinzelwert || 0).toFixed(2)}}{{Number(pos.menge*pos.zolleinzelgewicht || 0).toFixed(3)}}
{{total_value.toFixed(2)}}{{total_weight.toFixed(3)}}
-
-
-   -   -
-
- -
- \ No newline at end of file diff --git a/www/lib/versandarten/content/versandarten_shipcloud.tpl b/www/lib/versandarten/content/versandarten_shipcloud.tpl deleted file mode 100644 index 2fdf142a..00000000 --- a/www/lib/versandarten/content/versandarten_shipcloud.tpl +++ /dev/null @@ -1,69 +0,0 @@ -

- -
-
-
-[ERROR] -

Paketmarken Drucker für [ZUSATZ]

-
-Empfänger -
-
- -
- - - - - - - - - - - - - - -
Name:
Name 2:
p. Adr.:
Land:[EPROO_SELECT_LAND]
PLZ/Ort: 
Strasse/Hausnummer: 
E-Mail:
Telefon:
- - - - [GEWICHT] - - - - - - - - - - - - -
Höhe (in cm): - -
Breite (in cm): - -
Länge (in cm): - -
- -
- - -

-
  - [TRACKINGMANUELL] -    -
-
-
- -

-
diff --git a/www/lib/versandarten/content/versandarten_sonstiges.tpl b/www/lib/versandarten/content/versandarten_sonstiges.tpl deleted file mode 100644 index f36a299b..00000000 --- a/www/lib/versandarten/content/versandarten_sonstiges.tpl +++ /dev/null @@ -1,19 +0,0 @@ -

- -
-
-
-[ERROR] -

[ZUSATZ]

- -
-
-
-
  - -   -
-
-
-

diff --git a/www/lib/versandarten/dhl.php b/www/lib/versandarten/dhl.php index e6cf552f..ad065d86 100644 --- a/www/lib/versandarten/dhl.php +++ b/www/lib/versandarten/dhl.php @@ -1,7 +1,9 @@
    diff --git a/www/pages/content/versandarten_neu.tpl b/www/pages/content/versandarten_neu.tpl index d6f9727e..67c59ca7 100644 --- a/www/pages/content/versandarten_neu.tpl +++ b/www/pages/content/versandarten_neu.tpl @@ -1,3 +1,9 @@ +
      diff --git a/www/pages/lieferschein.php b/www/pages/lieferschein.php index c289f3bd..6c7fdaf2 100644 --- a/www/pages/lieferschein.php +++ b/www/pages/lieferschein.php @@ -1,4 +1,12 @@