From cd93d643f89fd5dce17ee50b146138ce3d3c5e08 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 21 Oct 2022 10:46:09 +0200 Subject: [PATCH 01/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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/51] 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 6e8f715f66102e0bcacb22f7e252a962ee02a62b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 18 Oct 2022 13:41:34 +0200 Subject: [PATCH 09/51] Create module rechnungslauf, basic version --- .../Modules/SubscriptionCycle/Bootstrap.php | 36 +-- .../SubscriptionCycleManualJobTask.php | 176 ++--------- .../Service/SubscriptionCycleJobService.php | 12 +- .../SubscriptionCycle/SubscriptionModule.php | 101 +++++++ .../SubscriptionModuleInterface.php | 35 +-- upgrade/data/db_schema.json | 86 ++++++ www/pages/content/rechnungslauf_abos.tpl | 8 + www/pages/content/rechnungslauf_list.tpl | 36 +++ .../content/rechnungslauf_minidetail.tpl | 2 +- www/pages/rechnungslauf.php | 279 ++++++++++++++++++ 10 files changed, 552 insertions(+), 219 deletions(-) create mode 100644 classes/Modules/SubscriptionCycle/SubscriptionModule.php create mode 100644 www/pages/content/rechnungslauf_abos.tpl create mode 100644 www/pages/content/rechnungslauf_list.tpl create mode 100644 www/pages/rechnungslauf.php diff --git a/classes/Modules/SubscriptionCycle/Bootstrap.php b/classes/Modules/SubscriptionCycle/Bootstrap.php index 8e5fdb0b..a27c4664 100644 --- a/classes/Modules/SubscriptionCycle/Bootstrap.php +++ b/classes/Modules/SubscriptionCycle/Bootstrap.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Xentral\Modules\SubscriptionCycle; use Aboabrechnung; +use Sabre\CalDAV\Subscriptions\Subscription; use Xentral\Components\SchemaCreator\Collection\SchemaCollection; use Xentral\Components\SchemaCreator\Schema\TableSchema; use Xentral\Components\SchemaCreator\Type; @@ -35,6 +36,7 @@ final class Bootstrap 'SubscriptionCycleJobService' => 'onInitSubscriptionCycleJobService', 'SubscriptionCycleFullTask' => 'onInitSubscriptionCycleFullTask', 'TaskMutexService' => 'onInitTaskMutexService', + 'SubscriptionModule' => 'onInitSubscriptionModule' ]; } @@ -60,20 +62,12 @@ final class Bootstrap */ public static function onInitSubscriptionCycleManualJobTask(ContainerInterface $container ): SubscriptionCycleManualJobTask { - $legacyApp = $container->get('LegacyApplication'); - - $subscriptionCycleModule = $legacyApp->loadModule('rechnungslauf'); - $subscriptionModule = new Aboabrechnung($legacyApp); - $subscriptionModule->cronjob = true; - return new SubscriptionCycleManualJobTask( - $legacyApp, + $container->get('LegacyApplication'), $container->get('Database'), $container->get('TaskMutexService'), $container->get('SubscriptionCycleJobService'), - $subscriptionCycleModule, - $subscriptionModule, - !empty($legacyApp->erp->GetKonfiguration('rechnungslauf_gruppen')) + $container->get('SubscriptionModule') ); } @@ -210,22 +204,10 @@ final class Bootstrap ); } - /** - * @param SchemaCollection $collection - * - * @return void - */ - public static function registerTableSchemas(SchemaCollection $collection): void - { - $subscriptionCycleJob = new TableSchema('subscription_cycle_job'); - $subscriptionCycleJob->addColumn(Type\Integer::asAutoIncrement('id')); - $subscriptionCycleJob->addColumn(new Type\Integer('address_id')); - $subscriptionCycleJob->addColumn(new Type\Varchar('document_type', 32)); - $subscriptionCycleJob->addColumn(new Type\Varchar('job_type', 32)); - $subscriptionCycleJob->addColumn(new Type\Integer('printer_id')); - $subscriptionCycleJob->addColumn(new Type\Timestamp('created_at', 'CURRENT_TIMESTAMP')); - $subscriptionCycleJob->addIndex(new Index\Primary(['id'])); - $subscriptionCycleJob->addIndex(new Index\Index(['address_id'])); - $collection->add($subscriptionCycleJob); + public static function onInitSubscriptionModule(ContainerInterface $container): SubscriptionModule { + return new SubscriptionModule( + $container->get('LegacyApplication'), + $container->get('Database') + ); } } diff --git a/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php b/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php index b7b4b03a..f7378baa 100644 --- a/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php +++ b/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php @@ -16,52 +16,33 @@ use Xentral\Modules\SubscriptionCycle\SubscriptionModuleInterface; final class SubscriptionCycleManualJobTask { - /** @var ApplicationCore $app */ - private $app; + private ApplicationCore $app; + private Database $db; + private SubscriptionCycleJobService $cycleJobService; + private TaskMutexServiceInterface $taskMutexService; + private SubscriptionModuleInterface $subscriptionModule; - /** @var Database $db */ - private $db; - - /** @var SubscriptionCycleJobService $cycleJobService */ - private $cycleJobService; - - /** @var TaskMutexServiceInterface $taskMutexService */ - private $taskMutexService; - - /** @var SubscriptionCycleModuleInterface $subscriptionCycleModule */ - private $subscriptionCycleModule; - - /** @var SubscriptionModuleInterface $subscriptionModule */ - private $subscriptionModule; - - /** @var bool $useGroups */ - private $useGroups; - - /** - * SubscriptionCycleManualJobTask constructor. - * - * @param ApplicationCore $app - * @param Database $db - * @param SubscriptionCycleJobService $cycleJobService - * @param SubscriptionCycleModuleInterface $subscriptionCycleModule - * @param bool $useGroups - */ + /** + * SubscriptionCycleManualJobTask constructor. + * + * @param ApplicationCore $app + * @param Database $db + * @param TaskMutexServiceInterface $taskMutexService + * @param SubscriptionCycleJobService $cycleJobService + * @param SubscriptionModuleInterface $subscriptionModule + */ public function __construct( ApplicationCore $app, Database $db, TaskMutexServiceInterface $taskMutexService, SubscriptionCycleJobService $cycleJobService, - SubscriptionCycleModuleInterface $subscriptionCycleModule, SubscriptionModuleInterface $subscriptionModule, - bool $useGroups ) { $this->app = $app; $this->db = $db; $this->taskMutexService = $taskMutexService; $this->cycleJobService = $cycleJobService; - $this->subscriptionCycleModule = $subscriptionCycleModule; $this->subscriptionModule = $subscriptionModule; - $this->useGroups = $useGroups; } public function execute(): void @@ -71,77 +52,16 @@ final class SubscriptionCycleManualJobTask } $this->taskMutexService->setMutex('rechnungslauf_manual'); $jobs = $this->cycleJobService->listAll(100); - $simulatedDays = $this->getSimulatedDates($jobs); - if (empty($jobs)) { - return; - } - foreach (['auftrag', 'rechnung'] as $doctype) { - foreach ($simulatedDays as $simulatedDay) { - if ($simulatedDay === '') { - $simulatedDay = null; - } else { - try { - $simulatedDay = new DateTimeImmutable($simulatedDay); - } catch (Exception $exception) { - $simulatedDay = null; - } - } - $addresses = $this->getAddressesByTypeFromJobs($jobs, $doctype, $simulatedDay); - foreach ($jobs as $job) { - $job = $this->cycleJobService->getJob((int)$job['id']); - if (empty($job)) { - continue; - } - if ($job['document_type'] !== $doctype) { - continue; - } - if ($job['simulated_day'] === null && $simulatedDay !== null) { - continue; - } - if ( - $job['simulated_day'] !== null - && ($simulatedDay === null || $simulatedDay->format('Y-m-d') !== $job['simulated_day']) - ) { - continue; - } - if (!in_array($job['address_id'], $addresses, false)) { - $this->cycleJobService->delete((int)$job['id']); - continue; - } - $simulatedDay = null; - if ($job['simulated_day'] !== null) { - try { - $simulatedDay = new DateTimeImmutable($job['simulated_day']); - } catch (Exception $exception) { - $simulatedDay = null; - } - } - if ($this->useGroups) { - $this->subscriptionCycleModule->generateAndSendSubscriptionCycleGroups( - $this->subscriptionModule, - [$job['address_id']], - $doctype, - $job['job_type'], - $job['printer_id'], - $simulatedDay - ); - } else { - $this->subscriptionCycleModule->generateAndSendSubscriptionCycle( - $this->subscriptionModule, - [$job['address_id']], - $doctype, - $job['printer_id'], - $job['job_type'], - $simulatedDay - ); - } - $this->cycleJobService->delete((int)$job['id']); - if ($this->taskMutexService->isTaskInstanceRunning('rechnungslauf')) { - return; - } - $this->taskMutexService->setMutex('rechnungslauf_manual'); - } - } + foreach ($jobs as $job) { + switch ($job['document_type']) { + case 'rechnung': + $this->subscriptionModule->CreateInvoice((int)$job['address_id']); + break; + case 'auftrag': + $this->subscriptionModule->CreateOrder((int)$job['address_id']); + break; + } + $this->cycleJobService->delete((int)$job['id']); } } @@ -149,52 +69,4 @@ final class SubscriptionCycleManualJobTask { $this->taskMutexService->setMutex('rechnungslauf_manual', false); } - - /** - * @param array $jobs - * @param string $documentType - * @param DateTimeInterface|null $simulatedDay - * - * @return array - */ - private function getAddressesByTypeFromJobs( - array $jobs, - string $documentType, - ?DateTimeInterface $simulatedDay = null - ): array { - $addresses = []; - foreach ($jobs as $job) { - if ($job['document_type'] === $documentType) { - $addresses[] = (int)$job['address_id']; - } - } - - if (empty($addresses)) { - return []; - } - - $addressesWithSubscriptions = array_keys( - (array)$this->subscriptionModule->GetRechnungsArray($documentType, true) - ); - - return array_intersect($addresses, $addressesWithSubscriptions); - } - - /** - * get all Dates from Setting "Vergangenes Datum für Abrechnungserstellung" to calc old Subscription cycles - * - * @param array $jobs - * - * @return array - */ - private function getSimulatedDates(array $jobs): array - { - $simulatedDates = []; - foreach ($jobs as $job) { - $simulatedDates[] = (string)$job['simulated_day']; - } - - return array_unique($simulatedDates); - } - } diff --git a/classes/Modules/SubscriptionCycle/Service/SubscriptionCycleJobService.php b/classes/Modules/SubscriptionCycle/Service/SubscriptionCycleJobService.php index 802d138f..5d5c106b 100644 --- a/classes/Modules/SubscriptionCycle/Service/SubscriptionCycleJobService.php +++ b/classes/Modules/SubscriptionCycle/Service/SubscriptionCycleJobService.php @@ -11,7 +11,7 @@ use Xentral\Modules\SubscriptionCycle\Exception\InvalidArgumentException; final class SubscriptionCycleJobService { - private $db; + private Database $db; /** * SubscriptionCycleJobService constructor. @@ -57,29 +57,27 @@ final class SubscriptionCycleJobService * @param string $documentType * @param string|null $jobType * @param int|null $printerId - * @param DateTimeInterface|null $simulatedDay * * @throws InvalidArgumentException * * @return int */ - public function create(int $addressId, string $documentType, ?string $jobType, ?int $printerId, ?DateTimeInterface $simulatedDay = null): int + public function create(int $addressId, string $documentType, ?string $jobType = null, ?int $printerId = null): int { $this->ensureDocumentType($documentType); $this->db->perform( 'INSERT INTO `subscription_cycle_job` - (`address_id`, `document_type`, `job_type`, `printer_id`, `created_at`, `simulated_day`) - VALUES (:address_id, :document_type, :job_type, :printer_id, NOW(), :simulated_day)', + (`address_id`, `document_type`, `job_type`, `printer_id`, `created_at`) + VALUES (:address_id, :document_type, :job_type, :printer_id, NOW())', [ 'address_id' => $addressId, 'document_type' => $documentType, 'job_type' => $jobType, 'printer_id' => $printerId, - 'simulated_day' => $simulatedDay === null ? null : $simulatedDay->format('Y-m-d'), ] ); - return (int)$this->db->lastInsertId(); + return $this->db->lastInsertId(); } /** diff --git a/classes/Modules/SubscriptionCycle/SubscriptionModule.php b/classes/Modules/SubscriptionCycle/SubscriptionModule.php new file mode 100644 index 00000000..6adfcca6 --- /dev/null +++ b/classes/Modules/SubscriptionCycle/SubscriptionModule.php @@ -0,0 +1,101 @@ +app = $app; + $this->db = $db; + } + + public function GetPositions(int $address, string $documentType, DateTimeInterface $calculationDate = null): array + { + if ($calculationDate === null) + $calculationDate = new DateTimeImmutable('today'); + + $sql = "SELECT + aa.id, + @start := GREATEST(aa.startdatum, aa.abgerechnetbis) as start, + @end := IF(aa.enddatum = '0000-00-00' OR aa.enddatum > :calcdate, :calcdate, aa.enddatum) as end, + @cycles := CASE + WHEN aa.preisart = 'monat' THEN + TIMESTAMPDIFF(MONTH, @start, @end) + WHEN aa.preisart = 'jahr' THEN + TIMESTAMPDIFF(YEAR, @start, @end) + WHEN aa.preisart = '30tage' THEN + FLOOR(TIMESTAMPDIFF(DAY, @start, @end) / 30) + END+1 as cycles, + CASE + WHEN aa.preisart = 'monat' THEN + DATE_ADD(@start, INTERVAL @cycles MONTH) + WHEN aa.preisart = 'jahr' THEN + DATE_ADD(@start, INTERVAL @cycles YEAR) + WHEN aa.preisart = '30tage' THEN + DATE_ADD(@start, INTERVAL @cycles*30 DAY ) + END as newend, + aa.preisart, + aa.adresse, + aa.preis, + aa.rabatt, + aa.bezeichnung, + aa.beschreibung, + aa.artikel, + aa.menge, + aa.waehrung + FROM abrechnungsartikel aa + JOIN artikel a on aa.artikel = a.id + WHERE aa.dokument = :doctype + AND greatest(aa.startdatum, aa.abgerechnetbis) <= :calcdate + AND (aa.enddatum = '0000-00-00' OR aa.abgerechnetbis < aa.enddatum) + AND aa.adresse = :address"; + + return $this->db->fetchAll($sql, [ + 'doctype' => $documentType, + 'calcdate' => $calculationDate->format('Y-m-d'), + 'address' => $address]); + } + + public function CreateInvoice(int $address, DateTimeInterface $calculationDate = null) { + $positions = $this->GetPositions($address, 'rechnung', $calculationDate); + if(empty($positions)) + return; + + $invoice = $this->app->erp->CreateRechnung($address); + $this->app->erp->LoadRechnungStandardwerte($invoice, $address); + foreach ($positions as $pos) { + $beschreibung = $pos['beschreibung']; + $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; + $this->app->erp->AddRechnungPositionManuell($invoice, $pos['artikel'], $pos['preis'], + $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); + } + $this->app->erp->RechnungNeuberechnen($invoice); + $this->app->erp->BelegFreigabe('rechnung', $invoice); + } + + public function CreateOrder(int $address, DateTimeInterface $calculationDate = null) { + $positions = $this->GetPositions($address, 'auftrag', $calculationDate); + if(empty($positions)) + return; + + $orderid = $this->app->erp->CreateAuftrag($address); + $this->app->erp->LoadAuftragStandardwerte($orderid, $address); + foreach ($positions as $pos) { + $beschreibung = $pos['beschreibung']; + $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; + $this->app->erp->AddAuftragPositionManuell($orderid, $pos['artikel'], $pos['preis'], + $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); + } + $this->app->erp->AuftragNeuberechnen($orderid); + $this->app->erp->BelegFreigabe('auftrag', $orderid); + } +} \ No newline at end of file diff --git a/classes/Modules/SubscriptionCycle/SubscriptionModuleInterface.php b/classes/Modules/SubscriptionCycle/SubscriptionModuleInterface.php index f30a97af..dea66b6c 100644 --- a/classes/Modules/SubscriptionCycle/SubscriptionModuleInterface.php +++ b/classes/Modules/SubscriptionCycle/SubscriptionModuleInterface.php @@ -8,36 +8,7 @@ use DateTimeInterface; interface SubscriptionModuleInterface { - /** - * @param int $customer - * @param string $documentType - * - * @return mixed - */ - public function RechnungKunde($customer, $documentType); - - /** - * @param $customer - * @param $invoiceGroupKey - * @param $key - * - * @return mixed - */ - public function AuftragImportAbo($customer, $invoiceGroupKey, $key); - - /** - * @param $customer - * @param $invoiceGroupKey - * @param $key - * - * @return mixed - */ - public function RechnungImportAbo($customer, $invoiceGroupKey, $key); - - /** - * @param string $documentType - * - * @return array|null - */ - public function GetRechnungsArray($documentType); + public function CreateInvoice(int $address, DateTimeInterface $calculationDate = null); + public function CreateOrder(int $address, DateTimeInterface $calculationDate = null); + public function GetPositions(int $address, string $documentType, DateTimeInterface $calculationDate = null): array; } diff --git a/upgrade/data/db_schema.json b/upgrade/data/db_schema.json index fbfab4fd..db865632 100644 --- a/upgrade/data/db_schema.json +++ b/upgrade/data/db_schema.json @@ -98587,6 +98587,92 @@ } ] }, + { + "name": "subscription_cycle_job", + "type": "BASE TABLE", + "columns": [ + { + "Field": "id", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "PRI", + "Default": "", + "Extra": "auto_increment", + "Privileges": "select,insert,update,references", + "Commant": "" + }, + { + "Field": "address_id", + "Type": "int(11)", + "Collation": null, + "Null": "NO", + "Key": "MUL", + "Default": "", + "Extra": "", + "Privileges": "select,insert,update,references", + "Commant": "" + }, + { + "Field": "document_type", + "Type": "varchar(32)", + "Collation": "utf8mb3_general_ci", + "Null": "NO", + "Key": "", + "Default": "", + "Extra": "", + "Privileges": "select,insert,update,references", + "Commant": "" + }, + { + "Field": "job_type", + "Type": "varchar(32)", + "Collation": "utf8mb3_general_ci", + "Null": "YES", + "Key": "", + "Default": "", + "Extra": "", + "Privileges": "select,insert,update,references", + "Commant": "" + }, + { + "Field": "printer_id", + "Type": "int(11)", + "Collation": "", + "Null": "YES", + "Key": "", + "Default": "", + "Extra": "", + "Privileges": "select,insert,update,references", + "Commant": "" + }, + { + "Field": "created_at", + "Type": "timestamp", + "Collation": "", + "Null": "NO", + "Key": "", + "Default": "current_timestamp()", + "Extra": "", + "Privileges": "select,insert,update,references", + "Commant": "" + } + ], + "keys": [ + { + "Key_name": "PRIMARY", + "columns": [ + "id" + ] + }, + { + "Key_name": "address", + "columns": [ + "address_id" + ] + } + ] + }, { "name": "supersearch_index_group", "type": "BASE TABLE", diff --git a/www/pages/content/rechnungslauf_abos.tpl b/www/pages/content/rechnungslauf_abos.tpl new file mode 100644 index 00000000..5a0a1bc9 --- /dev/null +++ b/www/pages/content/rechnungslauf_abos.tpl @@ -0,0 +1,8 @@ +
+
    +
  • +
+
+ [TAB1] +
+
diff --git a/www/pages/content/rechnungslauf_list.tpl b/www/pages/content/rechnungslauf_list.tpl new file mode 100644 index 00000000..5df2b76a --- /dev/null +++ b/www/pages/content/rechnungslauf_list.tpl @@ -0,0 +1,36 @@ +
+ +
+ [MESSAGE_INVOICES] +
+ [TAB_INVOICES] +
+ {|Stapelverarbeitung|} +  {|alle markieren|} + +
+
+
+
+ [MESSAGE_ORDERS] +
+ [TAB_ORDERS] +
+ {|Stapelverarbeitung|} +  {|alle markieren|} + +
+
+
+
+ + diff --git a/www/pages/content/rechnungslauf_minidetail.tpl b/www/pages/content/rechnungslauf_minidetail.tpl index b3b4fd57..588464dc 100644 --- a/www/pages/content/rechnungslauf_minidetail.tpl +++ b/www/pages/content/rechnungslauf_minidetail.tpl @@ -8,7 +8,7 @@ {|Menge|} {|Einzelpreis (netto)|} {|Rabatt|} - {|UST|} + {|Zyklen|} {|Gesamtpreis (netto)|} {|Währung|} diff --git a/www/pages/rechnungslauf.php b/www/pages/rechnungslauf.php new file mode 100644 index 00000000..94a62df8 --- /dev/null +++ b/www/pages/rechnungslauf.php @@ -0,0 +1,279 @@ +'; + $menu .= ''; + $menu .= ''; + $menu .= ''; + $menu .= ''; + $menu .= ''; + $menu .= ''; + $menu .= ''; + $menu .= ''; + + $calcdate = new \DateTimeImmutable('today'); + $scalcdate = $calcdate->format('Y-m-d'); + $where = " aa.id > 0 + AND aa.dokument = '$doctype' + AND greatest(aa.startdatum, aa.abgerechnetbis) < '$scalcdate' + AND (aa.enddatum = '0000-00-00' OR aa.abgerechnetbis < aa.enddatum)"; + + $sql = "SELECT SQL_CALC_FOUND_ROWS + adr.id, + '' as open, + concat('') as auswahl, + adr.kundennummer, + adr.name, + adr.anschreiben, + adr.email, + p.abkuerzung, + GROUP_CONCAT(DATE_FORMAT(@start := GREATEST(aa.startdatum, aa.abgerechnetbis),'%d.%m.%Y') SEPARATOR '
') as start, + GROUP_CONCAT(DATE_FORMAT( + @end := CASE + WHEN aa.preisart = 'monat' THEN + DATE_ADD(@start, INTERVAL TIMESTAMPDIFF(MONTH, @start, IF(aa.enddatum = '0000-00-00' OR aa.enddatum > '$scalcdate', '$scalcdate', aa.enddatum))+1 MONTH) + WHEN aa.preisart = 'jahr' THEN + DATE_ADD(@start, INTERVAL TIMESTAMPDIFF(YEAR, @start, IF(aa.enddatum = '0000-00-00' OR aa.enddatum > '$scalcdate', '$scalcdate', aa.enddatum))+1 YEAR) + WHEN aa.preisart = '30tage' THEN + DATE_ADD(@start, INTERVAL (FLOOR(TIMESTAMPDIFF(DAY, @start, IF(aa.enddatum = '0000-00-00' OR aa.enddatum > '$scalcdate', '$scalcdate', aa.enddatum)) / 30)+1)*30 DAY ) + END, '%d.%m.%Y') SEPARATOR '
') as end, + SUM((100-aa.rabatt)/100 * aa.preis * aa.menge * + (CASE + WHEN aa.preisart = 'monat' THEN + TIMESTAMPDIFF(MONTH, @start, @end) + WHEN aa.preisart = 'jahr' THEN + TIMESTAMPDIFF(YEAR, @start, @end) + WHEN aa.preisart = '30tage' THEN + FLOOR(TIMESTAMPDIFF(DAY, @start, @end) / 30) + END + ) + ) as amount, + adr.id + FROM abrechnungsartikel aa + JOIN artikel a ON aa.artikel = a.id + JOIN adresse adr ON aa.adresse = adr.id + LEFT JOIN projekt p ON aa.projekt = p.id"; + + $groupby = " GROUP BY aa.adresse, aa.projekt"; + + $count = "SELECT count(aa.id) + FROM `abrechnungsartikel` AS `aa` + WHERE $where $groupby"; + $menucol = 10; + $moreinfo = true; + break; + + case 'rechnungslauf_abos': + $allowed['rechnungslauf'] = ['abos']; + $heading = array( + 'Kunde', + 'Kunden Nr.', + 'Bezeichnung', + 'Nummer', + 'Abgerechnet bis', + 'Enddatum', + 'Preis', + 'Rabatt', + 'Menge', + 'Art', + 'Zahlperiode', + 'Zahlweise', + 'Dokument', + 'Menü'); + $width = ['10%','5%','15%','1','1','1','1','1','1','1','1','1','1','1']; + + $findcols = [ + 'ad.name', + 'ad.kundennummer', + 'aa.bezeichnung', + 'a.nummer', + "DATE_FORMAT(aa.abgerechnetbis, '%d.%m.%Y')", + 'aa.enddatum', + 'aa.preis', + 'aa.rabatt', + 'aa.menge', + 'aa.preisart', + 'aa.zahlzyklus', + '', + 'aa.dokument' + ]; + $searchsql = ['ad.name', 'aa.bezeichnung']; + + $numbercols = [0]; + $alignright = [7]; + $datecols = [5,6]; + + $defaultorder = 1; + $defaultorderdesc = 0; + + $menu = "
" + . "" + . "Conf->WFconf['defaulttheme']}/images/forward.svg\" border=\"0\">" + . " 
"; + + $where = " aa.id > 0 AND (aa.enddatum = '0000-00-00' OR aa.abgerechnetbis < aa.enddatum) "; + + $sql = "SELECT SQL_CALC_FOUND_ROWS aa.id, ad.name, ad.kundennummer, + aa.bezeichnung, a.nummer, DATE_FORMAT(aa.abgerechnetbis, '%d.%m.%Y'), + DATE_FORMAT(aa.enddatum, '%d.%m.%Y'), + ".$app->erp->FormatPreis('aa.preis', 2).", aa.rabatt, aa.menge, + aa.preisart, aa.zahlzyklus, '', aa.dokument, ad.id + FROM `abrechnungsartikel` AS `aa` + LEFT JOIN `adresse` AS `ad` ON aa.adresse = ad.id + LEFT JOIN `artikel` AS `a` ON aa.artikel = a.id"; + + $count = "SELECT count(aa.id) + FROM `abrechnungsartikel` AS `aa` + WHERE $where"; + break; + } + + $erg = []; + + foreach($erlaubtevars as $k => $v) { + if(isset($$v)) { + $erg[$v] = $$v; + } + } + + return $erg; + } + + /** + * Rechnungslauf constructor. + * + * @param Application $app + * @param bool $intern + */ + public function __construct($app, $intern = false) { + $this->app = $app; + if($intern) { + return; + } + $this->app->ActionHandlerInit($this); + + // ab hier alle Action Handler definieren die das Modul hat + $this->app->ActionHandler('rechnungslauf', 'ActionList'); + $this->app->ActionHandler('abos', 'ActionAbos'); + $this->app->ActionHandler('minidetail', 'ActionMinidetail'); + + $this->app->ActionHandlerListen($app); + } + + public function MenuList() { + $this->app->erp->Headlines("Abolauf"); + $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=rechnungslauf", "Übersicht"); + $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=abos", "gebuchte Abos"); + $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=einstellungen", "Einstellungen"); + } + + public function ActionList() { + /** @var SubscriptionModule $module */ + $this->MenuList(); + $this->app->YUI->TableSearch("TAB_INVOICES", 'rechnungslauf_invoices','show', '', '', basename(__FILE__), __CLASS__); + $this->app->YUI->TableSearch("TAB_ORDERS", 'rechnungslauf_orders','show', '', '', basename(__FILE__), __CLASS__); + if ($this->app->Secure->GetPOST('createInvoices') !== '') { + $selection = $this->app->Secure->GetPOST('selection'); + /** @var SubscriptionCycleJobService $subscriptionCycleJobService */ + $subscriptionCycleJobService = $this->app->Container->get('SubscriptionCycleJobService'); + foreach ($selection as $value) { + $subscriptionCycleJobService->deleteJobsByAddressIdAndDoctype($value, 'rechnung'); + $subscriptionCycleJobService->create($value, 'rechnung'); + $this->app->Tpl->addMessage('info', 'Die Rechnungen werden nun im Hintergrund erstellt', _var: 'MESSAGE_INVOICES'); + } + } + else if ($this->app->Secure->GetPOST('createOrders') !== '') { + $selection = $this->app->Secure->GetPOST('selection'); + /** @var SubscriptionCycleJobService $subscriptionCycleJobService */ + $subscriptionCycleJobService = $this->app->Container->get('SubscriptionCycleJobService'); + foreach ($selection as $value) { + $subscriptionCycleJobService->deleteJobsByAddressIdAndDoctype($value, 'auftrag'); + $subscriptionCycleJobService->create($value, 'auftrag'); + $this->app->Tpl->addMessage('info', 'Die Aufträge werden nun im Hintergrund erstellt', _var: 'MESSAGE_ORDERS'); + } + } + $this->app->Tpl->Parse('PAGE', 'rechnungslauf_list.tpl'); + } + + public function ActionAbos() { + $this->MenuList(); + $this->app->YUI->TableSearch("TAB1", 'rechnungslauf_abos', 'show', '', '', basename(__FILE__), __CLASS__); + $this->app->Tpl->Parse('PAGE', 'rechnungslauf_abos.tpl'); + } + + public function ActionMinidetail() { + /** @var SubscriptionModule $module */ + $module = $this->app->Container->get('SubscriptionModule'); + $address = $this->app->Secure->GetGET('id'); + $pos = $module->GetPositions($address, 'rechnung'); + foreach ($pos as $p) { + $row = ''; + $row .= sprintf('%s', $p['bezeichnung']); + $row .= sprintf('%s', $p['menge']); + $row .= sprintf('%s', + $this->app->erp->number_format_variable($p['preis'], 2)); + $row .= sprintf('%s', $p['rabatt']); + $row .= sprintf('%s', $p['cycles']); + $row .= sprintf('%s', + $this->app->erp->number_format_variable($p['preis']*$p['menge']*$p['cycles'], 2)); + $row .= sprintf('%s', $p['waehrung']); + $row .= ''; + $this->app->Tpl->Add('INHALT', $row); + } + $this->app->Tpl->Set('SUBHEADING', 'Kunde'); + $this->app->Tpl->Output('rechnungslauf_minidetail.tpl'); + $this->app->ExitXentral(); + } +} \ No newline at end of file From 474970e358790b5ea52f18395aa20fe4e21e9cb2 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 22 Dec 2022 22:27:27 +0100 Subject: [PATCH 10/51] Fix PHP 7 compat --- www/pages/rechnungslauf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/pages/rechnungslauf.php b/www/pages/rechnungslauf.php index 94a62df8..3fe7ffdd 100644 --- a/www/pages/rechnungslauf.php +++ b/www/pages/rechnungslauf.php @@ -231,7 +231,7 @@ class Rechnungslauf { foreach ($selection as $value) { $subscriptionCycleJobService->deleteJobsByAddressIdAndDoctype($value, 'rechnung'); $subscriptionCycleJobService->create($value, 'rechnung'); - $this->app->Tpl->addMessage('info', 'Die Rechnungen werden nun im Hintergrund erstellt', _var: 'MESSAGE_INVOICES'); + $this->app->Tpl->addMessage('info', 'Die Rechnungen werden nun im Hintergrund erstellt', false, 'MESSAGE_INVOICES'); } } else if ($this->app->Secure->GetPOST('createOrders') !== '') { @@ -241,7 +241,7 @@ class Rechnungslauf { foreach ($selection as $value) { $subscriptionCycleJobService->deleteJobsByAddressIdAndDoctype($value, 'auftrag'); $subscriptionCycleJobService->create($value, 'auftrag'); - $this->app->Tpl->addMessage('info', 'Die Aufträge werden nun im Hintergrund erstellt', _var: 'MESSAGE_ORDERS'); + $this->app->Tpl->addMessage('info', 'Die Aufträge werden nun im Hintergrund erstellt', false, 'MESSAGE_ORDERS'); } } $this->app->Tpl->Parse('PAGE', 'rechnungslauf_list.tpl'); From 66d248d9e5fdf0192adec4dcfc67c32015715d40 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 23 Dec 2022 00:00:59 +0100 Subject: [PATCH 11/51] Update abgerechnetbis after adding to invoice/order, disable Freigabe during testing --- classes/Modules/SubscriptionCycle/SubscriptionModule.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/Modules/SubscriptionCycle/SubscriptionModule.php b/classes/Modules/SubscriptionCycle/SubscriptionModule.php index 6adfcca6..c46a5a97 100644 --- a/classes/Modules/SubscriptionCycle/SubscriptionModule.php +++ b/classes/Modules/SubscriptionCycle/SubscriptionModule.php @@ -77,9 +77,10 @@ class SubscriptionModule implements SubscriptionModuleInterface $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; $this->app->erp->AddRechnungPositionManuell($invoice, $pos['artikel'], $pos['preis'], $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); + $this->db->update("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); } $this->app->erp->RechnungNeuberechnen($invoice); - $this->app->erp->BelegFreigabe('rechnung', $invoice); + //$this->app->erp->BelegFreigabe('rechnung', $invoice); } public function CreateOrder(int $address, DateTimeInterface $calculationDate = null) { @@ -94,8 +95,9 @@ class SubscriptionModule implements SubscriptionModuleInterface $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; $this->app->erp->AddAuftragPositionManuell($orderid, $pos['artikel'], $pos['preis'], $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); + $this->db->update("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); } $this->app->erp->AuftragNeuberechnen($orderid); - $this->app->erp->BelegFreigabe('auftrag', $orderid); + //$this->app->erp->BelegFreigabe('auftrag', $orderid); } } \ No newline at end of file From 5bac7c479cb30727c2b8e1bbbabfd06c9b1f26f6 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 27 Dec 2022 21:38:48 +0100 Subject: [PATCH 12/51] Bugfix date display --- .../Scheduler/SubscriptionCycleManualJobTask.php | 2 +- .../SubscriptionCycle/SubscriptionModule.php | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php b/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php index f7378baa..d032099d 100644 --- a/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php +++ b/classes/Modules/SubscriptionCycle/Scheduler/SubscriptionCycleManualJobTask.php @@ -36,7 +36,7 @@ final class SubscriptionCycleManualJobTask Database $db, TaskMutexServiceInterface $taskMutexService, SubscriptionCycleJobService $cycleJobService, - SubscriptionModuleInterface $subscriptionModule, + SubscriptionModuleInterface $subscriptionModule ) { $this->app = $app; $this->db = $db; diff --git a/classes/Modules/SubscriptionCycle/SubscriptionModule.php b/classes/Modules/SubscriptionCycle/SubscriptionModule.php index c46a5a97..8b6ecead 100644 --- a/classes/Modules/SubscriptionCycle/SubscriptionModule.php +++ b/classes/Modules/SubscriptionCycle/SubscriptionModule.php @@ -74,10 +74,14 @@ class SubscriptionModule implements SubscriptionModuleInterface $this->app->erp->LoadRechnungStandardwerte($invoice, $address); foreach ($positions as $pos) { $beschreibung = $pos['beschreibung']; - $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; + + $starts = DateTimeImmutable::createFromFormat('Y-m-d', $pos['start'])->format('d.m.Y'); + $newends = DateTimeImmutable::createFromFormat('Y-m-d', $pos['newend'])->format('d.m.Y'); + $beschreibung .= "
Zeitraum: $starts - $newends"; + $this->app->erp->AddRechnungPositionManuell($invoice, $pos['artikel'], $pos['preis'], $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); - $this->db->update("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); + $this->db->exec("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); } $this->app->erp->RechnungNeuberechnen($invoice); //$this->app->erp->BelegFreigabe('rechnung', $invoice); @@ -92,10 +96,14 @@ class SubscriptionModule implements SubscriptionModuleInterface $this->app->erp->LoadAuftragStandardwerte($orderid, $address); foreach ($positions as $pos) { $beschreibung = $pos['beschreibung']; - $beschreibung .= "
Zeitraum: {$pos['start']} - {$pos['end']}"; + + $starts = DateTimeImmutable::createFromFormat('Y-m-d', $pos['start'])->format('d.m.Y'); + $newends = DateTimeImmutable::createFromFormat('Y-m-d', $pos['newend'])->format('d.m.Y'); + $beschreibung .= "
Zeitraum: $starts - $newends"; + $this->app->erp->AddAuftragPositionManuell($orderid, $pos['artikel'], $pos['preis'], $pos['menge']*$pos['cycles'], $pos['bezeichnung'], $beschreibung, $pos['waehrung'], $pos['rabatt']); - $this->db->update("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); + $this->db->exec("UPDATE abrechnungsartikel SET abgerechnetbis='{$pos['newend']}' WHERE id={$pos['id']}"); } $this->app->erp->AuftragNeuberechnen($orderid); //$this->app->erp->BelegFreigabe('auftrag', $orderid); From 5539c9849c5a1ede1a262e63ac70d7ca473d55cc Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sat, 28 Jan 2023 13:04:28 +0100 Subject: [PATCH 13/51] Presta shopimporter --- www/lib/class.remote.php | 18 +- www/pages/appstore.php | 8 +- www/pages/shopimporter_presta.php | 417 ++++++++++++++++++++++++++++++ 3 files changed, 434 insertions(+), 9 deletions(-) create mode 100644 www/pages/shopimporter_presta.php diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php index 8fa23b2c..05d71eec 100644 --- a/www/lib/class.remote.php +++ b/www/lib/class.remote.php @@ -1,4 +1,4 @@ - +*/ +?> app->erp->CreateDatei($path_parts['basename'], 'Shopbild', '', '', base64_decode($v['content']), 'Cronjob'); + $tmpfilename = tempnam($this->app->erp->GetTMP(), 'img'); + file_put_contents($tmpfilename, base64_decode($v['content'])); + $fileid = $this->app->erp->CreateDatei($path_parts['basename'], 'Shopbild', '', '', $tmpfilename, 'Cronjob'); $this->app->erp->AddDateiStichwort($fileid, 'Shopbild', 'artikel', $articleid); + if (@is_file($tmpfilename)) + unlink($tmpfilename); } } }elseif($dateien[0]['subjekt'] === 'shopbild'){ @@ -766,12 +770,16 @@ class Remote if($v['path'] != '' && $v['content'] != '') { $path_parts = pathinfo($v['path']); - $fileid = $this->app->erp->CreateDatei($path_parts['basename'], 'Shopbild', '', '', base64_decode($v['content']), 'Cronjob'); + $tmpfilename = tempnam($this->app->erp->GetTMP(), 'img'); + file_put_contents($tmpfilename, base64_decode($v['content'])); + $fileid = $this->app->erp->CreateDatei($path_parts['basename'], 'Shopbild', '', '', $tmpfilename, 'Cronjob'); if(isset($v['id'])) { $this->ShopexportMappingSet($id, 'datei', $fileid, $v['id'], $articleid); } $this->app->erp->AddDateiStichwort($fileid, 'Shopbild', 'artikel', $articleid); + if (@is_file($tmpfilename)) + unlink($tmpfilename); } } } diff --git a/www/pages/appstore.php b/www/pages/appstore.php index ad3f857b..5ada3d28 100644 --- a/www/pages/appstore.php +++ b/www/pages/appstore.php @@ -1,4 +1,4 @@ - +*/ +?> array('Bezeichnung'=>'Presta', 'Link'=>'index.php?module=onlineshops&action=create&cmd=shopimporter_presta', 'Icon'=>'Icons_dunkel_1.gif', - 'Versionen'=>'ENT','install'=>true, 'beta' => false,'kategorie'=>'{|Shop Schnittstelle|}') + 'Versionen'=>'ALL','install'=>true, 'beta' => false,'kategorie'=>'{|Shop Schnittstelle|}') ,'shopimporter_shopify'=>array( 'Bezeichnung'=>'Shopify API Advanced', 'Link'=>'index.php?module=onlineshops&action=create&cmd=shopimporter_shopify', diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php new file mode 100644 index 00000000..7ee9eae2 --- /dev/null +++ b/www/pages/shopimporter_presta.php @@ -0,0 +1,417 @@ + 'de', 1 => 'en']; + private $taxationByDestinationCountry; + + + public function __construct($app, $intern = false) + { + $this->app = $app; + $this->intern = $intern; + if ($intern) + return; + + } + + public function EinstellungenStruktur() + { + return [ + 'ausblenden' => ['abholmodus' => ['ab_nummer', 'zeitbereich']], + 'functions' => ['getarticlelist'], + 'felder' => [ + 'protokoll' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Protokollierung im Logfile|}:' + ], + 'textekuerzen' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Texte bei Artikelexport auf Maximallänge kürzen|}:' + ], + 'useKeyAsParameter' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Shop Version ist mindestens 1.6.1.1|}:' + ], + 'apikey' => [ + 'typ' => 'text', + 'bezeichnung' => '{|API Key|}:', + 'size' => 40, + ], + 'shopurl' => [ + 'typ' => 'text', + 'bezeichnung' => '{|Shop URL|}:', + 'size' => 40, + ], + 'shopidpresta' => [ + 'typ' => 'text', + 'bezeichnung' => '{|Shop ID des Shops|}:', + 'size' => 40, + ], + 'steuergruppen' => [ + 'typ' => 'text', + 'bezeichnung' => '{|Steuergruppenmapping|}:', + 'size' => 40, + ], + 'zustand' => [ + 'typ' => 'text', + 'bezeichnung' => '{|Freifeld Zustand|}:', + 'size' => 40, + ], + 'abholen' => [ + 'typ' => 'text', + 'bezeichnung' => '{|\'Abholen\' Status IDs|}:', + 'size' => 40, + ], + 'bearbeitung' => [ + 'typ' => 'text', + 'bezeichnung' => '{|\'In Bearbeitung\' Status IDs|}:', + 'size' => 40, + ], + 'abgeschlossen' => [ + 'typ' => 'text', + 'bezeichnung' => '{|\'Abgeschlossen\' Status IDs|}:', + 'size' => 40, + ], + 'autoerstellehersteller' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Fehlende Hersteller automatisch anlegen|}:', + 'col' => 2 + ], + 'zeigezustand' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Artikelzustand im Shop anzeigen|}:', + 'col' => 2 + ], + 'zeigepreis' => [ + 'typ' => 'checkbox', + 'bezeichnung' => '{|Artikelpreis im Shop anzeigen|}:', + 'col' => 2 + ], + ] + ]; + } + + public function getKonfig($shopid, $data) + { + $this->shopid = $shopid; + $this->data = $data; + $importerSettings = $this->app->DB->SelectArr("SELECT `einstellungen_json` FROM `shopexport` WHERE `id` = '$shopid' LIMIT 1"); + $importerSettings = reset($importerSettings); + + $einstellungen = []; + if (!empty($importerSettings['einstellungen_json'])) { + $einstellungen = json_decode($importerSettings['einstellungen_json'], true); + } + $this->protocol = $einstellungen['felder']['protokoll']; + $this->apiKey = $einstellungen['felder']['apikey']; + $this->shopUrl = rtrim($einstellungen['felder']['shopurl'], '/') . '/'; + if ($einstellungen['felder']['autoerstellehersteller'] === '1') { + $this->createManufacturerAllowed = true; + } + $this->idsabholen = $einstellungen['felder']['abholen']; + $this->idbearbeitung = $einstellungen['felder']['bearbeitung']; + $this->idabgeschlossen = $einstellungen['felder']['abgeschlossen']; + $query = sprintf('SELECT `steuerfreilieferlandexport` FROM `shopexport` WHERE `id` = %d', $this->shopid); + $this->taxationByDestinationCountry = !empty($this->app->DB->Select($query)); + } + + public function ImportAuth() { + $ch = curl_init($this->shopUrl); + curl_setopt($ch, CURLOPT_USERNAME, $this->apiKey); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + if ($code == 200) + return 'success'; + + return $response; + } + + public function ImportDeleteAuftrag() + { + $auftrag = $this->data['auftrag']; + + $obj = $this->prestaRequest('GET', 'order_histories?schema=blank'); + $obj->order_history->id_order = $auftrag; + $obj->order_history->id_order_state = $this->idbearbeitung; + + $this->prestaRequest('POST', 'order_histories', $obj->asXML()); + } + + public function ImportUpdateAuftrag() + { + $auftrag = $this->data['auftrag']; + + $obj = $this->prestaRequest('GET', 'order_histories?schema=blank'); + $obj->order_history->id_order = $auftrag; + $obj->order_history->id_order_state = $this->idabgeschlossen; + + $this->prestaRequest('POST', 'order_histories', $obj->asXML()); + + //TODO Tracking + } + + public function ImportGetAuftraegeAnzahl() + { + $ordersToProcess = $this->getOrdersToProcess($this->getOrderSearchLimit()); + return count($ordersToProcess); + } + + public function ImportGetAuftrag() + { + $voucherArticleId = $this->app->DB->Select("SELECT s.artikelrabatt FROM `shopexport` AS `s` WHERE s.id='$this->shopid' LIMIT 1"); + $voucherArticleNumber = $this->app->DB->Select("SELECT a.nummer FROM `artikel` AS `a` WHERE a.id='$voucherArticleId' LIMIT 1"); + + if (empty($this->idsabholen)) { + return false; + } + $expectOrderArray = !empty($this->data['anzgleichzeitig']) && (int)$this->data['anzgleichzeitig'] > 1; + $expectNumber = !empty($this->data['nummer']); + if ($expectNumber) { + $ordersToProcess = [$this->data['nummer']]; + } elseif (!$expectOrderArray) { + $ordersToProcess = $this->getOrdersToProcess(1); + } else { + $ordersToProcess = $this->getOrdersToProcess($this->getOrderSearchLimit()); + } + + $fetchedOrders = []; + foreach ($ordersToProcess as $currentOrderId) { + $this->Log("Importing order from presta", [$this->data, $ordersToProcess, $currentOrderId]); + $order = $this->prestaRequest('GET', "orders/$currentOrderId"); + $order = $order->order; + $cart = []; + $cart['zeitstempel'] = strval($order->date_add); + $cart['auftrag'] = strval($order->id); + $cart['onlinebestellnummer'] = strval($order->reference); + $cart['gesamtsumme'] = strval($order->total_paid); + $cart['versandkostenbrutto'] = strval($order->total_shipping); + $cart['bestelldatum'] = strval($order->date_add); + + $carrier = $this->prestaRequest('GET', "carriers/$order->id_carrier"); + $cart['lieferung'] = strval($carrier->name); + + $customer = $this->prestaRequest('GET', "customers/$order->id_customer"); + $cart['email'] = strval($customer->email); + + $invoiceAddress = $this->prestaRequest('GET', "addresses/$order->id_address_invoice"); + $invoiceAddress = $invoiceAddress->address; + $invoiceCountry = $this->prestaRequest('GET', "countries/$invoiceAddress->id_country"); + $invoiceCountry = $invoiceCountry->country; + $cart['name'] = "$invoiceAddress->firstname $invoiceAddress->lastname"; + if (!empty($invoiceAddress->company)) { + $cart['ansprechpartner'] = $cart['name']; + $cart['name'] = strval($invoiceAddress->company); + } + $cart['strasse'] = strval($invoiceAddress->address1); + $cart['adresszusatz'] = strval($invoiceAddress->address2); + $cart['telefon'] = strval($invoiceAddress->phone_mobile); + if (empty($cart['telefon'])) + $cart['telefon'] = strval($invoiceAddress->phone); + $cart['plz'] = strval($invoiceAddress->postcode); + $cart['ort'] = strval($invoiceAddress->city); + $cart['ustid'] = strval($invoiceAddress->vat_number); + $cart['land'] = strval($invoiceCountry->iso_code); + + if ($order->id_address_invoice != $order->id_address_delivery) { + $deliveryAddress = $this->prestaRequest('GET', "addresses/$order->id_address_delivery"); + $deliveryAddress = $deliveryAddress->address; + $deliveryCountry = $this->prestaRequest('GET', "countries/$deliveryAddress->id_country"); + $deliveryCountry = $deliveryCountry->country; + $cart['abweichendelieferadresse'] = 1; + $cart['lieferadresse_name'] = "$deliveryAddress->firstname $deliveryAddress->lastname"; + if (!empty($deliveryAddress->company)) { + $cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name']; + $cart['lieferadresse_name'] = strval($deliveryAddress->company); + } + $cart['lieferadresse_strasse'] = strval($deliveryAddress->address1); + $cart['lieferadresse_adresszusatz'] = strval($deliveryAddress->address2); + $cart['lieferadresse_plz'] = strval($deliveryAddress->postcode); + $cart['lieferadresse_ort'] = strval($deliveryAddress->city); + $cart['lieferadresse_land'] = strval($deliveryCountry->iso_code); + } + + //TODO + //$cart['transaktionsnummer'] + $cart['zahlungsweise'] = strval($order->payment); + + $taxedCountry = $cart['land']; + if (!empty($cart['lieferadresse_land']) && $this->taxationByDestinationCountry) { + $taxedCountry = $cart['lieferadresse_land']; + } + if (strval($order->total_paid_tax_incl) === strval($order->total_paid_tax_excl)) { + if ($this->app->erp->IstEU($taxedCountry)) { + $cart['ust_befreit'] = 1; + } elseif ($this->app->erp->Export($taxedCountry)) { + $cart['ust_befreit'] = 2; + } else { + $cart['ust_befreit'] = 3; + } + } + + $cart['articlelist'] = []; + foreach ($order->associations->order_rows->order_row as $order_row) { + + $steuersatz = (strval($order_row->unit_price_tax_incl) / strval($order_row->unit_price_tax_excl)) - 1; + $steuersatz = round($steuersatz, 1); + + $cart['articlelist'][] = [ + 'articleid' => strval($order_row->product_reference), + 'name' => strval($order_row->product_name), + 'quantity' => strval($order_row->product_quantity), + 'price_netto' => strval($order_row->product_price), + 'steuersatz' => $steuersatz + ]; + } + + $fetchedOrders[] = [ + 'id' => $cart['auftrag'], + 'sessionid' => '', + 'logdatei' => '', + 'warenkorb' => base64_encode(serialize($cart)), + 'warenkorbjson' => base64_encode(json_encode($cart)), + ]; + } + $this->Log('Precessed order from presta', $fetchedOrders); + + return $fetchedOrders; + } + + public function ImportGetArticleList() + { + $result = []; + $response = $this->prestaRequest('GET', 'products?display=[reference]'); + foreach ($response->products->product as $product) { + $result[] = $product->reference; + } + + array_unique($result); + return $result; + } + + public function ImportGetArticle() + { + $nummer = $this->data['nummer']; + if (isset($this->data['nummerintern'])) { + $nummer = $this->data['nummerintern']; + } + $nummer = trim($nummer); + + if (empty($nummer)) + return; + + $searchresult = $this->prestaRequest('GET', 'products?filter[reference]='.$nummer); + if (empty($searchresult)) { + $this->Log('No product found in Shop', $this->data); + return; + } + if (count($searchresult->products->product) > 1) { + $this->Log('Got multiple results from Shop', $this->data); + } + + $productid = $searchresult->products->product->attributes()->id; + $product = $this->prestaRequest('GET', "products/$productid"); + $res = []; + $res['nummer'] = strval($product->product->reference); + $res['artikelnummerausshop'] = strval($product->product->reference); + $names = $this->toMultilangArray($product->product->name->language); + $descriptions = $this->toMultilangArray($product->product->description->language); + $shortdescriptions = $this->toMultilangArray($product->product->description_short->language); + $res['name'] = $names['de']; + $res['name_en'] = $names['en']; + $res['uebersicht_de'] = $descriptions['de']; + $res['uebersicht_en'] = $descriptions['en']; + $res['preis_netto'] = strval($product->product->price); + $res['hersteller'] = strval($product->product->manufacturer_name); + $res['ean'] = strval($product->product->ean13); + + $images = []; + foreach ($product->product->associations->images->image as $img) { + $endpoint = "images/products/$productid/$img->id"; + $imgdata = $this->prestaRequest('GET', $endpoint, '', true); + $images[] = [ + 'content' => base64_encode($imgdata), + 'path' => "$img->id.jpg", + 'id' => $img->id + ]; + } + $res['bilder'] = $images; + return $res; + } + + private function toMultilangArray($xmlnode) { + $res = []; + foreach ($xmlnode as $item) { + $iso = $this->langidToIso[strval($item->attributes()->id)]; + $res[$iso] = strval($item); + } + return $res; + } + + private function getOrdersToProcess(int $limit) + { + $states = implode('|', explode(',', $this->idsabholen)); + $response = $this->prestaRequest('GET', "orders?display=[id]&limit=$limit&filter[current_state]=[$states]"); + $result = []; + foreach ($response->orders->order as $order) { + $result[] = strval($order->id); + } + return $result; + } + + public function getOrderSearchLimit(): int + { + if(in_array($this->orderSearchLimit, ['50', '75', '100'])) { + return (int)$this->orderSearchLimit; + } + + return 25; + } + + private function Log($message, $dump = '') + { + if ($this->protocol) { + $this->app->erp->Logfile($message, print_r($dump, true)); + } + } + + private function prestaRequest($method, $endpoint, $data = '', $raw = false) + { + $url = $this->shopUrl . $endpoint; + $url = str_replace('[', '%5b', $url); + $url = str_replace(']', '%5d', $url); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + if (!empty($data)) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + } + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($ch, CURLOPT_USERNAME, $this->apiKey); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + if (curl_error($ch)) { + $this->error[] = curl_error($ch); + } + curl_close($ch); + + if ($raw) + return $response; + + return simplexml_load_string($response); + } +} \ No newline at end of file From d705d1a3eb76e8923166ec2382714d9615bea734 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 00:56:37 +0100 Subject: [PATCH 14/51] Small bugfix in presta importer, improve steuersaetze.php --- www/pages/shopimporter_presta.php | 12 ++++++++++-- www/pages/steuersaetze.php | 10 +++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 7ee9eae2..69149240 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -203,10 +203,10 @@ class Shopimporter_Presta extends ShopimporterBase $cart['bestelldatum'] = strval($order->date_add); $carrier = $this->prestaRequest('GET', "carriers/$order->id_carrier"); - $cart['lieferung'] = strval($carrier->name); + $cart['lieferung'] = strval($carrier->carrier->name); $customer = $this->prestaRequest('GET', "customers/$order->id_customer"); - $cart['email'] = strval($customer->email); + $cart['email'] = strval($customer->customer->email); $invoiceAddress = $this->prestaRequest('GET', "addresses/$order->id_address_invoice"); $invoiceAddress = $invoiceAddress->address; @@ -263,6 +263,14 @@ class Shopimporter_Presta extends ShopimporterBase } } + $taxes = []; + $this->app->erp->RunHook('getTaxRatesFromShopOrder', 2, $taxedCountry, $taxes); + + if (isset($taxes['normal']) && $taxes['normal'] > 0) + $cart['steuersatz_normal'] = $taxes['normal']; + if (isset($taxes['ermaessigt']) && $taxes['ermaessigt'] > 0) + $cart['steuersatz_ermaessigt'] = $taxes['ermaessigt']; + $cart['articlelist'] = []; foreach ($order->associations->order_rows->order_row as $order_row) { diff --git a/www/pages/steuersaetze.php b/www/pages/steuersaetze.php index 88830761..7cc77d71 100644 --- a/www/pages/steuersaetze.php +++ b/www/pages/steuersaetze.php @@ -1,4 +1,4 @@ - +*/ +?> app->DB->SelectArr( sprintf( - "SELECT DISTINCT `satz` + "SELECT DISTINCT `type`, `satz` FROM `steuersaetze` WHERE `aktiv` = 1 AND (`country_code` = '%s' OR (`bezeichnung` = '%s' AND `country_code` = ''))", @@ -163,7 +163,7 @@ class Steuersaetze { ); if(!empty($taxes)) { foreach($taxes as $rates) { - $ret[] = $rates['satz']; + $ret[$rates['type']] = $rates['satz']; } } From 0e3afa437be922a1fc9f3a7c02f3fb0fff536ff1 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 12:06:32 +0100 Subject: [PATCH 15/51] Bugfix shopimport, bugfixes presta, support for project specific number ranges --- www/lib/class.erpapi.php | 14 +++++++++++++- www/pages/shopimport.php | 8 ++++---- www/pages/shopimporter_presta.php | 14 +++++--------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 8f04e543..c12a4d90 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -29440,10 +29440,22 @@ function Firmendaten($field,$projekt="") $process_lock = $this->app->erp->ProzessLock("erpapi_getnextnummer"); $eigenernummernkreis = 0; + $newbelegnr = ''; if($eigenernummernkreis=='1') { + $allowedtypes = ['angebot', 'auftrag', 'rechnung', 'lieferschein', 'arbeitsnachweis', 'reisekosten', + 'bestellung', 'gutschrift', 'kundennummer', 'lieferantennummer', 'mitarbeiternummer', 'waren', + 'produktion', 'sonstiges', 'anfrage', 'artikelnummer', 'kalkulation', 'preisanfrage', 'proformarechnung', + 'retoure', 'verbindlichkeit', 'goodspostingdocument', 'receiptdocument']; - } else { + $dbfield = "next_$type"; + $dbvalue = $this->app->DB->Select("SELECT $dbfield FROM projekt WHERE id='$projekt' LIMIT 1"); + if (!empty($dbvalue)) { + $newbelegnr = $this->CalcNextNummer($dbvalue); + $this->app->DB->Update("UPDATE projekt SET $dbfield='$newbelegnr' WHERE id='$projekt' LIMIT 1"); + } + } + if (empty($newbelegnr)) { // naechste switch($type) { diff --git a/www/pages/shopimport.php b/www/pages/shopimport.php index 397b7a89..291e3d90 100644 --- a/www/pages/shopimport.php +++ b/www/pages/shopimport.php @@ -1,4 +1,4 @@ - +*/ +?> app->erp->KundeAnlegen($typ,$name,$abteilung, // $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt); - if(strlen($warenkorb['kundennummer'])!=''){ + if(!empty($warenkorb['kundennummer'])){ $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' $adresseprojekt AND geloescht!=1 LIMIT 1"); } diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 69149240..0a329611 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -253,15 +253,11 @@ class Shopimporter_Presta extends ShopimporterBase if (!empty($cart['lieferadresse_land']) && $this->taxationByDestinationCountry) { $taxedCountry = $cart['lieferadresse_land']; } - if (strval($order->total_paid_tax_incl) === strval($order->total_paid_tax_excl)) { - if ($this->app->erp->IstEU($taxedCountry)) { - $cart['ust_befreit'] = 1; - } elseif ($this->app->erp->Export($taxedCountry)) { - $cart['ust_befreit'] = 2; - } else { - $cart['ust_befreit'] = 3; - } - } + $lieferschwelle = $this->app->DB->Select("SELECT * FROM lieferschwelle WHERE empfaengerland='$taxedCountry' LIMIT 1"); + if ($this->app->erp->IstEU($taxedCountry) || !empty($lieferschwelle['ueberschreitungsdatum'])) { + $cart['ust_befreit'] = 1; + } elseif ($this->app->erp->Export($taxedCountry)) { + $cart['ust_befreit'] = 2; $taxes = []; $this->app->erp->RunHook('getTaxRatesFromShopOrder', 2, $taxedCountry, $taxes); From 1af809954c4a2198f51b943afea596eae914e77f Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 12:08:47 +0100 Subject: [PATCH 16/51] Bugfix shopimport, bugfixes presta, support for project specific number ranges --- www/pages/shopimporter_presta.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 0a329611..4ad949ce 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -258,7 +258,8 @@ class Shopimporter_Presta extends ShopimporterBase $cart['ust_befreit'] = 1; } elseif ($this->app->erp->Export($taxedCountry)) { $cart['ust_befreit'] = 2; - + } + $taxes = []; $this->app->erp->RunHook('getTaxRatesFromShopOrder', 2, $taxedCountry, $taxes); From 100024391db3a5e881a1d1c8f38ba6a49b33715d Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 14:34:47 +0100 Subject: [PATCH 17/51] Bugfixes presta, support for project specific number ranges --- www/lib/class.erpapi.php | 2 +- www/pages/shopimporter_presta.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index c12a4d90..554317a3 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -29439,7 +29439,7 @@ function Firmendaten($field,$projekt="") $process_lock = $this->app->erp->ProzessLock("erpapi_getnextnummer"); - $eigenernummernkreis = 0; + $eigenernummernkreis = $this->app->DB->Select("SELECT eigenernummernkreis FROM projekt WHERE id='$projekt' LIMIT 1"); $newbelegnr = ''; if($eigenernummernkreis=='1') { diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 4ad949ce..f874464c 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -253,13 +253,13 @@ class Shopimporter_Presta extends ShopimporterBase if (!empty($cart['lieferadresse_land']) && $this->taxationByDestinationCountry) { $taxedCountry = $cart['lieferadresse_land']; } - $lieferschwelle = $this->app->DB->Select("SELECT * FROM lieferschwelle WHERE empfaengerland='$taxedCountry' LIMIT 1"); + $lieferschwelle = $this->app->DB->SelectArr("SELECT * FROM lieferschwelle WHERE empfaengerland='$taxedCountry' LIMIT 1"); if ($this->app->erp->IstEU($taxedCountry) || !empty($lieferschwelle['ueberschreitungsdatum'])) { $cart['ust_befreit'] = 1; } elseif ($this->app->erp->Export($taxedCountry)) { $cart['ust_befreit'] = 2; } - + $taxes = []; $this->app->erp->RunHook('getTaxRatesFromShopOrder', 2, $taxedCountry, $taxes); From bcf2544735077ada89900d2f1057c0660e8a69cb Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 14:50:15 +0100 Subject: [PATCH 18/51] Bugfixes presta, support for project specific number ranges --- www/lib/class.erpapi.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 554317a3..4dcc75d8 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -29440,7 +29440,7 @@ function Firmendaten($field,$projekt="") $process_lock = $this->app->erp->ProzessLock("erpapi_getnextnummer"); $eigenernummernkreis = $this->app->DB->Select("SELECT eigenernummernkreis FROM projekt WHERE id='$projekt' LIMIT 1"); - $newbelegnr = ''; + $belegnr = ''; if($eigenernummernkreis=='1') { $allowedtypes = ['angebot', 'auftrag', 'rechnung', 'lieferschein', 'arbeitsnachweis', 'reisekosten', @@ -29449,13 +29449,13 @@ function Firmendaten($field,$projekt="") 'retoure', 'verbindlichkeit', 'goodspostingdocument', 'receiptdocument']; $dbfield = "next_$type"; - $dbvalue = $this->app->DB->Select("SELECT $dbfield FROM projekt WHERE id='$projekt' LIMIT 1"); - if (!empty($dbvalue)) { + $belegnr = $this->app->DB->Select("SELECT $dbfield FROM projekt WHERE id='$projekt' LIMIT 1"); + if (!empty($belegnr)) { $newbelegnr = $this->CalcNextNummer($dbvalue); $this->app->DB->Update("UPDATE projekt SET $dbfield='$newbelegnr' WHERE id='$projekt' LIMIT 1"); } } - if (empty($newbelegnr)) { + if (empty($belegnr)) { // naechste switch($type) { From 4eac5fbbdc7e20006baf272a6edac8a02f50df79 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 15:38:30 +0100 Subject: [PATCH 19/51] Bugfixes presta, support for project specific number ranges --- www/lib/class.erpapi.php | 2 +- www/pages/shopimporter_presta.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index 4dcc75d8..de87fb3e 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -29451,7 +29451,7 @@ function Firmendaten($field,$projekt="") $dbfield = "next_$type"; $belegnr = $this->app->DB->Select("SELECT $dbfield FROM projekt WHERE id='$projekt' LIMIT 1"); if (!empty($belegnr)) { - $newbelegnr = $this->CalcNextNummer($dbvalue); + $newbelegnr = $this->CalcNextNummer($belegnr); $this->app->DB->Update("UPDATE projekt SET $dbfield='$newbelegnr' WHERE id='$projekt' LIMIT 1"); } } diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index f874464c..68fda8d6 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -278,7 +278,7 @@ class Shopimporter_Presta extends ShopimporterBase 'articleid' => strval($order_row->product_reference), 'name' => strval($order_row->product_name), 'quantity' => strval($order_row->product_quantity), - 'price_netto' => strval($order_row->product_price), + 'price_netto' => strval($order_row->unit_price_tax_excl), 'steuersatz' => $steuersatz ]; } From 575ab86157e86c87f5a0893de0322ddc88b44385 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 29 Jan 2023 21:11:12 +0100 Subject: [PATCH 20/51] 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 21/51] 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 22/51] 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 406811872c724bd109dc384ce3d15d9f3ed832d3 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 31 Jan 2023 12:08:25 +0100 Subject: [PATCH 23/51] Prestashop: Tracking and shipping costs w/o tax --- www/pages/shopimporter_presta.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 68fda8d6..1aa7870f 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -162,7 +162,11 @@ class Shopimporter_Presta extends ShopimporterBase $this->prestaRequest('POST', 'order_histories', $obj->asXML()); - //TODO Tracking + $req = $this->prestaRequest('GET', "order_carriers?filter[order_id]=$auftrag&display=[id]"); + $orderCarrierId = strval($req->order_carriers->order_carrier[0]->id); + $req = $this->prestaRequest('GET', "order_carriers/$orderCarrierId"); + $req->order_carrier->tracking_number = $this->data['tracking']; + $this->prestaRequest('PUT', "order_carriers/$orderCarrierId", $req->asXML()); } public function ImportGetAuftraegeAnzahl() @@ -199,7 +203,7 @@ class Shopimporter_Presta extends ShopimporterBase $cart['auftrag'] = strval($order->id); $cart['onlinebestellnummer'] = strval($order->reference); $cart['gesamtsumme'] = strval($order->total_paid); - $cart['versandkostenbrutto'] = strval($order->total_shipping); + $cart['versandkostennetto'] = strval($order->total_shipping_tax_excl); $cart['bestelldatum'] = strval($order->date_add); $carrier = $this->prestaRequest('GET', "carriers/$order->id_carrier"); From aafcb4130f53deabdd840179e1695770b9cbef0c Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 31 Jan 2023 12:12:01 +0100 Subject: [PATCH 24/51] 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 36322b01716709e280a45978851e0103c345f32d Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 31 Jan 2023 12:19:09 +0100 Subject: [PATCH 25/51] Prestashop: fix typo --- www/pages/shopimporter_presta.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 1aa7870f..d8b34b28 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -162,7 +162,7 @@ class Shopimporter_Presta extends ShopimporterBase $this->prestaRequest('POST', 'order_histories', $obj->asXML()); - $req = $this->prestaRequest('GET', "order_carriers?filter[order_id]=$auftrag&display=[id]"); + $req = $this->prestaRequest('GET', "order_carriers?filter[id_order]=$auftrag&display=[id]"); $orderCarrierId = strval($req->order_carriers->order_carrier[0]->id); $req = $this->prestaRequest('GET', "order_carriers/$orderCarrierId"); $req->order_carrier->tracking_number = $this->data['tracking']; From d84b20fafe6f548e85cf6d15b38b608b12e7eb8b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Wed, 1 Feb 2023 15:42:03 +0100 Subject: [PATCH 26/51] 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 27/51] 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 f495964d2b78667b9fa856152eefbd8450472d78 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 5 Feb 2023 22:22:44 +0100 Subject: [PATCH 28/51] Prestashop: add missing strval() calls --- www/pages/shopimporter_presta.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index d8b34b28..60fd40c2 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -195,7 +195,6 @@ class Shopimporter_Presta extends ShopimporterBase $fetchedOrders = []; foreach ($ordersToProcess as $currentOrderId) { - $this->Log("Importing order from presta", [$this->data, $ordersToProcess, $currentOrderId]); $order = $this->prestaRequest('GET', "orders/$currentOrderId"); $order = $order->order; $cart = []; @@ -217,7 +216,7 @@ class Shopimporter_Presta extends ShopimporterBase $invoiceCountry = $this->prestaRequest('GET', "countries/$invoiceAddress->id_country"); $invoiceCountry = $invoiceCountry->country; $cart['name'] = "$invoiceAddress->firstname $invoiceAddress->lastname"; - if (!empty($invoiceAddress->company)) { + if (!empty(strval($invoiceAddress->company))) { $cart['ansprechpartner'] = $cart['name']; $cart['name'] = strval($invoiceAddress->company); } @@ -231,14 +230,14 @@ class Shopimporter_Presta extends ShopimporterBase $cart['ustid'] = strval($invoiceAddress->vat_number); $cart['land'] = strval($invoiceCountry->iso_code); - if ($order->id_address_invoice != $order->id_address_delivery) { + if (strval($order->id_address_invoice) != strval($order->id_address_delivery)) { $deliveryAddress = $this->prestaRequest('GET', "addresses/$order->id_address_delivery"); $deliveryAddress = $deliveryAddress->address; $deliveryCountry = $this->prestaRequest('GET', "countries/$deliveryAddress->id_country"); $deliveryCountry = $deliveryCountry->country; $cart['abweichendelieferadresse'] = 1; $cart['lieferadresse_name'] = "$deliveryAddress->firstname $deliveryAddress->lastname"; - if (!empty($deliveryAddress->company)) { + if (!empty(strval($deliveryAddress->company))) { $cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name']; $cart['lieferadresse_name'] = strval($deliveryAddress->company); } From 9defde81ae481d322f13385a3f40ea827a74f5cc Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Mon, 6 Feb 2023 13:08:53 +0100 Subject: [PATCH 29/51] 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 d23c0f09dd668f64f1d960fbf0a30c17b401055d Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 21 Feb 2023 17:14:56 +0100 Subject: [PATCH 30/51] apply customer language --- www/pages/shopimporter_presta.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 60fd40c2..818c56fc 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -211,6 +211,11 @@ class Shopimporter_Presta extends ShopimporterBase $customer = $this->prestaRequest('GET', "customers/$order->id_customer"); $cart['email'] = strval($customer->customer->email); + $language = $this->prestaRequest('GET', "languages/{$customer->customer->id_lang}"); + if ($language->language->iso_code == "en") { + $cart['kunde_sprache'] = 'englisch'; + } + $invoiceAddress = $this->prestaRequest('GET', "addresses/$order->id_address_invoice"); $invoiceAddress = $invoiceAddress->address; $invoiceCountry = $this->prestaRequest('GET', "countries/$invoiceAddress->id_country"); From 62de5cdacf44acea4b8a5db226197763cbd55f6c Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Mon, 27 Feb 2023 10:39:04 +0100 Subject: [PATCH 31/51] add copyright/license --- classes/Modules/SubscriptionCycle/Bootstrap.php | 6 ++++++ .../Scheduler/SubscriptionCycleManualJobTask.php | 5 +++++ .../Service/SubscriptionCycleJobService.php | 5 +++++ classes/Modules/SubscriptionCycle/SubscriptionModule.php | 4 ++++ .../SubscriptionCycle/SubscriptionModuleInterface.php | 6 ++++-- www/pages/content/rechnungslauf_abos.tpl | 4 ++++ www/pages/content/rechnungslauf_list.tpl | 4 ++++ www/pages/content/rechnungslauf_minidetail.tpl | 5 +++++ www/pages/rechnungslauf.php | 4 ++++ 9 files changed, 41 insertions(+), 2 deletions(-) diff --git a/classes/Modules/SubscriptionCycle/Bootstrap.php b/classes/Modules/SubscriptionCycle/Bootstrap.php index a27c4664..9e1cd737 100644 --- a/classes/Modules/SubscriptionCycle/Bootstrap.php +++ b/classes/Modules/SubscriptionCycle/Bootstrap.php @@ -1,4 +1,10 @@
  • diff --git a/www/pages/content/rechnungslauf_list.tpl b/www/pages/content/rechnungslauf_list.tpl index 5df2b76a..c0a0f53e 100644 --- a/www/pages/content/rechnungslauf_list.tpl +++ b/www/pages/content/rechnungslauf_list.tpl @@ -1,3 +1,7 @@ +
    • Rechnungen
    • diff --git a/www/pages/content/rechnungslauf_minidetail.tpl b/www/pages/content/rechnungslauf_minidetail.tpl index 588464dc..7a745af8 100644 --- a/www/pages/content/rechnungslauf_minidetail.tpl +++ b/www/pages/content/rechnungslauf_minidetail.tpl @@ -1,3 +1,8 @@ +
      [SUBHEADING] diff --git a/www/pages/rechnungslauf.php b/www/pages/rechnungslauf.php index 3fe7ffdd..fa050d00 100644 --- a/www/pages/rechnungslauf.php +++ b/www/pages/rechnungslauf.php @@ -1,4 +1,8 @@ Date: Mon, 27 Feb 2023 11:12:53 +0100 Subject: [PATCH 32/51] add AGPL and EGPL files to LICENSES folder, adopted README and LICENSE file --- .reuse/dep5 | 3 + LICENSE.md | 655 +------------------------------ LICENSES/AGPL-3.0-only.md | 660 ++++++++++++++++++++++++++++++++ LICENSES/LicenseRef-EGPL-3.1.md | 69 ++++ README.md | 4 +- 5 files changed, 738 insertions(+), 653 deletions(-) create mode 100644 .reuse/dep5 create mode 100644 LICENSES/AGPL-3.0-only.md create mode 100644 LICENSES/LicenseRef-EGPL-3.1.md diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 00000000..4d3579da --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,3 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: OpenXE +Source: https://openxe.org diff --git a/LICENSE.md b/LICENSE.md index 5b5102e0..58fa3fbf 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,654 +1,5 @@ -GNU Affero General Public License -================================= - -_Version 3, 19 November 2007_ -_Copyright © 2007 Free Software Foundation, Inc. <>_ - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. - -## Preamble - -The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - -The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - -When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - -Developers that use our General Public Licenses protect your rights -with two steps: **(1)** assert copyright on the software, and **(2)** offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - -A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - -The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - -An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - -The precise terms and conditions for copying, distribution and -modification follow. - -## TERMS AND CONDITIONS - -### 0. Definitions - -“This License†refers to version 3 of the GNU Affero General Public License. - -“Copyright†also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - -“The Program†refers to any copyrightable work licensed under this -License. Each licensee is addressed as “youâ€. “Licensees†and -“recipients†may be individuals or organizations. - -To “modify†a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a “modified version†of the -earlier work or a work “based on†the earlier work. - -A “covered work†means either the unmodified Program or a work based -on the Program. - -To “propagate†a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - -To “convey†a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - -An interactive user interface displays “Appropriate Legal Notices†-to the extent that it includes a convenient and prominently visible -feature that **(1)** displays an appropriate copyright notice, and **(2)** -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - -### 1. Source Code - -The “source code†for a work means the preferred form of the work -for making modifications to it. “Object code†means any non-source -form of a work. - -A “Standard Interface†means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - -The “System Libraries†of an executable work include anything, other -than the work as a whole, that **(a)** is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and **(b)** serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -“Major Componentâ€, in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - -The “Corresponding Source†for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - -The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - -The Corresponding Source for a work in source code form is that -same work. - -### 2. Basic Permissions - -All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - -You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - -### 3. Protecting Users' Legal Rights From Anti-Circumvention Law - -No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - -When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - -### 4. Conveying Verbatim Copies - -You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - -### 5. Conveying Modified Source Versions - -You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - -* **a)** The work must carry prominent notices stating that you modified -it, and giving a relevant date. -* **b)** The work must carry prominent notices stating that it is -released under this License and any conditions added under section 7. -This requirement modifies the requirement in section 4 to -“keep intact all noticesâ€. -* **c)** You must license the entire work, as a whole, under this -License to anyone who comes into possession of a copy. This -License will therefore apply, along with any applicable section 7 -additional terms, to the whole of the work, and all its parts, -regardless of how they are packaged. This License gives no -permission to license the work in any other way, but it does not -invalidate such permission if you have separately received it. -* **d)** If the work has interactive user interfaces, each must display -Appropriate Legal Notices; however, if the Program has interactive -interfaces that do not display Appropriate Legal Notices, your -work need not make them do so. - -A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -“aggregate†if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - -### 6. Conveying Non-Source Forms - -You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - -* **a)** Convey the object code in, or embodied in, a physical product -(including a physical distribution medium), accompanied by the -Corresponding Source fixed on a durable physical medium -customarily used for software interchange. -* **b)** Convey the object code in, or embodied in, a physical product -(including a physical distribution medium), accompanied by a -written offer, valid for at least three years and valid for as -long as you offer spare parts or customer support for that product -model, to give anyone who possesses the object code either **(1)** a -copy of the Corresponding Source for all the software in the -product that is covered by this License, on a durable physical -medium customarily used for software interchange, for a price no -more than your reasonable cost of physically performing this -conveying of source, or **(2)** access to copy the -Corresponding Source from a network server at no charge. -* **c)** Convey individual copies of the object code with a copy of the -written offer to provide the Corresponding Source. This -alternative is allowed only occasionally and noncommercially, and -only if you received the object code with such an offer, in accord -with subsection 6b. -* **d)** Convey the object code by offering access from a designated -place (gratis or for a charge), and offer equivalent access to the -Corresponding Source in the same way through the same place at no -further charge. You need not require recipients to copy the -Corresponding Source along with the object code. If the place to -copy the object code is a network server, the Corresponding Source -may be on a different server (operated by you or a third party) -that supports equivalent copying facilities, provided you maintain -clear directions next to the object code saying where to find the -Corresponding Source. Regardless of what server hosts the -Corresponding Source, you remain obligated to ensure that it is -available for as long as needed to satisfy these requirements. -* **e)** Convey the object code using peer-to-peer transmission, provided -you inform other peers where the object code and Corresponding -Source of the work are being offered to the general public at no -charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - -A “User Product†is either **(1)** a “consumer productâ€, which means any -tangible personal property which is normally used for personal, family, -or household purposes, or **(2)** anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, “normally used†refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - -“Installation Information†for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - -If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - -The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - -Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - -### 7. Additional Terms - -“Additional permissions†are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - -Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - -* **a)** Disclaiming warranty or limiting liability differently from the -terms of sections 15 and 16 of this License; or -* **b)** Requiring preservation of specified reasonable legal notices or -author attributions in that material or in the Appropriate Legal -Notices displayed by works containing it; or -* **c)** Prohibiting misrepresentation of the origin of that material, or -requiring that modified versions of such material be marked in -reasonable ways as different from the original version; or -* **d)** Limiting the use for publicity purposes of names of licensors or -authors of the material; or -* **e)** Declining to grant rights under trademark law for use of some -trade names, trademarks, or service marks; or -* **f)** Requiring indemnification of licensors and authors of that -material by anyone who conveys the material (or modified versions of -it) with contractual assumptions of liability to the recipient, for -any liability that these contractual assumptions directly impose on -those licensors and authors. - -All other non-permissive additional terms are considered “further -restrictions†within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - -### 8. Termination - -You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - -However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated **(a)** -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and **(b)** permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - -Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - -### 9. Acceptance Not Required for Having Copies - -You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - -### 10. Automatic Licensing of Downstream Recipients - -Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - -An “entity transaction†is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - -### 11. Patents - -A “contributor†is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's “contributor versionâ€. - -A contributor's “essential patent claims†are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, “control†includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - -In the following three paragraphs, a “patent license†is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To “grant†such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - -If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either **(1)** cause the Corresponding Source to be so -available, or **(2)** arrange to deprive yourself of the benefit of the -patent license for this particular work, or **(3)** arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. “Knowingly relying†means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - -A patent license is “discriminatory†if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license **(a)** in connection with copies of the covered work -conveyed by you (or copies made from those copies), or **(b)** primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - -### 12. No Surrender of Others' Freedom - -If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - -### 13. Remote Network Interaction; Use with the GNU General Public License - -Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - -Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - -### 14. Revised Versions of this License - -The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License “or any later version†applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - -Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - -### 15. Disclaimer of Warranty - -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS†WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -### 16. Limitation of Liability - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - -### 17. Interpretation of Sections 15 and 16 - -If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - -_END OF TERMS AND CONDITIONS_ - -## How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the “copyright†line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - -If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a “Source†link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - -You should also get your employer (if you work as a programmer) or school, -if any, to sign a “copyright disclaimer†for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -<>. +# THE CONTENT OF THIS FILE HAS BEEN MOVED TO THE [LICENSES](LICENSES) SUBFOLDER +# SEE [README](README.md) AND [LICENSES](LICENSES) FOLDER FOR MORE INFORMATION ## Plugins/Bibliotheken @@ -706,4 +57,4 @@ For more information on this, and how to apply and follow the GNU AGPL, see moxiecode.com Flot http://code.google.com/p/flot/ - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, \ No newline at end of file diff --git a/LICENSES/AGPL-3.0-only.md b/LICENSES/AGPL-3.0-only.md new file mode 100644 index 00000000..cba6f6a1 --- /dev/null +++ b/LICENSES/AGPL-3.0-only.md @@ -0,0 +1,660 @@ +### GNU AFFERO GENERAL PUBLIC LICENSE + +Version 3, 19 November 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + +### Preamble + +The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains +free software for all its users. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + +A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + +The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + +An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing +under this license. + +The precise terms and conditions for copying, distribution and +modification follow. + +### TERMS AND CONDITIONS + +#### 0. Definitions. + +"This License" refers to version 3 of the GNU Affero General Public +License. + +"Copyright" also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a "modified version" of +the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays "Appropriate Legal Notices" to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +#### 1. Source Code. + +The "source code" for a work means the preferred form of the work for +making modifications to it. "Object code" means any non-source form of +a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +#### 2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 makes +it unnecessary. + +#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +#### 4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +#### 5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: + +- a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. +- b) The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in section 4 + to "keep intact all notices". +- c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. +- d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +#### 6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +- a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. +- b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the Corresponding + Source from a network server at no charge. +- c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. +- d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. +- e) Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the general + public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +"normally used" refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +#### 7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +- a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or +- b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or +- c) Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or +- d) Limiting the use for publicity purposes of names of licensors + or authors of the material; or +- e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or +- f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions + of it) with contractual assumptions of liability to the recipient, + for any liability that these contractual assumptions directly + impose on those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +#### 8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +#### 9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +#### 10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +#### 11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +#### 12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree to +terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + +#### 13. Remote Network Interaction; Use with the GNU General Public License. + +Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your +version supports such interaction) an opportunity to receive the +Corresponding Source of your version by providing access to the +Corresponding Source from a network server at no charge, through some +standard or customary means of facilitating copying of software. This +Corresponding Source shall include the Corresponding Source for any +work covered by version 3 of the GNU General Public License that is +incorporated pursuant to the following paragraph. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + +#### 14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU Affero General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever +published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +#### 15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +#### 16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +#### 17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +### How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively state +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper +mail. + +If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for +the specific requirements. + +You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU AGPL, see . diff --git a/LICENSES/LicenseRef-EGPL-3.1.md b/LICENSES/LicenseRef-EGPL-3.1.md new file mode 100644 index 00000000..d94e4f30 --- /dev/null +++ b/LICENSES/LicenseRef-EGPL-3.1.md @@ -0,0 +1,69 @@ +# EMBEDDED PROJECTS GENERAL PUBLIC LICENSE Version 3.1 +‘EGPLv3.1’ + +Copyright (C) 2015 embedded projects GmbH, Augsburg, Germany + +## Preamble +The EGPLv3.1 incorporates the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3, dated 19 November 2007 (‘AGPLv3’) as shown under EXHIBIT A *and* the following terms, WHEREAS the following terms +- extend, amend and/or clarify the AGPLv3 and +- prevail in case of any contradictions with the AGPLv3. + +The following terms of the EGPLv3.1 may not be separated from the terms of the AGPLv3 in EXHIBIT A – together they form the EGPLv3.1. +It is purpose of the EGPLv3.1 to make any user and/or recipient of this file or its content aware of the identity of the copyright holder/licensor and its business. + +## DEVELOPER & DISTRIBUTOR NOTES: +- For purpose of clarification, the following terms have priority over the terms of the AGPLv3, especially No. 7 of the AGPLv3. This however, may render the EGPLv3.1 incompatible with any other AGPLv3s or any other GPL. +- Inasmuch as embedded projects GmbH is the licensor, embedded projects reserves the right to publish guidelines for the interpretation of the EGPLv3.1 on http://www.wawision.de which are incorporated into this license by reference in case they are published prior to your obtainment of the EGPLv3.1. You bear the burden of proof that you obtained this license prior to the publishment of a certain guideline. + +## 0. Definition of ‘the program’ +‘The Program’ hereinafeter (and pursuant to No. 0 AGPLv3) includes but is not limited to any file or portion of it that +- a) references to the EGPLv3.1 including but not limited to such references from source code header files + +OR + +- b) is referenced to the EGPLv3.1 by + - (i) any documentation provided with the file OR + - (ii) a notice file that is contained in the same directory in which the file is stored. In the absence of such notice file in the same directory, said notice file can be found in the upper directory that is next to the file – which would be the root directory as a last resort. + +The use of this file and its content (including but not limited to all modules, databases, pictorial images and documentation and all forms of computer program codes and parts thereof) are subject to the EGPLv3.1. + +## 1. Adevertising Clauses +- a) All advertising materials for (i) any work that contains this file, its content and/or any portion of it or (ii) mentioning features and/or use of this file, its content and/or any portion of it must mention at least ONE of the following statements: +> “Diese Software ist eine Ableitung und Veränderung von WaWision ERP. WaWision ERP wurde von embedded projects GmbH entwickelt und steht unter der EGPLv3.1-Lizenz als Open Source Software. Informationen zu WaWision und der Open-Source Version findet man unter http://www.wawision.de.†+ +AND/OR + +> “This Software is a derivative and modification of WaWision ERP. WaWision ERP was developed by embedded projects GmbH und is licensed under the EGPLv3.1 license as Open Source Software. Information on WaWision and its open source distribution can be obtained from http://www.wawision.†+ +- b) The statement under clause 1 a) has to be displayed in black latin font (“Arial†or “Times New Romanâ€) on white background with font size of at least 12pt. +- c) The “advertising materials†under clause 1 a) comprises all non-verbal forms of advertising and business in theprogram, including but not limited to digital or printed offers or displays (e.g. on convention displays, brochures, websites or webshops) or terms and conditions for the distribution or cloud/SaaS use of the program. +- d) You are required to provide customers and/or any recipients of your advertising materials with the text of the complete EGPLv3.1 text upon request. You may not charge any fee for the provision of the EGPLv3.1 text, when you are requested to provide the EGPLv3.1 by means of electronic communication (e.g. e-mail). + +## 2. Integrity of Copyright and License Notices +You are not allowed to remove or modify any copyright and license notices from the program unless you only add your own copyright notice exclusively for your own contributions. + +## 3. Network Interaction +- a) A user interaction with the program pursuant to No. 13 AGPLv3 includes but is not limited to situations in which the user receives parts of the program on a client machine during interaction with a server. For the purpose of clarification, + - i) said user interaction does not necessarily mean access to all functions of the program in order to interact with it. Said interaction comprises but is not limited to any code of the program that is purposefully cached on the user’s machine for preparing code execution and any login dialog of the program – no matter whether the user has the suitable login information. + - ii) the term ‘user’ means anyone but the licensee, i.e. comprising but not limited to employees of the licensee. +- b) Instead of providing the user that interacts with the program pursuant to No. 13 AGPLv3 with the source code of the original program, you are obliged to offer the complete corresponding code of the licensee’s covered work for internet download to the PUBLIC under the EGPLv3.1, including but not limited to No. 5 AGPLv3. The aforementioned offer has to be prominently positioned + +## 4. Defintion of a ‘Work Based on the Program’ +A ‘work based on the program’ includes but is not limited to +- a) any new arrangement of the program with other new files, e.g. libraries – without regard to the form of linking (dynamic or static) AND +- b) any other new module that contains portions of the program, e.g. any code fragment of the program. In case, the aforementioned incorporation of a code fragment into a new module does not require the permission by the licensor, said module must be licensed under the EGPLv3.1 when the module is conveyed together with the program. + +## 5. No Trademark or Name Rights +Notwithstanding No. 1 and 5 EGPLv3.1, nothing in the EGPLv3.1 grants you the to right to use the trademark ‘WaWision’ or the name of the embedded projects GmbH. + +## 6. Integrity of the EGPLv3.1 +The EGPLv3.1 may not be changed, including but not limited for the distribution of the program or any work based on the program; No. 14 AGPLv3 does not apply. + +## 7. Choice of Law, Jurisdiction +The EGPLv3.1 is governed by the laws of Germany whereas the application of the International Convention of the Sale of Goods (CISG) is excluded. Inasmuch as you are a merchant pursuant to Sec. 13 German Civil Code (BGB), all courts in Germany shall have jurisdiction for any dispute arising from the EGPLv3.1. + +# – EXHIBIT A – +## GNU AFFERO GENERAL PUBLIC LICENSE +Version 3, 19 November 2007 + +-> See [AGPL-3.0-only.md](AGPL-3.0-only.md) diff --git a/README.md b/README.md index 0e1c0c0e..65d088f3 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,6 @@ Neuimplementierung des Xentral 20 Enterprise Ticketsystems mit vielen Verbesseru [Hier gehts zur OpenXE Installation](INSTALL.md) -OpenXE ist freie Software, lizensiert unter AGPL 3 und basiert auf der Open Source Version von Xentral https://xentral.com/ +OpenXE ist freie Software, lizensiert unter der EGPL 3.1. +Diese Software ist eine Ableitung und Veränderung von WaWision ERP. WaWision ERP wurde von embedded projects GmbH entwickelt und steht unter der EGPLv3.1-Lizenz als Open Source Software. Informationen zu WaWision und der Open-Source Version findet man unter http://www.wawision.de + From f37ef6e5918adf918ad34090c3a1321c57262be1 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Tue, 28 Feb 2023 13:36:25 +0100 Subject: [PATCH 33/51] 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 @@ Date: Tue, 28 Feb 2023 13:40:31 +0100 Subject: [PATCH 34/51] add copyright/license --- www/lib/class.erpapi.php | 7 +++++++ www/lib/class.remote.php | 7 +++++++ www/pages/appstore.php | 7 +++++++ www/pages/shopimport.php | 7 +++++++ www/pages/shopimporter_presta.php | 6 ++++++ www/pages/steuersaetze.php | 7 +++++++ 6 files changed, 41 insertions(+) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index de87fb3e..a6dfeac7 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -1,4 +1,11 @@ Date: Sun, 12 Mar 2023 22:15:52 +0100 Subject: [PATCH 35/51] fix index accessor for new PHP Versions (implicit const string) --- www/pages/gutschrift.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/pages/gutschrift.php b/www/pages/gutschrift.php index 0fc85785..3182cac8 100644 --- a/www/pages/gutschrift.php +++ b/www/pages/gutschrift.php @@ -1260,7 +1260,7 @@ class Gutschrift extends GenGutschrift if((!empty($alle_gutschriften)?count($alle_gutschriften):0) > 1) { for($agi=0;$agi<(!empty($alle_gutschriften)?count($alle_gutschriften):0);$agi++) - $gutschriften .= "".$alle_gutschriften[$agi][belegnr]." "; + $gutschriften .= "".$alle_gutschriften[$agi]['belegnr']." "; $this->app->Tpl->Add('MESSAGE',"
          Für die angebene Rechnung gibt es schon folgende Gutschriften: $gutschriften
          "); } } From 28fc3f6bd3d5c225562e662216ab48f9d1fde5ed Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 12 Mar 2023 22:26:44 +0100 Subject: [PATCH 36/51] fix index accessor for new PHP Versions (implicit const string) in rechnung.php --- www/pages/rechnung.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/pages/rechnung.php b/www/pages/rechnung.php index 56a59deb..202b9a81 100644 --- a/www/pages/rechnung.php +++ b/www/pages/rechnung.php @@ -1804,7 +1804,7 @@ class Rechnung extends GenRechnung { $gutschriften = ''; for($agi=0;$agi<$cgutschriften;$agi++) - $gutschriften .= "".$alle_gutschriften[$agi][belegnr]." "; + $gutschriften .= "".$alle_gutschriften[$agi]['belegnr']." "; $this->app->Tpl->Add('MESSAGE',"
          Für die angebene Rechnung gibt es schon folgende Gutschriften: $gutschriften
          "); } From 5638f18770d863076f186ac2c024f62387df06da Mon Sep 17 00:00:00 2001 From: OpenXE-ERP <83282423+OpenXE-ERP@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:00:35 +0100 Subject: [PATCH 37/51] Merge pull request #67 from exciler/bugfix_gutschrift_php8 fix index accessor for new PHP Versions (implicit const string) --- www/pages/gutschrift.php | 2 +- www/pages/rechnung.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/www/pages/gutschrift.php b/www/pages/gutschrift.php index 0fc85785..3182cac8 100644 --- a/www/pages/gutschrift.php +++ b/www/pages/gutschrift.php @@ -1260,7 +1260,7 @@ class Gutschrift extends GenGutschrift if((!empty($alle_gutschriften)?count($alle_gutschriften):0) > 1) { for($agi=0;$agi<(!empty($alle_gutschriften)?count($alle_gutschriften):0);$agi++) - $gutschriften .= "".$alle_gutschriften[$agi][belegnr]." "; + $gutschriften .= "".$alle_gutschriften[$agi]['belegnr']." "; $this->app->Tpl->Add('MESSAGE',"
          Für die angebene Rechnung gibt es schon folgende Gutschriften: $gutschriften
          "); } } diff --git a/www/pages/rechnung.php b/www/pages/rechnung.php index 56a59deb..202b9a81 100644 --- a/www/pages/rechnung.php +++ b/www/pages/rechnung.php @@ -1804,7 +1804,7 @@ class Rechnung extends GenRechnung { $gutschriften = ''; for($agi=0;$agi<$cgutschriften;$agi++) - $gutschriften .= "".$alle_gutschriften[$agi][belegnr]." "; + $gutschriften .= "".$alle_gutschriften[$agi]['belegnr']." "; $this->app->Tpl->Add('MESSAGE',"
          Für die angebene Rechnung gibt es schon folgende Gutschriften: $gutschriften
          "); } From ecd86d120ad2ecf8587afb0fa3e2f40b6e7db117 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Tue, 14 Mar 2023 12:10:54 +0100 Subject: [PATCH 38/51] Bugfix lager wert calculation of prices added geloescht != 1 and date range --- www/pages/lager.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/www/pages/lager.php b/www/pages/lager.php index d6c1635d..9a2273f8 100644 --- a/www/pages/lager.php +++ b/www/pages/lager.php @@ -451,7 +451,7 @@ class Lager extends GenLager { FROM einkaufspreise minek WHERE - einkaufspreise.artikel = minek.artikel AND DATE( + einkaufspreise.geloescht != 1 AND einkaufspreise.artikel = minek.artikel AND DATE( REPLACE ( COALESCE(gueltig_bis, '9999-12-31'), @@ -482,7 +482,17 @@ class Lager extends GenLager { ) ) >= DATE('".$datum."') ) - ) + ) AND DATE( + REPLACE + ( + COALESCE( + einkaufspreise.gueltig_bis, + '9999-12-31' + ), + '0000-00-00', + '9999-12-31' + ) + ) >= DATE('".$datum."') GROUP BY artikel, waehrung From 34def013f70d016288c656c3a6063f9006c1a4b8 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 23 Mar 2023 22:28:48 +0100 Subject: [PATCH 39/51] change default handler to "list", fix TableSearch findcols --- www/pages/rechnungslauf.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/pages/rechnungslauf.php b/www/pages/rechnungslauf.php index fa050d00..dcb0313a 100644 --- a/www/pages/rechnungslauf.php +++ b/www/pages/rechnungslauf.php @@ -35,8 +35,8 @@ class Rechnungslauf { $width = ['1%', '1%', '10%', '20%', '10%', '10%', '10%', '10%', '10%', '10%', '1%']; $findcols = [ - '', - '', + 'adr.kundennummer', + 'adr.kundennummer', 'adr.kundennummer', 'adr.name', 'adr.anschreiben', @@ -209,7 +209,7 @@ class Rechnungslauf { $this->app->ActionHandlerInit($this); // ab hier alle Action Handler definieren die das Modul hat - $this->app->ActionHandler('rechnungslauf', 'ActionList'); + $this->app->ActionHandler('list', 'ActionList'); $this->app->ActionHandler('abos', 'ActionAbos'); $this->app->ActionHandler('minidetail', 'ActionMinidetail'); @@ -218,7 +218,7 @@ class Rechnungslauf { public function MenuList() { $this->app->erp->Headlines("Abolauf"); - $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=rechnungslauf", "Übersicht"); + $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=list", "Übersicht"); $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=abos", "gebuchte Abos"); $this->app->erp->MenuEintrag("index.php?module=rechnungslauf&action=einstellungen", "Einstellungen"); } From 696e9efc76a2a6d9a05527f0d293f8d164f74d2f Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 23 Mar 2023 23:22:45 +0100 Subject: [PATCH 40/51] improve stability of versandarten --- www/lib/class.versanddienstleister.php | 8 ++++---- www/pages/versandarten.php | 26 +++++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index e2e5afcd..9fcd29ee 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -153,14 +153,14 @@ abstract class Versanddienstleister 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 - LEFT JOIN rechnung r on rp.rechnung = r.id + LEFT OUTER JOIN auftrag_position ap on lp.auftrag_position_id = ap.id + LEFT OUTER JOIN rechnung_position rp on ap.id = rp.auftrag_position_id + LEFT OUTER 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); + $ret['positions'] = $this->app->DB->SelectArr($sql) ?? []; if ($sid === "lieferschein") { $standardkg = $this->app->erp->VersandartMindestgewicht($lieferscheinId); diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 6ab5cad0..60b996f0 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -10,7 +10,7 @@ /* **** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE **** * -* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019 +* Xentral (c) Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019 * * This file is licensed under the Embedded Projects General Public License *Version 3.1. * @@ -190,12 +190,14 @@ class Versandarten { )) $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->ValidateSettings($form)); - foreach ($obj->AdditionalSettings() as $k => $v) { - $json[$k] = $form[$k]; + if ($obj !== null) { + foreach ($obj->AdditionalSettings() as $k => $v) { + $form[$k] = $this->app->Secure->GetPOST($k); + } + $error = array_merge($error, $obj->ValidateSettings($form)); + foreach ($obj->AdditionalSettings() as $k => $v) { + $json[$k] = $form[$k]; + } } $json = json_encode($json ?? null); @@ -241,7 +243,7 @@ class Versandarten { $form['paketmarke_drucker'] = $daten['paketmarke_drucker']; } - $obj->RenderAdditionalSettings('MODULESETTINGS', $form); + $obj?->RenderAdditionalSettings('MODULESETTINGS', $form); $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', $this->getPrinterByModule($obj, false), $form['export_drucker']); @@ -278,11 +280,11 @@ class Versandarten { $this->app->Tpl->Parse('PAGE', 'versandarten_edit.tpl'); } - protected function getPrinterByModule(Versanddienstleister $obj, bool $includeLabelPrinter = true): array + protected function getPrinterByModule(?Versanddienstleister $obj, bool $includeLabelPrinter = true): array { $printer = $this->app->erp->GetDrucker(); - if ($includeLabelPrinter && $obj->isEtikettenDrucker()) { + if ($includeLabelPrinter && $obj?->isEtikettenDrucker()) { $labelPrinter = $this->app->erp->GetEtikettendrucker(); $printer = array_merge($printer ?? [], $labelPrinter ?? []); } @@ -757,7 +759,7 @@ class Versandarten { * @param string $module * @param int $moduleId * - * @return mixed|null + * @return ?Versanddienstleister */ public function loadModule(string $module, int $moduleId = 0) : ?Versanddienstleister { @@ -821,6 +823,8 @@ class Versandarten { continue; $obj = $this->loadModule($modul); + if ($obj === null) + continue; $result[$modul] = $obj->name ?? ucfirst($modul); unset($obj); } From 51552e7530058ee3a357dc9cec3cddbf956f0606 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 23 Mar 2023 23:23:03 +0100 Subject: [PATCH 41/51] cleanup old versandarten --- www/lib/class.erpapi.php | 16 - www/lib/versandarten/ShipService_v12.wsdl | 6097 --------------------- www/lib/versandarten/dhl.php_ | 691 --- www/lib/versandarten/internetmarke.php_ | 1096 ---- www/lib/versandarten/parcelone.php_ | 2172 -------- www/lib/versandarten/ppl_480.csv | 90 - www/lib/versandarten/sonstiges.php_ | 410 -- 7 files changed, 10572 deletions(-) delete mode 100644 www/lib/versandarten/ShipService_v12.wsdl delete mode 100644 www/lib/versandarten/dhl.php_ delete mode 100644 www/lib/versandarten/internetmarke.php_ delete mode 100644 www/lib/versandarten/parcelone.php_ delete mode 100644 www/lib/versandarten/ppl_480.csv delete mode 100644 www/lib/versandarten/sonstiges.php_ diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index c5280d4f..2f793032 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -28104,31 +28104,15 @@ function Firmendaten($field,$projekt="") $modul = ""; $tmp = array( - 'DHL'=>'DHL','DPD'=>'DPD', - 'express_dpd'=>'Express DPD', - 'export_dpd'=>'Export DPD', - 'gls'=>'GLS', 'keinversand'=>'Kein Versand', 'selbstabholer'=>'Selbstabholer', - 'versandunternehmen'=>'Sonstige', 'spedition'=>'Spedition', - 'Go'=>'GO!', - 'post'=>'Post' ); foreach($tmp as $key=>$value) { - if($key == 'DHL'){$modul='intraship';} - if($key == 'DPD'){$modul='dpdapi';} - if($key == 'express_dpd'){$modul='';} - if($key == 'export_dpd'){$modul='';} - if($key == 'gls'){$modul='glsapi';} if($key == 'keinversand'){$modul='';} if($key == 'selbstabholer'){$modul='selbstabholer';} - if($key == 'versandunternehmen'){$modul='';} if($key == 'spedition'){$modul='';} - if($key == 'Go'){$modul='';} - if($key == 'post'){$modul='post';} - $this->app->DB->Insert("INSERT INTO versandarten (id,type,bezeichnung,aktiv,modul) VALUES ('','$key','$value','1','$modul')"); } diff --git a/www/lib/versandarten/ShipService_v12.wsdl b/www/lib/versandarten/ShipService_v12.wsdl deleted file mode 100644 index f3c2463a..00000000 --- a/www/lib/versandarten/ShipService_v12.wsdl +++ /dev/null @@ -1,6097 +0,0 @@ - - - - - - - - - - - - - - - - - - Specifies additional labels to be produced. All required labels for shipments will be produced without the need to request additional labels. These are only available as thermal labels. - - - - - The type of additional labels to return. - - - - - The number of this type label to return - - - - - - - Identifies the type of additional labels. - - - - - - - - - - - - - - - - Descriptive data for a physical location. May be used as an actual physical address (place to which one could go), or as a container of "address parts" which should be handled as a unit (such as a city-state-ZIP combination within the US). - - - - - Combination of number, street name, etc. At least one line is required for a valid physical address; empty lines should not be included. - - - - - Name of city, town, etc. - - - - - Identifying abbreviation for US state, Canada province, etc. Format and presence of this field will vary, depending on country. - - - - - Identification of a region (usually small) for mail/package delivery. Format and presence of this field will vary, depending on country. - - - - - Relevant only to addresses in Puerto Rico. - - - - - The two-letter code used to identify a country. - - - - - The fully spelt out name of a country. - - - - - Indicates whether this address residential (as opposed to commercial). - - - - - - - - - - - - - - Specifies the tracking id for the payment on the return. - - - - - Specifies additional customer reference data about the associated shipment. - - - - - Specifies shipment level operational information. - - - - - Specifies package level operational information on the associated shipment. This information is not tied to an individual outbound package. - - - - - - - - - - - - - - - - Specifies which filing option is being exercised by the customer. - Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. - - - - - - - - - - - - - Identification of the type of barcode (symbology) used on FedEx documents and labels. - - - - - - - - - - Each instance of this data type represents a barcode whose content must be represented as binary data (i.e. not ASCII text). - - - - - The kind of barcode data in this instance. - - - - - The data content of this instance. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Descriptive data sent to FedEx by a customer in order to Cancel a Pending shipment. - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - - - - Identification of a FedEx operating company (transportation). - - - - - - - - - - - - - The instructions indicating how to print the Certificate of Origin ( e.g. whether or not to include the instructions, image type, etc ...) - - - - - Specifies characteristics of a shipping document to be produced. - - - - - Specifies the usage and identification of customer supplied images to be used on this document. - - - - - - - - - - - - - Specifies the type of brokerage to be applied to a shipment. - - - - - - - - - - - - Descriptive data for the client submitting a transaction. - - - - - The FedEx account number associated with this transaction. - - - - - This number is assigned by FedEx and identifies the unique device from which the request is originating - - - - - Only used in transactions which require identification of the Fed Ex Office integrator. - - - - - The language to be used for human-readable Notification.localizedMessages in responses to the request containing this ClientDetail object. Different requests from the same client may contain different Localization data. (Contrast with TransactionDetail.localization, which governs data payload language/translation.) - - - - - - - - - - - - - - - - - Select the type of rate from which the element is to be selected. - - - - - - - - - Specifies the type of adjustment was performed to the COD collection amount during rating. - - - - - - - - - Identifies the type of funds FedEx should collect upon shipment delivery. - - - - - - - - - - - - Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. - - - - - - Specifies the details of the charges are to be added to the COD collect amount. - - - - - Identifies the type of funds FedEx should collect upon package delivery - - - - - For Express this is the descriptive data that is used for the recipient of the FedEx Letter containing the COD payment. For Ground this is the descriptive data for the party to receive the payment that prints the COD receipt. - - - - - When the FedEx COD payment type is not CASH, indicates the contact and address of the financial institution used to service the payment of the COD. - - - - - Specifies the name of person or company receiving the secured/unsecured funds payment - - - - - Indicates which type of reference information to include on the COD return shipping label. - - - - - Only used with multi-piece COD shipments sent in multiple transactions. Required on last transaction only. - - - - - - - Specifies the information associated with a package that has COD special service in a ground shipment. - - - - - The COD amount (after any accumulations) that must be collected upon delivery of a package shipped using the COD special service. - - - - - - - Contains the data which form the Astra and 2DCommon barcodes that print on the COD return label. - - - - - The label image or printer commands to print the label. - - - - - - - Indicates which type of reference information to include on the COD return shipping label. - - - - - - - - - - - CommercialInvoice element is required for electronic upload of CI data. It will serve to create/transmit an Electronic Commercial Invoice through the FedEx Systems. Customers are responsible for printing their own Commercial Invoice.If you would likeFedEx to generate a Commercial Invoice and transmit it to Customs. for clearance purposes, you need to specify that in the ShippingDocumentSpecification element. If you would like a copy of the Commercial Invoice that FedEx generated returned to you in reply it needs to be specified in the ETDDetail/RequestedDocumentCopies element. Commercial Invoice support consists of maximum of 99 commodity line items. - - - - - Any comments that need to be communicated about this shipment. - - - - - Any freight charges that are associated with this shipment. - - - - - Any taxes or miscellaneous charges(other than Freight charges or Insurance charges) that are associated with this shipment. - - - - - Specifies which kind of charge is being recorded in the preceding field. - - - - - Any packing costs that are associated with this shipment. - - - - - Any handling costs that are associated with this shipment. - - - - - Free-form text. - - - - - Free-form text. - - - - - Free-form text. - - - - - The reason for the shipment. Note: SOLD is not a valid purpose for a Proforma Invoice. - - - - - Additional customer reference data. - - - - - Name of the International Expert that completed the Commercial Invoice different from Sender. - - - - - Required for dutiable international Express or Ground shipment. This field is not applicable to an international PIB(document) or a non-document which does not require a Commercial Invoice - - - - - - - The instructions indicating how to print the Commercial Invoice( e.g. image type) Specifies characteristics of a shipping document to be produced. - - - - - - Specifies the usage and identification of a customer supplied image to be used on this document. - - - - - - - - For international multiple piece shipments, commodity information must be passed in the Master and on each child transaction. - If this shipment cotains more than four commodities line items, the four highest valued should be included in the first 4 occurances for this request. - - - - - - Name of this commodity. - - - - - Total number of pieces of this commodity - - - - - Complete and accurate description of this commodity. - - 450 - - - - - - Country code where commodity contents were produced or manufactured in their final form. - - 2 - - - - - - - Unique alpha/numeric representing commodity item. - At least one occurrence is required for US Export shipments if the Customs Value is greater than $2500 or if a valid US Export license is required. - - - 14 - - - - - - Total weight of this commodity. 1 explicit decimal position. Max length 11 including decimal. - - - - - This field is used for enterprise transactions. - - - - - Unit of measure used to express the quantity of this commodity line item. - - 3 - - - - - - Contains only additional quantitative information other than weight and quantity to calculate duties and taxes. - - - - - Value of each unit in Quantity. Six explicit decimal positions, Max length 18 including decimal. - - - - - - Total customs value for this line item. - It should equal the commodity unit quantity times commodity unit value. - Six explicit decimal positions, max length 18 including decimal. - - - - - - Defines additional characteristic of commodity used to calculate duties and taxes - - - - - Applicable to US export shipping only. - - 12 - - - - - - - Date of expiration. Must be at least 1 day into future. - The date that the Commerce Export License expires. Export License commodities may not be exported from the U.S. on an expired license. - Applicable to US Export shipping only. - Required only if commodity is shipped on commerce export license, and Export License Number is supplied. - - - - - - - An identifying mark or number used on the packaging of a shipment to help customers identify a particular shipment. - - - 15 - - - - - - - All data required for this commodity in NAFTA Certificate of Origin. - - - - - - - Specifies the results of processing for the COD special service. - - - - - - - - - - - The identifier for all clearance documents associated with this shipment. - - - - - - - - Completed package-level hazardous commodity information for a single package. - - - - - A unique reference id that matches the package to a package configuration. This is populated if the client provided a package configuration for several packages that have the exact same dangerous goods content. - - - - - - When true indicates that the package can be transported only on a cargo aircraft. - - - - - Specifies the maximum radiation level from the package (measured in microSieverts per hour at a distance of one meter from the external surface of the package, divided by 10). - - - - - Specifies the label that is to be put on a package containing radioactive material. The label type is determined in accordance with the Transportation of Dangerous Goods Act and indicates the type of radioactive material being handled as well as the relative risk. - - - - - Documents the kinds and quantities of all hazardous commodities in the current package. - - - - - - - Computed shipment level hazardous commodity information. - - - - - - - - - - - Specifies the total number of packages containing hazardous commodities in small exceptions. - - - - - - - - - Identifies the branded location name, the hold at location phone number and the address of the location. - - - - - Identifies the type of FedEx location. - - - - - - - - - The package sequence number of this package in a multiple piece shipment. - - - - - The Tracking number and form id for this package. - - - - - Used with request containing PACKAGE_GROUPS, to identify which group of identical packages was used to produce a reply item. - - - - - Oversize class for this package. - - - - - All package-level rating data for this package, which may include data for multiple rate types. - - - - - - The label image or printer commands to print the label. - - - - - All package-level shipping documents (other than labels and barcodes). For use in loads after January, 2008. - - - - - Specifies the information associated with this package that has COD special service in a ground shipment. - - - - - Actual signature option applied, to allow for cases in which the original value conflicted with other service features in the shipment. - - - - - - Documents the kinds and quantities of all hazardous commodities in the current package, using updated hazardous commodity description data. - - - - - - - - - Indicates whether or not this is a US Domestic shipment. - - - - - Indicates the carrier that will be used to deliver this shipment. - - - - - The master tracking number and form id of this multiple piece shipment. This information is to be provided for each subsequent of a multiple piece shipment. - - - - - Description of the FedEx service used for this shipment. Currently not supported. - - 70 - - - - - - Description of the packaging used for this shipment. Currently not supported. - - 40 - - - - - - - Only used with pending shipments. - - - - - Only used in the reply to tag requests. - - - - - Provides reply information specific to SmartPost shipments. - - - - - Computed shipment level information about hazarous commodities. - - - - - All shipment-level rating data for this shipment, which may include data for multiple rate types. - - - - - Returns the default holding location information when HOLD_AT_LOCATION special service is requested and the client does not specify the hold location address. - - - - - Returns any defaults or updates applied to RequestedShipment.exportDetail.exportComplianceStatement. - - - - - - All shipment-level shipping documents (other than labels and barcodes). - - - - - - - Package level details about this package. - - - - - - - Provides reply information specific to SmartPost shipments. - - - - - Identifies the carrier that will pick up the SmartPost shipment. - - - - - Indicates whether the shipment is deemed to be machineable, based on dimensions, weight, and packaging. - - - - - - - Provides reply information specific to a tag request. - - - - - . - - - - - As of June 2007, returned only for FedEx Express services. - - - - - As of June 2007, returned only for FedEx Express services. - - - - - As of June 2007, returned only for FedEx Express services. - - - - - As of June 2007, returned only for FedEx Express services. - - - - - FEDEX INTERNAL USE ONLY: for use by INET. - - - - - - - Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. - - - - - 1 of 12 possible zones to position data. - - - - - The identifiying text for the data in this zone. - - - - - A reference to a field in either the request or reply to print in this zone following the header. - - - - - A literal value to print after the header in this zone. - - - - - - - The descriptive data for a point-of-contact person. - - - - - Client provided identifier corresponding to this contact information. - - - - - Identifies the contact person's name. - - - - - Identifies the contact person's title. - - - - - Identifies the company this contact is associated with. - - - - - Identifies the phone number associated with this contact. - - - - - Identifies the phone extension associated with this contact. - - - - - Identifies a toll free number, if any, associated with this contact. - - - - - Identifies the pager number associated with this contact. - - - - - Identifies the fax number associated with this contact. - - - - - Identifies the email address associated with this contact. - - - - - - - - - - - - - Content Record. - - - - - Part Number. - - - - - Item Number. - - - - - Received Quantity. - - - - - Description. - - - - - - - Reply to the Close Request transaction. The Close Reply bring back the ASCII data buffer which will be used to print the Close Manifest. The Manifest is essential at the time of pickup. - - - - - Identifies the highest severity encountered when executing the request; in order from high to low: FAILURE, ERROR, WARNING, NOTE, SUCCESS. - - - - - The descriptive data detailing the status of a sumbitted transaction. - - - - - Descriptive data that governs data payload language/translations. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - The reply payload. All of the returned information about this shipment/package. - - - - - - - Create Pending Shipment Request - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - The descriptive data identifying the client submitting the transaction. - - - - - The descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Descriptive data about the shipment being sent by the requestor. - - - - - - - Currency exchange rate information. - - - - - The currency code for the original (converted FROM) currency. - - - - - The currency code for the final (converted INTO) currency. - - - - - Multiplier used to convert fromCurrency units to intoCurrency units. - - - - - - - - - Indicates the type of custom delivery being requested. - - - - - Time by which delivery is requested. - - - - - Range of dates for custom delivery request; only used if type is BETWEEN. - - - - - Date for custom delivery request; only used for types of ON, BETWEEN, or AFTER. - - - - - - - - - - - - - - - Data required to produce a custom-specified document, either at shipment or package level. - - - - - Common information controlling document production. - - - - - Applicable only to documents produced on thermal printers with roll stock. - - - - - Applicable only to documents produced on thermal printers with roll stock. - - - - - Identifies the formatting specification used to construct this custom document. - - - - - Identifies the individual document specified by the client. - - - - - If provided, thermal documents will include specified doc tab content. If omitted, document will be produced without doc tab content. - - - - - - - Constructed string, based on format and zero or more data fields, printed in specified barcode symbology. - - - - - - - - - Width of thinnest bar/space element in the barcode. - - - - - - - - Solid (filled) rectangular area on label. - - - - - - - - - Valid values for CustomLabelCoordinateUnits - - - - - - - - - - - - - - - - - - Image to be included from printer's memory, or from a local file for offline clients. - - - - - - Printer-specific index of graphic image to be printed. - - - - - Fully-qualified path and file name for graphic image to be printed. - - - - - - - - - Horizontal position, relative to left edge of custom area. - - - - - Vertical position, relative to top edge of custom area. - - - - - - - Constructed string, based on format and zero or more data fields, printed in specified printer font (for thermal labels) or generic font/size (for plain paper labels). - - - - - - - - Printer-specific font name for use with thermal printer labels. - - - - - Generic font name for use with plain paper labels. - - - - - Generic font size for use with plain paper labels. - - - - - - - - - - - - - - - - - - - Reference information to be associated with this package. - - - - - The reference type to be associated with this reference data. - - - - - - - - The types of references available for use. - - - - - - - - - - - - - - - - - Allows customer-specified control of label content. - - - - - If omitted, no doc tab will be produced (i.e. default is former NONE type). - - - - - Defines any custom content to print on the label. - - - - - Defines additional data to print in the Configurable portion of the label, this allows you to print the same type information on the label that can also be printed on the doc tab. - - - - - Controls which data/sections will be suppressed. - - - - - For customers producing their own Ground labels, this field specifies which secondary barcode will be printed on the label; so that the primary barcode produced by FedEx has the correct SCNC. - - - - - - Controls the number of additional copies of supplemental labels. - - - - - This value reduces the default quantity of destination/consignee air waybill labels. A value of zero indicates no change to default. A minimum of one copy will always be produced. - - - - - - - - - - Interacts both with properties of the shipment and contractual relationship with the shipper. - - - - - - - Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. - - - - - - - - Identifies responsibilities with respect to loss, damage, etc. - - - - - Documents amount paid to third party for coverage of shipment content. - - - - - - - - - - - - - - - Specifies additional description about customs options. This is a required field when the customs options type is "OTHER". - - - - - - - - - - - - - - - - - - - - - - - - - - - Describes an approved container used to package dangerous goods commodities. This does not describe any individual inner receptacles that may be within this container. - - - - - Indicates whether there are additional inner receptacles within this container. - - - - - Indicates the type of this dangerous goods container, as specified by the IATA packing instructions. For example, steel cylinder, fiberboard box, plastic jerrican and steel drum. - - - - - Indicates the packaging type of the container used to package the radioactive materials. - - - - - Indicates the number of occurrences of this container with identical dangerous goods configuration. - - - - - Documents the kinds and quantities of all hazardous commodities in the current container. - - - - - - - The descriptive data required for a FedEx shipment containing dangerous goods (hazardous materials). - - - - - Identifies whether or not the products being shipped are required to be accessible during delivery. - - - - - Shipment is packaged/documented for movement ONLY on cargo aircraft. - - - - - Indicates which kinds of hazardous content are in the current package. - - - - - Indicates whether there is additional customer provided packaging enclosing the approved dangerous goods containers. - - - - - Identifies the configuration of this dangerous goods package. The common configuration is represented at the shipment level. - - - - - Indicates one or more containers used to pack dangerous goods commodities. - - - - - Description of the packaging of this commodity, suitable for use on OP-900 and OP-950 forms. - - - - - Name, title and place of the signatory for this shipment. - - - - - Telephone number to use for contact in the event of an emergency. - - - - - Offeror's name or contract number, per DOT regulation. - - - - - Specifies the contact of the party responsible for handling the infectious substances, if any, in the dangerous goods shipment. - - - - - Specifies additional handling information for the current package. - - - - - Specifies the radioactivity detail for the current package, if the package contains radioactive materials. - - - - - - - - - - - - The instructions indicating how to print the 1421c form for dangerous goods shipment. - - - - - Specifies characteristics of a shipping document to be produced. - - - - - Specifies the usage and identification of customer supplied images to be used on this document. - - - - - - - Specifies that name, title and place of the signatory responsible for the dangerous goods shipment. - - - - - - - Indicates the place where the form is signed. - - - - - - - - - The beginning date in a date range. - - - - - The end date in a date range. - - - - - - - Valid values for DayofWeekType - - - - - - - - - - - - - - Descriptive data sent to FedEx by a customer in order to delete a package. - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - The timestamp of the shipment request. - - - - - Identifies the FedEx tracking number of the package being cancelled. - - - - - Determines the type of deletion to be performed in relation to package level vs shipment level. - - - - - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Only used for tags which had FedEx Express services. - - - - - Only used for tags which had FedEx Express services. - - - - - If the original ProcessTagRequest specified third-party payment, then the delete request must contain the same pay type and payor account number for security purposes. - - - - - Also known as Pickup Confirmation Number or Dispatch Number - - - - - - - Specifies the type of deletion to be performed on a shipment. - - - - - - - - - - - - - - Specifies the tracking id for the return, if preassigned. - - - - - - - Data required to complete the Destionation Control Statement for US exports. - - - - - List of applicable Statment types. - - - - - Comma-separated list of up to four country codes, required for DEPARTMENT_OF_STATE statement. - - - - - Name of end user, required for DEPARTMENT_OF_STATE statement. - - - - - - - Used to indicate whether the Destination Control Statement is of type Department of Commerce, Department of State or both. - - - - - - - - - The dimensions of this package and the unit type used for the measurements. - - - - - - - - - - - - - The DocTabContentType options available. - - - - - The DocTabContentType should be set to ZONE001 to specify additional Zone details. - - - - - The DocTabContentType should be set to BARCODED to specify additional BarCoded details. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Zone number can be between 1 and 12. - - - - - Header value on this zone. - - - - - Reference path to the element in the request/reply whose value should be printed on this zone. - - - - - Free form-text to be printed in this zone. - - - - - Justification for the text printed on this zone. - - - - - - - Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. - - - - - - - - - - - - Describes specific information about the email label shipment. - - - - - Notification email will be sent to this email address - - - - - Message to be sent in the notification email - - - - - - - - - - - - - Information describing email notifications that will be sent in relation to events that occur during package movement - - - - - Specifies whether/how email notifications are grouped. - - - - - A message that will be included in the email notifications - - - - - Information describing the destination of the email, format of the email and events to be notified on - - - - - - - - - - - - - - - The format of the email - - - - - - - - - - The descriptive data for a FedEx email notification recipient. - - - - - Identifies the relationship this email recipient has to the shipment. - - - - - The email address to send the notification to - - - - - The types of email notifications being requested for this recipient. - - - - - The format of the email notification. - - - - - The language/locale to be used in this email notification. - - - - - - - Identifies the set of valid email notification recipient types. For SHIPPER, RECIPIENT and BROKER the email address asssociated with their definitions will be used, any email address sent with the email notification for these three email notification recipient types will be ignored. - - - - - - - - - - - - - - - - - - - - - Customer-declared value, with data type and legal values depending on excise condition, used in defining the taxable value of the item. - - - - - - - Specifies the types of Estimated Duties and Taxes to be included in a rate quotation for an international shipment. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Electronic Trade document references used with the ETD special service. - - - - - Indicates the types of shipping documents produced for the shipper by FedEx (see ShippingDocumentSpecification) which should be copied back to the shipper in the shipment result data. - - - - - - - - Country specific details of an International shipment. - - - - - - Specifies which filing option is being exercised by the customer. - Required for non-document shipments originating in Canada destined for any country other than Canada, the United States, Puerto Rico or the U.S. Virgin Islands. - - - - - - General field for exporting-country-specific export data (e.g. B13A for CA, FTSR Exemption or AES Citation for US). - - - - - This field is applicable only to Canada export non-document shipments of any value to any destination. No special characters allowed. - - 10 - - - - - - Department of Commerce/Department of State information about this shipment. - - - - - - - Details specific to an Express freight shipment. - - - - - Indicates whether or nor a packing list is enclosed. - - - - - - Total shipment pieces. - e.g. 3 boxes and 3 pallets of 100 pieces each = Shippers Load and Count of 303. - Applicable to International Priority Freight and International Economy Freight. - Values must be in the range of 1 - 99999 - - - - - - Required for International Freight shipping. Values must be 8- 12 characters in length. - - 12 - - - - - - - - Identifies a kind of FedEx facility. - - - - - - - - - - - - - Data required to produce the Freight handling-unit-level address labels. Note that the number of UNIQUE labels (the N as in 1 of N, 2 of N, etc.) is determined by total handling units. - - - - - - Indicates the number of copies to be produced for each unique label. - - - - - Specifies the quadrant of the page on which the label printing will start. - - - - - If omitted, no doc tab will be produced (i.e. default = former NONE type). - - - - - - - Individual charge which contributes to the total base charge for the shipment. - - - - - Freight class for this line item. - - - - - Effective freight class used for rating this line item. - - - - - NMFC Code for commodity. - - - - - Customer-provided description for this commodity or class line. - - - - - Weight for this commodity or class line. - - - - - Rate or factor applied to this line item. - - - - - Identifies the manner in which the chargeRate for this line item was applied. - - - - - The net or extended charge for this line item. - - - - - - - Specifies the way in which base charges for a Freight shipment or shipment leg are calculated. - - - - - - - - - - - - - - - - - These values represent the industry-standard freight classes used for FedEx Freight and FedEx National Freight shipment description. (Note: The alphabetic prefixes are required to distinguish these values from decimal numbers on some client platforms.) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Date for all Freight guarantee types. - - - - - - - - - - - - - Identifies responsibilities with respect to loss, damage, etc. - - - - - - - - - Rate data specific to FedEx Freight or FedEx National Freight services. - - - - - A unique identifier for a specific rate quotation. - - - - - Specifies whether the rate quote was automated or manual. - - - - - Specifies how total base charge is determined. - - - - - Freight charges which accumulate to the total base charge for the shipment. - - - - - Human-readable descriptions of additional information on this shipment rating. - - - - - - - Additional non-monetary data returned with Freight rates. - - - - - Unique identifier for notation. - - - - - Human-readable explanation of notation. - - - - - - - Specifies the type of rate quote - - - - - - - - - Data applicable to shipments using FEDEX_FREIGHT_ECONOMY and FEDEX_FREIGHT_PRIORITY services. - - - - - Account number used with FEDEX_FREIGHT service. - - - - - Used for validating FedEx Freight account number and (optionally) identifying third party payment on the bill of lading. - - - - - Used in connection with "Send Bill To" (SBT) identification of customer's account used for billing. - - - - - Identification values to be printed during creation of a Freight bill of lading. - - - - - Indicates the role of the party submitting the transaction. - - - - - Designates the terms of the "collect" payment for a Freight Shipment. - - - - - Identifies the declared value for the shipment - - - - - Identifies the declared value units corresponding to the above defined declared value - - - - - - Identifiers for promotional discounts offered to customers. - - - - - Total number of individual handling units in the entire shipment (for unit pricing). - - - - - Estimated discount rate provided by client for unsecured rate quote. - - - - - Total weight of pallets used in shipment. - - - - - Overall shipment dimensions. - - - - - Description for the shipment. - - - - - Specifies which party will pay surcharges for any special services which support split billing. - - - - - Must be populated if any line items contain hazardous materials. - - - - - - Details of the commodities in the shipment. - - - - - - - Description of an individual commodity or class of content in a shipment. - - - - - Freight class for this line item. - - - - - FEDEX INTERNAL USE ONLY: for FedEx system that estimate freight class from customer-provided dimensions and weight. - - - - - Number of individual handling units to which this line applies. (NOTE: Total of line-item-level handling units may not balance to shipment-level total handling units.) - - - - - Specification of handling-unit packaging for this commodity or class line. - - - - - Number of pieces for this commodity or class line. - - - - - NMFC Code for commodity. - - - - - Indicates the kind of hazardous material content in this line item. - - - - - For printed reference per line item. - - - - - Customer-provided description for this commodity or class line. - - - - - Weight for this commodity or class line. - - - - - FED EX INTERNAL USE ONLY - Individual line item dimensions. - - - - - Volume (cubic measure) for this commodity or class line. - - - - - - - Indicates the role of the party submitting the transaction. - - - - - - - - - Specifies which party will be responsible for payment of any surcharges for Freight special services for which split billing is allowed. - - - - - Identifies the special service. - - - - - Indicates who will pay for the special service. - - - - - - - Data required to produce a General Agency Agreement document. Remaining content (business data) to be defined once requirements have been completed. - - - - - - - - Represents features of FedEx Ground delivery for which the shipment is eligible. - - - - - - - - - - - Documents the kind and quantity of an individual hazardous commodity in a package. - - - - - Identifies and describes an individual hazardous commodity. - - - - - Specifies the amount of the commodity in alternate units. - - - - - Customer-provided specifications for handling individual commodities. - - - - - Specifies the details of any radio active materials within the commodity. - - - - - - - Identifies and describes an individual hazardous commodity. - - - - - Regulatory identifier for a commodity (e.g. "UN ID" value). - - - - - In conjunction with the regulatory identifier, this field uniquely identifies a specific hazardous materials commodity. - - - - - - - - - - - - - - Indicates any special processing options to be applied to the description of the dangerous goods commodity. - - - - - Information related to quantity limitations and operator or state variations as may be applicable to the dangerous goods commodity. - - - - - - - Specifies any special processing to be applied to the dangerous goods commodity description validation. - - - - - - - - Specifies how the commodity is to be labeled. - - - - - - - - - - Customer-provided specifications for handling individual commodities. - - - - - Specifies how the customer wishes the label text to be handled for this commodity in this package. - - - - - Text used in labeling the commodity under control of the labelTextOption field. - - - - - - - Indicates which kind of hazardous content (as defined by DOT) is being reported. - - - - - - - - - - - - Identifies number and type of packaging units for hazardous commodities. - - - - - Number of units of the type below. - - - - - Units in which the hazardous commodity is packaged. - - - - - - - Specifies documentation and limits for validation of an individual packing group/category. - - - - - - Coded specification for how commodity is to be packed. - - - - - - - Identifies DOT packing group for a hazardous commodity. - - - - - - - - - - - Identifies amount and units for quantity of hazardous commodities. - - - - - Number of units of the type below. - - - - - Units by which the hazardous commodity is measured. For IATA commodity, the units values are restricted based on regulation type. - - - - - Specifies which measure of quantity is to be validated. - - - - - - - Specifies the measure of quantity to be validated against a prescribed limit. - - - - - - - - - - - - - - Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. - - - - - Contact phone number for recipient of shipment. - - - - - Contact and address of FedEx facility at which shipment is to be held. - - - - - Type of facility at which package/shipment is to be held. - - - - - - - The descriptive data required by FedEx for home delivery services. - - - - - The type of Home Delivery Premium service being requested. - - - - - Required for Date Certain Home Delivery. - - - - - Required for Date Certain and Appointment Home Delivery. - - 15 - - - - - - - - The type of Home Delivery Premium service being requested. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The type of International shipment. - - - - - - - - - - - - - - - Specifies the type of label to be returned. - - - - - - - - - - - Names for data elements / areas which may be suppressed from printing on labels. - - - - - - - - - - - - This indicates if the top or bottom of the label comes out of the printer first. - - - - - - - - - Relative to normal orientation for the printer. - - - - - - - - - - - Description of shipping label to be returned in the reply - - - - - Specifies how to create, organize, and return the document. - - - - - Specify type of label to be returned - - - - - Specifies the image format used for a shipping document. - - - - - For thermal printer lables this indicates the size of the label and the location of the doc tab if present. - - - - - This indicates if the top or bottom of the label comes out of the printer first. - - - - - If present, this contact and address information will replace the return address information on the label. - - - - - Allows customer-specified control of label content. - - - - - - - For thermal printer labels this indicates the size of the label and the location of the doc tab if present. - - - - - - - - - - - - - - - - - - - - - - - Identifies the Liability Coverage Amount. For Jan 2010 this value represents coverage amount per pound - - - - - - - - - - - - - Represents a one-dimensional measurement in small units (e.g. suitable for measuring a package or document), contrasted with Distance, which represents a large one-dimensional measurement (e.g. distance between cities). - - - - - The numerical quantity of this measurement. - - - - - The units for this measurement. - - - - - - - CM = centimeters, IN = inches - - - - - - - - - Identifies the representation of human-readable text. - - - - - Two-letter code for language (e.g. EN, FR, etc.) - - - - - Two-letter code for the region (e.g. us, ca, etc..). - - - - - - - - - - - - - Identifies which type minimum charge was applied. - - - - - - - - - - - - The descriptive data for the medium of exchange for FedEx services. - - - - - Identifies the currency of the monetary amount. - - 3 - - - - - - Identifies the monetary amount. - - - - - - - Data required to produce a Certificate of Origin document. Remaining content (business data) to be defined once requirements have been completed. - - - - - - - Indicates which Party (if any) from the shipment is to be used as the source of importer data on the NAFTA COO form. - - - - - Contact information for "Authorized Signature" area of form. - - - - - - - - - - This element is currently not supported and is for the future use. - - - - - Defined by NAFTA regulations. - - - - - Defined by NAFTA regulations. - - - - - Identification of which producer is associated with this commodity (if multiple producers are used in a single shipment). - - - - - - Date range over which RVC net cost was calculated. - - - - - - - - - - - - - - - Net cost method used. - - - - - - - - - See instructions for NAFTA Certificate of Origin for code definitions. - - - - - - - - - - - - - This element is currently not supported and is for the future use. - - - - - - - - - See instructions for NAFTA Certificate of Origin for code definitions. - - - - - - - - - - - This element is currently not supported and is for the future use. - - - - - - - - - - - - The descriptive data regarding the result of the submitted transaction. - - - - - The severity of this notification. This can indicate success or failure or some other information about the request. The values that can be returned are SUCCESS - Your transaction succeeded with no other applicable information. NOTE - Additional information that may be of interest to you about your transaction. WARNING - Additional information that you need to know about your transaction that you may need to take action on. ERROR - Information about an error that occurred while processing your transaction. FAILURE - FedEx was unable to process your transaction at this time due to a system failure. Please try again later - - - - - Indicates the source of this notification. Combined with the Code it uniquely identifies this notification - - - - - A code that represents this notification. Combined with the Source it uniquely identifies this notification. - - - - - Human-readable text that explains this notification. - - - - - The translated message. The language and locale specified in the ClientDetail. Localization are used to determine the representation. Currently only supported in a TrackReply. - - - - - A collection of name/value pairs that provide specific data to help the client determine the nature of an error (or warning, etc.) witout having to parse the message string. - - - - - - - - - Identifies the type of data contained in Value (e.g. SERVICE_TYPE, PACKAGE_SEQUENCE, etc..). - - - - - The value of the parameter (e.g. PRIORITY_OVERNIGHT, 2, etc..). - - - - - - - Identifies the set of severity values for a Notification. - - - - - - - - - - - - The instructions indicating how to print the OP-900 form for hazardous materials packages. - - - - - Specifies characteristics of a shipping document to be produced. - - - - - Identifies which reference type (from the package's customer references) is to be used as the source for the reference on this OP-900. - - - - - Specifies the usage and identification of customer supplied images to be used on this document. - - - - - Data field to be used when a name is to be printed in the document instead of (or in addition to) a signature image. - - - - - - - - - Position of operational instruction element. - - - - - Content corresponding to the operational instruction. - - - - - - - The oversize class types. - - - - - - - - - - Each instance of this data type represents the set of barcodes (of all types) which are associated with a specific package. - - - - - Binary-style barcodes for this package. - - - - - String-style barcodes for this package. - - - - - - - Package-level data required for labeling and/or movement. - - - - - Human-readable text for pre-January 2011 clients. - - - - - Human-readable content for use on a label. - - - - - The operational barcodes pertaining to the current package. - - - - - The FedEx internal code that represents the service and/or features of service for the current package moving under a FedEx Ground service. - - - - - - - Data for a package's rates, as calculated per a specific rate type. - - - - - Type used for this specific set of rate data. - - - - - Indicates which weight was used. - - - - - INTERNAL FEDEX USE ONLY. - - - - - The weight that was used to calculate the rate. - - - - - The dimensional weight of this package (if greater than actual). - - - - - The oversize weight of this package (if the package is oversize). - - - - - The transportation charge only (prior to any discounts applied) for this package. - - - - - The sum of all discounts on this package. - - - - - This package's baseCharge - totalFreightDiscounts. - - - - - The sum of all surcharges on this package. - - - - - This package's netFreight + totalSurcharges (not including totalTaxes). - - - - - The sum of all taxes on this package. - - - - - This package's netFreight + totalSurcharges + totalTaxes. - - - - - The total sum of all rebates applied to this package. - - - - - All rate discounts that apply to this package. - - - - - All rebates that apply to this package. - - - - - All surcharges that apply to this package (either because of characteristics of the package itself, or because it is carrying per-shipment surcharges for the shipment of which it is a part). - - - - - All taxes applicable (or distributed to) this package. - - - - - The variable handling charges calculated based on the type variable handling charges requested. - - - - - - - This class groups together for a single package all package-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. - - - - - This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the package. - - - - - The "list" net charge minus "actual" net charge. - - - - - Each element of this field provides package-level rate data for a specific rate type. - - - - - - - Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Ground shipments only. - - - - - - - - - - - - - - - These special services are available at the package level for some or all service types. If the shipper is requesting a special service which requires additional data, the package special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. - - - - - The types of all special services requested for the enclosing shipment or package. - - - - - For use with FedEx Ground services only; COD must be present in shipment's special services. - - - - - Descriptive data required for a FedEx shipment containing dangerous materials. This element is required when SpecialServiceType.DANGEROUS_GOODS or HAZARDOUS_MATERIAL is present in the SpecialServiceTypes collection. - - - - - Descriptive data required for a FedEx shipment containing dry ice. This element is required when SpecialServiceType.DRY_ICE is present in the SpecialServiceTypes collection. - - - - - The descriptive data required for FedEx signature services. This element is required when SpecialServiceType.SIGNATURE_OPTION is present in the SpecialServiceTypes collection. - - - - - The descriptive data required for FedEx Priority Alert service. This element is required when SpecialServiceType.PRIORITY_ALERT is present in the SpecialServiceTypes collection. - - - - - - - Identifies the collection of available FedEx or customer packaging options. - - - - - - - - - - - - - - - - - - - - - - The descriptive data for a person or company entitiy doing business with FedEx. - - - - - Identifies the FedEx account number assigned to the customer. - - 12 - - - - - - - Descriptive data identifying the point-of-contact person. - - - - - The descriptive data for a physical location. - - - - - - - The descriptive data for the monetary compensation given to FedEx for services rendered to the customer. - - - - - Identifies the method of payment for a service. See PaymentType for list of valid enumerated values. - - - - - Descriptive data identifying the party responsible for payment for a service. - - - - - - - Identifies the method of payment for a service. - - - - - - - - - - - - The descriptive data identifying the party responsible for payment for a service. - - - - - - - - This information describes how and when a pending shipment may be accessed for completion. - - - - - Only for pending shipment type of "EMAIL" - - - - - Only for pending shipment type of "EMAIL" - - - - - Only for pending shipment type of "EMAIL" - - - - - This element is currently not supported and is for the future use. - - - - - - - This information describes the kind of pending shipment being requested. - - - - - Identifies the type of FedEx pending shipment - - - - - Date after which the pending shipment will no longer be available for completion. - - - - - Only used with type of EMAIL. - - - - - - - Identifies the type of service for a pending shipment. - - - - - - - - - - - - - - - - This enumeration rationalizes the former FedEx Express international "admissibility package" types (based on ANSI X.12) and the FedEx Freight packaging types. The values represented are those common to both carriers. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This class describes the pickup characteristics of a shipment (e.g. for use in a tag request). - - - - - - - - Identifies the type of Pickup request - - - - - Identifies the type of source for Pickup request - - - - - - - Identifies the type of source for pickup request service. - - - - - - - - - Identifies the type of pickup request service. - - - - - - - - - Identifies the type of pricing used for this shipment. - - - - - - - - - - - - - - - - - - - - Represents a reference identifier printed on Freight bills of lading - - - - - - - - - Identifies a particular reference identifier printed on a Freight bill of lading. - - - - - - - - - - - - - - - - - - - - - - - This indicates the highest level of severity of all the notifications returned in this reply - - - - - The descriptive data regarding the results of the submitted transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - - The reply payload. All of the returned information about this shipment/package. - - - - - Empty unless error label behavior is PACKAGE_ERROR_LABELS and one or more errors occured during transaction processing. - - - - - - - Descriptive data sent to FedEx by a customer in order to ship a package. - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Descriptive data about the shipment being sent by the requestor. - - - - - - - - - - - - - - - - Descriptive data sent to FedEx by a customer in order to ship a package. - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Descriptive data about the shipment being sent by the requestor. - - - - - - - Test for the Commercial Invoice. Note that Sold is not a valid Purpose for a Proforma Invoice. - - - - - - - - - - - - - Indicates the packaging type of the container used to package radioactive hazardous materials. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Indicates whether packaging type "EXCEPTED" or "EXCEPTED_PACKAGE" is for radioactive material in reportable quantity. - - - - - - - - - Indicates the reason that a dim divisor value was chose. - - - - - - - - - - - - Identifies a discount applied to the shipment. - - - - - Identifies the type of discount applied to the shipment. - - - - - - The amount of the discount applied to the shipment. - - - - - The percentage of the discount applied to the shipment. - - - - - - - The type of the discount. - - - - - - - - - - - - - Selects the value from a set of rate data to which the percentage is applied. - - - - - - - - - - - Identifies the type(s) of rates to be returned in the reply. - - - - - - - - - - Select the type of rate from which the element is to be selected. - - - - - - - - - The weight method used to calculate the rate. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specifies how the recipient is identified for customs purposes; the requirements on this information vary with destination country. - - - - - Specifies the kind of identification being used. - - - - - Contains the actual ID value, of the type specified above. - - - - - - - Type of Brazilian taxpayer identifier provided in Recipient/TaxPayerIdentification/Number. For shipments bound for Brazil this overrides the value in Recipient/TaxPayerIdentification/TinType - - - - - - - - - - FOOD_OR_PERISHABLE is required by FDA/BTA; must be true for food/perishable items coming to US or PR from non-US/non-PR origin - - - - - - - - - - This class rationalizes RequestedPackage and RequestedPackageSummary from previous interfaces. - - - - - Used only with INDIVIDUAL_PACKAGE, as a unique identifier of each requested package. - - - - - Used only with PACKAGE_GROUPS, as a unique identifier of each group of identical packages. - - - - - Used only with PACKAGE_GROUPS, as a count of packages within a group of identical packages. - - - - - - Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case totalInsuredValue and packageCount on the shipment will be used to determine this value. - - - - - Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. Ignored for PACKAGE_SUMMARY, in which case total weight and packageCount on the shipment will be used to determine this value. - - - - - - Provides additional detail on how the customer has physically packaged this item. As of June 2009, required for packages moving under international and SmartPost services. - - - - - Human-readable text describing the package. - - - - - - - Only used for INDIVIDUAL_PACKAGES and PACKAGE_GROUPS. - - - - - - - The descriptive data for the shipment being tendered to FedEx. - - - - - Identifies the date and time the package is tendered to FedEx. Both the date and time portions of the string are expected to be used. The date should not be a past date or a date more than 10 days in the future. The time is the local time of the shipment based on the shipper's time zone. The date component must be in the format: YYYY-MM-DD (e.g. 2006-06-26). The time component must be in the format: HH:MM:SS using a 24 hour clock (e.g. 11:00 a.m. is 11:00:00, whereas 5:00 p.m. is 17:00:00). The date and time parts are separated by the letter T (e.g. 2006-06-26T17:00:00). There is also a UTC offset component indicating the number of hours/mainutes from UTC (e.g 2006-06-26T17:00:00-0400 is defined form June 26, 2006 5:00 pm Eastern Time). - - - - - Identifies the method by which the package is to be tendered to FedEx. This element does not dispatch a courier for package pickup. See DropoffType for list of valid enumerated values. - - - - - Identifies the FedEx service to use in shipping the package. See ServiceType for list of valid enumerated values. - - - - - Identifies the packaging used by the requestor for the package. See PackagingType for list of valid enumerated values. - - - - - Identifies the total weight of the shipment being conveyed to FedEx.This is only applicable to International shipments and should only be used on the first package of a mutiple piece shipment.This value contains 1 explicit decimal position - - - - - Total insured amount. - - - - - This attribute indicates the currency the caller requests to have used in all returned monetary values (when a choice is possible). - - - - - Descriptive data identifying the party responsible for shipping the package. Shipper and Origin should have the same address. - - - - - Descriptive data identifying the party receiving the package. - - - - - A unique identifier for a recipient location - - 10 - - - - - - Physical starting address for the shipment, if different from shipper's address. - - - - - Descriptive data indicating the method and means of payment to FedEx for providing shipping services. - - - - - Descriptive data regarding special services requested by the shipper for this shipment. If the shipper is requesting a special service which requires additional data (e.g. COD), the special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object. For example, to request COD, "COD" must be included in the SpecialServiceTypes collection and the CodDetail object must contain the required data. - - - - - Details specific to an Express freight shipment. - - - - - Data applicable to shipments using FEDEX_FREIGHT_ECONOMY and FEDEX_FREIGHT_PRIORITY services. - - - - - Used with Ground Home Delivery and Freight. - - - - - Details about how to calculate variable handling charges at the shipment level. - - - - - Customs clearance data, used for both international and intra-country shipping. - - - - - For use in "process tag" transaction. - - - - - Specifies the characteristics of a shipment pertaining to SmartPost services. - - - - - If true, only the shipper/payor will have visibility of this shipment. - - - - - Details about the image format and printer type the label is to returned in. - - - - - Contains data used to create additional (non-label) shipping documents. - - - - - Specifies whether and what kind of rates the customer wishes to have quoted on this shipment. The reply will also be constrained by other data on the shipment and customer. - - - - - Specifies whether the customer wishes to have Estimated Duties and Taxes provided with the rate quotation on this shipment. Only applies with shipments moving under international services. - - - - - Only used with multiple-transaction shipments, to identify the master package in a multi-piece shipment. - - - - - The total number of packages in the entire shipment (even when the shipment spans multiple transactions.) - - - - - Specifies data structures that may be re-used multiple times with s single shipment. - - - - - One or more package-attribute descriptions, each of which describes an individual package, a group of identical packages, or (for the total-piece-total-weight case) common characteristics all packages in the shipment. - - - - - - - - - - - - - - - - - - - - - - - - - - Specifies the tracking number of the master associated with the return shipment. - - - - - - - - These values are used to control the availability of certain special services at the time when a customer uses the e-mail label link to create a return shipment. - - - - - - - - - Return Email Details - - - - - Phone number of the merchant - - - - - Identifies the allowed (merchant-authorized) special services which may be selected when the subsequent shipment is created. Only services represented in EMailLabelAllowedSpecialServiceType will be controlled by this list. - - - - - - - The instructions indicating how to print the return instructions( e.g. image type) Specifies characteristics of a shipping document to be produced. - - - - - - Specifies additional customer provided text to be inserted into the return document. - - - - - - - Information relating to a return shipment. - - - - - The type of return shipment that is being requested. - - - - - Return Merchant Authorization - - - - - Describes specific information about the email label for return shipment. - - - - - - - - The type of return shipment that is being requested. - - - - - - - - - - The "PAYOR..." rates are expressed in the currency identified in the payor's rate table(s). The "RATED..." rates are expressed in the currency of the origin country. Former "...COUNTER..." values have become "...RETAIL..." values, except for PAYOR_COUNTER and RATED_COUNTER, which have been removed. - - - - - - - - - - - - - - - - - - - - Shipping document type. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - June 2011 ITG 121203 IR-RMA number has been removed from this structure and added as a new customer reference type. The structure remains because of the reason field below. - - - - - The reason for the return. - - 60 - - - - - - - - - - - - - - - - Identifies the collection of available FedEx service options. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specifies data structures that may be re-used multiple times with s single shipment. - - - - - Specifies the data that is common to dangerous goods packages in the shipment. This is populated when the shipment contains packages with identical dangerous goods commodities. - - - - - - - Shipment-level totals of dry ice data across all packages. - - - - - Total number of packages in the shipment that contain dry ice. - - - - - Total shipment dry ice weight for all packages. - - - - - - - Data for a single leg of a shipment's total/summary rates, as calculated per a specific rate type. - - - - - Human-readable text describing the shipment leg. - - - - - Origin for this leg. - - - - - Specifies the location id the origin of shipment leg. - - - - - Destination for this leg. - - - - - Specifies the location id the destination of shipment leg. - - - - - Type used for this specific set of rate data. - - - - - Indicates the rate scale used. - - - - - Indicates the rate zone used (based on origin and destination). - - - - - - Indicates which weight was used. - - - - - INTERNAL FEDEX USE ONLY. - - - - - Specifies the currency exchange performed on financial amounts for this rate. - - - - - Indicates which special rating cases applied to this shipment. - - - - - - Identifies the type of dim divisor that was applied. - - - - - - - Sum of dimensional weights for all packages. - - - - - - - - - This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). - - - - - Total of the transportation-based taxes. - - - - - - - Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. - - - - - This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. - - - - - Rate data specific to FedEx Freight and FedEx National Freight services. - - - - - All rate discounts that apply to this shipment. - - - - - All rebates that apply to this shipment. - - - - - All surcharges that apply to this shipment. - - - - - All transportation-based taxes applicable to this shipment. - - - - - All commodity-based duties and taxes applicable to this shipment. - - - - - The "order level" variable handling charges. - - - - - The total of all variable handling charges at both shipment (order) and package level. - - - - - - - - - - - - - - - - - This is the state of the destination location ID, and is not necessarily the same as the postal state. - - - - - Expected/estimated date of delivery. - - - - - Expected/estimated day of week of delivery. - - - - - Delivery time, as published in Service Guide. - - - - - Committed date of delivery. - - - - - Committed day of week of delivery. - - - - - Standard transit time per origin, destination, and service. - - - - - Maximum expected transit time - - - - - Transit time based on customer eligibility. - - - - - Indicates that this shipment is not eligible for money back guarantee. - - - - - FedEx Ground delivery features for which this shipment may be eligible. - - - - - Text describing planned delivery. - - - - - - - - - - - - - - Data for a shipment's total/summary rates, as calculated per a specific rate type. The "total..." fields may differ from the sum of corresponding package data for Multiweight or Express MPS. - - - - - Type used for this specific set of rate data. - - - - - Indicates the rate scale used. - - - - - Indicates the rate zone used (based on origin and destination). - - - - - Identifies the type of pricing used for this shipment. - - - - - Indicates which weight was used. - - - - - INTERNAL FEDEX USE ONLY. - - - - - Specifies the currency exchange performed on financial amounts for this rate. - - - - - Indicates which special rating cases applied to this shipment. - - - - - The value used to calculate the weight based on the dimensions. - - - - - Identifies the type of dim divisor that was applied. - - - - - Specifies a fuel surcharge percentage. - - - - - The weight used to calculate these rates. - - - - - Sum of dimensional weights for all packages. - - - - - The total freight charge that was calculated for this package before surcharges, discounts and taxes. - - - - - The total discounts used in the rate calculation. - - - - - The freight charge minus discounts. - - - - - The total amount of all surcharges applied to this shipment. - - - - - This shipment's totalNetFreight + totalSurcharges (not including totalTaxes). - - - - - Total of the transportation-based taxes. - - - - - The net charge after applying all discounts and surcharges. - - - - - The total sum of all rebates applied to this shipment. - - - - - Total of all values under this shipment's dutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment. - - - - - This shipment's totalNetCharge + totalDutiesAndTaxes; only provided if estimated duties and taxes were calculated for this shipment AND duties, taxes and transportation charges are all paid by the same sender's account. - - - - - Identifies the Rate Details per each leg in a Freight Shipment - - - - - Rate data specific to FedEx Freight and FedEx National Freight services. - - - - - All rate discounts that apply to this shipment. - - - - - All rebates that apply to this shipment. - - - - - All surcharges that apply to this shipment. - - - - - All transportation-based taxes applicable to this shipment. - - - - - All commodity-based duties and taxes applicable to this shipment. - - - - - The "order level" variable handling charges. - - - - - The total of all variable handling charges at both shipment (order) and package level. - - - - - - - This class groups together all shipment-level rate data (across all rate types) as part of the response to a shipping request, which groups shipment-level data together and groups package-level data by package. - - - - - This rate type identifies which entry in the following array is considered as presenting the "actual" rates for the shipment. - - - - - The "list" total net charge minus "actual" total net charge. - - - - - Each element of this field provides shipment-level rate totals for a specific rate type. - - - - - - - - - This indicates the highest level of severity of all the notifications returned in this reply - - - - - The descriptive data regarding the results of the submitted transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - - - Identifies the collection of special service offered by FedEx. BROKER_SELECT_OPTION should be used for Express shipments only. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - These special services are available at the shipment level for some or all service types. If the shipper is requesting a special service which requires additional data (such as the COD amount), the shipment special service type must be present in the specialServiceTypes collection, and the supporting detail must be provided in the appropriate sub-object below. - - - - - The types of all special services requested for the enclosing shipment (or other shipment-level transaction). - - - - - Descriptive data required for a FedEx COD (Collect-On-Delivery) shipment. This element is required when SpecialServiceType.COD is present in the SpecialServiceTypes collection. - - - - - - Descriptive data required for a FedEx shipment that is to be held at the destination FedEx location for pickup by the recipient. This element is required when SpecialServiceType.HOLD_AT_LOCATION is present in the SpecialServiceTypes collection. - - - - - Descriptive data required for FedEx to provide email notification to the customer regarding the shipment. This element is required when SpecialServiceType.EMAIL_NOTIFICATION is present in the SpecialServiceTypes collection. - - - - - The descriptive data required for FedEx Printed Return Label. This element is required when SpecialServiceType.PRINTED_RETURN_LABEL is present in the SpecialServiceTypes collection - - - - - This field should be populated for pending shipments (e.g. e-mail label) It is required by a PENDING_SHIPMENT special service type. - - - - - - - Number of packages in this shipment which contain dry ice and the total weight of the dry ice for this shipment. - - - - - The descriptive data required for FedEx Home Delivery options. This element is required when SpecialServiceType.HOME_DELIVERY_PREMIUM is present in the SpecialServiceTypes collection - - - - - - Electronic Trade document references. - - - - - Specification for date or range of dates on which delivery is to be attempted. - - - - - - - All package-level shipping documents (other than labels and barcodes). - - - - - Shipping Document Type - - - - - Specifies how this document image/file is organized. - - - - - - The name under which a STORED or DEFERRED document is written. - - - - - Specifies the image type of this shipping document. - - - - - Specifies the image resolution in DPI (dots per inch). - - - - - Can be zero for documents whose disposition implies that no content is included. - - - - - One or more document parts which make up a single logical document, such as multiple pages of a single form. - - - - - - - Each occurrence of this class specifies a particular way in which a kind of shipping document is to be produced and provided. - - - - - Values in this field specify how to create and return the document. - - - - - Specifies how to organize all documents of this type. - - - - - Specifies how to e-mail document images. - - - - - Specifies how a queued document is to be printed. - - - - - - - Specifies how to return a shipping document to the caller. - - - - - - - - - - - - - - Specifies how to e-mail shipping documents. - - - - - Provides the roles and email addresses for e-mail recipients. - - - - - Identifies the convention by which documents are to be grouped as e-mail attachments. - - - - - - - - - - - - - Specifies an individual recipient of e-mailed shipping document(s). - - - - - Identifies the relationship of this recipient in the shipment. - - - - - Address to which the document is to be sent. - - - - - - - Specifies characteristics of a shipping document to be produced. - - - - - Specifies how to create, organize, and return the document. - - - - - Specifies how far down the page to move the beginning of the image; allows for printing on letterhead and other pre-printed stock. - - - - - - - For those shipping document types which have both a "form" and "instructions" component (e.g. NAFTA Certificate of Origin and General Agency Agreement), this field indicates whether to provide the instructions. - - - - - Governs the language to be used for this individual document, independently from other content returned for the same shipment. - - - - - Identifies the individual document specified by the client. - - - - - - - Specifies how to organize all shipping documents of the same type. - - - - - - - - - Specifies the image format used for a shipping document. - - - - - - - - - - - - - - - A single part of a shipping document, such as one page of a multiple-page document whose format requires a separate image per page. - - - - - The one-origin position of this part within a document. - - - - - Graphic or printer commands for this image within a document. - - - - - - - Specifies printing options for a shipping document. - - - - - Provides environment-specific printer identification. - - - - - - - Contains all data required for additional (non-label) shipping documents to be produced in conjunction with a specific shipment. - - - - - Indicates the types of shipping documents requested by the shipper. - - - - - - - Specifies the production of each package-level custom document (the same specification is used for all packages). - - - - - Specifies the production of a shipment-level custom document. - - - - - This element is currently not supported and is for the future use. (Details pertaining to the GAA.) - - - - - - Specifies the production of the OP-900 document for hazardous materials packages. - - - - - Specifies the production of the 1421c document for dangerous goods shipment. - - - - - Specifies the production of the OP-900 document for hazardous materials. - - - - - Specifies the production of the return instructions document. - - - - - - - Specifies the type of paper (stock) on which a document will be printed. - - - - - - - - - - - - - - - - - - - The descriptive data required for FedEx delivery signature services. - - - - - Identifies the delivery signature services option selected by the customer for this shipment. See OptionType for the list of valid values. - - - - - Identifies the delivery signature release authorization number. - - 10 - - - - - - - - Identifies the delivery signature services options offered by FedEx. - - - - - - - - - - - - These values are mutually exclusive; at most one of them can be attached to a SmartPost shipment. - - - - - - - - - - - - - - - - - - - - - Data required for shipments handled under the SMART_POST and GROUND_SMART_POST service types. - - - - - - - - - The CustomerManifestId is used to group Smart Post packages onto a manifest for each trailer that is being prepared. If you do not have multiple trailers this field can be omitted. If you have multiple trailers, you - must assign the same Manifest Id to each SmartPost package as determined by its trailer. In other words, all packages on a trailer must have the same Customer Manifest Id. The manifest Id must be unique to your account number for a minimum of 6 months - and cannot exceed 8 characters in length. We recommend you use the day of year + the trailer id (this could simply be a sequential number for that trailer). So if you had 3 trailers that you started loading on Feb 10 - the 3 manifest ids would be 041001, 041002, 041003 (in this case we used leading zeros on the trailer numbers). - - - - - - - - Special circumstance rating used for this shipment. - - - - - - - - - Each instance of this data type represents a barcode whose content must be represented as ASCII text (i.e. not binary data). - - - - - The kind of barcode data in this instance. - - - - - The data content of this instance. - - - - - - - - - - - - - - - - - Identifies each surcharge applied to the shipment. - - - - - The type of surcharge applied to the shipment. - - - - - - - The amount of the surcharge applied to the shipment. - - - - - - - - - - - - - The type of the surcharge. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Identifies each tax applied to the shipment. - - - - - The type of tax applied to the shipment. - - - - - - The amount of the tax applied to the shipment. - - - - - - - The type of the tax. - - - - - - - - - - - - - - Specifice the kind of tax or miscellaneous charge being reported on a Commercial Invoice. - - - - - - - - - - - - - The descriptive data for taxpayer identification information. - - - - - Identifies the category of the taxpayer identification number. See TinType for the list of values. - - - - - Identifies the taxpayer identification number. - - 15 - - - - - - Identifies the usage of Tax Identification Number in Shipment processing - - - - - - - - Required for dutiable international express or ground shipment. This field is not applicable to an international PIB (document) or a non-document which does not require a commercial invoice express shipment. - CFR_OR_CPT (Cost and Freight/Carriage Paid TO) - CIF_OR_CIP (Cost Insurance and Freight/Carraige Insurance Paid) - DDP (Delivered Duty Paid) - DDU (Delivered Duty Unpaid) - EXW (Ex Works) - FOB_OR_FCA (Free On Board/Free Carrier) - - - - - - - - - - - - - - - - Identifies the category of the taxpayer identification number. - - - - - - - - - - - - - - - - For use with SmartPost tracking IDs only - - - - - - - - TrackingIdType - - - - - - - - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Free form text to be echoed back in the reply. Used to match requests and replies. - - - - - Governs data payload language/translations (contrasted with ClientDetail.localization, which governs Notification.localizedMessage language selection). - - - - - - - Identifies the set of valid shipment transit time values. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Descriptive data sent to FedEx by a customer in order to validate a shipment. - - - - - Descriptive data to be used in authentication of the sender's identity (and right to use FedEx web services). - - - - - Descriptive data identifying the client submitting the transaction. - - - - - Descriptive data for this customer transaction. The TransactionDetail from the request is echoed back to the caller in the corresponding reply. - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Descriptive data about the shipment being sent by the requestor. - - - - - - - Documents the kind and quantity of an individual hazardous commodity in a package. - - - - - Identifies and describes an individual hazardous commodity. - - - - - Specifies the amount of the commodity in alternate units. - - - - - Customer-provided specifications for handling individual commodities. - - - - - - - Identifies and describes an individual hazardous commodity. For 201001 load, this is based on data from the FedEx Ground Hazardous Materials Shipping Guide. - - - - - Regulatory identifier for a commodity (e.g. "UN ID" value). - - - - - In conjunction with the regulatory identifier, this field uniquely identifies a specific hazardous materials commodity. - - - - - - - - Fully-expanded descriptive text for a hazardous commodity. - - - - - - - - Coded indications for special requirements or constraints. - - - - - - - - - - Specifies the concept of a container used to package dangerous goods commodities. - - - - - Indicates that the quantity of the dangerous goods packaged is permissible for shipping. This is used to ensure that the dangerous goods commodities do not exceed the net quantity per package restrictions. - - - - - Documents the kinds and quantities of all hazardous commodities in the current package. - - - - - - - This definition of variable handling charge detail is intended for use in Jan 2011 corp load. - - - - - - Used with Variable handling charge type of FIXED_VALUE. - Contains the amount to be added to the freight charge. - Contains 2 explicit decimal positions with a total max length of 10 including the decimal. - - - - - - Actual percentage (10 means 10%, which is a mutiplier of 0.1) - - - - - Select the value from a set of rate data to which the percentage is applied. - - - - - Select the type of rate from which the element is to be selected. - - - - - - - The variable handling charges calculated based on the type variable handling charges requested. - - - - - The variable handling charge amount calculated based on the requested variable handling charge detail. - - - - - - - The calculated varibale handling charge plus the net charge. - - - - - - - Three-dimensional volume/cubic measurement. - - - - - - - - - Units of three-dimensional volume/cubic measure. - - - - - - - - - The descriptive data for the heaviness of an object. - - - - - Identifies the unit of measure associated with a weight value. - - - - - Identifies the weight value of a package/shipment. - - - - - - - Identifies the unit of measure associated with a weight value. See the list of enumerated types for valid values. - - - - - - - - - Used in authentication of the sender's identity. - - - - - Credential used to authenticate a specific software application. This value is provided by FedEx after registration. - - - - - - - Two part authentication string used for the sender's identity - - - - - Identifying part of authentication credential. This value is provided by FedEx after registration - - - - - Secret part of authentication key. This value is provided by FedEx after registration. - - - - - - - Identifies the version/level of a service operation expected by a caller (in each request) and performed by the callee (in each reply). - - - - - Identifies a system or sub-system which performs an operation. - - - - - Identifies the service business level. - - - - - Identifies the service interface level. - - - - - Identifies the service code level. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/www/lib/versandarten/dhl.php_ b/www/lib/versandarten/dhl.php_ deleted file mode 100644 index 69bdb360..00000000 --- a/www/lib/versandarten/dhl.php_ +++ /dev/null @@ -1,691 +0,0 @@ -id = $id; - $this->app = $app; - $einstellungenArr = $this->app->DB->SelectRow("SELECT einstellungen_json,paketmarke_drucker,export_drucker FROM versandarten WHERE id = '$id' LIMIT 1"); - $einstellungen_json = $einstellungenArr['einstellungen_json']; - $this->paketmarke_drucker = $einstellungenArr['paketmarke_drucker']; - $this->export_drucker = $einstellungenArr['export_drucker']; - - $this->name = 'DHL 3.0'; - if($einstellungen_json){ - $this->einstellungen = json_decode($einstellungen_json, true); - }else{ - $this->einstellungen = []; - } - $this->errors = []; - } - - function ShowUserdata() - { - if(isset($this->app->Conf->WFuserdata)){ - return 'Userdata-Ordner: ' . $this->app->Conf->WFuserdata; - } - } - - public function Einstellungen($target = 'return') - { - if($this->app->Secure->GetPOST('testen')){ - $parameter1 = $this->einstellungen['pfad']; - if($parameter1){ - if(is_dir($parameter1)){ - if(substr($parameter1, -1) !== '/'){ - $parameter1 .= '/'; - } - - if(file_put_contents($parameter1 . 'wawision_test.txt', 'TEST')){ - $this->app->Tpl->Add('MESSAGE', - '
          Datei ' . $parameter1 . 'wawision_test.txt' . ' wurde erstellt!
          '); - }else{ - $this->app->Tpl->Add('MESSAGE', '
          Datei konnte nicht angelegt werden!
          '); - } - }else{ - $this->app->Tpl->Add('MESSAGE', - '
          Speicherort existiert nicht oder ist nicht erreichbar!
          '); - } - }else{ - $this->app->Tpl->Add('MESSAGE', '
          Bitte einen Speicherort angeben!
          '); - } - } - - parent::Einstellungen($target); - } - - //TODO .... - - /*function Trackinglink($tracking, &$notsend, &$link, &$rawlink) - { - $notsend = 0; - //$rawlink = 'https://tracking.dpd.de/parcelstatus/?locale=de_DE&query='.$tracking; - $rawlink = ' https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DE03/DE/5004.htm?txtRefNo='.$tracking.'&txtAction=71000'; - $link = 'GLS Versand: '.$tracking.' ('.$rawlink.')'; - }*/ - - public function GetBezeichnung() - { - return 'DHL 3.0'; - } - - /** - * @return array[] - */ - public function getCreateForm() - { - return [ - [ - 'id' => 0, - 'name' => 'usernameGroup', - 'inputs' => [ - [ - 'label' => 'Benutzername', - 'type' => 'text', - 'name' => 'dhl_username', - 'validation' => true, - ], - ], - ], - [ - 'id' => 1, - 'name' => 'passwordGroup', - 'inputs' => [ - [ - 'label' => 'Passwort', - 'type' => 'text', - 'name' => 'dhl_password', - 'validation' => true, - ] - ], - ], - [ - 'id' => 2, - 'name' => 'accountNumberGroup', - 'inputs' => [ - [ - 'label' => 'Abrechnungsnummer', - 'type' => 'text', - 'name' => 'dhl_accountnumber', - 'validation' => true, - ] - ], - ] - ]; - } - - /** - * @param array $postData - * - * @return array - */ - public function updatePostDataForAssistent($postData): array - { - $name = $this->app->erp->Firmendaten('name'); - $street = $this->app->erp->Firmendaten('strasse'); - $zip = $this->app->erp->Firmendaten('plz'); - $city = $this->app->erp->Firmendaten('ort'); - $country = $this->app->erp->Firmendaten('land'); - $houseNo = ''; - - $streetParts = explode(' ', $street); - $partsCount = count($streetParts); - - if($partsCount >= 2){ - $street = implode(' ', array_slice($streetParts, 0, $partsCount - 1)); - $houseNo = $streetParts[$partsCount - 1]; - } - - $postData['dhl_origin_name'] = $name; - $postData['dhl_origin_street'] = $street; - $postData['dhl_origin_houseno'] = $houseNo; - $postData['dhl_origin_zip'] = $zip; - $postData['dhl_origin_city'] = $city; - $postData['dhl_origin_country'] = $country; - - return $postData; - } - - /** - * @return JsonResponse|null - */ - public function AuthByAssistent() - { - $step = (int)$this->app->Secure->GetPOST('step'); - if($step == 0){ - $username = $this->app->Secure->GetPOST('dhl_username'); - $password = $this->app->Secure->GetPOST('dhl_password'); - $accountnumber = $this->app->Secure->GetPOST('dhl_accountnumber'); - - $error = null; - if(empty($username)){ - $error = 'Bitte Nutzernamen eingeben'; - }else if(empty($password)){ - $error = 'Bitte Passwort eingeben'; - }else if(empty($accountnumber)){ - $error = 'Bitte Abrechnungsnummer eingeben'; - } - - if($error != null) { - return new JsonResponse( - ['error' => $error], - JsonResponse::HTTP_BAD_REQUEST - ); - } - - try{ - $this->testCredentials($username, $password, $accountnumber); - }catch (DhlBaseException $e){ - return new JsonResponse( - ['error' => $e->getMessage()], - JsonResponse::HTTP_BAD_REQUEST - ); - } - } - - return null; - } - - - /** - * @return array - */ - public function getStructureDataForClickByClickSave(): array - { - return $this->updatePostDataForAssistent([]); - } - - function EinstellungenStruktur() - { - if(!empty($this->einstellungen['dhl_username']) && !empty($this->einstellungen['dhl_password'])){ - try{ - $this->testCredentials($this->einstellungen['dhl_username'], $this->einstellungen['dhl_password'], $this->einstellungen['dhl_accountnumber']); - $this->app->Tpl->Set('MESSAGE', '
          Zugangsdaten erfolgreich überprüft
          '); - }catch (DhlBaseException $e){ - $this->app->Tpl->Set('MESSAGE', '
          ' . $e->getMessage() . '
          '); - } - } - - - - return [ - 'dhl_username' => ['typ' => 'text', 'bezeichnung' => 'Benutzername:'], - 'dhl_password' => ['typ' => 'text', 'bezeichnung' => 'Passwort:'], - 'dhl_accountnumber' => ['typ' => 'text', 'bezeichnung' => 'Abrechnungsnummer:'], - 'dhl_origin_name' => ['typ' => 'text', 'bezeichnung' => 'Versender Name:'], - 'dhl_origin_street' => ['typ' => 'text', 'bezeichnung' => 'Versender Strasse:'], - 'dhl_origin_houseno' => ['typ' => 'text', 'bezeichnung' => 'Versender Hausnummer:'], - 'dhl_origin_city' => ['typ' => 'text', 'bezeichnung' => 'Versender Ort:'], - 'dhl_origin_zip' => ['typ' => 'text', 'bezeichnung' => 'Versender PLZ:'], - 'dhl_origin_country' => ['typ' => 'text', 'bezeichnung' => 'Versender Land (2-stellig):'], - 'dhl_origin_email' => ['typ' => 'text', 'bezeichnung' => 'Versender Email:'], - - 'dhl_height' => ['typ' => 'text', 'bezeichnung' => 'Standardhöhe'], - 'dhl_width' => ['typ' => 'text', 'bezeichnung' => 'Standardbreite'], - 'dhl_length' => ['typ' => 'text', 'bezeichnung' => 'Standardlänge'], - - 'dhl_export_product_type' => [ - 'typ' => 'select', - 'bezeichnung' => 'Export Producttyp', - 'optionen' => [ - 'PRESENT' => 'Geschenke', - 'COMMERCIAL_SAMPLE' => 'Kommerzielle Probe', - 'DOCUMENT' => 'Dokumente', - 'RETURN_OF_GOODS' => 'Rücksendungen', - 'OTHER' => 'Andere', - ] - ], - 'dhl_export_product_type_description' => [ - 'typ' => 'text', - 'bezeichnung' => 'Beschreibung im Falle von "Andere"' - ], - - 'dhl_product' => [ - 'typ' => 'select', - 'bezeichnung' => 'Produkt:', - 'optionen' => [ - 'V01PAK' => 'Paket national', - 'V53WPAK' => 'Paket international' - ], - ], - 'dhl_coding' => ['typ' => 'checkbox', 'bezeichnung' => 'Leitcodierung aktivieren'], - 'autotracking' => ['typ' => 'checkbox', 'bezeichnung' => 'Tracking übernehmen:'], - ]; - } - - public function testCredentials($username, $password, $accountNumber){ - /** @var DhlApiFactory $dhlApiFactory */ - $dhlApiFactory = $this->app->Container->get('DhlApiFactory'); - - /** @var DhlApi $dhlApi */ - $dhlApi = $dhlApiFactory->createProductionInstance( - $username, - $password, - $accountNumber, - '', - '', - '', - '', - '', - '', - '' - ); - - try { - $dhlApi->validateShipment(new CreateNationalShipmentRequest( - date("Y-m-d"), - 1.0, - 10, - 20, - 30, - "Max muster", - '', - '', - 'Teststr. 1', - '11', - '86153', - 'Augsburg', - 'DE', - 'max.muster@xentral.com', - false - )); - }catch (InvalidRequestDataException $e){ - // do nothing, test data is invalid - } - } - - public function PaketmarkeDrucken($id, $sid) - { - $adressdaten = $this->GetAdressdaten($id, $sid); - $ret = $this->Paketmarke($sid, $id, '', false, $adressdaten); - if($sid === 'lieferschein'){ - $deliveryNoteArr = $this->app->DB->SelectRow("SELECT adresse,projekt,versandart,auftragid FROM lieferschein WHERE id = '$id' LIMIT 1"); - $adresse = $deliveryNoteArr['adresse']; - $projekt = $deliveryNoteArr['projekt']; - $versandart = $deliveryNoteArr['versandart']; - $adressvalidation = 2; - if($ret){ - $adressvalidation = 1; - } - $tracking = ''; - if(isset($adressdaten['tracking'])){ - $tracking = $adressdaten['tracking']; - } - if(!isset($adressdaten['versandid'])){ - $adressdaten['versandid'] = $this->app->DB->Select("SELECT id FROM versand WHERE abgeschlossen = 0 AND tracking = '' AND lieferschein = '$id' LIMIT 1"); - } - if(!isset($adressdaten['versandid'])){ - $this->app->DB->Insert("INSERT INTO versand (versandunternehmen, tracking, - versendet_am,abgeschlossen,lieferschein,freigegeben,firma,adresse,projekt,paketmarkegedruckt,adressvalidation) - VALUES ($versandart','$tracking',NOW(),1,'$id',1,'1','$adresse','$projekt',1,'$adressvalidation') "); - $adressdaten['versandid'] = $this->app->DB->GetInsertID(); - }elseif($tracking){ - $this->app->DB->Update("UPDATE versand SET freigegeben = 1, abgeschlossen = 1, tracking =1, paketmarkegedruckt = 1, tracking= '$tracking',adressvalidation = '$adressvalidation', versendet_am = now() WHERE id = '" . $adressdaten['versandid'] . "' LIMIT 1"); - $this->app->DB->Update("UPDATE versand SET versandunternehmen = versandart WHERE id = '" . $adressdaten['versandid'] . "' AND versandunternehmen = '' LIMIT 1"); - $this->app->DB->Update("UPDATE versand SET versandunternehmen = '$versandart' WHERE id = '" . $adressdaten['versandid'] . "' AND versandunternehmen = '' LIMIT 1"); - } - $auftragid = $deliveryNoteArr['auftragid']; - if($auftragid){ - $this->app->DB->Update("UPDATE auftrag SET schreibschutz = 1, status = 'abgeschlossen' WHERE id = '$auftragid' AND status = 'freigegeben' LIMIT 1"); - } - if($adressvalidation == 1){ - $this->app->erp->LieferscheinProtokoll($id, 'Paketmarke automatisch gedruckt'); - if($adressdaten['versandid']){ - return $adressdaten['versandid']; - } - }elseif($adressvalidation == 2){ - $this->app->erp->LieferscheinProtokoll($id, 'automatisches Paketmarke Drucken fehlgeschlagen'); - } - } - - return $ret; - } - - public function Paketmarke($doctyp, $docid, $target = '', $error = false, &$adressdaten = null) - { - $id = $docid; - $sid = $doctyp; - if($adressdaten === null){ - $drucken = $this->app->Secure->GetPOST('drucken'); - $anders = $this->app->Secure->GetPOST('anders'); - $tracking_again = $this->app->Secure->GetGET('tracking_again'); - $module = $this->app->Secure->GetPOST('module'); - if(empty($module)){ - $module = $doctyp; - } - }else{ - $drucken = 1; - $anders = ''; - $tracking_again = ''; - $module = $doctyp; - } - - - /** @var DhlApiFactory $dhlApiFactory */ - $dhlApiFactory = $this->app->Container->get('DhlApiFactory'); - - /** @var DhlApi $dhlApi */ - $dhlApi = $dhlApiFactory->createProductionInstance( - $this->einstellungen['dhl_username'], - $this->einstellungen['dhl_password'], - $this->einstellungen['dhl_accountnumber'], - $this->einstellungen['dhl_origin_name'], - $this->einstellungen['dhl_origin_street'], - $this->einstellungen['dhl_origin_houseno'], - $this->einstellungen['dhl_origin_zip'], - $this->einstellungen['dhl_origin_city'], - $this->einstellungen['dhl_origin_country'], - $this->einstellungen['dhl_origin_email'] - ); - - if($drucken != '' || $tracking_again == '1'){ - - if($tracking_again != "1"){ - $versandId = 0; - if($module === 'retoure'){ - $Query = $this->app->DB->SelectRow("SELECT * FROM retoure where id='$id'"); - }elseif($module === 'versand'){ - $versandId = $id; - $lieferschein = $this->app->DB->Select("SELECT lieferschein WHERE id = '$id' LIMIT 1"); - $Query = $this->app->DB->SelectRow("SELECT * FROM lieferschein where id='$lieferschein'"); - }else{ - $Query = $this->app->DB->SelectRow("SELECT * FROM lieferschein where id='$id'"); - } - $projekt = $Query['projekt']; - $Adresse = $this->app->DB->SelectRow("SELECT * FROM adresse WHERE id='" . $Query['adresse'] . "'"); - $product = ''; - $Country = $Query['land']; - if($adressdaten === null){ - $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"); - - //$Weight = $this->app->Secure->GetPOST("kg1"); - $Name = $this->app->Secure->GetPOST("name"); - $Name2 = $this->app->Secure->GetPOST("name2"); - $Name3 = $this->app->Secure->GetPOST("name3"); - $Street = $this->app->Secure->GetPOST("strasse"); - $HouseNo = $this->app->Secure->GetPOST("hausnummer"); - $ZipCode = $this->app->Secure->GetPOST("plz"); - $City = $this->app->Secure->GetPOST("ort"); - $Mail = $this->app->Secure->GetPOST("email"); - $Phone = $this->app->Secure->GetPOST("phone"); - $Country = $this->app->Secure->GetPOST("land"); - $Weight = $this->app->Secure->GetPOST('kg1'); - - $height = $this->app->Secure->GetPOST('height'); - $wigth = $this->app->Secure->GetPOST('width'); - $length = $this->app->Secure->GetPOST('length'); - - $coding = $this->app->Secure->GetPOST('coding') == '1'; - }else{ - $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"); - - $Name = $adressdaten["name"]; - $Name2 = $adressdaten["name2"]; - $Name3 = $adressdaten["name3"]; - $Street = $adressdaten["strasse"]; - $HouseNo = $adressdaten["hausnummer"]; - $ZipCode = $adressdaten['plz']; - $City = $adressdaten['ort']; - $Mail = $adressdaten['email']; - $Phone = $adressdaten["telefon"]; - $Country = $adressdaten["land"]; - $Company = "Company"; - $Weight = $adressdaten["standardkg"]; - $coding = $this->einstellungen['dhl_coding'] == 1; - - $height = $this->einstellungen('dhl_height'); - $wigth = $this->einstellungen('dhl_width'); - $length = $this->einstellungen('dhl_length'); - - } - - try { - $shipmentDate = date("Y-m-d"); - - switch ($this->einstellungen['dhl_product']) { - case 'V01PAK': - { - $shipmentData = new CreateNationalShipmentRequest( - $shipmentDate, - $Weight, - $length, - $wigth, - $height, - $Name, - $Name2, - $Name3, - $Street, - $HouseNo, - $ZipCode, - $City, - $Country, - $Mail, - $coding - ); - break; - } - case 'V53WPAK': - { - $shipmentData = new CreateInterationalShipmentRequest( - $shipmentDate, - $Weight, - $length, - $wigth, - $height, - $Name, - $Name2, - $Name3, - $Street, - $HouseNo, - $ZipCode, - $City, - $Country, - $Mail, - $coding, - $this->einstellungen['dhl_export_product_type'], - $this->einstellungen['dhl_export_product_type_description'], - $this->getPackageContents($Query['id']) - ); - break; - } - default: - { - throw new UnknownProductException(); - } - } - - $createResponse = $dhlApi->createShipment($shipmentData); - - if($this->einstellungen['autotracking'] == "1") - $this->SetTracking($createResponse->getShipmentNumber(), $sid === 'versand' ? $id : 0, $lieferschein); - - - $data['drucker'] = $this->paketmarke_drucker; - $data['druckerlogistikstufe2'] = $this->export_drucker; - - if(!$data['drucker']){ - if($this->app->erp->GetStandardPaketmarkendrucker() > 0){ - $data['drucker'] = $this->app->erp->GetStandardPaketmarkendrucker(); - } - } - - if(!$data['druckerlogistikstufe2']){ - if($this->app->erp->GetStandardVersanddrucker($projekt) > 0){ - $data['druckerlogistikstufe2'] = $this->app->erp->GetStandardVersanddrucker($projekt); - } - } - $pdf = $createResponse->getLabelAsPdf(); - $datei = $this->app->erp->GetTMP() . 'DhlLabel_' . $createResponse->getShipmentNumber() . '.pdf'; - - file_put_contents($datei, $pdf); - - $spoolerId = $this->app->printer->Drucken($data['drucker'], $datei); - if($spoolerId > 0 && $versandId > 0){ - $this->app->DB->Update( - sprintf( - 'UPDATE versand SET lastspooler_id = %d, lastprinter = %d WHERE id = %d', - $spoolerId, $data['drucker'], $versandId - ) - ); - } - if($module === 'retoure'){ - if(@is_file($datei) && @filesize($datei)){ - $fileid = $this->app->erp->CreateDatei('DhlMarkeLabel_' . $this->app->DB->Select("SELECT belegnr FROM retoure WHERE id = '$id' LIMIT 1") . '.pdf', - 'Anhang', '', "", $datei, - $this->app->DB->real_escape_string($this->app->User->GetName())); - $this->app->erp->AddDateiStichwort($fileid, 'anhang', 'retoure', $id); - } - } - - unlink($datei); - if($adressdaten !== null){ - return true; - } - - if($createResponse->containsExportDocuments()){ - $tmppdf = $this->app->erp->GetTMP() . 'DhlExport_' . $createResponse->getShipmentNumber() . '.pdf'; - file_put_contents($tmppdf, $createResponse->getExportPaperAsPdf()); - $spoolerId = $this->app->printer->Drucken($data['druckerlogistikstufe2'], $tmppdf); - if($versandId && $spoolerId){ - $this->app->DB->Update( - sprintf( - 'UPDATE versand SET lastexportspooler_id = %d, lastexportprinter = %d WHERE id = %d', - $spoolerId, $data['druckerlogistikstufe2'], $versandId - ) - ); - } - if($module === 'retoure'){ - if(@is_file($tmppdf) && @filesize($tmppdf)){ - $fileid = $this->app->erp->CreateDatei('Export_' . $this->app->DB->Select("SELECT belegnr FROM retoure WHERE id = '$id' LIMIT 1") . '.pdf', 'Anhang', '', "", $tmppdf, $this->app->DB->real_escape_string($this->app->User->GetName())); - $this->app->erp->AddDateiStichwort($fileid, 'anhang', 'retoure', $id); - } - } - - unlink($tmppdf); - } - - - } catch (DhlBaseException $e) { - $this->errors[] = $e->getMessage(); - } - } - } - if($adressdaten !== null){ - return false; - } - if($target){ - if($this->einstellungen['dhl_coding'] == '1'){ - $this->app->Tpl->Set('DHL_CODING_CHECKED', 'checked="checked"'); - } - - $this->app->Tpl->Add("HEIGHT", $this->einstellungen['dhl_height']); - $this->app->Tpl->Add("WIDTH", $this->einstellungen['dhl_width']); - $this->app->Tpl->Add("LENGTH", $this->einstellungen['dhl_length']); - $this->app->Tpl->Parse($target, 'versandarten_dhl.tpl'); - } - if(count($this->errors) > 0){ - return $this->errors; - } - } - - private function getPackageContents($deliveryNoteId) - { - $contents = []; - /** @var Database $db */ - $db = $this->app->Container->get('Database'); - - $select = $db->select() - ->from('lieferschein_position AS l') - ->cols([ - 'l.bezeichnung', - 'l.menge', - 'l.zolltarifnummer', - 'l.herkunftsland', - 'a.umsatz_netto_einzeln', - 'g.gewicht' - ]) - ->leftJoin('auftrag_position AS a', 'l.auftrag_position_id = a.id') - ->leftJoin('artikel AS g', 'l.artikel = g.id') - ->where('l.lieferschein=:id') - ->bindValue('id', $deliveryNoteId); - - $positions = $db->fetchAll($select->getStatement(), $select->getBindValues()); - - foreach ($positions as $position) { - $contents[] = new PackageContent( - (int)$position['menge'], - $position['bezeichnung'], - $position['umsatz_netto_einzeln'], - $position['herkunftsland'], - $position['zolltarifnummer'], - $position['gewicht'] - ); - } - - return $contents; - } - - public function Export($daten) - { - - } - - - 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); - } - } - } - -} diff --git a/www/lib/versandarten/internetmarke.php_ b/www/lib/versandarten/internetmarke.php_ deleted file mode 100644 index 7d2be84c..00000000 --- a/www/lib/versandarten/internetmarke.php_ +++ /dev/null @@ -1,1096 +0,0 @@ -id = $id; - $this->app = $app; - - $this->ppl = 'ppl_480.csv'; - - $this->app->erp->LogFile("Internetmarke start", "Product version: {$this->ppl}"); - $einstellungenArr = $this->app->DB->SelectRow("SELECT einstellungen_json,paketmarke_drucker,export_drucker FROM versandarten WHERE id = '$id' LIMIT 1"); - $einstellungen_json = $einstellungenArr['einstellungen_json']; - $this->paketmarke_drucker = $einstellungenArr['paketmarke_drucker']; - $this->export_drucker = $einstellungenArr['export_drucker']; - - $this->name = 'Internetmarke'; - if ($einstellungen_json) { - $this->einstellungen = json_decode($einstellungen_json, true); - } else { - $this->einstellungen = []; - } - - $this->einstellungen['api_accountnumber'] = $this->einstellungen['accountnumber']; - $this->credentials = $this->einstellungen; - $this->errors = []; - $data = $this->einstellungen; - $this->info = $this->einstellungen; - - } - - function ShowUserdata() - { - if (isset($this->app->Conf->WFuserdata)) { - return 'Userdata-Ordner: ' . $this->app->Conf->WFuserdata; - } - } - - public function Einstellungen($target = 'return') - { - if ($this->app->Secure->GetPOST('testen')) { - $parameter1 = $this->einstellungen['pfad']; - if ($parameter1) { - if (is_dir($parameter1)) { - if (substr($parameter1, -1) !== '/') { - $parameter1 .= '/'; - } - - if (file_put_contents($parameter1 . 'wawision_test.txt', 'TEST')) { - $this->app->Tpl->Add('MESSAGE', - '
          Datei ' . $parameter1 . 'wawision_test.txt' . ' wurde erstellt!
          '); - } else { - $this->app->Tpl->Add('MESSAGE', '
          Datei konnte nicht angelegt werden!
          '); - } - } else { - $this->app->Tpl->Add('MESSAGE', - '
          Speicherort existiert nicht oder ist nicht erreichbar!
          '); - } - } else { - $this->app->Tpl->Add('MESSAGE', '
          Bitte einen Speicherort angeben!
          '); - } - } - - parent::Einstellungen($target); - } - - //TODO .... - - /*function Trackinglink($tracking, &$notsend, &$link, &$rawlink) - { - $notsend = 0; - //$rawlink = 'https://tracking.dpd.de/parcelstatus/?locale=de_DE&query='.$tracking; - $rawlink = ' https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DE03/DE/5004.htm?txtRefNo='.$tracking.'&txtAction=71000'; - $link = 'GLS Versand: '.$tracking.' ('.$rawlink.')'; - }*/ - - public function GetBezeichnung() - { - return 'Internetmarke'; - } - - function EinstellungenStruktur() - { - // include __DIR__ . '/../../../cronjobs/internetmarke.php'; - // $this->app->DB->Update('UPDATE prozessstarter AS p SET p.letzteausfuerhung="1970-01-01 00:00:00" WHERE p.parameter="internetmarke";'); - return [ - 'dhl_marke_email' => ['typ' => 'text', 'bezeichnung' => 'Portokasse:'], - 'dhl_marke_password' => ['typ' => 'text', 'bezeichnung' => 'Passwort:'], - 'origin_company' => ['typ' => 'text', 'bezeichnung' => 'Versender Firma:'], - // 'origin_surname' => array('typ'=>'text','bezeichnung'=>'Versender Vorname:'), - // 'origin_lastname' => array('typ'=>'text','bezeichnung'=>'Versender Nachname:'), - 'origin_street' => ['typ' => 'text', 'bezeichnung' => 'Versender Strasse:'], - 'origin_houseno' => ['typ' => 'text', 'bezeichnung' => 'Versender Hausnummer:'], - 'origin_city' => ['typ' => 'text', 'bezeichnung' => 'Versender Ort:'], - 'origin_zip' => ['typ' => 'text', 'bezeichnung' => 'Versender PLZ:'], - 'origin_country' => ['typ' => 'text', 'bezeichnung' => 'Versender Land (2-stellig):'], - 'product' => [ - 'typ' => 'select', - 'bezeichnung' => 'Produkt:', - 'optionen' => $this->getProductList(), - ], - 'format' => [ - 'typ' => 'select', - 'bezeichnung' => 'Format:', - 'optionen' => $this->pageFormatList(), - ], - 'autotracking' => ['typ' => 'checkbox', 'bezeichnung' => 'Tracking übernehmen:'], - ]; - - } - - public function PaketmarkeDrucken($id, $sid) - { - $adressdaten = $this->GetAdressdaten($id, $sid); - $ret = $this->Paketmarke($sid, $id, '', false, $adressdaten); - if ($sid === 'lieferschein') { - $deliveryNoteArr = $this->app->DB->SelectRow("SELECT adresse,projekt,versandert,auftragid FROM lieferschein WHERE id = '$id' LIMIT 1"); - $adresse = $deliveryNoteArr['adresse']; - $projekt = $deliveryNoteArr['projekt']; - $versandart = $deliveryNoteArr['versandart']; - $adressvalidation = 2; - if ($ret) { - $adressvalidation = 1; - } - $tracking = ''; - if (isset($adressdaten['tracking'])) { - $tracking = $adressdaten['tracking']; - } - if (!isset($adressdaten['versandid'])) { - $adressdaten['versandid'] = $this->app->DB->Select("SELECT id FROM versand WHERE abgeschlossen = 0 AND tracking = '' AND lieferschein = '$id' LIMIT 1"); - } - if (!isset($adressdaten['versandid'])) { - $this->app->DB->Insert("INSERT INTO versand (versandunternehmen, tracking, - versendet_am,abgeschlossen,lieferschein,freigegeben,firma,adresse,projekt,paketmarkegedruckt,adressvalidation) - VALUES ($versandart','$tracking',NOW(),1,'$id',1,'1','$adresse','$projekt',1,'$adressvalidation') "); - $adressdaten['versandid'] = $this->app->DB->GetInsertID(); - } elseif ($tracking) { - $this->app->DB->Update("UPDATE versand SET freigegeben = 1, abgeschlossen = 1, tracking =1, paketmarkegedruckt = 1, tracking= '$tracking',adressvalidation = '$adressvalidation', versendet_am = now() WHERE id = '" . $adressdaten['versandid'] . "' LIMIT 1"); - $this->app->DB->Update("UPDATE versand SET versandunternehmen = versandart WHERE id = '" . $adressdaten['versandid'] . "' AND versandunternehmen = '' LIMIT 1"); - $this->app->DB->Update("UPDATE versand SET versandunternehmen = '$versandart' WHERE id = '" . $adressdaten['versandid'] . "' AND versandunternehmen = '' LIMIT 1"); - } - $auftragid = $deliveryNoteArr['auftragid']; - if ($auftragid) { - $this->app->DB->Update("UPDATE auftrag SET schreibschutz = 1, status = 'abgeschlossen' WHERE id = '$auftragid' AND status = 'freigegeben' LIMIT 1"); - } - if ($adressvalidation == 1) { - $this->app->erp->LieferscheinProtokoll($id, 'Paketmarke automatisch gedruckt'); - if ($adressdaten['versandid']) { - return $adressdaten['versandid']; - } - } elseif ($adressvalidation == 2) { - $this->app->erp->LieferscheinProtokoll($id, 'automatisches Paketmarke Drucken fehlgeschlagen'); - } - } - - return $ret; - } - - public function Paketmarke($doctyp, $docid, $target = '', $error = false, &$adressdaten = null) - { - $id = $docid; - $sid = $doctyp; - if ($adressdaten === null) { - $drucken = $this->app->Secure->GetPOST('drucken'); - $anders = $this->app->Secure->GetPOST('anders'); - $tracking_again = $this->app->Secure->GetGET('tracking_again'); - $module = $this->app->Secure->GetPOST('module'); - if(empty($module)) { - $module = $doctyp; - } - } else { - $drucken = 1; - $anders = ''; - $tracking_again = ''; - $module = $doctyp; - } - - if ($drucken != '' || $tracking_again == '1') { - - if ($tracking_again != "1") { - $versandId = 0; - if ($module === 'retoure') { - $Query = $this->app->DB->SelectRow("SELECT * FROM retoure where id='$id'"); - } - elseif ($module === 'versand') { - $versandId = $id; - $lieferschein = $this->app->DB->Select("SELECT lieferschein WHERE id = '$id' LIMIT 1"); - $Query = $this->app->DB->SelectRow("SELECT * FROM lieferschein where id='$lieferschein'"); - } - else { - $Query = $this->app->DB->SelectRow("SELECT * FROM lieferschein where id='$id'"); - } - $projekt = $Query['projekt']; - $Adresse = $this->app->DB->SelectRow("SELECT * FROM adresse WHERE id='" . $Query['adresse'] . "'"); - $product = ''; - $Country = $Query['land']; - if ($adressdaten === null) { - $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"); - - //$Weight = $this->app->Secure->GetPOST("kg1"); - $Name = $this->app->Secure->GetPOST("name"); - $Name2 = $this->app->Secure->GetPOST("name2"); - $Name3 = $this->app->Secure->GetPOST("name3"); - $Street = $this->app->Secure->GetPOST("strasse"); - $HouseNo = $this->app->Secure->GetPOST("hausnummer"); - $ZipCode = $this->app->Secure->GetPOST("plz"); - $City = $this->app->Secure->GetPOST("ort"); - $Mail = $this->app->Secure->GetPOST("email"); - $Phone = $this->app->Secure->GetPOST("phone"); - $Country = $this->app->Secure->GetPOST("land"); - $Company = "Company"; - - - $product = $this->app->Secure->GetPOST("product"); - } else { - $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"); - - $Name = $adressdaten["name"]; - $Name2 = $adressdaten["name2"]; - $Name3 = $adressdaten["name3"]; - $Street = $adressdaten["strasse"]; - $HouseNo = $adressdaten["hausnummer"]; - $ZipCode = $adressdaten['plz']; - $City = $adressdaten['ort']; - $Mail = $adressdaten['email']; - $Phone = $adressdaten["telefon"]; - $Country = $adressdaten["land"]; - $Company = "Company"; - $Weight = $adressdaten["standardkg"]; - } - - if (!$product) { - $product = $this->einstellungen['product']; - } - - $ei = $this->einstellungen; - - if (!isset($this->einstellungen['format']) || $this->einstellungen['format'] == -1) { - $this->errors[] = 'Bitte Format einstellen'; - $link = 'fail'; - } else { - //$this->TIMESTAMP = "17072017-155000"; - $token = $this->getToken(); - if ($token !== 'fail') { - if($Name2 !== ''){ - $Name3 = $Name2; - } - $link = $this->checkoutPDF($token, $Name, $Name3, $Street, $HouseNo, $ZipCode, $City, $Country, - $this->einstellungen, $product, $sid, $lieferschein, $id); - if ($adressdaten !== null) { - $adressdaten['tracking'] = $this->voucherId; - } - } - } - - if ($token !== 'fail' && $link !== 'fail') { - $data['drucker'] = $this->paketmarke_drucker; - $data['druckerlogistikstufe2'] = $this->export_drucker; - - if (!$data['drucker']) { - if ($this->app->erp->GetStandardPaketmarkendrucker() > 0) { - $data['drucker'] = $this->app->erp->GetStandardPaketmarkendrucker(); - } - } - - if (!$data['druckerlogistikstufe2']) { - if ($this->app->erp->GetStandardVersanddrucker($projekt) > 0) { - $data['druckerlogistikstufe2'] = $this->app->erp->GetStandardVersanddrucker($projekt); - } - } - $pdf = file_get_contents($link); - $datei = $this->app->erp->GetTMP() . 'DhlMarkeLabel' . ".pdf"; - - file_put_contents($datei, $pdf); - - $spoolerId = $this->app->printer->Drucken($data['drucker'], $datei); - if($spoolerId > 0 && $versandId > 0) { - $this->app->DB->Update( - sprintf( - 'UPDATE versand SET lastspooler_id = %d, lastprinter = %d WHERE id = %d', - $spoolerId, $data['drucker'], $versandId - ) - ); - } - if ($module === 'retoure') { - if (@is_file($datei) && @filesize($datei)) { - $fileid = $this->app->erp->CreateDatei('DhlMarkeLabel_' . $this->app->DB->Select("SELECT belegnr FROM retoure WHERE id = '$id' LIMIT 1") . '.pdf', - 'Anhang', '', "", $datei, - $this->app->DB->real_escape_string($this->app->User->GetName())); - $this->app->erp->AddDateiStichwort($fileid, 'anhang', 'retoure', $id); - } - } - - unlink($datei); - if ($adressdaten !== null) { - return true; - } - } - } - } - if ($adressdaten !== null) { - return false; - } - if ($target) { - $formats = $this->retrievePageFormats(); - $pageFormats = new SimpleXMLElement($formats); - $pageFormats->registerXPathNamespace("a", "http://oneclickforapp.dpag.de/V3"); - $formats = $pageFormats->xpath('//a:pageFormat'); - $formatOptions = ""; - foreach ($formats as $format) { - $formatOptions .= ""; - } - $this->app->Tpl->Set('PAGE_FORMATS', $formatOptions); - if (!isset($this->einstellungen['product']) || $this->einstellungen['product'] == -1) { - $this->getProducts(); - } else { - $htmlString = ''; - $this->app->Tpl->Set('PRODUCT_LIST', $htmlString); - } - if (!isset($this->einstellungen["format"]) || $this->einstellungen["format"] == -1) { - $this->errors[] = 'Bitte Format einstellen'; - } - $Query = $this->app->DB->SelectRow("SELECT * FROM lieferschein where id='$id'"); - $this->app->Tpl->Set("ADRESSZUSATZ", $Query['adresszusatz']); - $this->app->Tpl->Parse($target, 'versandarten_internetmarke.tpl'); - } - if (count($this->errors) > 0) { - return $this->errors; - } - } - - function pageFormatList() - { - $formats = $this->retrievePageFormats(); - $pageFormats = new SimpleXMLElement($formats); - $pageFormats->registerXPathNamespace("a", "http://oneclickforapp.dpag.de/V3"); - $formats = $pageFormats->xpath('//a:pageFormat'); - //var_dump($formats); - $formats1 = [-1 => "Bitte auswählen"]; - foreach ($formats as $format) { - $formats1[(int)$format->id] = $format->name; - if (!filter_var($format->isAddressPossible, FILTER_VALIDATE_BOOLEAN)) { - $formats1[(int)$format->id] .= ' (Keine Adressanzeige vorgesehen)'; - } - } - - return $formats1; - } - - function getProductList() - { - $csvFile = fopen(__DIR__ . "/{$this->ppl}", "r"); - if (!$csvFile) { - $this->app->erp->Logfile("Internetmarke: Kann Produktdaten nicht finden."); - $this->errors[] = "Kann Produktdaten nicht finden."; - - //throw new Exception("Error openinig product csv"); - return 'fail'; - } - $options = []; - $options[-1] = "Alle zur Auswahl in Paketmarkendialog"; - $line = fgetcsv($csvFile, 0, ";"); - $htmlString = ""; - while ($line != null) { - if ($line[4] != "") { - //$htmlString .= '"; - $options[(string)$line[2]] = mb_convert_encoding($line[4], "UTF-8", - "ASCII") . " (" . money_format('%!n', (float)str_replace(",", ".", $line[5])) . ")"; - } - $line = fgetcsv($csvFile, 0, ";"); - } - fclose($csvFile); - - return $options; - } - - function getProducts($return = false) - { - $csvFile = fopen(__DIR__ . "/{$this->ppl}", "r"); - if (!$csvFile) { - $this->app->erp->Logfile("Internetmarke: Kann Produktdaten nicht finden."); - $this->errors[] = "Kann Produktdaten nicht finden."; - - //throw new Exception("Error openinig product csv"); - return 'fail'; - } - $line = fgetcsv($csvFile, 0, ";"); - $htmlString = ""; - while ($line != null) { - if ($line[4] != "") { - $htmlString .= '"; - if ($return) { - return $line[2]; - } - } - $line = fgetcsv($csvFile, 0, ";"); - } - $this->app->Tpl->Set('PRODUCT_LIST', - 'Produkt: '); - fclose($csvFile); - } - - - /** - * @param string $token - * - * @return string - */ - public function getProductPricesRequestXml($token) - { - return ' - ' . $this->getHeader() . ' - - - '.$token.' - - -'; - } - - function getProductPrice($id) - { - $price = 0.00; - $csvFile = fopen(__DIR__ . "/{$this->ppl}", "r"); - if (!$csvFile) { - $this->app->erp->Logfile("Internetmarke: Kann Produktdaten nicht öffnen"); - $this->errors[] = "Kann Produktdaten nicht finden."; - - return 'fail'; - //throw new Exception("Error openinig product csv"); - } - $line = fgetcsv($csvFile, 0, ";"); - $htmlString = ""; - while ($line != null) { - if ($line[4] != "") { - if ($line[2] == $id) { - $price = (float)str_replace(",", ".", $line[5]); - break; - } - } - $line = fgetcsv($csvFile, 0, ";"); - } - - fclose($csvFile); - - return $price; - } - - - public function Export($daten) - { - - } - - - 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 checkoutPDF($token, $name, $additional, $street, $houseno, $plz, $city, $country, $ei, $product, $sid, $lieferschein, $id) - { - if(!is_file(__DIR__.'/ppl_prices_'.$this->id.'.xml')){ - $xml = $this->getProductPricesRequestXml($token); - $curlData = $this->curl($xml); - file_put_contents(__DIR__ . '/ppl_prices_' . $this->id . '.xml', $curlData); - } - $prices = []; - try { - $curlData = file_get_contents(__DIR__ . '/ppl_prices_' . $this->id . '.xml'); - $doc = new DOMDocument(); - $doc->loadXML($curlData); - - $children = $doc->getElementsByTagName('products'); - for ($i = 0; $i < $children->length; $i++) { - $child[$i] = $children->item($i); - if($child[$i]->hasChildNodes()){ - $haschild[$i] = $child[$i]->childNodes; - if($haschild[$i]->length >= 2){ - $price = ''; - $code = ''; - for ($j = 0; $j < $haschild[$i]->length; $j++) { - $child1 = $haschild[$i]->item($j); - if($child1->nodeName === 'productCode'){ - $code = $child1->nodeValue; - } - if($child1->nodeName === 'price'){ - $price = $child1->nodeValue; - } - } - if(!empty($code) && !empty($price)){ - $prices[$code] = $price / 100; - } - } - } - } - } - catch (Exception $e) { - - } - $price = $this->getProductPrice($product); - if(!empty($prices[$product])) { - $price = $prices[$product]; - } - $c = $this->app->erp->GetSelectLaenderliste(); - - // anscheinend geben die manchmal komma an - if ((strpos($name, ',') !== false) && !(strpos($name, ' ') !== false)) { - $name = str_replace(',', ' ', $name); - } - - if (strpos($name, ' ') !== false) { - $firstname = trim(strstr($name, ' ', true)); - $lastname = trim(strstr($name, ' ')); - } else { - $firstname = $name; - $lastname = ""; - } - - - if ($ei["origin_company"] == "") { - $ei["origin_company"] = $ei["origin_firstname"] . " " . $ei["origin_lastname"]; - } - - - $country = $this->getAlpha3FromAlpa2($country); - $data = ' - - ' . $this->getHeader() . ' - - - ' . $token . ' - ' . $this->einstellungen["format"] . ' - - - ' . (int)$product . ' - - - - - - ' . $ei["origin_company"] . ' - - - - ' . $ei["origin_street"] . ' - ' . $ei["origin_houseno"] . ' - ' . $ei["origin_zip"] . ' - ' . $ei["origin_city"] . ' - ' . $ei["origin_country"] . ' - - - - - - ' . $firstname . ' - ' . $lastname . ' - - - - ' . $additional . ' - ' . $street . ' - ' . $houseno . ' - ' . $plz . ' - ' . $city . ' - ' . $country . ' - - - - AddressZone - - 1 - 1 - 1 - - - ' . ($price * 100) . ' - false - 2 - - - '; - - $this->app->erp->Logfile("Internetmarke checkout data", base64_encode($data)); - - - $data = str_replace('&', '&', $data); - $data = str_replace('&', '&', $data); - - $curlData = $this->curl($data); - $xml = new SimpleXMLElement($curlData); - $xml->registerXPathNamespace("a", "http://oneclickforapp.dpag.de/V3"); - $errorArray = $xml->xpath("//faultstring"); - if (sizeof($errorArray) > 0) { - $errorString = ""; - foreach ($errorArray as $error) { - $errorString .= (string)$error . "\n"; - } - //echo $curlData; - $this->app->erp->Logfile("Internetmarke Checkout Error", $errorString); - print(""); - $this->errors[] = $errorString; - - return 'fail'; - //throw new Exception($errorString); - } - $link = $xml->xpath("//a:link"); - $link = ((string)$link[0][0]); - - $countrycheck = str_replace('DEU','DE',$country); - $voucherID = (string)$xml->xpath("//a:voucherId")[0]; - if ($countrycheck !== 'DE') { - $voucherID = (string)$xml->xpath('//a:trackId')[0]; - } - $this->voucherId = $voucherID; - if ($this->einstellungen['autotracking'] == "1") { - $this->SetTracking($voucherID,$sid==='versand'?$id:0, $lieferschein); - } - - return $link; - } - - function retrievePublicGallery() - { - $data = ' - ' . $this->getHeader() . ' - - - - '; - - return format(curl($data)); - } - - - function retrievePageFormats() - { - $data = ' - ' . $this->getHeader() . ' - - - - '; - - return $this->curl($data); - } - - function format($xml) - { - $dom = new DOMDocument; - $dom->preserveWhiteSpace = false; - $dom->loadXML($xml); - $dom->formatOutput = true; - - return $dom->saveXml(); - } - - function getPageFormats() - { - $data = ' - ' . $this->getHeader() . ' - - - - '; - - return curl($data); - } - - function getVoucher() - { - $data = ' - ' . $this->getHeader() . ' - - - 1 - 79929186 - AddressZone - 7 - - - '; - - return curl($data); - } - - function getShopOrderID($token) - { - $data = ' - ' . $this->getHeader() . ' - - - ' . $token . ' - - - '; - - $curlData = curl($data); - - $xml = new SimpleXMLElement($curlData); - $xml->registerXPathNamespace('a', 'http://oneclickforapp.dpag.de/V3'); - $id = $xml->xpath("//a:shopOrderId"); - $id = (string)$id[0][0]; - - return $id; - } - - function curl($data) - { - $curl = curl_init(); - $endpoint_URL = "https://internetmarke.deutschepost.de/OneClickForAppV3"; - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_URL, $endpoint_URL); - curl_setopt($curl, CURLOPT_PORT, 443); - curl_setopt($curl, CURLOPT_VERBOSE, 0); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - curl_setopt($curl, CURLOPT_HTTPHEADER, - ["Content-Type: text/xml; charset=UTF-8", "SOAPAction: \"/soap/action/query\"", "Content-length: " . strlen($data)]); - $curlData = curl_exec($curl); - - return $curlData; - } - - function getToken() - { - $data = ' - ' . $this->getHeader() . ' - - - ' . $this->einstellungen['dhl_marke_email'] . ' - ' . $this->einstellungen['dhl_marke_password'] . ' - - - '; - - //echo $data . "\n"; - - $curl = curl_init(); - - $endpoint_URL = "https://internetmarke.deutschepost.de/OneClickForAppV3"; - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curl, CURLOPT_URL, $endpoint_URL); - curl_setopt($curl, CURLOPT_PORT, 443); - curl_setopt($curl, CURLOPT_VERBOSE, 0); - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_POST, 1); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - curl_setopt($curl, CURLOPT_HTTPHEADER, - ["Content-Type: text/xml", "SOAPAction: \"/soap/action/query\"", "Content-length: " . strlen($data)]); - $curlData = curl_exec($curl); - - //echo format($curlData); - - $simpleXml = new SimpleXMLElement($curlData); - $simpleXml->registerXPathNamespace('a', "http://oneclickforapp.dpag.de/V3"); - $simpleXml->registerXPathNamespace('ns2', "http://schemas.xmlsoap.org/soap/envelope/"); - $errorArray = $simpleXml->xpath("//faultstring"); - if (sizeof($errorArray) > 0) { - $errorString = ""; - foreach ($errorArray as $error) { - $errorString .= (string)$error . "\n"; - } - $this->app->erp->Logfile("Internetmarke Token Error", $errorString); - $this->errors[] = $errorString; - - return 'fail'; - //throw new Exception($errorString); - } - $user = $simpleXml->xpath("//a:userToken"); - $token = (string)$user[0][0]; - - return $token; - - } - - function getHeader() - { - $PARTNER_ID = "AEHWA"; - $KEY_PHASE = "1"; - $KEY = "nHHNZblHkRWpQeXq1c9nnRVsp8M8rAnC"; - $TIMESTAMP = date('dmY-His'); - $hashString = "$PARTNER_ID::" . $TIMESTAMP . "::$KEY_PHASE::$KEY"; - $hash = md5($hashString); - $hash = substr($hash, 0, 8); - - $data = '' . $PARTNER_ID . ' - ' . $TIMESTAMP . ' - ' . $KEY_PHASE . ' - ' . $hash . ''; - - return $data; - } - - function getAlpha3FromAlpa2($alpha2) - { - $countries = [ - "AF" => "AFG", - "AL" => "ALB", - "DZ" => "DZA", - "AS" => "ASM", - "AD" => "AND", - "AO" => "AGO", - "AI" => "AIA", - "AQ" => "ATA", - "AG" => "ATG", - "AR" => "ARG", - "AM" => "ARM", - "AW" => "ABW", - "AU" => "AUS", - "AT" => "AUT", - "AZ" => "AZE", - "BS" => "BHS", - "BH" => "BHR", - "BD" => "BGD", - "BB" => "BRB", - "BY" => "BLR", - "BE" => "BEL", - "BZ" => "BLZ", - "BJ" => "BEN", - "BM" => "BMU", - "BT" => "BTN", - "BO" => "BOL", - "BA" => "BIH", - "BW" => "BWA", - "BV" => "BVT", - "BR" => "BRA", - "IO" => "IOT", - "BN" => "BRN", - "BG" => "BGR", - "BF" => "BFA", - "BI" => "BDI", - "KH" => "KHM", - "CM" => "CMR", - "CA" => "CAN", - "CV" => "CPV", - "KY" => "CYM", - "CF" => "CAF", - "TD" => "TCD", - "CL" => "CHL", - "CN" => "CHN", - "CX" => "CXR", - "CC" => "CCK", - "CO" => "COL", - "KM" => "COM", - "CG" => "COG", - "CD" => "COD", - "CK" => "COK", - "CR" => "CRI", - "CI" => "CIV", - "HR" => "HRV", - "CU" => "CUB", - "CY" => "CYP", - "CZ" => "CZE", - "DK" => "DNK", - "DJ" => "DJI", - "DM" => "DMA", - "DO" => "DOM", - "EC" => "ECU", - "EG" => "EGY", - "SV" => "SLV", - "GQ" => "GNQ", - "ER" => "ERI", - "EE" => "EST", - "ET" => "ETH", - "FK" => "FLK", - "FO" => "FRO", - "FJ" => "FJI", - "FI" => "FIN", - "FR" => "FRA", - "GF" => "GUF", - "PF" => "PYF", - "TF" => "ATF", - "GA" => "GAB", - "GM" => "GMB", - "GE" => "GEO", - "DE" => "DEU", - "GH" => "GHA", - "GI" => "GIB", - "GR" => "GRC", - "GL" => "GRL", - "GD" => "GRD", - "GP" => "GLP", - "GU" => "GUM", - "GT" => "GTM", - "GG" => "GGY", - "GN" => "GIN", - "GW" => "GNB", - "GY" => "GUY", - "HT" => "HTI", - "HM" => "HMD", - "VA" => "VAT", - "HN" => "HND", - "HK" => "HKG", - "HU" => "HUN", - "IS" => "ISL", - "IN" => "IND", - "ID" => "IDN", - "IR" => "IRN", - "IQ" => "IRQ", - "IE" => "IRL", - "IM" => "IMN", - "IL" => "ISR", - "IT" => "ITA", - "JM" => "JAM", - "JP" => "JPN", - "JE" => "JEY", - "JO" => "JOR", - "KZ" => "KAZ", - "KE" => "KEN", - "KI" => "KIR", - "KP" => "PRK", - "KR" => "KOR", - "KW" => "KWT", - "KG" => "KGZ", - "LA" => "LAO", - "LV" => "LVA", - "LB" => "LBN", - "LS" => "LSO", - "LR" => "LBR", - "LY" => "LBY", - "LI" => "LIE", - "LT" => "LTU", - "LU" => "LUX", - "MO" => "MAC", - "MK" => "MKD", - "MG" => "MDG", - "MW" => "MWI", - "MY" => "MYS", - "MV" => "MDV", - "ML" => "MLI", - "MT" => "MLT", - "MH" => "MHL", - "MQ" => "MTQ", - "MR" => "MRT", - "MU" => "MUS", - "YT" => "MYT", - "MX" => "MEX", - "FM" => "FSM", - "MD" => "MDA", - "MC" => "MCO", - "MN" => "MNG", - "ME" => "MNE", - "MS" => "MSR", - "MA" => "MAR", - "MZ" => "MOZ", - "MM" => "MMR", - "NA" => "NAM", - "NR" => "NRU", - "NP" => "NPL", - "NL" => "NLD", - "AN" => "ANT", - "NC" => "NCL", - "NZ" => "NZL", - "NI" => "NIC", - "NE" => "NER", - "NG" => "NGA", - "NU" => "NIU", - "NF" => "NFK", - "MP" => "MNP", - "NO" => "NOR", - "OM" => "OMN", - "PK" => "PAK", - "PW" => "PLW", - "PS" => "PSE", - "PA" => "PAN", - "PG" => "PNG", - "PY" => "PRY", - "PE" => "PER", - "PH" => "PHL", - "PN" => "PCN", - "PL" => "POL", - "PT" => "PRT", - "PR" => "PRI", - "QA" => "QAT", - "RE" => "REU", - "RO" => "ROU", - "RU" => "RUS", - "RW" => "RWA", - "SH" => "SHN", - "KN" => "KNA", - "LC" => "LCA", - "PM" => "SPM", - "VC" => "VCT", - "WS" => "WSM", - "SM" => "SMR", - "ST" => "STP", - "SA" => "SAU", - "SN" => "SEN", - "RS" => "SRB", - "SC" => "SYC", - "SL" => "SLE", - "SG" => "SGP", - "SK" => "SVK", - "SI" => "SVN", - "SB" => "SLB", - "SO" => "SOM", - "ZA" => "ZAF", - "GS" => "SGS", - "ES" => "ESP", - "LK" => "LKA", - "SD" => "SDN", - "SR" => "SUR", - "SJ" => "SJM", - "SZ" => "SWZ", - "SE" => "SWE", - "CH" => "CHE", - "SY" => "SYR", - "TW" => "TWN", - "TJ" => "TJK", - "TZ" => "TZA", - "TH" => "THA", - "TL" => "TLS", - "TG" => "TGO", - "TK" => "TKL", - "TO" => "TON", - "TT" => "TTO", - "TN" => "TUN", - "TR" => "TUR", - "TM" => "TKM", - "TC" => "TCA", - "TV" => "TUV", - "UG" => "UGA", - "UA" => "UKR", - "AE" => "ARE", - "GB" => "GBR", - "US" => "USA", - "UM" => "UMI", - "UY" => "URY", - "UZ" => "UZB", - "VU" => "VUT", - "VE" => "VEN", - "VN" => "VNM", - "VG" => "VGB", - "VI" => "VIR", - "WF" => "WLF", - "EH" => "ESH", - "YE" => "YEM", - "ZM" => "ZMB", - "ZW" => "ZWE", - ]; - - return $countries[$alpha2]; - } - -} diff --git a/www/lib/versandarten/parcelone.php_ b/www/lib/versandarten/parcelone.php_ deleted file mode 100644 index f253c81c..00000000 --- a/www/lib/versandarten/parcelone.php_ +++ /dev/null @@ -1,2172 +0,0 @@ -replacements = $replacements; - } - - /** - * Search and replace variables in string. - * - * Replaces all placeholders in upper or lower case within single or double curly brackets - * @param string $message - * - * E.G.: Would convert "hello {customer}." to "hello awesome people." - * if array to __construct was like ['customer' => 'awesome people'] - * - * @return string - */ - public function handle($message) - { - if (!is_string($message)) { - $type = gettype($message); - throw new RuntimeException(sprintf( - 'Expected message as string, got %s.', $type - )); - } - - if (empty($this->replacements)) { - return $message; - } - - foreach ($this->replacements as $key => $value) { - $value = (string) $value; - - // key with one bracket - $key = '{' . trim($key, '{}') . '}'; - $message = str_replace([$key, strtolower($key)], [$value, $value], $message); - // key with two brackets - $key = '{' . $key . '}'; - $message = str_replace([$key, strtolower($key)], [$value, $value], $message); - } - - return $message; - } -} - -/** - * This abstract class is designed to simplify a new 'delivery tool' - * - * Class AbstractVersandart - */ -abstract class AbstractVersandartParcelone extends Versanddienstleister -{ - public $einstellungen = []; - public $export_drucker; - public $paketmarke_drucker; - - /** - * Copied from other 'versandart modules', added - * the RuntimeException for json decode. - * - * AbstractVersandart constructor. - * - * @param app_t $app - * @param int $id - */ - final public function __construct($app, $id) - { - $this->id = $id; - $this->app = &$app; - $settings = $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 ($settings) { - $settings = json_decode($settings, true); - if (json_last_error()) { - throw new RuntimeException(sprintf( - 'JSON decode failed in %s with %s.', get_class($this), json_last_error_msg() - )); - } - } else { - $settings = []; - } - $this->einstellungen = $settings; - $this->ctrHook(); - } - - /** - * Just a hook run if the ctr had his job done. - * - * @return void - */ - abstract protected function ctrHook(); - - /** - * - * Called via 'versandzentrum' - * Thanks to 'sevensenders.php' - * - * @param int|string $id - * @param $sid - * - * @return array - */ - public function PaketmarkeDrucken($id, $sid) - { - $adressdaten = $this->GetAdressdaten($id, $sid); - $ret = $this->Paketmarke($sid, $id, '', false, $adressdaten); - - if ($sid !== 'lieferschein') { - return $ret; - } - - $deliveryNoteArr = $this->app->DB->SelectRow("SELECT adresse, versandart, projekt FROM lieferschein WHERE id = '$id' LIMIT 1"); - $adresse = $deliveryNoteArr['adresse']; - $project = $deliveryNoteArr['projekt']; - $versandart = $deliveryNoteArr['versandart']; - $addressValidation = 2; - if ($ret) { - $addressValidation = 1; - } - - $tracking = null; - // $tracking = $this->tracking; // $this->tracking is not set in 'sevensenders.php' - if (isset($adressdaten['tracking'])) { - $tracking = $adressdaten['tracking']; - } - $this->app->DB->Insert("INSERT INTO versand (versandunternehmen, tracking, - versendet_am,abgeschlossen,lieferschein,freigegeben,firma,adresse,projekt,paketmarkegedruckt,adressvalidation) - VALUES ('$versandart','$tracking',NOW(),1,'$id',1,'1','$adresse','$project',1,'$addressValidation') "); - if ($addressValidation === 1) { - $this->app->erp->LieferscheinProtokoll($id, 'Paketmarke automatisch gedruckt'); - } elseif ($addressValidation === 2) { - $this->app->erp->LieferscheinProtokoll($id, 'automatisches Paketmarke Drucken fehlgeschlagen'); - } - - return $ret; - } - - /** - * This method is the 'main' part of all delivery tools. - * - * Available via Lager -> Lieferschein - * index.php?module=lieferschein&action=paketmarke&id={id} - * or Lager -> Versandzentrum - * index.php?module=versanderzeugen&action=frankieren&id={id} - * or Lager -> Retoure - * index.php?module=retoure&action=paketmarke&id={id} - * - * called via erpapi->Paketmarke($parsetarget,$sid="",$zusatz="",$typ="DHL") as: - * $error = $obj->Paketmarke($sid!=''?$sid:'lieferschein',($sid=='versand'?$id:$tid), $parsetarget, $error); - * - * Reads the address data and package data via '$this->app->Secure->GetPOST' or from '$adressdaten' array. - * - * @param string $doctyp 'lieferschein' / 'versand' / 'retoure' - * @param string|int $id '1' - * @param string $target '#TAB1' - * @param bool $error - * @param null|array $adressdaten - * - * @return array - */ - final public function Paketmarke($doctyp, $id, $target = '', $error = false, &$adressdaten = null) - { - if (is_string($id) && is_numeric($id)) { - $id = (int)$id; - } - if (!is_int($id)) { - $type = gettype($id); - throw new ArgumentTypeException('Expected id as integer, got ' . $type); - } - if (!is_string($doctyp)) { - $type = gettype($doctyp); - throw new ArgumentTypeException('Expected doctyp as string, got ' . $type); - } - $allowedTypes = ['lieferschein', 'versand', 'retoure']; - if ($adressdaten === null) { - $doctyp = $this->getModuleName($doctyp, $allowedTypes); - } - if (!in_array($doctyp, $allowedTypes, true)) { - throw new RuntimeException('Only \'Lieferschein\' is supported, got ' . $doctyp); - } - - $this->validateSettings(); - - if (is_array($adressdaten) && !empty($adressdaten)) { - - $address = [ - 'name' => $adressdaten['name'], - 'name2' => $adressdaten['name2'], - 'name3' => $adressdaten['name3'], - 'street' => $adressdaten['strassekomplett'], - 'street_no' => $adressdaten['hausnummer'], - 'plz' => $adressdaten['plz'], - 'ort' => $adressdaten['ort'], - 'email' => $adressdaten['email'], - 'phone' => $adressdaten['phone'], - 'land' => $adressdaten['land'], - // bundesstaat - ]; - -// $anzahl = (int)isset($adressdaten["anzahl"])?$adressdaten["anzahl"]:0; -// $nummeraufbeleg = "";//$this->app->Secure->GetPOST("nummeraufbeleg"); -// if ($anzahl <= 0 || !is_int($anzahl)) $anzahl = 1; -// $laenge = isset($adressdaten["laenge"])?$adressdaten["laenge"]:''; -// $breite = isset($adressdaten["breite"])?$adressdaten["breite"]:''; -// $hoehe = isset($adressdaten["hoehe"])?$adressdaten["hoehe"]:''; - - $cash_on_delivery = isset($adressdaten['Nachnahme']) ? $adressdaten['Nachnahme'] : 0; - $packageData = [ - 'kg1' => $adressdaten['standardkg'], - 'drucken' => '1', - 'anders' => '', - 'tracking_again' => '', - 'module' => $doctyp, - - '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'), - 'nachnahme' => (int)$cash_on_delivery, - 'product' => '', - ]; - - } else { - $address = [ - 'name' => $this->app->Secure->GetPOST('name'), - 'name2' => $this->app->Secure->GetPOST('name2'), - 'name3' => $this->app->Secure->GetPOST('name3'), - 'street' => $this->app->Secure->GetPOST('strasse'), - 'street_no' => $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'), - 'land' => $this->app->Secure->GetPOST('land'), - ]; - $packageData = [ - 'kg1' => $this->app->Secure->GetPOST('kg1'), - 'drucken' => $this->app->Secure->GetPOST('drucken'), - 'anders' => $this->app->Secure->GetPOST('anders'), - 'tracking_again' => $this->app->Secure->GetGET('tracking_again'), - 'module' => $this->app->Secure->GetGET('module'), - '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'), - // 'product' => $this->app->Secure->GetPOST('products'), - 'nachnahme' => $this->app->Secure->GetPOST('nachnahme'), - ]; - } - -// $packageData['clients_reference'] = $this->app->Secure->GetPOST('clients_reference'); -// $packageData['shipment_reference'] = $this->app->Secure->GetPOST('shipment_reference'); - $packageData['service'] = $this->app->Secure->GetPOST('service'); - - /* - * This is in 'sevensenders.php' only called, if $addressdata === null. But why? - */ - $this->setNachnahmeCheckbox($doctyp, $id); - - $ret = []; - if (!empty($address)) { - try { - // throw new RuntimeException('Ooops - data missing'); - $this->createPaketmarke($doctyp, $id, $target, $error, $address, $packageData); - } catch (Exception $e) { - $ret[] = $e->getMessage(); - } - } - - if ($target) { - $this->parseTemplate($target); - } - - return $ret; - } - - /** - * Get the module name. - * - * @param string $doctype - * @param array $allowedTypes - * - * @return string - */ - private function getModuleName($doctype, $allowedTypes) - { -// // in sevensenders: -// if($adressdaten === null){ -// $module = $this->app->Secure->GetGET('module'); -// }else{ -// $module = $doctyp; -// } - - $tmp = $this->app->Secure->GetGET('module'); - if (is_array($tmp)) { - $tmp = array_filter($tmp); - $tmp = array_filter($tmp, 'is_string'); - if (array_key_exists(0, $tmp)) { - $tmp = $tmp[0]; - } else { - $tmp = ''; - } - } - if (in_array($tmp, $allowedTypes, true)) { - return (string)$tmp; - } - - return $doctype; - } - - /** - * Check if all settings are set and not empty. - * Uses $this->settingsStructure() to get all - * required settings. Empty settings are not allowed! - * Respects select options (drop-down menus). Uses - * the shown labels in the exceptions. - * - * @throws RuntimeException - */ - protected function validateSettings() - { - $settings = $this->EinstellungenStruktur(); - foreach ($settings as $key => $setting) { - $name = rtrim($setting['bezeichnung'], ':'); - - if (!array_key_exists($key, $this->einstellungen)) { - if (array_key_exists('optional', $setting) && $setting['optional'] === true) { - continue; - } - if (array_key_exists('typ', $setting) && strtolower((string)$setting['typ']) === 'checkbox') { - continue; - } - if (array_key_exists('default', $setting)) { - $value = $setting['default']; - // if default value is empty, don't run other validations. - - $this->einstellungen[$key] = $value; - - if (empty($value)) { - continue; - } - } - } - - if (!array_key_exists($key, $this->einstellungen)) { - throw new RuntimeException(sprintf( - 'Setting \'%s\' is missing.', $name - )); - } - - $value = $this->einstellungen[$key]; - - /* - * Check 'size' argument for maximum length. - */ - if (array_key_exists('maxLength', $setting) && is_numeric($setting['maxLength'])) { - $maxLength = (int) $setting['maxLength']; - if ($maxLength > 0 && strlen($value) > $maxLength) { - throw new RuntimeException(sprintf( - 'Setting \'%s\' raised it\'s maximum length of %s.', $name, $maxLength - )); - } - } - - /* - * Respect select fields. - */ - if (array_key_exists('optionen', $setting) && $setting['type'] === 'select') { - $options = $setting['optionen']; - $keys = array_keys($options); - - if (!in_array($value, $keys, true)) { - $values = array_values($options); - $options = implode(', ', $values); - throw new RuntimeException(sprintf( - 'Setting \'%s\' is not allowed, allowed values are: %s.', $name, $options - )); - } - continue; - } - - if (array_key_exists('regex', $setting) && is_string($setting['regex'])) { - - $pattern = $setting['regex']; - $pattern = trim($pattern, '/'); - $pattern = ltrim($pattern, '^'); - $pattern = rtrim($pattern, '$'); - $pattern = '/^' . $pattern . '$/'; - $match = preg_match($pattern, $value); - - if ($match === false) { - throw new RuntimeException(sprintf( - 'Invalid regex pattern for \'%s\'.', $name - )); - } - if ($match !== 1) { - throw new RuntimeException(sprintf( - 'Setting \'%s\' does not match it\'s regex pattern.', $name - )); - } - } - } - } - - /** - * Print the created file. - * - * @param string $filename - * @param string $content - * @param int $versandId - * - * @throws RuntimeException - */ - protected function printFile($filename, $content, $versandId) - { - $printer = $this->getPrinter(); - if (!$printer) { - throw new RuntimeException('No printer configured.'); - } - - if (!is_string($filename)) { - $type = gettype($filename); - throw new RuntimeException(sprintf( - 'Expected filename as string, got %s.', $type - )); - } - - if (empty($filename)) { - throw new RuntimeException( - 'Empty filename is not supported.' - ); - } - - if (!is_string($content)) { - $type = gettype($content); - throw new RuntimeException(sprintf( - 'Expected content as string, got %s.', $type - )); - } - - if (empty($content)) { - throw new RuntimeException(sprintf( - 'Empty content for document %s is not supported.', $filename - )); - } - - $tmpPath = $this->app->erp->GetTMP(); - $full = $tmpPath . $filename; - - if (!file_put_contents($full, $content)) { - throw new RuntimeException(sprintf( - 'Could not write file \'%s\'.', $filename - )); - } - - $spoolerId = $this->app->printer->Drucken($printer, $full); - unlink($full); - - if($versandId && $spoolerId) { - $this->app->DB->Update( - sprintf( - 'UPDATE versand SET lastspooler_id = %d, lastprinter = %d WHERE id = %d', - $spoolerId, $printer, $versandId - ) - ); - } - } - - /** - * Return the html structure displayed in the - * 'versandarten' module to add some extra - * input fields for api keys etc. - * - * Displayed via class 'Versanddienstleister' located - * in ../class.versanddienstleister.php - * - * @return array - */ - abstract protected function EinstellungenStruktur(); - - /** - * Set the 'nachnahme' checkbox field. - * - * Thanks to 'sevensenders.php' - * - * @param string $doctyp - * @param int|string $id - */ - private function setNachnahmeCheckbox($doctyp, $id) - { - if ($doctyp === 'lieferschein') { - $lieferschein = $id; - } elseif ($doctyp === 'retoure') { - $lieferschein = $this->app->DB->Select("SELECT lieferschein FROM retoure WHERE id='$id' LIMIT 1"); - } else { - $lieferschein = $this->app->DB->Select("SELECT lieferschein FROM versand WHERE id='$id' LIMIT 1"); - if ($lieferschein <= 0) { - $lieferschein = $id; - } - } - - $rechnung = $this->app->DB->Select("SELECT id FROM rechnung WHERE lieferschein='$lieferschein' LIMIT 1"); - $zahlungsweise = $this->app->DB->Select("SELECT zahlungsweise FROM rechnung WHERE id='$rechnung' LIMIT 1"); - if ($zahlungsweise === 'nachnahme') { - $this->app->Tpl->Set('NACHNAHME', 'checked="checked"'); - } - } - - /** - * Create the package labels. - * - * Called via Paketmarke or PaketmarkeDrucken - * - * @param string $doctyp - * @param string $id - * @param string $target - * @param bool $error - * @param array $adressdaten - * @param array $packageData - * - * @return array list of error messages - */ - abstract protected function createPaketmarke($doctyp, $id, $target, $error, $adressdaten, $packageData); - - /** - * Parse the template. - * - * @param string $target - * - * @return void - */ - abstract protected function parseTemplate($target); - - /** - * May change the tracking id before inserting into the db. - * - * @param string $tracking - * - * @return string - */ - public function TrackingReplace($tracking) - { - return $tracking; - } - - /** - * Extract the child's name and create - * a default module name via 'ucfirst'. - * - * E.G. converts child's class name - * 'Versandart_parcelone' to 'Parcelone'. - * - * @return string - */ - public function GetBezeichnung() - { - $c = get_class($this); - $c = explode('_', $c); - $c = array_filter($c); - $c = array_pop($c); - $c = ucfirst($c); - - return $c; - } - - /** - * Load the data given by the current document type and it's id. - * - * @param string $documentTyp on of 'lieferschein', 'versand' or 'retoure' - * @param int $id - * - * @throws RuntimeException - * - * @return array - */ - protected function getDocumentByID($documentTyp, $id) - { - /* - * var $documentTyp may be: - * - 'lieferschein' - * - 'versand' - * - 'retoure' - * - * - 'auftrag' - */ - $documentTyp = $this->app->DB->real_escape_string($documentTyp); - $sql = sprintf('SELECT * FROM %s WHERE id = %s LIMIT 1', $documentTyp, $id); - - $data = $this->app->DB->SelectArr($sql); - $error = $this->app->DB->error(); - - if ($error) { - $error = htmlspecialchars($error); - $msg = sprintf('SQL SelectArr error: \'%s\', query was \'%s\'', $error, $sql); - throw new RuntimeException($msg); - } - - if (!is_array($data) || !array_key_exists(0, $data) || !is_array($data[0]) || !$data[0]) { - throw new RuntimeException(sprintf( - 'No data for document %s with id %s found.', $documentTyp, $id - )); - } - - $data = $data[0]; - - return $data; - } - - /** - * Return the 'standard Paketmarkendrucker'. - * - * Checks GetPOST: drucken - * Checks GetGET: tracking_again - * - * @return int - */ - protected function getPrinter() - { - if (is_numeric($this->paketmarke_drucker) && $this->paketmarke_drucker) { - return $this->paketmarke_drucker; - } - - $printer = (int) $this->app->erp->GetStandardPaketmarkendrucker(); - if ($printer) { - return $printer; - } - - return $this->export_drucker; - } - - /** - * Get the current user name as escaped string. - * - * @return string - */ - protected function getUserName() - { - $user = $this->app->User->GetName(); - $user = $this->app->DB->real_escape_string($user); - - return $user; - } - - /** - * Load an address via it's id. - * - * @param string|int $id - * @param string|array $fields Filter these columns, default all - * - * @throws RuntimeException - * - * @return array - */ - protected function loadAddress($id, $fields = '*') - { - if (is_string($id) && is_numeric($id)) { - $id = (int)$id; - } - if (!is_int($id)) { - $type = gettype($id); - throw new ArgumentTypeException('Expected addressID as int, got ' . $type); - } - - $fields = (array)$fields; - $fields = array_values($fields); - $fields = array_filter($fields); - $fields = array_filter($fields, 'is_string'); - if (in_array('*', $fields, true)) { - $fields = '*'; - } else { - $tmp = []; - foreach ($fields as $field) { - $tmp[] = $this->app->DB->real_escape_string($field); - } - $fields = implode(', ', $tmp); - } - - $sql = sprintf('SELECT %s FROM adresse WHERE id =\'%s\'', $fields, $id); - $query = $this->app->DB->Query($sql); - $address = $query->fetch_array(MYSQLI_ASSOC); - $error = $this->app->DB->error(); - - if ($error) { - $error = htmlspecialchars($error); - $msg = sprintf('SQL query error: \'%s\', query was \'%s\'', $error, $sql); - throw new RuntimeException($msg); - } - - if (!is_array($address)) { - $type = gettype($address); - throw new ArgumentTypeException('Expected address as array, got ' . $type); - } - - return $address; - } - - /** - * Get the package weight from user input. - * - * @param array $packageData - * - * @throws RuntimeException - * - * @return float - */ - protected function getWeight($packageData) - { - if (!is_array($packageData)) { - $type = gettype($packageData); - throw new ArgumentTypeException('Expected package data as array, got ' . $type); - } - if (!array_key_exists('kg1', $packageData)) { - throw new RuntimeException('Weight (kg1) is missing.'); - } - - $weight = $packageData['kg1']; - if (empty($weight) && $weight !== '0') { - // wtf?! why is '0' string empty? - throw new RuntimeException('The package weight is required.'); - } - if (is_string($weight)) { - $weight = str_replace(',', '.', $weight); - if (is_numeric($weight)) { - $weight = (float)$weight; - } - } - if (!is_float($weight)) { - $type = gettype($weight); - throw new ArgumentTypeException('Expected weight as float, got ' . $type); - } - if ($weight < 0) { - throw new RuntimeException('A negative package weight is not supported.'); - } - - return $weight; - } - - /** - * Build an html select element. - * - * @param string $nameID Name and ID of select element. - * @param array $select associative array - * @param string|int|null|array $selected - * - * @return string - */ - protected function buildSelectForm($nameID, $select, $selected = null) - { - $options = []; - $nameID = htmlspecialchars($nameID); - - $options[] = sprintf(''; - - return implode('', $options); - } -} - -class ArgumentTypeException extends RuntimeException implements ParcelOneExceptionInterface -{ -} - -class ResponseException extends RuntimeException implements ParcelOneExceptionInterface -{ -} - -class NotImplementedException extends RuntimeException implements ParcelOneExceptionInterface -{ -} - -class EmptyResponseException extends ResponseException implements ParcelOneExceptionInterface -{ -} - -class MissingArgumentException extends RuntimeException implements ParcelOneExceptionInterface -{ -} - -class MissingResponseFieldException extends ResponseException implements ParcelOneExceptionInterface -{ - /** - * MissingResponseFieldException constructor. - * - * Change the exception message -> wrap it, so its enough to pass only the missed argument name. - * - * @param string $message - * @param int $code - * @param Throwable|null $previous - * - * @return static - */ - final public static function fromFieldName($message, $code = 0, Throwable $previous = null) - { - if (!$message || !is_string($message)) { - $message = 'A field is missing.'; - } - $message = sprintf('The field %s is missing.', $message); - - return new static($message, $code, $previous); - } -} - -class SoapExtensionMissingException extends RuntimeException implements ParcelOneExceptionInterface -{ -} - -if (!class_exists('SoapHeader')) { - /** - * This is just a fix, if php comes without the soap extension. - * - * So the following header classes can extend this class without raising an unhandled exception just by loading this - * file. A check if the soap extension exists is located in Versandart_parcelone::EinstellungenStruktur() so the - * user cannot setup this delivery service. In addition, a check is located in - * AbstractParcelOneRequest::__construct() so it's not possible to execute a soap request if the extension is - * missing. - * - * Class SoapHeader - */ - class SoapHeader - { - public function __construct($namespace, $name, $data = null, $mustunderstand = false, $actor = '') - { - } - } -} -/** - * Define some constants if the soap extension is not available so at least the class instantiation runs as expected. - * - * @url: https://www.php.net/manual/en/soap.constants.php - */ -defined('SOAP_1_1') or define('SOAP_1_1', 1); -defined('WSDL_CACHE_NONE') or define('WSDL_CACHE_NONE', 0); -defined('SOAP_COMPRESSION_GZIP') or define('SOAP_COMPRESSION_GZIP', 0); -defined('SOAP_COMPRESSION_ACCEPT') or define('SOAP_COMPRESSION_ACCEPT', 32); - -/** - * Headers from documentation package. - * - * classes: - * - AuthHeader - * - APIKeyHeader - * - CultureHeader - * - * Thanks to Jörk Sternsdorff from - * Awiwe Solutions GmbH - */ -class AuthHeader extends SoapHeader -{ - private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'; - private $wsu_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'; - - /** - * AuthHeader constructor. - * - * @param string $user - * @param string $pass - */ - public function __construct($user, $pass) - { - $created = gmdate('Y-m-d\TH:i:s\Z'); - $nonce = mt_rand(); - $passdigest = base64_encode(pack('H*', sha1(pack('H*', $nonce) . pack('a*', $created) . pack('a*', $pass)))); - - $auth = new stdClass(); - $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns); - $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns); - $auth->Nonce = new SoapVar($passdigest, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns); - $auth->Created = new SoapVar($created, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wsu_ns); - - $username_token = new stdClass(); - $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns); - - $security_sv = new SoapVar( - new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns), - SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns); - parent::__construct($this->wss_ns, 'Security', $security_sv, true); - } -} - -class APIKeyHeader extends SoapHeader -{ - public function __construct($apiKey) - { - parent::__construct('apikey', 'apikey', $apiKey, false); - } -} - -class CultureHeader extends SoapHeader -{ - public function __construct($culture) - { - parent::__construct('culture', 'culture', $culture, false); - } -} - -/** - * Class AbstractParcelOneRequest - * - * This class holds only some functionality to - * build up the soap request. It supports some - * methods to set required header. - * Nothing more. - * - * @package ParcelOne - */ -abstract class AbstractParcelOneRequest -{ - /* - * Support only PA1 as carrier. - */ - const DEFAULT_CARRIER = 'PA1'; - - /** - * this Key is used to identify this software and not the customer. - */ - const API_KEY = '0641C551-D23A-43BB-87A9-626DAE7FFE00'; - - /** - * The default software attribute is injected into every request. - * It's possible to 'override' this constant in child classes. - */ - const SOFTWARE = 'Xentral_ERP_Software'; - - const SERVICE = 'https://productionapi.awiwe.solutions/version4/shippingwcf/ShippingWCF.svc?wsdl'; - const SANDBOX_SERVICE = 'https://sandboxapi.awiwe.solutions/version4/shippingwcfsandbox/shippingWCF.svc?wsdl'; - - const ENDPOINT = 'https://productionapi.awiwe.solutions/version4/shippingwcf/ShippingWCF.svc/Shippingwcf'; - const SANDBOX_ENDPOINT = 'https://sandboxapi.awiwe.solutions/version4/shippingwcfsandbox/shippingWCF.svc/ShippingWCF'; - /** - * @var AbstractParcelOneRequest|ParcelOneRequest - */ - static private $instance = null; - /** - * The Mandator ID - * - * ID at PARCEL.ONE, usually '1', if only one mandator. - * - * @var int 1 - */ - protected $mandator = 1; - /** - * The Consigner ID - * - * ID at PARCEL.ONE, usually "1", if only one consigner. - * - * @var int - */ - protected $consigner = 1; - /** - * The carrier selected as second step in the settings. - * - * @var string default PA1 for Parcel.One - */ - protected $carrier = 'PA1'; - /** - * @var string The product chosen in the settings. - */ - protected $product = ''; - - /** - * Options for the SoapClient constructor. - * - * Note: this property is private. Also child classes have to use - * the setOption / deleteOption methods. - * - * @var array - */ - private $options = [ - 'soap_version' => SOAP_1_1, - 'exceptions' => true, - 'trace' => false, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, - 'location' => 'https://shippingwcf.awiwe.net/Shippingwcf.svc/Shippingwcf', - 'connection_timeout' => 300 - ]; - /** - * @var array of RequestHeaderInterface - */ - private $soapHeaders = []; - /** - * @var string - */ - private $url; - /** - * Cache here the created soap client. - * - * @var SoapClient - */ - private $client = null; - - /** - * ParcelOneRequest constructor. - * - * @param bool $production - * @param int $mandator - * @param int $consigner - */ - final private function __construct($production = false, $mandator = 1, $consigner = 1) - { - if (!class_exists('SoapClient')) { - throw new SoapExtensionMissingException('SOAP support is not configured.'); - } - - $this->mandator = $mandator; - $this->consigner = $consigner; - - $this->url = self::SANDBOX_SERVICE; - $this->options['location'] = self::SANDBOX_ENDPOINT; - if ($production) { - $this->url = self::SERVICE; - $this->options['location'] = self::ENDPOINT; - } - } - - /** - * Get the singleton. - * - * @param array $settings - * @return AbstractParcelOneRequest|ParcelOneRequest - */ - final public static function getInstance($settings = []) - { - if (self::$instance !== null) { - if (empty(self::$instance->carrier) && array_key_exists('carrier', $settings)) { - self::$instance->carrier = $settings['carrier']; - } - if (empty(self::$instance->product) && array_key_exists('product', $settings)) { - self::$instance->product = $settings['product']; - } - return self::$instance; - } - - $required = ['kdnr', 'password', 'sandbox']; - foreach ($required as $requirenment) { - if (!array_key_exists($requirenment, $settings)) { - throw new MissingArgumentException(sprintf( - 'Setting %s is missing.', $requirenment - )); - } - } - $required = array_flip($required); - $settings = array_intersect_key($settings, $required); - - $production = true; - if (array_key_exists('sandbox', $settings)) { - $production = $settings['sandbox'] !== '1'; - } - if (!array_key_exists('mandator', $settings)) { - $settings['mandator'] = 1; - } - $mandator = (int)$settings['mandator']; - $mandator = max(1, $mandator); - - if (!array_key_exists('consigner', $settings)) { - $settings['consigner'] = 1; - } - $consigner = (int)$settings['consigner']; - $consigner = max(1, $consigner); - - if (!array_key_exists('country', $settings)) { - $settings['country'] = 'de-DE'; - } - - $instance = new static($production, $mandator, $consigner); - $instance - ->addSoapHeader(new AuthHeader($settings['kdnr'], $settings['password'])) - ->addSoapHeader(new CultureHeader($settings['country'])) - ->addSoapHeader(new APIKeyHeader(self::API_KEY)); - - self::$instance = $instance; - - return $instance; - } - - /** - * Don't allow 'on the fly' calls. - * - * Only the implemented SOAP methods are supported. - * - * @param string $name - * @param array $arguments - * - * @throws NotImplementedException - * - * @return mixed - */ - final public function __call($name, $arguments) - { - $class = get_class($this); - $message = sprintf( - 'Method %s->%s is not implemented.', $class, $name - ); - - throw new NotImplementedException($message); - } - - /** - * Make one call to the PARCEL.ONE API - * - * @param string $name - * @param array $arguments - * - * @throws SoapFault - * - * @throws EmptyResponseException - * @return stdClass|mixed - */ - final protected function call($name, $arguments = null) - { - $client = $this->getClient(); - - if (!is_string($name)) { - $type = gettype($name); - throw new InvalidArgumentException(sprintf( - 'Expected method name as string, got %s.', $type - )); - } - - if ($arguments === null) { - $arguments = []; - } - if (!is_array($arguments)) { - $type = gettype($arguments); - throw new InvalidArgumentException(sprintf( - 'Expected %s\'s arguments as array, got %s.', $name, $type - )); - } - - $arguments['Software'] = self::SOFTWARE; - - /* - * Do some magic ;) - */ - $callback = [$client, $name]; - - // $response = call_user_func($callback, $arguments); - $response = $callback($arguments); - - if (empty($response)) { - $message = sprintf('Method %s returned empty body.', $name); - throw new EmptyResponseException($message); - } - - return $response; - } - - /** - * Return the SOAP client. - * - * Set it up, if not available now. - * - * @throws SoapFault - * - * @return SoapClient - */ - final protected function getClient() - { - $client = $this->client; - if ($client === null) { - $client = new SoapClient($this->url, $this->options); - $client->__setSoapHeaders($this->soapHeaders); - $this->client = $client; - } - - return $this->client; - } - - /** - * Convert the stdClass object into an array. - * - * This method uses recursive calls. - * - * Thanks to https://stackoverflow.com/a/18576919 - * - * @param stdClass|array $array - * - * @return array - */ - final protected function convert2array($array) - { - if (is_array($array)) { - foreach ($array as $key => $value) { - if (is_array($value)) { - $array[$key] = $this->convert2array($value); - } - if ($value instanceof stdClass) { - $array[$key] = $this->convert2array((array)$value); - } - } - } - if ($array instanceof stdClass) { - return $this->convert2array((array)$array); - } - return $array; - } - - /** - * @param SoapHeader $header - * - * @return $this - */ - private function addSoapHeader(SoapHeader $header) - { - $this->client = null; - $this->soapHeaders[] = $header; - return $this; - } -} - -/** - * Class ParcelOneRequest - * - * Implement here all API methods we support. - */ -class ParcelOneRequest extends AbstractParcelOneRequest -{ - /** - * Get available Products for a mandator and Carrier - * - * @param int|string $level : [0, 1, 2, ..] - * - 0 = all levels returned; - * - 1 = only 1 level returned (only products), - * - >=2 = 2 levels returned (products and services info) - * - * @throws SoapFault - * - * @return array|stdClass - */ - public function getProducts($level = 1) - { - $level = is_numeric($level) ? $level : 1; - $level = max(0, (int)$level); - - $arguments = [ - 'Mandator' => $this->mandator, // string, as field in settings? - 'level' => $level, // int - 'CEP' => $this->carrier, // string Carrier abbreviation (UPS, PA1 for Parcel One, ...). - ]; - - $response = $this->call(__FUNCTION__, $arguments); - - if (!isset($response->getProductsResult)) { - throw MissingResponseFieldException::fromFieldName('getProductsResult'); - } - if (!isset($response->getProductsResult->Product)) { - throw MissingResponseFieldException::fromFieldName('getProductsResult->Product'); - } - $response = $response->getProductsResult->Product; - $response = $this->convert2array($response); - - $products = []; - // get as first the default product - foreach ($response as $product) { - if (array_key_exists('Default', $product) && $product['Default']) { - $id = $product['ProductID']; - $name = $product['ProductName']; - - $products[$id] = $name; - } - } - // then add all other products - foreach ($response as $product) { - if (array_key_exists('Default', $product) && !$product['Default']) { - $id = $product['ProductID']; - $name = $product['ProductName']; - - $products[$id] = $name; - } - } - - return $products; - } - - /** - * Register Forward and Return Shipments. - * - * @param $shippingData - * - * @throws SoapFault - * - * @return array - */ - public function registerShipments($shippingData) - { - $default = [ - // MandatorID: required - Mandator ID at PARCEL.ONE, usually "1", if only one mandator. - 'MandatorID' => $this->mandator, - // ConsignerID: required - Consigner ID at PARCEL.ONE, usually "1", if only one consigner. - 'ConsignerID' => $this->consigner, - // CEPID: required - Carrier specification, possible values so far: UPS, PA1, DHL. - 'CEPID' => $this->carrier, - // Software: required - Software specification of client, if possible with version number. - 'Software' => self::SOFTWARE, - /* - * PrintDocuments: required - Flag to indicate, - * if Documents (for DHL also Export Documents) should be returned with this request - * (0=no, 1=yes). - */ - 'PrintDocuments' => 1, - // DocumentFormat: required - only Format.Type = "PDF" needed. - 'DocumentFormat' => ['Type' => 'PDF'], - // LabelFormat: required - only Format.Type = either "GIF" or "PDF" needed. - 'LabelFormat' => ['Type' => 'PDF'], - // PrintLabel: required - Flag to indicate, if Label should be returned with this request (0=no, 1=yes). - 'PrintLabel' => 1, - ]; - - $shippingData = array_merge($shippingData, $default); - $shippingData = ['ShippingData' => [$shippingData]]; - $response = $this->call(__FUNCTION__, $shippingData); - - if (!isset($response->registerShipmentsResult)) { - throw MissingResponseFieldException::fromFieldName('registerShipmentsResult'); - } - - $response = $this->convert2array($response); - - if (!isset($response['registerShipmentsResult'])) { - throw new ResponseException('Missing registerShipmentsResult response field.'); - } - $response = $response['registerShipmentsResult']; - - if (!isset($response['ShipmentResult'])) { - throw new ResponseException('Missing ShipmentResult response field.'); - } - $response = $response['ShipmentResult']; - - foreach ($response['ActionResult']['Errors'] as $e) { - if (!is_array($e)) { - continue; - } - if (!array_key_exists('Message', $e) || !$e['Message']) { - continue; - } - $msg = $e['Message']; - if (array_key_exists('StatusCode', $e) && $e['StatusCode']) { - $msg .= ' (' . (string)$e['StatusCode'] . ')'; - } - throw new ResponseException($msg); - } - - return $response; - } - - /** - * Get available Carriers for a mandator, optionally filtered by countries list. - * - * CEP[] getCEPs(string Mandator, int level, String[] Countries); - * - * @param int|string level: [0, 1, 2, ..] - * 0 = all levels returned; - * 1 = only 1 level returned (only products), - * >=2 = 2 levels returned (products and services info) - * - * @throws SoapFault - * - * @return array|stdClass - */ - public function getCEPs($level = 1) - { - $arguments = [ - 'Mandator' => $this->mandator, - 'level' => max(1, (int) $level), - ]; - - $response = $this->call(__FUNCTION__, $arguments); - - if (!isset($response->getCEPsResult)) { - throw new ResponseException('Missing getCEPsResult field.'); - } - - if (!isset($response->getCEPsResult->CEP)) { - throw new ResponseException('Missing CEP field.'); - } - - $response = $response->getCEPsResult->CEP; - $response = $this->convert2array($response); - - return $response; - } - - /** - * @throws SoapFault - */ - public function getServices() - { - $arguments = [ - 'Mandator' => $this->mandator, - 'CEP' => $this->carrier, - 'Product' => $this->product, - ]; - - $response = $this->call(__FUNCTION__, $arguments); - - if (!isset($response->getServicesResult)) { - throw MissingResponseFieldException::fromFieldName('getServicesResult'); - } - if (!isset($response->getServicesResult->Service)) { - throw MissingResponseFieldException::fromFieldName('getServicesResult::Service.'); - } - - $response = $response->getServicesResult->Service; - $response = $this->convert2array($response); - - $services = [ - '' => 'Kein Service' - ]; - // Search for the default service - foreach ($response as $service) { - if (array_key_exists('Default', $service) && $service['Default']) { - $id = $service['ServiceID']; - $name = $service['ServiceName']; - - $services[$id] = $name; - } - } - // Append all other services - foreach ($response as $service) { - if (array_key_exists('Default', $service) && ! $service['Default']) { - $id = $service['ServiceID']; - $name = $service['ServiceName']; - - $services[$id] = $name; - } - } - - return $services; - } - - // todo: implement here the necessary methods -} - -/** - * API from PARCEL.ONE - * - * Note: the class name is expected as: - * - * Versandart_{filename} - * - * Where {filename} is lowercase and without the '.php' extension. - * - * @url: https://parcel.one/en - * @url: https://parcel.one/en/api - */ -class Versandart_parcelone extends AbstractVersandartParcelone -{ - /** - * @inheritDoc - */ - public function GetBezeichnung() - { - return 'PARCEL.ONE'; - } - - protected function ctrHook() - { - $current = [ - 'kdnr' => $this->app->Secure->GetPOST('kdnr'), - 'password' => $this->app->Secure->GetPOST('password'), - 'carrier_product' => $this->app->Secure->GetPOST('carrier_product'), - ]; - $current = array_filter($current); - // $this->einstellungen += $current; - $this->einstellungen = array_merge($this->einstellungen, $current); - - if (array_key_exists('carrier_product', $this->einstellungen)) { - list($carrier, $product) = explode('.', $this->einstellungen['carrier_product']); - $this->einstellungen['carrier'] = $carrier; - $this->einstellungen['product'] = $product; - } - } - - /** - * @inheritDoc - */ - protected function EinstellungenStruktur() - { - if (!class_exists('SoapClient')) { - $message = 'PHP SOAP Extension ist nicht konfiguriert. Diese Versandart kann nicht genutzt werden.'; - $this->app->Tpl->Add('MESSAGE', sprintf('
          %s
          ', $message)); - - return []; - } - - $select = []; - $settings = array_filter($this->einstellungen); -// $this->app->Tpl->Add('MESSAGE', '
          ' . json_encode($this->einstellungen) . '
          '); -// $this->app->Tpl->Add('MESSAGE', '
          ' . json_encode($settings) . '
          '); - - try { - if (!empty($settings)) { - $carriers = []; - if (!array_key_exists('kdnr', $settings) || !array_key_exists('password', $settings)) { - $this->app->Tpl->Add('MESSAGE', '
          ' . 'Bitte gültige API-Zugangsdaten angeben' . '
          '); - } else { - $request = ParcelOneRequest::getInstance($this->einstellungen); - $carriers = $request->getCEPs(2); - if (!array_key_exists('carrier_product', $settings)) { - $this->app->Tpl->Add('MESSAGE', '
          API-Key erfolgreich überprüft
          '); - } - } - - if (!array_key_exists(0, $carriers)) { - // i'm not sure about the structure if multiple carriers are available. - $tmp = $carriers; - $carriers = []; - $carriers[] = $tmp; - unset($tmp); - } - - foreach ($carriers as $carrier) { - $cepID = $carrier['CEPID']; - $cepName = $carrier['CEPLongname']; - - foreach ($carrier['Products']['Product'] as $product) { - $productID = $product['ProductID']; - $productName = $product['ProductName']; - - $select[$cepID . '.' . $productID] = $cepName . ': ' . $productName; - } - } - } - }catch (Exception $e) { - $this->app->Tpl->Add('MESSAGE', '
          ' . $e->getMessage() . '
          '); - $select = []; - } - - if (empty($select)) { - $select = ['Bitte Zugangsdaten berichtigen']; - } else if (!array_key_exists('carrier_product', $settings)) { - $this->app->Tpl->Add('MESSAGE', '
          Bitte ein Produkt wählen
          '); - } else { - $tmp = []; - $firstID = $settings['carrier_product']; - // add the chosen one as first element to $tmp - foreach ($select as $id => $name) { - if ($id === $firstID) { - $tmp[$id] = $name; - } - } - // append all other elements - foreach ($select as $id => $name) { - if ($id !== $firstID) { - $tmp[$id] = $name; - } - } - $select = $tmp; - unset($tmp); - } - - return [ - 'kdnr' => [ - 'typ' => 'text', - 'bezeichnung' => 'Kundennummer:', - 'size' => 40, - ], - 'password' => [ - 'typ' => 'text', - 'bezeichnung' => 'Passwort:', - 'size' => 40, - ], - 'country' => [ - 'typ' => 'text', - 'bezeichnung' => 'Absender Land:', - 'size' => 2, - 'placeholder' => 'DE', - 'default' => 'DE', - 'regex' => '^[A-Z]{2}$' - ], - 'international' => [ - 'size' => 40, - 'typ' => 'select', - 'default' => 'CN23', - 'bezeichnung' => 'Zolldokumente:', - 'optionen' => [ - '' => 'Nicht benötigt', - 'CN22' => 'CN22', - 'CN23' => 'CN23', - ], - ], - 'ref1' => [ - 'size' => 40, - 'typ' => 'text', - 'default' => '', - 'bezeichnung' => 'Referenz 1:', - 'placeholder' => 'Referenz 1 auf Label', - 'info'=>'{LIEFERSCHEIN}, {AUFTRAG}, {PROJEKT}, {IHREBESTELLNUMMER}, {INTERNET}', - ], - 'ref2' => [ - 'size' => 40, - 'typ' => 'text', - 'default' => '', - 'bezeichnung' => 'Referenz 2:', - 'placeholder' => 'Referenz 2 auf Label', - 'info'=>'{LIEFERSCHEIN}, {AUFTRAG}, {PROJEKT}, {IHREBESTELLNUMMER}, {INTERNET}', - ], - 'carrier_product' => [ - 'size' => 40, - 'typ' => 'select', - 'bezeichnung' => 'Spediteur & Produkt:', - 'optionen' => $select, - ], - 'standardgewicht' => [ - 'size' => 40, - 'typ' => 'text', - 'bezeichnung' => 'Standardgewicht' - ], - 'autotracking' => [ - 'typ' => 'checkbox', - 'bezeichnung' => 'Tracking übernehmen:' - ], - 'sandbox' => [ - 'typ' => 'checkbox', - 'bezeichnung' => 'Sandbox Anbindung:' - ], - ]; - } - - /** - * @inheritDoc - * - * @throws SoapFault - */ - protected function parseTemplate($target) - { - if (!array_key_exists('carrier', $this->einstellungen)) { - $this->app->Tpl->Add('MESSAGE', '
          Bitte die Einstellungen vervollständigen.
          '); - } else { - $request = ParcelOneRequest::getInstance($this->einstellungen); - - $services = $request->getServices(); - unset($services['']); - - $html = ''; - $frame = '
          '; - foreach ($services as $id => $service) { - $html .= sprintf($frame, $id, $id, $id, $service); - } - $services = $html; - - $this->app->Tpl->Set('SERVICE', $services); - } - $this->app->Tpl->Parse($target, 'versandarten_parcelone.tpl'); - } - - public function VersandartMindestgewicht() - { - if(!empty($this->einstellungen['standardgewicht'])){ - return str_replace(',','.',$this->einstellungen['standardgewicht']); - } - return 0; - } - - /** - * @inheritDoc - * - * @throws SoapFault - */ - protected function createPaketmarke($doctyp, $id, $target, $error, $adressdaten, $packageData) - { - $versandId = $doctyp==='versand'?$id:0; - if (!array_key_exists('carrier', $this->einstellungen)) { - $this->app->Tpl->Add('MESSAGE', '
          Bitte die Einstellungen vervollständigen.
          '); - return false; - } - - // lieferschein, retoure & versand contain all an 'adresse' field. - $document = $this->getDocumentByID($doctyp, $id); - if (!array_key_exists('adresse', $document)) { - throw new MissingArgumentException(sprintf( - 'Missed field for adresse in %s.', $doctyp - )); - } - - $lieferscheinID = $id; - if (array_key_exists('lieferscheinid', $document)) { - $lieferscheinID = $document['lieferscheinid']; - } - - $address = $this->loadAddress($document['adresse']); - $items = $this->loadDeliveryPositions($id, $doctyp); - - $auftragnummer = $this->getAuftragNummer($lieferscheinID); - $projektabkuerzung = $this->getProjectShortName($lieferscheinID); - // Source: ups.php - $ihrebestellnummer = $this->app->DB->Select("SELECT ihrebestellnummer FROM lieferschein WHERE id='$lieferscheinID' LIMIT 1"); - $lieferscheinnummer = $this->app->DB->Select("SELECT belegnr FROM lieferschein WHERE id='$lieferscheinID' LIMIT 1"); - $internet = $this->app->DB->Select("SELECT a.internet FROM lieferschein l LEFT JOIN auftrag a ON a.id=l.auftragid WHERE l.id='$lieferscheinID' LIMIT 1"); - - $replacer = new ParcelOneReplacer([ - 'IHREBESTELLNUMMER' => $ihrebestellnummer, - 'LIEFERSCHEIN' => $lieferscheinnummer, - 'PROJEKT' => $projektabkuerzung, - 'AUFTRAG' => $auftragnummer, - 'INTERNET' => $internet - ]); - - /* - * ShipTo Reference provided by client, string, max length 20 - */ - $clientsReference = $this->einstellungen['ref2']; - $clientsReference = $replacer->handle((string) $clientsReference); - $clientsReference = substr($clientsReference, 0, 20); - - /* - * Private Address = 1, B2B = 0 - */ - $private = $address['firma'] !== '1' ? 1 : 0; - /* - * ReturnShipmentIndicator: required - - * 0 = Forward Shipment, - * all values > 0 = Return Shipment. - * - * For UPS the following are available: - * 2-Print and Mail Return Label by UPS; - * 3-Return Service 1-Attempt; - * 5-Return Service 3-Attempt; - * 8-Electronic Return Label by URL; - * 9-Print Return Label. - * - * For DHL and Parcel One so far not available. - * - * We only support Parcel One, so: - * 0 -> forward, - * 1 -> return - */ - $returnShipment = (int)$doctyp === 'retoure'; - /* - * Parcel ID assigned at Shipping. - * will be reassigned at successfully shipping. - */ - $packageID = ''; - /* - * Shipment Reference field provided by client for identification, string, max length 20. - */ - $shipmentRef = $this->einstellungen['ref1']; // $packageData['shipment_reference']; - $shipmentRef = $replacer->handle((string) $shipmentRef); - $shipmentRef = substr($shipmentRef, 0, 20); - - /* - * Certificate No to print on CN23. - */ - $certificateNo = ''; - /* - * optional - Invoice No to print on CN23. max. length: 20 - * $lieferschein['belegnummer'] // 'ihrebestellnummer' - */ - $invoiceNo = ''; - /* - * optional item category - * possible values: - * - 1: Gift - * - 2: Documents - * - 3: Commercial Sample - * - 4: Returned Goods - * - 5: Other - */ - $itemCategory = $returnShipment ? 4 : 5; - - $weight = $this->getWeight($packageData); - if (!$weight) { - foreach ($items as $item) { - $weight += (float) $item['NetWeight']; - } - } - $weight = number_format($weight, 3); - - $product = $this->einstellungen['product']; - $international = $this->getInternationalDocumentType($adressdaten['land']); - - $destinationCountry = $adressdaten['land']; - $originCountry = $this->einstellungen['country']; - $printInternationalDocuments = 0; - if($destinationCountry != $originCountry){ - $printInternationalDocuments = (int)(!$this->app->erp->IsEU($destinationCountry)); - } - - $shipment = [ - 'ProductID' => $product, - 'ShipmentRef' => $shipmentRef, - 'ReturnShipmentIndicator' => $returnShipment, - 'ShipToData' => [ - 'Name1' => $adressdaten['name'], - 'Name2' => $adressdaten['name2'], - 'Name3' => $adressdaten['name3'], - /* - * PrivateAddressIndicator: optional/required - * - 1 Private Address, - * - 0 B2B-Address. - */ - 'PrivateAddressIndicator' => $private, - 'ShipmentAddress' => [ - 'City' => $adressdaten['ort'], - 'PostalCode' => $adressdaten['plz'], - 'Street' => $adressdaten['street'], - 'Streetno' => $adressdaten['street_no'], - 'Country' => $adressdaten['land'], -// 'State' => '', -// 'District' => '', - ], - 'Reference' => $clientsReference, - ], - 'Packages' => [ - [ - 'PackageWeight' => [ - 'Value' => $weight, - ], - 'PackageID' => $packageID, - 'IntDocData' => [ - 'ContentsDesc' => $items, - 'ShipToRef' => $shipmentRef, - 'ItemCategory' => $itemCategory, - 'InvoiceNo' => (string)$invoiceNo, - 'Invoice' => (int)(bool)$invoiceNo, - 'PrintInternationalDocuments' => (int) ! empty($international), - 'Explanation' => $clientsReference, - 'ConsignerCustomsID' => '', - 'CertificateNo' => (string)$certificateNo, - 'Certificate' => (int)(bool)$certificateNo, - 'TotalWeightkg' => $weight, // $weight, // '34.000', // "34.000", - // 'Postage' => '2.45', // "2.45", // optional - Postage Amount // Porto - 'InternationalDocumentFormat' => [ - 'Type' => 'PDF', - 'Size' => $international, - ], - ], - ], - ], - ]; - - $service = $packageData['service']; - if (!empty($service) && is_array($service)) { - $services = []; - foreach ($service as $serviceID) { -// Parameter Services - Array of ShipmentService: -// Parameters: optional - so far not in use, for future use. -// ServiceID: required - Service ID, e.g. NN for COD, WERT for insurance, SA for Saturday Delivery, etc. -// Value: optional - Currency and Value specification, e.g. for Insurance or COD. Exception for DHL-BulkyGoods: Amount determines kind of bulkgoods: 0=Lang, 1=L, 2=XL, 3=XXL, default=XXL - $services[] = ['ServiceID' => $serviceID]; - } - $shipment['Services'] = $services; - } - - $request = ParcelOneRequest::getInstance($this->einstellungen); - $response = $request->registerShipments($shipment); - - if (!array_key_exists('ActionResult', $response)) { - throw MissingResponseFieldException::fromFieldName('ActionResult'); - } - $number = $this->extractActionResultID($response); - - if ($this->einstellungen['autotracking'] === '1') { - $lieferscheinID = $id; - if (array_key_exists('lieferschein', $document)) { - $lieferscheinID = $document['lieferschein']; - } - $versandID = $doctyp === 'versand' ? $id : 0; - $this->SetTracking($number, $versandID, $lieferscheinID); - unset($versandID, $lieferscheinID); - } - - if (!$packageData['drucken'] && !$packageData['tracking_again']) { - return []; - } - - /* - * Let's print the two documents. - */ - if (array_key_exists('LabelsAvailable', $response) && $response['LabelsAvailable'] === 1) { - $label = 'Label_' . $number . '.pdf'; - $content = $response['PackageResults']['ShipmentPackageResult']['Label']; - $content = base64_decode($content, true); - $this->printFile($label, $content, $versandId); - unset($label, $content); - } - - if (array_key_exists('InternationalDocumentsNeeded', $response) && - array_key_exists('InternationalDocumentsResults', $response) && - array_key_exists('InternationalDocumentsAvailable', $response) && - is_array($response['InternationalDocumentsResults']) && - !empty($response['InternationalDocumentsResults']) && - $response['InternationalDocumentsNeeded'] === 1 && - $response['InternationalDocumentsAvailable'] === 1 && !empty($response['InternationalDocumentsResults'])) { - - $internationalFile = $international . '_' . $number . '.pdf'; - $content = $response['InternationalDocumentsResults']['ShipmentDocumentsResult']['Document']; - - $content = base64_decode($content, true); - $this->printFile($internationalFile, $content, $versandId); - } - - return []; - } - - /** - * Get the custom documents format. - * - * @param string $country like 'DE' - * - * @return string of '', 'CN22' or 'CN23'; - */ - protected function getInternationalDocumentType($country) - { - $senderCountry = $this->app->erp->Firmendaten('land'); - if ($country === $senderCountry) { - // no custom documents required - return ''; - } - if ($this->app->erp->IstEU($country)) { - // no custom documents required - return ''; - } - - $international = $this->einstellungen['international']; - if (in_array($international, ['CN22', 'CN23'], true)) { - return $international; - } - - return 'CN23'; - } - - /** - * Load contents & quantity for all items of one delivery. - * - * @param int|string $id delivery note id - * @param string $table - * - * @return array - */ - private function loadDeliveryPositions($id, $table) - { - if (is_string($id) && is_numeric($id)) { - $id = (int)$id; - } - if (!is_int($id)) { - $type = gettype($id); - throw new ArgumentTypeException('Expected order id as int, got ' . $type); - } -// $sql = ' -//SELECT -// lp.menge, -// lp.bezeichnung, -// if(lp.zolleinzelwert >0 , lp.zolleinzelwert , ( ap.preis - (ap.preis / 100 * ap.rabatt ) ) ) as preis, -// lp.zolltarifnummer, -// if(lp.zollwaehrung != \'\' , lp.zollwaehrung, ap.waehrung) as waehrung, -// lp.artikel, -// lp.zolltarifnummer -//FROM -// lieferschein_position lp -//LEFT JOIN -// auftrag_position ap -//ON -// ap.id = lp.auftrag_position_id -// LEFT JOIN -// artikel a -// ON -// a.id = lp.artikel -// WHERE -// lp.lieferschein=\'%s\' -// AND -// ap.explodiert != 1 -// AND -// a.lagerartikel = 1'; - switch ($table) { - case 'versand': - $sql = ' -SELECT - lp.bezeichnung as Contents, - lp.menge as Quantity, - lp.zollgesamtgewicht as NetWeight, - lp.zollgesamtwert as ItemValue, - lp.herkunftsland as Origin, - lp.zolltarifnummer as TariffNumber, - lp.zollwaehrung as Currency -FROM - lieferschein_position as lp, - versand as v -WHERE - lp.lieferschein = v.lieferschein -AND - v.id =\'%s\''; - break; - case 'lieferschein': - $sql = ' -SELECT - bezeichnung as Contents, - menge as Quantity, - zollgesamtgewicht as NetWeight, - zollgesamtwert as ItemValue, - herkunftsland as Origin, - zolltarifnummer as TariffNumber, - zollwaehrung as Currency -FROM - lieferschein_position -WHERE - lieferschein =\'%s\''; - break; - case 'retoure': - $sql = ' -SELECT - bezeichnung as Contents, - menge as Quantity, - herkunftsland as Origin, - zolltarifnummer as TariffNumber -FROM - retoure_position -WHERE - retoure =\'%s\''; -// zolleinzelgewicht as NetWeight, -// zolleinzelwert as ItemValue, -// zollwaehrung as Currency - break; - case 'auftrag': - $sql = ' -SELECT - bezeichnung as Contents, - menge as Quantity, - zollgesamtgewicht as NetWeight, - zollgesamtwert as ItemValue, - herkunftsland as Origin, - zolltarifnummer as TariffNumber, - zollwaehrung as Currency -FROM - auftrag_position -WHERE - auftrag =\'%s\''; - break; - default: - throw new InvalidArgumentException(sprintf('Unknown table \'%s\'.', $table)); - } - - $sql = sprintf($sql, $id); - - $positions = $this->app->DB->Query($sql); - $error = $this->app->DB->error(); - - if ($error) { - $error = htmlspecialchars($error); - $msg = sprintf('SQL query error: \'%s\', query was \'%s\'', $error, $sql); - throw new RuntimeException($msg); - } - - $positions = $positions->fetch_all(MYSQLI_ASSOC); - $error = $this->app->DB->error(); - if ($error) { - $error = htmlspecialchars($error); - $msg = sprintf('SQL query error: \'%s\', query was \'%s\'', $error, $sql); - throw new RuntimeException($msg); - } - - if (!is_array($positions)) { - $type = gettype($positions); - throw new ArgumentTypeException('Expected positions as array, got ' . $type); - } - - return (array)$positions; - } - - /** - * Return a tracking number / package id - * - * @param $response - * - * @throws MissingResponseFieldException - * - * @return string|int - */ - private function extractActionResultID($response) - { - $number = null; - if (!is_array($response)) { - $type = gettype($response); - throw new ArgumentTypeException('Expected response as array, got ' . $type); - } - if (!array_key_exists('ActionResult', $response)) { - throw new MissingResponseFieldException('Field \'ActionResult\' in response is missing'); - } - - $actionResult = $response['ActionResult']; - if (array_key_exists('TrackingID', $actionResult)) { - return $actionResult['TrackingID']; - } - if (array_key_exists('ShipmentID', $actionResult)) { - return $actionResult['ShipmentID']; - } - if (array_key_exists('ShipmentRef', $actionResult)) { - return $actionResult['ShipmentRef']; - } - - throw MissingResponseFieldException::fromFieldName('TrackingID/ShipmentID/ShipmentRef is missing.'); - } - - /** - * Source: ups.php - * - * @param int $lieferscheinID - * @return string - */ - public function getProjectShortName($lieferscheinID) - { - $projekt = $this->app->DB->Select("SELECT projekt FROM lieferschein WHERE id='$lieferscheinID' LIMIT 1"); - return $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id='$projekt' LIMIT 1"); - } - - /** - * Source: ups.php - * - * @param int $lieferscheinID - * @return int - */ - public function getAuftragNummer($lieferscheinID) - { - $auftragid = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id='$lieferscheinID' LIMIT 1"); - if ($auftragid > 0 ) { - return $this->app->DB->Select("SELECT belegnr FROM auftrag WHERE id='$auftragid' LIMIT 1"); - } - - return ''; - } -} diff --git a/www/lib/versandarten/ppl_480.csv b/www/lib/versandarten/ppl_480.csv deleted file mode 100644 index 43fddcc4..00000000 --- a/www/lib/versandarten/ppl_480.csv +++ /dev/null @@ -1,90 +0,0 @@ -01.01.2021;;1;N;Standardbrief;0,8;Standardbrief;0,8;;;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 20 g. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;;11;N;Kompaktbrief;0,95;Kompaktbrief;0,95;;;100;70;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 50 g. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;;21;N;Großbrief;1,55;Großbrief;1,55;;;100;70;0;353;250;20;0;500;;;;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 500 g.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;;31;N;Maxibrief;2,7;Maxibrief;2,7;;;100;70;0;353;250;50;0;1000;;;;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 1000 g.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;;41;N;Maxibrief bis 2000 g + Zusatzentgelt MBf;4,9;Maxibrief;2,7;Zusatzentgelt MBf;2,2;100;70;0;600;300;150;0;2000;;;Höchstmaße alternativ: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 2000 g mit einem Überformat.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;;51;N;Postkarte;0,6;Postkarte;0,6;;;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/brief_postkarte.html;nein;nein -01.01.2021;1;195;N;Standardbrief + Prio;1,8;Standardbrief;0,8;Prio;1;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Kombi-Produkt aus Standardbrief (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;1;196;N;Kompaktbrief + Prio;1,95;Kompaktbrief;0,95;Prio;1;100;70;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Kombi-Produkt aus Kompaktbrief (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;1;197;N;Großbrief + Prio;2,55;Großbrief;1,55;Prio;1;100;70;0;353;250;20;0;500;;;;Kombi-Produkt aus Großbrief (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;1;198;N;Maxibrief + Prio;3,7;Maxibrief;2,7;Prio;1;100;70;0;353;250;50;0;1000;;;;Kombi-Produkt aus Maxibrief (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;1;199;N;Maxibrief bis 2000 g + Zusatzentgelt MBf + Prio;5,9;Maxibrief;2,7;Zusatzentgelt MBf + Prio;3,2;100;70;0;600;300;150;0;2000;;;Höchstmaße alternativ: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Kombi-Produkt aus Maxibrief bis 2000 g mit einem Überformat (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;1;200;N;Postkarte + Prio;1,6;Postkarte;0,6;Prio;1;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Kombi-Produkt aus Postkarte (umsatzsteuerfrei) und Zusatzleistung Prio (umsatzsteuerfrei). Sendungsverfolgung per T&T. Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/p/prio.html;nein;nein -01.01.2021;;282;N;Bücher- und Warensendung 500;1,9;BÜCHER- UND WARENSENDUNG 500;1,9;;;100;70;0;353;250;50;0;500;;;;Preis nach UStG umsatzsteuerfrei. Bücher- und Warenversand bis 500 g, 35,3 x 25 x 5 cm. Zustellung bis 4 Werktage. Verschlossener Versand. Keine brieflichen Mitteilungen.;https://www.deutschepost.de/de/w/buecherundwarensendung.html;nein;nein -01.01.2021;;290;N;Bücher- und Warensendung 1000;2,2;BÜCHER- UND WARENSENDUNG 1000;2,2;;;100;70;0;353;250;50;501;1000;;;;Preis nach UStG umsatzsteuerfrei. Bücher- und Warenversand bis 1000 g, 35,3 x 25 x 5 cm. Zustellung bis 4 Werktage. Verschlossener Versand. Keine brieflichen Mitteilungen.;https://www.deutschepost.de/de/w/buecherundwarensendung.html;nein;nein -01.01.2021;;401;N;Streifbandzeitung bis 50 g;0,89;Streifbandzeitung bis 50 g;0,89;;;140;90;0;353;250;50;0;50;;;Einlieferung in Filiale oder Großannahmestelle, bei mehr als 500 Stück immer in Großannahmestelle. Mit Produkt- oder Internetmarke ist die Einlieferung über Briefkasten möglich.;Nutzung exklusiv für Vertragspartner der Deutsche Post Presse Distribution oder gewerbliche Einrichtungen des Pressehandels.;https://www.deutschepost.de/de/p/presse-distribution/produkte/streifbandzeitung.html;nein;nein -01.01.2021;;402;N;Streifbandzeitung bis 100 g;1,19;Streifbandzeitung über 50 g bis 100 g;1,19;;;140;90;0;353;250;50;51;100;;;Einlieferung in Filiale oder Großannahmestelle, bei mehr als 500 Stück immer in Großannahmestelle. Mit Produkt- oder Internetmarke ist die Einlieferung über Briefkasten möglich.;Nutzung exklusiv für Vertragspartner der Deutsche Post Presse Distribution oder gewerbliche Einrichtungen des Pressehandels.;https://www.deutschepost.de/de/p/presse-distribution/produkte/streifbandzeitung.html;nein;nein -01.01.2021;;403;N;Streifbandzeitung bis 250 g;1,37;Streifbandzeitung über 100 g bis 250 g;1,37;;;140;90;0;353;250;50;101;250;;;Einlieferung in Filiale oder Großannahmestelle, bei mehr als 500 Stück immer in Großannahmestelle. Mit Produkt- oder Internetmarke ist die Einlieferung über Briefkasten möglich.;Nutzung exklusiv für Vertragspartner der Deutsche Post Presse Distribution oder gewerbliche Einrichtungen des Pressehandels.;https://www.deutschepost.de/de/p/presse-distribution/produkte/streifbandzeitung.html;nein;nein -01.01.2021;;404;N;Streifbandzeitung bis 500 g;1,67;Streifbandzeitung über 250 g bis 500 g;1,67;;;140;90;0;353;250;50;251;500;;;Einlieferung in Filiale oder Großannahmestelle, bei mehr als 500 Stück immer in Großannahmestelle. Mit Produkt- oder Internetmarke ist die Einlieferung über Briefkasten möglich.;Nutzung exklusiv für Vertragspartner der Deutsche Post Presse Distribution oder gewerbliche Einrichtungen des Pressehandels.;https://www.deutschepost.de/de/p/presse-distribution/produkte/streifbandzeitung.html;nein;nein -01.01.2021;;405;N;Streifbandzeitung bis 1000 g;2,5;Streifbandzeitung über 500 g bis 1000 g;2,5;;;140;90;0;353;250;50;501;1000;;;Einlieferung in Filiale oder Großannahmestelle, bei mehr als 500 Stück immer in Großannahmestelle. Mit Produkt- oder Internetmarke ist die Einlieferung über Briefkasten möglich.;Nutzung exklusiv für Vertragspartner der Deutsche Post Presse Distribution oder gewerbliche Einrichtungen des Pressehandels.;https://www.deutschepost.de/de/p/presse-distribution/produkte/streifbandzeitung.html;nein;nein -01.01.2021;1;1002;N;Standardbrief Integral + EINSCHREIBEN EINWURF;3;Standardbrief;0,8;EINSCHREIBEN EINWURF;2,2;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Standardbrief bis 20 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1007;N;Standardbrief Integral + EINSCHREIBEN;3,3;Standardbrief;0,8;EINSCHREIBEN;2,5;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Standardbrief bis 20 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1009;N;Standardbrief Integral + EINSCHREIBEN + EIGENHÄNDIG;5,5;Standardbrief;0,8;EINSCHREIBEN + EIGENHÄNDIG;4,7;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Standardbrief bis 20 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1012;N;Kompaktbrief Integral + EINSCHREIBEN EINWURF;3,15;Kompaktbrief;0,95;EINSCHREIBEN EINWURF;2,2;100;70;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Kompaktbrief bis 50 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1017;N;Kompaktbrief Integral + EINSCHREIBEN;3,45;Kompaktbrief;0,95;EINSCHREIBEN;2,5;100;70;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Kompaktbrief bis 50 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1019;N;Kompaktbrief Integral + EINSCHREIBEN + EIGENHÄNDIG;5,65;Kompaktbrief;0,95;EINSCHREIBEN + EIGENHÄNDIG;4,7;100;70;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Kompaktbrief bis 50 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1022;N;Großbrief Integral + EINSCHREIBEN EINWURF;3,75;Großbrief;1,55;EINSCHREIBEN EINWURF;2,2;100;70;0;353;250;20;0;500;;;;Preis nach UStG umsatzsteuerfrei. Ein Großbrief bis 500 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1027;N;Großbrief Integral + EINSCHREIBEN;4,05;Großbrief;1,55;EINSCHREIBEN;2,5;100;70;0;353;250;20;0;500;;;;Preis nach UStG umsatzsteuerfrei. Ein Großbrief bis 500 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1029;N;Großbrief Integral + EINSCHREIBEN + EIGENHÄNDIG;6,25;Großbrief;1,55;EINSCHREIBEN + EIGENHÄNDIG;4,7;100;70;0;353;250;20;0;500;;;;Preis nach UStG umsatzsteuerfrei. Ein Großbrief bis 500 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1032;N;Maxibrief Integral + EINSCHREIBEN EINWURF;4,9;Maxibrief;2,7;EINSCHREIBEN EINWURF;2,2;100;70;0;353;250;50;0;1000;;;;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 1000 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1037;N;Maxibrief Integral + EINSCHREIBEN;5,2;Maxibrief;2,7;EINSCHREIBEN;2,5;100;70;0;353;250;50;0;1000;;;;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 1000 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1039;N;Maxibrief Integral + EINSCHREIBEN + EIGENHÄNDIG;7,4;Maxibrief;2,7;EINSCHREIBEN + EIGENHÄNDIG;4,7;100;70;0;353;250;50;0;1000;;;;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 1000 g, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1042;N;Maxibrief Integral + Zusatzentgelt MBf + EINSCHREIBEN EINWURF;7,1;Maxibrief;2,7;Zusatzentgelt MBf + EINSCHREIBEN EINWURF;4,4;100;70;0;600;300;150;0;2000;;;Höchstmaße alternativ: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 2000 g mit einem Überformat, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1047;N;Maxibrief Integral + Zusatzentgelt MBf + EINSCHREIBEN;7,4;Maxibrief;2,7;Zusatzentgelt MBf + EINSCHREIBEN;4,7;100;70;0;600;300;150;0;2000;;;Höchstmaße alternativ: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 2000 g mit einem Überformat, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1049;N;Maxibrief Integral + Zusatzentgelt MBf + EINSCHREIBEN + EIGENHÄNDIG;9,6;Maxibrief;2,7;Zusatzentgelt MBf + EINSCHREIBEN + EIGENHÄNDIG;6,9;100;70;0;600;300;150;0;2000;;;Höchstmaße alternativ: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief bis 2000 g mit einem Überformat, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1052;N;Postkarte Integral + EINSCHREIBEN EINWURF;2,8;Postkarte;0,6;EINSCHREIBEN EINWURF;2,2;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Eine Postkarte, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 20 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1057;N;Postkarte Integral + EINSCHREIBEN;3,1;Postkarte;0,6;EINSCHREIBEN;2,5;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Eine Postkarte, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;1;1059;N;Postkarte Integral + EINSCHREIBEN + EIGENHÄNDIG;5,3;Postkarte;0,6;EINSCHREIBEN + EIGENHÄNDIG;4,7;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Eine Postkarte, Zustellnachweis durch Postmitarbeiter, Sendungsverfolgung per T&T, Haftung bis 25 EUR, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/e/einschreiben.html;nein;nein -01.01.2021;;10001;I;Standardbrief Intern. GK;1,1;Standardbrief Intern. GK;1,1;;;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 20 g. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;;10011;I;Kompaktbrief Intern. GK;1,7;Kompaktbrief Intern. GK;1,7;;;140;90;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 50 g. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;;10051;I;Großbrief Intern. GK;3,7;Großbrief Intern. GK;3,7;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 500 g. Keine Seite länger als 600 mm.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;;10071;I;Maxibrief Intern. bis 1.000g GK;7;Maxibrief Intern. bis 1.000g GK;7;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 1000 g. Keine Seite länger als 600 mm.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;;10091;I;Maxibrief Intern. bis 2.000g GK;17;Maxibrief Intern. bis 2.000g GK;17;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände bis 2000 g. Keine Seite länger als 600 mm.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;1;10162;I;Brief Kilotarif international ohne USt + EINSCHREIBEN;4,29;Frankierung Brief Kilotarif Stückentgelt;0,79;EINSCHREIBEN;3,5;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-international-kilotarif.html;ja;nein -01.01.2021;;10166;I;Brief Kilotarif international ohne USt.;0,79;Frankierung Brief Kilotarif Stückentgelt;0,79;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Für Briefe, Schriftstücke und kleinere Gegenstände. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-international-kilotarif.html;ja;nein -01.01.2021;;10201;I;Postkarte Intern. GK;0,95;Postkarte Intern. GK;0,95;;;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Die Länge muss mindestens das 1,4-fache der Breite betragen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/brief-postkarte-international.html;nein;nein -01.01.2021;;10246;I;Warenpost International XS;3,8;Warenpost International XS;3,8;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10247;I;Warenpost International S;5;Warenpost International S;5;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10248;I;Warenpost International M;9;Warenpost International M;9;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10249;I;Warenpost International L;19,9;Warenpost International L;19,9;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10250;I;Warenpost International XS Tracked;6,15;Warenpost International XS Tracked;6,15;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10251;I;Warenpost International S Tracked;7,35;Warenpost International S Tracked;7,35;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10252;I;Warenpost International M Tracked;11,35;Warenpost International M Tracked;11,35;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10253;I;Warenpost International L Tracked;22,25;Warenpost International L Tracked;22,25;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10254;I;Warenpost International XS (EU/USt.);3,81;Warenpost International XS (EU/USt.);3,81;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10255;I;Warenpost International S (EU/USt.);4,4;Warenpost International S (EU/USt.);4,4;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10256;I;Warenpost International M (EU/USt.);8,33;Warenpost International M (EU/USt.);8,33;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10257;I;Warenpost International L (EU/USt.);20,23;Warenpost International L (EU/USt.);20,23;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10258;I;Warenpost International XS Tracked (EU/USt.);6,6;Warenpost International XS Tracked (EU/USt.);6,6;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10259;I;Warenpost International S Tracked (EU/USt.);7,2;Warenpost International S Tracked (EU/USt.);7,2;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10260;I;Warenpost International M Tracked (EU/USt.);11,13;Warenpost International M Tracked (EU/USt.);11,13;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;1;10261;I;Warenpost International L Tracked (EU/USt.);23,03;Warenpost International L Tracked (EU/USt.);23,03;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10270;I;Warenpost Int. KT (EU/USt.) für Internetmarke;1,5;WARENPOST INT KT EU Internetmarke;1,5;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;1;10271;I;Warenpost Int. KT Tracked (EU/USt.) für Internetmarke;3,6;WARENPOST INT KT TRACKED EU Internetmarke;3,6;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;;10272;I;Warenpost Int. KT (Non EU) für Internetmarke;2;WARENPOST INT KT NON EU Internetmarke;2;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;1;10273;I;Warenpost Int. KT Tracked (Non EU) für Internetmarke;4,1;WARENPOST INT KT TRACKED NON EU Internetmarke;4,1;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;;10280;I;Warenpost International XS Unterschrift;7,3;Warenpost International XS Unterschrift;7,3;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10281;I;Warenpost International S Unterschrift;8,5;Warenpost International S Unterschrift;8,5;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10282;I;Warenpost International M Unterschrift;12,5;Warenpost International M Unterschrift;12,5;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10283;I;Warenpost International L Unterschrift;23,4;Warenpost International L Unterschrift;23,4;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10284;I;Warenpost International XS Unterschrift (EU/USt.);7,97;Warenpost International XS Unterschrift (EU/USt.);7,97;;;140;90;0;353;250;30;0;500;;;;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10285;I;Warenpost International S Unterschrift (EU/USt.);8,57;Warenpost International S Unterschrift (EU/USt.);8,57;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10286;I;Warenpost International M Unterschrift (EU/USt.);12,5;Warenpost International M Unterschrift (EU/USt.);12,5;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10287;I;Warenpost International L Unterschrift (EU/USt.);24,4;Warenpost International L Unterschrift (EU/USt.);24,4;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;nein;ja -01.01.2021;;10292;I;Warenpost Int. KT Unterschrift (EU/USt.) für Internetmarke;4,75;WARENPOST INT KT UNTERSCHRIFT EU Internetmarke;4,75;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerpflichtig. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;;10293;I;Warenpost Int. KT Unterschrift (Non EU) für Internetmarke;5,25;WARENPOST INT KT UNTERSCHRIFT NON EU Internetmarke;5,25;;;140;90;0;600;600;600;0;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Vertragsprodukt. Umsatzsteuerfrei. Nur Waren als Inhalt, keine schriftlichen Mitteilungen zulässig, eine auf den Inhalt bezogene Rechnung ist zulässig, für Versande in Länder außerhalb der EU ist immer eine Zollinhaltserklärung auf der Sendung anzubringen.;https://www.deutschepost.de/de/b/briefe-ins-ausland/warenpost-international.html;ja;ja -01.01.2021;1;11006;I;Standardbrief Intern. GK Integral + EINSCHREIBEN;4,6;Standardbrief Intern. GK;1,1;EINSCHREIBEN;3,5;140;90;0;235;125;5;0;20;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Standardbrief INTERNATIONAL bis 20 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;1;11016;I;Kompaktbrief Intern. GK Integral + EINSCHREIBEN;5,2;Kompaktbrief Intern. GK;1,7;EINSCHREIBEN;3,5;140;90;0;235;125;10;0;50;;;Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Ein Kompaktbrief INTERNATIONAL bis 50 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;1;11056;I;Großbrief Intern. GK Integral + EINSCHREIBEN;7,2;Großbrief Intern. GK;3,7;EINSCHREIBEN;3,5;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Großbrief INTERNATIONAL bis 500 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;1;11076;I;Maxibrief Intern. bis 1.000g GK Integral + EINSCHREIBEN;10,5;Maxibrief Intern. bis 1.000g GK;7;EINSCHREIBEN;3,5;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief INTERNATIONAL bis 1000 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;1;11096;I;Maxibrief Intern. bis 2.000g GK Integral + EINSCHREIBEN;20,5;Maxibrief Intern. bis 2.000g GK;17;EINSCHREIBEN;3,5;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Ein Maxibrief INTERNATIONAL bis 2000 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;1;11202;I;Postkarte Intern. GK Integral + EINSCHREIBEN;4,45;Postkarte Intern. GK;0,95;EINSCHREIBEN;3,5;140;90;0;235;125;2;;;;;Flächengewicht: 150 g/m2 bis 500 g/m2. Die Länge muss mindestens das 1,4-fache der Breite betragen.;Preis nach UStG umsatzsteuerfrei. Eine Postkarte INTERNATIONAL, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post.;https://www.deutschepost.de/de/b/briefe-ins-ausland/einschreiben-international.html;nein;nein -01.01.2021;;30092;I;Presse Eco 500g;3,5;Presse Eco 500g;3,5;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Eco 500g versenden Sie Zeitungen und Zeitschriften.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;;30112;I;Presse Eco 1000g;6,5;Presse Eco 1000g;6,5;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Eco 1000g versenden Sie Zeitungen und Zeitschriften.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;;30132;I;Presse Eco 2000g;14;Presse Eco 2000g;14;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Eco 2000g versenden Sie Zeitungen und Zeitschriften.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;;30202;I;Presse Prio 500g;3,7;Presse Prio 500g;3,7;;;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Prio 500 g versenden Sie Zeitungen und Zeitschriften. Bitte beachten Sie die Kennzeichnungspflicht der Sendung.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;1;30207;I;Presse Prio 500g + EINSCHREIBEN;7,2;Presse Prio 500g;3,7;EINSCHREIBEN;3,5;140;90;0;600;600;600;0;500;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Presse Prio 500g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post. Bitte beachten Sie die Kennzeichnungspflicht der Sendung. ;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;;30222;I;Presse Prio 1000g;7;Presse Prio 1000g;7;;;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Prio 1000 g versenden Sie Zeitungen und Zeitschriften. Bitte beachten Sie die Kennzeichnungspflicht der Sendung.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;1;30227;I;Presse Prio 1000g + EINSCHREIBEN;10,5;Presse Prio 1000g;7;EINSCHREIBEN;3,5;140;90;0;600;600;600;501;1000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Presse Prio 1000 g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post. Bitte beachten Sie die Kennzeichnungspflicht der Sendung.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;;30242;I;Presse Prio 2000g;17;Presse Prio 2000g;17;;;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Mit Presse Prio 2000 g versenden Sie Zeitungen und Zeitschriften. Bitte beachten Sie die Kennzeichnungspflicht der Sendung.;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein -01.01.2021;1;30247;I;Presse Prio 2000g + EINSCHREIBEN;20,5;Presse Prio 2000g;17;EINSCHREIBEN;3,5;140;90;0;600;600;600;1001;2000;;;Höchstmaße: L + B + H = 900 mm, dabei keine Seite länger als 600 mm.;Preis nach UStG umsatzsteuerfrei. Presse Prio 2000g, nachgewiesene Übergabe an Empfänger, Sendungsverfolgung per T&T, Haftung, Einlieferung über die Filialen der Deutschen Post. Bitte beachten Sie die Kennzeichnungspflicht der Sendung. ;https://www.deutschepost.de/de/b/briefe-ins-ausland/presse-international.html;nein;nein diff --git a/www/lib/versandarten/sonstiges.php_ b/www/lib/versandarten/sonstiges.php_ deleted file mode 100644 index 9ed8de0b..00000000 --- a/www/lib/versandarten/sonstiges.php_ +++ /dev/null @@ -1,410 +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->credentials = $this->einstellungen; - //$this->errors = array(); - $data = $this->einstellungen; - $this->info = $this->einstellungen; - - - } - - public function GetBezeichnung() - { - return 'UPS'; - } - - function EinstellungenStruktur() - { - return array(); - - } - - public function VersandartMindestgewicht() - { - if(!isset($this->einstellungen['WeightInKG']))return 1; - if($this->einstellungen['WeightInKG'] === '')return 1; - return str_replace(',','.',$this->einstellungen['WeightInKG']); - } - - 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("telefon"); - $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"); - - if($name3=="" && $land!=$this->app->erp->Firmendaten("land")) $name3=$name; - - $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"); - } - - 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')) { - $this->app->Location->execute("index.php?module=versanderzeugen&action=frankieren&id=$id&land=$land&tracking_again=1"); - } - $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); - $this->app->erp->RunHook('versanderzeugen_frankieren_hook1', 1, $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(); - $this->app->Location->execute('index.php?module=versanderzeugen&action=einzel&id='.$newid); - } - $url = 'index.php?module=versanderzeugen&action=offene'; - $lieferschein = $this->app->DB->Select(sprintf('SELECT lieferschein FROM versand WHERE id = %d', $id)); - $this->app->erp->RunHook('paketmarke_abschluss_url', 2, $lieferschein, $url); - $this->app->Location->execute($url); - } - //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); - } - - $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(); - $auftrag = $this->app->DB->Select("SELECT auftragid FROM lieferschein WHERE id = '$id'"); - $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)); - $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); - - - $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 = $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 = $this->app->DB->Select("SELECT belegnr FROM auftrag WHERE id='$auftragid' LIMIT 1"); - } else { - $nummeraufbeleg = $lieferscheinnummer; - } - */ - $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 - if($phone=="") - $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'"); - } - - $data = $this->einstellungen; - - // your customer and api credentials from/for dhl - $credentials = array( - 'api_user' => $data['api_user'], - 'api_password' => $data['api_password'], - 'api_accountnumber' => $data['accountnumber'], - 'api_key' => $data['api_key'], - 'log' => true - ); - - // your company info - $info = array( - 'company_name' => $data['company_name'], - 'street_name' => $data['street_name'], - 'street_number' => $data['street_number'], - 'zip' => $data['zip'], - 'country' => $data['country'], - 'city' => $data['city'], - 'email' => $data['email'], - 'phone' => $data['phone'], - 'internet' => $data['internet'], - 'contact_person' => $data['contact_person'], - 'export_reason' => $data['exportgrund'] - ); - // receiver details - $customer_details = array( - 'name1' => $name, - 'name2' => $name2, - 'c/o' => $name3, - 'street_name' => $strasse, - 'street_number' => $hausnummer, - //'country' => 'germany', - 'country_code' => $land, - 'zip' => $plz, - 'city' => $ort, - 'email' => $email, - 'phone' => $phone, - 'ordernumber' => $nummeraufbeleg, - 'ordernumber2' => $lieferscheinnummer, - 'weight' => $kg, - 'amount' => str_replace(",",".",$rechnungssumme), - 'currency' => 'EUR' - ); - - - $shipment_details['WeightInKG'] = $data['WeightInKG']; - $shipment_details['LengthInCM'] = $data['LengthInCM']; - $shipment_details['WidthInCM'] = $data['WidthInCM']; - $shipment_details['HeightInCM'] = $data['HeightInCM']; - $shipment_details['PackageType'] = $data['PackageType']; - - $shipment_details['service_code'] = $data['service_code']; - $shipment_details['service_description'] = $data['service_description']; - $shipment_details['package_code'] = $data['package_code']; - $shipment_details['package_description'] = $data['package_description']; - $shipment_details['exportgrund'] = $data['exportgrund']; - - if($data['note']=="") $data['note'] = $rechnungsnummer; - - //$response = $this->createShipment($customer_details,$shipment_details); - - - $data['sonstiges_drucker'] = $this->paketmarke_drucker; - $data['druckerlogistikstufe2'] = $this->export_drucker; - - - if($this->app->erp->GetStandardPaketmarkendrucker()>0) - $data['sonstiges_drucker'] = $this->app->erp->GetStandardPaketmarkendrucker(); - - - if($this->app->erp->GetStandardVersanddrucker($projekt)>0) - $data['druckerlogistikstufe2'] = $this->app->erp->GetStandardVersanddrucker($projekt); - } - - - if($this->app->Secure->GetPOST('drucken') || $this->app->Secure->GetPOST('anders')) - { - - - }else{ - - } - } - - //$this->info = $customer_info; - if($target)$this->app->Tpl->Parse($target,'versandarten_sonstiges.tpl'); - } - - - public function Export($daten) - { - - } - - - 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); - - } - - } - - } - - - -} From 98bbdec8d355d375e1869926138237fc1a34f030 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 24 Mar 2023 00:28:39 +0100 Subject: [PATCH 42/51] fix link in menu --- www/lib/class.erpapi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php index c5280d4f..d508258c 100644 --- a/www/lib/class.erpapi.php +++ b/www/lib/class.erpapi.php @@ -7095,7 +7095,7 @@ title: 'Abschicken', $navarray['menu']['admin'][$menu]['sec'][] = array('Arbeitsnachweis','arbeitsnachweis','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Gutschrift / '.$this->Firmendaten("bezeichnungstornorechnung"),'gutschrift','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Proformarechnung','proformarechnung','list'); - $navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','rechnungslauf'); + $navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list'); $navarray['menu']['admin'][$menu]['sec'][] = array('Dokumenten Scanner','docscan','list'); From 18f2785abd4f82b1db34cd4012cda24786a60388 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 25 Mar 2023 20:47:08 +0100 Subject: [PATCH 43/51] Bugfix typ db_schema --- upgrade/data/db_schema.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/upgrade/data/db_schema.json b/upgrade/data/db_schema.json index f241296a..7ab66584 100644 --- a/upgrade/data/db_schema.json +++ b/upgrade/data/db_schema.json @@ -98705,7 +98705,7 @@ "Default": "", "Extra": "auto_increment", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" }, { "Field": "address_id", @@ -98716,7 +98716,7 @@ "Default": "", "Extra": "", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" }, { "Field": "document_type", @@ -98727,7 +98727,7 @@ "Default": "", "Extra": "", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" }, { "Field": "job_type", @@ -98738,7 +98738,7 @@ "Default": "", "Extra": "", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" }, { "Field": "printer_id", @@ -98749,7 +98749,7 @@ "Default": "", "Extra": "", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" }, { "Field": "created_at", @@ -98760,7 +98760,7 @@ "Default": "current_timestamp()", "Extra": "", "Privileges": "select,insert,update,references", - "Commant": "" + "Comment": "" } ], "keys": [ From 23dc74cd0898940d20af3b7595ea3ef751249e55 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sat, 25 Mar 2023 20:51:16 +0100 Subject: [PATCH 44/51] Bugfix versandart no module (dummy) --- www/pages/versandarten.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 6ab5cad0..227e0c5e 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -241,13 +241,14 @@ class Versandarten { $form['paketmarke_drucker'] = $daten['paketmarke_drucker']; } - $obj->RenderAdditionalSettings('MODULESETTINGS', $form); + if (!empty($obj)) { + $obj->RenderAdditionalSettings('MODULESETTINGS', $form); + $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', + $this->getPrinterByModule($obj, false), $form['export_drucker']); - $this->app->Tpl->addSelect('EXPORT_DRUCKER', 'export_drucker', 'export_drucker', - $this->getPrinterByModule($obj, false), $form['export_drucker']); - - $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', 'paketmarke_drucker', - $this->getPrinterByModule($obj), $form['paketmarke_drucker']); + $this->app->Tpl->addSelect('PAKETMARKE_DRUCKER', 'paketmarke_drucker', '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', [ @@ -827,4 +828,4 @@ class Versandarten { return $result; } -} \ No newline at end of file +} From 09039f9d2abd7ca97bcd96dd990d7f615b3e68a2 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 26 Mar 2023 13:23:15 +0200 Subject: [PATCH 45/51] Bugfix user avatar --- www/lib/class.image.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/lib/class.image.php b/www/lib/class.image.php index 71598c45..7d72e7ba 100644 --- a/www/lib/class.image.php +++ b/www/lib/class.image.php @@ -49,6 +49,7 @@ class image { $manipulator = new ImageManipulator($str); $type = mime_content_type($path); + $manipulator->resample($newwidth, $newheight, true, $upscale); /* @@ -200,7 +201,7 @@ class ImageManipulator public function resample($width, $height, $constrainProportions = true, $upscale = false, $keepformat = false) { if (!is_resource($this->image)) { - throw new RuntimeException('No image set'); +// throw new RuntimeException('No image set'); } if($keepformat) { @@ -340,9 +341,9 @@ class ImageManipulator */ protected function _replace($res) { - if (!is_resource($res)) { + /* if (!is_resource($res)) { throw new UnexpectedValueException('Invalid resource'); - } + }*/ if (is_resource($this->image)) { imagedestroy($this->image); } From 7a83c9fd29e1b65f01e3843845049c40db9b25d8 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Sun, 26 Mar 2023 13:26:49 +0200 Subject: [PATCH 46/51] Bugfix briefpapier freitexte width --- www/lib/dokumente/class.briefpapier.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/www/lib/dokumente/class.briefpapier.php b/www/lib/dokumente/class.briefpapier.php index 464fe186..3b10cc26 100644 --- a/www/lib/dokumente/class.briefpapier.php +++ b/www/lib/dokumente/class.briefpapier.php @@ -1797,12 +1797,19 @@ class Briefpapier extends SuperFPDF { public function setStyleData($styleData){ $this->styleData = $styleData; - } + } private function getStyleElement($key){ - if(isset($this->styleData[$key]) && !empty($this->styleData[$key])) return $this->styleData[$key]; - - return $this->app->erp->Firmendaten($key); + $result = null; + if(isset($this->styleData[$key]) && !empty($this->styleData[$key])) { + $result = $this->styleData[$key]; + } else { + $result = $this->app->erp->Firmendaten($key); + } + if (empty($result)) { + $result = 0; + } + return($result); } public function renderDocument() { From c361a825833c091cfaaad1b2d6b5d36e3b9b2e9b Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Mon, 27 Mar 2023 15:22:27 +0200 Subject: [PATCH 47/51] add "empty" to versandarten module list --- www/pages/versandarten.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/www/pages/versandarten.php b/www/pages/versandarten.php index 60b996f0..6c46f36f 100644 --- a/www/pages/versandarten.php +++ b/www/pages/versandarten.php @@ -268,7 +268,7 @@ class Versandarten { 'geschaeftsbrief_vorlage', $geschaeftsbrief_vorlagen, $daten['geschaeftsbrief_vorlage']); $this->app->Tpl->addSelect('SELMODUL', 'modul', 'modul', - $this->VersandartenSelModul(), $form['modul']); + $this->VersandartenSelModul(true), $form['modul']); $this->app->Tpl->Set('BEZEICHNUNG', $form['bezeichnung']); $this->app->Tpl->Set('TYPE', $form['type']); $this->app->Tpl->Set('PROJEKT', $form['projekt']); @@ -713,7 +713,7 @@ class Versandarten { return $this->HandleSaveAssistantAjaxAction(); } - $modulelist = $this->VersandartenSelModul(); + $modulelist = $this->VersandartenSelModul(true); $auswahlmodul = $this->app->Secure->GetGET('auswahl'); if($auswahlmodul && isset($modulelist[$auswahlmodul])) { @@ -791,9 +791,12 @@ class Versandarten { * Retrieve all Versandarten from lib/versandarten/ * @return array */ - function VersandartenSelModul() : array + function VersandartenSelModul(bool $addEmpty = false) : array { $result = []; + if ($addEmpty) + $result[''] = ''; + $pfad = dirname(__DIR__).'/lib/versandarten'; if(!is_dir($pfad)) return $result; From ebc7034164c77bc3d5c9bb3ad31dc946b0e69d10 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Thu, 30 Mar 2023 12:33:38 +0200 Subject: [PATCH 48/51] firmendaten hotfix freifelder --- www/pages/firmendaten.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/www/pages/firmendaten.php b/www/pages/firmendaten.php index 19a75eff..60b1a259 100644 --- a/www/pages/firmendaten.php +++ b/www/pages/firmendaten.php @@ -706,9 +706,12 @@ class Firmendaten { $n2 = 'adressefreifeld'.$i.'spalte'; $v1 = $this->app->Secure->GetPOST($n1); $v2 = $this->app->Secure->GetPOST($n2); - $this->app->DB->Update("UPDATE firmendaten SET + /*$this->app->DB->Update("UPDATE firmendaten SET $n1 = '".$v1."', $n2 = '".$v2."' - WHERE firma='$id' LIMIT 1"); + WHERE firma='$id' LIMIT 1");*/ + + $this->app->erp->FirmendatenSet($n1,$v1); + $this->app->erp->FirmendatenSet($n2,$v2); if(isset($firmendaten_werte_spalten)) { if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) { @@ -746,9 +749,12 @@ class Firmendaten { $n2 = 'projektfreifeld'.$i.'spalte'; $v1 = $this->app->Secure->GetPOST($n1); $v2 = $this->app->Secure->GetPOST($n2); - $this->app->DB->Update("UPDATE firmendaten SET +/* $this->app->DB->Update("UPDATE firmendaten SET $n1 = '".$v1."', $n2 = '".$v2."' - WHERE firma='$id' LIMIT 1"); + WHERE firma='$id' LIMIT 1"); */ + + $this->app->erp->FirmendatenSet($n1,$v1); + $this->app->erp->FirmendatenSet($n2,$v2); if(isset($firmendaten_werte_spalten)) { if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) { @@ -783,6 +789,8 @@ class Firmendaten { } $toupdate = null; + +/* for($in = 1; $in <= 40; $in++) { $toupdate[] = 'freifeld'.$in; } @@ -800,7 +808,20 @@ class Firmendaten { } $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1"; unset($sql2a); - $this->app->DB->Update($sql2); + $this->app->DB->Update($sql2);*/ + + for($in = 1; $in <= 40; $in++) { + $field = 'freifeld'.$in; + $this->app->erp->FirmendatenSet($field,$this->app->Secure->GetPOST($field)); + } + for($in = 1; $in <= 20; $in++) { + $field = 'projektfreifeld'.$in; + $this->app->erp->FirmendatenSet($field,$this->app->Secure->GetPOST($field)); + $field = 'adressefreifeld'.$in; + $this->app->erp->FirmendatenSet($field,$this->app->Secure->GetPOST($field)); + } + + if($this->app->DB->error()) { foreach($toupdate as $v) { $data[$v] = $this->app->Secure->GetPOST($v); From b6c23399c6f7acb5eb6d1e09594faa6922812933 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Thu, 30 Mar 2023 22:24:40 +0200 Subject: [PATCH 49/51] Versanddienstleister: display customs form only for non-EU countries, improve product/method selection --- www/lib/class.versanddienstleister.php | 5 +- .../versandarten/content/createshipment.tpl | 70 +++++++++++++------ www/lib/versandarten/sendcloud.php | 26 ++++--- 3 files changed, 66 insertions(+), 35 deletions(-) diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index 9fcd29ee..44743e27 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -409,8 +409,11 @@ abstract class Versanddienstleister $products = array_combine(array_column($products, 'Id'), $products); $address['product'] = $products[0]->Id ?? ''; + $countries = $this->app->DB->SelectArr("SELECT iso, bezeichnung_de name, eu FROM laender ORDER BY bezeichnung_de"); + $countries = array_combine(array_column($countries, 'iso'), $countries); + $json['form'] = $address; - $json['countries'] = $this->app->erp->GetSelectLaenderliste(); + $json['countries'] = $countries; $json['products'] = $products; $json['customs_shipment_types'] = [ CustomsInfo::CUSTOMS_TYPE_GIFT => 'Geschenk', diff --git a/www/lib/versandarten/content/createshipment.tpl b/www/lib/versandarten/content/createshipment.tpl index 04d3f8e1..3ece01dd 100644 --- a/www/lib/versandarten/content/createshipment.tpl +++ b/www/lib/versandarten/content/createshipment.tpl @@ -73,7 +73,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Land|}: @@ -156,7 +156,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 {|Produkt|}: @@ -170,29 +170,33 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1

          {|Bestellung|}

          - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
          {|Bestellnummer|}:
          {|Rechnungsnummer|}:
          {|Sendungsart|}: - -
          {|Versicherungssumme|}:
          {|Bestellnummer|}:
          {|Versicherungssumme|}:
          {|Rechnungsnummer|}:
          {|Sendungsart|}: + +
          -
          +
          @@ -269,10 +273,30 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1 deletePosition: function (index) { this.form.positions.splice(index, 1); }, + productAvailable: function (product) { + if (product == undefined) + return false; + if (product.WeightMin > this.form.weight || product.WeightMax < this.form.weight) + return false; + return true; + }, serviceAvailable: function (service) { if (!this.products.hasOwnProperty(this.form.product)) return false; return this.products[this.form.product].AvailableServices.indexOf(service) >= 0; + }, + customsRequired: function () { + return this.countries[this.form.country].eu == '0'; + } + }, + beforeUpdate: function () { + if (!this.productAvailable(this.products[this.form.product])) { + for (prod in this.products) { + if (!this.productAvailable(this.products[prod])) + continue; + this.form.product = prod; + break; + } } } }) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 2216cb83..4e4ebe03 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -105,19 +105,21 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->EMail = $json->email; $parcel->Telephone = $json->phone; $parcel->CountryState = $json->state; - $parcel->CustomsInvoiceNr = $json->invoice_number; - $parcel->CustomsShipmentType = $json->shipment_type; $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; + if (!empty($json->shipment_type)) { + $parcel->CustomsInvoiceNr = $json->invoice_number; + $parcel->CustomsShipmentType = $json->shipment_type; + 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; $ret = new CreateShipmentResult(); @@ -154,6 +156,8 @@ class Versandart_sendcloud extends Versanddienstleister $p = new Product(); $p->Id = $item->Id; $p->Name = $item->Name; + $p->WeightMin = $item->MinWeight / 1000; + $p->WeightMax = $item->MaxWeight / 1000; $result[] = $p; } return $result; From 03f51a548aa4503fe3f64d17fe76803d6b6e6d02 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 31 Mar 2023 10:21:08 +0200 Subject: [PATCH 50/51] Sendcloud: handle field requirement/null for parcels without customs declaration --- .../Carrier/SendCloud/Data/ParcelCreation.php | 16 ++++++++++------ www/lib/versandarten/sendcloud.php | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/Carrier/SendCloud/Data/ParcelCreation.php b/classes/Carrier/SendCloud/Data/ParcelCreation.php index d4014b17..174361b6 100644 --- a/classes/Carrier/SendCloud/Data/ParcelCreation.php +++ b/classes/Carrier/SendCloud/Data/ParcelCreation.php @@ -12,8 +12,9 @@ class ParcelCreation extends ParcelBase { public ?int $SenderAddressId = null; - public function toApiRequest(): array { - return [ + public function toApiRequest(): array + { + $data = [ 'name' => $this->Name, 'company_name' => $this->CompanyName, 'address' => $this->Address, @@ -32,16 +33,19 @@ class ParcelCreation extends ParcelBase '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 ?? 0, - 'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems), + 'parcel_items' => array_map(fn(ParcelItem $item) => $item->toApiRequest(), $this->ParcelItems), 'is_return' => $this->IsReturn, 'length' => $this->Length, 'width' => $this->Width, 'height' => $this->Height, ]; - } + if ($this->CustomsInvoiceNr !== null) + $data['customs_invoice_nr'] = $this->CustomsInvoiceNr; + if ($this->CustomsShipmentType !== null) + $data['customs_shipment_type'] = $this->CustomsShipmentType; + return $data; + } } \ No newline at end of file diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 4e4ebe03..2f7082e1 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -107,7 +107,7 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->CountryState = $json->state; $parcel->TotalInsuredValue = $json->total_insured_value; $parcel->OrderNumber = $json->order_number; - if (!empty($json->shipment_type)) { + if (!$this->app->erp->IstEU($json->country)) { $parcel->CustomsInvoiceNr = $json->invoice_number; $parcel->CustomsShipmentType = $json->shipment_type; foreach ($json->positions as $pos) { From e79e2e24d2de5c0bc4e1d4e0adf2ddcad3bab930 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Fri, 31 Mar 2023 22:30:35 +0200 Subject: [PATCH 51/51] Sendcloud: Fix for domestic parcels - use IsEU instead of IstEU :-/ --- www/lib/versandarten/sendcloud.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 2f7082e1..cdda1cce 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -107,7 +107,7 @@ class Versandart_sendcloud extends Versanddienstleister $parcel->CountryState = $json->state; $parcel->TotalInsuredValue = $json->total_insured_value; $parcel->OrderNumber = $json->order_number; - if (!$this->app->erp->IstEU($json->country)) { + if (!$this->app->erp->IsEU($json->country)) { $parcel->CustomsInvoiceNr = $json->invoice_number; $parcel->CustomsShipmentType = $json->shipment_type; foreach ($json->positions as $pos) {
          {|Bezeichnung|}