From 9d547c6e5227d2c2ec52a12cabd4e0c4462ab0c8 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 13 May 2024 14:43:33 +0200
Subject: [PATCH 01/87] Shop Mirakl initial copied from Presta
---
www/lib/ShopimporterBase.php | 52 ++++
www/pages/appstore.php | 5 +-
www/pages/shopimporter_mirakl.php | 483 ++++++++++++++++++++++++++++++
3 files changed, 539 insertions(+), 1 deletion(-)
create mode 100644 www/pages/shopimporter_mirakl.php
diff --git a/www/lib/ShopimporterBase.php b/www/lib/ShopimporterBase.php
index 0e3795a7..2d92213d 100644
--- a/www/lib/ShopimporterBase.php
+++ b/www/lib/ShopimporterBase.php
@@ -632,6 +632,18 @@ Class ShopimporterBase{
'variants',
'free_fields',
],
+ 'shopimporter_mirakl' => [
+ 'article_descriptions',
+ 'translations',
+ 'categories',
+ 'properties',
+ 'pictures',
+ 'cross_selling',
+ 'bulk_prices',
+ 'standard_price',
+ 'variants',
+ 'free_fields',
+ ],
'shopimporter_shopify' => [
'article_descriptions',
'translations',
@@ -1329,6 +1341,46 @@ Class ShopimporterBase{
'metabeschreibung' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
'metakeywords' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
'freifelder' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ ],
+ 'shopimporter_mirakl' => [
+ 'auftrag' => ['createarticle' => self::UNDEFINED, 'updatearticle' => self::UNDEFINED, 'importarticle' => self::UNDEFINED, 'importorder' => self::UNDEFINED],
+ 'artikelname' => ['createarticle' => self::MUST, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CAN],
+ 'artikelnummer' => ['createarticle' => self::MUST, 'updatearticle' => self::MUST, 'importarticle' => self::CANNOT, 'importorder' => self::CAN],
+ 'aktiv' => ['createarticle' => self::MUST, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'restmenge' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'beschreibung' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CAN],
+ 'ean' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'hersteller' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'herstellerlink' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'herstellernummer' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'zolltarifnummer' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'gewicht' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'einheit' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'laenge' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'hoehe' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'breite' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'verkaufspreis' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CAN],
+ 'pseudopreis' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'lagerzahlen' => ['createarticle' => self::MUST, 'updatearticle' => self::MUST, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'pseudolager' => ['createarticle' => self::MUST, 'updatearticle' => self::MUST, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'staffelpreise' => ['createarticle' => self::MUST, 'updatearticle' => self::MUST, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'gruppenpreise' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'fremdsprachen' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'kategorie' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'kategoriebaum' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'bilder' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'varianten' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'matrixeigenschaften' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'über 5000 Varianten' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'eigenschaften' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'crossselling' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'kurztext' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'herkunftsland' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'umsatzsteuer' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'metatitel' => ['createarticle' => self::CANNOT, 'updatearticle' => self::CANNOT, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'metabeschreibung' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'metakeywords' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
+ 'freifelder' => ['createarticle' => self::CAN, 'updatearticle' => self::CAN, 'importarticle' => self::CANNOT, 'importorder' => self::CANNOT],
],
'shopimporter_modified' => [
'auftrag' => ['createarticle' => self::UNDEFINED, 'updatearticle' => self::UNDEFINED, 'importarticle' => self::UNDEFINED, 'importorder' => self::UNDEFINED],
diff --git a/www/pages/appstore.php b/www/pages/appstore.php
index 6c9c7c89..c118ecaf 100644
--- a/www/pages/appstore.php
+++ b/www/pages/appstore.php
@@ -2628,6 +2628,10 @@ class Appstore {
'Link'=>'index.php?module=onlineshops&action=create&cmd=shopimporter_presta',
'Icon'=>'Icons_dunkel_1.gif',
'Versionen'=>'ALL','install'=>true, 'beta' => false,'kategorie'=>'{|Shop Schnittstelle|}')
+ ,'shopimporter_mirakl'=>array('Bezeichnung'=>'Mirakl',
+ 'Link'=>'index.php?module=onlineshops&action=create&cmd=shopimporter_mirakl',
+ 'Icon'=>'Icons_dunkel_1.gif',
+ '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',
@@ -3967,7 +3971,6 @@ class Appstore {
}
}
-
if(isset($module['installiert'])) {
foreach($module['installiert'] as $k => $v) {
$moduleInstallKey = $module['installiert'][$k]['key'];
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
new file mode 100644
index 00000000..e7b6b6e2
--- /dev/null
+++ b/www/pages/shopimporter_mirakl.php
@@ -0,0 +1,483 @@
+ 'de', 1 => 'en'];
+ private $taxationByDestinationCountry;
+ private $orderSearchLimit;
+
+
+ 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,
+ ],
+ 'shopidmirakl' => [
+ '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->miraklRequest('GET', 'order_histories?schema=blank');
+ $obj->order_history->id_order = $auftrag;
+ $obj->order_history->id_order_state = $this->idbearbeitung;
+
+ $this->miraklRequest('POST', 'order_histories', $obj->asXML());
+ }
+
+ public function ImportUpdateAuftrag()
+ {
+ $auftrag = $this->data['auftrag'];
+
+ $obj = $this->miraklRequest('GET', 'order_histories?schema=blank');
+ $obj->order_history->id_order = $auftrag;
+ $obj->order_history->id_order_state = $this->idabgeschlossen;
+
+ $this->miraklRequest('POST', 'order_histories', $obj->asXML());
+
+ $req = $this->miraklRequest('GET', "order_carriers?filter[id_order]=$auftrag&display=[id]");
+ $orderCarrierId = strval($req->order_carriers->order_carrier[0]->id);
+ $req = $this->miraklRequest('GET', "order_carriers/$orderCarrierId");
+ $req->order_carrier->tracking_number = $this->data['tracking'];
+ $this->miraklRequest('PUT', "order_carriers/$orderCarrierId", $req->asXML());
+ }
+
+ 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) {
+ $order = $this->miraklRequest('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['versandkostennetto'] = strval($order->total_shipping_tax_excl);
+ $cart['bestelldatum'] = strval($order->date_add);
+
+ $carrier = $this->miraklRequest('GET', "carriers/$order->id_carrier");
+ $cart['lieferung'] = strval($carrier->carrier->name);
+
+ $customer = $this->miraklRequest('GET', "customers/$order->id_customer");
+ $cart['email'] = strval($customer->customer->email);
+
+ $language = $this->miraklRequest('GET', "languages/{$customer->customer->id_lang}");
+ if ($language->language->iso_code == "en") {
+ $cart['kunde_sprache'] = 'englisch';
+ }
+
+ $invoiceAddress = $this->miraklRequest('GET', "addresses/$order->id_address_invoice");
+ $invoiceAddress = $invoiceAddress->address;
+ $invoiceCountry = $this->miraklRequest('GET', "countries/$invoiceAddress->id_country");
+ $invoiceCountry = $invoiceCountry->country;
+ $cart['name'] = "$invoiceAddress->firstname $invoiceAddress->lastname";
+ if (!empty(strval($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 (strval($order->id_address_invoice) != strval($order->id_address_delivery)) {
+ $deliveryAddress = $this->miraklRequest('GET', "addresses/$order->id_address_delivery");
+ $deliveryAddress = $deliveryAddress->address;
+ $deliveryCountry = $this->miraklRequest('GET', "countries/$deliveryAddress->id_country");
+ $deliveryCountry = $deliveryCountry->country;
+ $cart['abweichendelieferadresse'] = 1;
+ $cart['lieferadresse_name'] = "$deliveryAddress->firstname $deliveryAddress->lastname";
+ if (!empty(strval($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'];
+ }
+ $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);
+
+ 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) {
+ $article = [
+ 'articleid' => strval($order_row->product_reference),
+ 'name' => strval($order_row->product_name),
+ 'quantity' => strval($order_row->product_quantity),
+ 'price_netto' => strval($order_row->unit_price_tax_excl),
+ ];
+
+ if ($order_row->unit_price_tax_excl > 0) {
+ $steuersatz = (strval($order_row->unit_price_tax_incl) / strval($order_row->unit_price_tax_excl)) - 1;
+ $steuersatz = round($steuersatz, 1);
+ $article['steuersatz'] = $steuersatz;
+ }
+
+ $cart['articlelist'][] = $article;
+ }
+
+ $fetchedOrders[] = [
+ 'id' => $cart['auftrag'],
+ 'sessionid' => '',
+ 'logdatei' => '',
+ 'warenkorb' => base64_encode(serialize($cart)),
+ 'warenkorbjson' => base64_encode(json_encode($cart)),
+ ];
+ }
+ $this->Log('Precessed order from mirakl', $fetchedOrders);
+
+ return $fetchedOrders;
+ }
+
+ public function ImportGetArticleList()
+ {
+ $result = [];
+ $response = $this->miraklRequest('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;
+
+ $productsresult = $this->miraklRequest('GET', 'products?filter[reference]='.$nummer);
+ $combinationsresult = $this->miraklRequest('GET', 'combinations?filter[reference]='.$nummer);
+ $numberOfCombinations = count($combinationsresult->combinations->combination);
+ $numberOfProducts = count($productsresult->products->product);
+ $numberOfResults = $numberOfProducts + $numberOfCombinations;
+ if ($numberOfResults > 1) {
+ $this->Log('Got multiple results from Shop', $this->data);
+ return;
+ }
+ elseif ($numberOfResults < 1) {
+ $this->Log('No product found in Shop', $this->data);
+ return;
+ }
+
+ $isCombination = $numberOfCombinations > 0;
+ if ($isCombination) {
+ $combinationId = intval($combinationsresult->combinations->combination->attributes()->id);
+ $combination = $this->miraklRequest('GET', "combinations/$combinationId");
+ $productId = intval($combination->combination->id_product);
+ } else {
+ $productId = intval($productsresult->products->product->attributes()->id);
+ }
+ $product = $this->miraklRequest('GET', "products/$productId");
+ $res = [];
+ if ($isCombination) {
+ $res['nummer'] = strval($combination->combination->reference);
+ $res['artikelnummerausshop'] = strval($combination->combination->reference);
+ $res['ean'] = strval($combination->combination->ean13);
+ $res['preis_netto'] = floatval($product->product->price) + floatval($combination->combination->price);
+ } else {
+ $res['nummer'] = strval($product->product->reference);
+ $res['artikelnummerausshop'] = strval($product->product->reference);
+ $res['ean'] = strval($product->product->ean13);
+ $res['preis_netto'] = floatval($product->product->price);
+ }
+ $names = $this->toMultilangArray($product->product->name->language);
+ $descriptions = $this->toMultilangArray($product->product->description->language);
+ $shortdescriptions = $this->toMultilangArray($product->product->description_short->language);
+ $metadescriptions = $this->toMultilangArray($product->product->meta_description->language);
+ $metakeywords = $this->toMultilangArray($product->product->meta_keywords->language);
+ $metatitles = $this->toMultilangArray($product->product->meta_title->language);
+ $res['name'] = $names['de'];
+ $res['name_en'] = $names['en'];
+ $res['uebersicht_de'] = $descriptions['de'];
+ $res['uebersicht_en'] = $descriptions['en'];
+ $res['kurztext_de'] = strip_tags($shortdescriptions['de']);
+ $res['kurztext_en'] = strip_tags($shortdescriptions['en']);
+ $res['hersteller'] = strval($product->product->manufacturer_name);
+ $res['metatitle_de'] = $metatitles['de'];
+ $res['metatitle_en'] = $metatitles['en'];
+ $res['metadescription_de'] = $metadescriptions['de'];
+ $res['metadescription_en'] = $metadescriptions['en'];
+
+ $tags = $product->product->associations->tags->tag;
+ $keywords = [];
+ foreach ($tags as $tag) {
+ $tagid = intval($tag->id);
+ $endpoint = "tags/{$tagid}";
+ $tagdata = $this->miraklRequest('GET', $endpoint);
+ $tagiso = $this->langidToIso[intval($tagdata->tag->id_lang)];
+ $tagvalue = strval($tagdata->tag->name);
+ if (!array_key_exists($tagiso, $keywords))
+ $keywords[$tagiso] = [];
+ $keywords[$tagiso][] = $tagvalue;
+ }
+ $res['metakeywords_de'] = join(',', $keywords['de'] ?? []);
+ $res['metakeywords_en'] = join(',', $keywords['en'] ?? []);
+
+ $images = [];
+ foreach ($product->product->associations->images->image as $img) {
+ $endpoint = "images/products/$productId/$img->id";
+ $imgdata = $this->miraklRequest('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->miraklRequest('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 miraklRequest($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);
+ }
+}
From 9d71d9812f3a02b6c543a0069a8812bf13c1113b Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 14 May 2024 11:00:56 +0200
Subject: [PATCH 02/87] mirakl Zwischenstand
---
www/eproosystem.php | 2 +-
www/pages/onlineshops.php | 2 +-
www/pages/shopimporter_mirakl.php | 79 ++++++++++++-----------
www/widgets/templates/_gen/shopexport.tpl | 2 +-
4 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/www/eproosystem.php b/www/eproosystem.php
index 560f7a59..4e96c6bd 100644
--- a/www/eproosystem.php
+++ b/www/eproosystem.php
@@ -1111,7 +1111,7 @@ if (typeof document.hidden !== \"undefined\") { // Opera 12.10 and Firefox 18 an
}
// userd edit ajax call
- $poll = true;
+// $poll = true;
if($poll) {
$this->addPollJs($module, $action, $id);
}
diff --git a/www/pages/onlineshops.php b/www/pages/onlineshops.php
index a1eea6e4..7e1f015e 100644
--- a/www/pages/onlineshops.php
+++ b/www/pages/onlineshops.php
@@ -3339,7 +3339,7 @@ INNER JOIN shopexport s ON
}
if($this->app->Secure->GetPOST('pruefen')) {
-
+
$className = 'Remote';
$methodName = 'RemoteConnection';
$r = new ReflectionMethod($className, $methodName);
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index e7b6b6e2..5a4cb70d 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -45,14 +45,14 @@ class Shopimporter_Mirakl extends ShopimporterBase
'typ' => 'checkbox',
'bezeichnung' => '{|Protokollierung im Logfile|}:'
],
- 'textekuerzen' => [
+/* '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|}:',
@@ -65,9 +65,9 @@ class Shopimporter_Mirakl extends ShopimporterBase
],
'shopidmirakl' => [
'typ' => 'text',
- 'bezeichnung' => '{|Shop ID des Shops|}:',
+ 'bezeichnung' => '{|Shop ID des Shops (optional, int64)|}:',
'size' => 40,
- ],
+ ],/*
'steuergruppen' => [
'typ' => 'text',
'bezeichnung' => '{|Steuergruppenmapping|}:',
@@ -107,7 +107,7 @@ class Shopimporter_Mirakl extends ShopimporterBase
'typ' => 'checkbox',
'bezeichnung' => '{|Artikelpreis im Shop anzeigen|}:',
'col' => 2
- ],
+ ],*/
]
];
}
@@ -136,15 +136,39 @@ class Shopimporter_Mirakl extends ShopimporterBase
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
}
+ private function miraklRequest(string $endpoint, array $postdata = null, bool $raw = false)
+ {
+ $ch = curl_init($this->shopUrl.$endpoint);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: ".$this->apiKey));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ if (!empty($postdata)) {
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ }
+
+ $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);
+ }
+
+
public function ImportAuth() {
- $ch = curl_init($this->shopUrl);
- curl_setopt($ch, CURLOPT_USERNAME, $this->apiKey);
+ $ch = curl_init($this->shopUrl."version");
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: ".$this->apiKey));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
- $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
- if ($code == 200)
- return 'success';
-
+ $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
+ if ($code == 200) {
+ return 'success '.print_r($response,true);
+ }
return $response;
}
@@ -317,7 +341,11 @@ class Shopimporter_Mirakl extends ShopimporterBase
public function ImportGetArticleList()
{
$result = [];
- $response = $this->miraklRequest('GET', 'products?display=[reference]');
+ $response = $this->miraklRequest('offers');
+
+ print_r($response);
+ exit();
+
foreach ($response->products->product as $product) {
$result[] = $product->reference;
}
@@ -454,30 +482,5 @@ class Shopimporter_Mirakl extends ShopimporterBase
$this->app->erp->Logfile($message, print_r($dump, true));
}
}
-
- private function miraklRequest($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);
- }
+
}
diff --git a/www/widgets/templates/_gen/shopexport.tpl b/www/widgets/templates/_gen/shopexport.tpl
index c0241d10..4255bffd 100644
--- a/www/widgets/templates/_gen/shopexport.tpl
+++ b/www/widgets/templates/_gen/shopexport.tpl
@@ -98,7 +98,7 @@
{|Aktion|}
From 55e7934fe4dc7925e39f1ff072e7573fff03a4b9 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 14 May 2024 11:00:56 +0200
Subject: [PATCH 03/87] mirakl Zwischenstand
---
www/eproosystem.php | 2 +-
www/lib/class.remote.php | 8 +-
www/pages/artikel.php | 1 +
www/pages/onlineshops.php | 2 +-
www/pages/shopimporter_mirakl.php | 326 +++++++++++++---------
www/pages/verbindlichkeit.php | 40 +--
www/widgets/templates/_gen/shopexport.tpl | 2 +-
7 files changed, 221 insertions(+), 160 deletions(-)
diff --git a/www/eproosystem.php b/www/eproosystem.php
index 560f7a59..4e96c6bd 100644
--- a/www/eproosystem.php
+++ b/www/eproosystem.php
@@ -1111,7 +1111,7 @@ if (typeof document.hidden !== \"undefined\") { // Opera 12.10 and Firefox 18 an
}
// userd edit ajax call
- $poll = true;
+// $poll = true;
if($poll) {
$this->addPollJs($module, $action, $id);
}
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 0eb67ede..ef8cabb8 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2775,6 +2775,7 @@ class Remote
}
return '';
}
+
if($shoptyp === 'intern')
{
if($modulename != '')
@@ -2788,15 +2789,16 @@ class Remote
$obj->getKonfig($id, $data);
}
$method = 'Import'.$action;
+
if(method_exists($obj,$method)) {
try {
$ret = $obj->$method();
}
catch(Exception $e) {
if($isActionAuth) {
+ return 'Fehler Auth: '.$e->getMessage();
+ }
return 'Fehler: '.$e->getMessage();
- }
- return '';
}
if(!empty($this->app->stringcleaner)){
@@ -2804,6 +2806,8 @@ class Remote
}
$this->parseReturn($ret, $id, $action);
return $ret;
+ } else {
+ return 'Fehler: Funktion nicht implementiert: '.$method;
}
}elseif($isActionAuth)
{
diff --git a/www/pages/artikel.php b/www/pages/artikel.php
index 34af81c7..129f3592 100644
--- a/www/pages/artikel.php
+++ b/www/pages/artikel.php
@@ -2867,6 +2867,7 @@ class Artikel extends GenArtikel {
}
$pageContents = $this->app->remote->RemoteSendArticleList($shop,$artikel,$extartikelnummer);
+
$check = strpos($pageContents ,'error:');
$msg = '';
if(!empty($pageContents) && is_array($pageContents)) {
diff --git a/www/pages/onlineshops.php b/www/pages/onlineshops.php
index a1eea6e4..7e1f015e 100644
--- a/www/pages/onlineshops.php
+++ b/www/pages/onlineshops.php
@@ -3339,7 +3339,7 @@ INNER JOIN shopexport s ON
}
if($this->app->Secure->GetPOST('pruefen')) {
-
+
$className = 'Remote';
$methodName = 'RemoteConnection';
$r = new ReflectionMethod($className, $methodName);
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index e7b6b6e2..8352e5d0 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -11,7 +11,6 @@ class Shopimporter_Mirakl extends ShopimporterBase
private $app;
private $intern;
private $shopid;
- private $data;
private $protocol;
private $apiKey;
private $shopUrl;
@@ -20,6 +19,8 @@ class Shopimporter_Mirakl extends ShopimporterBase
private $idbearbeitung;
private $idabgeschlossen;
+ public $data;
+
// TODO
private $langidToIso = [3 => 'de', 1 => 'en'];
private $taxationByDestinationCountry;
@@ -45,14 +46,14 @@ class Shopimporter_Mirakl extends ShopimporterBase
'typ' => 'checkbox',
'bezeichnung' => '{|Protokollierung im Logfile|}:'
],
- 'textekuerzen' => [
+/* '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|}:',
@@ -65,9 +66,9 @@ class Shopimporter_Mirakl extends ShopimporterBase
],
'shopidmirakl' => [
'typ' => 'text',
- 'bezeichnung' => '{|Shop ID des Shops|}:',
+ 'bezeichnung' => '{|Shop ID des Shops (optional, int64)|}:',
'size' => 40,
- ],
+ ],/*
'steuergruppen' => [
'typ' => 'text',
'bezeichnung' => '{|Steuergruppenmapping|}:',
@@ -107,7 +108,7 @@ class Shopimporter_Mirakl extends ShopimporterBase
'typ' => 'checkbox',
'bezeichnung' => '{|Artikelpreis im Shop anzeigen|}:',
'col' => 2
- ],
+ ],*/
]
];
}
@@ -136,15 +137,44 @@ class Shopimporter_Mirakl extends ShopimporterBase
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
}
+ private function miraklRequest(string $endpoint, string $postdata = null, bool $raw = false)
+ {
+ $ch = curl_init($this->shopUrl.$endpoint);
+
+ $headers = array("Authorization: ".$this->apiKey);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ if (!empty($postdata)) {
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+ $headers[] = 'Content-Type: application/json';
+ }
+
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
+ $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);
+ }
+
+
public function ImportAuth() {
- $ch = curl_init($this->shopUrl);
- curl_setopt($ch, CURLOPT_USERNAME, $this->apiKey);
+ $ch = curl_init($this->shopUrl."version");
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: ".$this->apiKey));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
- $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
- if ($code == 200)
- return 'success';
-
+ $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
+ if ($code == 200) {
+ return 'success '.print_r($response,true);
+ }
return $response;
}
@@ -314,109 +344,180 @@ class Shopimporter_Mirakl extends ShopimporterBase
return $fetchedOrders;
}
+ /*
+ * Fetches article list from the shop, puts them into table shopexport_getarticles, starts the prozessstarter getarticles which fetches details for each article via ImportGetArticle()
+ */
public function ImportGetArticleList()
{
$result = [];
- $response = $this->miraklRequest('GET', 'products?display=[reference]');
- foreach ($response->products->product as $product) {
- $result[] = $product->reference;
+ $response = $this->miraklRequest('offers', raw: true);
+
+ $result_array = json_decode($response);
+
+ foreach ($result_array->offers as $offer) {
+ $result[] = $offer->shop_sku;
}
array_unique($result);
return $result;
}
+ /*
+ * Fetches article details from the shop
+ */
public function ImportGetArticle()
{
- $nummer = $this->data['nummer'];
- if (isset($this->data['nummerintern'])) {
- $nummer = $this->data['nummerintern'];
- }
- $nummer = trim($nummer);
+ throw new Exception("Not implemented");
+ }
- if (empty($nummer))
- return;
+ /*
+ * Send articles to shop
+ */
- $productsresult = $this->miraklRequest('GET', 'products?filter[reference]='.$nummer);
- $combinationsresult = $this->miraklRequest('GET', 'combinations?filter[reference]='.$nummer);
- $numberOfCombinations = count($combinationsresult->combinations->combination);
- $numberOfProducts = count($productsresult->products->product);
- $numberOfResults = $numberOfProducts + $numberOfCombinations;
- if ($numberOfResults > 1) {
- $this->Log('Got multiple results from Shop', $this->data);
- return;
- }
- elseif ($numberOfResults < 1) {
- $this->Log('No product found in Shop', $this->data);
- return;
- }
+ public function ImportSendList()
+ {
+ $articleList = $this->CatchRemoteCommand('data');
+
+ //print_r($articleList);
+
+ /*
+ Array
+(
+ [0] => Array
+ (
+ [artikel] => 1
+ [artikelid] => 1
+ [nummer] => 700001
+ [inaktiv] =>
+ [name_de] => Schraube M10x20
+ [name_en] =>
+ [einheit] =>
+ [hersteller] =>
+ [herstellernummer] =>
+ [ean] =>
+ [artikelnummer_fremdnummern] =>
+ [kurztext_de] =>
+ [kurztext_en] =>
+ [anabregs_text] =>
+ [anabregs_text_en] =>
+ [beschreibung_de] =>
+ [beschreibung_en] =>
+ [uebersicht_de] =>
+ [uebersicht_en] =>
+ [herkunftsland] => DE
+ [texteuebertragen] => 1
+ [metadescription_de] =>
+ [metadescription_en] =>
+ [metakeywords_de] =>
+ [metakeywords_en] =>
+ [metatitle_de] =>
+ [metatitle_en] =>
+ [links_de] =>
+ [altersfreigabe] =>
+ [links_en] =>
+ [startseite_de] =>
+ [startseite_en] =>
+ [restmenge] => 0
+ [startseite] => 0
+ [standardbild] =>
+ [herstellerlink] =>
+ [lieferzeit] =>
+ [lieferzeitmanuell] =>
+ [gewicht] =>
+ [laenge] => 0.00
+ [breite] => 0.00
+ [hoehe] => 0.00
+ [wichtig] => 0
+ [porto] => 0
+ [gesperrt] => 0
+ [sperrgrund] =>
+ [gueltigbis] => 0000-00-00
+ [umsatzsteuer] => normal
+ [ausverkauft] => 0
+ [variante] => 0
+ [variante_von_id] => 0
+ [variantevon] =>
+ [pseudopreis] => 0.00
+ [keinrabatterlaubt] => 0
+ [einkaufspreis] => 0.12000000
+ [pseudolager] =>
+ [downloadartikel] => 0
+ [zolltarifnummer] =>
+ [typ] => 1_kat
+ [kategoriename] => Handelsware (100000)
+ [steuer_art_produkt] => 0
+ [steuer_art_produkt_download] => 0
+ [anzahl_bilder] => 0
+ [anzahl_lager] =>
+ [lagerkorrekturwert] => -0
+ [autolagerlampe] => 0
+ [crosssellingartikel] => Array
+ (
+ )
- $isCombination = $numberOfCombinations > 0;
- if ($isCombination) {
- $combinationId = intval($combinationsresult->combinations->combination->attributes()->id);
- $combination = $this->miraklRequest('GET', "combinations/$combinationId");
- $productId = intval($combination->combination->id_product);
- } else {
- $productId = intval($productsresult->products->product->attributes()->id);
- }
- $product = $this->miraklRequest('GET', "products/$productId");
- $res = [];
- if ($isCombination) {
- $res['nummer'] = strval($combination->combination->reference);
- $res['artikelnummerausshop'] = strval($combination->combination->reference);
- $res['ean'] = strval($combination->combination->ean13);
- $res['preis_netto'] = floatval($product->product->price) + floatval($combination->combination->price);
- } else {
- $res['nummer'] = strval($product->product->reference);
- $res['artikelnummerausshop'] = strval($product->product->reference);
- $res['ean'] = strval($product->product->ean13);
- $res['preis_netto'] = floatval($product->product->price);
- }
- $names = $this->toMultilangArray($product->product->name->language);
- $descriptions = $this->toMultilangArray($product->product->description->language);
- $shortdescriptions = $this->toMultilangArray($product->product->description_short->language);
- $metadescriptions = $this->toMultilangArray($product->product->meta_description->language);
- $metakeywords = $this->toMultilangArray($product->product->meta_keywords->language);
- $metatitles = $this->toMultilangArray($product->product->meta_title->language);
- $res['name'] = $names['de'];
- $res['name_en'] = $names['en'];
- $res['uebersicht_de'] = $descriptions['de'];
- $res['uebersicht_en'] = $descriptions['en'];
- $res['kurztext_de'] = strip_tags($shortdescriptions['de']);
- $res['kurztext_en'] = strip_tags($shortdescriptions['en']);
- $res['hersteller'] = strval($product->product->manufacturer_name);
- $res['metatitle_de'] = $metatitles['de'];
- $res['metatitle_en'] = $metatitles['en'];
- $res['metadescription_de'] = $metadescriptions['de'];
- $res['metadescription_en'] = $metadescriptions['en'];
+ [waehrung] => EUR
+ [preis] => 0.16000000
+ [steuersatz] => 19
+ [staffelpreise_standard] => Array
+ (
+ [0] => Array
+ (
+ [ab_menge] => 1.0000
+ [preis] => 0.16000000
+ [bruttopreis] => 0.1904
+ [waehrung] => EUR
+ )
- $tags = $product->product->associations->tags->tag;
- $keywords = [];
- foreach ($tags as $tag) {
- $tagid = intval($tag->id);
- $endpoint = "tags/{$tagid}";
- $tagdata = $this->miraklRequest('GET', $endpoint);
- $tagiso = $this->langidToIso[intval($tagdata->tag->id_lang)];
- $tagvalue = strval($tagdata->tag->name);
- if (!array_key_exists($tagiso, $keywords))
- $keywords[$tagiso] = [];
- $keywords[$tagiso][] = $tagvalue;
- }
- $res['metakeywords_de'] = join(',', $keywords['de'] ?? []);
- $res['metakeywords_en'] = join(',', $keywords['en'] ?? []);
+ )
- $images = [];
- foreach ($product->product->associations->images->image as $img) {
- $endpoint = "images/products/$productId/$img->id";
- $imgdata = $this->miraklRequest('GET', $endpoint, '', true);
- $images[] = [
- 'content' => base64_encode($imgdata),
- 'path' => "$img->id.jpg",
- 'id' => $img->id
- ];
- }
- $res['bilder'] = $images;
- return $res;
+ [staffelpreise] => Array
+ (
+ [0] => Array
+ (
+ [ab_menge] => 1.0000
+ [preis] => 0.16000000
+ [bruttopreis] => 0.1904
+ [waehrung] => EUR
+ )
+
+ )
+
+ [bruttopreis] => 0.1904
+ [checksum] =>
+ [variantevorhanden] => 0
+ )
+
+)
+
+ */
+
+ $offers_for_mirakl = array();
+
+ foreach ($articleList as $article) {
+ $offers_for_mirakl[] = array(
+ 'product_id_type' => 'sku', // ?!?!
+ 'price' => $article['preis'],
+// 'pricing_unit' => $article['waehrung'],
+ 'product_id' => $article['nummer'],
+ 'shop_sku' => $article['nummer'],
+ 'state_code' => '11', // ?!?!
+ 'update_delete' => 'update' // update or delete
+ );
+ }
+
+ $data_for_mirakl = array();
+ $data_for_mirakl['offers'] = $offers_for_mirakl;
+
+ $json_for_mirakl = json_encode($data_for_mirakl);
+
+ $result = [];
+ $response = $this->miraklRequest('offers', postdata: $json_for_mirakl, raw: true);
+
+ $result_array = json_decode($response);
+
+
+ print_r($result_array); // stdClass Object ( [import_id] => 69751 )
+ exit();
}
private function toMultilangArray($xmlnode) {
@@ -454,30 +555,5 @@ class Shopimporter_Mirakl extends ShopimporterBase
$this->app->erp->Logfile($message, print_r($dump, true));
}
}
-
- private function miraklRequest($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);
- }
+
}
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 374db9cb..99a1d0a4 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -228,11 +228,7 @@ class Verbindlichkeit {
$defaultorder = 1;
$defaultorderdesc = 0;
- $offen_menge = "TRIM(IF(
- pd.menge > COALESCE(vp.menge,0),
- pd.menge - COALESCE(vp.menge,0),
- 0
- ))+0";
+ $offen_menge = "";
$auswahl = array (
' '
);
@@ -303,7 +297,7 @@ class Verbindlichkeit {
// END Toggle filters
$sql = "
- SELECT SQL_CALC_FOUND_ROWS * FROM (
+ SELECT * FROM (
SELECT
pa.id pa_id,
".$this->app->erp->ConcatSQL($auswahl)." AS auswahl,
@@ -316,11 +310,7 @@ class Verbindlichkeit {
art.name_de,
pd.bemerkung,
pd.menge,
- IF(
- pd.menge > COALESCE(vp.menge,0),
- pd.menge - COALESCE(vp.menge,0),
- 0
- ) offen_menge,
+ 0 offen_menge,
".$this->app->erp->ConcatSQL($werte).",
".$this->app->erp->ConcatSQL($preise)." AS preis,
if(art.umsatzsteuer = '',art.steuersatz,art.umsatzsteuer) steuer,
@@ -329,38 +319,28 @@ class Verbindlichkeit {
CONCAT(skadr.sachkonto,' ',skadr.beschriftung)
) AS sachkonto
FROM
- paketannahme pa
- INNER JOIN paketdistribution pd ON
+ paketdistribution pd
+ LEFT JOIN paketannahme pa ON
pd.paketannahme = pa.id
- INNER JOIN artikel art ON
+ LEFT JOIN artikel art ON
art.id = pd.artikel
LEFT JOIN adresse adr ON
adr.id = pa.adresse
LEFT JOIN bestellung_position bp ON
bp.id = pd.bestellung_position
LEFT JOIN bestellung b ON
- b.id = bp.bestellung
- LEFT JOIN(
- SELECT
- paketdistribution,
- SUM(menge) AS menge
- FROM
- verbindlichkeit_position vp
- GROUP BY
- paketdistribution
- ) vp
- ON
- vp.paketdistribution = pd.id
+ b.id = bp.bestellung
LEFT JOIN
kontorahmen skart ON skart.id = art.kontorahmen
LEFT JOIN
kontorahmen skadr ON skadr.id = adr.kontorahmen
- WHERE pa.adresse = ".$lieferant." AND pd.vorlaeufig IS NULL".$innerwhere."
+ WHERE pa.adresse = '".$lieferant."'
+ GROUP BY pd.id
) temp
";
$count = "";
-// $groupby = "";
+ $groupby = "";
break;
case 'verbindlichkeit_positionen':
diff --git a/www/widgets/templates/_gen/shopexport.tpl b/www/widgets/templates/_gen/shopexport.tpl
index c0241d10..4255bffd 100644
--- a/www/widgets/templates/_gen/shopexport.tpl
+++ b/www/widgets/templates/_gen/shopexport.tpl
@@ -98,7 +98,7 @@
{|Aktion|}
From 823f35e44dc420b19aab8253ac7f9dad044d451c Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 22 May 2024 11:23:49 +0200
Subject: [PATCH 04/87] Bugfix shop error message
---
www/pages/artikel.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/pages/artikel.php b/www/pages/artikel.php
index 129f3592..4f583554 100644
--- a/www/pages/artikel.php
+++ b/www/pages/artikel.php
@@ -2868,7 +2868,7 @@ class Artikel extends GenArtikel {
$pageContents = $this->app->remote->RemoteSendArticleList($shop,$artikel,$extartikelnummer);
- $check = strpos($pageContents ,'error:');
+ $check = strpos((string) $pageContents ,'error:');
$msg = '';
if(!empty($pageContents) && is_array($pageContents)) {
if(!empty($pageContents['status']) && !empty($pageContents['message'])) {
From 5c96cff8c336e4cb74f444aac7ecda71e7b9c118 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 22 May 2024 11:25:13 +0200
Subject: [PATCH 05/87] onlineshops changed options layout
---
www/widgets/templates/_gen/shopexport.tpl | 28 ++++++++++++++++++-----
www/widgets/widget.shopexport.php | 4 ++--
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/www/widgets/templates/_gen/shopexport.tpl b/www/widgets/templates/_gen/shopexport.tpl
index 4255bffd..fab71180 100644
--- a/www/widgets/templates/_gen/shopexport.tpl
+++ b/www/widgets/templates/_gen/shopexport.tpl
@@ -53,20 +53,36 @@
{|Bezeichnung|}:
[BEZEICHNUNG][MSGBEZEICHNUNG]
- {|Import-Modus|}: [SELMODUS]
{|Aktiv|}:
[AKTIV][MSGAKTIV]
- {|Nur 1 Auftrag pro Anfrage|}:
- [EINZELSYNC][MSGEINZELSYNC]
{|Projekt|}:
[PROJEKT][MSGPROJEKT]
- {|Aufträge in Zwischentabelle|}: [WARTESCHLANGE] {|Freigabe erfolgt manuell|}
-
- {|Abholmodus|}: [SELABHOLMODUS] {|Anzahl abholen begrenzen|}: [MAXMANUELL][MSGMAXMANUELL] {|0 bedeutet Begrenzung auf 100|}
+
+
+ {|Abholmodus|}: [SELABHOLMODUS]
+
+
+ {|Anzahl abholen begrenzen|}:
+ [MAXMANUELL][MSGMAXMANUELL]
+ {|0 bedeutet Begrenzung auf 100|}
+
+
+ {|Import-Modus|}: [SELMODUS]
+
+
+ {|Nur 1 Auftrag pro Anfrage|}:
+ [EINZELSYNC][MSGEINZELSYNC]
+
+
+
+ {|Aufträge in Zwischentabelle|}: [WARTESCHLANGE]
+ {|Freigabe erfolgt manuell|}
+
+
{|Datum von|}:
diff --git a/www/widgets/widget.shopexport.php b/www/widgets/widget.shopexport.php
index 3ff7c20e..0e6b8ed1 100644
--- a/www/widgets/widget.shopexport.php
+++ b/www/widgets/widget.shopexport.php
@@ -861,7 +861,7 @@ class WidgetShopexport extends WidgetGenShopexport
switch($typ)
{
case 'textarea':
- $aktcol .= '';
+ $aktcol .= '';
break;
case 'checkbox':
$aktcol .= ' ';
@@ -912,7 +912,7 @@ class WidgetShopexport extends WidgetGenShopexport
$aktcol .= ' ';
}
if(isset($val['info']) && $val['info']){
- $aktcol .= ' '.$val['info'].' ';
+ $aktcol .= ' '.$val['info'].' ';
}
if(isset($val['col']) && $val['col'] == 2)
{
From f479a12c848a1aa625ae706e0653f21ba5d986c0 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 22 May 2024 11:25:35 +0200
Subject: [PATCH 06/87] mirakl offer export
---
www/pages/shopimporter_mirakl.php | 1030 ++++++++++++-----------------
1 file changed, 425 insertions(+), 605 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 864b6a75..d64f21bd 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -6,623 +6,443 @@
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
*/
-class Shopimporter_Mirakl extends ShopimporterBase
-{
- private $app;
- private $intern;
- private $shopid;
- private $protocol;
- private $apiKey;
- private $shopUrl;
- private $createManufacturerAllowed = false;
- private $idsabholen;
- private $idbearbeitung;
- private $idabgeschlossen;
+class Shopimporter_Mirakl extends ShopimporterBase {
- public $data;
+ private $app;
+ private $intern;
+ private $shopid;
+ private $protocol;
+ private $apiKey;
+ private $shopUrl;
+ private $createManufacturerAllowed = false;
+ private $idsabholen;
+ private $idbearbeitung;
+ private $idabgeschlossen;
+ public $data;
+ // TODO
+ private $langidToIso = [3 => 'de', 1 => 'en'];
+ private $taxationByDestinationCountry;
+ private $orderSearchLimit;
- // TODO
- private $langidToIso = [3 => 'de', 1 => 'en'];
- private $taxationByDestinationCountry;
- private $orderSearchLimit;
+ private $category_identifier_source;
+ private $category_identifier_source_field;
+ private $product_identifier_type;
+ private $product_identifier_source;
+ private $product_identifier_source_field;
+ private $product_field_map;
+ private $offer_field_map;
-
- 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,
- ],
- 'shopidmirakl' => [
- 'typ' => 'text',
- 'bezeichnung' => '{|Shop ID des Shops (optional, int64)|}:',
- '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));
- }
-
- private function miraklRequest(string $endpoint, array $postdata = null, string $content_type = null, bool $raw = false)
- {
- $ch = curl_init($this->shopUrl.$endpoint);
-
- $headers = array("Authorization: ".$this->apiKey);
-
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- if (!empty($postdata)) {
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
- $headers[] = 'Content-Type: '.$content_type;
+ public function __construct($app, $intern = false) {
+ $this->app = $app;
+ $this->intern = $intern;
+ if ($intern)
+ return;
}
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_VERBOSE,true);
-
- $response = curl_exec($ch);
- if (curl_error($ch)) {
- $this->error[] = curl_error($ch);
- }
- curl_close($ch);
+ /*
+ * See widget.shopexport.php
+ */
- $information = curl_getinfo($ch);
- print_r($information);
-
- if ($raw)
- return $response;
-
- return simplexml_load_string($response);
- }
-
-
- public function ImportAuth() {
- $ch = curl_init($this->shopUrl."version");
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: ".$this->apiKey));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($ch);
- $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
- if ($code == 200) {
- return 'success '.print_r($response,true);
- }
- return $response;
- }
-
- /*
- * Fetches article list from the shop, puts them into table shopexport_getarticles, starts the prozessstarter getarticles which fetches details for each article via ImportGetArticle()
- */
- public function ImportGetArticleList()
- {
- $result = [];
-
- $response = $this->miraklRequest('offers', raw: true);
-
- $result_array = json_decode($response);
-
- foreach ($result_array->offers as $offer) {
- $result[] = $offer->shop_sku;
- }
-
- array_unique($result);
- return $result;
- }
-
- /*
- * Fetches article details from the shop
- */
- public function ImportGetArticle()
- {
- throw new Exception("Not implemented");
- }
-
- /*
- * Send articles to shop
- */
-
- public function ImportSendList()
- {
- $articleList = $this->CatchRemoteCommand('data');
-
- //print_r($articleList);
-
- /*
- Array
-(
- [0] => Array
- (
- [artikel] => 1
- [artikelid] => 1
- [nummer] => 700001
- [inaktiv] =>
- [name_de] => Schraube M10x20
- [name_en] =>
- [einheit] =>
- [hersteller] =>
- [herstellernummer] =>
- [ean] =>
- [artikelnummer_fremdnummern] =>
- [kurztext_de] =>
- [kurztext_en] =>
- [anabregs_text] =>
- [anabregs_text_en] =>
- [beschreibung_de] =>
- [beschreibung_en] =>
- [uebersicht_de] =>
- [uebersicht_en] =>
- [herkunftsland] => DE
- [texteuebertragen] => 1
- [metadescription_de] =>
- [metadescription_en] =>
- [metakeywords_de] =>
- [metakeywords_en] =>
- [metatitle_de] =>
- [metatitle_en] =>
- [links_de] =>
- [altersfreigabe] =>
- [links_en] =>
- [startseite_de] =>
- [startseite_en] =>
- [restmenge] => 0
- [startseite] => 0
- [standardbild] =>
- [herstellerlink] =>
- [lieferzeit] =>
- [lieferzeitmanuell] =>
- [gewicht] =>
- [laenge] => 0.00
- [breite] => 0.00
- [hoehe] => 0.00
- [wichtig] => 0
- [porto] => 0
- [gesperrt] => 0
- [sperrgrund] =>
- [gueltigbis] => 0000-00-00
- [umsatzsteuer] => normal
- [ausverkauft] => 0
- [variante] => 0
- [variante_von_id] => 0
- [variantevon] =>
- [pseudopreis] => 0.00
- [keinrabatterlaubt] => 0
- [einkaufspreis] => 0.12000000
- [pseudolager] =>
- [downloadartikel] => 0
- [zolltarifnummer] =>
- [typ] => 1_kat
- [kategoriename] => Handelsware (100000)
- [steuer_art_produkt] => 0
- [steuer_art_produkt_download] => 0
- [anzahl_bilder] => 0
- [anzahl_lager] =>
- [lagerkorrekturwert] => -0
- [autolagerlampe] => 0
- [crosssellingartikel] => Array
- (
- )
-
- [waehrung] => EUR
- [preis] => 0.16000000
- [steuersatz] => 19
- [staffelpreise_standard] => Array
- (
- [0] => Array
- (
- [ab_menge] => 1.0000
- [preis] => 0.16000000
- [bruttopreis] => 0.1904
- [waehrung] => EUR
- )
-
- )
-
- [staffelpreise] => Array
- (
- [0] => Array
- (
- [ab_menge] => 1.0000
- [preis] => 0.16000000
- [bruttopreis] => 0.1904
- [waehrung] => EUR
- )
-
- )
-
- [bruttopreis] => 0.1904
- [checksum] =>
- [variantevorhanden] => 0
- )
-
-)
-
- */
-
-
- foreach ($articleList as $article) {
-
- /*
- * Export product
- POST P41 - Import products to the operator information system
- Url
- /api/products/imports
- Description
-
- Import products to the operator information system
-
- Returns the import identifier to track the status of the import
- Call frequencies
-
- Recommended: Every hour, for each seller
- Maximum: Every 15 minutes, for each seller
-
- Query parameters
-
- shop_id
- optional
- integer - int64
- Use this parameter when your user has access to several shops. If not specified, the shop_id from your default shop will be used.
-
- HTTP Return Codes
-
- 201 - Created
- Response Headers
-
- Location - Pre-calculated URL to call to get the import status
- Input (body)
-
- file
- required
- string - binary
- Import file (CSV or XML or XLSX) to upload. Use multipart/form-data with name file
-
- operator_format
- optional
- boolean
- Force the use of the operator product format
- Default to:false
- Output (response)
-
- import_id
- required
- integer - int64
- */
-
- $file_contents = 'category;Product.SellerProductID;SHOP.PRODUCT.TITLE;Product.EAN.Main_MP;ATT.GLOBAL.Brandname;ATT.GLOBAL.ManufacturerAID;ATT.GLOBAL.ManufacturerTypeDesc;Product.BaseUnit;ATT.GLOBAL.NoCUperOU;ATT.GLOBAL.NoCUperOU__UNIT;Product.DetailpageVariantValue_MP;Product.RoHS.Compliant;ATT.Text.ProductHeadline;ATT.Text.ProductFeatures;ATT.Text.ProductTextLong;ATT.Text.ProductFacts;ATT.TXT.ProductSpecifications_MP;ATT.Text.ProductDelivery;ATT.Text.ProductSysReq;ATT.Text.ProductSpecialAdd;ATT.CPCS.ArticleKeywords;Product.PrimaryImageURL_MP;Product.Image02URL_MP;Product.Image03URL_MP;Product.Image04URL_MP;Product.Image05URL_MP;Product.ImageIllustration01URL_MP;Product.ImageIllustration02URL_MP;Product.ImageSymbol01URL_MP;Product.ImageSymbol02URL_MP;Product.ImageSymbol03URL_MP;Product.ImageSymbol04URL_MP;Product.ImageSymbol05URL_MP;Product.ImageAward01URL_MP;Product.ImageAward02URL_MP;Product.ImageEnergyEfficiencyLabelURL_MP;Product.DocumentEnergyEfficiencyFicheURL_MP;Product.DocumentDatasheet01URL_MP;Product.DocumentManual01URL_MP;Product.DocumentSecurityAdvisory01URL_MP;Product.DocumentCertificate01URL_MP;Product.DocumentCertificate02URL_MP;Product.DocumentCertificate03URL_MP;Product.Video01URL_MP;Product.Video02URL_MP;Product.TaxIndicator;Product.InvalidationFlag;Product.Disposal.EPR.Category@FR;Product.Disposal.ElektroG.Code@DE;Product.Disposal.ElektroG.Brand@DE;Product.CO2.Footprint;Product.CO2.Footprint__UNIT;Product.Order-Based-Production;ATT.PRODPSEC.SOURCEVOLTAGEMIN;ATT.LOV.MEASUREMENT-CATEGORY;ATT.LOV.MOUNTING_MEASUREMENT_FEATURES;ATT.INSTALLATION_WIDTH;ATT.NUM.SOURCE_VOLTAGE;ATT.PRODSPEC.SOURCEVOLTAGEMAX__UNIT;ATT.WEIGHT.VALUE;ATT.IP;ATT.DIMENSION.LENGTH;ATT.NUM.SOURCE_VOLTAGE__UNIT;ATT.DIMENSION.WIDTH;ATT.NUM.MEASURING_RANGE_UNIVERSAL_MAX;ATT.DIMENSION.DIAMETER;ATT.NUM.INSTALLATION_HEIGHT;ATT.PRODSPEC.SOURCEVOLTAGEMAX;ATT.FRAME-HEIGHT__UNIT;ATT.FRAME-HEIGHT;ATT.LOV.MEASURING_FUNCTION;ATT.NUM.FRAME_WIDTH__UNIT;ATT.MOUNTING_DEPTH__UNIT;ATT.LOV.DISPLAY_LIGHTING;ATT.INSTALLATION_WIDTH__UNIT;ATT.NUM.DISPLAY_COUNTS;ATT.WEIGHT.VALUE__UNIT;ATT.DIGIT_HEIGHT__UNIT;ATT.DIMENSION.LENGTH__UNIT;ATT.DIMENSION.WIDTH__UNIT;ATT.NUM.MEASURING_RANGE_UNIVERSAL_MIN__UNIT;Product.Disposal.ElektroG.Pickup;ATT.DIMENSION.DIAMETER__UNIT;ATT.NUM.INSTALLATION_HEIGHT__UNIT;ATT.CALIBRATION_POSSIBLE;ATT.MOUNTING_DEPTH;ATT.NUM.MEASURING_RANGE_UNIVERSAL_MIN;ATT.DISPLAY_TYPE;ATT.DIMENSION.HEIGHT;ATT.KAT.MOUNTING_MEASUREMENT_TYPE;ATT.PRODPSEC.SOURCEVOLTAGEMIN__UNIT;ATT.COLOR;ATT.DIGIT_HEIGHT;ATT.DIMENSION.HEIGHT__UNIT;ATT.INTERFACE;ATT.NUM.FRAME_WIDTH;ATT.LOV.INTERFACES_COMPONENTS;ATT.INT.RACK_UNIT;ATT.NUM.MEASURING_RANGE_UNIVERSAL_MAX__UNIT;ATT.INT.RACK_UNIT__UNIT;ATT.LOV.CALIBRATION_TO;Product.DetailpageVariantGroup_MP
-1105510;700002;"OpenXE Schraube M10x20";;Brand.5105083;OpenXE Schraube M10x20 vom Hersteller;;ST;1;unece.unit.C62;;ROHS-2;;;;;;;;;;https://conradb2b-prod.mirakl.net/mmp/media/product-media/28071/CIRCUTOR_DHC_CPM_1.png;;;;;;;;;;;;;;;;https://tde-instruments.de/wp-content/uploads/CIRCUTOR_DHC-96_CPM-HS_Datenblatt_Englisch.pdf;https://tde-instruments.de/wp-content/uploads/CIRCUTOR_DHC-96_CPM_Anleitung_Englisch.pdf;;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;';
-
- $postdata = array('file' => new CURLStringFile($file_contents,'file.csv'));
-
- $response = $this->miraklRequest('products/imports', postdata: $postdata, content_type: 'multipart/form-data', raw: true);
-
- print_r($response);
- exit();
-
- /*
- * Export offer
- */
- $offers_for_mirakl[] = array(
- 'product_id_type' => 'SHOP_SKU', // ?!?!
- 'price' => $article['preis'],
-// 'pricing_unit' => $article['waehrung'],
- 'product_id' => $article['nummer'],
- 'shop_sku' => $article['nummer'],
- 'state_code' => '11', // ?!?!
- 'update_delete' => 'update' // update or delete
- );
- }
-
- json_decode(null);
-
- $data_for_mirakl = array();
- $data_for_mirakl['offers'] = $offers_for_mirakl;
-
- $json_for_mirakl = json_encode($data_for_mirakl);
-
- $result = [];
- $response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
-
- $result_array = json_decode($response);
-
-
- print_r($result_array); // stdClass Object ( [import_id] => 69751 )
- exit();
- }
-
- 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->miraklRequest('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));
- }
- }
-
- public function ImportDeleteAuftrag()
- {
- $auftrag = $this->data['auftrag'];
-
- $obj = $this->miraklRequest('GET', 'order_histories?schema=blank');
- $obj->order_history->id_order = $auftrag;
- $obj->order_history->id_order_state = $this->idbearbeitung;
-
- $this->miraklRequest('POST', 'order_histories', $obj->asXML());
- }
-
- public function ImportUpdateAuftrag()
- {
- $auftrag = $this->data['auftrag'];
-
- $obj = $this->miraklRequest('GET', 'order_histories?schema=blank');
- $obj->order_history->id_order = $auftrag;
- $obj->order_history->id_order_state = $this->idabgeschlossen;
-
- $this->miraklRequest('POST', 'order_histories', $obj->asXML());
-
- $req = $this->miraklRequest('GET', "order_carriers?filter[id_order]=$auftrag&display=[id]");
- $orderCarrierId = strval($req->order_carriers->order_carrier[0]->id);
- $req = $this->miraklRequest('GET', "order_carriers/$orderCarrierId");
- $req->order_carrier->tracking_number = $this->data['tracking'];
- $this->miraklRequest('PUT', "order_carriers/$orderCarrierId", $req->asXML());
- }
-
- 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) {
- $order = $this->miraklRequest('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['versandkostennetto'] = strval($order->total_shipping_tax_excl);
- $cart['bestelldatum'] = strval($order->date_add);
-
- $carrier = $this->miraklRequest('GET', "carriers/$order->id_carrier");
- $cart['lieferung'] = strval($carrier->carrier->name);
-
- $customer = $this->miraklRequest('GET', "customers/$order->id_customer");
- $cart['email'] = strval($customer->customer->email);
-
- $language = $this->miraklRequest('GET', "languages/{$customer->customer->id_lang}");
- if ($language->language->iso_code == "en") {
- $cart['kunde_sprache'] = 'englisch';
- }
-
- $invoiceAddress = $this->miraklRequest('GET', "addresses/$order->id_address_invoice");
- $invoiceAddress = $invoiceAddress->address;
- $invoiceCountry = $this->miraklRequest('GET', "countries/$invoiceAddress->id_country");
- $invoiceCountry = $invoiceCountry->country;
- $cart['name'] = "$invoiceAddress->firstname $invoiceAddress->lastname";
- if (!empty(strval($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 (strval($order->id_address_invoice) != strval($order->id_address_delivery)) {
- $deliveryAddress = $this->miraklRequest('GET', "addresses/$order->id_address_delivery");
- $deliveryAddress = $deliveryAddress->address;
- $deliveryCountry = $this->miraklRequest('GET', "countries/$deliveryAddress->id_country");
- $deliveryCountry = $deliveryCountry->country;
- $cart['abweichendelieferadresse'] = 1;
- $cart['lieferadresse_name'] = "$deliveryAddress->firstname $deliveryAddress->lastname";
- if (!empty(strval($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'];
- }
- $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);
-
- 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) {
- $article = [
- 'articleid' => strval($order_row->product_reference),
- 'name' => strval($order_row->product_name),
- 'quantity' => strval($order_row->product_quantity),
- 'price_netto' => strval($order_row->unit_price_tax_excl),
+ 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,
+ ],
+ 'shopid' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Shop ID des Shops|}:',
+ 'size' => 40,
+ 'info' => 'optional, int64'
+ ],
+ 'category_identifier_source' => [
+ 'typ' => 'select',
+ 'bezeichnung' => '{|Kategorie-Identifizierer|}:',
+ 'size' => 40,
+ 'optionen' => ['Kategorie' => '{|Kategorie|}', 'Freifeld' => '{|Freifeld|}', 'Eigenschaft' => '{|Eigenschaft|}'],
+ 'info' => 'Feld in OpenXE für die Zuordnung der Artikel zu den Katalogkategorien in Mirakl'
+ ],
+ 'category_identifier_source_field' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Kategorie-Identifizierer Freifeld oder Eigenschaft|}:',
+ 'size' => 40,
+ 'info' => 'Wenn oben Freifeld oder Eigenschaft gewählt wurde'
+ ],
+ 'product_identifier_type' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Produkt-Identifizierertyp in Mirakl|}:',
+ 'size' => 40,
+ 'info' => 'Z.B. EAN'
+ ],
+ 'product_identifier_source' => [
+ 'typ' => 'select',
+ 'bezeichnung' => '{|Produkt-Identifizierer|}:',
+ 'size' => 40,
+ 'optionen' => ['Artikelnummer' => '{|Artikelnummer|}', 'Herstellernummer' => '{|Herstellernummer|}', 'EAN' => '{|EAN|}', 'Freifeld' => 'Freifeld', 'Eigenschaft' => 'Eigenschaft'],
+ 'info' => 'Feld in OpenXE für die Zuordnung der Artikel zu den Katalogprodukten in Mirakl'
+ ],
+ 'product_identifier_source_field' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Produkt-Identifizierer Freifeld oder Eigenschaft|}:',
+ 'size' => 40,
+ 'info' => 'Wenn oben Freifeld oder Eigenschaft gewählt wurde'
+ ],
+ 'product_field_map' => [
+ 'typ' => 'textarea',
+ 'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
+ 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: Artikelnummer, Artikelname, Einheit, Hersteller, Herstellernummer, EAN oder eine konkrete Artikeleigenschaft'
+ ],
+ 'offer_field_map' => [
+ 'typ' => 'textarea',
+ 'bezeichnung' => '{|Zuordnung Angebots-Felder je Kategorie (JSON)|}:',
+ 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: nummer, name_de, einheit, hersteller, herstellernummer, ean u.v.m. Freifelder: {"freifeld": "Freifeld1-40"}, Eigenschaften: {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: {"wert": "xyz"}, Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. {"freifeld": "Freifeld1", "zusatzfeld": true}'
+ ],
+ /*
+ '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
+ ], */
+ ]
];
+ }
- if ($order_row->unit_price_tax_excl > 0) {
- $steuersatz = (strval($order_row->unit_price_tax_incl) / strval($order_row->unit_price_tax_excl)) - 1;
- $steuersatz = round($steuersatz, 1);
- $article['steuersatz'] = $steuersatz;
+ 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));
+
+ $this->category_identifier_source = $einstellungen['felder']['category_identifier_source'];
+ $this->category_identifier_source_field = $einstellungen['felder']['category_identifier_source_field'];
+ $this->product_identifier_type = $einstellungen['felder']['product_identifier_type'];
+ $this->product_identifier_source = $einstellungen['felder']['product_identifier_source'];
+ $this->product_identifier_source_field = $einstellungen['felder']['product_identifier_source_field'];
+ $this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true);
+ $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true);
+ }
+
+ private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false) {
+ $ch = curl_init();
+ $url_addition = "";
+
+ $headers = array("Authorization: " . $this->apiKey);
+
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ if (!empty($getdata)) {
+ $url_addition = "?";
+ $ampersand = "";
+ foreach ($getdata as $key => $value) {
+ $url_addition .= $ampersand . $key . "=" . $value;
+ $ampersand = "&";
+ }
+ } else if (!empty($postdata)) {
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+ $headers[] = 'Content-Type: ' . $content_type;
}
- $cart['articlelist'][] = $article;
- }
+ curl_setopt($ch, CURLOPT_URL, $this->shopUrl . $endpoint . $url_addition);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+ curl_setopt($ch, CURLINFO_HEADER_OUT, true);
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
- $fetchedOrders[] = [
- 'id' => $cart['auftrag'],
- 'sessionid' => '',
- 'logdatei' => '',
- 'warenkorb' => base64_encode(serialize($cart)),
- 'warenkorbjson' => base64_encode(json_encode($cart)),
- ];
+ $response = curl_exec($ch);
+ if (curl_error($ch)) {
+ $this->error[] = curl_error($ch);
+ }
+ curl_close($ch);
+
+ $information = curl_getinfo($ch);
+// print_r($information);
+// print_r($postdata);
+// print_r($response);
+// exit();
+
+ if ($raw)
+ return $response;
+
+ return simplexml_load_string($response);
}
- $this->Log('Precessed order from mirakl', $fetchedOrders);
- return $fetchedOrders;
- }
+ public function ImportAuth() {
+ $ch = curl_init($this->shopUrl . "version");
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: " . $this->apiKey));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ $response = curl_exec($ch);
+ $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
+ if ($code == 200) {
+ return 'success ' . print_r($response, true);
+ }
+ return $response;
+ }
-
+ /*
+ * Fetches article list from the shop, puts them into table shopexport_getarticles, starts the prozessstarter getarticles which fetches details for each article via ImportGetArticle()
+ */
+
+ public function ImportGetArticleList() {
+ $result = [];
+
+ $response = $this->miraklRequest('offers', raw: true);
+
+ $result_array = json_decode($response);
+
+ foreach ($result_array->offers as $offer) {
+ $result[] = $offer->shop_sku;
+ }
+
+ array_unique($result);
+ return $result;
+ }
+
+ /*
+ * Fetches article details from the shop
+ */
+
+ public function ImportGetArticle() {
+
+ $articleList = $this->CatchRemoteCommand('data');
+
+ $parameters = array('product_references' => 'productID', 'product_');
+
+ $response = $this->miraklRequest('products?', raw: true);
+
+ throw new Exception("Not implemented");
+ }
+
+ /*
+ * Send articles to shop
+ */
+
+ public function ImportSendList() {
+ $articleList = $this->CatchRemoteCommand('data');
+
+ // First gather all articles as offers and send them
+ // Wait for import to finish
+ // Evaluate import
+
+ // Unimplemented (needed?)
+ // Select offers with no product
+ // Create products and send
+ // Wait for import to finish
+ // Evaluate import
+
+ foreach ($articleList as $article) {
+
+ /*
+ * Export offer
+ */
+
+ $additional_fields = array();
+
+ // Required attributes
+ $offer_for_mirakl = array(
+ 'product_id_type' => $this->product_identifier_type,
+ 'product_id' => $article['nummer'], // TBD
+ 'shop_sku' => $article['nummer'], // TBD
+ 'price' => $article['preis'],
+ 'state_code' => '11', // ?!?!
+ 'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
+ );
+
+ foreach ($this->offer_field_map as $offer_field => $offer_field_source) {
+
+ $offer_field_value = null;
+
+ print_r($this->offer_field_map);
+
+ if (!is_array($offer_field_source)) {
+ if (!isset($article[$offer_field_source])) {
+ throw new Exception("Artikelfeld \"".$offer_field_source."\" nicht vorhanden.");
+ }
+ $offer_field_value = $article[$offer_field_source];
+ } else {
+
+ $is_additional_field = false;
+
+ foreach ($offer_field_source as $key => $value) {
+ switch ($key) {
+ case 'freifeld':
+ // TBD
+ break;
+ case 'eigenschaft':
+ // TBD
+ break;
+ case 'wert':
+ $offer_field_value = $value;
+ break;
+ case 'zusatzfeld':
+ $is_additional_field = $value;
+ break;
+ }
+ }
+ }
+
+ if ($is_additional_field) {
+ $additional_field = array (
+ "code" => $offer_field,
+ "value" => $offer_field_value
+ );
+ $additional_fields[] = $additional_field;
+ } else {
+ $offer_for_mirakl[$offer_field] = $offer_field_value;
+ }
+ }
+
+ if (!empty($additional_fields)) {
+ $offer_for_mirakl['offer_additional_fields'] = $additional_fields;
+ }
+
+ $offers_for_mirakl[] = $offer_for_mirakl;
+ }
+
+ $data_for_mirakl = array();
+ $data_for_mirakl['offers'] = $offers_for_mirakl;
+
+ $json_for_mirakl = json_encode($data_for_mirakl);
+
+// print_r($json_for_mirakl);
+// exit();
+
+ $result = [];
+ $response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
+
+ $result = json_decode($response);
+
+ if (!isset($result->import_id)) {
+ return(array('status' => false, 'message' => "Offer import in Mirakl not accepted: ".print_r($response,true)));
+ }
+
+ $import_id = $result->import_id;
+
+ // Wait for import to finish
+
+ $status = null;
+
+ /*
+ WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
+ */
+
+ while ($status != 'COMPLETE' && $status != 'FAILED') {
+ sleep(5);
+ $response = $this->miraklRequest('offers/imports/'.$import_id, raw: true);
+ $result = json_decode($response);
+ $status = $result->status;
+ }
+
+ if ($status == 'FAILED') {
+ return(array('status' => false, 'message' => "Offer import in Mirakl failed: ".print_r($response,true)));
+ }
+
+ if ($result->lines_in_error == 0) {
+ return($result->lines_in_success);
+ }
+
+ // Check errors
+ $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
+
+ return(array('status' => false, 'message' => "Offer import in Mirakl has errors: ".print_r($response,true)));
+
+ }
+
+ private function getOrdersToProcess(int $limit) {
+
+ }
+
+ private function Log($message, $dump = '') {
+ if ($this->protocol) {
+ $this->app->erp->Logfile($message, print_r($dump, true));
+ }
+ }
+
+ public function ImportDeleteAuftrag() {
+
+ }
+
+ public function ImportUpdateAuftrag() {
+
+ }
+
+ public function ImportGetAuftraegeAnzahl() {
+
+ }
+
+ public function ImportGetAuftrag() {
+
+ }
}
+
From 365b87f73407d89c5c9b8648a082f95ba2ff51d6 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 22 May 2024 13:37:30 +0200
Subject: [PATCH 07/87] mirakl required fields
---
www/pages/shopimporter_mirakl.php | 97 ++++++++++++++-----------------
1 file changed, 45 insertions(+), 52 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index d64f21bd..1a59d3f8 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -76,7 +76,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'size' => 40,
'info' => 'optional, int64'
],
- 'category_identifier_source' => [
+/* 'category_identifier_source' => [
'typ' => 'select',
'bezeichnung' => '{|Kategorie-Identifizierer|}:',
'size' => 40,
@@ -89,34 +89,15 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'size' => 40,
'info' => 'Wenn oben Freifeld oder Eigenschaft gewählt wurde'
],
- 'product_identifier_type' => [
- 'typ' => 'text',
- 'bezeichnung' => '{|Produkt-Identifizierertyp in Mirakl|}:',
- 'size' => 40,
- 'info' => 'Z.B. EAN'
- ],
- 'product_identifier_source' => [
- 'typ' => 'select',
- 'bezeichnung' => '{|Produkt-Identifizierer|}:',
- 'size' => 40,
- 'optionen' => ['Artikelnummer' => '{|Artikelnummer|}', 'Herstellernummer' => '{|Herstellernummer|}', 'EAN' => '{|EAN|}', 'Freifeld' => 'Freifeld', 'Eigenschaft' => 'Eigenschaft'],
- 'info' => 'Feld in OpenXE für die Zuordnung der Artikel zu den Katalogprodukten in Mirakl'
- ],
- 'product_identifier_source_field' => [
- 'typ' => 'text',
- 'bezeichnung' => '{|Produkt-Identifizierer Freifeld oder Eigenschaft|}:',
- 'size' => 40,
- 'info' => 'Wenn oben Freifeld oder Eigenschaft gewählt wurde'
- ],
'product_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: Artikelnummer, Artikelname, Einheit, Hersteller, Herstellernummer, EAN oder eine konkrete Artikeleigenschaft'
- ],
+ ],*/
'offer_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Angebots-Felder je Kategorie (JSON)|}:',
- 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: nummer, name_de, einheit, hersteller, herstellernummer, ean u.v.m. Freifelder: {"freifeld": "Freifeld1-40"}, Eigenschaften: {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: {"wert": "xyz"}, Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. {"freifeld": "Freifeld1", "zusatzfeld": true}'
+ 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Zuordnung über "Mirakl-xyz": {"feld": "xyz"} oder kurz "Mirakl-xyz": "xyz" Mögliche Zuordnungen aus OpenXE sind: nummer, name_de, einheit, hersteller, herstellernummer, ean u.v.m. Freifelder wie im Reiter Freifelder mit Präfix \'freifeld_\', Eigenschaften: {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: {"wert": "xyz"}, Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. {"feld": "name_de", "zusatzfeld": true}'
],
/*
'steuergruppen' => [
@@ -310,46 +291,58 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$additional_fields = array();
// Required attributes
+
+ $required = [
+ 'product_id_type',
+ 'product_id',
+ 'shop_sku',
+ 'price'
+ ];
+
+ $missing = null;
+
+ foreach ($required as $key) {
+ if (!isset($this->offer_field_map[$key])) {
+ $missing[] = $key;
+ }
+ }
+
+ if ($missing) {
+ return(array('status' => false, 'message' => "Missing required field: ".implode(', ',$missing)));
+ }
+
$offer_for_mirakl = array(
- 'product_id_type' => $this->product_identifier_type,
- 'product_id' => $article['nummer'], // TBD
- 'shop_sku' => $article['nummer'], // TBD
- 'price' => $article['preis'],
'state_code' => '11', // ?!?!
'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
);
+// print_r($this->offer_field_map);
+
foreach ($this->offer_field_map as $offer_field => $offer_field_source) {
- $offer_field_value = null;
-
- print_r($this->offer_field_map);
-
if (!is_array($offer_field_source)) {
- if (!isset($article[$offer_field_source])) {
- throw new Exception("Artikelfeld \"".$offer_field_source."\" nicht vorhanden.");
- }
- $offer_field_value = $article[$offer_field_source];
- } else {
+ $offer_field_source = array('feld' => $offer_field_source);
+ }
- $is_additional_field = false;
+ $offer_field_value = null;
+ $is_additional_field = false;
- foreach ($offer_field_source as $key => $value) {
- switch ($key) {
- case 'freifeld':
- // TBD
- break;
- case 'eigenschaft':
- // TBD
- break;
- case 'wert':
- $offer_field_value = $value;
- break;
- case 'zusatzfeld':
- $is_additional_field = $value;
- break;
- }
- }
+ foreach ($offer_field_source as $key => $value) {
+ switch ($key) {
+ case 'feld':
+ $offer_field_value = $article[$value];
+ break;
+ case 'eigenschaft':
+ $sql = "SELECT wert FROM artikeleigenschaften ae INNER JOIN artikeleigenschaftenwerte aew ON aew.artikeleigenschaften = ae.id WHERE aew.artikel = '".$article['artikelid']."' AND ae.name = '".$value."' LIMIT 1";
+ $offer_field_value = $this->app->DB->Select($sql);
+ break;
+ case 'wert':
+ $offer_field_value = $value;
+ break;
+ case 'zusatzfeld':
+ $is_additional_field = $value;
+ break;
+ }
}
if ($is_additional_field) {
From 35e2feee2e39f628a42a4bd01292b5a626c1d0d1 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 23 May 2024 20:12:05 +0200
Subject: [PATCH 08/87] mirakl field mapping for multiple categories
---
www/pages/shopimporter_mirakl.php | 141 ++++++++++++++++--------------
1 file changed, 77 insertions(+), 64 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 1a59d3f8..839f51ec 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -30,7 +30,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $product_identifier_source;
private $product_identifier_source_field;
private $product_field_map;
- private $offer_field_map;
+ private $field_map;
public function __construct($app, $intern = false) {
$this->app = $app;
@@ -94,7 +94,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: Artikelnummer, Artikelname, Einheit, Hersteller, Herstellernummer, EAN oder eine konkrete Artikeleigenschaft'
],*/
- 'offer_field_map' => [
+ 'field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Angebots-Felder je Kategorie (JSON)|}:',
'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Zuordnung über "Mirakl-xyz": {"feld": "xyz"} oder kurz "Mirakl-xyz": "xyz" Mögliche Zuordnungen aus OpenXE sind: nummer, name_de, einheit, hersteller, herstellernummer, ean u.v.m. Freifelder wie im Reiter Freifelder mit Präfix \'freifeld_\', Eigenschaften: {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: {"wert": "xyz"}, Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. {"feld": "name_de", "zusatzfeld": true}'
@@ -172,7 +172,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->product_identifier_source = $einstellungen['felder']['product_identifier_source'];
$this->product_identifier_source_field = $einstellungen['felder']['product_identifier_source_field'];
$this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true);
- $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true);
+ $this->field_map = json_decode($einstellungen['felder']['field_map'], true);
}
private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false) {
@@ -265,13 +265,35 @@ class Shopimporter_Mirakl extends ShopimporterBase {
throw new Exception("Not implemented");
}
+ /*
+ * Gets a flexible mapped fieldvalue from feld, wert or eigenschaft
+ */
+ public function GetFieldValue($article, $field_map_entry) {
+ foreach ($field_map_entry as $key => $value) {
+ switch ($key) {
+ case 'feld':
+ return($article[$value]);
+ break;
+ case 'eigenschaft':
+ $sql = "SELECT wert FROM artikeleigenschaften ae INNER JOIN artikeleigenschaftenwerte aew ON aew.artikeleigenschaften = ae.id WHERE aew.artikel = '".$article['artikelid']."' AND ae.name = '".$value."' LIMIT 1";
+ return($this->app->DB->Select($sql));
+ break;
+ case 'wert':
+ return($value);
+ break;
+ }
+ }
+ return(null);
+ }
+
/*
* Send articles to shop
*/
public function ImportSendList() {
+
$articleList = $this->CatchRemoteCommand('data');
-
+
// First gather all articles as offers and send them
// Wait for import to finish
// Evaluate import
@@ -287,73 +309,64 @@ class Shopimporter_Mirakl extends ShopimporterBase {
/*
* Export offer
*/
-
+ $processed = false;
$additional_fields = array();
- // Required attributes
-
- $required = [
- 'product_id_type',
- 'product_id',
- 'shop_sku',
- 'price'
- ];
-
- $missing = null;
-
- foreach ($required as $key) {
- if (!isset($this->offer_field_map[$key])) {
- $missing[] = $key;
- }
- }
-
- if ($missing) {
- return(array('status' => false, 'message' => "Missing required field: ".implode(', ',$missing)));
- }
-
$offer_for_mirakl = array(
'state_code' => '11', // ?!?!
'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
);
-// print_r($this->offer_field_map);
+ foreach ($this->field_map['angebotskonfiguration'] as $offer_field_entry) {
- foreach ($this->offer_field_map as $offer_field => $offer_field_source) {
-
- if (!is_array($offer_field_source)) {
- $offer_field_source = array('feld' => $offer_field_source);
+ $kategorie = $this->GetFieldValue($article, $this->field_map['katalogkonfiguration']['kategorie']);
+ if ($offer_field_entry['kategorie'] != $kategorie && $offer_field_entry['kategorie'] != null) {
+ continue;
+ };
+
+ // Check Required attributes
+ $required = [
+ 'product_id_type',
+ 'product_id',
+ 'shop_sku',
+ 'price'
+ ];
+ $missing = null;
+ foreach ($required as $key) {
+ if (!isset($offer_field_entry['felder'][$key])) {
+ $missing[] = $key;
+ }
+ }
+ if ($missing) {
+ return(array('status' => false, 'message' => "Pflichtfelder fehlen in Angebotskonfiguration von Kategorie \"".$offer_field_entry['kategorie']."\": ".implode(', ',$missing)));
}
+ // Check Required attributes
+
+ foreach ($offer_field_entry['felder'] as $offer_field => $offer_field_source) {
+ if (!is_array($offer_field_source)) {
+ $offer_field_source = array('feld' => $offer_field_source);
+ }
+ $offer_field_value = null;
+ $is_additional_field = false;
+ $offer_field_value = $this->GetFieldValue($article, $offer_field_source);
+ if (in_array('zusatzfeld', $offer_field_source)) {
+ $is_additional_field = true;
+ }
+ if ($is_additional_field) {
+ $additional_field = array (
+ "code" => $offer_field,
+ "value" => $offer_field_value
+ );
+ $additional_fields[] = $additional_field;
+ } else {
+ $offer_for_mirakl[$offer_field] = $offer_field_value;
+ }
+ }
+ $processed = true;
+ }
- $offer_field_value = null;
- $is_additional_field = false;
-
- foreach ($offer_field_source as $key => $value) {
- switch ($key) {
- case 'feld':
- $offer_field_value = $article[$value];
- break;
- case 'eigenschaft':
- $sql = "SELECT wert FROM artikeleigenschaften ae INNER JOIN artikeleigenschaftenwerte aew ON aew.artikeleigenschaften = ae.id WHERE aew.artikel = '".$article['artikelid']."' AND ae.name = '".$value."' LIMIT 1";
- $offer_field_value = $this->app->DB->Select($sql);
- break;
- case 'wert':
- $offer_field_value = $value;
- break;
- case 'zusatzfeld':
- $is_additional_field = $value;
- break;
- }
- }
-
- if ($is_additional_field) {
- $additional_field = array (
- "code" => $offer_field,
- "value" => $offer_field_value
- );
- $additional_fields[] = $additional_field;
- } else {
- $offer_for_mirakl[$offer_field] = $offer_field_value;
- }
+ if (!$processed) {
+ return(array('status' => false, 'message' => "Angebotskonfiguration für Kategorie \"".$kategorie."\" nicht gefunden"));
}
if (!empty($additional_fields)) {
@@ -377,7 +390,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$result = json_decode($response);
if (!isset($result->import_id)) {
- return(array('status' => false, 'message' => "Offer import in Mirakl not accepted: ".print_r($response,true)));
+ return(array('status' => false, 'message' => "Angebotsimport in Mirakl abgelehnt: ".print_r($response,true)));
}
$import_id = $result->import_id;
@@ -398,7 +411,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
if ($status == 'FAILED') {
- return(array('status' => false, 'message' => "Offer import in Mirakl failed: ".print_r($response,true)));
+ return(array('status' => false, 'message' => "Angebotsimport in Mirakl fehlgeschlagen: ".print_r($response,true)));
}
if ($result->lines_in_error == 0) {
@@ -408,7 +421,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
// Check errors
$response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
- return(array('status' => false, 'message' => "Offer import in Mirakl has errors: ".print_r($response,true)));
+ return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler: ".print_r($response,true)));
}
From e71da793a38f178001da117d35135388e2e991ce Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 10:10:59 +0200
Subject: [PATCH 09/87] mirakl angebotskonfiguration multiple categories
---
www/pages/shopimporter_mirakl.php | 37 ++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 839f51ec..e151fe8e 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -2,10 +2,39 @@
/*
* SPDX-FileCopyrightText: 2022 Andreas Palm
+ * SPDX-FileCopyrightText: 2024 OpenXE project
*
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
*/
+
+/*
+
+JSON example for field_map
+
+{
+ "katalogkonfiguration": {
+ "kategorie": {"feld": "freifeld_Kategorie"}
+ },
+ "angebotskonfiguration":
+ [
+ {
+ "kategorien": ["Schrauben"],
+ "felder": {
+ "product_id_type": {"wert": "SHOP_SKU"},
+ "product_id": {"feld": "nummer"},
+ "shop_sku": {"feld": "nummer"},
+ "price": {"feld": "preis"},
+ "description": "freifeld_Kategorie",
+ "internal_description": {"eigenschaft": "Mirakl Steuertext"},
+ "reversecharge": {"wert": "false","zusatzfeld": true},
+ "warehouse": {"wert": "1","zusatzfeld": true}
+ }
+ }
+ ]
+}
+*/
+
class Shopimporter_Mirakl extends ShopimporterBase {
private $app;
@@ -320,9 +349,11 @@ class Shopimporter_Mirakl extends ShopimporterBase {
foreach ($this->field_map['angebotskonfiguration'] as $offer_field_entry) {
$kategorie = $this->GetFieldValue($article, $this->field_map['katalogkonfiguration']['kategorie']);
- if ($offer_field_entry['kategorie'] != $kategorie && $offer_field_entry['kategorie'] != null) {
- continue;
- };
+ if ($offer_field_entry['kategorien'] != null) {
+ if (!in_array($kategorie,$offer_field_entry['kategorien'])) {
+ continue;
+ }
+ }
// Check Required attributes
$required = [
From 7f61cad921e4fa9700813e10b77807450cb28b28 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 10:18:26 +0200
Subject: [PATCH 10/87] 3540153c417eb2f99f83aa250f3e9516fed61122
---
www/eproosystem.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/eproosystem.php b/www/eproosystem.php
index 4e96c6bd..560f7a59 100644
--- a/www/eproosystem.php
+++ b/www/eproosystem.php
@@ -1111,7 +1111,7 @@ if (typeof document.hidden !== \"undefined\") { // Opera 12.10 and Firefox 18 an
}
// userd edit ajax call
-// $poll = true;
+ $poll = true;
if($poll) {
$this->addPollJs($module, $action, $id);
}
From 4f106028c9fe7671186051ba10494ab38249538c Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 10:53:49 +0200
Subject: [PATCH 11/87] mirakl send shop_id
---
www/pages/shopimporter_mirakl.php | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index e151fe8e..7a837079 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -43,6 +43,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $protocol;
private $apiKey;
private $shopUrl;
+ private $mirakl_shopid;
private $createManufacturerAllowed = false;
private $idsabholen;
private $idbearbeitung;
@@ -99,7 +100,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'bezeichnung' => '{|Shop URL|}:',
'size' => 40,
],
- 'shopid' => [
+ 'mirakl_shopid' => [
'typ' => 'text',
'bezeichnung' => '{|Shop ID des Shops|}:',
'size' => 40,
@@ -178,7 +179,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$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);
@@ -186,6 +186,8 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->protocol = $einstellungen['felder']['protokoll'];
$this->apiKey = $einstellungen['felder']['apikey'];
$this->shopUrl = rtrim($einstellungen['felder']['shopurl'], '/') . '/';
+ $this->mirakl_shopid = $einstellungen['felder']['mirakl_shopid'];
+
if ($einstellungen['felder']['autoerstellehersteller'] === '1') {
$this->createManufacturerAllowed = true;
}
@@ -212,6 +214,10 @@ class Shopimporter_Mirakl extends ShopimporterBase {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ if (!empty($this->mirakl_shopid)) {
+ $getdata['shop_id'] = $this->mirakl_shopid;
+ }
+
if (!empty($getdata)) {
$url_addition = "?";
$ampersand = "";
@@ -219,7 +225,8 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$url_addition .= $ampersand . $key . "=" . $value;
$ampersand = "&";
}
- } else if (!empty($postdata)) {
+ }
+ if (!empty($postdata)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$headers[] = 'Content-Type: ' . $content_type;
@@ -237,10 +244,12 @@ class Shopimporter_Mirakl extends ShopimporterBase {
curl_close($ch);
$information = curl_getinfo($ch);
-// print_r($information);
-// print_r($postdata);
-// print_r($response);
-// exit();
+
+/* print_r($information);
+ print_r($postdata);
+ print_r($response);
+ exit();
+*/
if ($raw)
return $response;
From d20bbe79b34b35b029eb3bf2d2896430f0ccf555 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 18:57:37 +0200
Subject: [PATCH 12/87] mirakl lagersync removed storageNotNeededElements
---
www/lib/ShopimporterBase.php | 12 ------------
www/pages/shopimporter_mirakl.php | 15 +++++++--------
2 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/www/lib/ShopimporterBase.php b/www/lib/ShopimporterBase.php
index 2d92213d..716b1469 100644
--- a/www/lib/ShopimporterBase.php
+++ b/www/lib/ShopimporterBase.php
@@ -632,18 +632,6 @@ Class ShopimporterBase{
'variants',
'free_fields',
],
- 'shopimporter_mirakl' => [
- 'article_descriptions',
- 'translations',
- 'categories',
- 'properties',
- 'pictures',
- 'cross_selling',
- 'bulk_prices',
- 'standard_price',
- 'variants',
- 'free_fields',
- ],
'shopimporter_shopify' => [
'article_descriptions',
'translations',
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 7a837079..5d5ddadf 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -19,7 +19,6 @@ JSON example for field_map
"angebotskonfiguration":
[
{
- "kategorien": ["Schrauben"],
"felder": {
"product_id_type": {"wert": "SHOP_SKU"},
"product_id": {"feld": "nummer"},
@@ -28,7 +27,8 @@ JSON example for field_map
"description": "freifeld_Kategorie",
"internal_description": {"eigenschaft": "Mirakl Steuertext"},
"reversecharge": {"wert": "false","zusatzfeld": true},
- "warehouse": {"wert": "1","zusatzfeld": true}
+ "warehouse": {"wert": "1","zusatzfeld": true},
+ "quantity": {"feld": "anzahl_lager"}
}
}
]
@@ -324,10 +324,13 @@ class Shopimporter_Mirakl extends ShopimporterBase {
return(null);
}
+ public function ImportSendListLager() {
+ return($this->ImportSendList());
+ }
+
/*
* Send articles to shop
*/
-
public function ImportSendList() {
$articleList = $this->CatchRemoteCommand('data');
@@ -421,9 +424,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$json_for_mirakl = json_encode($data_for_mirakl);
-// print_r($json_for_mirakl);
-// exit();
-
$result = [];
$response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
@@ -459,8 +459,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
// Check errors
- $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
-
+ $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler: ".print_r($response,true)));
}
From 57a9aa23fff9b9d73e8256c1bc128ec5a414878d Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 18:58:32 +0200
Subject: [PATCH 13/87] class.remote sendlistlager condensed
---
www/lib/class.remote.php | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index ef8cabb8..0ba1f2a5 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2218,7 +2218,7 @@ class Remote
$data2 = $data;
foreach ($data2 as $key => $value){
$data2[$key]['artikel'] = $value['artikelid'];
- }
+ }
$result = $this->RemoteCommand($id,'sendlistlager',$data2);
$this->app->DB->Update(
sprintf(
@@ -2286,17 +2286,7 @@ class Remote
}//Altes Verhalten
}
if(!$isLagerExported){
- $data2 = $data;
- foreach ($data2 as $key => $value){
- $data2[$key]['artikel'] = $value['artikelid'];
- }
- $this->RemoteCommand($id,'sendlistlager',$data2);
- $this->app->DB->Update(
- sprintf(
- 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
- $data2[$i]['artikel'], $id
- )
- );
+ $this->sendlistlager($i,$id,$data);
}
return $result;
}
From 5b9a04031ab0a22b3aa624c14e6a7cd26cbd5937 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 24 May 2024 18:59:43 +0200
Subject: [PATCH 14/87] cronjob lagerzahlen added information
---
cronjobs/lagerzahlen.php | 207 +++++++++++++++++++--------------------
1 file changed, 100 insertions(+), 107 deletions(-)
diff --git a/cronjobs/lagerzahlen.php b/cronjobs/lagerzahlen.php
index 4466331e..a1ef1e0b 100644
--- a/cronjobs/lagerzahlen.php
+++ b/cronjobs/lagerzahlen.php
@@ -1,38 +1,37 @@
Conf)) {
- $conf = new Config();
- $app->Conf = $conf;
+if (empty($app->Conf)) {
+ $conf = new Config();
+ $app->Conf = $conf;
}
-if(empty($app->DB)) {
- $app->DB = new DB($app->Conf->WFdbhost,$app->Conf->WFdbname,$app->Conf->WFdbuser,$app->Conf->WFdbpass,null,$app->Conf->WFdbport);
+if (empty($app->DB)) {
+ $app->DB = new DB($app->Conf->WFdbhost, $app->Conf->WFdbname, $app->Conf->WFdbuser, $app->Conf->WFdbpass, null, $app->Conf->WFdbport);
}
-if(empty($app->erp)) {
- if(class_exists('erpAPICustom')) {
- $erp = new erpAPICustom($app);
- }
- else {
- $erp = new erpAPI($app);
- }
- $app->erp = $erp;
-}
-if(empty($app->remote)) {
- if(is_file(dirname(__DIR__) . '/www/lib/class.remote_custom.php')){
- if(!class_exists('RemoteCustom')) {
- require_once dirname(__DIR__) . '/www/lib/class.remote_custom.php';
+if (empty($app->erp)) {
+ if (class_exists('erpAPICustom')) {
+ $erp = new erpAPICustom($app);
+ } else {
+ $erp = new erpAPI($app);
+ }
+ $app->erp = $erp;
+}
+if (empty($app->remote)) {
+ if (is_file(dirname(__DIR__) . '/www/lib/class.remote_custom.php')) {
+ if (!class_exists('RemoteCustom')) {
+ require_once dirname(__DIR__) . '/www/lib/class.remote_custom.php';
+ }
+ $app->remote = new RemoteCustom($app);
+ } else {
+ $app->remote = new Remote($app);
}
- $app->remote = new RemoteCustom($app);
- }
- else {
- $app->remote = new Remote($app);
- }
}
$app->erp->LogFile("Lagerzahlen-Synchronisation Start");
@@ -40,34 +39,33 @@ $app->erp->LogFile("Lagerzahlen-Synchronisation Start");
$firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
- $app->DB->Update(
+$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutexcounter` = `mutexcounter` + 1
WHERE `mutex` = 1 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
- );
- if(!$app->DB->Select(
+);
+if (!$app->DB->Select(
"SELECT `id` FROM `prozessstarter` WHERE `mutex` = 0 AND `parameter` = 'lagerzahlen' AND `aktiv` = 1"
- )) {
+)) {
+ $app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Prozessstarter-Mutex nicht bereit");
return;
- }
-
- $shops = $app->DB->SelectArr('SELECT * FROM `shopexport` WHERE `aktiv` = 1');
- if(empty($shops)) {
+}
+$shops = $app->DB->SelectArr('SELECT * FROM `shopexport` WHERE `aktiv` = 1');
+if (empty($shops)) {
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine aktiven Shops");
-
return;
- }
- $shopByIds = [];
- foreach($shops as $shop) {
+}
+$shopByIds = [];
+foreach ($shops as $shop) {
$shopByIds[$shop['id']] = $shop;
- }
- $shopIds = array_keys($shopByIds);
- $shopIdsStr = implode(',', $shopIds);
- $hours = 12;
- $hoursShop = 48;
- $lagerartikel = $app->DB->SelectFirstCols(
- "SELECT a.id
+}
+$shopIds = array_keys($shopByIds);
+$shopIdsStr = implode(',', $shopIds);
+$hours = 12;
+$hoursShop = 48;
+$lagerartikel = $app->DB->SelectFirstCols(
+ "SELECT a.id
FROM `artikel` AS `a`
LEFT JOIN (
SELECT ao2.artikel, 1 AS `autolagerlampe`,
@@ -97,91 +95,86 @@ $firmendatenid = $app->DB->Select("SELECT MAX(id) FROM firmendaten LIMIT 1");
ORDER BY a.cache_lagerplatzinhaltmenge = -999 DESC,
ao.cache_reseted DESC,
a.laststorage_sync"
- );
-
- if(empty($lagerartikel)) {
+);
+if (empty($lagerartikel)) {
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: Keine fälligen Artikel");
-
return;
- }
+}
- try {
+try {
$r = new ReflectionMethod($app->erp, 'LagerSync');
$params = $r->getParameters();
$anzargs = count($params);
- }
- catch(Exception $e) {
+} catch (Exception $e) {
$anzargs = 2;
- }
+}
- $clagerartikel = $lagerartikel?count($lagerartikel):0;
- $app->erp->LogFile('Lagerzahlen-Synchronisation, Artikel gesamt: '.$clagerartikel);
- foreach($lagerartikel as $ij => $articleId) {
+$clagerartikel = $lagerartikel ? count($lagerartikel) : 0;
+$app->erp->LogFile('Lagerzahlen-Synchronisation, Artikel gesamt: ' . $clagerartikel);
+foreach ($lagerartikel as $articleCounter => $articleId) {
$app->DB->Update(
- "UPDATE `prozessstarter`
+ "UPDATE `prozessstarter`
SET `mutex` = 1 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
);
try {
- if($anzargs > 2){
- $message .= $app->erp->LagerSync($articleId, false, $shopByIds); // 2nd parameter is print_echo -> prints via echo to logfile (big print_r)
- }else{
- $message .= $app->erp->LagerSync($articleId, false);
- }
+ if ($anzargs > 2) {
+ $message .= $app->erp->LagerSync($articleId, false, $shopByIds); // 2nd parameter is print_echo -> prints via echo to logfile (big print_r)
+ } else {
+ $message .= $app->erp->LagerSync($articleId, false);
+ }
+ } catch (Exception $exception) {
+ $message .= ' ' . $exception->getMessage();
}
- catch (Exception $exception) {
- $message .= ' ' . $exception->getMessage();
+ if ($message != '') {
+ $message .= ' ';
}
- if($message!='') {
- $message .=' ';
- }
- if($ij % 10 === 0 && method_exists($app->erp, 'canRunCronjob')
- && !$app->erp->canRunCronjob(['lagerzahlen'])) {
- $app->DB->Update(
- "UPDATE `prozessstarter`
- SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
- WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
- );
- return;
+ if ($articleCounter % 10 === 0 && method_exists($app->erp, 'canRunCronjob') && !$app->erp->canRunCronjob(['lagerzahlen'])) {
+ $app->DB->Update(
+ "UPDATE `prozessstarter`
+ SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
+ WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
+ );
+ $app->erp->LogFile("Lagerzahlen-Synchronisation Ende: lagerzahlen-Job kann nicht geladen werden");
+ return;
}
+ $app->erp->LogFile("Lagerzahlen-Synchronisation: Warte 10 Sekunden");
usleep(10000);
- }
- $app->DB->Update(
+}
+$app->DB->Update(
"UPDATE `prozessstarter`
SET `mutex` = 0 , `mutexcounter` = 0, `letzteausfuerhung` = NOW()
WHERE `parameter` = 'lagerzahlen' AND `aktiv` = 1"
- );
- if($message !='' && $erp->Firmendaten('systemmailsabschalten') == 0 && $erp->GetFirmaMail()!='') {
+);
+if ($message != '' && $erp->Firmendaten('systemmailsabschalten') == 0 && $erp->GetFirmaMail() != '') {
try {
- if($erp->Firmendaten('systemmailsempfaenger') != ''){
- $erp->MailSend(
- $erp->GetFirmaMail(),
- $erp->GetFirmaName(),
- $erp->Firmendaten('systemmailsempfaenger'),
- 'Lagerverwaltung',
- 'Systemmeldung: Auto Update Lagerlampen',
- $message
- );
-
- }else{
- if($erp->GetFirmaBCC1() != ''){
- $erp->MailSend(
- $erp->GetFirmaMail(),
- $erp->GetFirmaName(),
- $erp->GetFirmaBCC1(),
- 'Lagerverwaltung',
- 'Systemmeldung: Auto Update Lagerlampen',
- $message
- );
+ if ($erp->Firmendaten('systemmailsempfaenger') != '') {
+ $erp->MailSend(
+ $erp->GetFirmaMail(),
+ $erp->GetFirmaName(),
+ $erp->Firmendaten('systemmailsempfaenger'),
+ 'Lagerverwaltung',
+ 'Systemmeldung: Auto Update Lagerlampen',
+ $message
+ );
+ } else {
+ if ($erp->GetFirmaBCC1() != '') {
+ $erp->MailSend(
+ $erp->GetFirmaMail(),
+ $erp->GetFirmaName(),
+ $erp->GetFirmaBCC1(),
+ 'Lagerverwaltung',
+ 'Systemmeldung: Auto Update Lagerlampen',
+ $message
+ );
+ }
}
- }
+ } catch (Exception $exception) {
+ $app->erp->LogFile("Lagerzahlen-Synchronisation Exception:" . $app->DB->real_escape_string($exception->getMessage()));
}
- catch (Exception $exception) {
- $app->erp->LogFile("Lagerzahlen-Synchronisation Exception:".$app->DB->real_escape_string($exception->getMessage()));
- }
- }
+}
- $app->erp->LogFile("Lagerzahlen-Synchronisation Ende");
+$app->erp->LogFile("Lagerzahlen-Synchronisation Ende");
From a5f5f4aede130e73b9654cd05937182cf60737fb Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 5 Jun 2024 09:48:56 +0200
Subject: [PATCH 15/87] reimplemented module artikeltexte
---
phpwf/plugins/class.yui.php | 11 +-
www/lib/class.erpapi.php | 27 ++-
www/lib/class.remote.php | 21 +-
www/pages/artikel.php | 6 +-
www/pages/artikeltexte.php | 270 ++++++++++++++++++++++++
www/pages/content/artikeltexte_edit.tpl | 144 +++++++++++++
www/pages/content/artikeltexte_list.tpl | 10 +
www/pages/importvorlage.php | 4 +-
www/widgets/templates/_gen/artikel.tpl | 6 +-
9 files changed, 465 insertions(+), 34 deletions(-)
create mode 100644 www/pages/artikeltexte.php
create mode 100644 www/pages/content/artikeltexte_edit.tpl
create mode 100644 www/pages/content/artikeltexte_list.tpl
diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php
index d78eb336..c2d2398e 100644
--- a/phpwf/plugins/class.yui.php
+++ b/phpwf/plugins/class.yui.php
@@ -1921,8 +1921,17 @@ class YUI {
}
}
-
$this->app->erp->RunHook('AARLGPositionenSprache', 6, $module, $id, $artikel_id, $sprache, $bezeichnung, $beschreibung);
+
+ // OpenXE artikel_texte
+ $language = $this->app->erp->GetSpracheBeleg($module,$id);
+ $sql = "SELECT * FROM artikel_texte WHERE artikel = '".$artikel_id."' AND sprache = '".$language."'";
+ $uebersetzung = $this->app->DB->SelectRow($sql);
+ if ($uebersetzung) {
+ $bezeichnung = $uebersetzung['name'];
+ $beschreibung = $uebersetzung['beschreibung'];
+ }
+
$bezeichnung = $this->app->DB->real_escape_string($bezeichnung);
$beschreibung = $this->app->DB->real_escape_string($beschreibung);
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index b855b0f3..9ec83a60 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -31396,15 +31396,15 @@ function Firmendaten($field,$projekt="")
$variante_von = $this->app->DB->Select("SELECT variante_von FROM artikel WHERE id = '$artikel' LIMIT 1");
if($variante_von)$beschreibung = $this->app->DB->real_escape_string($this->app->DB->Select("SELECT anabregs_text FROM artikel WHERE id='$variante_von' LIMIT 1"));
}
- if($this->ModulVorhanden('artikel_texte')){
- if(array_key_exists($belegsprache,$adresssprachen)){
+
+ if(array_key_exists($belegsprache,$adresssprachen)){
$belegsprache = $adresssprachen[$belegsprache];
- }
- $artikelbeschreibung = $this->app->DB->Select("SELECT beschreibung FROM artikel_texte WHERE artikel=$artikel AND sprache='$belegsprache'");
- if($artikelbeschreibung){
- $beschreibung = $artikelbeschreibung;
- }
}
+ $artikelbeschreibung = $this->app->DB->Select("SELECT beschreibung FROM artikel_texte WHERE artikel=$artikel AND sprache='$belegsprache'");
+ if($artikelbeschreibung){
+ $beschreibung = $artikelbeschreibung;
+ }
+
}
//$vpe = $this->app->DB->Select("SELECT vpe FROM verkaufspreise WHERE id='$verkauf' LIMIT 1");
$sort = $this->app->DB->Select("SELECT MAX(sort) FROM ".$typ."_position WHERE $typ='$id' LIMIT 1");
@@ -31419,20 +31419,19 @@ function Firmendaten($field,$projekt="")
if($this->app->DB->Select("SELECT adr.id FROM auftrag auf INNER JOIN adresse adr ON auf.adresse = adr.id AND adr.sprache = 'englisch' WHERE auf.id = '$id' LIMIT 1"))
$name = $this->app->DB->Select("SELECT name_en FROM artikel WHERE id = '$artikel'");
if($name === '')$name = $this->app->DB->Select("SELECT name_de FROM artikel WHERE id = '$artikel'");
- if($this->ModulVorhanden('artikel_texte')){
- if(array_key_exists($belegsprache,$adresssprachen)){
+
+ if(array_key_exists($belegsprache,$adresssprachen)){
$belegsprache = $adresssprachen[$belegsprache];
- }
- $artikelbezeichnung = $this->app->DB->Select(
+ }
+ $artikelbezeichnung = $this->app->DB->Select(
"SELECT name
FROM artikel_texte
WHERE artikel=$artikel AND sprache='$belegsprache'
ORDER BY name <> '' DESC
LIMIT 1"
- );
- if($artikelbezeichnung){
+ );
+ if($artikelbezeichnung){
$name = $artikelbezeichnung;
- }
}
}
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 0eb67ede..3880b024 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -1177,11 +1177,7 @@ class Remote
}
$shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
$artikelexport = $shopexportarr['artikelexport'];
- $translationpossible = false;
- if($this->app->erp->ModulVorhanden('artikel_texte'))
- {
- $translationpossible = true;
- }
+
$loadElements = [
'foreign_numbers' => true,
'article_descriptions' => true,
@@ -1811,7 +1807,7 @@ class Remote
foreach ($db->yieldAll($query) as $matrixdaten) {
$data[$i]['matrix_varianten']['gruppen'][$matrixdaten['gruppe']][$matrixdaten['wert']] = true;
- if ($translationpossible && !empty($loadElements['translations'])) {
+ if (!empty($loadElements['translations'])) {
if (empty($gruppenuebersetzung[$matrixdaten['gruppe']])) {
$gruppennamen = $this->app->DB->SelectArr("SELECT
IF(name_external_from<>'',name_external_from,name_from) AS name_from,
@@ -2092,17 +2088,16 @@ class Remote
$variantennettopreis = $this->app->erp->GetVerkaufspreis($v['id'], 1, 0);
}
}
- if(!empty($loadElements['translations']) && $this->app->erp->ModulVorhanden('artikel_texte')){
- $sprachen = ['de','en'];
- foreach ($sprachen as $sprache){
+ $sprachen = ['de','en'];
+ foreach ($sprachen as $sprache){
$query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
- $id,strtoupper($sprache),$v['id']);
+ $id,strtoupper($sprache),$v['id']);
$ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
- if(!empty($ersetzeStandardbeschreibung)){
- $v['name_'.$sprache] = $ersetzeStandardbeschreibung['name'];
+ if(!empty($ersetzeStandardbeschreibung)) {
+ $v['name_'.$sprache] = $ersetzeStandardbeschreibung['name'];
}
- }
}
+
$this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $v['id'], $v['pseudolager']);
if(is_numeric($v['pseudolager']) && $v['pseudolager'] < 0) {
$v['pseudolager'] = 0;
diff --git a/www/pages/artikel.php b/www/pages/artikel.php
index 34af81c7..4412e536 100644
--- a/www/pages/artikel.php
+++ b/www/pages/artikel.php
@@ -7333,6 +7333,10 @@ class Artikel extends GenArtikel {
$this->app->erp->MenuEintrag('index.php?module=artikel&action=eigenschaften&id='.$id, 'Eigenschaften');
}
+ $this->app->erp->MenuEintrag("index.php?module=artikeltexte&action=list&artikel=$id",'Übersetzung');
+
+ $this->app->erp->MenuEintrag("index.php?module=artikel&action=baum&id=$id",'Artikelbaum');
+
if($rabatt!='1'){
$this->app->erp->MenuEintrag("index.php?module=artikel&action=einkauf&id=$id",'Einkauf');
if($this->app->erp->RechteVorhanden('einkaufabgleich','einkaufapi'))
@@ -7393,7 +7397,7 @@ class Artikel extends GenArtikel {
}
$this->app->erp->MenuEintrag('index.php?module=artikel&action=list','Zurück zur Übersicht');
- $this->app->erp->InsertMenuAfter("index.php?module=artikel&action=baum&id=$id",'Artikelbaum','artikel','eigenschaften');
+
}
}
$this->app->erp->MenuEintrag('index.php?module=artikel&action=create','Neuen Artikel anlegen');
diff --git a/www/pages/artikeltexte.php b/www/pages/artikeltexte.php
new file mode 100644
index 00000000..adc4f311
--- /dev/null
+++ b/www/pages/artikeltexte.php
@@ -0,0 +1,270 @@
+app = $app;
+ if ($intern)
+ return;
+
+ $this->app->ActionHandlerInit($this);
+ $this->app->ActionHandler("list", "artikel_texte_list");
+ $this->app->ActionHandler("create", "artikel_texte_edit"); // This automatically adds a "New" button
+ $this->app->ActionHandler("edit", "artikel_texte_edit");
+ $this->app->ActionHandler("delete", "artikel_texte_delete");
+ $this->app->DefaultActionHandler("list");
+ $this->app->ActionHandlerListen($app);
+ }
+
+ public function Install() {
+ /* Fill out manually later */
+ }
+
+ static function TableSearch(&$app, $name, $erlaubtevars) {
+ switch ($name) {
+ case "artikel_texte_list":
+ $allowed['artikel_texte_list'] = array('list');
+ $heading = array('','','Nummer','Artikel','Sprache', 'Name', 'Kurztext', 'Beschreibung', 'Beschreibung_online', 'Meta title', 'Meta description', 'Meta keywords', 'Katalogartikel', 'Katalogbezeichnung', 'Katalogtext', 'Shop', 'Aktiv', 'Menü');
+ $width = array('1%','1%','1%'); // Fill out manually later
+
+ $artikel = $app->User->GetParameter('artikeltexte_artikel');
+
+ // columns that are aligned right (numbers etc)
+ // $alignright = array(4,5,6,7,8);
+
+ $findcols = array('a.id','a.id','art.nummer', 'art.name_de', 'a.sprache', 'a.name', 'a.kurztext', 'a.beschreibung', 'a.beschreibung_online', 'a.meta_title', 'a.meta_description', 'a.meta_keywords', 'a.katalogartikel', 'a.katalog_bezeichnung', 'a.katalog_text', 'a.shop', 'a.aktiv');
+ $searchsql = array('a.artikel', 'a.sprache', 'a.name', 'a.kurztext', 'a.beschreibung', 'a.beschreibung_online', 'a.meta_title', 'a.meta_description', 'a.meta_keywords', 'a.katalogartikel', 'a.katalog_bezeichnung', 'a.katalog_text', 'a.shop', 'a.aktiv');
+
+ $defaultorder = 1;
+ $defaultorderdesc = 0;
+ $aligncenter = array();
+ $alignright = array();
+ $numbercols = array();
+ $sumcol = array();
+
+ $dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
+
+// $moreinfo = true; // Allow drop down details
+// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
+// $mencol = 11; // Set id col for moredata/menu
+
+ $menu = "";
+
+ $sql = "
+ SELECT SQL_CALC_FOUND_ROWS a.id, $dropnbox,
+ art.nummer,
+ art.name_de,
+ a.sprache,
+ a.name,
+ a.kurztext,
+ a.beschreibung,
+ a.beschreibung_online,
+ a.meta_title,
+ a.meta_description,
+ a.meta_keywords,
+ a.katalogartikel,
+ a.katalog_bezeichnung,
+ a.katalog_text,
+ a.shop,
+ a.aktiv,
+ a.id FROM artikel_texte a
+ INNER JOIN artikel art ON art.id = a.artikel
+ ";
+
+ $where = "1";
+
+ if ($artikel) {
+ // $where .= " AND a.artikel = '".$artikel."'";
+ }
+
+ $count = "SELECT count(DISTINCT id) FROM artikel_texte a WHERE $where";
+// $groupby = "";
+
+ break;
+ }
+
+ $erg = false;
+
+ foreach ($erlaubtevars as $k => $v) {
+ if (isset($$v)) {
+ $erg[$v] = $$v;
+ }
+ }
+ return $erg;
+ }
+
+ function artikel_texte_list() {
+
+ $this->app->erp->MenuEintrag("index.php?module=artikeltexte&action=list", "Übersicht");
+ $this->app->erp->MenuEintrag("index.php?module=artikeltexte&action=create", "Neu anlegen");
+
+ $this->app->erp->MenuEintrag("index.php", "Zurück");
+
+ $artikel = $this->app->Secure->GetGET('artikel');
+ $this->app->User->SetParameter('artikeltexte_artikel', $artikel);
+
+ $this->app->YUI->TableSearch('TAB1', 'artikel_texte_list', "show", "", "", basename(__FILE__), __CLASS__);
+ $this->app->Tpl->Parse('PAGE', "artikeltexte_list.tpl");
+ }
+
+ public function artikel_texte_delete() {
+ $id = (int) $this->app->Secure->GetGET('id');
+ $this->app->DB->Delete("DELETE FROM `artikel_texte` WHERE `id` = '{$id}'");
+ $this->app->Tpl->addMessage('error', 'Der Eintrag wurde gelöscht');
+ $this->artikel_texte_list();
+ }
+
+ /*
+ * Edit artikel_texte item
+ * If id is empty, create a new one
+ */
+
+ function artikel_texte_edit() {
+ $id = $this->app->Secure->GetGET('id');
+ // Check if other users are editing this id
+/* if($this->app->erp->DisableModul('artikel_texte',$id))
+ {
+ return;
+ } */
+
+ $this->app->Tpl->Set('ID', $id);
+
+ $this->app->erp->MenuEintrag("index.php?module=artikeltexte&action=edit&id=$id", "Details");
+ $this->app->erp->MenuEintrag("index.php?module=artikeltexte&action=list", "Zurück zur Übersicht");
+ $id = $this->app->Secure->GetGET('id');
+ $input = $this->GetInput();
+ $submit = $this->app->Secure->GetPOST('submit');
+
+ if (empty($id)) {
+ // New item
+ $id = 'NULL';
+ }
+
+ if ($submit != '')
+ {
+
+ // Write to database
+
+ // Add checks here
+
+ // $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],true); // Parameters: Target db?, value, from form?
+
+ $columns = "id, ";
+ $values = "$id, ";
+ $update = "";
+
+ $fix = "";
+
+ foreach ($input as $key => $value) {
+ $columns = $columns.$fix.$key;
+ $values = $values.$fix."'".$value."'";
+ $update = $update.$fix.$key." = '$value'";
+
+ $fix = ", ";
+ }
+
+// echo($columns." ");
+// echo($values." ");
+// echo($update." ");
+
+ $sql = "INSERT INTO artikel_texte (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
+
+// echo($sql);
+
+ $this->app->DB->Update($sql);
+
+ if ($id == 'NULL') {
+ $msg = $this->app->erp->base64_url_encode("Das Element wurde erfolgreich angelegt.
");
+ header("Location: index.php?module=artikeltexte&action=list&msg=$msg");
+ } else {
+ $this->app->Tpl->addMessage('success', 'Die Einstellungen wurden erfolgreich übernommen.');
+ }
+ }
+
+
+ // Load values again from database
+ if ($id != 'NULL') {
+
+ $dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
+ $result = $this->app->DB->SelectArr("
+ SELECT SQL_CALC_FOUND_ROWS
+ a.id,
+ $dropnbox,
+ art.name_de,
+ a.sprache,
+ a.name,
+ a.kurztext,
+ a.beschreibung,
+ a.beschreibung_online,
+ a.meta_title,
+ a.meta_description,
+ a.meta_keywords,
+ a.katalogartikel,
+ a.katalog_bezeichnung,
+ a.katalog_text,
+ a.shop,
+ a.aktiv,
+ a.id
+ FROM
+ artikel_texte a
+ INNER JOIN artikel art ON a.artikel = art.id
+ WHERE a.id=$id
+ ");
+
+
+ foreach ($result[0] as $key => $value) {
+ $this->app->Tpl->Set(strtoupper($key), $value);
+ }
+
+ if (!empty($result)) {
+ $artikel_texte_from_db = $result[0];
+ } else {
+ return;
+ }
+ }
+
+ /*
+ * Add displayed items later
+ *
+ $this->app->Tpl->Add('EMAIL', $email);
+ $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
+
+ $this->app->YUI->AutoComplete("artikel", "artikelnummer");
+
+ */
+
+ $sprachenOptions = $this->app->erp->GetSprachenSelect();
+ $this->app->Tpl->Set('SPRACHE', $this->app->erp->GetSelectAsso($sprachenOptions, $artikel_texte_from_db['sprache']));
+ $this->app->Tpl->Parse('PAGE', "artikeltexte_edit.tpl");
+ }
+
+ /**
+ * Get all paramters from html form and save into $input
+ */
+ public function GetInput(): array {
+ $input = array();
+ //$input['EMAIL'] = $this->app->Secure->GetPOST('email');
+
+ $input['sprache'] = $this->app->Secure->GetPOST('sprache');
+ $input['name'] = $this->app->Secure->GetPOST('name');
+ $input['kurztext'] = $this->app->Secure->GetPOST('kurztext');
+ $input['beschreibung'] = $this->app->Secure->GetPOST('beschreibung');
+ $input['beschreibung_online'] = $this->app->Secure->GetPOST('beschreibung_online');
+ $input['meta_title'] = $this->app->Secure->GetPOST('meta_title');
+ $input['meta_description'] = $this->app->Secure->GetPOST('meta_description');
+ $input['meta_keywords'] = $this->app->Secure->GetPOST('meta_keywords');
+ $input['katalogartikel'] = $this->app->Secure->GetPOST('katalogartikel');
+ $input['katalog_bezeichnung'] = $this->app->Secure->GetPOST('katalog_bezeichnung');
+ $input['katalog_text'] = $this->app->Secure->GetPOST('katalog_text');
+ $input['shop'] = $this->app->Secure->GetPOST('shop');
+ $input['aktiv'] = $this->app->Secure->GetPOST('aktiv')?'1':'0';
+
+ return $input;
+ }
+ }
diff --git a/www/pages/content/artikeltexte_edit.tpl b/www/pages/content/artikeltexte_edit.tpl
new file mode 100644
index 00000000..9e784335
--- /dev/null
+++ b/www/pages/content/artikeltexte_edit.tpl
@@ -0,0 +1,144 @@
+
+
diff --git a/www/pages/content/artikeltexte_list.tpl b/www/pages/content/artikeltexte_list.tpl
new file mode 100644
index 00000000..394c103a
--- /dev/null
+++ b/www/pages/content/artikeltexte_list.tpl
@@ -0,0 +1,10 @@
+
+
+
+ [MESSAGE]
+ [TAB1]
+ [TAB1NEXT]
+
+
diff --git a/www/pages/importvorlage.php b/www/pages/importvorlage.php
index a096fb1d..ea9be2ee 100644
--- a/www/pages/importvorlage.php
+++ b/www/pages/importvorlage.php
@@ -3990,7 +3990,6 @@ class Importvorlage extends GenImportvorlage {
if($this->app->DB->Select("SELECT id FROM artikel WHERE id ='$artikelid' LIMIT 1")){
//Sprachen
- if($this->app->erp->ModulVorhanden('artikel_texte')){
$erlaubtefelder= array('name','kurztext','beschreibung','beschreibung_online','meta_title',
'meta_description','meta_keywords','katalog_bezeichnung','katalog_text','katalogartikel','shop','aktiv');
$zuImportierendeSprachen = [];
@@ -4066,8 +4065,7 @@ class Importvorlage extends GenImportvorlage {
}
}
}
- }
- }
+ } // Sprachen
//freifelduebersetzungen
foreach ($tmp as $feldname => $feldwerte) {
diff --git a/www/widgets/templates/_gen/artikel.tpl b/www/widgets/templates/_gen/artikel.tpl
index a7cc327e..3230ce71 100644
--- a/www/widgets/templates/_gen/artikel.tpl
+++ b/www/widgets/templates/_gen/artikel.tpl
@@ -566,11 +566,13 @@
-
{|Beschreibung|}
+
+ {|Beschreibung|}
From 575c15c3338d0b60a163e6fb662d3fbf3d0ef561 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 8 Jun 2024 10:03:14 +0200
Subject: [PATCH 17/87] adress search filter search in delivery adress
---
phpwf/plugins/class.yui.php | 19 +++++++++++++++++++
www/pages/content/adresse_table_filter.tpl | 20 +++++++++++++-------
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php
index c2d2398e..a276877c 100644
--- a/phpwf/plugins/class.yui.php
+++ b/phpwf/plugins/class.yui.php
@@ -5275,6 +5275,25 @@ url:strUrl, success:function(html){strReturn = html;}, async:false
)
";
}
+
+ if(isset($parameter['lieferadresse']) && !empty($parameter['lieferadresse'])) {
+ $paramsArray[] = "
+ (
+ a.id IN
+ (
+ SELECT
+ adresse
+ FROM
+ lieferadressen lfadr
+ WHERE
+ lfadr.name LIKE '%" . $parameter['lieferadresse'] . "%' OR
+ lfadr.strasse LIKE '%" . $parameter['lieferadresse'] . "%' OR
+ lfadr.plz LIKE '%" . $parameter['lieferadresse'] . "%' OR
+ lfadr.ort LIKE '%" . $parameter['lieferadresse'] . "%'
+ )
+ )
+ ";
+ }
if(isset($parameter['abteilung']) && !empty($parameter['abteilung'])) {
$paramsArray[] = "a.abteilung LIKE '%".$parameter['abteilung']."%' ";
diff --git a/www/pages/content/adresse_table_filter.tpl b/www/pages/content/adresse_table_filter.tpl
index 28437af7..551aaecb 100644
--- a/www/pages/content/adresse_table_filter.tpl
+++ b/www/pages/content/adresse_table_filter.tpl
@@ -62,10 +62,14 @@
{|E-Mail|}:
-
- {|Kunde hat Abo|} {|Marketingsperre|}: {|Lead|}:
-
-
+
+ {|Lieferadresse|}:
+
+
+
+ {|Kunde hat Abo|} {|Marketingsperre|}: {|Lead|}:
+
+
@@ -150,13 +154,15 @@
[ROLLEN]
- Gruppen:
-
+
+
+ Gruppen:
+
{|Alle|}
[GRUPPEN]
-
+
From 3c170318dfe27aabba76623f1aef7970d8df782b Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 10 Jun 2024 17:43:16 +0200
Subject: [PATCH 18/87] gruppen module reimplemented
---
www/pages/content/gruppen_edit.tpl | 784 +++++++++++++++++++++++++++++
www/pages/content/gruppen_list.tpl | 667 +-----------------------
www/pages/gruppen.php | 351 +++++++++++--
3 files changed, 1107 insertions(+), 695 deletions(-)
create mode 100644 www/pages/content/gruppen_edit.tpl
diff --git a/www/pages/content/gruppen_edit.tpl b/www/pages/content/gruppen_edit.tpl
new file mode 100644
index 00000000..33b41335
--- /dev/null
+++ b/www/pages/content/gruppen_edit.tpl
@@ -0,0 +1,784 @@
+
+
+
+
+ [MESSAGE]
+
+ [FORMHANDLEREVENT]
+
+
+
+
+
+ {|Gruppe|} Gruppe für die Zuordnung zu Preislisten, Onlineshop-Preislisten oder Adressgruppen
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/www/pages/content/gruppen_list.tpl b/www/pages/content/gruppen_list.tpl
index 860568d6..394c103a 100644
--- a/www/pages/content/gruppen_list.tpl
+++ b/www/pages/content/gruppen_list.tpl
@@ -1,661 +1,10 @@
-
-
-
- [MESSAGE]
-
-
-
-[TAB1]
+
+
+ [MESSAGE]
+ [TAB1]
+ [TAB1NEXT]
+
-
-
-[TAB3]
-
-
-
-
-[EXTRA]
-
-
-
-
-
-
-
-
-
diff --git a/www/pages/gruppen.php b/www/pages/gruppen.php
index 6fd22eab..41b52b5c 100644
--- a/www/pages/gruppen.php
+++ b/www/pages/gruppen.php
@@ -1,43 +1,322 @@
-
app=$app;
- if($intern) {
- return;
- }
- $this->app->ActionHandlerInit($this);
+/*
+ * Copyright (c) 2022 OpenXE project
+ */
- $this->app->ActionHandler("list","GruppenList");
- $this->app->DefaultActionHandler("list");
+use Xentral\Components\Database\Exception\QueryFailureException;
+class Gruppen {
- $this->app->ActionHandlerListen($app);
- }
- function GruppenList()
- {
- $this->app->Tpl->Set('VERS','Professional');
- $this->app->Tpl->Set('MODUL','Professional');
- $this->app->Tpl->Parse('PAGE', "only_version.tpl");
+ function __construct($app, $intern = false) {
+ $this->app = $app;
+ if ($intern)
+ return;
+
+ $this->app->ActionHandlerInit($this);
+ $this->app->ActionHandler("list", "gruppen_list");
+ $this->app->ActionHandler("create", "gruppen_edit"); // This automatically adds a "New" button
+ $this->app->ActionHandler("edit", "gruppen_edit");
+ $this->app->ActionHandler("delete", "gruppen_delete");
+ $this->app->DefaultActionHandler("list");
+ $this->app->ActionHandlerListen($app);
}
- }
-}
+ public function Install() {
+ /* Fill out manually later */
+ }
+
+ static function TableSearch(&$app, $name, $erlaubtevars) {
+ switch ($name) {
+ case "gruppen_list":
+ $allowed['gruppen_list'] = array('list');
+ $heading = array(
+ '',
+ '',
+ 'Kennziffer',
+ 'Name',
+ 'Art',
+ 'Internebemerkung',
+ 'Projekt',
+ 'Aktiv',
+ 'Menü');
+ $width = array('1%','1%','10%'); // Fill out manually later
+
+ // columns that are aligned right (numbers etc)
+ // $alignright = array(4,5,6,7,8);
+
+ $findcols = array(
+ 'g.id',
+ 'g.id',
+ 'g.kennziffer',
+ 'g.name',
+ 'g.art',
+ 'g.internebemerkung',
+ 'p.abkuerzung',
+ 'g.aktiv',
+ 'g.id'
+ );
+ $searchsql = array('g.name', 'g.art', 'g.kennziffer', 'g.internebemerkung');
+
+ $defaultorder = 1;
+ $defaultorderdesc = 0;
+ $aligncenter = array();
+ $alignright = array();
+ $numbercols = array();
+ $sumcol = array();
+
+ $dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
+
+// $moreinfo = true; // Allow drop down details
+// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
+// $menucol = 11; // Set id col for moredata/menu
+
+ $menu = "";
+
+ $sql = "SELECT SQL_CALC_FOUND_ROWS g.id, $dropnbox, g.kennziffer, g.name, g.art, g.internebemerkung, p.abkuerzung, g.aktiv, g.id FROM gruppen g LEFT JOIN projekt p ON g.projekt = p.id";
+
+ $where = "1";
+ $count = "SELECT count(DISTINCT id) FROM gruppen WHERE $where";
+// $groupby = "";
+
+ break;
+ }
+
+ $erg = false;
+
+ foreach ($erlaubtevars as $k => $v) {
+ if (isset($$v)) {
+ $erg[$v] = $$v;
+ }
+ }
+ return $erg;
+ }
+
+ function gruppen_list() {
+ $this->app->erp->MenuEintrag("index.php?module=gruppen&action=list", "Übersicht");
+ $this->app->erp->MenuEintrag("index.php?module=gruppen&action=create", "Neu anlegen");
+
+ $this->app->erp->MenuEintrag("index.php", "Zurück");
+
+ $this->app->YUI->TableSearch('TAB1', 'gruppen_list', "show", "", "", basename(__FILE__), __CLASS__);
+ $this->app->Tpl->Parse('PAGE', "gruppen_list.tpl");
+ }
+
+ public function gruppen_delete() {
+ $id = (int) $this->app->Secure->GetGET('id');
+
+ $this->app->DB->Delete("DELETE FROM `gruppen` WHERE `id` = '{$id}'");
+ $this->app->Tpl->Set('MESSAGE', "Der Eintrag wurde gelöscht.
");
+
+ $this->gruppen_list();
+ }
+
+ /*
+ * Edit gruppen item
+ * If id is empty, create a new one
+ */
+
+ function gruppen_edit() {
+ $id = $this->app->Secure->GetGET('id');
+
+ // Check if other users are editing this id
+/* if($this->app->erp->DisableModul('gruppen',$id))
+ {
+ return;
+ } */
+
+ $this->app->Tpl->Set('ID', $id);
+
+ $this->app->erp->MenuEintrag("index.php?module=gruppen&action=edit&id=$id", "Details");
+ $this->app->erp->MenuEintrag("index.php?module=gruppen&action=list", "Zurück zur Übersicht");
+ $id = $this->app->Secure->GetGET('id');
+ $input = $this->GetInput();
+
+ // Convert here
+ $input['aktiv'] = !empty($this->app->Secure->GetPOST('aktiv'))?"1":"0";
+
+ $submit = $this->app->Secure->GetPOST('submit');
+
+ if (empty($id)) {
+ // New item
+ $id = 'NULL';
+ }
+
+ if ($submit != '')
+ {
+
+ // Write to database
+
+ // Add checks here
+
+ $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],true); // Parameters: Target db?, value, from form?
+
+ $columns = "id, ";
+ $values = "$id, ";
+ $update = "";
+
+ $fix = "";
+
+ foreach ($input as $key => $value) {
+ $columns = $columns.$fix.$key;
+ $values = $values.$fix."'".$value."'";
+ $update = $update.$fix.$key." = '$value'";
+
+ $fix = ", ";
+ }
+
+// echo($columns." ");
+// echo($values." ");
+// echo($update." ");
+
+ $sql = "INSERT INTO gruppen (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
+
+// echo($sql);
+
+ $this->app->DB->Update($sql);
+
+ if ($id == 'NULL') {
+ $msg = $this->app->erp->base64_url_encode("Das Element wurde erfolgreich angelegt.
");
+ header("Location: index.php?module=gruppen&action=list&msg=$msg");
+ } else {
+ $this->app->Tpl->Set('MESSAGE', "Die Einstellungen wurden erfolgreich übernommen.
");
+ }
+ }
+
+
+ // Load values again from database
+ $dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
+ $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS g.id, $dropnbox, g.name, g.art, g.kennziffer, g.internebemerkung, g.grundrabatt, g.rabatt1, g.rabatt2, g.rabatt3, g.rabatt4, g.rabatt5, g.sonderrabatt_skonto, g.provision, g.kundennummer, g.partnerid, g.dta_aktiv, g.dta_periode, g.dta_dateiname, g.dta_mail, g.dta_mail_betreff, g.dta_mail_text, g.dtavariablen, g.dta_variante, g.bonus1, g.bonus1_ab, g.bonus2, g.bonus2_ab, g.bonus3, g.bonus3_ab, g.bonus4, g.bonus4_ab, g.bonus5, g.bonus5_ab, g.bonus6, g.bonus6_ab, g.bonus7, g.bonus7_ab, g.bonus8, g.bonus8_ab, g.bonus9, g.bonus9_ab, g.bonus10, g.bonus10_ab, g.zahlungszieltage, g.zahlungszielskonto, g.zahlungszieltageskonto, g.portoartikel, g.portofreiab, g.erweiterteoptionen, g.zentralerechnung, g.zentralregulierung, g.gruppe, g.preisgruppe, g.verbandsgruppe, g.rechnung_name, g.rechnung_strasse, g.rechnung_ort, g.rechnung_plz, g.rechnung_abteilung, g.rechnung_land, g.rechnung_email, g.rechnung_periode, g.rechnung_anzahlpapier, g.rechnung_permail, g.webid, g.portofrei_aktiv, g.projekt, g.objektname, g.objekttyp, g.parameter, g.objektname2, g.objekttyp2, g.parameter2, g.objektname3, g.objekttyp3, g.parameter3, g.kategorie, g.aktiv, g.id FROM gruppen g"." WHERE id=$id");
+
+ foreach ($result[0] as $key => $value) {
+ $this->app->Tpl->Set(strtoupper($key), $value);
+ }
+
+ if (!empty($result)) {
+ $gruppen_from_db = $result[0];
+ } else {
+
+ }
+
+ /*
+ * Add displayed items later
+ *
+
+ $this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
+ $this->app->Tpl->Add('EMAIL', $email);
+ $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
+
+ $this->app->YUI->AutoComplete("artikel", "artikelnummer");
+
+ */
+
+ $this->app->YUI->AutoComplete("kennziffer", "gruppekennziffer");
+
+ if ($gruppen_from_db['art'] != 'preisgruppe') {
+ $this->app->Tpl->Set('PREISGRUPPEHIDDEN','hidden');
+ }
+
+ $art_select = Array(
+ 'gruppe' => 'Gruppe',
+ 'preisgruppe' => 'Preisgruppe'
+ );
+ $art_select = $this->app->erp->GetSelectAsso($art_select,$gruppen_from_db['art']);
+ $this->app->Tpl->Set('ARTSELECT',$art_select);
+
+ $this->app->YUI->AutoComplete("projekt","projektname",1);
+ $this->app->Tpl->Set('PROJEKT',$this->app->erp->ReplaceProjekt(false,$gruppen_from_db['projekt'],false));
+
+ $this->app->Tpl->Set('AKTIV', $gruppen_from_db['aktiv']==1?"checked":"");
+
+ $this->app->Tpl->Parse('PAGE', "gruppen_edit.tpl");
+ }
+
+ /**
+ * Get all paramters from html form and save into $input
+ */
+ public function GetInput(): array {
+ $input = array();
+ //$input['EMAIL'] = $this->app->Secure->GetPOST('email');
+
+ $input['name'] = $this->app->Secure->GetPOST('name');
+ $input['art'] = $this->app->Secure->GetPOST('art');
+ $input['kennziffer'] = $this->app->Secure->GetPOST('kennziffer');
+ $input['internebemerkung'] = $this->app->Secure->GetPOST('internebemerkung');
+ $input['grundrabatt'] = $this->app->Secure->GetPOST('grundrabatt');
+ $input['rabatt1'] = $this->app->Secure->GetPOST('rabatt1');
+ $input['rabatt2'] = $this->app->Secure->GetPOST('rabatt2');
+ $input['rabatt3'] = $this->app->Secure->GetPOST('rabatt3');
+ $input['rabatt4'] = $this->app->Secure->GetPOST('rabatt4');
+ $input['rabatt5'] = $this->app->Secure->GetPOST('rabatt5');
+ $input['sonderrabatt_skonto'] = $this->app->Secure->GetPOST('sonderrabatt_skonto');
+ $input['provision'] = $this->app->Secure->GetPOST('provision');
+ $input['kundennummer'] = $this->app->Secure->GetPOST('kundennummer');
+ $input['partnerid'] = $this->app->Secure->GetPOST('partnerid');
+ $input['dta_aktiv'] = $this->app->Secure->GetPOST('dta_aktiv');
+ $input['dta_periode'] = $this->app->Secure->GetPOST('dta_periode');
+ $input['dta_dateiname'] = $this->app->Secure->GetPOST('dta_dateiname');
+ $input['dta_mail'] = $this->app->Secure->GetPOST('dta_mail');
+ $input['dta_mail_betreff'] = $this->app->Secure->GetPOST('dta_mail_betreff');
+ $input['dta_mail_text'] = $this->app->Secure->GetPOST('dta_mail_text');
+ $input['dtavariablen'] = $this->app->Secure->GetPOST('dtavariablen');
+ $input['dta_variante'] = $this->app->Secure->GetPOST('dta_variante');
+ $input['bonus1'] = $this->app->Secure->GetPOST('bonus1');
+ $input['bonus1_ab'] = $this->app->Secure->GetPOST('bonus1_ab');
+ $input['bonus2'] = $this->app->Secure->GetPOST('bonus2');
+ $input['bonus2_ab'] = $this->app->Secure->GetPOST('bonus2_ab');
+ $input['bonus3'] = $this->app->Secure->GetPOST('bonus3');
+ $input['bonus3_ab'] = $this->app->Secure->GetPOST('bonus3_ab');
+ $input['bonus4'] = $this->app->Secure->GetPOST('bonus4');
+ $input['bonus4_ab'] = $this->app->Secure->GetPOST('bonus4_ab');
+ $input['bonus5'] = $this->app->Secure->GetPOST('bonus5');
+ $input['bonus5_ab'] = $this->app->Secure->GetPOST('bonus5_ab');
+ $input['bonus6'] = $this->app->Secure->GetPOST('bonus6');
+ $input['bonus6_ab'] = $this->app->Secure->GetPOST('bonus6_ab');
+ $input['bonus7'] = $this->app->Secure->GetPOST('bonus7');
+ $input['bonus7_ab'] = $this->app->Secure->GetPOST('bonus7_ab');
+ $input['bonus8'] = $this->app->Secure->GetPOST('bonus8');
+ $input['bonus8_ab'] = $this->app->Secure->GetPOST('bonus8_ab');
+ $input['bonus9'] = $this->app->Secure->GetPOST('bonus9');
+ $input['bonus9_ab'] = $this->app->Secure->GetPOST('bonus9_ab');
+ $input['bonus10'] = $this->app->Secure->GetPOST('bonus10');
+ $input['bonus10_ab'] = $this->app->Secure->GetPOST('bonus10_ab');
+ $input['zahlungszieltage'] = $this->app->Secure->GetPOST('zahlungszieltage');
+ $input['zahlungszielskonto'] = $this->app->Secure->GetPOST('zahlungszielskonto');
+ $input['zahlungszieltageskonto'] = $this->app->Secure->GetPOST('zahlungszieltageskonto');
+ $input['portoartikel'] = $this->app->Secure->GetPOST('portoartikel');
+ $input['portofreiab'] = $this->app->Secure->GetPOST('portofreiab');
+ $input['erweiterteoptionen'] = $this->app->Secure->GetPOST('erweiterteoptionen');
+ $input['zentralerechnung'] = $this->app->Secure->GetPOST('zentralerechnung');
+ $input['zentralregulierung'] = $this->app->Secure->GetPOST('zentralregulierung');
+ $input['gruppe'] = $this->app->Secure->GetPOST('gruppe');
+ $input['preisgruppe'] = $this->app->Secure->GetPOST('preisgruppe');
+ $input['verbandsgruppe'] = $this->app->Secure->GetPOST('verbandsgruppe');
+ $input['rechnung_name'] = $this->app->Secure->GetPOST('rechnung_name');
+ $input['rechnung_strasse'] = $this->app->Secure->GetPOST('rechnung_strasse');
+ $input['rechnung_ort'] = $this->app->Secure->GetPOST('rechnung_ort');
+ $input['rechnung_plz'] = $this->app->Secure->GetPOST('rechnung_plz');
+ $input['rechnung_abteilung'] = $this->app->Secure->GetPOST('rechnung_abteilung');
+ $input['rechnung_land'] = $this->app->Secure->GetPOST('rechnung_land');
+ $input['rechnung_email'] = $this->app->Secure->GetPOST('rechnung_email');
+ $input['rechnung_periode'] = $this->app->Secure->GetPOST('rechnung_periode');
+ $input['rechnung_anzahlpapier'] = $this->app->Secure->GetPOST('rechnung_anzahlpapier');
+ $input['rechnung_permail'] = $this->app->Secure->GetPOST('rechnung_permail');
+ $input['webid'] = $this->app->Secure->GetPOST('webid');
+ $input['portofrei_aktiv'] = $this->app->Secure->GetPOST('portofrei_aktiv');
+ $input['projekt'] = $this->app->Secure->GetPOST('projekt');
+ $input['objektname'] = $this->app->Secure->GetPOST('objektname');
+ $input['objekttyp'] = $this->app->Secure->GetPOST('objekttyp');
+ $input['parameter'] = $this->app->Secure->GetPOST('parameter');
+ $input['objektname2'] = $this->app->Secure->GetPOST('objektname2');
+ $input['objekttyp2'] = $this->app->Secure->GetPOST('objekttyp2');
+ $input['parameter2'] = $this->app->Secure->GetPOST('parameter2');
+ $input['objektname3'] = $this->app->Secure->GetPOST('objektname3');
+ $input['objekttyp3'] = $this->app->Secure->GetPOST('objekttyp3');
+ $input['parameter3'] = $this->app->Secure->GetPOST('parameter3');
+ $input['kategorie'] = $this->app->Secure->GetPOST('kategorie');
+ $input['aktiv'] = $this->app->Secure->GetPOST('aktiv');
+
+
+ return $input;
+ }
+ }
From 0b5b7cbed19ca2d075b0779100980c538949da5c Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 11 Jun 2024 19:45:39 +0200
Subject: [PATCH 19/87] Bugfixes adressstammdatenblatt
---
www/lib/dokumente/class.adressstammblatt.php | 465 +++++++++---------
www/lib/dokumente/class.dokumentenvorlage.php | 6 +-
www/pages/adresse.php | 2 +-
3 files changed, 238 insertions(+), 235 deletions(-)
diff --git a/www/lib/dokumente/class.adressstammblatt.php b/www/lib/dokumente/class.adressstammblatt.php
index 93904637..2a7c8507 100644
--- a/www/lib/dokumente/class.adressstammblatt.php
+++ b/www/lib/dokumente/class.adressstammblatt.php
@@ -1,235 +1,236 @@
-app=$app;
- //parent::Dokumentenvorlage();
- $this->doctype="adresse";
- $this->doctypeOrig="Adressstammblatt";
- parent::__construct($this->app,$projekt);
- }
-
- public function renderDocument() {
- // prepare page details
- SuperFPDF::__construct('P','mm','A4');
-
-
- $this->AddPage();
- $this->SetDisplayMode("real","single");
-
- $this->SetMargins(15,50);
- $this->SetAutoPageBreak(true,40);
- $this->AliasNbPages('{nb}');
-
-
- // Bei Adressstammblatt immer oben beginnen
- $this->abstand_betreffzeileoben=0;
- $this->logofile = "";//$this->app->erp->GetTMP()."/".$this->app->Conf->WFdbname."_logo.jpg";
- $this->briefpapier="";
-
-
- $schrift = $this->app->erp->Firmendaten('schriftgroesse');
-
- $this->SetFontSize($schrift);
- $this->SetFont($this->GetFont(),'','10');
- $this->SetX($this->GetX()+160);
- $this->Cell(10,0,date("d.m.Y"),"","","L");
-
- $this->renderDoctype();
-
- $adresse = $this->app->DB->SelectArr("SELECT * FROM adresse WHERE id='".$this->id."'");
- $adresse = reset($adresse);
-
- if($adresse['typ']=="firma")
- {
- $infofields[]=array("Firma",$adresse['name']);
- if($adresse['ansprechpartner']!="")
- $infofields[]=array("Ansprechpartner",$adresse['ansprechpartner']);
- } else {
- $infofields[]=array("Name",$adresse['name']);
- }
-
- $infofields[]=array("Anschrift",$adresse['land']."-".$adresse['plz']." ".$adresse['ort'].", ".$adresse['strasse']);
-
- $felder = array('telefon','telefax','mobil','email','web');
- foreach($felder as $feldname)
- {
- $infofields[]=array(ucfirst($feldname),$adresse[$feldname=='web'?'internetseite':$feldname]);
- }
-
-
- if($this->app->erp->Firmendaten("modul_mlm")==1)
- {
- $mlmvertragsbeginn = $this->app->DB->Select("SELECT DATE_FORMAT(mlmvertragsbeginn,'%d.%m.%Y') FROM adresse WHERE id='".$adresse['id']."' LIMIT 1");
- if($mlmvertragsbeginn=="00.00.0000") $mlmvertragsbeginn = "kein Vertragsbeginn eingestellt";
- $sponsorid = $this->app->DB->Select("SELECT sponsor FROM adresse WHERE id='".$adresse['id']."' LIMIT 1");
- if($sponsorid> 0)
- $sponsor = $this->app->DB->Select("SELECT CONCAT(kundennummer,' ',name) FROM adresse WHERE id='$sponsorid' LIMIT 1");
- else
- $sponsor = "Kein Sponsor vorhanden";
-
- $erfasstam = $this->app->DB->Select("SELECT DATE_FORMAT(zeitstempel,'%d.%m.%Y') FROM objekt_protokoll WHERE objekt='adresse' AND objektid='".$adresse['id']."' AND action_long='adresse_create' LIMIT 1");
-
- $infofields[]=array("Sponsor",$sponsor);
- $infofields[]=array("Erfasst am",$erfasstam);
- $infofields[]=array("Vertragsbeginn am",$mlmvertragsbeginn);
- }
-
-
-
- $infofields[]=array("UST-ID",$adresse['ustid']);
-
-
- if($adresse['kundennummer']!="")
- $numbers[] = array("Kunden Nr.",$adresse['kundennummer']);
-
- if($adresse['lieferantennummer']!="")
- $numbers[] = array("Lieferanten Nr.",$adresse['lieferantennummer']);
-
- if($adresse['mitarbeiternummer']!="")
- $numbers[] = array("Mitarbeiter Nr.",$adresse['mitarbeiternummer']);
-
- if(count($numbers)>0)
- $this->renderInfoBox($numbers);
-
- $this->Ln(5);
- $this->renderHeading("Adressstammblatt",8);
- $this->renderInfoBox($infofields);
-
-
-
- $ansprechpartner_tmp = $this->app->DB->SelectArr("SELECT CONCAT(name,', ',if(bereich='','-',bereich),
- ', Telefon: ',telefon,
- ', Mobil: ',mobil,
- ', E-Mail: ',email
- ) as 'value' FROM ansprechpartner WHERE adresse='".$adresse['id']."'");
-
- for($i=0;$i 0)
- {
- $this->Ln(5);
- $this->renderHeading("Ansprechpartner",8);
- $this->renderInfoBoxSingle($ansprechpartner);
- }
-
- $lieferadressen_tmp = $this->app->DB->SelectArr("SELECT name,abteilung,unterabteilung,adresszusatz,strasse,plz,ort,land,
- telefon,email
- FROM lieferadressen WHERE adresse='".$adresse['id']."' ORDER by standardlieferadresse DESC");
-
- for($i=0;$i$value)
- {
- switch($key)
- {
- case "email":
- $lieferadressen_tmp[$i]['value'] .= "E-Mail: $value, ";
- break;
-
- case "telefon":
- $lieferadressen_tmp[$i]['value'] .= "Telefon: $value, ";
- break;
- case "telefax":
- $lieferadressen_tmp[$i]['value'] .= "Telefax: $value, ";
- break;
-
- default:
- if($value!="")
- $lieferadressen_tmp[$i]['value'] .= "$value, ";
- }
- }
-
- $lieferadressen_tmp[$i]['value'] = trim($lieferadressen_tmp[$i]['value'],', ');
- if($i==0) $standard = " (Standard)"; else $standard="";
-
- $lieferadressen[] = $lieferadressen_tmp[$i]['value'].$standard;
- }
-
- if(count($lieferadressen) > 0)
- {
- $this->Ln(5);
- $this->renderHeading("Lieferadressen",8);
- $this->renderInfoBoxSingle($lieferadressen);
- }
-
-
- $this->Ln(5);
-
- if($adresse['sonstiges']!="")
- {
- $this->renderHeading("Sonstiges",8);
- $this->SetFont($this->GetFont(),'',7);
- $this->MultiCell(180,4,$this->WriteHTML($adresse['sonstiges']));
- }
-
- $this->renderFooter();
- }
-
-
- function GetAdressstammblatt($id,$info="",$extrafreitext="")
- {
- $this->id = $id;
- // das muss vom reisekosten sein!!!!
- //$this->setRecipientLieferadresse($id,"reisekosten");
-
- // OfferNo, customerId, OfferDate
- /*$auftrag = $this->app->DB->Select("SELECT auftragid FROM reisekosten WHERE id='$id' LIMIT 1");
- $auftrag = $this->app->DB->Select("SELECT belegnr FROM auftrag WHERE id='$auftrag' LIMIT 1");
- $bearbeiter = $this->app->DB->Select("SELECT bearbeiter FROM reisekosten WHERE id='$id' LIMIT 1");
- $prefix = $this->app->DB->Select("SELECT prefix FROM reisekosten WHERE id='$id' LIMIT 1");
- $bestellbestaetigung = $this->app->DB->Select("SELECT bestellbestaetigung FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->datum = $this->app->DB->Select("SELECT DATE_FORMAT(datum,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
-
- $this->von = $this->app->DB->Select("SELECT DATE_FORMAT(von,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->bis = $this->app->DB->Select("SELECT DATE_FORMAT(bis,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->von_zeit = $this->app->DB->Select("SELECT von_zeit FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->bis_zeit = $this->app->DB->Select("SELECT bis_zeit FROM reisekosten WHERE id='$id' LIMIT 1");
- $belegnr = $this->app->DB->Select("SELECT belegnr FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->anlass = $this->app->DB->Select("SELECT anlass FROM reisekosten WHERE id='$id' LIMIT 1");
- $this->freitext = $this->app->DB->Select("SELECT freitext FROM reisekosten WHERE id='$id' LIMIT 1");
- $projekt = $this->app->DB->Select("SELECT projekt FROM reisekosten WHERE id='$id' LIMIT 1");
- $mitarbeiter = $this->app->DB->Select("SELECT mitarbeiter FROM reisekosten WHERE id='$id' LIMIT 1");*/
- $kunde= $this->app->DB->SelectArr("SELECT name,kundennummer,lieferantennummer FROM adresse WHERE id='$id' LIMIT 1");
- $kunde = reset($kunde);
-
- $kundennummer = $kunde['kundennummer'];
- $this->name = $kunde['name'];
-
- $this->projektabkuerzung = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id='$projekt'");
- $this->firmenname = $this->app->erp->Firmendaten('name');
- $this->doctypeOrig="Adresse: ".$kunde['name'];
- $this->barcode=$belegnr;
-
- //$ohne_briefpapier = $this->app->DB->Select("SELECT ohne_briefpapier FROM reisekosten WHERE id='$id' LIMIT 1");
-
-
-
-
- //$artikel = $this->app->DB->SelectArr("SELECT *,DATE_FORMAT(datum,'%d.%m.%Y') as datum, CONCAT(rk.nummer,'- ',rk.beschreibung) as reisekostenart FROM reisekosten_position rp LEFT JOIN reisekostenart rk ON rk.id=rp.reisekostenart WHERE rp.reisekosten='$id' ORDER By rp.sort");
-
- //$waehrung = $this->app->DB->Select("SELECT waehrung FROM reisekosten_position WHERE reisekosten='$id' LIMIT 1");
-
- /* Dateiname */
- $this->filename = date('Ymd')."_STAMMDATEN_ADRESSE_".$this->app->erp->Dateinamen($kunde['name']).".pdf";
-
- $this->setBarcode($id);
- }
-
-
-}
+app=$app;
+ //parent::Dokumentenvorlage();
+ $this->doctype="adresse";
+ $this->table="adresse";
+ $this->doctypeOrig="Adressstammblatt";
+ parent::__construct($this->app,$projekt);
+ }
+
+ public function renderDocument() {
+ // prepare page details
+ SuperFPDF::__construct('P','mm','A4');
+
+
+ $this->AddPage();
+ $this->SetDisplayMode("real","single");
+
+ $this->SetMargins(15,50);
+ $this->SetAutoPageBreak(true,40);
+ $this->AliasNbPages('{nb}');
+
+
+ // Bei Adressstammblatt immer oben beginnen
+ $this->abstand_betreffzeileoben=0;
+ $this->logofile = "";//$this->app->erp->GetTMP()."/".$this->app->Conf->WFdbname."_logo.jpg";
+ $this->briefpapier="";
+
+
+ $schrift = $this->app->erp->Firmendaten('schriftgroesse');
+
+ $this->SetFontSize($schrift);
+ $this->SetFont($this->GetFont(),'','10');
+ $this->SetX($this->GetX()+160);
+ $this->Cell(10,0,date("d.m.Y"),"","","L");
+
+ $this->renderDoctype();
+
+ $adresse = $this->app->DB->SelectArr("SELECT * FROM adresse WHERE id='".$this->id."'");
+ $adresse = reset($adresse);
+
+ if($adresse['typ']=="firma")
+ {
+ $infofields[]=array("Firma",$adresse['name']);
+ if($adresse['ansprechpartner']!="")
+ $infofields[]=array("Ansprechpartner",$adresse['ansprechpartner']);
+ } else {
+ $infofields[]=array("Name",$adresse['name']);
+ }
+
+ $infofields[]=array("Anschrift",$adresse['land']."-".$adresse['plz']." ".$adresse['ort'].", ".$adresse['strasse']);
+
+ $felder = array('telefon','telefax','mobil','email','web');
+ foreach($felder as $feldname)
+ {
+ $infofields[]=array(ucfirst($feldname),$adresse[$feldname=='web'?'internetseite':$feldname]);
+ }
+
+
+ if($this->app->erp->Firmendaten("modul_mlm")==1)
+ {
+ $mlmvertragsbeginn = $this->app->DB->Select("SELECT DATE_FORMAT(mlmvertragsbeginn,'%d.%m.%Y') FROM adresse WHERE id='".$adresse['id']."' LIMIT 1");
+ if($mlmvertragsbeginn=="00.00.0000") $mlmvertragsbeginn = "kein Vertragsbeginn eingestellt";
+ $sponsorid = $this->app->DB->Select("SELECT sponsor FROM adresse WHERE id='".$adresse['id']."' LIMIT 1");
+ if($sponsorid> 0)
+ $sponsor = $this->app->DB->Select("SELECT CONCAT(kundennummer,' ',name) FROM adresse WHERE id='$sponsorid' LIMIT 1");
+ else
+ $sponsor = "Kein Sponsor vorhanden";
+
+ $erfasstam = $this->app->DB->Select("SELECT DATE_FORMAT(zeitstempel,'%d.%m.%Y') FROM objekt_protokoll WHERE objekt='adresse' AND objektid='".$adresse['id']."' AND action_long='adresse_create' LIMIT 1");
+
+ $infofields[]=array("Sponsor",$sponsor);
+ $infofields[]=array("Erfasst am",$erfasstam);
+ $infofields[]=array("Vertragsbeginn am",$mlmvertragsbeginn);
+ }
+
+
+
+ $infofields[]=array("UST-ID",$adresse['ustid']);
+
+
+ if($adresse['kundennummer']!="")
+ $numbers[] = array("Kunden Nr.",$adresse['kundennummer']);
+
+ if($adresse['lieferantennummer']!="")
+ $numbers[] = array("Lieferanten Nr.",$adresse['lieferantennummer']);
+
+ if($adresse['mitarbeiternummer']!="")
+ $numbers[] = array("Mitarbeiter Nr.",$adresse['mitarbeiternummer']);
+
+ if($numbers?count($numbers):0>0)
+ $this->renderInfoBox($numbers);
+
+ $this->Ln(5);
+ $this->renderHeading("Adressstammblatt",8);
+ $this->renderInfoBox($infofields);
+
+
+
+ $ansprechpartner_tmp = $this->app->DB->SelectArr("SELECT CONCAT(name,', ',if(bereich='','-',bereich),
+ ', Telefon: ',telefon,
+ ', Mobil: ',mobil,
+ ', E-Mail: ',email
+ ) as 'value' FROM ansprechpartner WHERE adresse='".$adresse['id']."'");
+
+ for($i=0;$i<($ansprechpartner_tmp?count($ansprechpartner_tmp):0);$i++) $ansprechpartner[] = $ansprechpartner_tmp[$i]['value'];
+ if($ansprechpartner_tmp?count($ansprechpartner):0 > 0)
+ {
+ $this->Ln(5);
+ $this->renderHeading("Ansprechpartner",8);
+ $this->renderInfoBoxSingle($ansprechpartner);
+ }
+
+ $lieferadressen_tmp = $this->app->DB->SelectArr("SELECT name,abteilung,unterabteilung,adresszusatz,strasse,plz,ort,land,
+ telefon,email
+ FROM lieferadressen WHERE adresse='".$adresse['id']."' ORDER by standardlieferadresse DESC");
+
+ for($i=0;$i<($lieferadressen_tmp?count($lieferadressen_tmp):0);$i++) {
+ $lieferadressen_tmp[$i]['value']="";
+ foreach($lieferadressen_tmp[$i] as $key=>$value)
+ {
+ switch($key)
+ {
+ case "email":
+ $lieferadressen_tmp[$i]['value'] .= "E-Mail: $value, ";
+ break;
+
+ case "telefon":
+ $lieferadressen_tmp[$i]['value'] .= "Telefon: $value, ";
+ break;
+ case "telefax":
+ $lieferadressen_tmp[$i]['value'] .= "Telefax: $value, ";
+ break;
+
+ default:
+ if($value!="")
+ $lieferadressen_tmp[$i]['value'] .= "$value, ";
+ }
+ }
+
+ $lieferadressen_tmp[$i]['value'] = trim($lieferadressen_tmp[$i]['value'],', ');
+ if($i==0) $standard = " (Standard)"; else $standard="";
+
+ $lieferadressen[] = $lieferadressen_tmp[$i]['value'].$standard;
+ }
+
+ if($lieferadressen?count($lieferadressen):0 > 0)
+ {
+ $this->Ln(5);
+ $this->renderHeading("Lieferadressen",8);
+ $this->renderInfoBoxSingle($lieferadressen);
+ }
+
+
+ $this->Ln(5);
+
+ if($adresse['sonstiges']!="")
+ {
+ $this->renderHeading("Sonstiges",8);
+ $this->SetFont($this->GetFont(),'',7);
+ $this->MultiCell(180,4,$this->WriteHTML($adresse['sonstiges']));
+ }
+
+ $this->renderFooter();
+ }
+
+
+ function GetAdressstammblatt($id,$info="",$extrafreitext="")
+ {
+ $this->id = $id;
+ // das muss vom reisekosten sein!!!!
+ //$this->setRecipientLieferadresse($id,"reisekosten");
+
+ // OfferNo, customerId, OfferDate
+ /*$auftrag = $this->app->DB->Select("SELECT auftragid FROM reisekosten WHERE id='$id' LIMIT 1");
+ $auftrag = $this->app->DB->Select("SELECT belegnr FROM auftrag WHERE id='$auftrag' LIMIT 1");
+ $bearbeiter = $this->app->DB->Select("SELECT bearbeiter FROM reisekosten WHERE id='$id' LIMIT 1");
+ $prefix = $this->app->DB->Select("SELECT prefix FROM reisekosten WHERE id='$id' LIMIT 1");
+ $bestellbestaetigung = $this->app->DB->Select("SELECT bestellbestaetigung FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->datum = $this->app->DB->Select("SELECT DATE_FORMAT(datum,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
+
+ $this->von = $this->app->DB->Select("SELECT DATE_FORMAT(von,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->bis = $this->app->DB->Select("SELECT DATE_FORMAT(bis,'%d.%m.%Y') FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->von_zeit = $this->app->DB->Select("SELECT von_zeit FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->bis_zeit = $this->app->DB->Select("SELECT bis_zeit FROM reisekosten WHERE id='$id' LIMIT 1");
+ $belegnr = $this->app->DB->Select("SELECT belegnr FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->anlass = $this->app->DB->Select("SELECT anlass FROM reisekosten WHERE id='$id' LIMIT 1");
+ $this->freitext = $this->app->DB->Select("SELECT freitext FROM reisekosten WHERE id='$id' LIMIT 1");
+ $projekt = $this->app->DB->Select("SELECT projekt FROM reisekosten WHERE id='$id' LIMIT 1");
+ $mitarbeiter = $this->app->DB->Select("SELECT mitarbeiter FROM reisekosten WHERE id='$id' LIMIT 1");*/
+ $kunde= $this->app->DB->SelectArr("SELECT name,kundennummer,lieferantennummer FROM adresse WHERE id='$id' LIMIT 1");
+ $kunde = reset($kunde);
+
+ $kundennummer = $kunde['kundennummer'];
+ $this->name = $kunde['name'];
+
+ $this->projektabkuerzung = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id='$projekt'");
+ $this->firmenname = $this->app->erp->Firmendaten('name');
+ $this->doctypeOrig="Adresse: ".$kunde['name'];
+ $this->barcode=$belegnr;
+
+ //$ohne_briefpapier = $this->app->DB->Select("SELECT ohne_briefpapier FROM reisekosten WHERE id='$id' LIMIT 1");
+
+
+
+
+ //$artikel = $this->app->DB->SelectArr("SELECT *,DATE_FORMAT(datum,'%d.%m.%Y') as datum, CONCAT(rk.nummer,'- ',rk.beschreibung) as reisekostenart FROM reisekosten_position rp LEFT JOIN reisekostenart rk ON rk.id=rp.reisekostenart WHERE rp.reisekosten='$id' ORDER By rp.sort");
+
+ //$waehrung = $this->app->DB->Select("SELECT waehrung FROM reisekosten_position WHERE reisekosten='$id' LIMIT 1");
+
+ /* Dateiname */
+ $this->filename = date('Ymd')."_STAMMDATEN_ADRESSE_".$this->app->erp->Dateinamen($kunde['name']).".pdf";
+
+ $this->setBarcode($id);
+ }
+
+
+}
diff --git a/www/lib/dokumente/class.dokumentenvorlage.php b/www/lib/dokumente/class.dokumentenvorlage.php
index 1c14dcd3..f2a024f9 100644
--- a/www/lib/dokumente/class.dokumentenvorlage.php
+++ b/www/lib/dokumente/class.dokumentenvorlage.php
@@ -474,9 +474,11 @@ class Dokumentenvorlage extends SuperFPDF {
$this->Output($dir."/".$this->table."/".$this->id."_".$this->filename,'F');
}
- public function displayDocument() {
+ public function displayDocument($archive = true) {
$this->renderDocument();
- $this->archiveDocument();
+ if ($archive) {
+ $this->archiveDocument();
+ }
$this->Output($this->filename,'D');
exit;
}
diff --git a/www/pages/adresse.php b/www/pages/adresse.php
index ca86ff8d..82c3a957 100644
--- a/www/pages/adresse.php
+++ b/www/pages/adresse.php
@@ -780,7 +780,7 @@ class Adresse extends GenAdresse {
}
$Brief->GetAdressstammblatt($id);
- $Brief->displayDocument();
+ $Brief->displayDocument(archive: false);
$this->app->ExitXentral();
}
From 2b43efca70d3e8f6224116b47b4f528e6b110a02 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 11 Jun 2024 20:00:16 +0200
Subject: [PATCH 20/87] Bugfix add price when address is in several groups
---
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 9ec83a60..27679ee4 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -38222,7 +38222,7 @@ function Firmendaten($field,$projekt="")
$sql_erweiterung = '';
if(!empty($gruppenarr))
{
- $sql_erweiterung .= ' OR v.gruppe IN ('.implode(' ', $gruppenarr).') ';
+ $sql_erweiterung .= ' OR v.gruppe IN ('.implode(', ', $gruppenarr).') ';
}
if(!$guenstigste_vk) {
$vkarr = $this->app->DB->SelectArr("SELECT * FROM verkaufspreise v WHERE v.ab_menge <= '$menge' AND
From 09aacfbb7bb6bedc52eb115913d906a5547a278d Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 12 Jun 2024 11:24:10 +0200
Subject: [PATCH 21/87] Bugfix file upload dragndrop
---
phpwf/plugins/class.yui.php | 168 +++++++++++++++-----------
www/pages/content/datei_neudirekt.tpl | 6 +-
2 files changed, 103 insertions(+), 71 deletions(-)
diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php
index a276877c..bfe50fbd 100644
--- a/phpwf/plugins/class.yui.php
+++ b/phpwf/plugins/class.yui.php
@@ -14135,24 +14135,18 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
$action = $this->app->Secure->GetGET("action");
$id = $this->app->Secure->GetGET("id");
if($id)$this->app->Tpl->Set('ID',$id);
- if ($speichern != "") {
- $titel = $this->app->Secure->GetPOST("titel");
- $beschreibung = $this->app->Secure->GetPOST("beschreibung");
- $stichwort = $this->app->Secure->GetPOST("stichwort");
- $this->app->Tpl->Set('TITLE', $titel);
- $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung);
-
- if ($_FILES['upload']['tmp_name'] == "") {
- $this->app->Tpl->Set('ERROR', "Bitte wählen Sie eine Datei aus und laden Sie diese herauf!
");
- $this->app->erp->EnableTab("tabs-2");
- } else {
- //$fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'],$titel,$beschreibung,"",$_FILES['upload']['tmp_name'],$this->app->User->GetName());
- $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $_FILES['upload']['name'], "Neue Version", $_FILES['upload']['tmp_name']);
- header("Location: index.php?module=$module&action=$action&id=$id");
- exit;
+ // Get files here
+ if ($speichern != "") {
+ $retval = $this->FilesFromUploadtoDMS(null, null, $datei);
+ if ($retval !== true) {
+ $this->app->Tpl->Set('ERROR', implode(', ',$retval));
+ $this->app->erp->EnableTab("tabs-2");
+ } else {
+ header("Location: index.php?module=$module&action=$action&id=$id");
}
}
+
$this->app->Tpl->Set('STARTDISABLE', "");
$this->app->Tpl->Parse($parsetarget, "datei_neudirekt.tpl");
@@ -14229,61 +14223,18 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
$id = $this->app->Secure->GetGET("id");
$sid = $this->app->Secure->GetGET("sid");
if($id)$this->app->Tpl->Set('ID', $id);
+
+ // Get files here
if ($speichern != "") {
- if($parameter == '')$parameter = $id;
- if(isset($_POST['dateiv']))
- {
- foreach($_POST['dateiv'] as $k => $v)
- {
- $name = $this->app->DB->real_escape_string($_POST['dateiname'][$k]);
- $titel = $this->app->DB->real_escape_string($_POST['dateititel'][$k]);
- $beschreibung = $this->app->DB->real_escape_string($_POST['beschreibung'][$k]);
- $stichwort = $this->app->DB->real_escape_string($_POST['dateistichwort'][$k]);
-
- //$getMime = explode('.', $name);
- //$mime = end($getMime);
-
- $data = explode(',', $v);
-
- $encodedData = str_replace(' ','+',$data[1]);
- $decodedData = base64_decode($encodedData);
-
- $this->app->Tpl->Set('TITLE', $titel);
- $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung);
-
- if ($v == "" ) {
- $this->app->Tpl->Set('ERROR', "Keine Datei ausgewählt!
");
- $this->app->erp->EnableTab("tabs-2");
- } else {
- $fileid = $this->app->erp->CreateDatei($name, $titel, $beschreibung, "", $decodedData, $this->app->User->GetName());
-
- // stichwoerter hinzufuegen
- $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter);
- }
- }
- if($_FILES['upload']['tmp_name'] == "")
- {
- header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:''));
- }
+ if($parameter == '') {
+ $parameter = $id;
}
-
-
-
- $titel = $this->app->Secure->GetPOST("titel");
- $beschreibung = $this->app->Secure->GetPOST("beschreibung");
- $stichwort = $this->app->Secure->GetPOST("stichwort");
- $this->app->Tpl->Set('TITLE', $titel);
- $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung);
-
- if ($_FILES['upload']['tmp_name'] == "" && empty($_POST['dateiv'])) {
- $this->app->Tpl->Set('ERROR', "Keine Datei ausgewählt!
");
- $this->app->erp->EnableTab("tabs-2");
- } elseif($_FILES['upload']['tmp_name'] != '') {
- $fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'], $titel, $beschreibung, "", $_FILES['upload']['tmp_name'], $this->app->User->GetName());
-
- // stichwoerter hinzufuegen
- $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter);
- header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:''));
+ $retval = $this->FilesFromUploadtoDMS($objekt, $parameter);
+ if ($retval !== true) {
+ $this->app->Tpl->Set('ERROR', implode(', ',$retval));
+ $this->app->erp->EnableTab("tabs-2");
+ } else {
+ header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:''));
}
}
@@ -14551,6 +14502,87 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
}
}
+ /*
+ * Retrieve uploaded files and put them into DMS
+ * $datei: given file, just add a new version
+ * Return array of errors or true
+ */
+ function FilesFromUploadtoDMS($objekt, $parameter, $datei = false) {
+
+ $retval = true;
+ // Files come from drag'n'drop
+ if(isset($_POST['dateiv']))
+ {
+ foreach($_POST['dateiv'] as $k => $v)
+ {
+ $name = $this->app->DB->real_escape_string($_POST['dateiname'][$k]);
+ $titel = $this->app->DB->real_escape_string($_POST['dateititel'][$k]);
+ $beschreibung = $this->app->DB->real_escape_string($_POST['dateibeschreibung'][$k]);
+ $stichwort = $this->app->DB->real_escape_string($_POST['dateistichwort'][$k]);
+
+ $data = explode(',', $v);
+
+ $encodedData = str_replace(' ','+',$data[1]);
+ $decodedData = base64_decode($encodedData);
+
+ $this->app->Tpl->Set('TITLE', $titel);
+ $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung);
+
+ if ($v == "" ) {
+ $this->app->Tpl->Set('ERROR', "Keine Datei ausgewählt!
");
+ $this->app->erp->EnableTab("tabs-2");
+ } else {
+ // Save file to disk first
+ $tempfilename = rtrim($this->app->erp->GetTMP(), '/') . "/" . $name;
+ if($handle = fopen($tempfilename, "wb")){
+ fwrite($handle, $decodedData);
+ fclose($handle);
+ // Add file to DMS
+ if ($datei) {
+ $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $name, "Neue Version", $tempfilename);
+ } else {
+ $fileid = $this->app->erp->CreateDatei($name, $titel, $beschreibung, "", $tempfilename, $this->app->User->GetName());
+ // stichwoerter hinzufuegen
+ $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter);
+ }
+ } else {
+ if ($retval === true) {
+ $retval = array();
+ }
+ $retval[] = "Datei konnte nicht gespeichert werden: ".$name."
";
+ }
+ }
+ }
+ } // drag'n'drop
+ // Single file comes from browse button
+ else {
+ $titel = $this->app->Secure->GetPOST("titel");
+ $beschreibung = $this->app->Secure->GetPOST("beschreibung");
+ $stichwort = $this->app->Secure->GetPOST("stichwort");
+ $this->app->Tpl->Set('TITLE', $titel);
+ $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung);
+
+ if ($_FILES['upload']['tmp_name'] == "" && empty($_POST['dateiv'])) {
+ $this->app->erp->EnableTab("tabs-2");
+ if ($retval === true) {
+ $retval = array();
+ }
+ $retval[] = "Keine Datei ausgewählt!
";
+
+ } elseif ($_FILES['upload']['tmp_name'] != '') {
+ if ($datei) {
+ $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $_FILES['upload']['name'], "Neue Version", $_FILES['upload']['tmp_name']);
+ }
+ else {
+ $fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'], $titel, $beschreibung, "", $_FILES['upload']['tmp_name'], $this->app->User->GetName());
+ // stichwoerter hinzufuegen
+ $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter);
+ }
+ }
+ }
+ return($retval);
+ }
+
function SortListAdd($parsetarget, &$ref, $menu, $sql, $sort = true) {
$module = $this->app->Secure->GetGET("module");
diff --git a/www/pages/content/datei_neudirekt.tpl b/www/pages/content/datei_neudirekt.tpl
index f7200905..3321a05d 100644
--- a/www/pages/content/datei_neudirekt.tpl
+++ b/www/pages/content/datei_neudirekt.tpl
@@ -11,7 +11,7 @@
[ERROR]
-
+
{|Dateien hier einfügen|}
@@ -333,8 +333,8 @@ $(document).ready(function() {
}
}
- $('#trdatei').before(' Datei '+vorschau+' '+filenameEncoded+'Titel: '+$('#stichwort').html()+' ');
- };
+ $('#trdatei').before(' Datei '+vorschau+' '+filenameEncoded+' Titel: {|Beschreibung|}: '+$('#stichwort').html()+' ');
+ };
})(files[index]);
fileReader.readAsDataURL(file);
From f95918647a37595203d7ed3fc78119f28003a7bf Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 13 Jun 2024 15:51:30 +0200
Subject: [PATCH 22/87] reworked shop configuration fields and mapping
---
www/pages/shopimporter_mirakl.php | 192 ++++++++++++------------------
www/widgets/widget.shopexport.php | 5 +-
2 files changed, 77 insertions(+), 120 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 5d5ddadf..48537af5 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -7,34 +7,6 @@
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
*/
-
-/*
-
-JSON example for field_map
-
-{
- "katalogkonfiguration": {
- "kategorie": {"feld": "freifeld_Kategorie"}
- },
- "angebotskonfiguration":
- [
- {
- "felder": {
- "product_id_type": {"wert": "SHOP_SKU"},
- "product_id": {"feld": "nummer"},
- "shop_sku": {"feld": "nummer"},
- "price": {"feld": "preis"},
- "description": "freifeld_Kategorie",
- "internal_description": {"eigenschaft": "Mirakl Steuertext"},
- "reversecharge": {"wert": "false","zusatzfeld": true},
- "warehouse": {"wert": "1","zusatzfeld": true},
- "quantity": {"feld": "anzahl_lager"}
- }
- }
- ]
-}
-*/
-
class Shopimporter_Mirakl extends ShopimporterBase {
private $app;
@@ -54,13 +26,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $taxationByDestinationCountry;
private $orderSearchLimit;
- private $category_identifier_source;
- private $category_identifier_source_field;
- private $product_identifier_type;
- private $product_identifier_source;
- private $product_identifier_source_field;
- private $product_field_map;
- private $field_map;
+ private $category_identifier;
+
+ private $offer_field_map;
public function __construct($app, $intern = false) {
$this->app = $app;
@@ -70,11 +38,11 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
/*
- * See widget.shopexport.php
+ * See widget.shopexport.php, ShowExtraeinstellungen()
*/
public function EinstellungenStruktur() {
- return [
+ $einstellungen = [
'ausblenden' => ['abholmodus' => ['ab_nummer', 'zeitbereich']],
'functions' => ['getarticlelist'],
'felder' => [
@@ -82,14 +50,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'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|}:',
@@ -106,75 +66,61 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'size' => 40,
'info' => 'optional, int64'
],
-/* 'category_identifier_source' => [
+ 'category_identifier_source' => [
'typ' => 'select',
- 'bezeichnung' => '{|Kategorie-Identifizierer|}:',
+ 'bezeichnung' => '{|Katalogkategorie-Typ|}:',
'size' => 40,
- 'optionen' => ['Kategorie' => '{|Kategorie|}', 'Freifeld' => '{|Freifeld|}', 'Eigenschaft' => '{|Eigenschaft|}'],
- 'info' => 'Feld in OpenXE für die Zuordnung der Artikel zu den Katalogkategorien in Mirakl'
+ 'info' => 'Woher soll die Katalogkategorie des jeweiligen Artikels bezogen werden?',
+ 'default' => 'feld',
+ 'optionen' => ['feld' => '{|Feld|}', 'freifeld' => '{|Freifeld|}', 'eigenschaft' => '{|Eigenschaft|}', 'wert' => '{|Fester Wert|}']
],
- 'category_identifier_source_field' => [
+ 'category_identifier_source_value' => [
'typ' => 'text',
- 'bezeichnung' => '{|Kategorie-Identifizierer Freifeld oder Eigenschaft|}:',
+ 'bezeichnung' => '{|Katalogkategorie-Wert|}:',
'size' => 40,
- 'info' => 'Wenn oben Freifeld oder Eigenschaft gewählt wurde'
+ 'info' => '',
+ 'default' => 'kategoriename'
],
- 'product_field_map' => [
- 'typ' => 'textarea',
- 'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
- 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Mögliche Zuordnungen aus OpenXE sind: Artikelnummer, Artikelname, Einheit, Hersteller, Herstellernummer, EAN oder eine konkrete Artikeleigenschaft'
- ],*/
- 'field_map' => [
+ 'offer_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Angebots-Felder je Kategorie (JSON)|}:',
- 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Zuordnung über "Mirakl-xyz": {"feld": "xyz"} oder kurz "Mirakl-xyz": "xyz" Mögliche Zuordnungen aus OpenXE sind: nummer, name_de, einheit, hersteller, herstellernummer, ean u.v.m. Freifelder wie im Reiter Freifelder mit Präfix \'freifeld_\', Eigenschaften: {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: {"wert": "xyz"}, Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. {"feld": "name_de", "zusatzfeld": true}'
+ 'cols' => 80,
+ 'rows' => 20,
+ 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Ist keine Kategorie definiert, gilt der Eintrag für alle Artikel. Jedes Feld kann wie folgt zugeordnet werden: Artikelfeld: "Mirakel-Feldname": {"feld": "xyz"} oder kurz "Mirakel-Feldname": "xyz", Freifeld: "Mirakel-Feldname": {"freifeld": "Bezeichnung in Shop"} (Siehe Reiter "Freifelder"), Eigenschaft: "Mirakel-Feldname": {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: "Mirakel-Feldname": {"wert": "xyz"} Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. "Mirakel-Feldname": {"feld": "name_de", "zusatzfeld": true}',
+ 'placeholder' => '[
+ {
+ "kategorien": [
+ "Schuhe", "Hosen"
+ ],
+ "felder": {
+ "product_id_type": {"wert": "SHOP_SKU"},
+ "product_id": {"feld": "nummer"},
+ "shop_sku": {"feld": "nummer"},
+ "price": {"feld": "preis"},
+ "description": {"freifeld": "Kategorie"},
+ "internal_description": {"eigenschaft": "Mirakl Steuertext"},
+ "reversecharge": {"wert": "false","zusatzfeld": true},
+ "warehouse": {"wert": "1","zusatzfeld": true},
+ "quantity": {"feld": "anzahl_lager"}
+ }
+ }
+]'
],
- /*
- '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
- ], */
+ 'Artikelfelder' => [
+ 'heading' => 'Zusatzinformationen',
+ 'typ' => 'info',
+ 'text' => 'Folgende Artikelfelder stehen zur Verfügung:',
+ 'bezeichnung' => null,
+ 'info' => 'artikel, artikelid, nummer, inaktiv, name_de, name_en, einheit, hersteller, herstellernummer, ean, artikelnummer_fremdnummern, kurztext_de, kurztext_en, anabregs_text, anabregs_text_en, beschreibung_de, beschreibung_en, uebersicht_de, uebersicht_en, herkunftsland, texteuebertragen, metadescription_de, metadescription_en, metakeywords_de, metakeywords_en, metatitle_de, metatitle_en, links_de, altersfreigabe, links_en, startseite_de, startseite_en, restmenge, startseite, standardbild, herstellerlink, lieferzeit, lieferzeitmanuell, gewicht, laenge, breite, hoehe, wichtig, porto, gesperrt, sperrgrund, gueltigbis, umsatzsteuer, ausverkauft, variante, variante_von_id, variantevon, pseudopreis, keinrabatterlaubt, einkaufspreis, pseudolager, downloadartikel, zolltarifnummer, freifeld_Kategorie, typ, kategoriename, steuer_art_produkt, steuer_art_produkt_download, anzahl_bilder, anzahl_lager, lagerkorrekturwert, autolagerlampe, waehrung, preis, steuersatz, bruttopreis, checksum, variantevorhanden'
+ ]
]
];
+
+ return($einstellungen);
}
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");
@@ -197,13 +143,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$query = sprintf('SELECT `steuerfreilieferlandexport` FROM `shopexport` WHERE `id` = %d', $this->shopid);
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
- $this->category_identifier_source = $einstellungen['felder']['category_identifier_source'];
- $this->category_identifier_source_field = $einstellungen['felder']['category_identifier_source_field'];
- $this->product_identifier_type = $einstellungen['felder']['product_identifier_type'];
- $this->product_identifier_source = $einstellungen['felder']['product_identifier_source'];
- $this->product_identifier_source_field = $einstellungen['felder']['product_identifier_source_field'];
- $this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true);
- $this->field_map = json_decode($einstellungen['felder']['field_map'], true);
+ $this->category_identifier = array($einstellungen['felder']['category_identifier_source'] => $einstellungen['felder']['category_identifier_source_value']);
+
+ $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
}
private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false) {
@@ -310,7 +252,18 @@ class Shopimporter_Mirakl extends ShopimporterBase {
foreach ($field_map_entry as $key => $value) {
switch ($key) {
case 'feld':
- return($article[$value]);
+ if (isset($article[$value])) {
+ return($article[$value]);
+ } else {
+ throw new Exception("Artikelfeld existiert nicht: \"".$value."\"");
+ }
+ break;
+ case 'freifeld':
+ if (isset($article['freifelder']['DE'][$value])) {
+ return($article['freifelder']['DE'][$value]);
+ } else {
+ throw new Exception("Freifeld existiert nicht: \"".$value."\"");
+ }
break;
case 'eigenschaft':
$sql = "SELECT wert FROM artikeleigenschaften ae INNER JOIN artikeleigenschaftenwerte aew ON aew.artikeleigenschaften = ae.id WHERE aew.artikel = '".$article['artikelid']."' AND ae.name = '".$value."' LIMIT 1";
@@ -320,7 +273,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
return($value);
break;
}
- }
+ }
return(null);
}
@@ -350,23 +303,25 @@ class Shopimporter_Mirakl extends ShopimporterBase {
/*
* Export offer
*/
- $processed = false;
+ $category_found = false;
$additional_fields = array();
$offer_for_mirakl = array(
'state_code' => '11', // ?!?!
'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
);
-
- foreach ($this->field_map['angebotskonfiguration'] as $offer_field_entry) {
- $kategorie = $this->GetFieldValue($article, $this->field_map['katalogkonfiguration']['kategorie']);
+ $kategorie = $this->GetFieldValue($article, $this->category_identifier);
+
+ foreach ($this->offer_field_map as $offer_field_entry) {
if ($offer_field_entry['kategorien'] != null) {
if (!in_array($kategorie,$offer_field_entry['kategorien'])) {
continue;
}
- }
-
+ }
+
+ $category_found = true;
+
// Check Required attributes
$required = [
'product_id_type',
@@ -405,12 +360,11 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$offer_for_mirakl[$offer_field] = $offer_field_value;
}
}
- $processed = true;
}
- if (!$processed) {
- return(array('status' => false, 'message' => "Angebotskonfiguration für Kategorie \"".$kategorie."\" nicht gefunden"));
- }
+ if (!$category_found) {
+ return(array('status' => false, 'message' => "Angebotskonfiguration für Artikel ".$article['nummer'].", Kategorie \"".$kategorie."\" nicht gefunden"));
+ }
if (!empty($additional_fields)) {
$offer_for_mirakl['offer_additional_fields'] = $additional_fields;
diff --git a/www/widgets/widget.shopexport.php b/www/widgets/widget.shopexport.php
index 0e6b8ed1..d2ab80d0 100644
--- a/www/widgets/widget.shopexport.php
+++ b/www/widgets/widget.shopexport.php
@@ -861,7 +861,7 @@ class WidgetShopexport extends WidgetGenShopexport
switch($typ)
{
case 'textarea':
- $aktcol .= ''.(!isset($json['felder'][$name])?'':htmlspecialchars($json['felder'][$name])).' ';
+ $aktcol .= ''.(!isset($json['felder'][$name])?'':htmlspecialchars($json['felder'][$name])).' ';
break;
case 'checkbox':
$aktcol .= ' ';
@@ -894,6 +894,9 @@ class WidgetShopexport extends WidgetGenShopexport
}
}
break;
+ case 'info':
+ $aktcol .= $val['text'];
+ break;
default:
switch($typ) {
case 'datum':
From b06e0aa3e404bf4468550571ed330f020701d414 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 15 Jun 2024 18:52:46 +0200
Subject: [PATCH 23/87] mirakl create product initial
---
www/pages/shopimporter_mirakl.php | 170 +++++++++++++++++++++++++++---
1 file changed, 157 insertions(+), 13 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 48537af5..2f369bd6 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -29,6 +29,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $category_identifier;
private $offer_field_map;
+ private $product_field_map;
public function __construct($app, $intern = false) {
$this->app = $app;
@@ -81,6 +82,31 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'info' => '',
'default' => 'kategoriename'
],
+ 'product_field_map' => [
+ 'typ' => 'textarea',
+ 'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
+ 'cols' => 80,
+ 'rows' => 20,
+ 'info' => 'Die Felder werden vom Mirakl-Betreiber vorgegeben. Ist keine Kategorie definiert, gilt der Eintrag für alle Artikel. Jedes Feld kann wie folgt zugeordnet werden: Artikelfeld: "Mirakel-Feldname": {"feld": "xyz"} oder kurz "Mirakel-Feldname": "xyz", Freifeld: "Mirakel-Feldname": {"freifeld": "Bezeichnung in Shop"} (Siehe Reiter "Freifelder"), Eigenschaft: "Mirakel-Feldname": {"eigenschaft": "Eigenschaftenname xyz"}, Fester Wert: "Mirakel-Feldname": {"wert": "xyz"} Zusatzfelder zusätzlich mit der Eigenschaft "zusatzfeld": true versehen: z.B. "Mirakel-Feldname": {"feld": "name_de", "zusatzfeld": true}',
+ 'placeholder' => '[
+ {
+ "kategorien": [
+ "Schuhe", "Hosen"
+ ],
+ "felder": {
+ "category": {"freifeld": "Kategorie"},
+ "Product.SellerProductID": {"feld": "nummer"},
+ "SHOP.PRODUCT.TITLE": {"feld": "nummer"},
+ "ATT.GLOBAL.Brandname": {"feld": "preis"},
+ "Product.BaseUnit": {"freifeld": "Kategorie"},
+ "ATT.GLOBAL.NoCUperOU": {"eigenschaft": "Mirakl Steuertext"},
+ "ATT.GLOBAL.NoCUperOU__UNIT": {"wert": "false","zusatzfeld": true},
+ "Product.TaxIndicator": {"wert": "1","zusatzfeld": true}
+ }
+ }
+]'
+ ],
+
'offer_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Angebots-Felder je Kategorie (JSON)|}:',
@@ -145,10 +171,11 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->category_identifier = array($einstellungen['felder']['category_identifier_source'] => $einstellungen['felder']['category_identifier_source_value']);
- $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
+ $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
+ $this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true, flags: JSON_THROW_ON_ERROR);
}
- private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false) {
+ private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false, $debug = false, $debugurl = null) {
$ch = curl_init();
$url_addition = "";
@@ -171,10 +198,17 @@ class Shopimporter_Mirakl extends ShopimporterBase {
if (!empty($postdata)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+
$headers[] = 'Content-Type: ' . $content_type;
}
- curl_setopt($ch, CURLOPT_URL, $this->shopUrl . $endpoint . $url_addition);
+ if ($debugurl) {
+ $url = $debugurl;
+ } else {
+ $url = $this->shopUrl;
+ }
+
+ curl_setopt($ch, CURLOPT_URL, $url . $endpoint . $url_addition);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
@@ -187,11 +221,12 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$information = curl_getinfo($ch);
-/* print_r($information);
- print_r($postdata);
- print_r($response);
- exit();
-*/
+ if ($debug) {
+ print_r($information);
+ print_r($postdata);
+ print_r($response);
+ exit();
+ }
if ($raw)
return $response;
@@ -287,6 +322,8 @@ class Shopimporter_Mirakl extends ShopimporterBase {
public function ImportSendList() {
$articleList = $this->CatchRemoteCommand('data');
+
+ $this->Log('ImportSendList start', print_r($articleList,true));
// First gather all articles as offers and send them
// Wait for import to finish
@@ -378,12 +415,15 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$json_for_mirakl = json_encode($data_for_mirakl);
+ $this->Log('posting offer data', $json_for_mirakl);
+
$result = [];
$response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
$result = json_decode($response);
if (!isset($result->import_id)) {
+ $this->Log('posting offer data error', print_r($response,true));
return(array('status' => false, 'message' => "Angebotsimport in Mirakl abgelehnt: ".print_r($response,true)));
}
@@ -405,16 +445,120 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
if ($status == 'FAILED') {
+ $this->Log('importing of offer data failed in mirakl', print_r($response,true));
return(array('status' => false, 'message' => "Angebotsimport in Mirakl fehlgeschlagen: ".print_r($response,true)));
}
-
+
if ($result->lines_in_error == 0) {
+ $this->Log('importing of offer data ok', print_r($response,true));
return($result->lines_in_success);
}
- // Check errors
- $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
- return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler: ".print_r($response,true)));
+ $this->Log('importing of offer returned with '.$result->lines_in_error.' lines', print_r($response,true));
+
+ $result = array();
+ // Check errors with CSV unfucking...
+ $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
+ $response_lines = preg_split('/\R/', $response, flags: PREG_SPLIT_NO_EMPTY);
+
+ $error_message_key = null;
+ $firstline = true;
+
+ foreach ($response_lines as $response_line) {
+
+ $response_array = str_getcsv($response_line,';','"');
+
+ if ($firstline) {
+ $error_message_key = array_search("error-message",$response_array);
+ $firstline = false;
+ continue;
+ }
+
+ switch ($response_array[$error_message_key]) {
+ case 'The product does not exist':
+
+ // Try to create the product
+ $product_for_mirakl = array();
+
+ print_r($this->product_field_map);
+
+ foreach ($this->product_field_map as $product_field_entry) {
+ foreach ($product_field_entry['felder'] as $product_field => $product_field_source) {
+ if (!is_array($product_field_source)) {
+ $product_field_source = array('feld' => $product_field_source);
+ }
+ $product_field_value = null;
+ $product_field_value = $this->GetFieldValue($article, $product_field_source);
+ $product_for_mirakl[$product_field] = $product_field_value;
+ }
+ }
+
+ $this->Log('creating product', print_r($product_for_mirakl,true));
+
+ // Create CSV from array
+ $csv1 .= '"'.implode('";"',array_keys($product_for_mirakl)).'"';
+ $csv2 .= '"'.implode('";"',$product_for_mirakl).'"';
+ $csv = $csv1."\r\n".$csv2;
+
+ $result = [];
+
+ $this->Log('creating product csv', print_r($csv,true));
+
+ $postdata = array('file' => new CURLStringFile(postname: 'import.csv', data: $csv));
+
+ $response = $this->miraklRequest('products/imports', postdata: $postdata, content_type: 'multipart/form-data', raw: true);
+
+ $result = json_decode($response);
+
+ $this->Log('posting product data posted', print_r($result,true));
+
+ if (!isset($result->import_id)) {
+ $this->Log('posting product data error', print_r($response,true));
+ return(array('status' => false, 'message' => "Produktimport in Mirakl abgelehnt: ".print_r($response,true)));
+ }
+
+ $import_id = $result->import_id;
+
+ // Wait for import to finish
+
+ $status = null;
+
+ /*
+ WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
+ */
+
+ while ($status != 'COMPLETE' && $status != 'FAILED') {
+ sleep(5);
+ $response = $this->miraklRequest('products/imports/'.$import_id, raw: true);
+ $result = json_decode($response);
+ $status = $result->import_status;
+ }
+
+ if ($status == 'FAILED') {
+ $this->Log('importing of product data failed in mirakl', print_r($response,true));
+ return(array('status' => false, 'message' => "Produktimport in Mirakl fehlgeschlagen: ".print_r($response,true)));
+ }
+
+ if ($result->transform_lines_in_error == 0) {
+ $this->Log('importing of product data ok', print_r($response,true));
+ return($result->lines_in_success);
+ }
+
+ $this->Log('importing of product returned with '.$result->transform_lines_in_error.' error lines', print_r($response,true));
+
+ $response = $this->miraklRequest('products/imports/'.$import_id.'/transformation_error_report', raw: true);
+
+ $this->Log('product import error report', print_r($response,true));
+
+
+ break;
+ default:
+ $result[] = array('Unhandled error' => $response_array);
+ break;
+ }
+ }
+
+ return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler: ".print_r($result,true)));
}
@@ -424,7 +568,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private function Log($message, $dump = '') {
if ($this->protocol) {
- $this->app->erp->Logfile($message, print_r($dump, true));
+ $this->app->erp->Logfile('Mirakl (Shop '.$this->shopid.') '.$message, print_r($dump, true));
}
}
From bb4538498af0fb4c05face8bbb5e8e7ac3b475df Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 17 Jun 2024 13:09:30 +0200
Subject: [PATCH 24/87] mirakl reworked logging and functions
---
www/pages/shopimporter_mirakl.php | 657 +++++++++++++++++++-----------
1 file changed, 420 insertions(+), 237 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 2f369bd6..08ecd777 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -28,6 +28,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $category_identifier;
+ private $create_products;
+ private $mirakl_error_text_product_missing;
+
private $offer_field_map;
private $product_field_map;
@@ -82,6 +85,19 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'info' => '',
'default' => 'kategoriename'
],
+ 'create_products' => [
+ 'typ' => 'checkbox',
+ 'bezeichnung' => '{|Produkte anlegen|}:',
+ 'size' => 40,
+ 'info' => 'Produkte automatisch anlegen wenn sie nicht existieren'
+ ],
+ 'mirakl_error_text_product_missing' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Fehlertext Produkt fehlt|}:',
+ 'size' => 40,
+ 'info' => 'Der Fehlertext der anzeigt dass das Produkt nicht existiert (Angebotsimport, Fehlerbericht)',
+ 'default' => 'The product does not exist'
+ ],
'product_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
@@ -171,8 +187,12 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->category_identifier = array($einstellungen['felder']['category_identifier_source'] => $einstellungen['felder']['category_identifier_source_value']);
- $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
- $this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true, flags: JSON_THROW_ON_ERROR);
+ $this->create_products = $einstellungen['felder']['create_products'];
+ $this->mirakl_error_text_product_missing = $einstellungen['felder']['mirakl_error_text_product_missing'];
+
+ $this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
+ $this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true, flags: JSON_THROW_ON_ERROR);
+
}
private function miraklRequest(string $endpoint, $postdata = null, array $getdata = null, string $content_type = null, bool $raw = false, $debug = false, $debugurl = null) {
@@ -322,243 +342,49 @@ class Shopimporter_Mirakl extends ShopimporterBase {
public function ImportSendList() {
$articleList = $this->CatchRemoteCommand('data');
-
- $this->Log('ImportSendList start', print_r($articleList,true));
-
- // First gather all articles as offers and send them
- // Wait for import to finish
- // Evaluate import
-
- // Unimplemented (needed?)
- // Select offers with no product
- // Create products and send
- // Wait for import to finish
- // Evaluate import
-
- foreach ($articleList as $article) {
-
- /*
- * Export offer
- */
- $category_found = false;
- $additional_fields = array();
-
- $offer_for_mirakl = array(
- 'state_code' => '11', // ?!?!
- 'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
- );
-
- $kategorie = $this->GetFieldValue($article, $this->category_identifier);
-
- foreach ($this->offer_field_map as $offer_field_entry) {
- if ($offer_field_entry['kategorien'] != null) {
- if (!in_array($kategorie,$offer_field_entry['kategorien'])) {
- continue;
- }
- }
-
- $category_found = true;
-
- // Check Required attributes
- $required = [
- 'product_id_type',
- 'product_id',
- 'shop_sku',
- 'price'
- ];
- $missing = null;
- foreach ($required as $key) {
- if (!isset($offer_field_entry['felder'][$key])) {
- $missing[] = $key;
- }
- }
- if ($missing) {
- return(array('status' => false, 'message' => "Pflichtfelder fehlen in Angebotskonfiguration von Kategorie \"".$offer_field_entry['kategorie']."\": ".implode(', ',$missing)));
- }
- // Check Required attributes
-
- foreach ($offer_field_entry['felder'] as $offer_field => $offer_field_source) {
- if (!is_array($offer_field_source)) {
- $offer_field_source = array('feld' => $offer_field_source);
- }
- $offer_field_value = null;
- $is_additional_field = false;
- $offer_field_value = $this->GetFieldValue($article, $offer_field_source);
- if (in_array('zusatzfeld', $offer_field_source)) {
- $is_additional_field = true;
- }
- if ($is_additional_field) {
- $additional_field = array (
- "code" => $offer_field,
- "value" => $offer_field_value
- );
- $additional_fields[] = $additional_field;
- } else {
- $offer_for_mirakl[$offer_field] = $offer_field_value;
- }
- }
- }
-
- if (!$category_found) {
- return(array('status' => false, 'message' => "Angebotskonfiguration für Artikel ".$article['nummer'].", Kategorie \"".$kategorie."\" nicht gefunden"));
- }
-
- if (!empty($additional_fields)) {
- $offer_for_mirakl['offer_additional_fields'] = $additional_fields;
- }
-
- $offers_for_mirakl[] = $offer_for_mirakl;
- }
-
- $data_for_mirakl = array();
- $data_for_mirakl['offers'] = $offers_for_mirakl;
-
- $json_for_mirakl = json_encode($data_for_mirakl);
-
- $this->Log('posting offer data', $json_for_mirakl);
-
- $result = [];
- $response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
-
- $result = json_decode($response);
-
- if (!isset($result->import_id)) {
- $this->Log('posting offer data error', print_r($response,true));
- return(array('status' => false, 'message' => "Angebotsimport in Mirakl abgelehnt: ".print_r($response,true)));
- }
-
- $import_id = $result->import_id;
-
- // Wait for import to finish
-
- $status = null;
-
- /*
- WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
- */
-
- while ($status != 'COMPLETE' && $status != 'FAILED') {
- sleep(5);
- $response = $this->miraklRequest('offers/imports/'.$import_id, raw: true);
- $result = json_decode($response);
- $status = $result->status;
- }
-
- if ($status == 'FAILED') {
- $this->Log('importing of offer data failed in mirakl', print_r($response,true));
- return(array('status' => false, 'message' => "Angebotsimport in Mirakl fehlgeschlagen: ".print_r($response,true)));
- }
-
- if ($result->lines_in_error == 0) {
- $this->Log('importing of offer data ok', print_r($response,true));
- return($result->lines_in_success);
- }
-
- $this->Log('importing of offer returned with '.$result->lines_in_error.' lines', print_r($response,true));
-
- $result = array();
- // Check errors with CSV unfucking...
- $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
- $response_lines = preg_split('/\R/', $response, flags: PREG_SPLIT_NO_EMPTY);
-
- $error_message_key = null;
- $firstline = true;
-
- foreach ($response_lines as $response_line) {
-
- $response_array = str_getcsv($response_line,';','"');
-
- if ($firstline) {
- $error_message_key = array_search("error-message",$response_array);
- $firstline = false;
- continue;
- }
-
- switch ($response_array[$error_message_key]) {
- case 'The product does not exist':
-
- // Try to create the product
- $product_for_mirakl = array();
-
- print_r($this->product_field_map);
-
- foreach ($this->product_field_map as $product_field_entry) {
- foreach ($product_field_entry['felder'] as $product_field => $product_field_source) {
- if (!is_array($product_field_source)) {
- $product_field_source = array('feld' => $product_field_source);
- }
- $product_field_value = null;
- $product_field_value = $this->GetFieldValue($article, $product_field_source);
- $product_for_mirakl[$product_field] = $product_field_value;
- }
- }
-
- $this->Log('creating product', print_r($product_for_mirakl,true));
-
- // Create CSV from array
- $csv1 .= '"'.implode('";"',array_keys($product_for_mirakl)).'"';
- $csv2 .= '"'.implode('";"',$product_for_mirakl).'"';
- $csv = $csv1."\r\n".$csv2;
-
- $result = [];
-
- $this->Log('creating product csv', print_r($csv,true));
-
- $postdata = array('file' => new CURLStringFile(postname: 'import.csv', data: $csv));
-
- $response = $this->miraklRequest('products/imports', postdata: $postdata, content_type: 'multipart/form-data', raw: true);
-
- $result = json_decode($response);
-
- $this->Log('posting product data posted', print_r($result,true));
-
- if (!isset($result->import_id)) {
- $this->Log('posting product data error', print_r($response,true));
- return(array('status' => false, 'message' => "Produktimport in Mirakl abgelehnt: ".print_r($response,true)));
- }
-
- $import_id = $result->import_id;
-
- // Wait for import to finish
-
- $status = null;
-
- /*
- WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
- */
-
- while ($status != 'COMPLETE' && $status != 'FAILED') {
- sleep(5);
- $response = $this->miraklRequest('products/imports/'.$import_id, raw: true);
- $result = json_decode($response);
- $status = $result->import_status;
- }
-
- if ($status == 'FAILED') {
- $this->Log('importing of product data failed in mirakl', print_r($response,true));
- return(array('status' => false, 'message' => "Produktimport in Mirakl fehlgeschlagen: ".print_r($response,true)));
- }
-
- if ($result->transform_lines_in_error == 0) {
- $this->Log('importing of product data ok', print_r($response,true));
- return($result->lines_in_success);
- }
-
- $this->Log('importing of product returned with '.$result->transform_lines_in_error.' error lines', print_r($response,true));
-
- $response = $this->miraklRequest('products/imports/'.$import_id.'/transformation_error_report', raw: true);
-
- $this->Log('product import error report', print_r($response,true));
-
-
- break;
- default:
- $result[] = array('Unhandled error' => $response_array);
- break;
- }
+
+ $offer_export_result = $this->mirakl_export_offers($articleList);
+
+ if ($offer_export_result['returncode'] == 0) {
+ return(array('status' => true, 'message' => "Angebotsimport in Mirakl ok"));
}
- return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler: ".print_r($result,true)));
+ // Check for missing products and try to create
+ if ($this->create_products) {
+
+ $create_products_list = array();
+
+ foreach ($offer_export_result['articleList'] as $key => $article) {
+ if ($article['mirakl_export_offers_result']['returncode'] == 12) {
+ switch ($article['mirakl_export_offers_result']['message']) {
+ case $this->mirakl_error_text_product_missing:
+ $create_products_list[] = $article;
+ break;
+ }
+ }
+ }
+
+ if (empty($create_products_list)) {
+ return(array('status' => false, 'message' => "Produktimport nicht möglich"));
+ }
+
+ $create_products_result = $this->mirakl_create_products($create_products_list);
+
+ if ($create_products_result['returncode'] != 0) {
+ $this->Log("Produktimport in Mirakl hat Fehler", print_r($create_products_result, true));
+ return(array('status' => false, 'message' => "Produktimport in Mirakl hat Fehler"));
+ }
+
+ // Retry offer import
+ $offer_export_result = $this->mirakl_export_offers($articleList);
+ if ($offer_export_result['returncode'] == 0) {
+ return(array('status' => true, 'message' => "Angebots und Produktimport in Mirakl ok"));
+ }
+ }
+
+ $this->Log("Angebotsimport in Mirakl hat Fehler", print_r($offer_export_result, true));
+
+ return(array('status' => false, 'message' => "Angebotsimport in Mirakl hat Fehler"));
}
@@ -587,5 +413,362 @@ class Shopimporter_Mirakl extends ShopimporterBase {
public function ImportGetAuftrag() {
}
+
+ /*
+ * Send offer data to mirakl
+ * $articleList = $this->CatchRemoteCommand('data');
+ * Return
+ * array (returncode, message, articleList) articleList with added mirakl_export_offers_result element (array (returncode, message)) for further processing (e.g. create product)
+ * returncode 0 = ok, 1 = not ok
+ * returncode articleList 0 = ok, 10 = missing required attributes, 11 category not found, 12 rejected from mirakl
+ */
+ private function mirakl_export_offers(array $articleList) : array {
+
+ $mirakl_export_offers_return_value = array();
+ $mirakl_export_offers_return_value['returncode'] = 0;
+ $mirakl_export_offers_return_value['articleList'] = array();
+
+ $this->Log('Angebotsexport start', print_r($articleList,true));
+
+ // First gather all articles as offers and send them
+ // Wait for import to finish
+ // Evaluate import
+
+ foreach ($articleList as $key => $article) {
+
+ $skip_article = false;
+
+ /*
+ * Export offer
+ */
+ $category_found = false;
+ $additional_fields = array();
+
+ $offer_for_mirakl = array(
+ 'state_code' => '11', // ?!?!
+ 'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
+ );
+
+ $kategorie = $this->GetFieldValue($article, $this->category_identifier);
+
+ foreach ($this->offer_field_map as $offer_field_entry) {
+ if ($offer_field_entry['kategorien'] != null) {
+ if (!in_array($kategorie,$offer_field_entry['kategorien'])) {
+ continue;
+ }
+ }
+
+ $category_found = true;
+
+ // Check required attributes
+ $required = [
+ 'product_id_type',
+ 'product_id',
+ 'shop_sku',
+ 'price'
+ ];
+ $missing = null;
+ foreach ($required as $key) {
+ if (!isset($offer_field_entry['felder'][$key])) {
+ $missing[] = $key;
+ }
+ }
+ if ($missing) {
+ $mirakl_export_offers_return_value['returncode'] = 1;
+ $article['mirakl_export_offers_result'] = array('returncode' => 10, 'message' => "Pflichtfelder fehlen in Angebotskonfiguration von Kategorie \"".$offer_field_entry['kategorie']."\": ".implode(', ',$missing));
+ $mirakl_export_offers_return_value['articleList'][] = $article;
+ $skip_article = true;
+ }
+ // Check Required attributes
+
+ foreach ($offer_field_entry['felder'] as $offer_field => $offer_field_source) {
+ if (!is_array($offer_field_source)) {
+ $offer_field_source = array('feld' => $offer_field_source);
+ }
+ $offer_field_value = null;
+ $is_additional_field = false;
+ $offer_field_value = $this->GetFieldValue($article, $offer_field_source);
+ if (in_array('zusatzfeld', $offer_field_source)) {
+ $is_additional_field = true;
+ }
+ if ($is_additional_field) {
+ $additional_field = array (
+ "code" => $offer_field,
+ "value" => $offer_field_value
+ );
+ $additional_fields[] = $additional_field;
+ } else {
+ $offer_for_mirakl[$offer_field] = $offer_field_value;
+ }
+ }
+ }
+
+ if ($skip_article) {
+ continue;
+ }
+
+ if (!$category_found) {
+ $mirakl_export_offers_return_value['returncode'] = 1;
+ $article['mirakl_export_offers_result'] = array('returncode' => 11, 'message' => "Angebotskonfiguration für Artikel ".$article['nummer'].", Kategorie \"".$kategorie."\" nicht gefunden");
+ $mirakl_export_offers_return_value['articleList'][] = $article;
+ continue;
+ }
+
+ if (!empty($additional_fields)) {
+ $offer_for_mirakl['offer_additional_fields'] = $additional_fields;
+ }
+
+ $offers_for_mirakl[] = $offer_for_mirakl;
+
+ $article['mirakl_export_offers_result'] = array('returncode' => 0, 'message' => "");
+ $mirakl_export_offers_return_value['articleList'][] = $article;
+
+ }
+
+ if (empty($offers_for_mirakl)) {
+ $mirakl_export_offers_return_value['returncode'] = 1;
+ $this->Log('Angebotsexport keine Artikel bereit', $mirakl_export_offers_return_value);
+ $mirakl_export_offers_return_value['message'] = "Angebotsexport keine Artikel bereit";
+ return($mirakl_export_offers_return_value);
+ }
+
+ $data_for_mirakl = array();
+ $data_for_mirakl['offers'] = $offers_for_mirakl;
+
+ $json_for_mirakl = json_encode($data_for_mirakl);
+
+ $this->Log('Angebotsexport Daten', $json_for_mirakl);
+
+ $result = [];
+ $response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
+
+ $result = json_decode($response);
+
+ if (!isset($result->import_id)) {
+ $mirakl_export_offers_return_value['returncode'] = 1;
+ $this->Log('Angebotsimport abgelehnt', print_r($response,true));
+ $mirakl_export_offers_return_value['message'] = "Angebotsimport abgelehnt: ".print_r($response,true);
+ return($mirakl_export_offers_return_value);
+ }
+
+ $this->Log('Angebotsimport angelegt', print_r($response,true));
+
+ $import_id = $result->import_id;
+
+ // Wait for import to finish
+
+ $status = null;
+
+ /*
+ WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
+ */
+
+ while ($status != 'COMPLETE' && $status != 'FAILED') {
+ sleep(5);
+ $response = $this->miraklRequest('offers/imports/'.$import_id, raw: true);
+ $result = json_decode($response);
+ $status = $result->status;
+ }
+
+ if ($status == 'FAILED') {
+ $this->Log('Angebotsimport fehlgeschlagen', print_r($response,true));
+
+ $mirakl_export_offers_return_value['returncode'] = 2;
+ $mirakl_export_offers_return_value['message'] = "Angebotsimport fehlgeschlagen: ".print_r($response,true);
+ return($mirakl_export_offers_return_value);
+ }
+
+ if ($result->lines_in_error == 0) {
+ $this->Log('Angebotsimport ok', print_r($response,true));
+ return($mirakl_export_offers_return_value);
+ }
+
+ $this->Log('Angebotsimport meldet Fehler in '.$result->lines_in_error.' Zeilen', print_r($response,true));
+
+ $result = array();
+ // Check errors with CSV unfucking...
+ $response = $this->miraklRequest('offers/imports/'.$import_id.'/error_report', raw: true);
+ $response_lines = preg_split('/\R/', $response, flags: PREG_SPLIT_NO_EMPTY);
+
+ $error_message_key = null;
+ $firstline = true;
+
+ foreach ($response_lines as $key => $response_line) {
+ $response_array = str_getcsv($response_line,';','"');
+ if ($firstline) {
+ $error_message_key = array_search("error-message",$response_array);
+ $firstline = false;
+ continue;
+ }
+
+ $article_key = array_search(
+ $response_array['product_id'],
+ array_column(
+ $mirakl_export_offers_return_value['articleList'],
+ 'product_id')
+ );
+
+ $mirakl_export_offers_return_value['articleList'][$article_key]['mirakl_export_offers_result'] = array('returncode' => 12, 'message' => $response_array[$error_message_key]);
+ }
+
+ $this->Log('Angebotsimport Fehlerbericht', print_r($response,true));
+
+ $mirakl_export_offers_return_value['returncode'] = 1;
+
+ return($mirakl_export_offers_return_value);
+ }
+
+ /*
+ * Create products
+ * Return
+ * array (returncode, message, articleList) articleList with added mirakl_export_offers_result element (array (returncode, message)) for further processing (e.g. create product)
+ * returncode 0 = ok, 1 = not ok
+ * returncode articleList 0 = ok, 20 rejected from mirakl
+ */
+ private function mirakl_create_products(array $articleList) : array {
+
+ $mirakl_create_products_return_value = array();
+ $mirakl_create_products_return_value['returncode'] = 0;
+ $mirakl_create_products_return_value['articleList'] = $articleList;
+
+ // Build CSV
+ $csv_header = "";
+ $newline = "";
+ foreach ($articleList as $article) {
+
+ // Try to create the product
+ $product_for_mirakl = array();
+ foreach ($this->product_field_map as $product_field_entry) {
+ foreach ($product_field_entry['felder'] as $product_field => $product_field_source) {
+ if (!is_array($product_field_source)) {
+ $product_field_source = array('feld' => $product_field_source);
+ }
+ $product_field_value = null;
+ $product_field_value = $this->GetFieldValue($article, $product_field_source);
+ $product_for_mirakl[$product_field] = $product_field_value;
+ }
+ }
+
+ // Create CSV from array
+ if (empty($csv_header)) {
+ $csv_header .= '"'.implode('";"',array_keys($product_for_mirakl)).'"';
+ }
+ $csv .= $newline.'"'.implode('";"',$product_for_mirakl).'"';
+ $newline = "\r\n";
+ }
+
+ $csv = $csv_header.$newline.$csv;
+
+ $result = [];
+
+ $this->Log('Produktexport Daten', print_r($csv,true));
+
+ $postdata = array('file' => new CURLStringFile(postname: 'import.csv', data: $csv));
+
+ $response = $this->miraklRequest('products/imports', postdata: $postdata, content_type: 'multipart/form-data', raw: true);
+
+ $result = json_decode($response);
+
+ if (!isset($result->import_id)) {
+ $this->Log('Produktimport abgelehnt', print_r($response,true));
+ $mirakl_create_products_return_value['returncode'] = 1;
+ return($mirakl_create_products_return_value);
+ }
+
+ $this->Log('Produktimport angelegt', print_r($result,true));
+
+ $import_id = $result->import_id;
+
+ // Wait for import to finish
+
+ $status = null;
+
+ /*
+ WAITING_SYNCHRONIZATION_PRODUCT, WAITING, RUNNING, COMPLETE, FAILED
+ */
+
+ while ($status != 'COMPLETE' && $status != 'FAILED') {
+ sleep(5);
+ $response = $this->miraklRequest('products/imports/'.$import_id, raw: true);
+ $result = json_decode($response);
+ $status = $result->import_status;
+ }
+
+ if ($status == 'FAILED') {
+ $this->Log('Produktimport fehlgeschlagen', print_r($response,true));
+ $mirakl_create_products_return_value['returncode'] = 1;
+ return($mirakl_create_products_return_value);
+ }
+
+ if (!$result->has_error_report && !$result->has_transformation_error_report) {
+ $this->Log('Produktimport ok', print_r($response,true));
+ } else {
+ $this->Log('Produktimport meldet Fehler', print_r($response,true));
+ $mirakl_create_products_return_value['returncode'] = 1;
+ }
+
+ if ($result->has_new_product_report) {
+ $response = $this->miraklRequest('products/imports/'.$import_id.'/new_product_report', raw: true);
+ $this->Log('Produktimport "Hinzugefügte Produkte"-Bericht', print_r($response,true));
+ }
+
+ if ($result->has_transformed_file) {
+ $response = $this->miraklRequest('products/imports/'.$import_id.'/transformed_file', raw: true);
+ $this->Log('Produktimport Datei im Marketplace-Format', print_r($response,true));
+ }
+
+ if ($result->has_error_report) {
+ // Check errors with CSV unfucking...
+ $response = $this->miraklRequest('products/imports/'.$import_id.'/error_report', raw: true);
+ $response_lines = preg_split('/\R/', $response, flags: PREG_SPLIT_NO_EMPTY);
+ $error_message_key = null;
+ $firstline = true;
+ foreach ($response_lines as $key => $response_line) {
+ $response_array = str_getcsv($response_line,';','"');
+ if ($firstline) {
+ $error_message_key = array_search("ERRORS",$response_array);
+ $firstline = false;
+ continue;
+ }
+ $article_key = array_search(
+ $response_array['product_id'],
+ array_column(
+ $mirakl_create_products_return_value['articleList'],
+ 'product_id')
+ );
+
+ $mirakl_create_products_return_value['articleList'][$article_key]['mirakl_create_products_result'] = array('returncode' => 13, 'message' => $response_array[$error_message_key]);
+ }
+ $this->Log('Produktimport Fehlerbericht', print_r($response,true));
+ }
+
+ if ($result->has_transformation_error_report) {
+ // Check errors with CSV unfucking...
+ $response = $this->miraklRequest('products/imports/'.$import_id.'/transformation_error_report', raw: true);
+ $response_lines = preg_split('/\R/', $response, flags: PREG_SPLIT_NO_EMPTY);
+ $error_message_key = null;
+ $firstline = true;
+ foreach ($response_lines as $key => $response_line) {
+ $response_array = str_getcsv($response_line,';','"');
+ if ($firstline) {
+ $error_message_key = array_search("errors",$response_array);
+ $firstline = false;
+ continue;
+ }
+ $article_key = array_search(
+ $response_array['product_id'],
+ array_column(
+ $mirakl_create_products_return_value['articleList'],
+ 'product_id')
+ );
+
+ $mirakl_create_products_return_value['articleList'][$article_key]['mirakl_create_products_result'] = array('returncode' => 14, 'message' => $response_array[$error_message_key]);
+ }
+ $this->Log('Produktimport Transformation-Fehlerbericht', print_r($response,true));
+ }
+
+ return($mirakl_create_products_return_value);
+ }
+
}
From 9b3950e3aa6aa70b4f7ba1e2ec925392fa9b51d0 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 18 Jun 2024 15:18:45 +0200
Subject: [PATCH 25/87] shopimport ajax submit vs. submit
---
www/widgets/templates/_gen/shopexport.tpl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/widgets/templates/_gen/shopexport.tpl b/www/widgets/templates/_gen/shopexport.tpl
index fab71180..782b78e2 100644
--- a/www/widgets/templates/_gen/shopexport.tpl
+++ b/www/widgets/templates/_gen/shopexport.tpl
@@ -115,7 +115,7 @@
{|Aktion|}
From 471bceb06010d1d4f74ab1726d53df3eb22319d4 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 18 Jun 2024 15:19:19 +0200
Subject: [PATCH 26/87] mirakl fetch orders
---
www/pages/shopimporter_mirakl.php | 156 ++++++++++++++++++++++++++----
1 file changed, 137 insertions(+), 19 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 08ecd777..07650835 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -16,8 +16,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $apiKey;
private $shopUrl;
private $mirakl_shopid;
- private $createManufacturerAllowed = false;
- private $idsabholen;
private $idbearbeitung;
private $idabgeschlossen;
public $data;
@@ -31,6 +29,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $create_products;
private $mirakl_error_text_product_missing;
+ private $normalTaxId;
+ private $reducedTaxId;
+
private $offer_field_map;
private $product_field_map;
@@ -98,6 +99,16 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'info' => 'Der Fehlertext der anzeigt dass das Produkt nicht existiert (Angebotsimport, Fehlerbericht)',
'default' => 'The product does not exist'
],
+ 'normalTaxId' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|TaxId für Steuersatz "normal"|}',
+ 'size' => 40,
+ ],
+ 'reducedTaxId' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|TaxId für Steuersatz "ermäßigt"|}',
+ 'size' => 40,
+ ],
'product_field_map' => [
'typ' => 'textarea',
'bezeichnung' => '{|Zuordnung Produkt-Felder je Kategorie (JSON)|}:',
@@ -175,21 +186,15 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->apiKey = $einstellungen['felder']['apikey'];
$this->shopUrl = rtrim($einstellungen['felder']['shopurl'], '/') . '/';
$this->mirakl_shopid = $einstellungen['felder']['mirakl_shopid'];
-
- 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));
-
+
$this->category_identifier = array($einstellungen['felder']['category_identifier_source'] => $einstellungen['felder']['category_identifier_source_value']);
$this->create_products = $einstellungen['felder']['create_products'];
$this->mirakl_error_text_product_missing = $einstellungen['felder']['mirakl_error_text_product_missing'];
+ $this->normalTaxId = $einstellungen['felder']['normalTaxId'];
+ $this->reducedTaxId = $einstellungen['felder']['reducedTaxId'];
+
$this->offer_field_map = json_decode($einstellungen['felder']['offer_field_map'], true, flags: JSON_THROW_ON_ERROR);
$this->product_field_map = json_decode($einstellungen['felder']['product_field_map'], true, flags: JSON_THROW_ON_ERROR);
@@ -245,7 +250,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
print_r($information);
print_r($postdata);
print_r($response);
- exit();
}
if ($raw)
@@ -261,7 +265,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($code == 200) {
- return 'success ' . print_r($response, true);
+ return 'success';
}
return $response;
}
@@ -389,7 +393,8 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
private function getOrdersToProcess(int $limit) {
-
+ echo("getOrdersToProcess");
+ exit();
}
private function Log($message, $dump = '') {
@@ -399,19 +404,132 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
public function ImportDeleteAuftrag() {
-
+ echo("ImportDeleteAuftrag");
+ exit();
}
public function ImportUpdateAuftrag() {
-
+ echo("ImportUpdateAuftrag");
+ exit();
}
- public function ImportGetAuftraegeAnzahl() {
-
+ // STAGING, WAITING_ACCEPTANCE, WAITING_DEBIT, WAITING_DEBIT_PAYMENT, SHIPPING, SHIPPED, TO_COLLECT, RECEIVED, CLOSED, REFUSED, CANCELED
+ public function ImportGetAuftraegeAnzahl() {
+ $response = $this->miraklRequest('orders', getdata: array('order_state_codes' => 'WAITING_ACCEPTANCE'), raw: true);
+ $this->Log('ImportGetAuftraegeAnzahl', print_r($response,true));
+ $result_array = json_decode($response);
+ return($result_array->total_count);
}
public function ImportGetAuftrag() {
+
+ $parameters = array('order_state_codes' => 'WAITING_ACCEPTANCE');
+
+ if(!empty($this->data['nummer'])) {
+ $parameters['order_ids'] = $this->data['nummer'];
+ }
+
+ $response = $this->miraklRequest('orders', getdata: $parameters, raw: true);
+ $this->Log('ImportGetAuftraegeAnzahl', print_r($response,true));
+ $result_array = json_decode($response);
+
+ $fetchedOrders = [];
+ foreach ($result_array->orders as $order) {
+ $cart = [];
+ $cart['zeitstempel'] = strval($order->created_date);
+
+ $cart['auftrag'] = strval($order->order_id);
+ $cart['onlinebestellnummer'] = strval($order->commercial_id);
+ $cart['gesamtsumme'] = strval($order->total_price);
+
+ $cart['bestelldatum'] = strval($order->created_date);
+
+ $cart['lieferung'] = strval($order->shipping_type_code);
+
+ $cart['email'] = strval($order->customer_notification_email);
+
+ $cart['kunde_sprache'] = '?';
+ $cart['kundennummer'] = $order->customer->customer_id;
+
+ $cart['name'] = ($order->customer->civility?$order->customer->civility." ":"").$order->customer->firstname." ".$order->customer->lastname;
+ if (!empty(strval($order->customer->company))) {
+ $cart['ansprechpartner'] = $cart['name'];
+ $cart['name'] = strval($order->customer->company);
+ }
+ $cart['strasse'] = strval($order->customer->billing_address->street_1);
+ $cart['adresszusatz'] = strval($order->customer->billing_address->street_2);
+ $cart['telefon'] = strval($order->customer->billing_address->phone);
+ $cart['plz'] = strval($order->customer->billing_address->zip_code);
+ $cart['ort'] = strval($order->customer->billing_address->city);
+
+ $cart['ustid'] = '?';
+ $cart['land'] = strval($order->customer->billing_address->country_iso_code);
+
+ $cart['abweichendelieferadresse'] = 1;
+ $cart['lieferadresse_name'] = ($order->customer->shipping_address->civility?$order->customer->shipping_address->civility." ":"").$order->customer->shipping_address->firstname." ".$order->customer->shipping_address->lastname;
+ if (!empty(strval($order->customer->shipping_address->company))) {
+ $cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name'];
+ $cart['lieferadresse_name'] = strval($deliveryAddress->company);
+ }
+ $cart['lieferadresse_strasse'] = strval($order->customer->shipping_address->street_1);
+ $cart['lieferadresse_adresszusatz'] = strval($order->customer->shipping_address->street_2);
+ $cart['lieferadresse_telefon'] = strval($order->customer->shipping_address->phone);
+ $cart['lieferadresse_plz'] = strval($order->customer->shipping_address->zip_code);
+ $cart['lieferadresse_ort'] = strval($order->customer->shipping_address->city);
+
+ $cart['zahlungsweise'] = strval($order->payment_type);
+
+ $cart['ust_befreit'] = '?'; // 1, 2
+
+ $cart['steuersatz_normal'] = '?';//strval($order->taxes[0]->amount);
+ $cart['steuersatz_ermaessigt'] = '?'; // strval($order->taxes[0]->amount);
+
+ $cart['articlelist'] = [];
+
+ $shipping_tax_amount = 0;
+
+ foreach ($order->order_lines as $order_row) {
+
+ $steuersatz = '?';
+
+ switch ($order->row->taxes[0]->code) {
+ case $this->normalTaxId:
+ $steuersatz = 'normal';
+ break;
+ case $this->reducedTaxId:
+ $steuersatz = 'ermaessigt';
+ break;
+ }
+
+ $article = [
+ 'articleid' => strval($order_row->offer_sku),
+ 'name' => strval($order_row->product_title),
+ 'quantity' => strval($order_row->quantity),
+ 'price_netto' => strval($order_row->price_unit),
+ 'steuersatz' => $steuersatz
+ ];
+
+ foreach ($order_row->shipping_taxes as $shipment_tax) {
+ $shipping_tax_amount += $shipment_tax->amount;
+ }
+ $cart['articlelist'][] = $article;
+ } // foreach articles
+
+ $cart['versandkostennetto'] = strval($order->shipping_price);
+ $cart['versandkostenbrutto'] = $cart['versandkostennetto']+$shipping_tax_amount;
+
+ } // foreach orders
+
+ $fetchedOrders[] = [
+ 'id' => $cart['auftrag'],
+ 'sessionid' => $cart['onlinebestellnummer'],
+ 'logdatei' => '',
+ 'warenkorb' => base64_encode(serialize($cart)),
+ 'warenkorbjson' => base64_encode(json_encode($cart))
+ ];
+ $this->Log('Auftragsimport', $cart);
+ return $fetchedOrders;
}
/*
From 15c36925a22b1176cbe9e1258bd6c18c48018d23 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 19 Jun 2024 21:31:40 +0200
Subject: [PATCH 27/87] shopimport preview table
---
www/pages/shopimport.php | 19 +++++++++++-------
www/themes/new/images/lupe.svg | 36 ++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 7 deletions(-)
create mode 100644 www/themes/new/images/lupe.svg
diff --git a/www/pages/shopimport.php b/www/pages/shopimport.php
index 0a1112d1..171e0112 100644
--- a/www/pages/shopimport.php
+++ b/www/pages/shopimport.php
@@ -52,6 +52,7 @@ class Shopimport
$this->app->ActionHandler("list","ShopimportList");
$this->app->ActionHandler("alle","ShopimportAlle");
$this->app->ActionHandler("import","ShopimportImport");
+ $this->app->ActionHandler("view","ShopimportView");
$this->app->ActionHandler("einzelimport","ShopimportEinzelimport");
$this->app->ActionHandler("navigation","ShopimportNavigation");
$this->app->ActionHandler("logout","ShopimportLogout");
@@ -339,9 +340,9 @@ class Shopimport
$this->app->Tpl->Set('TAB1','Es läuft gerade ein Cronjob der Aufträge abholt. Die manuelle Auftragsabholung ist in dieser Zeit gesperrt. Bitte warten Sie ein paar Minuten und versuchen Sie es erneut.
');
}else{
$table = new EasyTable($this->app);
- $table->Query("SELECT ae.bezeichnung,p.abkuerzung,
+ $table->Query("SELECT ae.bezeichnung,p.abkuerzung as Projekt,
ae.id FROM shopexport ae LEFT JOIN projekt p ON p.id=ae.projekt WHERE ae.aktiv='1'");
- $table->DisplayNew('INHALT'," ");
+ $table->DisplayNew('INHALT'," ");
$this->app->Tpl->Parse('TAB1','rahmen.tpl');
}
$this->app->Tpl->Set('INHALT','');
@@ -949,6 +950,10 @@ class Shopimport
$bekanntezahlungsweisen = $this->app->erp->GetZahlungsweise();
$tmpauftragid = $this->app->erp->ImportAuftrag($adresse,$warenkorb,$projekt,$shopid);
+ if ($tmpauftragid > 0) {
+ $sucess_import = true;
+ }
+
$doctype = 'auftrag';
if($this->app->DB->Select("SELECT angeboteanlegen FROM shopexport WHERE id = '$shopid' LIMIT 1"))
{
@@ -971,7 +976,7 @@ class Shopimport
}
}
- if($shopimportid)
+ if($shopimportid && $tmpauftragid)
{
$this->app->DB->Update("UPDATE shopimport_auftraege SET imported='1' WHERE id='$shopimportid' LIMIT 1");
}
@@ -985,10 +990,7 @@ class Shopimport
}
$this->app->erp->RunHook('Shopimportwarenkorb', 4, $doctype, $tmpauftragid, $shopid, $warenkorb);
$this->app->erp->RunHook('Shopimport', 3, $doctype, $tmpauftragid, $shopid);
-
-
$adresse ='';
- $sucess_import++;
return $sucess_import;
}
@@ -1112,6 +1114,10 @@ class Shopimport
return ['codingerror'=>$umlautefehler, 'success' => $succes];
}
+ public function ShopimportView() {
+ $this->ShopimportImport(showonly: true);
+ }
+
public function ShopimportImport($id='', $count = 0, $returncount = false, $showonly = false)
{
$deletedRows = 0;
@@ -2002,7 +2008,6 @@ class Shopimport
$htmltable->AddCol(' ');
$htmltable->AddCol($arr[$i]['abkuerzung']);
-
$htmltable->AddCol(($doppelteonlinebestellnummer?'':'').$warenkorb['onlinebestellnummer'].($doppelteonlinebestellnummer?' ':''));
$htmltable->AddCol($warenkorb['name'].$kdr_name.' '.$warenkorb['email'].$email);
$htmltable->AddCol($warenkorb['internebezeichnung']);
diff --git a/www/themes/new/images/lupe.svg b/www/themes/new/images/lupe.svg
new file mode 100644
index 00000000..ef5adf6b
--- /dev/null
+++ b/www/themes/new/images/lupe.svg
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4b7f3e19e7ef804cf719ebb1aaa5bbc00e592753 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 19 Jun 2024 21:33:05 +0200
Subject: [PATCH 28/87] erpapi ImportAuftrag abort with logfile if porto is not
defined
---
www/lib/class.erpapi.php | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index b855b0f3..ab84107f 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -18809,16 +18809,23 @@ function CheckShopTabelle($artikel)
$artikelporto = $artikelportoermaessigt;
}
- if(empty($artikelporto) && $this->app->DB->Select("SELECT portoartikelanlegen FROM shopexport WHERE id = '$shop' LIMIT 1"))
- {
- if($warenkorb['versandkostennetto'] != 0 || $warenkorb['versandkostenbrutto'] != 0 || $portocheck == 1){
- $portoartikelarr = array('projekt'=>$projekt,'porto'=>1, 'lagerartikel'=>0,'name_de'=>'Porto','umsatzsteuer'=>'normal');
- $artikelporto = $this->app->erp->InsertUpdateArtikel($portoartikelarr);
- if($artikelporto){
- $this->app->DB->Update("UPDATE shopexport SET artikelporto = '$artikelporto' WHERE id = '$shop' AND artikelporto = 0 LIMIT 1");
- }
+ if(empty($artikelporto)) {
+ if ($this->app->DB->Select("SELECT portoartikelanlegen FROM shopexport WHERE id = '$shop' LIMIT 1"))
+ {
+ if($warenkorb['versandkostennetto'] != 0 || $warenkorb['versandkostenbrutto'] != 0 || $portocheck == 1)
+ {
+ $portoartikelarr = array('projekt'=>$projekt,'porto'=>1, 'lagerartikel'=>0,'name_de'=>'Porto','umsatzsteuer'=>'normal');
+ $artikelporto = $this->app->erp->InsertUpdateArtikel($portoartikelarr);
+ if($artikelporto)
+ {
+ $this->app->DB->Update("UPDATE shopexport SET artikelporto = '$artikelporto' WHERE id = '$shop' AND artikelporto = 0 LIMIT 1");
+ }
+ }
+ } else {
+ $this->LogFile('Importauftrag Shop '.$shop.' Fehler: Kein Portoartikel vorhanden',['Onlinebestellnummer' => $warenkorb['onlinebestellnummer']]);
+ return(null);
+ }
}
- }
$umsatzsteuer_porto = $this->app->DB->Select("SELECT umsatzsteuer FROM artikel WHERE id='$artikelporto' LIMIT 1");
$versandname = '';
From 04daacb227e7e98a254c2d796096b10360851c09 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 19 Jun 2024 21:33:49 +0200
Subject: [PATCH 29/87] mirakl importauftrag steuer, iso3 country code
---
www/pages/shopimporter_mirakl.php | 56 +++++++++++++++++++------------
1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 07650835..6fbb810e 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -430,7 +430,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
}
$response = $this->miraklRequest('orders', getdata: $parameters, raw: true);
- $this->Log('ImportGetAuftraegeAnzahl', print_r($response,true));
+ $this->Log('ImportGetAuftrag', print_r($response,true));
$result_array = json_decode($response);
$fetchedOrders = [];
@@ -448,7 +448,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['email'] = strval($order->customer_notification_email);
- $cart['kunde_sprache'] = '?';
+// $cart['kunde_sprache'] = '?';
$cart['kundennummer'] = $order->customer->customer_id;
$cart['name'] = ($order->customer->civility?$order->customer->civility." ":"").$order->customer->firstname." ".$order->customer->lastname;
@@ -462,10 +462,15 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['plz'] = strval($order->customer->billing_address->zip_code);
$cart['ort'] = strval($order->customer->billing_address->city);
- $cart['ustid'] = '?';
- $cart['land'] = strval($order->customer->billing_address->country_iso_code);
+// $cart['ustid'] = '?';
+ $sql = "SELECT iso FROM laender WHERE iso3 = '".$order->customer->billing_address->country_iso_code."'";
+ $cart['land'] = $this->app->DB->Select($sql);
$cart['abweichendelieferadresse'] = 1;
+
+ $sql = "SELECT iso FROM laender WHERE iso3 = '".$order->customer->shipping_address->country_iso_code."'";
+ $cart['lieferadresse_land'] = $this->app->DB->Select($sql);
+
$cart['lieferadresse_name'] = ($order->customer->shipping_address->civility?$order->customer->shipping_address->civility." ":"").$order->customer->shipping_address->firstname." ".$order->customer->shipping_address->lastname;
if (!empty(strval($order->customer->shipping_address->company))) {
$cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name'];
@@ -479,34 +484,43 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['zahlungsweise'] = strval($order->payment_type);
- $cart['ust_befreit'] = '?'; // 1, 2
+ $cart['waehrung'] = strval($order->currency_iso_code);
- $cart['steuersatz_normal'] = '?';//strval($order->taxes[0]->amount);
- $cart['steuersatz_ermaessigt'] = '?'; // strval($order->taxes[0]->amount);
+// $cart['ust_befreit'] = '?'; // 1, 2
- $cart['articlelist'] = [];
+// $cart['steuersatz_normal'] = 19;//strval($order->taxes[0]->amount);
+// $cart['steuersatz_ermaessigt'] 07; // strval($order->taxes[0]->amount);
+
+ $cart['articlelist'] = [];
+
$shipping_tax_amount = 0;
foreach ($order->order_lines as $order_row) {
- $steuersatz = '?';
-
- switch ($order->row->taxes[0]->code) {
- case $this->normalTaxId:
- $steuersatz = 'normal';
- break;
- case $this->reducedTaxId:
- $steuersatz = 'ermaessigt';
- break;
+ $steuersatz = 0;
+ $umsatzsteuer_typ = 'normal';
+ foreach($order_row->taxes as $tax) {
+ if($tax->rate > $steuersatz) {
+ $steuersatz = $tax->rate;
+ }
+ switch ($order->row->taxes[0]->code) {
+ case $this->reducedTaxId:
+ $umsatzsteuer_typ = 'ermaessigt';
+ break;
+ default:
+ case $this->normalTaxId:
+ $umsatzsteuer_typ = 'normal';
+ break;
+ }
}
$article = [
'articleid' => strval($order_row->offer_sku),
- 'name' => strval($order_row->product_title),
+// 'name' => strval($order_row->product_title),
'quantity' => strval($order_row->quantity),
'price_netto' => strval($order_row->price_unit),
- 'steuersatz' => $steuersatz
+ 'umsatzsteuer' => $steuersatz
];
foreach ($order_row->shipping_taxes as $shipment_tax) {
@@ -515,8 +529,8 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['articlelist'][] = $article;
} // foreach articles
- $cart['versandkostennetto'] = strval($order->shipping_price);
- $cart['versandkostenbrutto'] = $cart['versandkostennetto']+$shipping_tax_amount;
+ $cart['versandkostennetto'] = round(strval($order->shipping_price),2);
+ $cart['versandkostenbrutto'] = round($cart['versandkostennetto']+$shipping_tax_amount,2);
} // foreach orders
From 610ed35218c424e3f56e1f7492354c30c5bee24a Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 20 Jun 2024 14:18:20 +0200
Subject: [PATCH 30/87] shopimport improvements
---
www/lib/class.erpapi.php | 9 +-
www/pages/shopimport.php | 3623 ++++++++++++++---------------
www/pages/shopimporter_mirakl.php | 9 +-
3 files changed, 1713 insertions(+), 1928 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index ab84107f..a3a5128c 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -17334,7 +17334,7 @@ function CheckShopTabelle($artikel)
return $taxrates;
}
- function ImportAuftrag($adresse,$warenkorb,$projekt,$shop="",$auftrag=0)
+ function ImportAuftrag($adresse,$warenkorb,$projekt,$shop="",$auftrag=0) : array
{
$this->RunHook('ImportAuftragBefore',4, $adresse,$warenkorb,$projekt,$shop);
if(!empty($this->app->stringcleaner)){
@@ -18822,8 +18822,9 @@ function CheckShopTabelle($artikel)
}
}
} else {
- $this->LogFile('Importauftrag Shop '.$shop.' Fehler: Kein Portoartikel vorhanden',['Onlinebestellnummer' => $warenkorb['onlinebestellnummer']]);
- return(null);
+ $error_msg = 'Importauftrag Shop '.$shop.' Fehler: Kein Portoartikel vorhanden';
+ $this->LogFile($error_msg,['Onlinebestellnummer' => $warenkorb['onlinebestellnummer']]);
+ return(array("status" => false, "message" => $error_msg, "onlinebestellnummer" => $warenkorb['onlinebestellnummer']));
}
}
$umsatzsteuer_porto = $this->app->DB->Select("SELECT umsatzsteuer FROM artikel WHERE id='$artikelporto' LIMIT 1");
@@ -19171,7 +19172,7 @@ function CheckShopTabelle($artikel)
}
}
- return $auftrag;
+ return array("status" => true, "$auftragid" => $auftrag);
}
diff --git a/www/pages/shopimport.php b/www/pages/shopimport.php
index 171e0112..30b681b1 100644
--- a/www/pages/shopimport.php
+++ b/www/pages/shopimport.php
@@ -1,4 +1,5 @@
app=$app;
- if($intern) {
- return;
- }
- $this->app->ActionHandlerInit($this);
+ const MODULE_NAME = 'Shopimport';
- $this->app->ActionHandler("login","ShopimportLogin");
- $this->app->ActionHandler("main","ShopimportMain");
- $this->app->ActionHandler("list","ShopimportList");
- $this->app->ActionHandler("alle","ShopimportAlle");
- $this->app->ActionHandler("import","ShopimportImport");
- $this->app->ActionHandler("view","ShopimportView");
- $this->app->ActionHandler("einzelimport","ShopimportEinzelimport");
- $this->app->ActionHandler("navigation","ShopimportNavigation");
- $this->app->ActionHandler("logout","ShopimportLogout");
- $this->app->ActionHandler("archiv","ShopimportArchiv");
+ public $javascript = [
+ './classes/Modules/Shopimport/www/js/shopimport.js'
+ ];
- $this->app->DefaultActionHandler("list");
+ /**
+ * Shopimport constructor.
+ *
+ * @param Application $app
+ * @param bool $intern
+ */
+ public function __construct($app, $intern = false) {
+ $this->app = $app;
+ if ($intern) {
+ return;
+ }
+ $this->app->ActionHandlerInit($this);
+ $this->app->ActionHandler("login", "ShopimportLogin");
+ $this->app->ActionHandler("main", "ShopimportMain");
+ $this->app->ActionHandler("list", "ShopimportList");
+ $this->app->ActionHandler("alle", "ShopimportAlle");
+ $this->app->ActionHandler("import", "ShopimportImport");
+ $this->app->ActionHandler("view", "ShopimportView");
+ $this->app->ActionHandler("einzelimport", "ShopimportEinzelimport");
+ $this->app->ActionHandler("navigation", "ShopimportNavigation");
+ $this->app->ActionHandler("logout", "ShopimportLogout");
+ $this->app->ActionHandler("archiv", "ShopimportArchiv");
- $this->app->Tpl->Set('UEBERSCHRIFT','Shop Import');
- $this->app->ActionHandlerListen($app);
- }
+ $this->app->DefaultActionHandler("list");
- /**
- * @param int $shopId
- * @param array $data
- *
- * @return int
- *
- * @throws Exception
- */
- public function Refund($shopId, $data)
- {
- if(empty($shopId)) {
- throw new Exception('no Shop given');
- }
- if(empty($data)) {
- throw new Exception('no Data given');
+ $this->app->Tpl->Set('UEBERSCHRIFT', 'Shop Import');
+ $this->app->ActionHandlerListen($app);
}
- $shop = $this->app->DB->SelectRow(
- sprintf(
- 'SELECT `aktiv`, `id`, `artikelrabatt` FROM `shopexport` WHERE `id` = %d',
- $shopId
- )
- );
- if(empty($shop)) {
- throw new Exception('Shop not found');
- }
- if(empty($shop['aktiv'])) {
- throw new Exception('Shop is not active');
- }
+ /**
+ * @param int $shopId
+ * @param array $data
+ *
+ * @return int
+ *
+ * @throws Exception
+ */
+ public function Refund($shopId, $data) {
+ if (empty($shopId)) {
+ throw new Exception('no Shop given');
+ }
+ if (empty($data)) {
+ throw new Exception('no Data given');
+ }
- if(!empty($data->extid)) {
- $order = $this->app->DB->SelectRow(
- sprintf(
- "SELECT *
+ $shop = $this->app->DB->SelectRow(
+ sprintf(
+ 'SELECT `aktiv`, `id`, `artikelrabatt` FROM `shopexport` WHERE `id` = %d',
+ $shopId
+ )
+ );
+ if (empty($shop)) {
+ throw new Exception('Shop not found');
+ }
+ if (empty($shop['aktiv'])) {
+ throw new Exception('Shop is not active');
+ }
+
+ if (!empty($data->extid)) {
+ $order = $this->app->DB->SelectRow(
+ sprintf(
+ "SELECT *
FROM `auftrag`
WHERE `shop` = %d AND `shopextid` = '%s' AND `shopextid` <> ''
AND `status` <> 'storniert'
LIMIT 1",
- $shopId, $this->app->DB->real_escape_string((string)$data->extid)
- )
- );
- }
- elseif(!empty($data->internet)) {
- $order = $this->app->DB->SelectRow(
- sprintf(
- "SELECT *
+ $shopId, $this->app->DB->real_escape_string((string) $data->extid)
+ )
+ );
+ } elseif (!empty($data->internet)) {
+ $order = $this->app->DB->SelectRow(
+ sprintf(
+ "SELECT *
FROM `auftrag`
WHERE `shop` = %d AND `internet` = '%s' AND `internet` <> ''
AND `status` <> 'storniert'
LIMIT 1",
- $shopId, $this->app->DB->real_escape_string((string)$data->extid)
- )
- );
- }
- else {
- throw new Exception('No order given');
- }
+ $shopId, $this->app->DB->real_escape_string((string) $data->extid)
+ )
+ );
+ } else {
+ throw new Exception('No order given');
+ }
- if(empty($order)) {
- throw new Exception('order not found');
- }
+ if (empty($order)) {
+ throw new Exception('order not found');
+ }
- $invoice = $this->app->DB->SelectRow(
- sprintf(
- "SELECT * FROM `rechnung` WHERE `auftragid` = %d ORDER BY `status` = 'storniert' LIMIT 1",
- $order['id']
- )
- );
+ $invoice = $this->app->DB->SelectRow(
+ sprintf(
+ "SELECT * FROM `rechnung` WHERE `auftragid` = %d ORDER BY `status` = 'storniert' LIMIT 1",
+ $order['id']
+ )
+ );
- if(empty($invoice)) {
- if(empty($data->createinvoice)){
- throw new Exception('order has no invoice');
- }
- $invoiceId = $this->app->erp->WeiterfuehrenAuftragZuRechnung($order['id']);
- $this->app->erp->AuftragProtokoll($order['id'], 'Rechnung erstellt durch Shop-Trigger');
- $this->app->erp->RechnungProtokoll($invoiceId, 'Rechnung erstellt durch Shop-Trigger');
- $this->app->erp->BelegFreigabe('rechnung', $invoiceId);
- $this->app->erp->RechnungNeuberechnen($invoiceId);
- $invoice = $this->app->DB->SelectRow(
- sprintf(
- "SELECT * FROM `rechnung` WHERE `auftragid` = %d ORDER BY `status` = 'storniert' LIMIT 1",
- $order['id']
- )
- );
- }
+ if (empty($invoice)) {
+ if (empty($data->createinvoice)) {
+ throw new Exception('order has no invoice');
+ }
+ $invoiceId = $this->app->erp->WeiterfuehrenAuftragZuRechnung($order['id']);
+ $this->app->erp->AuftragProtokoll($order['id'], 'Rechnung erstellt durch Shop-Trigger');
+ $this->app->erp->RechnungProtokoll($invoiceId, 'Rechnung erstellt durch Shop-Trigger');
+ $this->app->erp->BelegFreigabe('rechnung', $invoiceId);
+ $this->app->erp->RechnungNeuberechnen($invoiceId);
+ $invoice = $this->app->DB->SelectRow(
+ sprintf(
+ "SELECT * FROM `rechnung` WHERE `auftragid` = %d ORDER BY `status` = 'storniert' LIMIT 1",
+ $order['id']
+ )
+ );
+ }
- if($invoice['status'] === 'storniert') {
- throw new Exception('order invoice is already cancelled');
- }
- if(!empty($data->positions)) {
- $positions = $this->app->DB->SelectArr(
- sprintf(
- "SELECT `op`.webid, ip.artikel, ip.menge,ip.preis, ip.rabatt, ip.auftrag_position_id
+ if ($invoice['status'] === 'storniert') {
+ throw new Exception('order invoice is already cancelled');
+ }
+ if (!empty($data->positions)) {
+ $positions = $this->app->DB->SelectArr(
+ sprintf(
+ "SELECT `op`.webid, ip.artikel, ip.menge,ip.preis, ip.rabatt, ip.auftrag_position_id
FROM `rechnung_position` AS `ip`
INNER JOIN `auftrag_position` AS `op` ON ip.auftrag_position_id = op.id
WHERE `ip`.rechnung = %d",
- $invoice['id']
- )
- );
- if(empty($positions)) {
- throw new Exception('invoice has no positions');
- }
- $webIds = [];
- $foundWebIds = [];
- foreach($positions as $position) {
- if(!empty($position['webid'])) {
- $webIds[] = $position['webid'];
- }
- }
+ $invoice['id']
+ )
+ );
+ if (empty($positions)) {
+ throw new Exception('invoice has no positions');
+ }
+ $webIds = [];
+ $foundWebIds = [];
+ foreach ($positions as $position) {
+ if (!empty($position['webid'])) {
+ $webIds[] = $position['webid'];
+ }
+ }
- $webIdToPosition = [];
+ $webIdToPosition = [];
- foreach($data->positions as $position) {
- if(!empty($position->webid)){
- if(!in_array((string)$position->webid, $webIds)){
- throw new Exception(sprintf('position %s not found', (string)$position->webid));
- }
- $foundWebIds[] = (string)$position->webid;
- $webIdToPosition[$position->webid] = $position;
- }
- else {
- throw new Exception('no webId given');
- }
- }
+ foreach ($data->positions as $position) {
+ if (!empty($position->webid)) {
+ if (!in_array((string) $position->webid, $webIds)) {
+ throw new Exception(sprintf('position %s not found', (string) $position->webid));
+ }
+ $foundWebIds[] = (string) $position->webid;
+ $webIdToPosition[$position->webid] = $position;
+ } else {
+ throw new Exception('no webId given');
+ }
+ }
- if(empty($foundWebIds)) {
- throw new Exception('positions empty');
- }
+ if (empty($foundWebIds)) {
+ throw new Exception('positions empty');
+ }
- $toDeleteInvoicePositionIds = [0];
- foreach($positions as $position) {
- if(empty($position['webid']) || !in_array($position['webid'], $foundWebIds)) {
- $toDeleteInvoicePositionIds[] = (int)$position['auftrag_position_id'];
- }
- }
+ $toDeleteInvoicePositionIds = [0];
+ foreach ($positions as $position) {
+ if (empty($position['webid']) || !in_array($position['webid'], $foundWebIds)) {
+ $toDeleteInvoicePositionIds[] = (int) $position['auftrag_position_id'];
+ }
+ }
- $creditNoteId = $this->app->erp->WeiterfuehrenRechnungZuGutschrift($invoice['id']);
- $this->app->erp->RechnungProtokoll($invoice['id'], 'Rechnung durch Shop-Trigger storniert');
- $this->app->erp->GutschriftProtokoll($creditNoteId, 'Gutschrift durch Shop-Trigger angelegt');
- $this->app->erp->BelegFreigabe('gutschrift', $creditNoteId);
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM `gutschrift_position` WHERE `gutschrift` = %d AND `auftrag_position_id` IN (%s)",
- $creditNoteId, implode(',', $toDeleteInvoicePositionIds)
- )
- );
- $hasCreditNoteTax = !empty($this->app->erp->GutschriftMitUmsatzeuer($creditNoteId));
- $this->app->erp->GutschriftNeuberechnen($creditNoteId);
- $creditNote = $this->app->DB->SelectRow(
- sprintf(
- 'SELECT * FROM `gutschrift` WHERE `id` = %d',
- $creditNoteId
- )
- );
- $creditNotePositions = $this->app->DB->SelectArr(
- sprintf(
- "SELECT op.webid, cnp.id, cnp.menge, cnp.preis, cnp.rabatt, cnp.umsatzsteuer,
+ $creditNoteId = $this->app->erp->WeiterfuehrenRechnungZuGutschrift($invoice['id']);
+ $this->app->erp->RechnungProtokoll($invoice['id'], 'Rechnung durch Shop-Trigger storniert');
+ $this->app->erp->GutschriftProtokoll($creditNoteId, 'Gutschrift durch Shop-Trigger angelegt');
+ $this->app->erp->BelegFreigabe('gutschrift', $creditNoteId);
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM `gutschrift_position` WHERE `gutschrift` = %d AND `auftrag_position_id` IN (%s)",
+ $creditNoteId, implode(',', $toDeleteInvoicePositionIds)
+ )
+ );
+ $hasCreditNoteTax = !empty($this->app->erp->GutschriftMitUmsatzeuer($creditNoteId));
+ $this->app->erp->GutschriftNeuberechnen($creditNoteId);
+ $creditNote = $this->app->DB->SelectRow(
+ sprintf(
+ 'SELECT * FROM `gutschrift` WHERE `id` = %d',
+ $creditNoteId
+ )
+ );
+ $creditNotePositions = $this->app->DB->SelectArr(
+ sprintf(
+ "SELECT op.webid, cnp.id, cnp.menge, cnp.preis, cnp.rabatt, cnp.umsatzsteuer,
cnp.steuersatz
FROM `gutschrift_position` AS `cnp`
INNER JOIN `auftrag_position` AS `op` ON cnp.auftrag_position_id = op.id
WHERE cnp.gutschrift = %d",
- $creditNoteId
- )
- );
- foreach($creditNotePositions as $creditNotePosition) {
- if(isset($webIdToPosition[$creditNotePosition['webid']])) {
- $position = $webIdToPosition[$creditNotePosition['webid']];
- if(!empty($position->quantity)) {
- $this->app->DB->Update(
- sprintf(
- "UPDATE `gutschrift_position` SET `menge` = %f WHERE `id` = %d",
- (float)$position->quantity, $creditNotePosition['id']
- )
+ $creditNoteId
+ )
);
- }
- elseif(!empty($position->menge)) {
- $this->app->DB->Update(
- sprintf(
- "UPDATE `gutschrift_position` SET `menge` = %f WHERE `id` = %d",
- (float)$position->menge, $creditNotePosition['id']
- )
- );
- }
- $preis = null;
- if(isset($position->price)) {
- $preis = (float)$position->price;
- }
- elseif(isset($position->preis)) {
- $preis = (float)$position->preis;
- }
- elseif(isset($position->amount)) {
- $preis = (float)$position->amount;
- }
- if($preis !== null) {
- if($hasCreditNoteTax) {
- if($creditNotePosition['steuersatz'] !== null && $creditNotePosition['steuersatz'] >= 0) {
- $preis /= 1+ $creditNotePosition['steuersatz'] / 100;
- }
- elseif($creditNotePosition['umsatzsteuer'] === 'ermaessigt') {
- $preis /= 1+ $creditNote['steuersatz_ermaessigt'] / 100;
- }
- elseif($creditNotePosition['umsatzsteuer'] !== 'befreit') {
- $preis /= 1+ $creditNote['steuersatz_normal'] / 100;
- }
+ foreach ($creditNotePositions as $creditNotePosition) {
+ if (isset($webIdToPosition[$creditNotePosition['webid']])) {
+ $position = $webIdToPosition[$creditNotePosition['webid']];
+ if (!empty($position->quantity)) {
+ $this->app->DB->Update(
+ sprintf(
+ "UPDATE `gutschrift_position` SET `menge` = %f WHERE `id` = %d",
+ (float) $position->quantity, $creditNotePosition['id']
+ )
+ );
+ } elseif (!empty($position->menge)) {
+ $this->app->DB->Update(
+ sprintf(
+ "UPDATE `gutschrift_position` SET `menge` = %f WHERE `id` = %d",
+ (float) $position->menge, $creditNotePosition['id']
+ )
+ );
+ }
+ $preis = null;
+ if (isset($position->price)) {
+ $preis = (float) $position->price;
+ } elseif (isset($position->preis)) {
+ $preis = (float) $position->preis;
+ } elseif (isset($position->amount)) {
+ $preis = (float) $position->amount;
+ }
+ if ($preis !== null) {
+ if ($hasCreditNoteTax) {
+ if ($creditNotePosition['steuersatz'] !== null && $creditNotePosition['steuersatz'] >= 0) {
+ $preis /= 1 + $creditNotePosition['steuersatz'] / 100;
+ } elseif ($creditNotePosition['umsatzsteuer'] === 'ermaessigt') {
+ $preis /= 1 + $creditNote['steuersatz_ermaessigt'] / 100;
+ } elseif ($creditNotePosition['umsatzsteuer'] !== 'befreit') {
+ $preis /= 1 + $creditNote['steuersatz_normal'] / 100;
+ }
+ }
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE `gutschrift_position` SET `preis` = %f, `rabatt` = 0 WHERE `id` = %d',
+ $preis, $creditNotePosition['id']
+ )
+ );
+ }
+ }
}
- $this->app->DB->Update(
- sprintf(
- 'UPDATE `gutschrift_position` SET `preis` = %f, `rabatt` = 0 WHERE `id` = %d',
- $preis, $creditNotePosition['id']
- )
+
+ $this->app->erp->GutschriftNeuberechnen($creditNoteId);
+
+ if (!empty($data->amount)) {
+ $soll = $this->app->DB->Select(sprintf('SELECT `soll` FROM `gutschrift` WHERE `id` = %d', $creditNoteId));
+ $diff = round($soll, 2) - round((float) $data->amount, 2);
+ if ($diff == 0) {
+ return $creditNoteId;
+ }
+ $this->app->erp->AddPositionManuellPreis(
+ 'gutschrift', $creditNoteId, $shop['artikelrabatt'], 1, 'Differenz', -$diff, 'befreit', $invoice['waehrung']
+ );
+ }
+
+ return (int) $creditNoteId;
+ }
+ $creditNoteId = $this->app->erp->WeiterfuehrenRechnungZuGutschrift($invoice['id']);
+ $this->app->erp->RechnungProtokoll($invoice['id'], 'Rechnung durch Shop-Trigger storniert');
+ $this->app->erp->GutschriftProtokoll($creditNoteId, 'Gutschrift durch Shop-Trigger angelegt');
+ $this->app->erp->BelegFreigabe('gutschrift', $creditNoteId);
+ $this->app->erp->GutschriftNeuberechnen($creditNoteId);
+ if (!empty($data->amount)) {
+ $soll = $this->app->DB->Select(sprintf('SELECT `soll` FROM `gutschrift` WHERE `id` = %d', $creditNoteId));
+ $diff = round($soll, 2) - round((float) $data->amount, 2);
+ if ($diff == 0) {
+ return $creditNoteId;
+ }
+ $this->app->erp->AddPositionManuellPreis(
+ 'gutschrift', $creditNoteId, $shop['artikelrabatt'], 1, 'Differenz', -$diff, 'befreit', $invoice['waehrung']
);
- }
}
- }
- $this->app->erp->GutschriftNeuberechnen($creditNoteId);
+ return (int) $creditNoteId;
+ }
- if(!empty($data->amount)) {
- $soll = $this->app->DB->Select(sprintf('SELECT `soll` FROM `gutschrift` WHERE `id` = %d', $creditNoteId));
- $diff = round($soll,2) - round((float)$data->amount, 2);
- if($diff == 0) {
- return $creditNoteId;
+ public function ShopimportList() {
+ $msg = $this->app->Secure->GetGET('msg');
+ if (!empty($msg)) {
+ $msg = $this->app->erp->base64_url_decode($msg);
+ $this->app->Tpl->Set('MESSAGE', $msg);
}
- $this->app->erp->AddPositionManuellPreis(
- 'gutschrift', $creditNoteId, $shop['artikelrabatt'], 1, 'Differenz', -$diff,'befreit', $invoice['waehrung']
- );
- }
+ $this->app->erp->MenuEintrag('index.php?module=importvorlage&action=uebersicht', 'Zurück zur Übersicht');
- return (int)$creditNoteId;
- }
- $creditNoteId = $this->app->erp->WeiterfuehrenRechnungZuGutschrift($invoice['id']);
- $this->app->erp->RechnungProtokoll($invoice['id'], 'Rechnung durch Shop-Trigger storniert');
- $this->app->erp->GutschriftProtokoll($creditNoteId, 'Gutschrift durch Shop-Trigger angelegt');
- $this->app->erp->BelegFreigabe('gutschrift', $creditNoteId);
- $this->app->erp->GutschriftNeuberechnen($creditNoteId);
- if(!empty($data->amount)) {
- $soll = $this->app->DB->Select(sprintf('SELECT `soll` FROM `gutschrift` WHERE `id` = %d', $creditNoteId));
- $diff = round($soll,2) - round((float)$data->amount, 2);
- if($diff == 0) {
- return $creditNoteId;
- }
- $this->app->erp->AddPositionManuellPreis(
- 'gutschrift', $creditNoteId, $shop['artikelrabatt'], 1, 'Differenz', -$diff,'befreit', $invoice['waehrung']
- );
- }
+ //$this->app->Tpl->Add(TABS,"Shopimport ");
+ $this->app->erp->Headlines('Shopimport');
+ //$this->app->erp->MenuEintrag("index.php?module=shopimport&action=alle","Alle importieren");
+ $this->app->erp->MenuEintrag('index.php?module=shopimport&action=list', 'Übersicht');
- return (int)$creditNoteId;
- }
-
- public function ShopimportList()
- {
- $msg = $this->app->Secure->GetGET('msg');
- if(!empty($msg))
- {
- $msg = $this->app->erp->base64_url_decode($msg);
- $this->app->Tpl->Set('MESSAGE',$msg);
- }
- $this->app->erp->MenuEintrag('index.php?module=importvorlage&action=uebersicht','Zurück zur Übersicht');
-
- //$this->app->Tpl->Add(TABS,"Shopimport ");
- $this->app->erp->Headlines('Shopimport');
- //$this->app->erp->MenuEintrag("index.php?module=shopimport&action=alle","Alle importieren");
- $this->app->erp->MenuEintrag('index.php?module=shopimport&action=list','Übersicht');
-
- if($this->app->erp->RechteVorhanden('shopimport','alle')){
- $this->app->Tpl->Add('INHALT', " ");
- }
- //$this->app->Tpl->Set('SUBHEADING',"Imports");
- //Jeder der in Nachbesserung war egal ob auto oder manuell wandert anschliessend in Manuelle-Freigabe");
- $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
- if($runningcronjob)
- {
- $this->app->Tpl->Set('TAB1','Es läuft gerade ein Cronjob der Aufträge abholt. Die manuelle Auftragsabholung ist in dieser Zeit gesperrt. Bitte warten Sie ein paar Minuten und versuchen Sie es erneut.
');
- }else{
- $table = new EasyTable($this->app);
- $table->Query("SELECT ae.bezeichnung,p.abkuerzung as Projekt,
+ if ($this->app->erp->RechteVorhanden('shopimport', 'alle')) {
+ $this->app->Tpl->Add('INHALT', " ");
+ }
+ //$this->app->Tpl->Set('SUBHEADING',"Imports");
+ //Jeder der in Nachbesserung war egal ob auto oder manuell wandert anschliessend in Manuelle-Freigabe");
+ $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
+ if ($runningcronjob) {
+ $this->app->Tpl->Set('TAB1', 'Es läuft gerade ein Cronjob der Aufträge abholt. Die manuelle Auftragsabholung ist in dieser Zeit gesperrt. Bitte warten Sie ein paar Minuten und versuchen Sie es erneut.
');
+ } else {
+ $table = new EasyTable($this->app);
+ $table->Query("SELECT ae.bezeichnung,p.abkuerzung as Projekt,
ae.id FROM shopexport ae LEFT JOIN projekt p ON p.id=ae.projekt WHERE ae.aktiv='1'");
- $table->DisplayNew('INHALT'," ");
- $this->app->Tpl->Parse('TAB1','rahmen.tpl');
- }
- $this->app->Tpl->Set('INHALT','');
+ $table->DisplayNew('INHALT', " ");
+ $this->app->Tpl->Parse('TAB1', 'rahmen.tpl');
+ }
+ $this->app->Tpl->Set('INHALT', '');
-
- // Archiv GESTERN
- $table = new EasyTable($this->app);
- $table->Query("SELECT a.datum, a.internet, a.transaktionsnummer,a.name, a.land, a.gesamtsumme as betrag, (SELECT SUM(r.soll) FROM rechnung r WHERE r.adresse=a.adresse AND r.status='offen') as mahnwesen, a.zahlungsweise, a.partnerid as Partner, a.id FROM auftrag a WHERE
+ // Archiv GESTERN
+ $table = new EasyTable($this->app);
+ $table->Query("SELECT a.datum, a.internet, a.transaktionsnummer,a.name, a.land, a.gesamtsumme as betrag, (SELECT SUM(r.soll) FROM rechnung r WHERE r.adresse=a.adresse AND r.status='offen') as mahnwesen, a.zahlungsweise, a.partnerid as Partner, a.id FROM auftrag a WHERE
(datum=DATE_FORMAT( DATE_SUB( NOW() , INTERVAL 1 DAY ) , '%Y-%m-%d' ) OR (datum=DATE_FORMAT( NOW(), '%Y-%m-%d' ))) AND a.internet>0
ORDER by a.id DESC");
- $table->DisplayNew('INHALT'," app->Conf->WFconf['defaulttheme']."/images/edit.svg\">
- app->Conf->WFconf['defaulttheme']."/images/pdf.svg\"> ");
+ $table->DisplayNew('INHALT', " app->Conf->WFconf['defaulttheme'] . "/images/edit.svg\">
+ app->Conf->WFconf['defaulttheme'] . "/images/pdf.svg\"> ");
- $this->app->Tpl->Parse('TAB2','rahmen.tpl');
- $this->app->Tpl->Set('INHALT','');
+ $this->app->Tpl->Parse('TAB2', 'rahmen.tpl');
+ $this->app->Tpl->Set('INHALT', '');
-
- $summe_heute = $this->app->DB->Select("SELECT SUM(a.gesamtsumme) FROM auftrag a WHERE
+ $summe_heute = $this->app->DB->Select("SELECT SUM(a.gesamtsumme) FROM auftrag a WHERE
a.datum=DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND a.internet>0
");
- $summe_gestern = $this->app->DB->Select("SELECT SUM(a.gesamtsumme) FROM auftrag a WHERE
+ $summe_gestern = $this->app->DB->Select("SELECT SUM(a.gesamtsumme) FROM auftrag a WHERE
a.datum=DATE_FORMAT( DATE_SUB( NOW() , INTERVAL 1 DAY ) , '%Y-%m-%d' ) AND a.internet>0
");
- $this->app->Tpl->Add('TAB2',"Heute: $summe_heute EUR (inkl. Steuer und Versand) Umsatz aus den Online-Shop
");
- $this->app->Tpl->Add('TAB2',"Gestern: $summe_gestern EUR (inkl. Steuer und Versand) Umsatz aus den Online-Shop
");
+ $this->app->Tpl->Add('TAB2', "Heute: $summe_heute EUR (inkl. Steuer und Versand) Umsatz aus den Online-Shop
");
+ $this->app->Tpl->Add('TAB2', "Gestern: $summe_gestern EUR (inkl. Steuer und Versand) Umsatz aus den Online-Shop
");
- $this->app->Tpl->Set('SUBHEADING','');
- $this->app->Tpl->Parse('PAGE','shopimport_list.tpl');
- }
-
-
- public function ShopimportArchiv()
- {
- $id = $this->app->Secure->GetGET('id');
- $more = $this->app->Secure->GetGET('more');
- $datum = $this->app->Secure->GetGET('datum');
-
- $this->app->Tpl->Set('TABTEXT','Shopimport - Archiv');
-
-
- //$this->app->YUI->TableSearch('TAB1',"shopimportarchiv");
-
- //$this->app->Tpl->Set('TAB1',"Shopimport - Archiv");
-
- if($datum=='')
- {
- $datum = date('Y-m-d');
+ $this->app->Tpl->Set('SUBHEADING', '');
+ $this->app->Tpl->Parse('PAGE', 'shopimport_list.tpl');
}
- $result = $this->app->DB->SelectArr("SELECT * FROM shopimport_auftraege WHERE DATE_FORMAT(logdatei,'%Y-%m-%d') = '$datum'");
+ public function ShopimportArchiv() {
+ $id = $this->app->Secure->GetGET('id');
+ $more = $this->app->Secure->GetGET('more');
+ $datum = $this->app->Secure->GetGET('datum');
+ $this->app->Tpl->Set('TABTEXT', 'Shopimport - Archiv');
- $table = '';
+ //$this->app->YUI->TableSearch('TAB1',"shopimportarchiv");
+ //$this->app->Tpl->Set('TAB1',"Shopimport - Archiv");
- if(is_array($result))
- {
- foreach($result as $key=>$row)
- {
- //$table = $row['imported'];
- if(isset($row['jsonencoded']) && $row['jsonencoded'])
- {
- $warenkorb = json_decode(base64_decode($row['warenkorb']), true);
- }else{
- $warenkorb = unserialize(base64_decode($row['warenkorb']));
- }
- $this->app->stringcleaner->XMLArray_clean($warenkorb);
-
- $table .= "".$warenkorb["onlinebestellnummer"]."/".$warenkorb["transaktionsnummer"]." ".$warenkorb["name"]." ".$warenkorb["email"]." ".$warenkorb["gesamtsumme"]."
- mehr Informationen ";
-
- }
- }
-
- $table .= '
';
-
- if($more > 0)
- {
- $result = $this->app->DB->Select("SELECT warenkorb FROM shopimport_auftraege WHERE id='$more' LIMIT 1");
- if($this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE id='$more' AND jsonencoded = 1 LIMIT 1"))
- {
- $warenkorb = json_decode(base64_decode($result), true);
- }else{
- $warenkorb = unserialize(base64_decode($result));
- }
-
- ob_start();
- var_dump($warenkorb);
- $var_dump_result = ob_get_clean();
-
- $table .=''.$var_dump_result.' ';
-
- }
-
- $this->app->Tpl->Set('TAB1',$table);
- $this->app->Tpl->Parse('PAGE','tabview.tpl');
- }
-
-
- public function ShopimportAlle()
- {
- $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
- if(!empty($runningcronjob))
- {
- $this->app->Location->execute('index.php?module=shopimport&action=list');
- }
- $lastshop = false;
- $shops = $this->app->DB->SelectArr("SELECT ae.id as id FROM shopexport ae LEFT JOIN projekt p ON p.id=ae.projekt WHERE ae.aktiv='1' and ae.demomodus <> '1'");
- if(!empty($shops))
- {
- $anz = 0;
- $fp = $this->app->erp->ProzessLock('shopimport_alle');
- $cshops = (!empty($shops)?count($shops):0);
- for($i=0;$i<$cshops-1;$i++)
- {
- $anz += $this->ShopimportImport($shops[$i]['id'],$anz,true);
- }
- $lastshop=$shops[(!empty($shops)?count($shops):0)-1]['id'];
- $this->app->erp->ProzessUnlock($fp);
- }
- if($lastshop && is_numeric($lastshop)){
- $this->app->Location->execute('index.php?module=shopimport&action=import&id='.$lastshop);
- }
- else{
- $this->app->Location->execute('index.php?module=shopimport&action=list');
- }
- }
-
- /**
- * @param int $shopId
- * @param string $shopOrderNumber
- * @param bool $changeShopOrderStatus
- * @param int $projectId
- * @param bool $allStati
- *
- * @return array
- */
- public function importSingleOrder($shopId, $shopOrderNumber, $changeShopOrderStatus, $projectId, $allStati = false)
- {
- $pageContents = $this->app->remote->RemoteConnection($shopId);
- if($pageContents==='success')
- {
- $orderCount = $this->app->remote->RemoteGetAuftraegeAnzahlNummer($shopId, $shopOrderNumber);
-
- if($orderCount > 0)
- {
- if($allStati){
- $result = $this->app->remote->RemoteCommand($shopId, 'getauftrag', ['nummer' => $shopOrderNumber]);
- }
- else {
- $result = $this->app->remote->RemoteGetAuftragNummer($shopId, $shopOrderNumber);
+ if ($datum == '') {
+ $datum = date('Y-m-d');
}
- if(is_array($result))
- {
- $result = reset($result);
- $shopExtId = $result['id'];
- $sessionid = $result['sessionid'];
- $jsonEncoded = 0;
- if(empty(!$result['warenkorbjson'])) {
- $jsonEncoded = 1;
- $warenkorb = $result['warenkorbjson'];
- } else{
- $warenkorb = $result['warenkorb'];
- }
- $logdatei = $result['logdatei'];
- $username = !empty($this->app->User)?$this->app->User->GetName():'Cronjob';
- $this->app->DB->Insert(
- sprintf(
- "INSERT INTO shopimport_auftraege (extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei, jsonencoded, shopid)
+ $result = $this->app->DB->SelectArr("SELECT * FROM shopimport_auftraege WHERE DATE_FORMAT(logdatei,'%Y-%m-%d') = '$datum'");
+
+ $table = '';
+
+ if (is_array($result)) {
+ foreach ($result as $key => $row) {
+ //$table = $row['imported'];
+ if (isset($row['jsonencoded']) && $row['jsonencoded']) {
+ $warenkorb = json_decode(base64_decode($row['warenkorb']), true);
+ } else {
+ $warenkorb = unserialize(base64_decode($row['warenkorb']));
+ }
+ $this->app->stringcleaner->XMLArray_clean($warenkorb);
+
+ $table .= "" . $warenkorb["onlinebestellnummer"] . "/" . $warenkorb["transaktionsnummer"] . " " . $warenkorb["name"] . " " . $warenkorb["email"] . " " . $warenkorb["gesamtsumme"] . "
+ mehr Informationen ";
+ }
+ }
+
+ $table .= '
';
+
+ if ($more > 0) {
+ $result = $this->app->DB->Select("SELECT warenkorb FROM shopimport_auftraege WHERE id='$more' LIMIT 1");
+ if ($this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE id='$more' AND jsonencoded = 1 LIMIT 1")) {
+ $warenkorb = json_decode(base64_decode($result), true);
+ } else {
+ $warenkorb = unserialize(base64_decode($result));
+ }
+
+ ob_start();
+ var_dump($warenkorb);
+ $var_dump_result = ob_get_clean();
+
+ $table .= '' . $var_dump_result . ' ';
+ }
+
+ $this->app->Tpl->Set('TAB1', $table);
+ $this->app->Tpl->Parse('PAGE', 'tabview.tpl');
+ }
+
+ public function ShopimportAlle() {
+ $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
+ if (!empty($runningcronjob)) {
+ $this->app->Location->execute('index.php?module=shopimport&action=list');
+ }
+ $lastshop = false;
+ $shops = $this->app->DB->SelectArr("SELECT ae.id as id FROM shopexport ae LEFT JOIN projekt p ON p.id=ae.projekt WHERE ae.aktiv='1' and ae.demomodus <> '1'");
+ if (!empty($shops)) {
+ $anz = 0;
+ $fp = $this->app->erp->ProzessLock('shopimport_alle');
+ $cshops = (!empty($shops) ? count($shops) : 0);
+ for ($i = 0; $i < $cshops - 1; $i++) {
+ $anz += $this->ShopimportImport($shops[$i]['id'], $anz, true);
+ }
+ $lastshop = $shops[(!empty($shops) ? count($shops) : 0) - 1]['id'];
+ $this->app->erp->ProzessUnlock($fp);
+ }
+ if ($lastshop && is_numeric($lastshop)) {
+ $this->app->Location->execute('index.php?module=shopimport&action=import&id=' . $lastshop);
+ } else {
+ $this->app->Location->execute('index.php?module=shopimport&action=list');
+ }
+ }
+
+ /**
+ * @param int $shopId
+ * @param string $shopOrderNumber
+ * @param bool $changeShopOrderStatus
+ * @param int $projectId
+ * @param bool $allStati
+ *
+ * @return array
+ */
+ public function importSingleOrder($shopId, $shopOrderNumber, $changeShopOrderStatus, $projectId, $allStati = false) {
+ $pageContents = $this->app->remote->RemoteConnection($shopId);
+ if ($pageContents === 'success') {
+ $orderCount = $this->app->remote->RemoteGetAuftraegeAnzahlNummer($shopId, $shopOrderNumber);
+
+ if ($orderCount > 0) {
+ if ($allStati) {
+ $result = $this->app->remote->RemoteCommand($shopId, 'getauftrag', ['nummer' => $shopOrderNumber]);
+ } else {
+ $result = $this->app->remote->RemoteGetAuftragNummer($shopId, $shopOrderNumber);
+ }
+
+ if (is_array($result)) {
+ $result = reset($result);
+ $shopExtId = $result['id'];
+ $sessionid = $result['sessionid'];
+ $jsonEncoded = 0;
+ if (empty(!$result['warenkorbjson'])) {
+ $jsonEncoded = 1;
+ $warenkorb = $result['warenkorbjson'];
+ } else {
+ $warenkorb = $result['warenkorb'];
+ }
+ $logdatei = $result['logdatei'];
+ $username = !empty($this->app->User) ? $this->app->User->GetName() : 'Cronjob';
+ $this->app->DB->Insert(
+ sprintf(
+ "INSERT INTO shopimport_auftraege (extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei, jsonencoded, shopid)
VALUES('%s','%s','%s',0,%d, '%s','%s', %d, %d)",
- $this->app->DB->real_escape_string($shopExtId),
- $this->app->DB->real_escape_string($sessionid),
- $this->app->DB->real_escape_string($warenkorb),
- (int)$projectId,
- $this->app->DB->real_escape_string($username),
- $this->app->DB->real_escape_string($logdatei),
- $jsonEncoded,
- (int)$shopId
- )
- );
- $insid = $this->app->DB->GetInsertID();
- if($changeShopOrderStatus && (String)$shopExtId !== '')
- {
- $this->app->remote->RemoteDeleteAuftrag($shopId, $shopExtId);
- }
- return ['status'=>1,'id'=>$insid,'info'=>'Auftrag wurde abgeholt.'];
+ $this->app->DB->real_escape_string($shopExtId),
+ $this->app->DB->real_escape_string($sessionid),
+ $this->app->DB->real_escape_string($warenkorb),
+ (int) $projectId,
+ $this->app->DB->real_escape_string($username),
+ $this->app->DB->real_escape_string($logdatei),
+ $jsonEncoded,
+ (int) $shopId
+ )
+ );
+ $insid = $this->app->DB->GetInsertID();
+ if ($changeShopOrderStatus && (String) $shopExtId !== '') {
+ $this->app->remote->RemoteDeleteAuftrag($shopId, $shopExtId);
+ }
+ return ['status' => 1, 'id' => $insid, 'info' => 'Auftrag wurde abgeholt.'];
+ }
+ }
+ return ['status' => 0, 'error' => 'Auftrag wurde nicht gefunden!'];
}
- }
- return ['status'=>0,'error'=>'Auftrag wurde nicht gefunden!'];
+ return ['status' => 0, 'error' => 'Verbindung fehlgeschlagen!'];
}
- return ['status'=>0,'error'=>'Verbindung fehlgeschlagen!'];
- }
- public function ShopimportEinzelimport()
- {
- $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
- if(!empty($runningcronjob))
- {
- $this->app->Location->execute('index.php?module=shopimport&action=list');
- }
- $id = (int)$this->app->Secure->GetGET('id');
- $nummer = (String)$this->app->Secure->GetGET('nummer');
- if($nummer === '')
- {
- $nummer = (String)$this->app->Secure->GetPOST('nummer');
- }
- $deleteauftrag = (int)$this->app->Secure->GetPOST('deleteauftrag');
- if(!empty($id) && !empty($nummer))
- {
- $shoparr = $this->app->DB->SelectRow("SELECT projekt,holealle FROM shopexport WHERE id = '$id' LIMIT 1");
- $projekt = $shoparr['projekt'];//$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
- $holealle = $shoparr['holealle'];//$this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$id' LIMIT 1");
- if($holealle)
- {
+ public function ShopimportEinzelimport() {
+ $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
+ if (!empty($runningcronjob)) {
+ $this->app->Location->execute('index.php?module=shopimport&action=list');
+ }
+ $id = (int) $this->app->Secure->GetGET('id');
+ $nummer = (String) $this->app->Secure->GetGET('nummer');
+ if ($nummer === '') {
+ $nummer = (String) $this->app->Secure->GetPOST('nummer');
+ }
+ $deleteauftrag = (int) $this->app->Secure->GetPOST('deleteauftrag');
+ if (!empty($id) && !empty($nummer)) {
+ $shoparr = $this->app->DB->SelectRow("SELECT projekt,holealle FROM shopexport WHERE id = '$id' LIMIT 1");
+ $projekt = $shoparr['projekt']; //$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
+ $holealle = $shoparr['holealle']; //$this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$id' LIMIT 1");
+ if ($holealle) {
- $res = $this->importSingleOrder($id, $nummer, $deleteauftrag, $projekt);
- if($res['status'] == 1){
- $this->app->Tpl->Add('MESSAGE',''.$res['info'].'
');
+ $res = $this->importSingleOrder($id, $nummer, $deleteauftrag, $projekt);
+ if ($res['status'] == 1) {
+ $this->app->Tpl->Add('MESSAGE', '' . $res['info'] . '
');
+ } else {
+ $this->app->Tpl->Add('MESSAGE', '' . $res['error'] . '
');
+ }
+ } else {
+ $this->app->Tpl->Add('MESSAGE', 'Shop nicht auf alle Aufträge eingstellt!
');
+ }
+ } elseif ($id <= 0) {
+ $msg = $this->app->erp->base64_url_encode('Kein Shop gewählt!
');
+ $this->app->Location->execute('index.php?module=shopimport&action=list&msg=' . $msg);
} else {
- $this->app->Tpl->Add('MESSAGE',''.$res['error'].'
');
+ $this->app->Tpl->Add('MESSAGE', 'Keine Nummer angegeben!
');
}
- }else{
- $this->app->Tpl->Add('MESSAGE','Shop nicht auf alle Aufträge eingstellt!
');
- }
- } elseif($id <= 0) {
- $msg = $this->app->erp->base64_url_encode('Kein Shop gewählt!
');
- $this->app->Location->execute('index.php?module=shopimport&action=list&msg='.$msg);
- } else {
- $this->app->Tpl->Add('MESSAGE','Keine Nummer angegeben!
');
- }
- $this->app->erp->MenuEintrag('index.php?module=shopimport&action=einzelimport&id='.$id,'Einzelimport');
- $this->app->erp->MenuEintrag('index.php?module=shopimport&action=import','Shopauftrag-Liste');
- $this->app->Tpl->Parse('PAGE','shopimport_einzelimport.tpl');
- }
-
- public function KundeAnlegenUpdate($shopimportid,$shopextid, $warenkorb, $kundennummer = 0, $import_kundennummer, &$unbekanntezahlungsweisen)
- {
- if(empty($warenkorb)) {
- return 0;
- }
- if(!empty($this->app->stringcleaner)){
- $this->app->stringcleaner->XMLArray_clean($warenkorb);
- }
- $i = 0;
- $sucess_import = 0;
- $shopid = $this->app->DB->Select("SELECT shopid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
- $shopexportArr = $this->app->DB->SelectRow(sprintf('SELECT * FROM shopexport WHERE id=%d', $shopid));
- $projekt = $shopexportArr['projekt'];//$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$shopid'");
- if(!empty($warenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '".(int)$warenkorb['projekt']."' LIMIT 1"))
- {
- $projekt = (int)$warenkorb['projekt'];
- }
- $adresseprojekt = '';
- $kundenurvonprojekt = $shopexportArr['kundenurvonprojekt'];//$this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '".$shopid."' LIMIT 1");
- if($kundenurvonprojekt)
- {
- $adresseprojekt = $projekt;
+ $this->app->erp->MenuEintrag('index.php?module=shopimport&action=einzelimport&id=' . $id, 'Einzelimport');
+ $this->app->erp->MenuEintrag('index.php?module=shopimport&action=import', 'Shopauftrag-Liste');
+ $this->app->Tpl->Parse('PAGE', 'shopimport_einzelimport.tpl');
}
- if(isset($warenkorb['subshop']) && $warenkorb['subshop'])
- {
- $subshopprojekt = $this->app->DB->SelectArr("SELECT * FROM shopexport_subshop WHERE shop = '".$shopid."' AND aktiv = 1 AND subshopkennung = '".$this->app->DB->real_escape_string($warenkorb['subshop'])."' LIMIT 1");
- if($subshopprojekt)
- {
- if($subshopprojekt[0]['projekt'])
- {
- $adresseprojekt = $subshopprojekt[0]['projekt'];
- $projekt = $subshopprojekt[0]['projekt'];
- $arr[$i]['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
+ public function KundeAnlegenUpdate($shopimportid, $shopextid, $warenkorb, $kundennummer = 0, $import_kundennummer, &$unbekanntezahlungsweisen) {
+ if (empty($warenkorb)) {
+ return 0;
}
- if($subshopprojekt[0]['sprache'])
- {
- $defaultsprache = $this->app->DB->Select("SELECT sprache FROM shopexport_sprachen WHERE shop = '$shopid' AND (projekt = '$projekt' OR projekt = 0) AND
- land = '' ORDER BY projekt = '$projekt' DESC, land = '".$warenkorb['land']."' DESC LIMIT 1");
- $checksprache = $this->app->DB->Select("SELECT sprache FROM shopexport_sprachen WHERE shop = '$shopid' AND (projekt = '$projekt' OR projekt = 0) AND
- land = '".(isset($warenkorb['land'])?$warenkorb['land']:$this->app->erp->Firmendaten('land'))."' ORDER BY projekt = '$projekt' DESC, land = '".$warenkorb['land']."' DESC LIMIT 1");
- if($checksprache != ''){
- if(empty($warenkorb['kunde_sprache']))
- {
- $warenkorb['kunde_sprache'] = $checksprache;
+ if (!empty($this->app->stringcleaner)) {
+ $this->app->stringcleaner->XMLArray_clean($warenkorb);
+ }
+ $i = 0;
+ $success_import = 0;
+ $shopid = $this->app->DB->Select("SELECT shopid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
+ $shopexportArr = $this->app->DB->SelectRow(sprintf('SELECT * FROM shopexport WHERE id=%d', $shopid));
+ $projekt = $shopexportArr['projekt']; //$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$shopid'");
+ if (!empty($warenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '" . (int) $warenkorb['projekt'] . "' LIMIT 1")) {
+ $projekt = (int) $warenkorb['projekt'];
+ }
+ $adresseprojekt = '';
+ $kundenurvonprojekt = $shopexportArr['kundenurvonprojekt']; //$this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '".$shopid."' LIMIT 1");
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = $projekt;
+ }
+
+ if (isset($warenkorb['subshop']) && $warenkorb['subshop']) {
+ $subshopprojekt = $this->app->DB->SelectArr("SELECT * FROM shopexport_subshop WHERE shop = '" . $shopid . "' AND aktiv = 1 AND subshopkennung = '" . $this->app->DB->real_escape_string($warenkorb['subshop']) . "' LIMIT 1");
+ if ($subshopprojekt) {
+ if ($subshopprojekt[0]['projekt']) {
+ $adresseprojekt = $subshopprojekt[0]['projekt'];
+ $projekt = $subshopprojekt[0]['projekt'];
+ $arr[$i]['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
+ }
+ if ($subshopprojekt[0]['sprache']) {
+ $defaultsprache = $this->app->DB->Select("SELECT sprache FROM shopexport_sprachen WHERE shop = '$shopid' AND (projekt = '$projekt' OR projekt = 0) AND
+ land = '' ORDER BY projekt = '$projekt' DESC, land = '" . $warenkorb['land'] . "' DESC LIMIT 1");
+ $checksprache = $this->app->DB->Select("SELECT sprache FROM shopexport_sprachen WHERE shop = '$shopid' AND (projekt = '$projekt' OR projekt = 0) AND
+ land = '" . (isset($warenkorb['land']) ? $warenkorb['land'] : $this->app->erp->Firmendaten('land')) . "' ORDER BY projekt = '$projekt' DESC, land = '" . $warenkorb['land'] . "' DESC LIMIT 1");
+ if ($checksprache != '') {
+ if (empty($warenkorb['kunde_sprache'])) {
+ $warenkorb['kunde_sprache'] = $checksprache;
+ }
+ } else {
+ if (empty($warenkorb['kunde_sprache'])) {
+ $warenkorb['kunde_sprache'] = $defaultsprache;
+ }
+ }
+
+ if (empty($warenkorb['kunde_sprache'])) {
+ $warenkorb['kunde_sprache'] = $subshopprojekt[0]['sprache'];
+ }
+ }
+ } else {
+ if (!$this->app->DB->Select("SELECT id FROM shopexport_subshop WHERE shop = '" . $shopid . "' AND subshopkennung = '" . $this->app->DB->real_escape_string($warenkorb['subshop']) . "' LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO shopexport_subshop (shop, subshopkennung, aktiv, projekt) VALUES ('" . $shopid . "','" . $this->app->DB->real_escape_string($warenkorb['subshop']) . "','0','$projekt')");
+ }
}
- }
- else{
- if(empty($warenkorb['kunde_sprache']))
- {
- $warenkorb['kunde_sprache'] = $defaultsprache;
+ }
+
+ $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '$shopid' LIMIT 1");
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = " AND projekt = '" . $adresseprojekt . "' ";
+ } else {
+ $adresseprojekt = '';
+ }
+
+ if (empty($warenkorb['name'])) {
+ $warenkorb['name'] = $warenkorb['ansprechpartner'];
+ $warenkorb['ansprechpartner'] = '';
+ }
+ if (empty($warenkorb['name']) && !empty($warenkorb['lieferadresse_name'])) {
+ $warenkorb['name'] = $warenkorb['lieferadresse_name'];
+ }
+ if (empty($warenkorb['lieferadresse_name'])) {
+ $warenkorb['lieferadresse_name'] = $warenkorb['lieferadresse_ansprechpartner'];
+ $warenkorb['lieferadresse_ansprechpartner'] = '';
+ }
+ $warenkorb['email'] = trim($warenkorb['email'], " \t\n\r\0\x0B\xc2\xa0");
+ if (empty($warenkorb['name'])) {
+ return 0;
+ }
+ //$projekt = $arr[0][projekt];
+
+ if ($kundennummer == '1') {
+ $warenkorb['kundennummer'] = $import_kundennummer;
+ if (strlen($warenkorb['kundennummer']) != '') {
+ $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' AND geloescht!=1 $adresseprojekt LIMIT 1");
}
- }
-
- if(empty($warenkorb['kunde_sprache']))
- {
- $warenkorb['kunde_sprache'] = $subshopprojekt[0]['sprache'];
- }
- }
- }else{
- if(!$this->app->DB->Select("SELECT id FROM shopexport_subshop WHERE shop = '".$shopid."' AND subshopkennung = '".$this->app->DB->real_escape_string($warenkorb['subshop'])."' LIMIT 1"))
- {
- $this->app->DB->Insert("INSERT INTO shopexport_subshop (shop, subshopkennung, aktiv, projekt) VALUES ('".$shopid."','".$this->app->DB->real_escape_string($warenkorb['subshop'])."','0','$projekt')");
- }
- }
- }
+ if ($adresse <= 0) {
+ $adresse = $this->app->erp->KundeAnlegen($warenkorb['anrede'], $warenkorb['name'], $warenkorb['abteilung'],
+ $warenkorb['unterabteilung'], $warenkorb['ansprechpartner'], $warenkorb['adresszusatz'], $warenkorb['strasse'], $warenkorb['land'], $warenkorb['plz'], $warenkorb['ort'], $warenkorb['email'],
+ $warenkorb['telefon'], $warenkorb['telefax'], $warenkorb['ustid'], $warenkorb['affiliate_ref'], $projekt);
+ $warenkorb['customer_created'] = true;
+ if (isset($warenkorb['kunde_sprache'])) {
+ if ($warenkorb['kunde_sprache'] == 'englisch' || $warenkorb['kunde_sprache'] == 'english') {
+ $this->app->DB->Update("UPDATE adresse SET sprache = 'englisch' WHERE id = '$adresse' LIMIT 1");
+ } elseif ($warenkorb['kunde_sprache'] == 'deutsch' || $warenkorb['kunde_sprache'] == 'german') {
+ $this->app->DB->Update("UPDATE adresse SET sprache = 'deutsch' WHERE id = '$adresse' LIMIT 1");
+ } elseif (method_exists($this->app->erp, 'GetSprachenSelect')) {
+ $sprachen = $this->app->erp->GetSprachenSelect;
+ if (isset($sprachen[strtolower($warenkorb['kunde_sprache'])])) {
+ $this->app->DB->Update("UPDATE adresse SET sprache = '" . strtolower($warenkorb['kunde_sprache']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ }
+ }
+ if ($warenkorb['titel'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET titel = '" . $this->app->DB->real_escape_string($warenkorb['titel']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if (isset($warenkorb['ust_befreit'])) {
+ $this->app->DB->Update("UPDATE adresse SET ust_befreit = '" . (int) $warenkorb['ust_befreit'] . "' WHERE id = '$adresse' LIMIT 1");
+ }
- $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '$shopid' LIMIT 1");
- if($kundenurvonprojekt)
- {
- $adresseprojekt = " AND projekt = '".$adresseprojekt."' ";
- }else{
- $adresseprojekt = '';
- }
+ $kundenGruppen = $this->app->DB->SelectArr("SELECT gruppeid,type FROM shopexport_kundengruppen WHERE shopid=$shopid AND aktiv=1 AND apply_to_new_customers=1 AND type<>'Artikel' AND (projekt=0 OR projekt='$projekt')");
+ if (!empty($kundenGruppen)) {
+ foreach ($kundenGruppen as $gruppe) {
+ $this->app->erp->AddRolleZuAdresse($adresse, $gruppe['type'], 'von', 'Gruppe', $gruppe['gruppeid']);
+ }
+ }
- if(empty($warenkorb['name'])){
- $warenkorb['name']=$warenkorb['ansprechpartner'];
- $warenkorb['ansprechpartner'] = '';
- }
- if(empty($warenkorb['name']) && !empty($warenkorb['lieferadresse_name'])) {
- $warenkorb['name'] = $warenkorb['lieferadresse_name'];
- }
- if(empty($warenkorb['lieferadresse_name'])){
- $warenkorb['lieferadresse_name']=$warenkorb['lieferadresse_ansprechpartner'];
- $warenkorb['lieferadresse_ansprechpartner'] = '';
- }
- $warenkorb['email'] = trim($warenkorb['email']," \t\n\r\0\x0B\xc2\xa0");
- if(empty($warenkorb['name'])) {
- return 0;
- }
- //$projekt = $arr[0][projekt];
+ if (isset($warenkorb['kundengruppe'])) {
+ $this->shopimportAdresseGruppenMapping($warenkorb['kundengruppe'], $adresse, $shopid, $projekt);
+ }
+ if ($shopexportArr['vertrieb']) {
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE adresse SET vertrieb = %d WHERE id = %d',
+ $shopexportArr['vertrieb'], $adresse
+ )
+ );
+ }
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE adresse SET fromshop = %d WHERE fromshop = 0 AND id = %d',
+ $shopexportArr['id'], $adresse
+ )
+ );
+ } else {
+ if (!empty($warenkorb['anrede'])) {
+ $typ = $warenkorb['anrede'];
+ } else {
+ $typ = $this->app->DB->Select("SELECT typ FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ $name = $warenkorb['name'];
- if($kundennummer=='1')
- {
- $warenkorb['kundennummer']= $import_kundennummer;
- if(strlen($warenkorb['kundennummer'])!=''){
- $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' AND geloescht!=1 $adresseprojekt LIMIT 1");
- }
- if($adresse<=0) {
- $adresse = $this->app->erp->KundeAnlegen($warenkorb['anrede'],$warenkorb['name'],$warenkorb['abteilung'],
- $warenkorb['unterabteilung'],$warenkorb['ansprechpartner'],$warenkorb['adresszusatz'],$warenkorb['strasse'],$warenkorb['land'],$warenkorb['plz'],$warenkorb['ort'],$warenkorb['email'],
- $warenkorb['telefon'],$warenkorb['telefax'],$warenkorb['ustid'],$warenkorb['affiliate_ref'],$projekt);
- $warenkorb['customer_created'] = true;
- if(isset($warenkorb['kunde_sprache']))
- {
- if($warenkorb['kunde_sprache'] == 'englisch' || $warenkorb['kunde_sprache'] == 'english')
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = 'englisch' WHERE id = '$adresse' LIMIT 1");
- }elseif($warenkorb['kunde_sprache'] == 'deutsch' || $warenkorb['kunde_sprache'] == 'german')
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = 'deutsch' WHERE id = '$adresse' LIMIT 1");
- }elseif(method_exists($this->app->erp, 'GetSprachenSelect')){
- $sprachen = $this->app->erp->GetSprachenSelect;
- if(isset($sprachen[strtolower($warenkorb['kunde_sprache'])]))
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = '".strtolower($warenkorb['kunde_sprache'])."' WHERE id = '$adresse' LIMIT 1");
- }
+ if (!empty($warenkorb['abteilung'])) {
+ $abteilung = $warenkorb['abteilung'];
+ } else {
+ $abteilung = $this->app->DB->Select("SELECT abteilung FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['unterabteilung'])) {
+ $unterabteilung = $warenkorb['unterabteilung'];
+ } else {
+ $unterabteilung = $this->app->DB->Select("SELECT unterabteilung FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+
+ $ansprechpartner = $warenkorb['ansprechpartner'];
+ $adresszusatz = $warenkorb['adresszusatz'];
+ $strasse = $warenkorb['strasse'];
+ $land = $warenkorb['land'];
+ $plz = $warenkorb['plz'];
+ $ort = $warenkorb['ort'];
+ if (!empty($warenkorb['email'])) {
+ $email = $warenkorb['email'];
+ } else {
+ $email = $this->app->DB->Select("SELECT email FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['telefon'])) {
+ $telefon = $warenkorb['telefon'];
+ } else {
+ $telefon = $this->app->DB->Select("SELECT telefon FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['telefax'])) {
+ $telefax = $warenkorb['telefax'];
+ } else {
+ $telefax = $this->app->DB->Select("SELECT telefax FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['ustid'])) {
+ $ustid = $warenkorb['ustid'];
+ } else {
+ $ustid = $this->app->DB->Select("SELECT ustid FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['affiliate_ref'])) {
+ $partner = $warenkorb['affiliate_ref'];
+ } else {
+ $partner = $this->app->DB->Select("SELECT partner FROM adresse WHERE id = '$adresse' LIMIT 1");
+ }
+ // Update + protokoll
+ if (!$this->app->DB->Select("SELECT adressennichtueberschreiben FROM shopexport WHERE id = '$shopid' LIMIT 1")) {
+ if ($warenkorb['mobil'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET mobil = '" . $this->app->DB->real_escape_string($warenkorb['mobil']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if ($warenkorb['titel'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET titel = '" . $this->app->DB->real_escape_string($warenkorb['titel']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if ($warenkorb['geburtstag'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET geburtstag = '" . $this->app->DB->real_escape_string($warenkorb['geburtstag']) . "' WHERE id = '$adresse' AND ISNULL(geburtstag) LIMIT 1");
+ }
+ if (isset($warenkorb['ust_befreit'])) {
+ $query = sprintf('UPDATE `adresse` SET `ust_befreit` = %d WHERE `id` = %d LIMIT 1',
+ $warenkorb['ust_befreit'], $adresse);
+ $this->app->DB->Update($query);
+ }
+ $this->app->erp->KundeUpdate($adresse, $typ, $name, $abteilung,
+ $unterabteilung, $ansprechpartner, $adresszusatz, $strasse, $land, $plz, $ort, $email, $telefon, $telefax, $ustid, $partner, $projekt);
+
+ if (!empty($warenkorb['bundesland'])) {
+ $this->app->DB->Update("UPDATE adresse SET bundesland = '" . $this->app->DB->real_escape_string($warenkorb['bundesland']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ }
}
- }
- if($warenkorb['titel'] != ''){
- $this->app->DB->Update("UPDATE adresse SET titel = '".$this->app->DB->real_escape_string($warenkorb['titel'])."' WHERE id = '$adresse' LIMIT 1");
- }
- if(isset($warenkorb['ust_befreit']))
- {
- $this->app->DB->Update("UPDATE adresse SET ust_befreit = '".(int)$warenkorb['ust_befreit']."' WHERE id = '$adresse' LIMIT 1");
- }
-
- $kundenGruppen = $this->app->DB->SelectArr("SELECT gruppeid,type FROM shopexport_kundengruppen WHERE shopid=$shopid AND aktiv=1 AND apply_to_new_customers=1 AND type<>'Artikel' AND (projekt=0 OR projekt='$projekt')");
- if(!empty($kundenGruppen)){
- foreach ($kundenGruppen as $gruppe){
- $this->app->erp->AddRolleZuAdresse($adresse, $gruppe['type'], 'von', 'Gruppe', $gruppe['gruppeid']);
- }
- }
-
- if(isset($warenkorb['kundengruppe'])){
- $this->shopimportAdresseGruppenMapping($warenkorb['kundengruppe'],$adresse,$shopid,$projekt);
- }
- if($shopexportArr['vertrieb']) {
- $this->app->DB->Update(
- sprintf(
- 'UPDATE adresse SET vertrieb = %d WHERE id = %d',
- $shopexportArr['vertrieb'], $adresse
- )
- );
- }
- $this->app->DB->Update(
- sprintf(
- 'UPDATE adresse SET fromshop = %d WHERE fromshop = 0 AND id = %d',
- $shopexportArr['id'], $adresse
- )
- );
- }
- else {
- if(!empty($warenkorb['anrede']))
- {
+ } else {
+ //echo "import als Neu-Kunde $shopimportid ";
$typ = $warenkorb['anrede'];
- }else{
- $typ = $this->app->DB->Select("SELECT typ FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- $name= $warenkorb['name'];
-
- if(!empty($warenkorb['abteilung']))
- {
+ $name = $warenkorb['name'];
$abteilung = $warenkorb['abteilung'];
- }else{
- $abteilung = $this->app->DB->Select("SELECT abteilung FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['unterabteilung']))
- {
$unterabteilung = $warenkorb['unterabteilung'];
- }else{
- $unterabteilung = $this->app->DB->Select("SELECT unterabteilung FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
-
- $ansprechpartner = $warenkorb['ansprechpartner'];
- $adresszusatz = $warenkorb['adresszusatz'];
- $strasse = $warenkorb['strasse'];
- $land = $warenkorb['land'];
- $plz = $warenkorb['plz'];
- $ort = $warenkorb['ort'];
- if(!empty($warenkorb['email']))
- {
+ $ansprechpartner = $warenkorb['ansprechpartner'];
+ $adresszusatz = $warenkorb['adresszusatz'];
+ $strasse = $warenkorb['strasse'];
+ $land = $warenkorb['land'];
+ $plz = $warenkorb['plz'];
+ $ort = $warenkorb['ort'];
$email = $warenkorb['email'];
- }else{
- $email = $this->app->DB->Select("SELECT email FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['telefon']))
- {
$telefon = $warenkorb['telefon'];
- }else{
- $telefon = $this->app->DB->Select("SELECT telefon FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['telefax']))
- {
$telefax = $warenkorb['telefax'];
- }else{
- $telefax = $this->app->DB->Select("SELECT telefax FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['ustid']))
- {
$ustid = $warenkorb['ustid'];
- }else{
- $ustid = $this->app->DB->Select("SELECT ustid FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['affiliate_ref']))
- {
$partner = $warenkorb['affiliate_ref'];
- }else{
- $partner = $this->app->DB->Select("SELECT partner FROM adresse WHERE id = '$adresse' LIMIT 1");
- }
- // Update + protokoll
- if(!$this->app->DB->Select("SELECT adressennichtueberschreiben FROM shopexport WHERE id = '$shopid' LIMIT 1"))
- {
- if($warenkorb['mobil'] != ''){
- $this->app->DB->Update("UPDATE adresse SET mobil = '".$this->app->DB->real_escape_string($warenkorb['mobil'])."' WHERE id = '$adresse' LIMIT 1");
- }
- if($warenkorb['titel'] != ''){
- $this->app->DB->Update("UPDATE adresse SET titel = '".$this->app->DB->real_escape_string($warenkorb['titel'])."' WHERE id = '$adresse' LIMIT 1");
- }
- if($warenkorb['geburtstag'] != ''){
- $this->app->DB->Update("UPDATE adresse SET geburtstag = '".$this->app->DB->real_escape_string($warenkorb['geburtstag'])."' WHERE id = '$adresse' AND ISNULL(geburtstag) LIMIT 1");
- }
- if(isset($warenkorb['ust_befreit'])){
- $query = sprintf('UPDATE `adresse` SET `ust_befreit` = %d WHERE `id` = %d LIMIT 1',
- $warenkorb['ust_befreit'], $adresse);
- $this->app->DB->Update($query);
- }
- $this->app->erp->KundeUpdate($adresse,$typ,$name,$abteilung,
- $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt);
-
- if(!empty($warenkorb['bundesland']))
- {
- $this->app->DB->Update("UPDATE adresse SET bundesland = '".$this->app->DB->real_escape_string($warenkorb['bundesland'])."' WHERE id = '$adresse' LIMIT 1");
- }
- }
- }
- }
- else {
- //echo "import als Neu-Kunde $shopimportid ";
- $typ = $warenkorb['anrede'];
- $name= $warenkorb['name'];
- $abteilung = $warenkorb['abteilung'];
- $unterabteilung = $warenkorb['unterabteilung'];
- $ansprechpartner = $warenkorb['ansprechpartner'];
- $adresszusatz = $warenkorb['adresszusatz'];
- $strasse = $warenkorb['strasse'];
- $land = $warenkorb['land'];
- $plz = $warenkorb['plz'];
- $ort = $warenkorb['ort'];
- $email = $warenkorb['email'];
- $telefon = $warenkorb['telefon'];
- $telefax = $warenkorb['telefax'];
- $ustid = $warenkorb['ustid'];
- $partner = $warenkorb['affiliate_ref'];
-
- // denn fall das es kunde 1:1 schon gibt = alte Kundennummer verwenden kommt vor allem vor, wenn ein Kunde an einem Tag oefters bestellt hat
- // $adresse = $this->app->erp->KundeAnlegen($typ,$name,$abteilung,
- // $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt);
- if(!empty($warenkorb['kundennummer'])){
- $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' $adresseprojekt AND geloescht!=1 LIMIT 1");
- }
- if(empty($adresse)){
- $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE email='{$warenkorb['email']}' and email <> '' $adresseprojekt AND geloescht!=1 LIMIT 1");
- }
-
- if($adresse<=0) {
- $adresse = $this->app->erp->KundeAnlegen($typ,$name,$abteilung,
- $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt);
- $warenkorb['customer_created'] = true;
- if(!empty($warenkorb['bundesland']))
- {
- $this->app->DB->Update("UPDATE adresse SET bundesland = '".$this->app->DB->real_escape_string($warenkorb['bundesland'])."' WHERE id = '$adresse' LIMIT 1");
- }
-
- if(isset($warenkorb['kunde_sprache']))
- {
- if($warenkorb['kunde_sprache'] === 'englisch' || $warenkorb['kunde_sprache'] === 'english')
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = 'englisch' WHERE id = '$adresse' LIMIT 1");
- }elseif($warenkorb['kunde_sprache'] === 'deutsch' || $warenkorb['kunde_sprache'] === 'german')
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = 'deutsch' WHERE id = '$adresse' LIMIT 1");
- }elseif(method_exists($this->app->erp, 'GetAdressSprachen')){
- $sprachen = $this->app->erp->GetAdressSprachen();
- if(isset($sprachen[strtolower($warenkorb['kunde_sprache'])]))
- {
- $this->app->DB->Update("UPDATE adresse SET sprache = '".strtolower($warenkorb['kunde_sprache'])."' WHERE id = '$adresse' LIMIT 1");
- }
+ // denn fall das es kunde 1:1 schon gibt = alte Kundennummer verwenden kommt vor allem vor, wenn ein Kunde an einem Tag oefters bestellt hat
+ // $adresse = $this->app->erp->KundeAnlegen($typ,$name,$abteilung,
+ // $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt);
+ if (!empty($warenkorb['kundennummer'])) {
+ $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='{$warenkorb['kundennummer']}' $adresseprojekt AND geloescht!=1 LIMIT 1");
}
- }
- if($warenkorb['titel'] != ''){
- $this->app->DB->Update("UPDATE adresse SET titel = '".$this->app->DB->real_escape_string($warenkorb['titel'])."' WHERE id = '$adresse' LIMIT 1");
- }
- if(isset($warenkorb['ust_befreit']))
- {
- $this->app->DB->Update("UPDATE adresse SET ust_befreit = '".(int)$warenkorb['ust_befreit']."' WHERE id = '$adresse' LIMIT 1");
- }
- if($warenkorb['mobil'] != ''){
- $this->app->DB->Update("UPDATE adresse SET mobil = '".$this->app->DB->real_escape_string($warenkorb['mobil'])."' WHERE id = '$adresse' LIMIT 1");
- }
- if(!empty($warenkorb['geburtstag'])){
- $query = sprintf("UPDATE `adresse` SET `geburtstag` = '%s' WHERE `id` = %d",
- $this->app->DB->real_escape_string($warenkorb['geburtstag']),
- $adresse);
- $this->app->DB->Update($query);
- }
- $kundenGruppen = $this->app->DB->SelectArr("SELECT gruppeid,type FROM shopexport_kundengruppen WHERE shopid=$shopid AND aktiv=1 AND apply_to_new_customers=1 AND (projekt=0 OR projekt='$projekt')");
- if(!empty($kundenGruppen)){
- foreach ($kundenGruppen as $gruppe){
- $this->app->erp->AddRolleZuAdresse($adresse, $gruppe['type'], 'von', 'Gruppe', $gruppe['gruppeid']);
- }
- }
- if(isset($warenkorb['kundengruppe'])){
- $this->shopimportAdresseGruppenMapping($warenkorb['kundengruppe'],$adresse,$shopid,$projekt);
- }
- if($shopexportArr['vertrieb']) {
- $this->app->DB->Update(
- sprintf(
- 'UPDATE adresse SET vertrieb = %d WHERE id = %d AND geloescht <> 1 AND vertrieb = 0',
- $shopexportArr['vertrieb'], $adresse
- )
- );
- }
- $this->app->DB->Update(
- sprintf(
- 'UPDATE adresse SET fromshop = %d WHERE fromshop = 0 AND id = %d',
- $shopexportArr['id'], $adresse
- )
- );
- } else {
- // Update + protokoll
- if(!$this->app->DB->Select("SELECT adressennichtueberschreiben FROM shopexport WHERE id = '$shopid' LIMIT 1"))
- {
- $this->app->erp->KundeUpdate($adresse,$typ,$name,$abteilung,
- $unterabteilung,$ansprechpartner,$adresszusatz,$strasse,$land,$plz,$ort,$email,$telefon,$telefax,$ustid,$partner,$projekt);
- if(!empty($warenkorb['bundesland']))
- {
- $this->app->DB->Update("UPDATE adresse SET bundesland = '".$this->app->DB->real_escape_string($warenkorb['bundesland'])."' WHERE id = '$adresse' LIMIT 1");
+ if (empty($adresse)) {
+ $adresse = $this->app->DB->Select("SELECT id FROM adresse WHERE email='{$warenkorb['email']}' and email <> '' $adresseprojekt AND geloescht!=1 LIMIT 1");
}
- }
- }
- // abweichende lieferadresse gleich angelegen?
- if(strlen($warenkorb['lieferadresse_ansprechpartner'])>3)
- {
- $this->app->DB->Insert("INSERT INTO lieferadressen (typ,name,abteilung,unterabteilung,land,strasse,ort,plz,adresszusatz,adresse) VALUES
+
+ if ($adresse <= 0) {
+ $adresse = $this->app->erp->KundeAnlegen($typ, $name, $abteilung,
+ $unterabteilung, $ansprechpartner, $adresszusatz, $strasse, $land, $plz, $ort, $email, $telefon, $telefax, $ustid, $partner, $projekt);
+ $warenkorb['customer_created'] = true;
+ if (!empty($warenkorb['bundesland'])) {
+ $this->app->DB->Update("UPDATE adresse SET bundesland = '" . $this->app->DB->real_escape_string($warenkorb['bundesland']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+
+ if (isset($warenkorb['kunde_sprache'])) {
+ if ($warenkorb['kunde_sprache'] === 'englisch' || $warenkorb['kunde_sprache'] === 'english') {
+ $this->app->DB->Update("UPDATE adresse SET sprache = 'englisch' WHERE id = '$adresse' LIMIT 1");
+ } elseif ($warenkorb['kunde_sprache'] === 'deutsch' || $warenkorb['kunde_sprache'] === 'german') {
+ $this->app->DB->Update("UPDATE adresse SET sprache = 'deutsch' WHERE id = '$adresse' LIMIT 1");
+ } elseif (method_exists($this->app->erp, 'GetAdressSprachen')) {
+ $sprachen = $this->app->erp->GetAdressSprachen();
+ if (isset($sprachen[strtolower($warenkorb['kunde_sprache'])])) {
+ $this->app->DB->Update("UPDATE adresse SET sprache = '" . strtolower($warenkorb['kunde_sprache']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ }
+ }
+ if ($warenkorb['titel'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET titel = '" . $this->app->DB->real_escape_string($warenkorb['titel']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if (isset($warenkorb['ust_befreit'])) {
+ $this->app->DB->Update("UPDATE adresse SET ust_befreit = '" . (int) $warenkorb['ust_befreit'] . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if ($warenkorb['mobil'] != '') {
+ $this->app->DB->Update("UPDATE adresse SET mobil = '" . $this->app->DB->real_escape_string($warenkorb['mobil']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ if (!empty($warenkorb['geburtstag'])) {
+ $query = sprintf("UPDATE `adresse` SET `geburtstag` = '%s' WHERE `id` = %d",
+ $this->app->DB->real_escape_string($warenkorb['geburtstag']),
+ $adresse);
+ $this->app->DB->Update($query);
+ }
+ $kundenGruppen = $this->app->DB->SelectArr("SELECT gruppeid,type FROM shopexport_kundengruppen WHERE shopid=$shopid AND aktiv=1 AND apply_to_new_customers=1 AND (projekt=0 OR projekt='$projekt')");
+ if (!empty($kundenGruppen)) {
+ foreach ($kundenGruppen as $gruppe) {
+ $this->app->erp->AddRolleZuAdresse($adresse, $gruppe['type'], 'von', 'Gruppe', $gruppe['gruppeid']);
+ }
+ }
+
+ if (isset($warenkorb['kundengruppe'])) {
+ $this->shopimportAdresseGruppenMapping($warenkorb['kundengruppe'], $adresse, $shopid, $projekt);
+ }
+ if ($shopexportArr['vertrieb']) {
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE adresse SET vertrieb = %d WHERE id = %d AND geloescht <> 1 AND vertrieb = 0',
+ $shopexportArr['vertrieb'], $adresse
+ )
+ );
+ }
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE adresse SET fromshop = %d WHERE fromshop = 0 AND id = %d',
+ $shopexportArr['id'], $adresse
+ )
+ );
+ } else {
+ // Update + protokoll
+ if (!$this->app->DB->Select("SELECT adressennichtueberschreiben FROM shopexport WHERE id = '$shopid' LIMIT 1")) {
+ $this->app->erp->KundeUpdate($adresse, $typ, $name, $abteilung,
+ $unterabteilung, $ansprechpartner, $adresszusatz, $strasse, $land, $plz, $ort, $email, $telefon, $telefax, $ustid, $partner, $projekt);
+ if (!empty($warenkorb['bundesland'])) {
+ $this->app->DB->Update("UPDATE adresse SET bundesland = '" . $this->app->DB->real_escape_string($warenkorb['bundesland']) . "' WHERE id = '$adresse' LIMIT 1");
+ }
+ }
+ }
+ // abweichende lieferadresse gleich angelegen?
+ if (strlen($warenkorb['lieferadresse_ansprechpartner']) > 3) {
+ $this->app->DB->Insert("INSERT INTO lieferadressen (typ,name,abteilung,unterabteilung,land,strasse,ort,plz,adresszusatz,adresse) VALUES
('','{$warenkorb['lieferadresse_ansprechpartner']}',
'{$warenkorb['lieferadresse_abteilung']}','{$warenkorb['lieferadresse_unterabteilung']}','{$warenkorb['lieferadresse_land']}',
'{$warenkorb['lieferadresse_strasse']}','{$warenkorb['lieferadresse_ort']}','{$warenkorb['lieferadresse_plz']}','{$warenkorb['lieferadresse_adresszusatz']}','$adresse')");
- }
+ }
- if(strlen($warenkorb['lieferadresse_name'])>3 && $warenkorb['lieferadresse_ansprechpartner']=='')
- {
- $this->app->DB->Insert("INSERT INTO lieferadressen (typ,name,abteilung,unterabteilung,land,strasse,ort,plz,adresszusatz,adresse) VALUES
+ if (strlen($warenkorb['lieferadresse_name']) > 3 && $warenkorb['lieferadresse_ansprechpartner'] == '') {
+ $this->app->DB->Insert("INSERT INTO lieferadressen (typ,name,abteilung,unterabteilung,land,strasse,ort,plz,adresszusatz,adresse) VALUES
('','{$warenkorb['lieferadresse_name']}',
'{$warenkorb['lieferadresse_abteilung']}','{$warenkorb['lieferadresse_unterabteilung']}','{$warenkorb['lieferadresse_land']}',
'{$warenkorb['lieferadresse_strasse']}','{$warenkorb['lieferadresse_ort']}','{$warenkorb['lieferadresse_plz']}','{$warenkorb['lieferadresse_adresszusatz']}','$adresse')");
+ }
}
- }
- //print_r($warenkorb);
- //echo " Ende";
- //exit;
- //imort auf kunde
- //$bekanntezahlungsweisen = array('rechnung','vorkasse','nachnahme','kreditkarte','einzugsermaechtigung','bar','paypal','amazon','amazon_bestellung','sofortueberweisung','amazoncba','secupay','lastschrift');
+ //print_r($warenkorb);
+ //echo " Ende";
+ //exit;
+ //imort auf kunde
+ //$bekanntezahlungsweisen = array('rechnung','vorkasse','nachnahme','kreditkarte','einzugsermaechtigung','bar','paypal','amazon','amazon_bestellung','sofortueberweisung','amazoncba','secupay','lastschrift');
- $bekanntezahlungsweisen = $this->app->erp->GetZahlungsweise();
+ $bekanntezahlungsweisen = $this->app->erp->GetZahlungsweise();
- $tmpauftragid = $this->app->erp->ImportAuftrag($adresse,$warenkorb,$projekt,$shopid);
- if ($tmpauftragid > 0) {
- $sucess_import = true;
- }
-
- $doctype = 'auftrag';
- if($this->app->DB->Select("SELECT angeboteanlegen FROM shopexport WHERE id = '$shopid' LIMIT 1"))
- {
- $doctype = 'angebot';
- }
+ $import_result = $this->app->erp->ImportAuftrag($adresse, $warenkorb, $projekt, $shopid);
- if(isset($warenkorb['doctype']) && $warenkorb['doctype']==='angebot'){
- $doctype = 'angebot';
- }
+ if ($import_result['status']) {
+ $tmpauftragid = $import_result['auftragid'];
+ $success_import = true;
- $warenkorb['zahlungsweise'] = $this->app->DB->Select("SELECT zahlungsweise FROM $doctype WHERE id = '$tmpauftragid' LIMIT 1");
- if($warenkorb['zahlungsweise'] != ''){
- if(!isset($bekanntezahlungsweisen[$warenkorb['zahlungsweise']])){
- if(!$unbekanntezahlungsweisen || !isset($unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])])){
- $unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])] = false;
- }
- $tmp = array();
- $tmp['bestellnummer'] = $warenkorb['onlinebestellnummer'];
- $unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])][] = $tmp;
+ $doctype = 'auftrag';
+ if ($this->app->DB->Select("SELECT angeboteanlegen FROM shopexport WHERE id = '$shopid' LIMIT 1")) {
+ $doctype = 'angebot';
+ }
+
+ if (isset($warenkorb['doctype']) && $warenkorb['doctype'] === 'angebot') {
+ $doctype = 'angebot';
+ }
+
+ $warenkorb['zahlungsweise'] = $this->app->DB->Select("SELECT zahlungsweise FROM $doctype WHERE id = '$tmpauftragid' LIMIT 1");
+ if ($warenkorb['zahlungsweise'] != '') {
+ if (!isset($bekanntezahlungsweisen[$warenkorb['zahlungsweise']])) {
+ if (!$unbekanntezahlungsweisen || !isset($unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])])) {
+ $unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])] = false;
+ }
+ $tmp = array();
+ $tmp['bestellnummer'] = $warenkorb['onlinebestellnummer'];
+ $unbekanntezahlungsweisen[strtolower($warenkorb['zahlungsweise'])][] = $tmp;
+ }
+ }
+
+ if ($shopimportid && $tmpauftragid) {
+ $this->app->DB->Update("UPDATE shopimport_auftraege SET imported='1' WHERE id='$shopimportid' LIMIT 1");
+ }
+ if ($shopimportid) {
+ $shopextid = $this->app->DB->real_escape_string($this->app->DB->Select("SELECT extid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1"));
+ }
+ if ($shopextid) {
+ $this->app->DB->Select("UPDATE $doctype SET shopextid='$shopextid' WHERE id='$tmpauftragid' LIMIT 1");
+ }
+ $this->app->erp->RunHook('Shopimportwarenkorb', 4, $doctype, $tmpauftragid, $shopid, $warenkorb);
+ $this->app->erp->RunHook('Shopimport', 3, $doctype, $tmpauftragid, $shopid);
+ $adresse = '';
+ } else {
+ // Error...
}
- }
-
- if($shopimportid && $tmpauftragid)
- {
- $this->app->DB->Update("UPDATE shopimport_auftraege SET imported='1' WHERE id='$shopimportid' LIMIT 1");
- }
- if($shopimportid)
- {
- $shopextid = $this->app->DB->real_escape_string($this->app->DB->Select("SELECT extid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1"));
- }
- if($shopextid)
- {
- $this->app->DB->Select("UPDATE $doctype SET shopextid='$shopextid' WHERE id='$tmpauftragid' LIMIT 1");
- }
- $this->app->erp->RunHook('Shopimportwarenkorb', 4, $doctype, $tmpauftragid, $shopid, $warenkorb);
- $this->app->erp->RunHook('Shopimport', 3, $doctype, $tmpauftragid, $shopid);
- $adresse ='';
- return $sucess_import;
- }
-
- /**
- * @param String $gruppenBezeichnung im Shop
- * @param int $adresseId
- * @param int $shopId
- * @param int $projektId
- *
- * @return string
- */
- private function shopimportAdresseGruppenMapping($gruppenBezeichnung, $adresseId, $shopId, $projektId){
- $kundenGruppen = $this->getShopimportKundenGruppenZuordnungen($gruppenBezeichnung, $shopId, $projektId);
- if(empty($kundenGruppen)) {
- return '';
- }
- foreach ($kundenGruppen as $gruppe => $rolle){
- $this->app->erp->AddRolleZuAdresse($adresseId, $rolle, 'von', 'Gruppe', $gruppe);
+ return $success_import;
}
- return '';
- }
+ /**
+ * @param String $gruppenBezeichnung im Shop
+ * @param int $adresseId
+ * @param int $shopId
+ * @param int $projektId
+ *
+ * @return string
+ */
+ private function shopimportAdresseGruppenMapping($gruppenBezeichnung, $adresseId, $shopId, $projektId) {
+ $kundenGruppen = $this->getShopimportKundenGruppenZuordnungen($gruppenBezeichnung, $shopId, $projektId);
+ if (empty($kundenGruppen)) {
+ return '';
+ }
+ foreach ($kundenGruppen as $gruppe => $rolle) {
+ $this->app->erp->AddRolleZuAdresse($adresseId, $rolle, 'von', 'Gruppe', $gruppe);
+ }
- /**
- * @param String $gruppenBezeichnung im Shop
- * @param int $shopId
- * @param int $projektId
- *
- * @return array
- */
- private function getShopimportKundenGruppenZuordnungen($gruppenBezeichnung, $shopId, $projektId){
- $gefundeneGruppen = $this->app->DB->SelectArr("SELECT gruppeid, type FROM shopexport_kundengruppen WHERE shopid='$shopId' AND extgruppename='$gruppenBezeichnung' AND projekt='$projektId'");
-
- if(empty($gefundeneGruppen)){
- //Fallback, falls kein projektspezifisches Mapping gefunden
- $gefundeneGruppen = $this->app->DB->SelectArr("SELECT gruppeid, type FROM shopexport_kundengruppen WHERE shopid='$shopId' AND extgruppename='$gruppenBezeichnung' AND projekt='0'");
+ return '';
}
- if(empty($gefundeneGruppen)) {
- return [];
+ /**
+ * @param String $gruppenBezeichnung im Shop
+ * @param int $shopId
+ * @param int $projektId
+ *
+ * @return array
+ */
+ private function getShopimportKundenGruppenZuordnungen($gruppenBezeichnung, $shopId, $projektId) {
+ $gefundeneGruppen = $this->app->DB->SelectArr("SELECT gruppeid, type FROM shopexport_kundengruppen WHERE shopid='$shopId' AND extgruppename='$gruppenBezeichnung' AND projekt='$projektId'");
+
+ if (empty($gefundeneGruppen)) {
+ //Fallback, falls kein projektspezifisches Mapping gefunden
+ $gefundeneGruppen = $this->app->DB->SelectArr("SELECT gruppeid, type FROM shopexport_kundengruppen WHERE shopid='$shopId' AND extgruppename='$gruppenBezeichnung' AND projekt='0'");
+ }
+
+ if (empty($gefundeneGruppen)) {
+ return [];
+ }
+
+ $kundenGruppen = [];
+ foreach ($gefundeneGruppen as $gruppe) {
+ $kundenGruppen[$gruppe['gruppeid']] = $gruppe['type'];
+ }
+
+ return $kundenGruppen;
}
- $kundenGruppen = [];
- foreach ($gefundeneGruppen as $gruppe){
- $kundenGruppen[$gruppe['gruppeid']] = $gruppe['type'];
+ /**
+ * @param $shopImportedOrderId
+ *
+ * @return bool
+ */
+ public function setShopImportedOrderTrash($shopImportedOrderId) {
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE shopimport_auftraege SET trash=1 WHERE id= %d LIMIT 1',
+ (int) $shopImportedOrderId
+ )
+ );
+ return $this->app->DB->affected_rows() > 0;
}
- return $kundenGruppen;
- }
+ public function importShopOrder($shopImportedOrderId, $utf8coding, $customerNumber, $custumerNumberImported, &$unknownPaymentTypes) {
+ $shopImportedOrder = $this->app->DB->SelectRow(
+ sprintf(
+ 'SELECT * FROM shopimport_auftraege WHERE imported=0 AND trash=0 AND id=%d LIMIT 1',
+ $shopImportedOrderId
+ )
+ );
+ if (empty($shopImportedOrder)) {
+ return ['success' => 0];
+ }
- /**
- * @param $shopImportedOrderId
- *
- * @return bool
- */
- public function setShopImportedOrderTrash($shopImportedOrderId) {
- $this->app->DB->Update(
- sprintf(
- 'UPDATE shopimport_auftraege SET trash=1 WHERE id= %d LIMIT 1',
- (int)$shopImportedOrderId
- )
- );
- return $this->app->DB->affected_rows() > 0;
- }
+ if (isset($shopImportedOrder['jsonencoded']) && $shopImportedOrder['jsonencoded']) {
+ $shopOrder = json_decode(base64_decode($shopImportedOrder['warenkorb']), true);
+ } else {
+ $shopOrder = unserialize(base64_decode($shopImportedOrder['warenkorb']));
+ }
- public function importShopOrder($shopImportedOrderId, $utf8coding, $customerNumber, $custumerNumberImported, &$unknownPaymentTypes) {
- $shopImportedOrder = $this->app->DB->SelectRow(
- sprintf(
- 'SELECT * FROM shopimport_auftraege WHERE imported=0 AND trash=0 AND id=%d LIMIT 1',
- $shopImportedOrderId
- )
- );
- if(empty($shopImportedOrder)) {
- return ['success' => 0];
+ //alle leerzeichen am amfang und ende entfernen + umbrueche komplett entfernen
+ if ($utf8coding == '1') {
+ $shopOrderCleaned = $this->app->erp->CleanDataBeforImportUTF8($shopOrder, false);
+ } else {
+ $shopOrderCleaned = $this->app->erp->CleanDataBeforImport($shopOrder, false);
+ }
+ if ($shopOrderCleaned['name'] === '') {
+ $shopOrderCleaned['name'] = $shopOrderCleaned['ansprechpartner'];
+ $shopOrderCleaned['ansprechpartner'] = '';
+ }
+ if ($shopOrderCleaned['lieferadresse_name'] === '') {
+ $shopOrderCleaned['lieferadresse_name'] = $shopOrderCleaned['lieferadresse_ansprechpartner'];
+ $shopOrderCleaned['lieferadresse_ansprechpartner'] = '';
+ }
+
+ if ($shopOrderCleaned['name'] === '' && !empty($shopOrderCleaned['lieferadresse_name'])) {
+ $shopOrderCleaned['name'] = $shopOrderCleaned['lieferadresse_name'];
+ }
+
+ foreach ($shopOrderCleaned as $k => $v) {
+ if (!is_array($v)) {
+ $shopOrderCleaned[$k] = $this->app->erp->fixeUmlaute($v);
+ }
+ }
+ $umlautefehler = false;
+ if ((String) $shopOrder['name'] !== '' && (String) $shopOrderCleaned['name'] === '') {
+ $umlautefehler = true;
+ $this->app->erp->LogFile('Kodierungsfehler in shopimport_auftraege ' . $shopImportedOrderId);
+ }
+ $succes = $this->KundeAnlegenUpdate($shopImportedOrderId, '', $shopOrderCleaned, $customerNumber, $custumerNumberImported, $unknownPaymentTypes);
+
+ return ['codingerror' => $umlautefehler, 'success' => $succes];
}
- if(isset($shopImportedOrder['jsonencoded']) && $shopImportedOrder['jsonencoded'])
- {
- $shopOrder = json_decode(base64_decode($shopImportedOrder['warenkorb']), true);
- }else{
- $shopOrder = unserialize(base64_decode($shopImportedOrder['warenkorb']));
+ public function ShopimportView() {
+ $this->ShopimportImport(showonly: true);
}
- //alle leerzeichen am amfang und ende entfernen + umbrueche komplett entfernen
- if($utf8coding=='1')
- {
- $shopOrderCleaned = $this->app->erp->CleanDataBeforImportUTF8($shopOrder, false);
- } else {
- $shopOrderCleaned = $this->app->erp->CleanDataBeforImport($shopOrder, false);
- }
- if($shopOrderCleaned['name']===''){
- $shopOrderCleaned['name']=$shopOrderCleaned['ansprechpartner'];
- $shopOrderCleaned['ansprechpartner'] = '';
- }
- if($shopOrderCleaned['lieferadresse_name']==='')
- {
- $shopOrderCleaned['lieferadresse_name']=$shopOrderCleaned['lieferadresse_ansprechpartner'];
- $shopOrderCleaned['lieferadresse_ansprechpartner'] = '';
- }
-
- if($shopOrderCleaned['name']==='' && !empty($shopOrderCleaned['lieferadresse_name']))
- {
- $shopOrderCleaned['name'] = $shopOrderCleaned['lieferadresse_name'];
- }
-
- foreach($shopOrderCleaned as $k => $v)
- {
- if(!is_array($v)){
- $shopOrderCleaned[$k] = $this->app->erp->fixeUmlaute($v);
- }
- }
- $umlautefehler = false;
- if((String)$shopOrder['name'] !== '' && (String)$shopOrderCleaned['name'] === '')
- {
- $umlautefehler = true;
- $this->app->erp->LogFile('Kodierungsfehler in shopimport_auftraege '.$shopImportedOrderId);
- }
- $succes = $this->KundeAnlegenUpdate($shopImportedOrderId,'', $shopOrderCleaned, $customerNumber, $custumerNumberImported,$unknownPaymentTypes);
-
- return ['codingerror'=>$umlautefehler, 'success' => $succes];
- }
-
- public function ShopimportView() {
- $this->ShopimportImport(showonly: true);
- }
-
- public function ShopimportImport($id='', $count = 0, $returncount = false, $showonly = false)
- {
- $deletedRows = 0;
- if(!is_numeric($id) && $this->app->Secure->GetPOST('deletedouble')) {
- $id = (int)$this->app->Secure->GetGET('id');
- $this->app->DB->Update(
- sprintf(
- 'UPDATE shopimport_auftraege AS sa
+ public function ShopimportImport($id = '', $count = 0, $returncount = false, $showonly = false) {
+ $deletedRows = 0;
+ if (!is_numeric($id) && $this->app->Secure->GetPOST('deletedouble')) {
+ $showonly = true;
+ $id = (int) $this->app->Secure->GetGET('id');
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE shopimport_auftraege AS sa
INNER JOIN auftrag a ON sa.bestellnummer = a.internet AND sa.shopid = a.shop
SET sa.trash = 1
WHERE IFNULL(a.internet,\'\') <> \'\' AND sa.trash = 0 AND sa.imported = 0 AND
(sa.shopid = %d OR %d = 0)',
- $id, $id
- )
- );
- $deletedRows = (int)$this->app->DB->affected_rows();
- $this->app->Tpl->Add('IMPORT','Es wurden '.$deletedRows.' bereits importierte Datensätze entfernt.
');
- }
- $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
- if($runningcronjob && !$showonly)
- {
- $this->app->Location->execute('index.php?module=shopimport&action=list');
- }
- if(!is_numeric($id)){
- $id = $this->app->Secure->GetGET('id');
- }
-
- $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id'");
- $projekt = $shopexportarr['projekt'];//$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$id'");
- $demomodus = $shopexportarr['demomodus'];//$this->app->DB->Select("SELECT demomodus FROM shopexport WHERE id='$id'");
- $einzelsync = $shopexportarr['einzelsync'];//$this->app->DB->Select("SELECT einzelsync FROM shopexport WHERE id='$id'");
- $utf8codierung = $shopexportarr['utf8codierung'];//$this->app->DB->Select("SELECT utf8codierung FROM shopexport WHERE id='$id'");
-
- if(!$returncount)
- {
- $this->app->erp->Headlines('Shopimport');
- $this->app->erp->MenuEintrag('index.php?module=shopimport&action=list','Zurück zur Übersicht');
- }
- //name, strasse, ort, plz und kundenummer, emailadresse oder bestellung kam von login account ==> Kunde aus DB verwenden
- //ACHTUNG Lieferadresse immer aus Auftrag!!! aber Lieferadresse extra bei Kunden anlegen
- if($this->app->Secure->GetPOST('submit')!='')
- {
- $auftraege = $this->app->Secure->GetPOST('auftrag');
- $kundennummer = $this->app->Secure->GetPOST('kundennummer');
- $import= $this->app->Secure->GetPOST('import');
- $import_kundennummer= $this->app->Secure->GetPOST('import_kundennummer');
-
- $sucess_import = 0;
- $insgs_import = 0;
- $unbekanntezahlungsweisen = null;
- $cauftraege = $auftraege?count($auftraege):0;
- for($i=0;$i<$cauftraege;$i++)
- {
- $adresse = '';
- $shopimportid = $auftraege[$i];
- $shopid = $this->app->DB->Select("SELECT shopid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
- if($shopid)
- {
- $demomodus = $this->app->DB->Select("SELECT demomodus FROM shopexport WHERE id='$shopid'");
- $einzelsync = $this->app->DB->Select("SELECT einzelsync FROM shopexport WHERE id='$shopid'");
- $utf8codierung = $this->app->DB->Select("SELECT utf8codierung FROM shopexport WHERE id='$shopid'");
- }
- $projekt = $this->app->DB->Select("SELECT projekt FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
- if($import[$shopimportid]==='warten')
- {
-
- }
- else if($import[$shopimportid]==='muell')
- {
- $this->setShopImportedOrderTrash($shopimportid);
- } else if($import[$shopimportid]==='import') {
-
- $res = $this->importShopOrder($shopimportid, $utf8codierung, $kundennummer[$shopimportid], $import_kundennummer[$shopimportid], $unbekanntezahlungsweisen);
- if($res['codingerror']) {
- $umlautefehler = true;
- }
- if($res['success']) {
- $sucess_import += $res['success'];
- }
- $insgs_import++;
- }
- } // ende for
-
-
- if($unbekanntezahlungsweisen)
- {
- $meldung = '';
- foreach($unbekanntezahlungsweisen as $k => $v)
- {
- $meldung .= 'Unbekannte Zahlungsart: '.$k.' in Bestellung(en): ';
- $first = true;
- foreach($v as $k2 => $v2)
- {
- if(!$first)
- {
- $meldung .= ', ';
- }
- $first = false;
- $meldung .= $v2['bestellnummer'];
-
- }
- $meldung .= " \r\n";
-
- }
-
- if(isset($this->app->User) && method_exists($this->app->User,'GetID') && $this->app->User->GetID())
- {
- $this->app->erp->EventMitSystemLog($this->app->User->GetID(), $meldung, -1,'', 'warning', 1);
- }
- }
- if(!empty($umlautefehler))
- {
- $msg = $this->app->erp->base64_url_encode("$sucess_import".($sucess_import != $insgs_import?" von $insgs_import ":'')." Aufträge importiert. Aufträge mit Kodierungsprobleme. Bitte prüfen Sie sie UTF8-Einstellung in der Shopschnittstelle!
");
- }else{
- $msg = $this->app->erp->base64_url_encode("$sucess_import".($sucess_import != $insgs_import?" von $insgs_import ":'')." Aufträge importiert!
");
- }
- $this->app->Location->execute('index.php?module=shopimport&action=list&msg='.$msg);
- }
-
-
- if(!$showonly && $id)
- {
- try {
- $pageContents = $this->app->remote->RemoteConnection($id);
- }catch(Exception $e){
- $pageContents = $e->getMessage();
- }
- if($pageContents==='success')
- {
- $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
- $holealle = $shopexportarr['holealle'];//$this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$id' LIMIT 1");
- $statusaendern = $shopexportarr['nummersyncstatusaendern'];//$this->app->DB->Select("SELECT nummersyncstatusaendern FROM shopexport WHERE id = '$id' LIMIT 1");
- $auftragabgleich = $shopexportarr['auftragabgleich'];//$this->app->DB->Select("SELECT auftragabgleich FROM shopexport WHERE id = '$id' LIMIT 1");
- $zeitraum = array('datumvon'=>$shopexportarr['datumvon'], 'datumbis'=>$shopexportarr['datumbis'],'tmpdatumvon'=>$shopexportarr['tmpdatumvon'], 'tmpdatumbis'=>$shopexportarr['tmpdatumbis'], 'anzgleichzeitig'=>$shopexportarr['anzgleichzeitig']);
- //$this->app->DB->SelectArr("SELECT datumvon, datumbis,tmpdatumvon, tmpdatumbis, anzgleichzeitig FROM shopexport WHERE id = '$id' LIMIT 1");
- /*if(!empty($zeitraum))
- {
- $zeitraum = reset($zeitraum);
- }*/
- $anzgleichzeitig = 1;
- if(isset($zeitraum['anzgleichzeitig'])){
- $anzgleichzeitig = (int)$zeitraum['anzgleichzeitig'];
- }
-
- if($anzgleichzeitig > 1)
- {
- $result = $this->app->remote->RemoteGetAuftrag($id);
- if(!empty($result) && is_array($result) && isset($result[0]))
- {
- $maxtime = false;
- $mintime = false;
- $gesamtanzahl = (!empty($result)?count($result):0);
- for($i = 0; $i < $gesamtanzahl; $i++)
- {
- $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
- $auftrag = $result[$i]['id'];
- if(isset($result[$i]['warenkorbjson']))
- {
- $isjson = true;
- $tmpwarenkorb = json_decode(base64_decode($result[$i]['warenkorbjson']), true);
- }else{
- $isjson = false;
- $tmpwarenkorb = unserialize(base64_decode($result[$i]['warenkorb']));
- }
- if(!empty($tmpwarenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '".(int)$tmpwarenkorb['projekt']."' LIMIT 1"))
- {
- $projekt = (int)$tmpwarenkorb['projekt'];
- }
- if(!empty($tmpwarenkorb['zeitstempel']))
- {
- $time = strtotime($tmpwarenkorb['zeitstempel']);
- if($time < 0)
- {
- $time = 0;
- }
- if($maxtime === false)
- {
- $maxtime = $time;
- }
- if($mintime === false)
- {
- $mintime = $time;
- }
- if($time > $maxtime)
- {
- $maxtime = $time;
- }
- if($time < $mintime)
- {
- $mintime = $time;
- }
- }
- $onlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
- if(!empty($tmpwarenkorb['useorderid']) ||
- (!is_numeric($onlinebestellnummer) && trim((String)$onlinebestellnummer) !== ''))
- {
- $onlinebestellnummer = $tmpwarenkorb['auftrag'];
- }
-
- if($holealle && $onlinebestellnummer)
- {
- $neue_nummer = (int)$onlinebestellnummer+1;
- $this->app->DB->Update("UPDATE shopexport SET ab_nummer = '$neue_nummer' WHERE id = '$id'");
- }
- $sessionid = isset($result[$i]['sessionid'])?$result[$i]['sessionid']:'';
- if($isjson)
- {
- $warenkorb = $result[$i]['warenkorbjson'];
- }else{
- $warenkorb = $result[$i]['warenkorb'];
- }
- $logdatei = isset($result[$i]['logdatei'])?$result[$i]['logdatei']:null;
- if(empty($logdatei))
- {
- $logdatei = date('Y-m-d H:i:s');
- }
- if(isset($tmpwarenkorb['subshop']) && $tmpwarenkorb['subshop'])
- {
- $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '$id' AND aktiv = 1 AND subshopkennung = '".$this->app->DB->real_escape_string($tmpwarenkorb['subshop'])."' LIMIT 1");
- if($subshopprojekt)
- {
- $projekt = $subshopprojekt;
- }
- }
- $letzteonlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
- unset($tmpwarenkorb);
-
- //globalerauftragsnummernkreis
- $standardcheck = true;
- $modulename = $this->app->DB->Select(
- sprintf(
- "SELECT modulename FROM shopexport WHERE id = %d AND modulename <> '' AND (shoptyp = 'intern')",
- $id
- )
- );
- $shopIds = [$id];
- $otherModules= empty($modulename)?null:
- $this->app->DB->SelectFirstCols(
- sprintf(
- "SELECT id
- FROM shopexport
- WHERE modulename = '%s' AND id <> %d",
- $this->app->DB->real_escape_string($modulename), $id
- )
- );
- if(!empty($otherModules) && $this->app->erp->ModulVorhanden($modulename)) {
- $obj = $this->app->erp->LoadModul($modulename);
- if(!empty($obj) && method_exists($obj, 'EinstellungenStruktur')){
- $konfiguration = $obj->EinstellungenStruktur();
- if($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis']) {
- $shopIds = array_merge([$id], $otherModules);
- $standardcheck = false;
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- }
- }
- }
- $checkdoppeltimported = $this->app->DB->Select(
- sprintf(
- "SELECT id
- FROM shopimport_auftraege
- WHERE extid = '%s' and shopid IN (%s) AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1",
- $this->app->DB->real_escape_string($auftrag), implode(',', $shopIds)
- )
- );
- /*if($standardcheck)
- {*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and shopid = '$id' and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and shopid = '$id' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");
- }*/
- $insid = null;
- if(empty($checkdoppeltimported))
- {
- $this->app->DB->Insert("INSERT INTO shopimport_auftraege (id,extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei)
- VALUES('','".$this->app->DB->real_escape_string($auftrag)."','".$this->app->DB->real_escape_string($sessionid)."','".$this->app->DB->real_escape_string($warenkorb)."','0','$projekt','".$this->app->DB->real_escape_string($this->app->User->GetName())."','".$this->app->DB->real_escape_string($logdatei)."')");
- $insid = $this->app->DB->GetInsertID();
- if($insid)
- {
- if($isjson)
- {
- $this->app->DB->Update("UPDATE shopimport_auftraege set jsonencoded = 1 where id = '$insid'");
- }
- $this->app->DB->Update("UPDATE shopimport_auftraege set shopid = '$id' where id = '$insid'");
- $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '".$this->app->DB->real_escape_string($letzteonlinebestellnummer)."' where id = '$insid'");
- }
- }
- if($demomodus!='1')
- {
- $this->app->remote->RemoteDeleteAuftrag($id,$auftrag,$letzteonlinebestellnummer);
- }
- elseif($demomodus == '1')
- {
- break;
- }
- unset($letzteonlinebestellnummer);
-
- }
- if(!$demomodus)
- {
- if(empty($maxtime))
- {
- $maxtime = strtotime(date('Y-m-d H:i:s'));
- }
- $datumvon = strtotime($zeitraum['datumvon']);
- $datumbis = strtotime($zeitraum['datumbis']);
- $tmpdatumvon = strtotime($zeitraum['tmpdatumvon']);
- $tmpdatumbis = strtotime($zeitraum['tmpdatumbis']);
- if($datumvon < 0){
- $datumvon = 0;
- }
- if($datumbis < 0){
- $datumbis = 0;
- }
- if($tmpdatumvon < 0){
- $tmpdatumvon = 0;
- }
- if($tmpdatumbis < 0)
- {
- $tmpdatumbis = 0;
- }
- $this->app->DB->Update("UPDATE shopexport SET datumvon = '".date('Y-m-d H:i:s',$maxtime)."', tmpdatumbis = '0000-00-00' WHERE id = '$id' LIMIT 1");
- }
- }else{
- if(!$demomodus)
- {
- if(is_array($result) && !empty($result['zeitstempel']))
- {
- $this->app->DB->Update("UPDATE shopexport SET datumvon = '".date('Y-m-d H:i:s',strtotime($result['zeitstempel']))."', tmpdatumbis = '0000-00-00' WHERE id = '$id' AND datumvon < '".date('Y-m-d H:i:s',strtotime($result['zeitstempel']))."' LIMIT 1");
- }
- if(empty($maxtime))
- {
- $maxtime = strtotime(date('Y-m-d H:i:s'));
- }
- $datumvon = strtotime($zeitraum['datumvon']);
- $datumbis = strtotime($zeitraum['datumbis']);
- $tmpdatumvon = strtotime($zeitraum['tmpdatumvon']);
- $tmpdatumbis = strtotime($zeitraum['tmpdatumbis']);
- if($datumvon < 0){
- $datumvon = 0;
- }
- if($datumbis < 0){
- $datumbis = 0;
- }
- if($tmpdatumvon < 0){
- $tmpdatumvon = 0;
- }
- if($tmpdatumbis < 0){
- $tmpdatumbis = 0;
- }
- if($tmpdatumbis)
- {
- $this->app->DB->Update("UPDATE shopexport SET tmpdatumbis = '0000-00-00' WHERE id = '$id' LIMIT 1");
- }
- }
- }
- }else{
- $gesamtanzahl = $this->app->remote->RemoteGetAuftraegeAnzahl($id);
- $maxmanuell = (int)$this->app->DB->Select("SELECT maxmanuell FROM shopexport WHERE id = '$id' LIMIT 1");
- if($maxmanuell <= 0){
- $maxmanuell = 100;
- }
- if($gesamtanzahl > $maxmanuell){
- $gesamtanzahl = $maxmanuell;
- }
- if($einzelsync=='1' && $gesamtanzahl > 1 && $maxmanuell <= 1){
- $gesamtanzahl = 1;
- }
- if($gesamtanzahl > 0)
- {
- for($i=0;$i<$gesamtanzahl;$i++)
- {
- //import au
- $result = $this->app->remote->RemoteGetAuftrag($id);
-
- if(is_array($result))
- {
- $auftrag = $result[0]['id'];
- if(isset($result[0]['warenkorbjson']))
- {
- $isjson = true;
- $tmpwarenkorb = json_decode(base64_decode($result[0]['warenkorbjson']), true);
- }else{
- $isjson = false;
- $tmpwarenkorb = unserialize(base64_decode($result[0]['warenkorb']));
- }
- $onlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
- if(!empty($tmpwarenkorb['useorderid']) || (!is_numeric($onlinebestellnummer) && trim((String)$onlinebestellnummer) !== ''))
- {
- $onlinebestellnummer = $tmpwarenkorb['auftrag'];
- }
- if($holealle && $onlinebestellnummer)
- {
- $neue_nummer = (int)$onlinebestellnummer+1;
- $this->app->DB->Update("UPDATE shopexport SET ab_nummer = '$neue_nummer' WHERE id = '$id'");
- }
- $sessionid = $result[0]['sessionid'];
- if($isjson)
- {
- $warenkorb = $result[0]['warenkorbjson'];
- }else{
- $warenkorb = $result[0]['warenkorb'];
- }
- $logdatei = $result[0]['logdatei'];
- if(empty($logdatei))
- {
- $logdatei = date('Y-m-d H:i:s');
- }
- $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
- if(!empty($tmpwarenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '".(int)$tmpwarenkorb['projekt']."' LIMIT 1"))
- {
- $projekt = (int)$tmpwarenkorb['projekt'];
- }
- if(isset($tmpwarenkorb['subshop']) && $tmpwarenkorb['subshop'])
- {
- $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '$id' AND aktiv = 1 AND subshopkennung = '".$this->app->DB->real_escape_string($tmpwarenkorb['subshop'])."' LIMIT 1");
- if($subshopprojekt)
- {
- $projekt = $subshopprojekt;
- }
- }
- unset($tmpwarenkorb);
-
- $standardcheck = true;
- $modulename = $this->app->DB->Select(
- sprintf(
- "SELECT modulename FROM shopexport WHERE id = %d AND modulename <> '' AND (shoptyp = 'intern')",
- $id
- )
- );
- $shopIds = [$id];
- $otherModules= empty($modulename)?null:
- $this->app->DB->SelectFirstCols(
- sprintf(
- "SELECT id
- FROM shopexport
- WHERE modulename = '%s' AND id <> %d",
- $this->app->DB->real_escape_string($modulename), $id
+ $id, $id
)
- );
- if(!empty($otherModules) && $this->app->erp->ModulVorhanden($modulename)) {
- $obj = $this->app->erp->LoadModul($modulename);
- if(!empty($obj) && method_exists($obj, 'EinstellungenStruktur')){
- $konfiguration = $obj->EinstellungenStruktur();
- if($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis']) {
- $shopIds = array_merge([$id], $otherModules);
- $standardcheck = false;
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- }
- }
+ );
+ $deletedRows = (int) $this->app->DB->affected_rows();
+ $this->app->Tpl->Add('IMPORT', 'Es wurden ' . $deletedRows . ' bereits importierte Datensätze entfernt.
');
+ }
+ $runningcronjob = $this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'shopimport' AND aktiv=1 AND mutex = 1 AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(letzteausfuerhung) < 300 LIMIT 1");
+ if ($runningcronjob && !$showonly) {
+ $this->app->Location->execute('index.php?module=shopimport&action=list');
+ }
+ if (!is_numeric($id)) {
+ $id = $this->app->Secure->GetGET('id');
+ }
+
+ $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id'");
+ $projekt = $shopexportarr['projekt']; //$this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$id'");
+ $demomodus = $shopexportarr['demomodus']; //$this->app->DB->Select("SELECT demomodus FROM shopexport WHERE id='$id'");
+ $einzelsync = $shopexportarr['einzelsync']; //$this->app->DB->Select("SELECT einzelsync FROM shopexport WHERE id='$id'");
+ $utf8codierung = $shopexportarr['utf8codierung']; //$this->app->DB->Select("SELECT utf8codierung FROM shopexport WHERE id='$id'");
+
+ if (!$returncount) {
+ $this->app->erp->Headlines('Shopimport');
+ $this->app->erp->MenuEintrag('index.php?module=shopimport&action=list', 'Zurück zur Übersicht');
+ }
+ //name, strasse, ort, plz und kundenummer, emailadresse oder bestellung kam von login account ==> Kunde aus DB verwenden
+ //ACHTUNG Lieferadresse immer aus Auftrag!!! aber Lieferadresse extra bei Kunden anlegen
+ if ($this->app->Secure->GetPOST('submit') != '') {
+ $auftraege = $this->app->Secure->GetPOST('auftrag');
+ $kundennummer = $this->app->Secure->GetPOST('kundennummer');
+ $import = $this->app->Secure->GetPOST('import');
+ $import_kundennummer = $this->app->Secure->GetPOST('import_kundennummer');
+
+ $success_import = 0;
+ $insgs_import = 0;
+ $unbekanntezahlungsweisen = null;
+ $cauftraege = $auftraege ? count($auftraege) : 0;
+ for ($i = 0; $i < $cauftraege; $i++) {
+ $adresse = '';
+ $shopimportid = $auftraege[$i];
+ $shopid = $this->app->DB->Select("SELECT shopid FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
+ if ($shopid) {
+ $demomodus = $this->app->DB->Select("SELECT demomodus FROM shopexport WHERE id='$shopid'");
+ $einzelsync = $this->app->DB->Select("SELECT einzelsync FROM shopexport WHERE id='$shopid'");
+ $utf8codierung = $this->app->DB->Select("SELECT utf8codierung FROM shopexport WHERE id='$shopid'");
}
- $checkdoppeltimported = $this->app->DB->Select(
- sprintf(
- "SELECT id
+ $projekt = $this->app->DB->Select("SELECT projekt FROM shopimport_auftraege WHERE id='$shopimportid' LIMIT 1");
+ if ($import[$shopimportid] === 'warten') {
+
+ } else if ($import[$shopimportid] === 'muell') {
+ $this->setShopImportedOrderTrash($shopimportid);
+ } else if ($import[$shopimportid] === 'import') {
+
+ $res = $this->importShopOrder($shopimportid, $utf8codierung, $kundennummer[$shopimportid], $import_kundennummer[$shopimportid], $unbekanntezahlungsweisen);
+ if ($res['codingerror']) {
+ $umlautefehler = true;
+ }
+ if ($res['success']) {
+ $success_import += $res['success'];
+ }
+ $insgs_import++;
+ }
+ } // ende for
+
+
+ if ($unbekanntezahlungsweisen) {
+ $meldung = '';
+ foreach ($unbekanntezahlungsweisen as $k => $v) {
+ $meldung .= 'Unbekannte Zahlungsart: ' . $k . ' in Bestellung(en): ';
+ $first = true;
+ foreach ($v as $k2 => $v2) {
+ if (!$first) {
+ $meldung .= ', ';
+ }
+ $first = false;
+ $meldung .= $v2['bestellnummer'];
+ }
+ $meldung .= " \r\n";
+ }
+
+ if (isset($this->app->User) && method_exists($this->app->User, 'GetID') && $this->app->User->GetID()) {
+ $this->app->erp->EventMitSystemLog($this->app->User->GetID(), $meldung, -1, '', 'warning', 1);
+ }
+ }
+ if (!empty($umlautefehler)) {
+ $msg = $this->app->erp->base64_url_encode("$success_import" . ($success_import != $insgs_import ? " von $insgs_import " : '') . " Aufträge importiert. Aufträge mit Kodierungsprobleme. Bitte prüfen Sie sie UTF8-Einstellung in der Shopschnittstelle!
");
+ } else {
+ $msg = $this->app->erp->base64_url_encode("$success_import" . ($success_import != $insgs_import ? " von $insgs_import " : '') . " Aufträge importiert!
");
+ }
+ $this->app->Location->execute('index.php?module=shopimport&action=list&msg=' . $msg);
+ }
+
+
+ if (!$showonly && $id) {
+ try {
+ $pageContents = $this->app->remote->RemoteConnection($id);
+ } catch (Exception $e) {
+ $pageContents = $e->getMessage();
+ }
+ if ($pageContents === 'success') {
+ $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
+ $holealle = $shopexportarr['holealle']; //$this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$id' LIMIT 1");
+ $statusaendern = $shopexportarr['nummersyncstatusaendern']; //$this->app->DB->Select("SELECT nummersyncstatusaendern FROM shopexport WHERE id = '$id' LIMIT 1");
+ $auftragabgleich = $shopexportarr['auftragabgleich']; //$this->app->DB->Select("SELECT auftragabgleich FROM shopexport WHERE id = '$id' LIMIT 1");
+ $zeitraum = array('datumvon' => $shopexportarr['datumvon'], 'datumbis' => $shopexportarr['datumbis'], 'tmpdatumvon' => $shopexportarr['tmpdatumvon'], 'tmpdatumbis' => $shopexportarr['tmpdatumbis'], 'anzgleichzeitig' => $shopexportarr['anzgleichzeitig']);
+ //$this->app->DB->SelectArr("SELECT datumvon, datumbis,tmpdatumvon, tmpdatumbis, anzgleichzeitig FROM shopexport WHERE id = '$id' LIMIT 1");
+ /* if(!empty($zeitraum))
+ {
+ $zeitraum = reset($zeitraum);
+ } */
+ $anzgleichzeitig = 1;
+ if (isset($zeitraum['anzgleichzeitig'])) {
+ $anzgleichzeitig = (int) $zeitraum['anzgleichzeitig'];
+ }
+
+ if ($anzgleichzeitig > 1) {
+ $result = $this->app->remote->RemoteGetAuftrag($id);
+ if (!empty($result) && is_array($result) && isset($result[0])) {
+ $maxtime = false;
+ $mintime = false;
+ $gesamtanzahl = (!empty($result) ? count($result) : 0);
+ for ($i = 0; $i < $gesamtanzahl; $i++) {
+ $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
+ $auftrag = $result[$i]['id'];
+ if (isset($result[$i]['warenkorbjson'])) {
+ $isjson = true;
+ $tmpwarenkorb = json_decode(base64_decode($result[$i]['warenkorbjson']), true);
+ } else {
+ $isjson = false;
+ $tmpwarenkorb = unserialize(base64_decode($result[$i]['warenkorb']));
+ }
+ if (!empty($tmpwarenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '" . (int) $tmpwarenkorb['projekt'] . "' LIMIT 1")) {
+ $projekt = (int) $tmpwarenkorb['projekt'];
+ }
+ if (!empty($tmpwarenkorb['zeitstempel'])) {
+ $time = strtotime($tmpwarenkorb['zeitstempel']);
+ if ($time < 0) {
+ $time = 0;
+ }
+ if ($maxtime === false) {
+ $maxtime = $time;
+ }
+ if ($mintime === false) {
+ $mintime = $time;
+ }
+ if ($time > $maxtime) {
+ $maxtime = $time;
+ }
+ if ($time < $mintime) {
+ $mintime = $time;
+ }
+ }
+ $onlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
+ if (!empty($tmpwarenkorb['useorderid']) ||
+ (!is_numeric($onlinebestellnummer) && trim((String) $onlinebestellnummer) !== '')) {
+ $onlinebestellnummer = $tmpwarenkorb['auftrag'];
+ }
+
+ if ($holealle && $onlinebestellnummer) {
+ $neue_nummer = (int) $onlinebestellnummer + 1;
+ $this->app->DB->Update("UPDATE shopexport SET ab_nummer = '$neue_nummer' WHERE id = '$id'");
+ }
+ $sessionid = isset($result[$i]['sessionid']) ? $result[$i]['sessionid'] : '';
+ if ($isjson) {
+ $warenkorb = $result[$i]['warenkorbjson'];
+ } else {
+ $warenkorb = $result[$i]['warenkorb'];
+ }
+ $logdatei = isset($result[$i]['logdatei']) ? $result[$i]['logdatei'] : null;
+ if (empty($logdatei)) {
+ $logdatei = date('Y-m-d H:i:s');
+ }
+ if (isset($tmpwarenkorb['subshop']) && $tmpwarenkorb['subshop']) {
+ $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '$id' AND aktiv = 1 AND subshopkennung = '" . $this->app->DB->real_escape_string($tmpwarenkorb['subshop']) . "' LIMIT 1");
+ if ($subshopprojekt) {
+ $projekt = $subshopprojekt;
+ }
+ }
+ $letzteonlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
+ unset($tmpwarenkorb);
+
+ //globalerauftragsnummernkreis
+ $standardcheck = true;
+ $modulename = $this->app->DB->Select(
+ sprintf(
+ "SELECT modulename FROM shopexport WHERE id = %d AND modulename <> '' AND (shoptyp = 'intern')",
+ $id
+ )
+ );
+ $shopIds = [$id];
+ $otherModules = empty($modulename) ? null :
+ $this->app->DB->SelectFirstCols(
+ sprintf(
+ "SELECT id
+ FROM shopexport
+ WHERE modulename = '%s' AND id <> %d",
+ $this->app->DB->real_escape_string($modulename), $id
+ )
+ );
+ if (!empty($otherModules) && $this->app->erp->ModulVorhanden($modulename)) {
+ $obj = $this->app->erp->LoadModul($modulename);
+ if (!empty($obj) && method_exists($obj, 'EinstellungenStruktur')) {
+ $konfiguration = $obj->EinstellungenStruktur();
+ if ($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis']) {
+ $shopIds = array_merge([$id], $otherModules);
+ $standardcheck = false;
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ }
+ }
+ }
+ $checkdoppeltimported = $this->app->DB->Select(
+ sprintf(
+ "SELECT id
FROM shopimport_auftraege
WHERE extid = '%s' and shopid IN (%s) AND trash = 0
AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
LIMIT 1",
- $this->app->DB->real_escape_string($auftrag), implode(',', $shopIds)
- )
- );
-
- /*if($standardcheck){*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '" . $this->app->DB->real_escape_string($auftrag) . "' and shopid = '$id' and warenkorb = '" . $this->app->DB->real_escape_string($warenkorb) . "' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");*/
- /*$checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '" . $this->app->DB->real_escape_string($auftrag) . "' and shopid = '$id' AND trash = 0
- AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
- LIMIT 1");
- }*/
-
- $insid = null;
- if($demomodus == '1')
- {
- $checkdoppeltimported = null;
- }
- if(!$checkdoppeltimported)
- {
- $this->app->DB->Insert("INSERT INTO shopimport_auftraege (id,extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei)
- VALUES('','$auftrag','$sessionid','$warenkorb','0','$projekt','".$this->app->User->GetName()."','$logdatei')");
- $insid = $this->app->DB->GetInsertID();
- if($insid){
- $this->app->DB->Update("UPDATE shopimport_auftraege set shopid = '$id' where id = '$insid'");
- $this->app->DB->Update("UPDATE shopimport_auftraege set logdatei = now() where id = '$insid' AND logdatei = '0000-00-00' OR logdatei > now()");
- if($isjson){
- $this->app->DB->Update("UPDATE shopimport_auftraege set jsonencoded = 1 where id = '$insid'");
+ $this->app->DB->real_escape_string($auftrag), implode(',', $shopIds)
+ )
+ );
+ /* if($standardcheck)
+ { */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and shopid = '$id' and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and shopid = '$id' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1");
+ } */
+ $insid = null;
+ if (empty($checkdoppeltimported)) {
+ $this->app->DB->Insert("INSERT INTO shopimport_auftraege (id,extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei)
+ VALUES('','" . $this->app->DB->real_escape_string($auftrag) . "','" . $this->app->DB->real_escape_string($sessionid) . "','" . $this->app->DB->real_escape_string($warenkorb) . "','0','$projekt','" . $this->app->DB->real_escape_string($this->app->User->GetName()) . "','" . $this->app->DB->real_escape_string($logdatei) . "')");
+ $insid = $this->app->DB->GetInsertID();
+ if ($insid) {
+ if ($isjson) {
+ $this->app->DB->Update("UPDATE shopimport_auftraege set jsonencoded = 1 where id = '$insid'");
+ }
+ $this->app->DB->Update("UPDATE shopimport_auftraege set shopid = '$id' where id = '$insid'");
+ $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '" . $this->app->DB->real_escape_string($letzteonlinebestellnummer) . "' where id = '$insid'");
+ }
+ }
+ if ($demomodus != '1') {
+ $this->app->remote->RemoteDeleteAuftrag($id, $auftrag, $letzteonlinebestellnummer);
+ } elseif ($demomodus == '1') {
+ break;
+ }
+ unset($letzteonlinebestellnummer);
+ }
+ if (!$demomodus) {
+ if (empty($maxtime)) {
+ $maxtime = strtotime(date('Y-m-d H:i:s'));
+ }
+ $datumvon = strtotime($zeitraum['datumvon']);
+ $datumbis = strtotime($zeitraum['datumbis']);
+ $tmpdatumvon = strtotime($zeitraum['tmpdatumvon']);
+ $tmpdatumbis = strtotime($zeitraum['tmpdatumbis']);
+ if ($datumvon < 0) {
+ $datumvon = 0;
+ }
+ if ($datumbis < 0) {
+ $datumbis = 0;
+ }
+ if ($tmpdatumvon < 0) {
+ $tmpdatumvon = 0;
+ }
+ if ($tmpdatumbis < 0) {
+ $tmpdatumbis = 0;
+ }
+ $this->app->DB->Update("UPDATE shopexport SET datumvon = '" . date('Y-m-d H:i:s', $maxtime) . "', tmpdatumbis = '0000-00-00' WHERE id = '$id' LIMIT 1");
+ }
+ } else {
+ if (!$demomodus) {
+ if (is_array($result) && !empty($result['zeitstempel'])) {
+ $this->app->DB->Update("UPDATE shopexport SET datumvon = '" . date('Y-m-d H:i:s', strtotime($result['zeitstempel'])) . "', tmpdatumbis = '0000-00-00' WHERE id = '$id' AND datumvon < '" . date('Y-m-d H:i:s', strtotime($result['zeitstempel'])) . "' LIMIT 1");
+ }
+ if (empty($maxtime)) {
+ $maxtime = strtotime(date('Y-m-d H:i:s'));
+ }
+ $datumvon = strtotime($zeitraum['datumvon']);
+ $datumbis = strtotime($zeitraum['datumbis']);
+ $tmpdatumvon = strtotime($zeitraum['tmpdatumvon']);
+ $tmpdatumbis = strtotime($zeitraum['tmpdatumbis']);
+ if ($datumvon < 0) {
+ $datumvon = 0;
+ }
+ if ($datumbis < 0) {
+ $datumbis = 0;
+ }
+ if ($tmpdatumvon < 0) {
+ $tmpdatumvon = 0;
+ }
+ if ($tmpdatumbis < 0) {
+ $tmpdatumbis = 0;
+ }
+ if ($tmpdatumbis) {
+ $this->app->DB->Update("UPDATE shopexport SET tmpdatumbis = '0000-00-00' WHERE id = '$id' LIMIT 1");
+ }
+ }
}
- }
- }
+ } else {
+ $gesamtanzahl = $this->app->remote->RemoteGetAuftraegeAnzahl($id);
+ $maxmanuell = (int) $this->app->DB->Select("SELECT maxmanuell FROM shopexport WHERE id = '$id' LIMIT 1");
+ if ($maxmanuell <= 0) {
+ $maxmanuell = 100;
+ }
+ if ($gesamtanzahl > $maxmanuell) {
+ $gesamtanzahl = $maxmanuell;
+ }
+ if ($einzelsync == '1' && $gesamtanzahl > 1 && $maxmanuell <= 1) {
+ $gesamtanzahl = 1;
+ }
+ if ($gesamtanzahl > 0) {
+ for ($i = 0; $i < $gesamtanzahl; $i++) {
+ //import au
+ $result = $this->app->remote->RemoteGetAuftrag($id);
- if($demomodus!='1')
- {
- $this->app->remote->RemoteDeleteAuftrag($id,$auftrag);
+ if (is_array($result)) {
+ $auftrag = $result[0]['id'];
+ if (isset($result[0]['warenkorbjson'])) {
+ $isjson = true;
+ $tmpwarenkorb = json_decode(base64_decode($result[0]['warenkorbjson']), true);
+ } else {
+ $isjson = false;
+ $tmpwarenkorb = unserialize(base64_decode($result[0]['warenkorb']));
+ }
+ $onlinebestellnummer = $tmpwarenkorb['onlinebestellnummer'];
+ if (!empty($tmpwarenkorb['useorderid']) || (!is_numeric($onlinebestellnummer) && trim((String) $onlinebestellnummer) !== '')) {
+ $onlinebestellnummer = $tmpwarenkorb['auftrag'];
+ }
+ if ($holealle && $onlinebestellnummer) {
+ $neue_nummer = (int) $onlinebestellnummer + 1;
+ $this->app->DB->Update("UPDATE shopexport SET ab_nummer = '$neue_nummer' WHERE id = '$id'");
+ }
+ $sessionid = $result[0]['sessionid'];
+ if ($isjson) {
+ $warenkorb = $result[0]['warenkorbjson'];
+ } else {
+ $warenkorb = $result[0]['warenkorb'];
+ }
+ $logdatei = $result[0]['logdatei'];
+ if (empty($logdatei)) {
+ $logdatei = date('Y-m-d H:i:s');
+ }
+ $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '$id' LIMIT 1");
+ if (!empty($tmpwarenkorb['projekt']) && $this->app->DB->Select("SELECT id FROM projekt WHERE id = '" . (int) $tmpwarenkorb['projekt'] . "' LIMIT 1")) {
+ $projekt = (int) $tmpwarenkorb['projekt'];
+ }
+ if (isset($tmpwarenkorb['subshop']) && $tmpwarenkorb['subshop']) {
+ $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '$id' AND aktiv = 1 AND subshopkennung = '" . $this->app->DB->real_escape_string($tmpwarenkorb['subshop']) . "' LIMIT 1");
+ if ($subshopprojekt) {
+ $projekt = $subshopprojekt;
+ }
+ }
+ unset($tmpwarenkorb);
+
+ $standardcheck = true;
+ $modulename = $this->app->DB->Select(
+ sprintf(
+ "SELECT modulename FROM shopexport WHERE id = %d AND modulename <> '' AND (shoptyp = 'intern')",
+ $id
+ )
+ );
+ $shopIds = [$id];
+ $otherModules = empty($modulename) ? null :
+ $this->app->DB->SelectFirstCols(
+ sprintf(
+ "SELECT id
+ FROM shopexport
+ WHERE modulename = '%s' AND id <> %d",
+ $this->app->DB->real_escape_string($modulename), $id
+ )
+ );
+ if (!empty($otherModules) && $this->app->erp->ModulVorhanden($modulename)) {
+ $obj = $this->app->erp->LoadModul($modulename);
+ if (!empty($obj) && method_exists($obj, 'EinstellungenStruktur')) {
+ $konfiguration = $obj->EinstellungenStruktur();
+ if ($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis']) {
+ $shopIds = array_merge([$id], $otherModules);
+ $standardcheck = false;
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') and warenkorb = '".$this->app->DB->real_escape_string($warenkorb)."' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '".$this->app->DB->real_escape_string($auftrag)."' and ((modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern') OR shopid = '$id') AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ }
+ }
+ }
+ $checkdoppeltimported = $this->app->DB->Select(
+ sprintf(
+ "SELECT id
+ FROM shopimport_auftraege
+ WHERE extid = '%s' and shopid IN (%s) AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1",
+ $this->app->DB->real_escape_string($auftrag), implode(',', $shopIds)
+ )
+ );
+
+ /* if($standardcheck){ */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '" . $this->app->DB->real_escape_string($auftrag) . "' and shopid = '$id' and warenkorb = '" . $this->app->DB->real_escape_string($warenkorb) . "' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1"); */
+ /* $checkdoppeltimported = $this->app->DB->Select("SELECT id FROM shopimport_auftraege WHERE extid = '" . $this->app->DB->real_escape_string($auftrag) . "' and shopid = '$id' AND trash = 0
+ AND (imported = 0 OR (imported = 1 AND DATE_SUB(NOW(),INTERVAL 10 MINUTE)>logdatei ))
+ LIMIT 1");
+ } */
+
+ $insid = null;
+ if ($demomodus == '1') {
+ $checkdoppeltimported = null;
+ }
+ if (!$checkdoppeltimported) {
+ $this->app->DB->Insert("INSERT INTO shopimport_auftraege (id,extid,sessionid,warenkorb,imported,projekt,bearbeiter,logdatei)
+ VALUES('','$auftrag','$sessionid','$warenkorb','0','$projekt','" . $this->app->User->GetName() . "','$logdatei')");
+ $insid = $this->app->DB->GetInsertID();
+ if ($insid) {
+ $this->app->DB->Update("UPDATE shopimport_auftraege set shopid = '$id' where id = '$insid'");
+ $this->app->DB->Update("UPDATE shopimport_auftraege set logdatei = now() where id = '$insid' AND logdatei = '0000-00-00' OR logdatei > now()");
+ if ($isjson) {
+ $this->app->DB->Update("UPDATE shopimport_auftraege set jsonencoded = 1 where id = '$insid'");
+ }
+ }
+ }
+
+ if ($demomodus != '1') {
+ $this->app->remote->RemoteDeleteAuftrag($id, $auftrag);
+ } elseif ($demomodus == '1') {
+ $i = $gesamtanzahl;
+ }
+ }
+ }
+ }
}
- elseif($demomodus == '1')
- {
- $i=$gesamtanzahl;
+ } else {
+ if (!$returncount) {
+ $this->app->Tpl->Set('IMPORT', "Verbindungsprobleme! Bitte Administrator kontaktieren! ($pageContents)
");
+ } else {
+ $this->error = "Verbindungsprobleme! Bitte Administrator kontaktieren! ($pageContents)
";
}
- }
}
- }
}
- } else {
- if(!$returncount)
- {
- $this->app->Tpl->Set('IMPORT',"Verbindungsprobleme! Bitte Administrator kontaktieren! ($pageContents)
");
- }else {
- $this->error = "Verbindungsprobleme! Bitte Administrator kontaktieren! ($pageContents)
";
+
+ if (!$returncount) {
+ $this->drawShopOrderTable($deletedRows);
+ } else {
+ return $count + (is_numeric($gesamtanzahl) ? $gesamtanzahl : 0);
}
- }
}
- if(!$returncount)
- {
- $this->drawShopOrderTable($deletedRows);
- } else
- {
- return $count+(is_numeric($gesamtanzahl)?$gesamtanzahl:0);
- }
- }
-
- /**
- * @param array $arr
- *
- * @return array
- */
- public function getCustomerNumberFromShopCart($arr)
- {
- $validkundennummer = '';
- if(!empty($arr['jsonencoded']))
- {
- $warenkorb = json_decode(base64_decode($arr['warenkorb']),true);
- }else{
- $warenkorb = unserialize(base64_decode($arr['warenkorb']));
- }
- foreach($warenkorb as $key=>$value) {
- if(is_string($warenkorb[$key])){
- $warenkorb[$key] = trim($warenkorb[$key]);
- }
- }
- foreach($warenkorb as $k => $v) {
- $warenkorb[$k] = $this->app->erp->fixeUmlaute($v);
- }
-
- $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '".$arr['shopid']."' LIMIT 1");
- $adresseprojekt = '';
- if($kundenurvonprojekt)
- {
- $adresseprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '".$arr['shopid']."' LIMIT 1");
- }
- if(!empty($warenkorb['kundennummer'])) {
- $validkundennummer = $this->app->DB->Select(
- "SELECT kundennummer
- FROM adresse
- WHERE kundennummer='".$warenkorb['kundennummer']."' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> ''
- LIMIT 1"
- );
- }
- if(isset($warenkorb['subshop']) && $warenkorb['subshop'])
- {
- $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '".$arr['shopid']."' AND aktiv = 1 AND subshopkennung = '".$this->app->DB->real_escape_string($warenkorb['subshop'])."' LIMIT 1");
- if($subshopprojekt)
- {
- if(!$kundenurvonprojekt)
- {
- $adresseprojekt = $subshopprojekt;
+ /**
+ * @param array $arr
+ *
+ * @return array
+ */
+ public function getCustomerNumberFromShopCart($arr) {
+ $validkundennummer = '';
+ if (!empty($arr['jsonencoded'])) {
+ $warenkorb = json_decode(base64_decode($arr['warenkorb']), true);
+ } else {
+ $warenkorb = unserialize(base64_decode($arr['warenkorb']));
}
- $arr['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
- }
- }
- if($kundenurvonprojekt)
- {
- $adresseprojekt = " AND projekt = '".$adresseprojekt."' ";
- }else {
- $adresseprojekt = '';
- }
-
- $checkid = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE `name`='".$this->app->DB->real_escape_string($warenkorb['name'])."' AND abteilung='".$this->app->DB->real_escape_string($warenkorb['abteilung'])."'
- AND strasse='".$this->app->DB->real_escape_string($warenkorb['strasse'])."' AND plz='".$this->app->DB->real_escape_string($warenkorb['plz'])."' AND ort='".$this->app->DB->real_escape_string($warenkorb['ort'])."' AND kundennummer <> '' AND geloescht!=1 $adresseprojekt
- ORDER BY email='".$this->app->DB->real_escape_string($warenkorb['email'])."' DESC
- LIMIT 1");
-
-
- if($warenkorb['email'] != '')
- {
- if($warenkorb['email']!=='amazon_import_bounce@nfxmedia.de')
- {
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE email='".$warenkorb['email']."' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
- }
- if((String)$checkidemail === ''){
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name LIKE '" . $warenkorb['name'] . "' AND ort LIKE '" . $warenkorb['ort'] . "' AND geloescht!=1 $adresseprojekt AND kundennummer <> '' LIMIT 1");
- }
- }else{
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name='".$this->app->DB->real_escape_string($warenkorb['name'])."' AND strasse='".$this->app->DB->real_escape_string($warenkorb['strasse'])."' AND plz='".$this->app->DB->real_escape_string($warenkorb['plz'])."' AND ort='".$this->app->DB->real_escape_string($warenkorb['ort'])."' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
- }
-
- if($warenkorb['kundennummer']!='' && !empty($validkundennummer) && $validkundennummer==$warenkorb['kundennummer'])
- {
- $kdrnummer = $warenkorb['kundennummer'];
- }
- elseif ($checkid!='')
- {
- $kdrnummer = $checkid;
- }
- elseif ($checkidemail!='')
- {
- $kdrnummer = $checkidemail;
- }
- else {
- $kdrnummer='';
- $checkidemail='';
- }
-
- return [$checkidemail, $kdrnummer];
- }
-
- public function drawShopOrderTable($deletedRows) {
- $checkglobal = null;
- $htmltable = new HTMLTable(0,'100%','',3,1,'font-size:85%');
- $htmltable->AddRowAsHeading(array('Import','Müll','Später','Projekt','Internet','Name','Bemerkung','Strasse','PLZ','Ort','Kd.Nr.','vorhanden','Land','Betrag','Offen','Zahlung','Partner'));
- $htmltable->ChangingRowColors('#e0e0e0','#fff');
-
- $shopid = $this->app->Secure->GetGET('shopid');
- $where = '';
- if(!empty($shopid)){
- $where = 'AND sa.shopid='.(int)$shopid;
- }
-
- $bestellnummer = $this->app->Secure->GetGET('bestellnummer');
- if(!empty($bestellnummer)){
- $bestellnummer = preg_replace('/[^\w-]/', '', $bestellnummer);
- $where .= " AND sa.bestellnummer='$bestellnummer'";
- }
-
- $arr = $this->app->DB->SelectArr("SELECT sa.*, p.abkuerzung FROM shopimport_auftraege sa left join projekt p on sa.projekt = p.id WHERE sa.imported='0' AND sa.trash='0' $where ORDER BY sa.logdatei LIMIT 100");
- if(is_array($arr) && (!empty($arr)?count($arr):0) > 0)
- {
-
- //Alte Auftraege prüfen
- $alteauftraegeohnebestellnummer = $this->app->DB->Query("SELECT sa.* FROM shopimport_auftraege sa WHERE isnull(bestellnummer) AND sa.trash='0' LIMIT 100");
- while($row = $this->app->DB->Fetch_Assoc($alteauftraegeohnebestellnummer))
- {
- if($row['warenkorb'] != '')
- {
- if(!empty($row['jsonencoded']))
- {
- $warenkorb = json_decode(base64_decode($row['warenkorb']),true);
- }else{
- $warenkorb = unserialize(base64_decode($row['warenkorb']));
- }
- $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '".(isset($warenkorb['onlinebestellnummer'])?$warenkorb['onlinebestellnummer']:'')."' where id = '".$row['id']."'");
- }else{
- $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '' where id = '".$row['id']."'");
- }
- }
- $this->app->DB->free($alteauftraegeohnebestellnummer);
-
- $unbekanntezahlungsweisen = null;
- $enthaeltdoppeltenummern = false;
- $carr = $arr?count($arr):0;
- for($i=0;$i<$carr;$i++)
- {
- if(empty($checkglobal) || !isset($checkglobal[$arr[$i]['shopid']]))
- {
- $checkglobal[$arr[$i]['shopid']] = null;
-
- if(($modulename = $this->app->DB->Select("SELECT modulename FROM shopexport WHERE id = '".$arr[$i]['shopid']."' AND modulename <> '' AND shoptyp = 'intern'"))
- && $this->app->DB->Select("SELECT id FROM shopexport WHERE modulename = '".$this->app->DB->real_escape_string($modulename)."' AND id <> '".$arr[$i]['shopid']."' LIMIT 1")
- )
- {
- $shopsintern = $this->app->DB->SelectArr("SELECT id FROM shopexport WHERE id = '".$arr[$i]['shopid']."' OR (modulename = '".$this->app->DB->real_escape_string($modulename)."' AND shoptyp = 'intern')");
- if($shopsintern)
- {
- foreach($shopsintern as $vs)
- {
- $checkglobal[$arr[$i]['shopid']][] = " shopid = '". $vs['id']."' ";
- }
- if($this->app->erp->ModulVorhanden($modulename))
- {
- /** @var ShopimporterBase $obj */
- $obj = $this->app->erp->LoadModul($modulename);
- if($obj && method_exists($obj, 'EinstellungenStruktur')){
- $konfiguration = $obj->EinstellungenStruktur();
- if($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis'])
- {
-
- }else
- {
- $checkglobal[$arr[$i]['shopid']] = null;
- }
- }else {
- $checkglobal[$arr[$i]['shopid']] = null;
- }
- }else {
- $checkglobal[$arr[$i]['shopid']] = null;
- }
+ foreach ($warenkorb as $key => $value) {
+ if (is_string($warenkorb[$key])) {
+ $warenkorb[$key] = trim($warenkorb[$key]);
}
- }
}
- }
+ foreach ($warenkorb as $k => $v) {
+ $warenkorb[$k] = $this->app->erp->fixeUmlaute($v);
+ }
- $carr = $arr?count($arr):0;
- for($i=0;$i<$carr;$i++)
- {
- $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '".$arr[$i]['shopid']."' LIMIT 1");
- $auftraegeaufspaeter = $this->app->DB->Select("SELECT auftraegeaufspaeter FROM shopexport WHERE id='".$arr[$i]['shopid']."'");
- if(!empty($arr[$i]['jsonencoded']))
- {
- $warenkorb = json_decode(base64_decode($arr[$i]['warenkorb']),true);
- }else{
- $warenkorb = unserialize(base64_decode($arr[$i]['warenkorb']));
- }
- foreach($warenkorb as $key=>$value) {
- if(is_string($warenkorb[$key])){
- $warenkorb[$key] = trim($warenkorb[$key]);
- }
- }
- foreach($warenkorb as $k => $v) {
- $warenkorb[$k] = $this->app->erp->fixeUmlaute($v);
- }
- $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '".$arr[$i]['shopid']."' LIMIT 1");
+ $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '" . $arr['shopid'] . "' LIMIT 1");
$adresseprojekt = '';
- if($kundenurvonprojekt)
- {
- $adresseprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '".$arr[$i]['shopid']."' LIMIT 1");
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '" . $arr['shopid'] . "' LIMIT 1");
}
- if(isset($warenkorb['subshop']) && $warenkorb['subshop'])
- {
- $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '".$arr[$i]['shopid']."' AND aktiv = 1 AND subshopkennung = '".$this->app->DB->real_escape_string($warenkorb['subshop'])."' LIMIT 1");
- if($subshopprojekt)
- {
- if(!$kundenurvonprojekt)
- {
- $adresseprojekt = $subshopprojekt;
+ if (!empty($warenkorb['kundennummer'])) {
+ $validkundennummer = $this->app->DB->Select(
+ "SELECT kundennummer
+ FROM adresse
+ WHERE kundennummer='" . $warenkorb['kundennummer'] . "' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> ''
+ LIMIT 1"
+ );
+ }
+ if (isset($warenkorb['subshop']) && $warenkorb['subshop']) {
+ $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '" . $arr['shopid'] . "' AND aktiv = 1 AND subshopkennung = '" . $this->app->DB->real_escape_string($warenkorb['subshop']) . "' LIMIT 1");
+ if ($subshopprojekt) {
+ if (!$kundenurvonprojekt) {
+ $adresseprojekt = $subshopprojekt;
+ }
+ $arr['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
}
- $arr[$i]['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
- }
}
- if($kundenurvonprojekt)
- {
- $adresseprojekt = " AND projekt = '".$adresseprojekt."' ";
- }else {
- $adresseprojekt = '';
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = " AND projekt = '" . $adresseprojekt . "' ";
+ } else {
+ $adresseprojekt = '';
}
- $checkid = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE `name`='".$this->app->DB->real_escape_string($warenkorb['name'])."' AND abteilung='".$this->app->DB->real_escape_string($warenkorb['abteilung'])."'
- AND strasse='".$this->app->DB->real_escape_string($warenkorb['strasse'])."' AND plz='".$this->app->DB->real_escape_string($warenkorb['plz'])."' AND ort='".$this->app->DB->real_escape_string($warenkorb['ort'])."' AND kundennummer <> '' AND geloescht!=1 $adresseprojekt
- ORDER BY email='".$this->app->DB->real_escape_string($warenkorb['email'])."' DESC
+ $checkid = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE `name`='" . $this->app->DB->real_escape_string($warenkorb['name']) . "' AND abteilung='" . $this->app->DB->real_escape_string($warenkorb['abteilung']) . "'
+ AND strasse='" . $this->app->DB->real_escape_string($warenkorb['strasse']) . "' AND plz='" . $this->app->DB->real_escape_string($warenkorb['plz']) . "' AND ort='" . $this->app->DB->real_escape_string($warenkorb['ort']) . "' AND kundennummer <> '' AND geloescht!=1 $adresseprojekt
+ ORDER BY email='" . $this->app->DB->real_escape_string($warenkorb['email']) . "' DESC
LIMIT 1");
-
- if($warenkorb['email'] != '')
- {
- if($warenkorb['email']!=='amazon_import_bounce@nfxmedia.de')
- {
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE email='".$warenkorb['email']."' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
- }
- if((String)$checkidemail === ''){
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name LIKE '" . $warenkorb['name'] . "' AND ort LIKE '" . $warenkorb['ort'] . "' AND geloescht!=1 $adresseprojekt AND kundennummer <> '' LIMIT 1");
- }
- }else{
- $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name='".$this->app->DB->real_escape_string($warenkorb['name'])."' AND strasse='".$this->app->DB->real_escape_string($warenkorb['strasse'])."' AND plz='".$this->app->DB->real_escape_string($warenkorb['plz'])."' AND ort='".$this->app->DB->real_escape_string($warenkorb['ort'])."' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
+ if ($warenkorb['email'] != '') {
+ if ($warenkorb['email'] !== 'amazon_import_bounce@nfxmedia.de') {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE email='" . $warenkorb['email'] . "' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
+ }
+ if ((String) $checkidemail === '') {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name LIKE '" . $warenkorb['name'] . "' AND ort LIKE '" . $warenkorb['ort'] . "' AND geloescht!=1 $adresseprojekt AND kundennummer <> '' LIMIT 1");
+ }
+ } else {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name='" . $this->app->DB->real_escape_string($warenkorb['name']) . "' AND strasse='" . $this->app->DB->real_escape_string($warenkorb['strasse']) . "' AND plz='" . $this->app->DB->real_escape_string($warenkorb['plz']) . "' AND ort='" . $this->app->DB->real_escape_string($warenkorb['ort']) . "' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
}
- if($warenkorb['kundennummer']!='' && !empty($validkundennummer) && $validkundennummer==$warenkorb['kundennummer'])
- {
- $kdrnummer = $warenkorb['kundennummer'];
- $kdr_name = $this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' $adresseprojekt AND geloescht!=1 LIMIT 1");
- $email = $this->app->DB->Select("SELECT email FROM adresse WHERE kundennummer='$kdrnummer' $adresseprojekt AND geloescht!=1 LIMIT 1");
- $parts= explode("\n", wordwrap($kdr_name, 20, "\n"));
- $kdr_name = $parts[0];
- $kdr_name = ''.$kdr_name.' ';
- $email = ''.$email.' ';
-
- $kdr_strasse = $this->app->DB->Select("SELECT strasse FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
- $parts= explode("\n", wordwrap($kdr_strasse, 20, "\n"));
- $kdr_strasse = $parts[0];
- $kdr_strasse = ''.$kdr_strasse.' ';
-
- $kdr_plz = ''.$this->app->DB->Select("SELECT plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1").' ';
- $kdr_ort = ''.$this->app->DB->Select("SELECT ort FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1").' ';
- $checked='';
- }
- elseif ($checkid!='')
- {
- $checked='checked';
- $kdrnummer = $checkid;
- //$kdr_name = "".$this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' AND firma='".$this->app->User->GetFirma()."' LIMIT 1")." ";
- $kdrArr = $this->app->DB->SelectRow("SELECT name, email, strasse, ort, plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
- $kdr_name = $kdrArr['name'];
- $email = $kdrArr['email'];
- $parts= explode("\n", wordwrap($kdr_name, 20, "\n"));
- $kdr_name = $parts[0];
- $kdr_name = ''.$kdr_name.' ';
- $email = ''.$email.' ';
-
- $kdr_strasse = $kdrArr['strasse'];
- $parts= explode("\n", wordwrap($kdr_strasse, 20, "\n"));
- $kdr_strasse = $parts[0];
- $kdr_strasse = ''.$kdr_strasse.' ';
-
- $kdr_plz = ''.$kdrArr['plz'].' ';
- $kdr_ort = ''.$kdrArr['or'].' ';
-
- }
- elseif ($checkidemail!='')
- {
- $checked='checked';
- $kdrnummer = $checkidemail;
- $warenkorb['kundennummer'] = $kdrnummer;
- //$kdr_name = "".$this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' AND firma='".$this->app->User->GetFirma()."' LIMIT 1")." ";
- $kdrArr = $this->app->DB->SelectRow("SELECT name, email, strasse, ort, plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
- $kdr_name = $kdrArr['name'];
- $email = $kdrArr['email'];
- $parts= explode("\n", wordwrap($kdr_name, 20, "\n"));
- $kdr_name = $parts[0];
- $kdr_name = ''.$kdr_name.' ';
- $email = ''.$email.' ';
-
- $kdr_strasse = $kdrArr['strasse'];
- $parts= explode("\n", wordwrap($kdr_strasse, 40, "\n"));
- $kdr_strasse = $parts[0];
- $kdr_strasse = ''.$kdr_strasse.' ';
-
- $kdr_plz = ''.$kdrArr['plz'].' ';
- $kdr_ort = ''.$kdrArr['ort'].' ';
+ if ($warenkorb['kundennummer'] != '' && !empty($validkundennummer) && $validkundennummer == $warenkorb['kundennummer']) {
+ $kdrnummer = $warenkorb['kundennummer'];
+ } elseif ($checkid != '') {
+ $kdrnummer = $checkid;
+ } elseif ($checkidemail != '') {
+ $kdrnummer = $checkidemail;
+ } else {
+ $kdrnummer = '';
+ $checkidemail = '';
}
+ return [$checkidemail, $kdrnummer];
+ }
- else {
- $checked='';
- $checkid='';
- $kdrnummer='';
- $checkidemail='';
- $kdr_name='';
- $kdr_strasse='';
- $kdr_plz='';
- $kdr_ort='';
- $email='';
- }
- if($kdrnummer != ''){
- $kdr_addresse_id = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
- }
- else {
- $kdr_addresse_id = '';
+ public function drawShopOrderTable($deletedRows) {
+ $checkglobal = null;
+ $htmltable = new HTMLTable(0, '100%', '', 3, 1, 'font-size:85%');
+ $htmltable->AddRowAsHeading(array('Import', 'Müll', 'Später', 'Projekt', 'Internet', 'Name', 'Bemerkung', 'Strasse', 'PLZ', 'Ort', 'Kd.Nr.', 'vorhanden', 'Land', 'Betrag', 'Offen', 'Zahlung', 'Partner'));
+ $htmltable->ChangingRowColors('#e0e0e0', '#fff');
+
+ $shopid = $this->app->Secure->GetGET('shopid');
+ $where = '';
+ if (!empty($shopid)) {
+ $where = 'AND sa.shopid=' . (int) $shopid;
+ }
+
+ $bestellnummer = $this->app->Secure->GetGET('bestellnummer');
+ if (!empty($bestellnummer)) {
+ $bestellnummer = preg_replace('/[^\w-]/', '', $bestellnummer);
+ $where .= " AND sa.bestellnummer='$bestellnummer'";
+ }
+
+ $arr = $this->app->DB->SelectArr("SELECT sa.*, p.abkuerzung FROM shopimport_auftraege sa left join projekt p on sa.projekt = p.id WHERE sa.imported='0' AND sa.trash='0' $where ORDER BY sa.logdatei LIMIT 100");
+ if (is_array($arr) && (!empty($arr) ? count($arr) : 0) > 0) {
+
+ //Alte Auftraege prüfen
+ $alteauftraegeohnebestellnummer = $this->app->DB->Query("SELECT sa.* FROM shopimport_auftraege sa WHERE isnull(bestellnummer) AND sa.trash='0' LIMIT 100");
+ while ($row = $this->app->DB->Fetch_Assoc($alteauftraegeohnebestellnummer)) {
+ if ($row['warenkorb'] != '') {
+ if (!empty($row['jsonencoded'])) {
+ $warenkorb = json_decode(base64_decode($row['warenkorb']), true);
+ } else {
+ $warenkorb = unserialize(base64_decode($row['warenkorb']));
+ }
+ $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '" . (isset($warenkorb['onlinebestellnummer']) ? $warenkorb['onlinebestellnummer'] : '') . "' where id = '" . $row['id'] . "'");
+ } else {
+ $this->app->DB->Update("UPDATE shopimport_auftraege set bestellnummer = '' where id = '" . $row['id'] . "'");
+ }
+ }
+ $this->app->DB->free($alteauftraegeohnebestellnummer);
+
+ $unbekanntezahlungsweisen = null;
+ $enthaeltdoppeltenummern = false;
+ $carr = $arr ? count($arr) : 0;
+ for ($i = 0; $i < $carr; $i++) {
+ if (empty($checkglobal) || !isset($checkglobal[$arr[$i]['shopid']])) {
+ $checkglobal[$arr[$i]['shopid']] = null;
+
+ if (($modulename = $this->app->DB->Select("SELECT modulename FROM shopexport WHERE id = '" . $arr[$i]['shopid'] . "' AND modulename <> '' AND shoptyp = 'intern'")) && $this->app->DB->Select("SELECT id FROM shopexport WHERE modulename = '" . $this->app->DB->real_escape_string($modulename) . "' AND id <> '" . $arr[$i]['shopid'] . "' LIMIT 1")
+ ) {
+ $shopsintern = $this->app->DB->SelectArr("SELECT id FROM shopexport WHERE id = '" . $arr[$i]['shopid'] . "' OR (modulename = '" . $this->app->DB->real_escape_string($modulename) . "' AND shoptyp = 'intern')");
+ if ($shopsintern) {
+ foreach ($shopsintern as $vs) {
+ $checkglobal[$arr[$i]['shopid']][] = " shopid = '" . $vs['id'] . "' ";
+ }
+ if ($this->app->erp->ModulVorhanden($modulename)) {
+ /** @var ShopimporterBase $obj */
+ $obj = $this->app->erp->LoadModul($modulename);
+ if ($obj && method_exists($obj, 'EinstellungenStruktur')) {
+ $konfiguration = $obj->EinstellungenStruktur();
+ if ($konfiguration && isset($konfiguration['globalerauftragsnummernkreis']) && $konfiguration['globalerauftragsnummernkreis']) {
+
+ } else {
+ $checkglobal[$arr[$i]['shopid']] = null;
+ }
+ } else {
+ $checkglobal[$arr[$i]['shopid']] = null;
+ }
+ } else {
+ $checkglobal[$arr[$i]['shopid']] = null;
+ }
+ }
+ }
+ }
+ }
+
+ $carr = $arr ? count($arr) : 0;
+ for ($i = 0; $i < $carr; $i++) {
+ $projekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '" . $arr[$i]['shopid'] . "' LIMIT 1");
+ $auftraegeaufspaeter = $this->app->DB->Select("SELECT auftraegeaufspaeter FROM shopexport WHERE id='" . $arr[$i]['shopid'] . "'");
+ if (!empty($arr[$i]['jsonencoded'])) {
+ $warenkorb = json_decode(base64_decode($arr[$i]['warenkorb']), true);
+ } else {
+ $warenkorb = unserialize(base64_decode($arr[$i]['warenkorb']));
+ }
+ foreach ($warenkorb as $key => $value) {
+ if (is_string($warenkorb[$key])) {
+ $warenkorb[$key] = trim($warenkorb[$key]);
+ }
+ }
+ foreach ($warenkorb as $k => $v) {
+ $warenkorb[$k] = $this->app->erp->fixeUmlaute($v);
+ }
+ $kundenurvonprojekt = $this->app->DB->Select("SELECT kundenurvonprojekt FROM shopexport WHERE id = '" . $arr[$i]['shopid'] . "' LIMIT 1");
+ $adresseprojekt = '';
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id = '" . $arr[$i]['shopid'] . "' LIMIT 1");
+ }
+ if (isset($warenkorb['subshop']) && $warenkorb['subshop']) {
+ $subshopprojekt = $this->app->DB->Select("SELECT projekt FROM shopexport_subshop WHERE shop = '" . $arr[$i]['shopid'] . "' AND aktiv = 1 AND subshopkennung = '" . $this->app->DB->real_escape_string($warenkorb['subshop']) . "' LIMIT 1");
+ if ($subshopprojekt) {
+ if (!$kundenurvonprojekt) {
+ $adresseprojekt = $subshopprojekt;
+ }
+ $arr[$i]['abkuerzung'] = $this->app->DB->Select("SELECT abkuerzung FROM projekt WHERE id = '$adresseprojekt' LIMIT 1");
+ }
+ }
+ if ($kundenurvonprojekt) {
+ $adresseprojekt = " AND projekt = '" . $adresseprojekt . "' ";
+ } else {
+ $adresseprojekt = '';
+ }
+
+ $checkid = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE `name`='" . $this->app->DB->real_escape_string($warenkorb['name']) . "' AND abteilung='" . $this->app->DB->real_escape_string($warenkorb['abteilung']) . "'
+ AND strasse='" . $this->app->DB->real_escape_string($warenkorb['strasse']) . "' AND plz='" . $this->app->DB->real_escape_string($warenkorb['plz']) . "' AND ort='" . $this->app->DB->real_escape_string($warenkorb['ort']) . "' AND kundennummer <> '' AND geloescht!=1 $adresseprojekt
+ ORDER BY email='" . $this->app->DB->real_escape_string($warenkorb['email']) . "' DESC
+ LIMIT 1");
+
+ if ($warenkorb['email'] != '') {
+ if ($warenkorb['email'] !== 'amazon_import_bounce@nfxmedia.de') {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE email='" . $warenkorb['email'] . "' and email <> '' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
+ }
+ if ((String) $checkidemail === '') {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name LIKE '" . $warenkorb['name'] . "' AND ort LIKE '" . $warenkorb['ort'] . "' AND geloescht!=1 $adresseprojekt AND kundennummer <> '' LIMIT 1");
+ }
+ } else {
+ $checkidemail = $this->app->DB->Select("SELECT kundennummer FROM adresse WHERE name='" . $this->app->DB->real_escape_string($warenkorb['name']) . "' AND strasse='" . $this->app->DB->real_escape_string($warenkorb['strasse']) . "' AND plz='" . $this->app->DB->real_escape_string($warenkorb['plz']) . "' AND ort='" . $this->app->DB->real_escape_string($warenkorb['ort']) . "' $adresseprojekt AND geloescht!=1 AND kundennummer <> '' LIMIT 1");
+ }
+
+ if ($warenkorb['kundennummer'] != '' && !empty($validkundennummer) && $validkundennummer == $warenkorb['kundennummer']) {
+ $kdrnummer = $warenkorb['kundennummer'];
+ $kdr_name = $this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' $adresseprojekt AND geloescht!=1 LIMIT 1");
+ $email = $this->app->DB->Select("SELECT email FROM adresse WHERE kundennummer='$kdrnummer' $adresseprojekt AND geloescht!=1 LIMIT 1");
+ $parts = explode("\n", wordwrap($kdr_name, 20, "\n"));
+ $kdr_name = $parts[0];
+ $kdr_name = '' . $kdr_name . ' ';
+ $email = '' . $email . ' ';
+
+ $kdr_strasse = $this->app->DB->Select("SELECT strasse FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
+ $parts = explode("\n", wordwrap($kdr_strasse, 20, "\n"));
+ $kdr_strasse = $parts[0];
+ $kdr_strasse = '' . $kdr_strasse . ' ';
+
+ $kdr_plz = '' . $this->app->DB->Select("SELECT plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1") . ' ';
+ $kdr_ort = '' . $this->app->DB->Select("SELECT ort FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1") . ' ';
+ $checked = '';
+ } elseif ($checkid != '') {
+ $checked = 'checked';
+ $kdrnummer = $checkid;
+ //$kdr_name = "".$this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' AND firma='".$this->app->User->GetFirma()."' LIMIT 1")." ";
+ $kdrArr = $this->app->DB->SelectRow("SELECT name, email, strasse, ort, plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
+ $kdr_name = $kdrArr['name'];
+ $email = $kdrArr['email'];
+ $parts = explode("\n", wordwrap($kdr_name, 20, "\n"));
+ $kdr_name = $parts[0];
+ $kdr_name = '' . $kdr_name . ' ';
+ $email = '' . $email . ' ';
+
+ $kdr_strasse = $kdrArr['strasse'];
+ $parts = explode("\n", wordwrap($kdr_strasse, 20, "\n"));
+ $kdr_strasse = $parts[0];
+ $kdr_strasse = '' . $kdr_strasse . ' ';
+
+ $kdr_plz = '' . $kdrArr['plz'] . ' ';
+ $kdr_ort = '' . $kdrArr['or'] . ' ';
+ } elseif ($checkidemail != '') {
+ $checked = 'checked';
+ $kdrnummer = $checkidemail;
+ $warenkorb['kundennummer'] = $kdrnummer;
+ //$kdr_name = "".$this->app->DB->Select("SELECT name FROM adresse WHERE kundennummer='$kdrnummer' AND firma='".$this->app->User->GetFirma()."' LIMIT 1")." ";
+ $kdrArr = $this->app->DB->SelectRow("SELECT name, email, strasse, ort, plz FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
+ $kdr_name = $kdrArr['name'];
+ $email = $kdrArr['email'];
+ $parts = explode("\n", wordwrap($kdr_name, 20, "\n"));
+ $kdr_name = $parts[0];
+ $kdr_name = '' . $kdr_name . ' ';
+ $email = '' . $email . ' ';
+
+ $kdr_strasse = $kdrArr['strasse'];
+ $parts = explode("\n", wordwrap($kdr_strasse, 40, "\n"));
+ $kdr_strasse = $parts[0];
+ $kdr_strasse = '' . $kdr_strasse . ' ';
+
+ $kdr_plz = '' . $kdrArr['plz'] . ' ';
+ $kdr_ort = '' . $kdrArr['ort'] . ' ';
+ } else {
+ $checked = '';
+ $checkid = '';
+ $kdrnummer = '';
+ $checkidemail = '';
+ $kdr_name = '';
+ $kdr_strasse = '';
+ $kdr_plz = '';
+ $kdr_ort = '';
+ $email = '';
+ }
+ if ($kdrnummer != '') {
+ $kdr_addresse_id = $this->app->DB->Select("SELECT id FROM adresse WHERE kundennummer='$kdrnummer' AND geloescht!=1 $adresseprojekt LIMIT 1");
+ } else {
+ $kdr_addresse_id = '';
+ }
+
+ $warenkorb['name'] = $this->app->erp->LimitWord($warenkorb['name'], 20);
+ $warenkorb['strasse'] = $this->app->erp->LimitWord($warenkorb['strasse'], 20);
+
+ $htmltable->NewRow();
+
+ $doppelteonlinebestellnummer = false;
+ if (!empty($warenkorb['onlinebestellnummer'])) {
+ $check = $this->app->DB->Select("SELECT id from shopimport_auftraege where id <> '" . $arr[$i]['id'] . "' and shopid = '" . $arr[$i]['shopid'] . "' and bestellnummer = '" . $warenkorb['onlinebestellnummer'] . "' and trash = '0' LIMIT 1");
+ if ($check) {
+ $doppelteonlinebestellnummer = true;
+ $enthaeltdoppeltenummern = true;
+ } elseif (!empty($checkglobal) && isset($checkglobal[$arr[$i]['shopid']]) && $checkglobal[$arr[$i]['shopid']]) {
+ $check = $this->app->DB->Select("SELECT id from shopimport_auftraege where id <> '" . $arr[$i]['id'] . "' and (shopid = '" . $arr[$i]['shopid'] . "' OR " . (implode(" OR ", $checkglobal[$arr[$i]['shopid']])) . ") and bestellnummer = '" . $warenkorb['onlinebestellnummer'] . "' and trash = '0' LIMIT 1");
+ if ($check) {
+ $doppelteonlinebestellnummer = true;
+ $enthaeltdoppeltenummern = true;
+ }
+ }
+ }
+
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol($arr[$i]['abkuerzung']);
+
+ $htmltable->AddCol(($doppelteonlinebestellnummer ? '' : '') . $warenkorb['onlinebestellnummer'] . ($doppelteonlinebestellnummer ? ' ' : ''));
+ $htmltable->AddCol($warenkorb['name'] . $kdr_name . ' ' . $warenkorb['email'] . $email);
+ $htmltable->AddCol($warenkorb['internebezeichnung']);
+
+ $htmltable->AddCol($warenkorb['strasse'] . $kdr_strasse);
+ $htmltable->AddCol($warenkorb['plz'] . $kdr_plz);
+ $htmltable->AddCol($warenkorb['ort'] . $kdr_ort);
+ if ($checkid != '') {
+ $htmltable->AddCol(' ');
+ } else {
+ $htmltable->AddCol(' ');
+ }
+
+ $htmltable->AddCol(' ');
+ //$htmltable->AddCol(' ');
+ $htmltable->AddCol($warenkorb['land']);
+ $htmltable->AddCol(number_format($warenkorb['gesamtsumme'], 2, ',', '.'));
+ $saldo_kunde = round($this->app->erp->SaldoAdresse($kdr_addresse_id), 2);
+ if ($saldo_kunde > 0) {
+ $saldo_kunde = '' . number_format($saldo_kunde, 2, ',', '.') . ' ';
+ } else {
+ $saldo_kunde = '-';
+ }
+ $htmltable->AddCol($saldo_kunde);
+ $htmltable->AddCol($warenkorb['zahlungsweise']);
+
+ $htmltable->AddCol($warenkorb['affiliate_ref']);
+ //$htmltable->AddCol('Einzelimport verwerfen ');
+ //$warenkorb[gesamtsumme] = str_replace(".","",$warenkorb[gesamtsumme]);
+ $gesamtsumme = (isset($gesamtsumme) ? $gesamtsumme : 0) + $warenkorb['gesamtsumme'];
+ $checkid = '';
+ $checkidemail = '';
+ $validkundennummer = '';
+ //$this->app->Tpl->Add('INHALT',"{$warenkorb[onlinebestellnummer]} {$warenkorb[name]} {$warenkorb[land]} {$warenkorb[gesamtsumme]} ");
+ }
+ } else {
+ if ($deletedRows > 0) {
+ $msg = $this->app->erp->base64_url_encode('Es wurden ' . $deletedRows . ' bereits importierte Datensätze entfernt.
');
+ } else {
+ $msg = $this->app->erp->base64_url_encode('Aktuell sind keine Aufträge in den Online-Shops vorhanden!
');
+ }
+ $this->app->Location->execute('Location: index.php?module=shopimport&action=list&msg=' . $msg);
}
- $warenkorb['name'] = $this->app->erp->LimitWord($warenkorb['name'],20);
- $warenkorb['strasse'] = $this->app->erp->LimitWord($warenkorb['strasse'],20);
$htmltable->NewRow();
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol(' ');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
+ $htmltable->AddCol(number_format($gesamtsumme, 2, ',', '.'));
+ $htmltable->AddCol('');
+ $htmltable->AddCol('');
- $doppelteonlinebestellnummer = false;
- if(!empty($warenkorb['onlinebestellnummer']))
- {
- $check = $this->app->DB->Select("SELECT id from shopimport_auftraege where id <> '".$arr[$i]['id']."' and shopid = '".$arr[$i]['shopid']."' and bestellnummer = '".$warenkorb['onlinebestellnummer']."' and trash = '0' LIMIT 1");
- if($check)
- {
- $doppelteonlinebestellnummer = true;
- $enthaeltdoppeltenummern = true;
- }elseif(!empty($checkglobal) && isset($checkglobal[$arr[$i]['shopid']]) && $checkglobal[$arr[$i]['shopid']])
- {
- $check = $this->app->DB->Select("SELECT id from shopimport_auftraege where id <> '".$arr[$i]['id']."' and (shopid = '".$arr[$i]['shopid']."' OR ".(implode( " OR ", $checkglobal[$arr[$i]['shopid']])).") and bestellnummer = '".$warenkorb['onlinebestellnummer']."' and trash = '0' LIMIT 1");
- if($check)
- {
- $doppelteonlinebestellnummer = true;
- $enthaeltdoppeltenummern = true;
- }
- }
+ if ($enthaeltdoppeltenummern) {
+ $this->app->Tpl->Add('INHALT', 'Es wurde ein Auftrag aus einem Shop geholt, der bereits importiert wurde!
');
}
+ $this->app->Tpl->Add('INHALT', $htmltable->Get());
- $htmltable->AddCol(' ');
- $htmltable->AddCol(' ');
- $htmltable->AddCol(' ');
- $htmltable->AddCol($arr[$i]['abkuerzung']);
-
- $htmltable->AddCol(($doppelteonlinebestellnummer?'':'').$warenkorb['onlinebestellnummer'].($doppelteonlinebestellnummer?' ':''));
- $htmltable->AddCol($warenkorb['name'].$kdr_name.' '.$warenkorb['email'].$email);
- $htmltable->AddCol($warenkorb['internebezeichnung']);
-
- $htmltable->AddCol($warenkorb['strasse'].$kdr_strasse);
- $htmltable->AddCol($warenkorb['plz'].$kdr_plz);
- $htmltable->AddCol($warenkorb['ort'].$kdr_ort);
- if($checkid!=''){
- $htmltable->AddCol(' ');
- }
- else{
- $htmltable->AddCol(' ');
- }
-
- $htmltable->AddCol(' ');
- //$htmltable->AddCol(' ');
- $htmltable->AddCol($warenkorb['land']);
- $htmltable->AddCol(number_format($warenkorb['gesamtsumme'],2,',','.'));
- $saldo_kunde = round($this->app->erp->SaldoAdresse($kdr_addresse_id),2);
- if($saldo_kunde > 0){
- $saldo_kunde = '' . number_format($saldo_kunde, 2, ',','.') . ' ';
- }
- else{
- $saldo_kunde = '-';
- }
- $htmltable->AddCol($saldo_kunde);
- $htmltable->AddCol($warenkorb['zahlungsweise']);
-
-
- $htmltable->AddCol($warenkorb['affiliate_ref']);
- //$htmltable->AddCol('Einzelimport verwerfen ');
- //$warenkorb[gesamtsumme] = str_replace(".","",$warenkorb[gesamtsumme]);
- $gesamtsumme = (isset($gesamtsumme)?$gesamtsumme:0) + $warenkorb['gesamtsumme'];
- $checkid = '';
- $checkidemail = '';
- $validkundennummer = '';
- //$this->app->Tpl->Add('INHALT',"{$warenkorb[onlinebestellnummer]} {$warenkorb[name]} {$warenkorb[land]} {$warenkorb[gesamtsumme]} ");
- }
-
-
- } else {
- if($deletedRows > 0){
- $msg = $this->app->erp->base64_url_encode('Es wurden ' . $deletedRows . ' bereits importierte Datensätze entfernt.
');
- }else{
- $msg = $this->app->erp->base64_url_encode('Aktuell sind keine Aufträge in den Online-Shops vorhanden!
');
- }
- $this->app->Location->execute('Location: index.php?module=shopimport&action=list&msg='.$msg);
- }
-
-
- $htmltable->NewRow();
- $htmltable->AddCol(' ');
- $htmltable->AddCol(' ');
- $htmltable->AddCol(' ');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol('');
- $htmltable->AddCol(number_format($gesamtsumme,2,',','.'));
- $htmltable->AddCol('');
- $htmltable->AddCol('');
-
- if($enthaeltdoppeltenummern)
- {
- $this->app->Tpl->Add('INHALT','Es wurde ein Auftrag aus einem Shop geholt, der bereits importiert wurde!
');
- }
- $this->app->Tpl->Add('INHALT',$htmltable->Get());
-
- $this->app->Tpl->Add('INHALT'," Bedeutung:
+ $this->app->Tpl->Add('INHALT', " Bedeutung:
Kundennummer von Kunde angegeben, eventuell ist diese falsch!
Doppelte Internetbestellnummer!
Kundennummer bitte manuell prüfen!
Kundennummer aufgrund Felder Ort, Strasse, Name, Abteilung und E-Mail eindeutig gefunden!
");
- $this->app->Tpl->Set('EXTEND',' ');
- $this->app->Tpl->Parse('IMPORT','rahmen70.tpl');
+ $this->app->Tpl->Set('EXTEND', ' ');
+ $this->app->Tpl->Parse('IMPORT', 'rahmen70.tpl');
+ $this->app->Tpl->Parse('PAGE', 'shopimport_import.tpl');
+ }
- $this->app->Tpl->Parse('PAGE','shopimport_import.tpl');
- }
-
- public function ShopimportNavigation()
- {
- $id = $this->app->Secure->GetGET('id');
- $tmp = new Navigation($this->app, $id);
- $this->app->Tpl->Set('ID',$id);
- $this->app->Tpl->Set('PAGE',$tmp->Get());
- $this->app->BuildNavigation=false;
- }
-
+ public function ShopimportNavigation() {
+ $id = $this->app->Secure->GetGET('id');
+ $tmp = new Navigation($this->app, $id);
+ $this->app->Tpl->Set('ID', $id);
+ $this->app->Tpl->Set('PAGE', $tmp->Get());
+ $this->app->BuildNavigation = false;
+ }
}
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 6fbb810e..608ab1a2 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -452,10 +452,13 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['kundennummer'] = $order->customer->customer_id;
$cart['name'] = ($order->customer->civility?$order->customer->civility." ":"").$order->customer->firstname." ".$order->customer->lastname;
- if (!empty(strval($order->customer->company))) {
+
+ if (!empty($order->customer->billing_address->company)) {
+ $cart['anrede'] = 'firma';
$cart['ansprechpartner'] = $cart['name'];
- $cart['name'] = strval($order->customer->company);
+ $cart['name'] = strval($order->customer->billing_address->company);
}
+
$cart['strasse'] = strval($order->customer->billing_address->street_1);
$cart['adresszusatz'] = strval($order->customer->billing_address->street_2);
$cart['telefon'] = strval($order->customer->billing_address->phone);
@@ -472,10 +475,12 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['lieferadresse_land'] = $this->app->DB->Select($sql);
$cart['lieferadresse_name'] = ($order->customer->shipping_address->civility?$order->customer->shipping_address->civility." ":"").$order->customer->shipping_address->firstname." ".$order->customer->shipping_address->lastname;
+
if (!empty(strval($order->customer->shipping_address->company))) {
$cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name'];
$cart['lieferadresse_name'] = strval($deliveryAddress->company);
}
+
$cart['lieferadresse_strasse'] = strval($order->customer->shipping_address->street_1);
$cart['lieferadresse_adresszusatz'] = strval($order->customer->shipping_address->street_2);
$cart['lieferadresse_telefon'] = strval($order->customer->shipping_address->phone);
From f1bd5020448f3bb7eb2aabc1d2eca05f70b35816 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 20 Jun 2024 14:23:51 +0200
Subject: [PATCH 31/87] laender 3-letter codes
---
www/pages/content/laender_edit.tpl | 1 +
www/pages/laender.php | 428 +++++++++++++++--------------
2 files changed, 217 insertions(+), 212 deletions(-)
diff --git a/www/pages/content/laender_edit.tpl b/www/pages/content/laender_edit.tpl
index 802be0f3..978e1eba 100644
--- a/www/pages/content/laender_edit.tpl
+++ b/www/pages/content/laender_edit.tpl
@@ -22,6 +22,7 @@
{|Land|}
diff --git a/www/pages/exportbuchhaltung.php b/www/pages/exportbuchhaltung.php
index ec3f2912..b96476e1 100644
--- a/www/pages/exportbuchhaltung.php
+++ b/www/pages/exportbuchhaltung.php
@@ -80,6 +80,7 @@ class Exportbuchhaltung
$lgchecked = $this->app->Secure->GetPOST("lieferantengutschrift");
$diffignore = $this->app->Secure->GetPOST("diffignore");
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
+ $format = $this->app->Secure->GetPOST('format');
$account_id = null;
if (!empty($sachkonto)) {
@@ -162,7 +163,7 @@ class Exportbuchhaltung
if ($dataok) {
$filename = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
try {
- $csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung);
+ $csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung, $format);
header("Content-Disposition: attachment; filename=" . $filename);
header("Pragma: no-cache");
header("Expires: 0");
@@ -214,9 +215,10 @@ class Exportbuchhaltung
/*
* Create DATEV Buchhungsstapel
+ * format: "ISO-8859-1", "UTF-8", "UTF-8-BOM"
* @throws ConsistencyException with string (list of items) if consistency check fails and no sachkonto for differences is given
*/
- function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences) : string {
+ function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences, string $format = "ISO-8859-1") : string {
$datev_header_definition = array (
'1' => 'Kennzeichen',
@@ -671,7 +673,17 @@ class Exportbuchhaltung
$csv .= '"0";"S";"EUR";"0";"";"";"1234";"1370";"";"101";"";"";"";"Testbuchung";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"0";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""'; // Testbuchung
- $csv = mb_convert_encoding($csv, "ISO-8859-1", "UTF-8");
+ switch ($format) {
+ case "UTF-8":
+ break;
+ case "UTF-8-BOM":
+ $csv = "\xef\xbb\xbf".$csv;
+ break;
+ default:
+ $csv = mb_convert_encoding($csv, "ISO-8859-1", "UTF-8");
+ break;
+ }
+
return($csv);
}
From cbd44d167a5a8dd239a9ca056e38e9822ee243be Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 13 Jul 2024 14:46:58 +0200
Subject: [PATCH 50/87] rework paketmarke contact fields
---
www/lib/class.versanddienstleister.php | 32 ++++++++++++++----
.../versandarten/content/createshipment.tpl | 33 ++++++++++---------
www/lib/versandarten/dhl.php | 28 +++++++++++++++-
www/lib/versandarten/sendcloud.php | 33 +++++++++++++++++--
4 files changed, 99 insertions(+), 27 deletions(-)
diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php
index c0fc16a6..921eccf6 100644
--- a/www/lib/class.versanddienstleister.php
+++ b/www/lib/class.versanddienstleister.php
@@ -68,6 +68,9 @@ abstract class Versanddienstleister
$auftragId = $this->app->DB->Select("SELECT auftragid FROM rechnung WHERE id=$rechnungId LIMIT 1");
if ($sid === 'rechnung' || $sid === 'lieferschein' || $sid === 'adresse') {
+
+ $ret['addresstype'] = 0; // 0 = firma, 1 = packstation, 2 = postfiliale, 3 = privatadresse
+
$docArr = $this->app->DB->SelectRow("SELECT * FROM `$sid` WHERE id = $id LIMIT 1");
$ret['addressId'] = $docArr['adresse'];
$ret['auftragId'] = $auftragId;
@@ -79,12 +82,28 @@ abstract class Versanddienstleister
$ret['original'] = array_filter($docArr, fn($key) => in_array($key, $addressfields), ARRAY_FILTER_USE_KEY);
- $ret['name'] = empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : trim($docArr['ansprechpartner']);
- $ret['name2'] = !empty(trim($docArr['ansprechpartner'])) ? trim($docArr['name']) : '';
- $ret['name3'] = join(';', array_filter([
- $docArr['abteilung'],
- $docArr['unterabteilung']
- ], fn(string $item) => !empty(trim($item))));
+ if ($docArr['typ'] == "firma") {
+ $ret['company_name'] = $docArr['name'];
+ $ret['addresstype'] = 0;
+ } else {
+ $ret['addresstype'] = 3;
+ }
+
+ $ret['contact_name'] = $docArr['ansprechpartner'];
+
+ $ret['company_division'] = join(
+ ';',
+ array_filter(
+ [
+ $docArr['abteilung'],
+ $docArr['unterabteilung']
+ ],
+ fn(string $item) => !empty(trim($item))
+ )
+ );
+
+ $ret['name'] = $docArr['name'];
+
$ret['address2'] = $docArr['adresszusatz'];
$ret['city'] = $docArr['ort'];
@@ -92,7 +111,6 @@ abstract class Versanddienstleister
$ret['country'] = $docArr['land'];
$ret['phone'] = $docArr['telefon'];
$ret['email'] = $docArr['email'];
- $ret['addresstype'] = 0;
$strasse = trim($docArr['strasse']);
$ret['streetwithnumber'] = $strasse;
diff --git a/www/lib/versandarten/content/createshipment.tpl b/www/lib/versandarten/content/createshipment.tpl
index d524c75f..db8e88da 100644
--- a/www/lib/versandarten/content/createshipment.tpl
+++ b/www/lib/versandarten/content/createshipment.tpl
@@ -18,29 +18,34 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
{|Adresstyp|}:
- Haus
+ Firma
Packstation
Filiale
+ Privatadresse
-
- {|Name / Zeile 1|}:
-
+
+ {|Firma|}:
+
- {|Firmenname / Zeile 2|}:
-
+ {|Abteilung|}:
+
+
+
+ {|Name|}:
+
+
+
+ {|Ansprechpartner|}:
+
{|Postnummer|}:
-
- {|Firmenname / Zeile 3|}:
-
-
-
+
{|Strasse/Hausnummer|}:
@@ -55,7 +60,7 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
{|Postfilialnummer|}:
-
+
{|Adresszeile 2|}:
@@ -77,10 +82,6 @@ SPDX-License-Identifier: LicenseRef-EGPL-3.1
-
- {|Ansprechpartner|}:
-
-
{|E-Mail|}:
diff --git a/www/lib/versandarten/dhl.php b/www/lib/versandarten/dhl.php
index ad065d86..9ed5e7ee 100644
--- a/www/lib/versandarten/dhl.php
+++ b/www/lib/versandarten/dhl.php
@@ -102,7 +102,19 @@ class Versandart_dhl extends Versanddienstleister{
switch ($json->addresstype) {
case 0:
$shipment->Receiver->Address = new ReceiverNativeAddress();
- $shipment->Receiver->Address->name2 = $json->name2;
+
+ $shipment->Receiver->name1 = $json->company_name;
+ $shipment->Receiver->Address->name2 = join(
+ ';',
+ array_filter(
+ [
+ $json->contact_name,
+ $json->company_division
+ ],
+ fn(string $item) => !empty(trim($item))
+ )
+ );
+
$shipment->Receiver->Address->streetName = $json->street ?? '';
$shipment->Receiver->Address->streetNumber = $json->streetnumber;
$shipment->Receiver->Address->city = $json->city ?? '';
@@ -127,6 +139,20 @@ class Versandart_dhl extends Versanddienstleister{
$shipment->Receiver->Postfiliale->zip = $json->zip ?? '';
$shipment->Receiver->Postfiliale->Origin = Country::Create($json->country ?? 'DE', $json->state);
break;
+ case 3:
+ $shipment->Receiver->Address = new ReceiverNativeAddress();
+
+ $shipment->Receiver->name1 = $json->name;
+ $shipment->Receiver->Address->name2 = $json->contact_name;
+
+ $shipment->Receiver->Address->streetName = $json->street ?? '';
+ $shipment->Receiver->Address->streetNumber = $json->streetnumber;
+ $shipment->Receiver->Address->city = $json->city ?? '';
+ $shipment->Receiver->Address->zip = $json->zip ?? '';
+ $shipment->Receiver->Address->Origin = Country::Create($json->country ?? 'DE', $json->state);
+ if (isset($json->address2) && !empty($json->address2))
+ $shipment->Receiver->Address->addressAddition[] = $json->address2;
+ break;
}
$shipment->Receiver->Communication = new Communication();
$shipment->Receiver->Communication->email = $json->email;
diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php
index cdda1cce..172a3116 100644
--- a/www/lib/versandarten/sendcloud.php
+++ b/www/lib/versandarten/sendcloud.php
@@ -82,8 +82,18 @@ class Versandart_sendcloud extends Versanddienstleister
$parcel->ShippingMethodId = $json->product;
$parcel->Name = $json->name;
switch ($json->addresstype) {
- case 0:
- $parcel->CompanyName = trim("$json->name2 $json->name3");
+ case 0:
+ $parcel->CompanyName = $json->company_name;
+ $parcel->Name = join(
+ ';',
+ array_filter(
+ [
+ $json->contact_name,
+ $json->company_division
+ ],
+ fn(string $item) => !empty(trim($item))
+ )
+ );
$parcel->Address = $json->street;
$parcel->Address2 = $json->address2;
$parcel->HouseNumber = $json->streetnumber;
@@ -98,6 +108,23 @@ class Versandart_sendcloud extends Versanddienstleister
$parcel->Address = "Postfiliale";
$parcel->HouseNumber = $json->postofficeNumber;
break;
+ case 3:
+ $parcel->Name = join(
+ ';',
+ array_filter(
+ [
+ $json->name,
+ $json->contact_name
+ ],
+ fn(string $item) => !empty(trim($item))
+ )
+ );
+
+ $parcel->Address = $json->street;
+ $parcel->Address2 = $json->address2;
+ $parcel->HouseNumber = $json->streetnumber;
+ break;
+
}
$parcel->Country = $json->country;
$parcel->PostalCode = $json->zip;
@@ -164,4 +191,4 @@ class Versandart_sendcloud extends Versanddienstleister
}
-}
\ No newline at end of file
+}
From f1400c48926887a07156fac9211d19bbaecb6417 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 19 Jul 2024 12:17:24 +0200
Subject: [PATCH 51/87] mirakl bugfix protokoll, taxes
---
www/lib/class.remote.php | 1 +
www/pages/shopimporter_mirakl.php | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 1c0a2f34..ea75cab4 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2159,6 +2159,7 @@ class Remote {
}
public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest
+ {
$orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
if (empty($orderArr))
return null;
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index c039e745..3822fb3c 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -175,7 +175,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
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'], '/') . '/';
$this->mirakl_shopid = $einstellungen['felder']['mirakl_shopid'];
@@ -545,7 +544,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
if($tax->rate > $steuersatz) {
$steuersatz = $tax->rate;
}
- switch ($order->row->taxes[0]->code) {
+ switch ($tax->code) {
case $this->reducedTaxId:
$umsatzsteuer_typ = 'ermaessigt';
break;
From 1c8d64f3be5e0c48b3656b469b78f6d78e42ed2b Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 22 Jul 2024 12:29:02 +0200
Subject: [PATCH 52/87] revert faulty commit verbindlichkeit.php
---
www/pages/verbindlichkeit.php | 40 ++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 99a1d0a4..374db9cb 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -228,7 +228,11 @@ class Verbindlichkeit {
$defaultorder = 1;
$defaultorderdesc = 0;
- $offen_menge = "";
+ $offen_menge = "TRIM(IF(
+ pd.menge > COALESCE(vp.menge,0),
+ pd.menge - COALESCE(vp.menge,0),
+ 0
+ ))+0";
$auswahl = array (
' '
);
@@ -297,7 +303,7 @@ class Verbindlichkeit {
// END Toggle filters
$sql = "
- SELECT * FROM (
+ SELECT SQL_CALC_FOUND_ROWS * FROM (
SELECT
pa.id pa_id,
".$this->app->erp->ConcatSQL($auswahl)." AS auswahl,
@@ -310,7 +316,11 @@ class Verbindlichkeit {
art.name_de,
pd.bemerkung,
pd.menge,
- 0 offen_menge,
+ IF(
+ pd.menge > COALESCE(vp.menge,0),
+ pd.menge - COALESCE(vp.menge,0),
+ 0
+ ) offen_menge,
".$this->app->erp->ConcatSQL($werte).",
".$this->app->erp->ConcatSQL($preise)." AS preis,
if(art.umsatzsteuer = '',art.steuersatz,art.umsatzsteuer) steuer,
@@ -319,28 +329,38 @@ class Verbindlichkeit {
CONCAT(skadr.sachkonto,' ',skadr.beschriftung)
) AS sachkonto
FROM
- paketdistribution pd
- LEFT JOIN paketannahme pa ON
+ paketannahme pa
+ INNER JOIN paketdistribution pd ON
pd.paketannahme = pa.id
- LEFT JOIN artikel art ON
+ INNER JOIN artikel art ON
art.id = pd.artikel
LEFT JOIN adresse adr ON
adr.id = pa.adresse
LEFT JOIN bestellung_position bp ON
bp.id = pd.bestellung_position
LEFT JOIN bestellung b ON
- b.id = bp.bestellung
+ b.id = bp.bestellung
+ LEFT JOIN(
+ SELECT
+ paketdistribution,
+ SUM(menge) AS menge
+ FROM
+ verbindlichkeit_position vp
+ GROUP BY
+ paketdistribution
+ ) vp
+ ON
+ vp.paketdistribution = pd.id
LEFT JOIN
kontorahmen skart ON skart.id = art.kontorahmen
LEFT JOIN
kontorahmen skadr ON skadr.id = adr.kontorahmen
- WHERE pa.adresse = '".$lieferant."'
- GROUP BY pd.id
+ WHERE pa.adresse = ".$lieferant." AND pd.vorlaeufig IS NULL".$innerwhere."
) temp
";
$count = "";
- $groupby = "";
+// $groupby = "";
break;
case 'verbindlichkeit_positionen':
From 58174a8eef14340d38bfb713973e9c20afb957dd Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 23 Jul 2024 13:12:34 +0200
Subject: [PATCH 53/87] mirakl volume pricing
---
www/pages/shopimporter_mirakl.php | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 3822fb3c..0d025cc4 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -621,8 +621,27 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$configuration_found = false;
$additional_fields = array();
+ // Prepare volume prices
+ $volume_prices = array();
+
+ foreach ($article['staffelpreise_standard'] as $volume_price) {
+ if ($volume_price['ab_menge'] > 1) {
+ $volume_prices[] = array (
+ 'quantity_threshold' => (int) $volume_price['ab_menge'],
+ 'unit_discount_price' => $volume_price['preis'],
+ 'unit_origin_price' => $article['preis']
+ );
+ }
+ }
+
+ $all_prices = array (
+ 'volume_prices' => $volume_prices
+ );
+
$offer_for_mirakl = array(
- 'state_code' => '11', // ?!?!
+ 'state_code' => '11', // Condition new
+ 'price' => $article['preis'],
+ 'all_prices' => array($all_prices),
'update_delete' => null // Update delete flag. Could be empty (means "update"), "update" or "delete".
);
@@ -645,8 +664,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$required = [
'product_id_type',
'product_id',
- 'shop_sku',
- 'price'
+ 'shop_sku'
];
$missing = null;
foreach ($required as $key) {
@@ -718,7 +736,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$json_for_mirakl = json_encode($data_for_mirakl);
- $this->Log(Logger::DEBUG, 'Angebotsexport Daten', $json_for_mirakl);
+ $this->Log(Logger::DEBUG, 'Angebotsexport Daten', ['json' => $json_for_mirakl]);
$result = [];
$response = $this->miraklRequest('offers', postdata: $json_for_mirakl, content_type: 'application/json', raw: true);
From 9a9e34a32ae335d5bf04cbd672849ba655dd34c9 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 24 Jul 2024 16:01:17 +0200
Subject: [PATCH 54/87] erpapi bugfix result of RemoteSendArticleList, new
array format
---
www/lib/class.erpapi.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index b1ffdedf..72cb4d94 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -21046,7 +21046,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
$anzges = 0;
$anzfehler = 0;
- $result = null; // 1 on success
+ $result = null; // $result['status'] == 1 on success
if(!empty($extnummer) && is_array($extnummer)) {
foreach($extnummer as $nummer) {
@@ -21077,9 +21077,9 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
}
- $this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.gettype($result).' '.$result);
+ $this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.(is_array($result)?$result['status']:$result), $result);
- if ($result == 1) {
+ if ($result['status'] == 1 || $status === 1) {
$cacheQuantity = (int) $verkaufbare_menge_korrektur + (int) $pseudolager;
$this->app->DB->Update(
"UPDATE `artikel` SET `cache_lagerplatzinhaltmenge` = '{$cacheQuantity}'
From fbe266c97c486c841f5c75e3a6bb7c9678a3a561 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 1 Aug 2024 14:04:48 +0200
Subject: [PATCH 55/87] bugfix mirakl auftragsimport country code
---
www/pages/shopimporter_mirakl.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 0d025cc4..063a18fc 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -501,7 +501,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['ort'] = strval($order->customer->billing_address->city);
// $cart['ustid'] = '?';
- $sql = "SELECT iso FROM laender WHERE iso3 = '".$order->customer->billing_address->country_iso_code."'";
+ if ($order->customer->billing_address->country_iso_code) {
+ $sql = "SELECT iso FROM laender WHERE iso3 = '".$order->customer->billing_address->country_iso_code."' LIMIT 1";
+ }
$cart['land'] = $this->app->DB->Select($sql);
$cart['abweichendelieferadresse'] = 1;
From d180a1af54cd340a88a476c779f02e06c5f5c872 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 3 Aug 2024 13:33:58 +0200
Subject: [PATCH 56/87] module_creator echo $sql
---
tools/module_creator/module_creator_php_template.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/module_creator/module_creator_php_template.txt b/tools/module_creator/module_creator_php_template.txt
index e0806214..6bdb7f6d 100644
--- a/tools/module_creator/module_creator_php_template.txt
+++ b/tools/module_creator/module_creator_php_template.txt
@@ -36,7 +36,7 @@ class PLACEHOLDER_MODULECLASSNAME {
// columns that are aligned right (numbers etc)
// $alignright = array(4,5,6,7,8);
- $findcols = array('PLACEHOLDER_ID_COLUMN','PLACEHOLDER_ID_COLUMN',PLACEHOLDER_SQL_COLUMNS);
+ $findcols = array('PLACEHOLDER_ID_COLUMN','PLACEHOLDER_ID_COLUMN',PLACEHOLDER_SQL_COLUMNS); // use 'null' for non-searchable columns
$searchsql = array(PLACEHOLDER_SQL_COLUMNS);
$defaultorder = 1;
@@ -60,6 +60,8 @@ class PLACEHOLDER_MODULECLASSNAME {
$count = "SELECT count(DISTINCT id) FROM PLACEHOLDER_MODULENAME WHERE $where";
// $groupby = "";
+// echo($sql." WHERE ".$where." ".$groupby);
+
break;
}
From 94f3fb0261426125c47b8fd93670f782110275c7 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 3 Aug 2024 14:28:05 +0200
Subject: [PATCH 57/87] cronjobs/cleaner.php removed shopimport_amazon_fees
---
cronjobs/cleaner.php | 28 ++--------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/cronjobs/cleaner.php b/cronjobs/cleaner.php
index 4c0759e0..85c4a1ff 100644
--- a/cronjobs/cleaner.php
+++ b/cronjobs/cleaner.php
@@ -148,8 +148,7 @@ $tables = [
'templatemessage',
'shopimport_auftraege',
'versandzentrum_log',
- 'api_request_response_log',
- 'shopimport_amazon_fees',
+ 'api_request_response_log'
];
$minMemoryMb = 1;
$minMemory = $minMemoryMb * 1024 * 1024;
@@ -623,34 +622,11 @@ if($shopExportLogCleanerActive && $tage > 0) {
$shopExportLogCleanerActive = $app->erp->Firmendaten('cleaner_shopexportlog');
$tage = (int)$app->erp->Firmendaten('cleaner_shopexportlog_tage');
-$isToDelete = !empty($tableSchemaByTables['shopimport_amazon_fees'])
- && !empty($tableSchemaByTables['shopimport_amazon_fees']['todelete']);
-if((!$shopExportLogCleanerActive || $tage <= 0 || $tage > 30) && $isToDelete) {
- $shopExportLogCleanerActive = true;
- if($tage <= 0 || $tage > 30) {
- $tage = 30;
- }
-}
+
if($shopExportLogCleanerActive && $tage > 0) {
if($tage < 30) {
$tage = 30;
}
- $app->DB->Delete(
- sprintf(
- "DELETE FROM `shopimport_amazon_fees`
- WHERE DATE_SUB(NOW(), INTERVAL %d DAY) >= `zeitstempel` OR `zeitstempel` = '0000-00-00 00:00:00'",
- $tage
- )
- );
- $affectedRows = $app->DB->affected_rows();
- if(!empty($tableSchemaByTables['shopimport_amazon_fees'])
- && ($tableSchemaByTables['shopimport_amazon_fees']['todelete'] > 0)) {
- $tableSchemaByTables['shopimport_amazon_fees']['todelete'] -= $affectedRows;
- }
- if($affectedRows > 0 && !empty($optimize['shopimport_amazon_fees'])) {
- $app->DB->Query('OPTIMIZE TABLE `shopimport_amazon_fees`');
- unset($optimize['shopimport_amazon_fees']);
- }
$app->DB->Update(
"UPDATE prozessstarter SET letzteausfuerhung=NOW(),mutex=1,mutexcounter=0 WHERE parameter = 'cleaner' AND aktiv = 1"
);
From 5ad57e2fc813b4c2e3b6885252263a6638e94804 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sun, 11 Aug 2024 12:46:41 +0200
Subject: [PATCH 58/87] bugfix TOTP, additional database entries needed:
login_password_check_otp (hook), TOTPCheckLogin (hook_register)
---
.../Modules/TOTPLogin/TOTPLoginService.php | 2 +-
phpwf/plugins/class.templateparser.php | 2 +-
www/pages/totp.php | 261 +++++++++---------
3 files changed, 132 insertions(+), 133 deletions(-)
diff --git a/classes/Modules/TOTPLogin/TOTPLoginService.php b/classes/Modules/TOTPLogin/TOTPLoginService.php
index ecfe97ab..09f20803 100644
--- a/classes/Modules/TOTPLogin/TOTPLoginService.php
+++ b/classes/Modules/TOTPLogin/TOTPLoginService.php
@@ -270,7 +270,7 @@ class TOTPLoginService
$secret = $this->getTOTPSecret($userId);
}
- $query = "otpauth://totp/{$label}?secret=" . $secret . '&issuer=Xentral&algorithm=SHA1&digits=6&period=30';
+ $query = "otpauth://totp/{$label}?secret=" . $secret . '&issuer=OpenXE&algorithm=SHA1&digits=6&period=30';
return $this->barcodeService->createQrCode($query);
}
diff --git a/phpwf/plugins/class.templateparser.php b/phpwf/plugins/class.templateparser.php
index 09854989..c7e55f3d 100644
--- a/phpwf/plugins/class.templateparser.php
+++ b/phpwf/plugins/class.templateparser.php
@@ -616,7 +616,7 @@ class TemplateParser {
}
}
- if(count($this->VARARRAY)>0)
+ if(!empty($this->VARARRAY))
foreach($this->VARARRAY as $key=>$value)
{
if($key!="")
diff --git a/www/pages/totp.php b/www/pages/totp.php
index 8d382bd2..420238e5 100644
--- a/www/pages/totp.php
+++ b/www/pages/totp.php
@@ -1,134 +1,133 @@
-app = $app;
-
- if($intern) return;
-
- $app->ActionHandlerInit($this);
-
- $app->ActionHandler('generate', 'TOTPGenerateSecretJSON');
- $app->ActionHandler('enable', 'TOTPEnable');
- $app->ActionHandler('disable', 'TOTPDisable');
-
- $app->ActionHandlerListen($app);
- }
-
- public function Install()
- {
- $tableName = 'user_totp';
- $this->app->erp->CheckTable($tableName);
- $this->app->erp->CheckColumn('id', 'UNSIGNED INT', $tableName, 'NOT NULL AUTO_INCREMENT');
- $this->app->erp->CheckColumn('user_id', 'INT', $tableName, 'UNSIGNED NOT NULL');
- $this->app->erp->CheckColumn('active', 'TINYINT(1)', $tableName, 'UNSIGNED DEFAULT 0');
- $this->app->erp->CheckColumn('secret', 'VARCHAR(100)', $tableName, 'NOT NULL');
- $this->app->erp->CheckColumn('created_at', 'TIMESTAMP', $tableName, 'DEFAULT NOW()');
- $this->app->erp->CheckColumn('modified_at', 'TIMESTAMP', $tableName);
- $this->app->erp->CheckIndex($tableName, 'user_id', true);
-
- $this->app->erp->RegisterHook('login_password_check_otp', 'totp', 'TOTPCheckLogin', 1, false, null, 3);
- }
-
- function TOTPDisable(){
- $action = $this->app->Secure->GetPOST('action');
-
- if($action !== 'disable'){
- return new JsonResponse(['status' => 'error', 'msg' => 'muss POST sein'], 400);
- }
-
- /** @var TOTPLoginService $totpLoginService */
- $totpLoginService = $this->app->Container->get('TOTPLoginService');
-
- $userId = $this->app->User->GetID();
-
- $totpLoginService->disableTotp($userId);
-
- return new JsonResponse(['status' => 'success']);
- }
-
- function TOTPEnable(){
- $secret = $this->app->Secure->GetPOST('secret');
-
- if(empty($secret)){
- return new JsonResponse(['status' => 'error', 'msg' => 'Secret Empty'], 400);
- }
-
- /** @var TOTPLoginService $totpLoginService */
- $totpLoginService = $this->app->Container->get('TOTPLoginService');
-
- $userId = $this->app->User->GetID();
-
- $totpLoginService->enableTotp($userId);
- $totpLoginService->setUserSecret($userId, $secret);
-
- return new JsonResponse(['status' => 'success']);
- }
-
- /**
- * @param $userID
- * @param $token
- * @param $passwordValid
- *
- * @throws Exception
- */
- public function TOTPCheckLogin($userID, $token, &$passwordValid)
- {
- /** @var TOTPLoginService $totpLoginService */
- $totpLoginService = $this->app->Container->get('TOTPLoginService');
-
- if(!$totpLoginService->isTOTPEnabled($userID)){
- return;
- }
- $passwordValid = $totpLoginService->isTokenValid($userID, $token);
- }
-
- public function TOTPGenerateSecretJSON(){
- /** @var TOTPLoginService $totpLoginService */
- $totpLoginService = $this->app->Container->get('TOTPLoginService');
-
- /** @var \Xentral\Components\Token\TOTPTokenManager $tokenManager */
- $tokenManager = $this->app->Container->get('TOTPTokenManager');
-
- $secret = $tokenManager->generateBase32Secret();
-
- $label = 'Xentral' . ' | ' . $this->app->erp->GetFirmaName();
-
- $qr = $totpLoginService->generatePairingQrCode($this->app->User->GetID(), $label, $secret);
-
- return new JsonResponse(
- [
- 'secret' => $secret,
- 'qr' => $qr->toHtml(4, 4)
- ]
- );
- }
-}
+app = $app;
+
+ if($intern) return;
+
+ $app->ActionHandlerInit($this);
+
+ $app->ActionHandler('generate', 'TOTPGenerateSecretJSON');
+ $app->ActionHandler('enable', 'TOTPEnable');
+ $app->ActionHandler('disable', 'TOTPDisable');
+
+ $app->ActionHandlerListen($app);
+ }
+
+ public function Install()
+ {
+ $tableName = 'user_totp';
+ $this->app->erp->CheckTable($tableName);
+ $this->app->erp->CheckColumn('id', 'UNSIGNED INT', $tableName, 'NOT NULL AUTO_INCREMENT');
+ $this->app->erp->CheckColumn('user_id', 'INT', $tableName, 'UNSIGNED NOT NULL');
+ $this->app->erp->CheckColumn('active', 'TINYINT(1)', $tableName, 'UNSIGNED DEFAULT 0');
+ $this->app->erp->CheckColumn('secret', 'VARCHAR(100)', $tableName, 'NOT NULL');
+ $this->app->erp->CheckColumn('created_at', 'TIMESTAMP', $tableName, 'DEFAULT NOW()');
+ $this->app->erp->CheckColumn('modified_at', 'TIMESTAMP', $tableName);
+ $this->app->erp->CheckIndex($tableName, 'user_id', true);
+
+ $this->app->erp->RegisterHook('login_password_check_otp', 'totp', 'TOTPCheckLogin', 1, false, null, 3);
+ }
+
+ function TOTPDisable(){
+ $action = $this->app->Secure->GetPOST('action');
+
+ if($action !== 'disable'){
+ return new JsonResponse(['status' => 'error', 'msg' => 'muss POST sein'], 400);
+ }
+
+ /** @var TOTPLoginService $totpLoginService */
+ $totpLoginService = $this->app->Container->get('TOTPLoginService');
+
+ $userId = $this->app->User->GetID();
+
+ $totpLoginService->disableTotp($userId);
+
+ return new JsonResponse(['status' => 'success']);
+ }
+
+ function TOTPEnable(){
+ $secret = $this->app->Secure->GetPOST('secret');
+
+ if(empty($secret)){
+ return new JsonResponse(['status' => 'error', 'msg' => 'Secret Empty'], 400);
+ }
+
+ /** @var TOTPLoginService $totpLoginService */
+ $totpLoginService = $this->app->Container->get('TOTPLoginService');
+
+ $userId = $this->app->User->GetID();
+
+ $totpLoginService->enableTotp($userId);
+ $totpLoginService->setUserSecret($userId, $secret);
+
+ return new JsonResponse(['status' => 'success']);
+ }
+
+ /**
+ * @param $userID
+ * @param $token
+ * @param $passwordValid
+ *
+ * @throws Exception
+ */
+ public function TOTPCheckLogin($userID, $token, &$passwordValid)
+ {
+ /** @var TOTPLoginService $totpLoginService */
+ $totpLoginService = $this->app->Container->get('TOTPLoginService');
+ if(!$totpLoginService->isTOTPEnabled($userID)){
+ return;
+ }
+ $passwordValid = $totpLoginService->isTokenValid($userID, $token);
+ }
+
+ public function TOTPGenerateSecretJSON(){
+ /** @var TOTPLoginService $totpLoginService */
+ $totpLoginService = $this->app->Container->get('TOTPLoginService');
+
+ /** @var \Xentral\Components\Token\TOTPTokenManager $tokenManager */
+ $tokenManager = $this->app->Container->get('TOTPTokenManager');
+
+ $secret = $tokenManager->generateBase32Secret();
+
+ $label = 'OpenXE' . ':' . $this->app->User->Getname();
+
+ $qr = $totpLoginService->generatePairingQrCode($this->app->User->GetID(), $label, $secret);
+
+ return new JsonResponse(
+ [
+ 'secret' => $secret,
+ 'qr' => $qr->toHtml(4, 4)
+ ]
+ );
+ }
+}
From 7e2155f586db0ac879fb0a5404c7403263eae084 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sun, 11 Aug 2024 13:10:35 +0200
Subject: [PATCH 59/87] TOTP, additional database entries for fresh install
---
database/struktur.sql | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/database/struktur.sql b/database/struktur.sql
index 8f70631f..272dd39c 100755
--- a/database/struktur.sql
+++ b/database/struktur.sql
@@ -17873,6 +17873,15 @@ INSERT INTO `hook_register` (`hook_action`, `function`, `aktiv`, `position`, `ho
;
/* OpenXE 2024-02-03 für belegvorlagen */
+/* OpenXE 2024-08-11 für TOTP */
+INSERT INTO `hook`(`name`, `aktiv`, `parametercount`, `alias`, `description`) VALUES
+('login_password_check_otp', 1, 3, '', '');
+
+INSERT INTO `hook_register`(
+ `hook_action`, `function`, `aktiv`, `position`, `hook`, `module`, `module_parameter`) VALUES
+ ( 0, 'TOTPCheckLogin', 1, 1, (SELECT id FROM hook WHERE NAME = 'login_password_check_otp' LIMIT 1), 'totp', 0);
+/* OpenXE 2024-08-11 für TOTP */
+
/*
BelegPositionenButtons
From 23b9fa781b3c7c0b8d62070b18f08c3d34960600 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sun, 11 Aug 2024 13:19:53 +0200
Subject: [PATCH 60/87] Smarty shopimport, additional database entries for
fresh install
---
database/struktur.sql | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/database/struktur.sql b/database/struktur.sql
index 272dd39c..2b0475e9 100755
--- a/database/struktur.sql
+++ b/database/struktur.sql
@@ -17882,6 +17882,14 @@ INSERT INTO `hook_register`(
( 0, 'TOTPCheckLogin', 1, 1, (SELECT id FROM hook WHERE NAME = 'login_password_check_otp' LIMIT 1), 'totp', 0);
/* OpenXE 2024-08-11 für TOTP */
+/* OpenXE 2024-08-11 für Smarty shopimport */
+INSERT INTO `hook` (`name`, `aktiv`, `parametercount`, `alias`, `description`) VALUES
+('ImportAuftragBefore', 1, 4, '', '');
+
+INSERT INTO `hook_register` (`hook_action`, `function`, `aktiv`, `position`, `hook`, `module`, `module_parameter`) VALUES
+(0, 'ImportAuftragBeforeHook', 1, 1, (SELECT id FROM hook WHERE name = 'ImportAuftragBefore' LIMIT 1), 'onlineshops', 0);
+/* OpenXE 2024-08-11 für Smarty shopimport */
+
/*
BelegPositionenButtons
From e1b9428ef56f70a600f2d414f204f69951420eac Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Mon, 12 Aug 2024 13:12:02 +0200
Subject: [PATCH 61/87] Shopimport: Fix sql escaping
---
www/lib/class.erpapi.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 381e6114..30b1f402 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -16624,9 +16624,10 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
$check = $this->app->DB->Select("SELECT $key FROM adresse WHERE id='$adresse' LIMIT 1");
if($check!=${$key})
{
- $this->app->DB->Update("UPDATE adresse SET $key='".${$key}."' WHERE id='$adresse' LIMIT 1");
+ $val = $this->app->DB->real_escape_string(${$key});
+ $this->app->DB->Update("UPDATE adresse SET $key='$val' WHERE id='$adresse' LIMIT 1");
$logfile = $this->app->DB->Select("SELECT `logfile` FROM adresse WHERE id='$adresse' LIMIT 1");
- $this->app->DB->Update("UPDATE adresse SET `logfile`='".$logfile." Update Feld $key alt:$check neu:".${$key}.";' WHERE id='$adresse' LIMIT 1");
+ $this->app->DB->Update("UPDATE adresse SET `logfile`='".$logfile." Update Feld $key alt:$check neu:".$val.";' WHERE id='$adresse' LIMIT 1");
}
}
From 3eb4d6bc3a736487eb39bcff6d6d731a9bdb7efa Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 22 Aug 2024 12:45:59 +0200
Subject: [PATCH 62/87] lagerzahlen removed 10 sec. wait
---
cronjobs/lagerzahlen.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cronjobs/lagerzahlen.php b/cronjobs/lagerzahlen.php
index a1ef1e0b..bd50830c 100644
--- a/cronjobs/lagerzahlen.php
+++ b/cronjobs/lagerzahlen.php
@@ -139,8 +139,8 @@ foreach ($lagerartikel as $articleCounter => $articleId) {
$app->erp->LogFile("Lagerzahlen-Synchronisation Ende: lagerzahlen-Job kann nicht geladen werden");
return;
}
- $app->erp->LogFile("Lagerzahlen-Synchronisation: Warte 10 Sekunden");
- usleep(10000);
+// $app->erp->LogFile("Lagerzahlen-Synchronisation: Warte 10 Sekunden");
+// usleep(10000);
}
$app->DB->Update(
"UPDATE `prozessstarter`
From 50d8646d70381cceb41faa2a4d070370a0b57e75 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sun, 25 Aug 2024 14:32:56 +0200
Subject: [PATCH 63/87] verbindlichkeit date assistant
---
www/pages/content/verbindlichkeit_edit.tpl | 6 +-
www/pages/verbindlichkeit.php | 581 +++++++++++----------
2 files changed, 302 insertions(+), 285 deletions(-)
diff --git a/www/pages/content/verbindlichkeit_edit.tpl b/www/pages/content/verbindlichkeit_edit.tpl
index 319ca0c1..83a20a37 100644
--- a/www/pages/content/verbindlichkeit_edit.tpl
+++ b/www/pages/content/verbindlichkeit_edit.tpl
@@ -62,7 +62,7 @@
{|Rechnungsdatum|}:
-
+
@@ -103,7 +103,7 @@
{|Zahlbar bis|}:
-
+ Tage
@@ -119,7 +119,7 @@
{|Skonto bis|}:
-
+ Tage
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 45a559e0..3eda30d8 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -15,7 +15,7 @@ class Verbindlichkeit {
return;
$this->app->ActionHandlerInit($this);
- $this->app->ActionHandler("list", "verbindlichkeit_list");
+ $this->app->ActionHandler("list", "verbindlichkeit_list");
$this->app->ActionHandler("create", "verbindlichkeit_edit"); // This automatically adds a "New" button
$this->app->ActionHandler("edit", "verbindlichkeit_edit");
$this->app->ActionHandler("positionen", "verbindlichkeit_positionen");
@@ -28,10 +28,10 @@ class Verbindlichkeit {
$this->app->ActionHandler("freigabe", "verbindlichkeit_freigabe");
$this->app->ActionHandler("freigabeeinkauf", "verbindlichkeit_freigabeeinkauf");
$this->app->ActionHandler("freigabebuchhaltung", "verbindlichkeit_freigabebuchhaltung");
- $this->app->ActionHandler("freigabebezahlt", "verbindlichkeit_freigabebezahlt");
+ $this->app->ActionHandler("freigabebezahlt", "verbindlichkeit_freigabebezahlt");
$this->app->ActionHandler("ruecksetzeneinkauf", "verbindlichkeit_ruecksetzeneinkauf");
$this->app->ActionHandler("ruecksetzenbuchhaltung", "verbindlichkeit_ruecksetzenbuchhaltung");
- $this->app->ActionHandler("ruecksetzenbezahlt", "verbindlichkeit_ruecksetzenbezahlt");
+ $this->app->ActionHandler("ruecksetzenbezahlt", "verbindlichkeit_ruecksetzenbezahlt");
$this->app->ActionHandler("minidetail", "verbindlichkeit_minidetail");
$this->app->DefaultActionHandler("list");
@@ -50,14 +50,14 @@ class Verbindlichkeit {
$width = array('1%','1%','10%'); // Fill out manually later
// columns that are aligned right (numbers etc)
- // $alignright = array(4,5,6,7,8);
+ // $alignright = array(4,5,6,7,8);
$findcols = array(
'v.id',
'v.id',
'v.belegnr',
'a.name',
- 'a.lieferantennummer',
+ 'a.lieferantennummer',
'v.rechnung',
'v.rechnungsdatum',
'v.betrag',
@@ -70,10 +70,10 @@ class Verbindlichkeit {
'v.status_beleg',
'v.id'
);
-
- $searchsql = array(
+
+ $searchsql = array(
'a.name',
- 'a.lieferantennummer',
+ 'a.lieferantennummer',
'v.rechnung',
'v.internebemerkung'
);
@@ -91,7 +91,7 @@ class Verbindlichkeit {
$menu = "";
- $sql = "SELECT SQL_CALC_FOUND_ROWS
+ $sql = "SELECT SQL_CALC_FOUND_ROWS
v.id,
$dropnbox,
v.belegnr,
@@ -103,8 +103,8 @@ class Verbindlichkeit {
v.waehrung,
if(v.bezahlt,'bezahlt','offen'),
".$app->erp->FormatDate("v.zahlbarbis").",
- IF(v.skonto <> 0,".$app->erp->FormatDate("v.skontobis").",''),
- IF(v.skonto <> 0,CONCAT(".$app->erp->FormatMenge('v.skonto',0).",'%'),''),
+ IF(v.skonto <> 0,".$app->erp->FormatDate("v.skontobis").",''),
+ IF(v.skonto <> 0,CONCAT(".$app->erp->FormatMenge('v.skonto',0).",'%'),''),
v.status,
".$app->YUI->IconsSQLVerbindlichkeit().",
v.id FROM verbindlichkeit v
@@ -134,9 +134,9 @@ class Verbindlichkeit {
else
oMoreData' . $r . $name . ' = 1;
- $(\'#' . $name . '\').dataTable().fnFilter(
+ $(\'#' . $name . '\').dataTable().fnFilter(
\'\',
- i,
+ i,
0,0
);
}
@@ -145,7 +145,7 @@ class Verbindlichkeit {
$more_data1 = $this->app->Secure->GetGET("more_data1");
if ($more_data1 == 1) {
- $where .= " AND datei_anzahl IS NULL";
+ $where .= " AND datei_anzahl IS NULL";
} else {
}
@@ -154,36 +154,36 @@ class Verbindlichkeit {
$where .= " AND v.freigabe <> '1'";
}
else {
- }
+ }
$more_data3 = $this->app->Secure->GetGET("more_data3");
if ($more_data3 == 1) {
$where .= " AND v.rechnungsfreigabe <> '1'";
}
- else {
- }
-
+ else {
+ }
+
$more_data4 = $this->app->Secure->GetGET("more_data4");
if ($more_data4 == 1) {
- $where .= " AND v.bezahlt <> 1";
+ $where .= " AND v.bezahlt <> 1";
+ }
+ else {
}
- else {
- }
$more_data5 = $this->app->Secure->GetGET("more_data5");
if ($more_data5 == 1) {
}
- else {
- $where .= " AND v.status <> 'storniert'";
- }
+ else {
+ $where .= " AND v.status <> 'storniert'";
+ }
$more_data6 = $this->app->Secure->GetGET("more_data6");
if ($more_data6 == 1) {
}
- else {
- $where .= " AND v.status <> 'abgeschlossen'";
- }
-
+ else {
+ $where .= " AND v.status <> 'abgeschlossen'";
+ }
+
$this->app->YUI->DatePicker('zahlbarbis');
$filterzahlbarbis = $this->app->YUI->TableSearchFilter($name, 7,'zahlbarbis');
if (!empty($filterzahlbarbis)) {
@@ -204,7 +204,7 @@ class Verbindlichkeit {
break;
case 'verbindlichkeit_paketdistribution_list':
- $allowed['verbindlichkeit_paketdistribution_list'] = array('list');
+ $allowed['verbindlichkeit_paketdistribution_list'] = array('list');
$id = $app->Secure->GetGET('id');
if (empty($id)) {
@@ -212,13 +212,13 @@ class Verbindlichkeit {
}
$verbindlichkeit = $app->DB->SelectArr("SELECT v.adresse, v.rechnung, b.belegnr FROM verbindlichkeit v LEFT JOIN bestellung b ON b.id = v.bestellung WHERE v.id = ".$id)[0];
-
+
$lieferant = $verbindlichkeit['adresse'];
$bestellnummer = $verbindlichkeit['belegnr'];
$rechnung = $verbindlichkeit['rechnung'];
-
+
$heading = array('', 'Paket-Nr.','Paket-Pos.', 'Bestellung', 'Lieferschein', 'Rechnung', 'Artikel-Nr.','Artikel','Bemerkung','Menge','Menge offen','Eingabe','Preis','Steuer','Sachkonto','');
- $width = array( '1%','1%', '1%', '5%', '5%', '5%', '5%', '20%', '20%', '2%', '1%', '1%', '1%', '1%', '1%', '1%');
+ $width = array( '1%','1%', '1%', '5%', '5%', '5%', '5%', '20%', '20%', '2%', '1%', '1%', '1%', '1%', '1%', '1%');
$findcols = array('id','pa','id','belegnr','lsnr','renr','artikelnummer','name_de','bemerkung','menge','offen_menge','offen_menge','preis','steuer','sachkonto','pa');
$searchsql = array('p.nummer', 'p.name', 'p.bemerkung');
@@ -226,7 +226,7 @@ class Verbindlichkeit {
$alignright = array(9,10);
$defaultorder = 1;
- $defaultorderdesc = 0;
+ $defaultorderdesc = 0;
$offen_menge = "TRIM(IF(
pd.menge > COALESCE(vp.menge,0),
@@ -235,10 +235,10 @@ class Verbindlichkeit {
))+0";
$auswahl = array (
- ' 'pd.id'],
'"/>'
- );
+ );
$werte = array (
' $offen_menge],
'"/>'
- );
+ );
$preise = array (
' '
- );
-
+ );
+
$artikellink = array (
'',
+ '">',
['sql' => 'art.nummer'],
' '
);
@@ -267,16 +267,16 @@ class Verbindlichkeit {
$paketlink = array (
'',
+ '">',
['sql' => 'pa.id'],
' '
);
-
+
$where = "offen_menge > 0";
// Toggle filters
$this->app->Tpl->Add('JQUERYREADY', "$('#passende').click( function() { fnFilterColumn1( 0 ); } );");
-
+
for ($r = 1;$r <= 1;$r++) {
$this->app->Tpl->Add('JAVASCRIPT', '
function fnFilterColumn' . $r . ' ( i )
@@ -286,9 +286,9 @@ class Verbindlichkeit {
else
oMoreData' . $r . $name . ' = 1;
- $(\'#' . $name . '\').dataTable().fnFilter(
+ $(\'#' . $name . '\').dataTable().fnFilter(
\'\',
- i,
+ i,
0,0
);
}
@@ -299,12 +299,12 @@ class Verbindlichkeit {
if ($more_data1 == 1) {
$innerwhere .= " AND ((b.belegnr LIKE '%".$bestellnummer."%' AND '".$bestellnummer."' <> '') OR (pa.renr LIKE '%".$rechnung."%' AND pa.renr <> ''))";
} else {
- }
- // END Toggle filters
+ }
+ // END Toggle filters
$sql = "
SELECT SQL_CALC_FOUND_ROWS * FROM (
- SELECT
+ SELECT
pa.id pa_id,
".$this->app->erp->ConcatSQL($auswahl)." AS auswahl,
".$this->app->erp->ConcatSQL($paketlink)." pa,
@@ -326,7 +326,7 @@ class Verbindlichkeit {
if(art.umsatzsteuer = '',art.steuersatz,art.umsatzsteuer) steuer,
if (skart.id <> 0,
CONCAT(skart.sachkonto,' ',skart.beschriftung),
- CONCAT(skadr.sachkonto,' ',skadr.beschriftung)
+ CONCAT(skadr.sachkonto,' ',skadr.beschriftung)
) AS sachkonto
FROM
paketannahme pa
@@ -339,7 +339,7 @@ class Verbindlichkeit {
LEFT JOIN bestellung_position bp ON
bp.id = pd.bestellung_position
LEFT JOIN bestellung b ON
- b.id = bp.bestellung
+ b.id = bp.bestellung
LEFT JOIN(
SELECT
paketdistribution,
@@ -350,11 +350,11 @@ class Verbindlichkeit {
paketdistribution
) vp
ON
- vp.paketdistribution = pd.id
- LEFT JOIN
+ vp.paketdistribution = pd.id
+ LEFT JOIN
kontorahmen skart ON skart.id = art.kontorahmen
- LEFT JOIN
- kontorahmen skadr ON skadr.id = adr.kontorahmen
+ LEFT JOIN
+ kontorahmen skadr ON skadr.id = adr.kontorahmen
WHERE pa.adresse = ".$lieferant." AND pd.vorlaeufig IS NULL".$innerwhere."
) temp
";
@@ -365,24 +365,24 @@ class Verbindlichkeit {
break;
case 'verbindlichkeit_positionen':
- $allowed['verbindlichkeit_positionen'] = array('list');
+ $allowed['verbindlichkeit_positionen'] = array('list');
$id = $app->Secure->GetGET('id');
$freigabe = $app->DB->Select("SELECT freigabe FROM verbindlichkeit WHERE id = '".$id."'");
$rechnungsfreigabe = $app->DB->Select("SELECT rechnungsfreigabe FROM verbindlichkeit WHERE id = '".$id."'");
$heading = array('', 'Paket-Nr.','Paket-Pos.', 'Bestellung', 'Artikel-Nr.','Artikel','Bemerkung','Menge','Preis','Steuersatz','Sachkonto');
- $width = array( '1%','1%', '1%' , '2%', '2%', '20%', '20%', '1%', '1%', '3%', '1%', '1%');
+ $width = array( '1%','1%', '1%' , '2%', '2%', '20%', '20%', '1%', '1%', '3%', '1%', '1%');
$findcols = array('vp.id','pd.paketannahme','pd.id','b.belegnr','art.nummer','art.name_de','pd.bemerkung','vp.menge','vp.preis','vp.steuersatz',"CONCAT(skv.sachkonto,' ',skv.beschriftung)",'vp.id');
$searchsql = array('p.nummer', 'p.name', 'p.bemerkung');
- $alignright = array(8,9,10);
+ $alignright = array(8,9,10);
$defaultorder = 1;
- $defaultorderdesc = 0;
+ $defaultorderdesc = 0;
- if (empty($freigabe)) {
+ if (empty($freigabe)) {
$menu="";
} else if (empty($rechnungsfreigabe)) {
$menu="";
@@ -390,20 +390,20 @@ class Verbindlichkeit {
else {
$deletepos = array('');
}
- $heading[] = '';
-
+ $heading[] = '';
+
$box = "CONCAT(' ') AS `auswahl`";
$paketlink = array (
'',
+ '">',
['sql' => 'pd.paketannahme'],
' '
);
$sql = "
- SELECT SQL_CALC_FOUND_ROWS
+ SELECT SQL_CALC_FOUND_ROWS
vp.id,
$box,
".$this->app->erp->ConcatSQL($paketlink)." pa,
@@ -429,7 +429,7 @@ class Verbindlichkeit {
adr.id = v.adresse
LEFT JOIN bestellung_position bp ON pd.bestellung_position = bp.id
LEFT JOIN bestellung b ON b.id = bp.bestellung
- LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen
+ LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen
";
$where = "vp.verbindlichkeit = ".$id;
@@ -448,26 +448,26 @@ class Verbindlichkeit {
}
return $erg;
}
-
+
function verbindlichkeit_list() {
// Process multi action
$submit = $this->app->Secure->GetPOST('submit');
switch($submit) {
case 'status_berechnen':
-
+
$sql = "SELECT id FROM verbindlichkeit WHERE status <> 'abgeschlossen' AND status <> 'storniert'";
$ids = $this->app->DB->SelectArr($sql);
-
+
foreach ($ids as $verbindlichkeit) {
$this->verbindlichkeit_abschliessen($verbindlichkeit['id']);
}
-
+
break;
case 'ausfuehren':
$auswahl = $this->app->Secure->GetPOST('auswahl');
$aktion = $this->app->Secure->GetPOST('sel_aktion');
-
+
$selectedIds = [];
if(!empty($auswahl)) {
foreach($auswahl as $selectedId) {
@@ -475,7 +475,7 @@ class Verbindlichkeit {
if($selectedId > 0) {
$selectedIds[] = $selectedId;
}
- }
+ }
switch ($aktion) {
case 'freigabeeinkauf':
@@ -487,7 +487,7 @@ class Verbindlichkeit {
}
break;
case 'freigabebuchhaltung':
- foreach ($selectedIds as $id) {
+ foreach ($selectedIds as $id) {
$result = $this->verbindlichkeit_freigabebuchhaltung($id);
if ($result !== true) {
$this->app->YUI->Message('warning',$result);
@@ -502,9 +502,9 @@ class Verbindlichkeit {
}
}
break;
- }
- }
- break;
+ }
+ }
+ break;
}
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht");
@@ -531,51 +531,51 @@ class Verbindlichkeit {
$this->app->User->SetParameter('table_verbindlichkeit_list_skontobis', '');
$this->app->Tpl->Parse('PAGE', "verbindlichkeit_list.tpl");
- }
+ }
public function verbindlichkeit_delete() {
$id = (int) $this->app->Secure->GetGET('id');
-
- $this->app->DB->Delete("UPDATE `verbindlichkeit` SET status='storniert' WHERE `id` = '{$id}'");
- $this->app->Tpl->Set('MESSAGE', "Der Eintrag wurde storniert.
");
+
+ $this->app->DB->Delete("UPDATE `verbindlichkeit` SET status='storniert' WHERE `id` = '{$id}'");
+ $this->app->Tpl->Set('MESSAGE', "Der Eintrag wurde storniert.
");
$this->verbindlichkeit_list();
- }
+ }
public function verbindlichkeit_deletepos() {
$posid = (int) $this->app->Secure->GetGET('posid');
- $id = (int) $this->app->Secure->GetGET('id');
+ $id = (int) $this->app->Secure->GetGET('id');
$verbindlichkeit = $this->app->DB->Select("SELECT verbindlichkeit FROM verbindlichkeit_position WHERE id ='{$posid}'");
- $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id = '{$posid}' AND v.freigabe <> 1");
+ $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id = '{$posid}' AND v.freigabe <> 1");
header("Location: index.php?module=verbindlichkeit&action=edit&id=$id#tabs-2");
- }
+ }
/*
* Edit verbindlichkeit item
* If id is empty, create a new one
*/
-
+
function verbindlichkeit_edit($einkauf_automatik_aus = false) {
$id = $this->app->Secure->GetGET('id');
-
+
// Check if other users are editing this id
if($this->app->erp->DisableModul('verbindlichkeit',$id))
{
return;
- }
-
+ }
+
$this->app->Tpl->Set('ID', $id);
$this->verbindlichkeit_menu($id);
$input = $this->GetInput();
$submit = $this->app->Secure->GetPOST('submit');
-
+
if (empty($id)) {
// New item
$id = 'NULL';
$input['status'] = 'angelegt';
- }
+ }
if (!empty($submit)) {
$einkauf_automatik_aus = false;
@@ -584,7 +584,7 @@ class Verbindlichkeit {
switch($submit)
{
case 'speichern':
- // Write to database
+ // Write to database
// Add checks here
$freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
@@ -597,21 +597,36 @@ class Verbindlichkeit {
$input['projekt'] = $this->app->erp->ReplaceProjekt(true,$projekt,true);
$input['kostenstelle'] = $this->app->DB->Select("SELECT id FROM kostenstellen WHERE nummer = '".$kostenstelle."'");
} else {
- $input['adresse'] = $this->app->erp->ReplaceLieferantennummer(true,$input['adresse'],true); // Parameters: Target db?, value, from form?
+
$input['rechnungsdatum'] = $this->app->erp->ReplaceDatum(true,$input['rechnungsdatum'],true); // Parameters: Target db?, value, from form?
$input['eingangsdatum'] = $this->app->erp->ReplaceDatum(true,$input['eingangsdatum'],true); // Parameters: Target db?, value, from form?
$input['skontobis'] = $this->app->erp->ReplaceDatum(true,$input['skontobis'],true); // Parameters: Target db?, value, from form?
$input['zahlbarbis'] = $this->app->erp->ReplaceDatum(true,$input['zahlbarbis'],true); // Parameters: Target db?, value, from form?
+
+ if(!empty($input['zahlbarbis_tage'])) {
+ $zahlbarbis = date_create_from_format('Y-m-d', $input['rechnungsdatum']);
+ date_add($zahlbarbis,date_interval_create_from_date_string($input['zahlbarbis_tage']." days"));
+ $input['zahlbarbis'] = date_format($zahlbarbis, 'Y-m-d');
+ }
+ unset($input['zahlbarbis_tage']);
+ if(!empty($input['skontobis_tage'])) {
+ $skontobis = date_create_from_format('Y-m-d', $input['rechnungsdatum']);
+ date_add($skontobis,date_interval_create_from_date_string($input['skontobis_tage']." days"));
+ $input['skontobis'] = date_format($skontobis, 'Y-m-d');
+ }
+ unset($input['skontobis_tage']);
+
+ $input['adresse'] = $this->app->erp->ReplaceLieferantennummer(true,$input['adresse'],true); // Parameters: Target db?, value, from form?
$input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],true);
$input['kostenstelle'] = $this->app->DB->Select("SELECT id FROM kostenstellen WHERE nummer = '".$input['kostenstelle']."'");
$input['bestellung'] = $this->app->erp->ReplaceBestellung(true,$input['bestellung'],true);
if(empty($input['projekt']) && !empty($input['adresse'])) {
- $input['projekt'] = $this->app->erp->GetCreateProjekt($input['adresse']);
+ $input['projekt'] = $this->app->erp->GetCreateProjekt($input['adresse']);
}
if (!empty($input['adresse'])) {
$adressdaten = $this->app->DB->SelectRow("
- SELECT
+ SELECT
zahlungszieltagelieferant,
zahlungszieltageskontolieferant,
zahlungszielskontolieferant,
@@ -619,7 +634,7 @@ class Verbindlichkeit {
FROM adresse WHERE id = ".$input['adresse']
);
-
+
if ($input['zahlbarbis'] == '0000-00-00' && $input['rechnungsdatum'] != '0000-00-00' && !empty($adressdaten['zahlungszieltagelieferant'])) {
$input['zahlbarbis'] = date('Y-m-d',strtotime($input['rechnungsdatum']." + ".$adressdaten['zahlungszieltagelieferant']." days"));
}
@@ -630,12 +645,12 @@ class Verbindlichkeit {
}
- }
+ }
$columns = "id, ";
$values = "$id, ";
$update = "";
-
+
$fix = "";
foreach ($input as $key => $value) {
@@ -662,7 +677,7 @@ class Verbindlichkeit {
header("Location: index.php?module=verbindlichkeit&action=edit&id=$id&msg=$msg");
} else {
$this->app->Tpl->Set('MESSAGE', "Die Einstellungen wurden erfolgreich übernommen.
");
- }
+ }
break;
case 'positionen_hinzufuegen':
@@ -676,7 +691,7 @@ class Verbindlichkeit {
$werte = $this->app->Secure->GetPOST('werte');
$preise = $this->app->Secure->GetPOST('preise');
- $bruttoeingabe = $this->app->Secure->GetPOST('bruttoeingabe');
+ $bruttoeingabe = $this->app->Secure->GetPOST('bruttoeingabe');
foreach ($ids as $key => $paketdistribution) {
$menge = $werte[$key];
@@ -687,13 +702,13 @@ class Verbindlichkeit {
// Check available number
$sql = "
- SELECT
+ SELECT
IF(
pd.menge > COALESCE(vp.menge,0),
pd.menge - COALESCE(vp.menge,0),
0
) offen_menge
- FROM
+ FROM
paketdistribution pd
LEFT JOIN(
SELECT
@@ -705,7 +720,7 @@ class Verbindlichkeit {
paketdistribution
) vp
ON
- vp.paketdistribution = pd.id
+ vp.paketdistribution = pd.id
WHERE pd.id = ".$paketdistribution."
";
$offen_menge = $this->app->DB->Select($sql);
@@ -719,27 +734,27 @@ class Verbindlichkeit {
}
$preis = $preise[$key];
- $sql = "SELECT
+ $sql = "SELECT
a.id,
a.umsatzsteuer,
a.steuersatz,
COALESCE(if (skart.id <> 0,skart.id,skadr.id),0) AS kontorahmen
- FROM
- paketdistribution pd
+ FROM
+ paketdistribution pd
INNER JOIN
paketannahme pa ON pa.id = pd.paketannahme
- INNER JOIN
+ INNER JOIN
artikel a ON a.id = pd.artikel
- INNER JOIN
+ INNER JOIN
adresse adr ON pa.adresse = adr.id
- LEFT JOIN
+ LEFT JOIN
kontorahmen skart ON skart.id = a.kontorahmen
- LEFT JOIN
- kontorahmen skadr ON skadr.id = adr.kontorahmen
+ LEFT JOIN
+ kontorahmen skadr ON skadr.id = adr.kontorahmen
WHERE pd.id =".$paketdistribution;
$artikel = $this->app->DB->SelectRow($sql);
-
+
$einartikel = $artikel['id'];
$umsatzsteuer = $artikel['umsatzsteuer'];
$kontorahmen = $artikel['kontorahmen'];
@@ -752,13 +767,13 @@ class Verbindlichkeit {
if ($bruttoeingabe) {
$preis = $preis / (1+($steuersatz/100));
- }
+ }
$sql = "INSERT INTO verbindlichkeit_position (verbindlichkeit,paketdistribution, menge, preis, steuersatz, artikel, kontorahmen) VALUES ($id, $paketdistribution, $menge, $preis, $steuersatz, $einartikel, $kontorahmen)";
$this->app->DB->Insert($sql);
}
- break;
- case 'positionen_entfernen':
+ break;
+ case 'positionen_entfernen':
$freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
if ($freigabe['rechnungsfreigabe'] || $freigabe['freigabe']) {
@@ -769,10 +784,10 @@ class Verbindlichkeit {
if (!is_array($ids)) {
break;
}
- $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id IN (".implode(',',$ids).") AND v.freigabe <> 1");
+ $this->app->DB->Delete("DELETE vp FROM verbindlichkeit_position vp INNER JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit WHERE vp.id IN (".implode(',',$ids).") AND v.freigabe <> 1");
- break;
- case 'positionen_steuersatz_zu_netto':
+ break;
+ case 'positionen_steuersatz_zu_netto':
$freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
if ($freigabe['rechnungsfreigabe'] || $freigabe['freigabe']) {
@@ -792,12 +807,12 @@ class Verbindlichkeit {
$faktor = 1+($tmpsteuersatz/100);
- $sql = "UPDATE verbindlichkeit_position SET preis = preis / ".$faktor." WHERE id = $posid";
+ $sql = "UPDATE verbindlichkeit_position SET preis = preis / ".$faktor." WHERE id = $posid";
$this->app->DB->Update($sql);
- }
+ }
break;
- case 'positionen_kontorahmen_setzen':
+ case 'positionen_kontorahmen_setzen':
$freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
if ($freigabe['rechnungsfreigabe']) {
break;
@@ -811,14 +826,14 @@ class Verbindlichkeit {
$positionen_sachkonto = $this->app->Secure->GetPOST('positionen_sachkonto');
$positionen_kontorahmen = $this->app->erp->ReplaceKontorahmen(true,$positionen_sachkonto,false);
- foreach ($ids as $posid) {
- $sql = "UPDATE verbindlichkeit_position SET kontorahmen = '".$positionen_kontorahmen."' WHERE id =".$posid;
+ foreach ($ids as $posid) {
+ $sql = "UPDATE verbindlichkeit_position SET kontorahmen = '".$positionen_kontorahmen."' WHERE id =".$posid;
$this->app->DB->Update($sql);
- }
+ }
break;
}
-
+
// Load values again from database
$dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
$result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id,
@@ -851,7 +866,7 @@ class Verbindlichkeit {
v.bezahlt,
v.kontoauszuege,
v.firma,
- v.logdatei,
+ v.logdatei,
v.waehrung,
v.zahlungsweise,
v.eingangsdatum,
@@ -896,40 +911,40 @@ class Verbindlichkeit {
a.name AS adresse_name FROM verbindlichkeit v LEFT JOIN adresse a ON a.id = v.adresse"." WHERE v.id=$id");
foreach ($result[0] as $key => $value) {
- $this->app->Tpl->Set(strtoupper($key), $value);
+ $this->app->Tpl->Set(strtoupper($key), $value);
}
if (!empty($result[0])) {
$verbindlichkeit_from_db = $result[0];
}
- // Check positions
- $pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']);
-
+ // Check positions
+ $pos_check = $this->check_positions($verbindlichkeit_from_db['id'],$verbindlichkeit_from_db['betrag']);
+
$this->app->Tpl->Set('BETRAGNETTO', $pos_check['betrag_netto']);
$this->app->Tpl->Set('BETRAGBRUTTOPOS', $pos_check['betrag_brutto']);
-
+
if (empty($pos_check['rundungsdifferenz'])) {
- $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
+ $this->app->Tpl->Set('RUNDUNGSDIFFERENZICONHIDDEN', 'hidden');
} else {
- $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']);
+ $this->app->Tpl->Set('RUNDUNGSDIFFERENZ', $pos_check['rundungsdifferenz']);
}
- if ($pos_check['pos_ok']) {
+ if ($pos_check['pos_ok']) {
if (!$verbindlichkeit_from_db['freigabe'] && !$einkauf_automatik_aus) {
if ($this->verbindlichkeit_freigabeeinkauf($id,"Verbindlichkeit automatisch freigegeben (Einkauf)") === true) {
$this->app->YUI->Message('success',"Verbindlichkeit automatisch freigegeben (Einkauf)");
$verbindlichkeit_from_db['freigabe'] = 1;
} else {
- $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
+ $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
}
- }
- $this->app->Tpl->Set('POSITIONENMESSAGE', 'Positionen vollständig
');
-
+ }
+ $this->app->Tpl->Set('POSITIONENMESSAGE', 'Positionen vollständig
');
+
if ($verbindlichkeit_from_db['status'] != 'abgeschlossen' && $verbindlichkeit_from_db['status'] != 'storniert') {
- $this->verbindlichkeit_abschliessen($id);
- }
-
+ $this->verbindlichkeit_abschliessen($id);
+ }
+
} else {
$this->app->Tpl->Set('
POSITIONENMESSAGE', 'Positionen nicht vollständig. Bruttobetrag '.
@@ -939,30 +954,30 @@ class Verbindlichkeit {
', Differenz '.
round($pos_check['betrag_brutto']-$verbindlichkeit_from_db['betrag'],2).
'
'
- );
+ );
if ($verbindlichkeit_from_db['freigabe']) {
$this->app->DB->Update("UPDATE verbindlichkeit SET freigabe = 0 WHERE id = ".$id);
$verbindlichkeit_from_db['freigabe'] = 0;
- $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
+ $this->app->YUI->Message('warning',"Verbindlichkeit rückgesetzt (Einkauf)");
}
- }
-
+ }
+
/*
* Add displayed items later
- *
+ *
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
- $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
+ $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
$this->app->YUI->AutoComplete("artikel", "artikelnummer");
*/
- $this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); // prevent manual setting
+ $this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); // prevent manual setting
if (empty($verbindlichkeit_from_db['adresse']) || $verbindlichkeit_from_db['status'] == 'angelegt') {
- $this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden');
- $this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden');
+ $this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden');
+ $this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden');
$this->app->Tpl->Set('POSITIONHINZUFUEGENHIDDEN','hidden');
$this->app->Tpl->Set('POSITIONENHIDDEN','hidden');
}
@@ -980,19 +995,19 @@ class Verbindlichkeit {
if (!empty($positionen)) {
$this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden');
}
-
+
if ($verbindlichkeit_from_db['rechnungsfreigabe']) {
$this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden');
$this->app->Tpl->Set('RUECKSETZENEINKAUFHIDDEN','hidden');
- $this->app->Tpl->Set('SACHKONTOCHANGEHIDDEN','hidden');
+ $this->app->Tpl->Set('SACHKONTOCHANGEHIDDEN','hidden');
} else {
$this->app->Tpl->Set('RUECKSETZENBUCHHALTUNGHIDDEN','hidden');
- }
+ }
if ($verbindlichkeit_from_db['bezahlt'] == '1') {
$this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden');
} else {
$this->app->Tpl->Set('RUECKSETZENBEZAHLTHIDDEN','hidden');
- }
+ }
$this->app->Tpl->Set('WARENEINGANGCHECKED', $verbindlichkeit_from_db['freigabe']==1?"checked":"");
$this->app->Tpl->Set('RECHNUNGSFREIGABECHECKED', $verbindlichkeit_from_db['rechnungsfreigabe']==1?"checked":"");
@@ -1007,9 +1022,9 @@ class Verbindlichkeit {
$this->app->Tpl->Set('ZAHLBARBIS',$this->app->erp->ReplaceDatum(false,$verbindlichkeit_from_db['zahlbarbis'],false));
$this->app->YUI->DatePicker("zahlbarbis");
- $sql = "SELECT
- ".$this->app->YUI->IconsSQLVerbindlichkeit() . " AS `icons`
- FROM verbindlichkeit v
+ $sql = "SELECT
+ ".$this->app->YUI->IconsSQLVerbindlichkeit() . " AS `icons`
+ FROM verbindlichkeit v
LEFT JOIN (
SELECT ds.parameter, COUNT(ds.objekt) datei_anzahl FROM datei_stichwoerter ds INNER JOIN datei d ON d.id = ds.datei WHERE ds.objekt='verbindlichkeit' AND d.geloescht <> 1 GROUP BY ds.parameter
) d ON d.parameter = v.id
@@ -1017,7 +1032,7 @@ class Verbindlichkeit {
$icons = $this->app->DB->SelectArr($sql);
$this->app->Tpl->Add('STATUSICONS', $icons[0]['icons']);
- $this->app->YUI->AutoComplete("adresse", "lieferant");
+ $this->app->YUI->AutoComplete("adresse", "lieferant");
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
$this->app->Tpl->Set('PROJEKT',$this->app->erp->ReplaceProjekt(false,$verbindlichkeit_from_db['projekt'],false));
$this->app->YUI->AutoComplete("kostenstelle", "kostenstelle", 1);
@@ -1028,16 +1043,16 @@ class Verbindlichkeit {
$this->app->Tpl->Set('ADRESSE_ID', $verbindlichkeit_from_db['adresse']);
- $this->app->Tpl->Set('ADRESSE', $this->app->erp->ReplaceLieferantennummer(false,$verbindlichkeit_from_db['adresse'],false)); // Convert ID to form display
+ $this->app->Tpl->Set('ADRESSE', $this->app->erp->ReplaceLieferantennummer(false,$verbindlichkeit_from_db['adresse'],false)); // Convert ID to form display
$this->app->Tpl->Set('BESTELLUNG',$this->app->erp->ReplaceBestellung(false,$verbindlichkeit_from_db['bestellung'],false));
- $this->app->YUI->AutoComplete("bestellung", "lieferantenbestellung",0,"&adresse=".$verbindlichkeit_from_db['adresse']);
+ $this->app->YUI->AutoComplete("bestellung", "lieferantenbestellung",0,"&adresse=".$verbindlichkeit_from_db['adresse']);
$this->app->YUI->CkEditor("internebemerkung");
$anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id);
if ($anzahldateien > 0) {
- $file = urlencode("../../../../index.php?module=verbindlichkeit&action=inlinepdf&id=$id");
+ $file = urlencode("../../../../index.php?module=verbindlichkeit&action=inlinepdf&id=$id");
$iframe = "";
$this->app->Tpl->Set('INLINEPDF', $iframe);
} else {
@@ -1047,7 +1062,7 @@ class Verbindlichkeit {
if (empty($verbindlichkeit_from_db['freigabe'])) {
$this->app->YUI->TableSearch('PAKETDISTRIBUTION', 'verbindlichkeit_paketdistribution_list', "show", "", "", basename(__FILE__), __CLASS__);
}
-
+
// -- POSITIONEN
$this->app->YUI->AutoComplete("positionen_sachkonto", "sachkonto", 1);
$this->app->YUI->TableSearch('POSITIONEN', 'verbindlichkeit_positionen', "show", "", "", basename(__FILE__), __CLASS__);
@@ -1061,15 +1076,15 @@ class Verbindlichkeit {
function verbindlichkeit_editpos() {
$id = $this->app->Secure->GetGET('id');
- $posid = $this->app->Secure->GetGET('posid');
-
+ $posid = $this->app->Secure->GetGET('posid');
+
$this->app->Tpl->Set('ID', $id);
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=edit&id=$id#tabs-2", "Zurück");
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
- $menge = $this->app->Secure->GetPOST('menge');
- $preis = $this->app->Secure->GetPOST('preis');
- $steuersatz = $this->app->Secure->GetPOST('steuersatz');
+ $menge = $this->app->Secure->GetPOST('menge');
+ $preis = $this->app->Secure->GetPOST('preis');
+ $steuersatz = $this->app->Secure->GetPOST('steuersatz');
$kontorahmen = $this->app->erp->ReplaceKontorahmen(true,$sachkonto,false);
if ($menge < 0) {
@@ -1081,20 +1096,20 @@ class Verbindlichkeit {
if ($steuersatz < 0) {
$steuersatz = 0;
}
- $submit = $this->app->Secure->GetPOST('submit');
+ $submit = $this->app->Secure->GetPOST('submit');
- $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
+ $freigabe = $this->app->DB->SelectArr("SELECT rechnungsfreigabe, freigabe FROM verbindlichkeit WHERE id =".$id)[0];
if ($freigabe['rechnungsfreigabe'] && $freigabe['freigabe']) {
$this->app->Tpl->Set('SAVEDISABLED','disabled');
$this->app->Tpl->Set('SACHKONTOSAVEDISABLED','disabled');
} else if ($freigabe['freigabe']) {
- $this->app->Tpl->Set('SAVEDISABLED','disabled');
+ $this->app->Tpl->Set('SAVEDISABLED','disabled');
if ($submit != '')
- {
+ {
$sql = "
- UPDATE verbindlichkeit_position SET
+ UPDATE verbindlichkeit_position SET
kontorahmen = '$kontorahmen'
- WHERE id = ".$posid."
+ WHERE id = ".$posid."
";
$this->app->DB->Update($sql);
$this->app->Tpl->Set('MESSAGE', "Die Einstellungen wurden erfolgreich übernommen.
");
@@ -1102,14 +1117,14 @@ class Verbindlichkeit {
}
} else {
if ($submit != '')
- {
+ {
$sql = "
- UPDATE verbindlichkeit_position SET
+ UPDATE verbindlichkeit_position SET
menge = '$menge',
preis = '$preis',
steuersatz = '$steuersatz',
kontorahmen = '$kontorahmen'
- WHERE id = ".$posid."
+ WHERE id = ".$posid."
";
$this->app->DB->Update($sql);
@@ -1117,13 +1132,13 @@ class Verbindlichkeit {
header("Location: index.php?module=verbindlichkeit&action=edit&id=$id&msg=$msg#tabs-2");
}
}
-
+
// Load values again from database
$dropnbox = "' ' AS `open`, CONCAT(' ') AS `auswahl`";
- $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, v.steuersatz, v.preis, v.menge, v.kontorahmen, v.id FROM verbindlichkeit_position v"." WHERE id=$posid");
+ $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS v.id, $dropnbox, v.steuersatz, v.preis, v.menge, v.kontorahmen, v.id FROM verbindlichkeit_position v"." WHERE id=$posid");
foreach ($result[0] as $key => $value) {
- $this->app->Tpl->Set(strtoupper($key), $value);
+ $this->app->Tpl->Set(strtoupper($key), $value);
}
if (!empty($result)) {
@@ -1131,14 +1146,14 @@ class Verbindlichkeit {
} else {
return;
}
-
+
/*
* Add displayed items later
- *
+ *
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
- $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
+ $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
$this->app->YUI->AutoComplete("artikel", "artikelnummer");
@@ -1159,10 +1174,12 @@ class Verbindlichkeit {
$input['adresse'] = $this->app->Secure->GetPOST('adresse');
$input['rechnung'] = $this->app->Secure->GetPOST('rechnung');
$input['zahlbarbis'] = $this->app->Secure->GetPOST('zahlbarbis');
+ $input['zahlbarbis_tage'] = $this->app->Secure->GetPOST('zahlbarbis_tage');
$input['betrag'] = $this->app->Secure->GetPOST('betrag');
$input['waehrung'] = $this->app->Secure->GetPOST('waehrung');
$input['skonto'] = $this->app->Secure->GetPOST('skonto');
$input['skontobis'] = $this->app->Secure->GetPOST('skontobis');
+ $input['skontobis_tage'] = $this->app->Secure->GetPOST('skontobis_tage');
$input['projekt'] = $this->app->Secure->GetPOST('projekt');
$input['zahlungsweise'] = $this->app->Secure->GetPOST('zahlungsweise');
$input['eingangsdatum'] = $this->app->Secure->GetPOST('eingangsdatum');
@@ -1173,14 +1190,14 @@ class Verbindlichkeit {
return $input;
}
- function verbindlichkeit_menu($id) {
+ function verbindlichkeit_menu($id) {
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=edit&id=$id", "Details");
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Zurück zur Übersicht");
$anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id);
if ($anzahldateien > 0) {
- $anzahldateien = " (".$anzahldateien.")";
+ $anzahldateien = " (".$anzahldateien.")";
} else {
$anzahldateien="";
}
@@ -1199,7 +1216,7 @@ class Verbindlichkeit {
if ($invoiceArr['status'] === 'angelegt' || empty($invoiceArr['status'])) {
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=freigabe&id=$id",'Freigabe');
- }
+ }
}
function verbindlichkeit_dateien()
@@ -1211,9 +1228,9 @@ class Verbindlichkeit {
}
function verbindlichkeit_inlinepdf() {
- $id = $this->app->Secure->GetGET('id');
+ $id = $this->app->Secure->GetGET('id');
- $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','verbindlichkeit',$id);
+ $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','verbindlichkeit',$id);
if (!empty($file_attachments)) {
@@ -1242,14 +1259,14 @@ class Verbindlichkeit {
echo($file_contents);
$this->app->ExitXentral();
}
- }
- }
- }
+ }
+ }
+ }
$this->app->ExitXentral();
}
-
+
function verbindlichkeit_freigabe()
- {
+ {
$id = $this->app->Secure->GetGET('id');
$this->app->erp->BelegFreigabe('verbindlichkeit',$id);
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben");
@@ -1258,7 +1275,7 @@ class Verbindlichkeit {
// Returns true or error message
function verbindlichkeit_freigabeeinkauf($id = null, $text = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
@@ -1266,35 +1283,35 @@ class Verbindlichkeit {
$error = false;
- if (!$this->verbindlichkeit_is_freigegeben($id)) {
+ if (!$this->verbindlichkeit_is_freigegeben($id)) {
if ($gotoedit) {
- $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
+ $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
$error = true;
} else {
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
- }
- }
+ }
+ }
- // Check wareneingang status
- $sql = "SELECT
- pa.id
- FROM verbindlichkeit_position vp
+ // Check wareneingang status
+ $sql = "SELECT
+ pa.id
+ FROM verbindlichkeit_position vp
INNER JOIN paketdistribution pd ON pd.id = vp.paketdistribution
- INNER JOIN paketannahme pa ON pa.id = pd.paketannahme
+ INNER JOIN paketannahme pa ON pa.id = pd.paketannahme
WHERE
- verbindlichkeit='$id'
+ verbindlichkeit='$id'
AND
- pa.status = 'abgeschlossen'
+ pa.status = 'abgeschlossen'
";
- $check = $this->app->DB->SelectArr($sql);
+ $check = $this->app->DB->SelectArr($sql);
if (empty($check)) {
if ($gotoedit) {
- $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
+ $this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
} else {
return('Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen '.$this->verbindlichkeit_get_belegnr($id));
- }
+ }
} else {
$sql = "UPDATE verbindlichkeit SET freigabe = 1 WHERE id=".$id;
$this->app->DB->Update($sql);
@@ -1309,57 +1326,57 @@ class Verbindlichkeit {
}
else {
return(true);
- }
+ }
}
// Returns true or error message
function verbindlichkeit_freigabebuchhaltung($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
- }
+ }
$error = false;
- if (!$this->verbindlichkeit_is_freigegeben($id)) {
+ if (!$this->verbindlichkeit_is_freigegeben($id)) {
if ($gotoedit) {
$this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
$error = true;
} else {
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
- }
+ }
}
if (!$error) {
// Check accounting
$sql = "
- SELECT
+ SELECT
vp.id,
- v.belegnr
- FROM verbindlichkeit_position vp
+ v.belegnr
+ FROM verbindlichkeit_position vp
LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit
- WHERE
+ WHERE
verbindlichkeit='$id'
AND vp.kontorahmen = 0
";
- $check = $this->app->DB->SelectArr($sql);
+ $check = $this->app->DB->SelectArr($sql);
- if (!empty($check)) {
+ if (!empty($check)) {
if ($gotoedit) {
- $this->app->YUI->Message('warning','Kontierung unvollständig');
+ $this->app->YUI->Message('warning','Kontierung unvollständig');
$error = true;
} else {
return('Kontierung unvollständig '.$this->verbindlichkeit_get_belegnr($id));
}
}
}
-
- if (!$error) {
+
+ if (!$error) {
$sql = "UPDATE verbindlichkeit SET rechnungsfreigabe = 1 WHERE freigabe = 1 AND id=".$id;
$this->app->DB->Update($sql);
- $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)");
+ $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)");
}
if ($gotoedit) {
@@ -1371,21 +1388,21 @@ class Verbindlichkeit {
// Returns true or error message
function verbindlichkeit_freigabebezahlt($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
}
- if (!$this->verbindlichkeit_is_freigegeben($id)) {
+ if (!$this->verbindlichkeit_is_freigegeben($id)) {
if ($gotoedit) {
- $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
+ $this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
$error = true;
} else {
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
- }
+ }
}
-
+
if (!$error) {
$sql = "UPDATE verbindlichkeit SET bezahlt = 1 WHERE id=".$id;
$this->app->DB->Update($sql);
@@ -1394,20 +1411,20 @@ class Verbindlichkeit {
$this->verbindlichkeit_edit();
} else {
return(true);
- }
+ }
}
- }
-
+ }
+
function verbindlichkeit_abschliessen($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
}
-
- $sql = "SELECT freigabe, rechnungsfreigabe, bezahlt, betrag FROM verbindlichkeit WHERE id =".$id;
+
+ $sql = "SELECT freigabe, rechnungsfreigabe, bezahlt, betrag FROM verbindlichkeit WHERE id =".$id;
$verbindlichkeit = $this->app->DB->SelectRow($sql);
-
+
if ($verbindlichkeit['freigabe'] != 1) {
$einkauf_check = $this->check_positions($id,$verbindlichkeit['betrag']);
if ($einkauf_check['pos_ok']) {
@@ -1415,20 +1432,20 @@ class Verbindlichkeit {
$verbindlichkeit['freigabe'] = 1;
}
}
-
- $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id);
+
+ $anzahldateien = $this->app->erp->AnzahlDateien("verbindlichkeit",$id);
if (!empty($anzahldateien) && $verbindlichkeit['freigabe'] && $verbindlichkeit['rechnungsfreigabe'] && $verbindlichkeit['bezahlt']) {
$sql = "UPDATE verbindlichkeit SET status = 'abgeschlossen' WHERE id=".$id;
$this->app->DB->Update($sql);
- $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit abgeschlossen");
+ $this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit abgeschlossen");
if ($gotoedit) {
$this->verbindlichkeit_edit();
- }
- }
- }
+ }
+ }
+ }
function verbindlichkeit_ruecksetzeneinkauf($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
@@ -1442,7 +1459,7 @@ class Verbindlichkeit {
}
function verbindlichkeit_ruecksetzenbuchhaltung($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
@@ -1456,7 +1473,7 @@ class Verbindlichkeit {
}
function verbindlichkeit_ruecksetzenbezahlt($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
@@ -1466,11 +1483,11 @@ class Verbindlichkeit {
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit bezahlt rückgesetzt");
if ($gotoedit) {
$this->verbindlichkeit_edit();
- }
- }
-
+ }
+ }
+
/* function verbindlichkeit_schreibschutz($id = null)
- {
+ {
if (empty($id)) {
$id = $this->app->Secure->GetGET('id');
$gotoedit = true;
@@ -1480,14 +1497,14 @@ class Verbindlichkeit {
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit Schreibschutz entfernt");
if ($gotoedit) {
$this->verbindlichkeit_edit();
- }
+ }
} */
public function verbindlichkeit_minidetail($parsetarget='',$menu=true) {
- $id = $this->app->Secure->GetGET('id');
+ $id = $this->app->Secure->GetGET('id');
- $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS
+ $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS
v.id,
v.belegnr,
v.status_beleg,
@@ -1542,14 +1559,14 @@ class Verbindlichkeit {
v.sprache,
v.id,
CONCAT(a.lieferantennummer,' ',a.name) AS adresse
- FROM verbindlichkeit v
+ FROM verbindlichkeit v
LEFT JOIN adresse a ON a.id = v.adresse
LEFT JOIN projekt p ON a.projekt = p.id
LEFT JOIN kostenstellen k ON v.kostenstelle = k.id
- WHERE v.id='$id'");
+ WHERE v.id='$id'");
foreach ($result[0] as $key => $value) {
- $this->app->Tpl->Set(strtoupper($key), $value);
+ $this->app->Tpl->Set(strtoupper($key), $value);
}
if (!empty($result[0])) {
@@ -1564,11 +1581,11 @@ class Verbindlichkeit {
vp.preis,
vp.steuersatz,
CONCAT(skv.sachkonto,' ',skv.beschriftung) AS sachkonto,
- ''
- FROM verbindlichkeit_position vp
- INNER JOIN artikel art ON art.id = vp.artikel
+ ''
+ FROM verbindlichkeit_position vp
+ INNER JOIN artikel art ON art.id = vp.artikel
LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit
- LEFT JOIN adresse adr ON adr.id = v.adresse
+ LEFT JOIN adresse adr ON adr.id = v.adresse
LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen
WHERE verbindlichkeit='$id'
ORDER by vp.sort ASC");
@@ -1612,7 +1629,7 @@ class Verbindlichkeit {
'',
'',
'Betrag Positionen netto ',
- 'Betrag Positionen brutto '
+ 'Betrag Positionen brutto '
);
$tmp->AddRow($row);
$row = array(
@@ -1639,20 +1656,20 @@ class Verbindlichkeit {
}
function verbindlichkeit_is_freigegeben($id) {
- $sql = "SELECT
- belegnr
- FROM
+ $sql = "SELECT
+ belegnr
+ FROM
verbindlichkeit
WHERE
- id='$id'
+ id='$id'
AND
- status IN ('freigegeben')
+ status IN ('freigegeben')
";
- $check = $this->app->DB->SelectArr($sql);
+ $check = $this->app->DB->SelectArr($sql);
if (empty($check)) {
return(false);
- } else
+ } else
{
return(true);
}
@@ -1663,7 +1680,7 @@ class Verbindlichkeit {
}
/* Calculate steuersatz
- Get from
+ Get from
Check address first, if foreign, then steuersatz = 0
if not foreign there are three cases: befreit = 0, ermaessigt, normal
if not befreit, get from projekt or firmendaten
@@ -1676,19 +1693,19 @@ class Verbindlichkeit {
if ($umsatzsteuer == 'befreit') {
return(0);
}
-
+
$adresse = $this->app->DB->Select("SELECT adresse FROM verbindlichkeit WHERE id=".$verbindlichkeit);
$umsatzsteuer_lieferant = $this->app->DB->Select("SELECT umsatzsteuer_lieferant FROM adresse WHERE id=".$adresse); /* inland, eu-lieferung, import*/
if (in_array($umsatzsteuer_lieferant,array('import','eulieferung'))) {
return(0);
}
-
+
$projekt = $this->app->DB->Select("SELECT projekt FROM verbindlichkeit WHERE id=".$verbindlichkeit);
$steuersatz_projekt = $this->app->DB->SelectRow("SELECT steuersatz_normal, steuersatz_ermaessigt FROM projekt WHERE id ='".$projekt."'");
$steuersatz_normal_projekt = $steuersatz_projekt['steuer_normal'];
$steuersatz_ermaessigt_projekt = $steuersatz_projekt['steuer_ermaessigt'];
-
+
$steuersatz_normal = $this->app->erp->Firmendaten('steuersatz_normal');
$steuersatz_ermaessigt = $this->app->erp->Firmendaten('steuersatz_ermaessigt');
@@ -1698,22 +1715,22 @@ class Verbindlichkeit {
return($steuersatz_normal_projekt);
} else {
return($steuersatz_normal);
- }
+ }
break;
case 'ermaessigt':
if (!empty($steuersatz_ermaessigt_projekt)) {
return($steuersatz_ermaessigt_projekt);
} else {
return($steuersatz_ermaessigt);
- }
+ }
break;
- default:
+ default:
return(0);
break;
}
}
-
+
// Check positions and return status and values
function check_positions($id, $bruttobetrag_verbindlichkeit) : array {
@@ -1723,7 +1740,7 @@ class Verbindlichkeit {
"betrag_brutto" => 0,
"rundungsdifferenz" => 0,
"bruttobetrag_verbindlichkeit" => $bruttobetrag_verbindlichkeit
- );
+ );
if (empty($id)) {
return($result);
@@ -1731,7 +1748,7 @@ class Verbindlichkeit {
// Summarize positions
$sql = "SELECT * FROM verbindlichkeit_position WHERE verbindlichkeit = ".$id;
- $positionen = $this->app->DB->SelectArr($sql);
+ $positionen = $this->app->DB->SelectArr($sql);
if (!empty($positionen)) {
$betrag_netto = 0;
@@ -1740,7 +1757,7 @@ class Verbindlichkeit {
$steuer_normal = 0;
$steuer_ermaessigt = 0;
- /*
+ /*
Normal: umsatzsteuer leer, steuersatz = leer
Ermäßigt: umsatzsteuer ermaessigt, steuersatz = -1
Befreit: umsatzsteuer befreit, steursatz = -1
@@ -1757,27 +1774,27 @@ class Verbindlichkeit {
$position['steuersatz_berechnet'] = $tmpsteuersatz;
$position['steuertext_berechnet'] = $tmpsteuertext;
$position['steuererloes_berechnet'] = $erloes;
-
+
$betrag_netto += ($position['menge']*$position['preis']);
$betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100));
$betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2);
}
-
+
$result['betrag_netto'] = round($betrag_netto,2);
$result['betrag_brutto'] = round($betrag_brutto,2);
-
+
if ($bruttobetrag_verbindlichkeit == round($betrag_brutto,2)) {
- $result['pos_ok'] = true;
+ $result['pos_ok'] = true;
}
else if (round($bruttobetrag_verbindlichkeit,2) == round($betrag_brutto_pos_summe,2)) {
- $result['pos_ok'] = true;
+ $result['pos_ok'] = true;
if (round($bruttobetrag_verbindlichkeit,2) != round($betrag_brutto_pos_summe,2)) {
$result['rundungsdifferenz'] = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2);
- }
- }
- }
-
+ }
+ }
+ }
+
return($result);
}
}
From 19ac3415e36527d743662457dcada45ce1cce830 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sun, 25 Aug 2024 20:15:43 +0200
Subject: [PATCH 64/87] verbindlichkeit bugfix netto positions rounded
---
www/pages/verbindlichkeit.php | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 3eda30d8..110b3462 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -1756,6 +1756,7 @@ class Verbindlichkeit {
$betrag_brutto_pos_summe = 0;
$steuer_normal = 0;
$steuer_ermaessigt = 0;
+ $betrag_brutto_alternativ = 0;
/*
Normal: umsatzsteuer leer, steuersatz = leer
@@ -1763,6 +1764,9 @@ class Verbindlichkeit {
Befreit: umsatzsteuer befreit, steursatz = -1
Individuell: umsatzsteuer leer, steuersatz = wert
*/
+
+ $betrag_brutto_pro_steuersatz = array();
+
foreach ($positionen as $position) {
$tmpsteuersatz = null;
@@ -1775,23 +1779,31 @@ class Verbindlichkeit {
$position['steuertext_berechnet'] = $tmpsteuertext;
$position['steuererloes_berechnet'] = $erloes;
- $betrag_netto += ($position['menge']*$position['preis']);
- $betrag_brutto += ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100));
- $betrag_brutto_pos_summe += round(($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100)),2);
+ $betrag_netto_pos = ($position['menge']*$position['preis']);
+ $betrag_netto += $betrag_netto_pos;
+ $betrag_brutto_pos = ($position['menge']*$position['preis'])*(1+($tmpsteuersatz/100));
+ $betrag_brutto += $betrag_brutto_pos;
+ $betrag_brutto_pos_summe += round($betrag_brutto_pos,2);
+ $betrag_netto_pro_steuersatz[$tmpsteuersatz] += round($betrag_netto_pos,2);
}
$result['betrag_netto'] = round($betrag_netto,2);
$result['betrag_brutto'] = round($betrag_brutto,2);
+ foreach ($betrag_netto_pro_steuersatz as $steuersatz => $betrag_netto) {
+ $betrag_brutto_alternativ += round($betrag_netto*(1+($steuersatz/100)),2);
+ }
+
if ($bruttobetrag_verbindlichkeit == round($betrag_brutto,2)) {
$result['pos_ok'] = true;
}
else if (round($bruttobetrag_verbindlichkeit,2) == round($betrag_brutto_pos_summe,2)) {
$result['pos_ok'] = true;
- if (round($bruttobetrag_verbindlichkeit,2) != round($betrag_brutto_pos_summe,2)) {
- $result['rundungsdifferenz'] = round(round($betrag_brutto,2) - $betrag_brutto_pos_summe,2);
- }
+ $result['rundungsdifferenz'] = round($bruttobetrag_verbindlichkeit-$result['betrag_brutto'],2);
+ } else if (round($bruttobetrag_verbindlichkeit,2) == $betrag_brutto_alternativ) {
+ $result['pos_ok'] = true;
+ $result['rundungsdifferenz'] = round($bruttobetrag_verbindlichkeit-$result['betrag_brutto'],2);
}
}
From 7675f93034b6f0fd95bce910143a87edcf66421d Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Sun, 25 Aug 2024 21:50:50 +0200
Subject: [PATCH 65/87] FIX Shopimport: Update shop orders without shipments
---
classes/Modules/Onlineshop/Data/Shipment.php | 12 ++++++------
www/lib/class.remote.php | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/classes/Modules/Onlineshop/Data/Shipment.php b/classes/Modules/Onlineshop/Data/Shipment.php
index 87daeed5..c85959db 100644
--- a/classes/Modules/Onlineshop/Data/Shipment.php
+++ b/classes/Modules/Onlineshop/Data/Shipment.php
@@ -14,17 +14,17 @@ class Shipment
public int $id;
/**
- * @var string plain tracking number
+ * @var ?string plain tracking number
*/
- public string $trackingNumber;
+ public ?string $trackingNumber;
/**
- * @var string URL to view tracking details
+ * @var ?string URL to view tracking details
*/
- public string $trackingUrl;
+ public ?string $trackingUrl;
/**
- * @var string shipping method (after mapping to Shop domain)
+ * @var ?string shipping method (after mapping to Shop domain)
*/
- public string $shippingMethod;
+ public ?string $shippingMethod;
}
\ No newline at end of file
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 091a7db2..6401a427 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2342,7 +2342,7 @@ class Remote
vlp.versandpaket = v.id OR v.lieferschein_ohne_pos = l.id
LEFT JOIN shopexport_versandarten sv ON
sv.versandart_wawision = v.versandart AND sv.shop = $shopId
- WHERE a.id = $orderId OR a.teillieferungvon = $orderId
+ WHERE (a.id = $orderId OR a.teillieferungvon = $orderId) AND v.id IS NOT NULL
ORDER BY v.id";
$shipments = $this->app->DB->SelectArr($sql);
From 26e6d773a9d047e24351ee3e424e1c76b4278ee1 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 26 Aug 2024 11:03:59 +0200
Subject: [PATCH 66/87] Lagersync bugfix result array
---
www/lib/class.erpapi.php | 2 +-
www/lib/class.remote.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 72cb4d94..1e28a58a 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -21079,7 +21079,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
$this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.(is_array($result)?$result['status']:$result), $result);
- if ($result['status'] == 1 || $status === 1) {
+ if ((is_array($result)?$result['status'] == 1:false) || $status === 1) {
$cacheQuantity = (int) $verkaufbare_menge_korrektur + (int) $pseudolager;
$this->app->DB->Update(
"UPDATE `artikel` SET `cache_lagerplatzinhaltmenge` = '{$cacheQuantity}'
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index ea75cab4..96f890aa 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -1088,6 +1088,7 @@ class Remote {
$this->logger->debug(
'RemoteSendArticleList',
[
+ 'shop' => $id,
'artikel_arr' => $artikel_arr
]
);
From 43b2cb05c04386804b2bcd9872faf3b70aceff95 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 26 Aug 2024 14:16:08 +0200
Subject: [PATCH 67/87] Bugfix verbindlichkeit datepicker & skonto, zahlbarbis
0 tage
---
www/pages/verbindlichkeit.php | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 110b3462..119d8002 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -603,13 +603,13 @@ class Verbindlichkeit {
$input['skontobis'] = $this->app->erp->ReplaceDatum(true,$input['skontobis'],true); // Parameters: Target db?, value, from form?
$input['zahlbarbis'] = $this->app->erp->ReplaceDatum(true,$input['zahlbarbis'],true); // Parameters: Target db?, value, from form?
- if(!empty($input['zahlbarbis_tage'])) {
+ if($input['zahlbarbis_tage'] != '') {
$zahlbarbis = date_create_from_format('Y-m-d', $input['rechnungsdatum']);
date_add($zahlbarbis,date_interval_create_from_date_string($input['zahlbarbis_tage']." days"));
$input['zahlbarbis'] = date_format($zahlbarbis, 'Y-m-d');
}
unset($input['zahlbarbis_tage']);
- if(!empty($input['skontobis_tage'])) {
+ if($input['skontobis_tage'] != '') {
$skontobis = date_create_from_format('Y-m-d', $input['rechnungsdatum']);
date_add($skontobis,date_interval_create_from_date_string($input['skontobis_tage']." days"));
$input['skontobis'] = date_format($skontobis, 'Y-m-d');
@@ -1032,6 +1032,7 @@ class Verbindlichkeit {
$icons = $this->app->DB->SelectArr($sql);
$this->app->Tpl->Add('STATUSICONS', $icons[0]['icons']);
+ $this->app->YUI->DatePicker("rechnungsdatum");
$this->app->YUI->AutoComplete("adresse", "lieferant");
$this->app->YUI->AutoComplete("projekt", "projektname", 1);
$this->app->Tpl->Set('PROJEKT',$this->app->erp->ReplaceProjekt(false,$verbindlichkeit_from_db['projekt'],false));
@@ -1061,15 +1062,16 @@ class Verbindlichkeit {
if (empty($verbindlichkeit_from_db['freigabe'])) {
$this->app->YUI->TableSearch('PAKETDISTRIBUTION', 'verbindlichkeit_paketdistribution_list', "show", "", "", basename(__FILE__), __CLASS__);
+ } else {
+ // -- POSITIONEN
+ $this->app->YUI->AutoComplete("positionen_sachkonto", "sachkonto", 1);
+ $this->app->YUI->TableSearch('POSITIONEN', 'verbindlichkeit_positionen', "show", "", "", basename(__FILE__), __CLASS__);
+ $this->app->Tpl->Parse('POSITIONENTAB', "verbindlichkeit_positionen.tpl");
+ // -- POSITIONEN
+
+ $this->verbindlichkeit_minidetail('MINIDETAIL',false);
}
- // -- POSITIONEN
- $this->app->YUI->AutoComplete("positionen_sachkonto", "sachkonto", 1);
- $this->app->YUI->TableSearch('POSITIONEN', 'verbindlichkeit_positionen', "show", "", "", basename(__FILE__), __CLASS__);
- $this->app->Tpl->Parse('POSITIONENTAB', "verbindlichkeit_positionen.tpl");
- // -- POSITIONEN
-
- $this->verbindlichkeit_minidetail('MINIDETAIL',false);
$this->app->Tpl->Parse('PAGE', "verbindlichkeit_edit.tpl");
}
From b7ade7b4b27d07cd95ef6d153cb2745f2955c122 Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Mon, 26 Aug 2024 21:58:28 +0200
Subject: [PATCH 68/87] FIX Article: Filter deleted files from thumbnail
selection
---
www/pages/artikel.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/pages/artikel.php b/www/pages/artikel.php
index 62986378..3a6f9689 100644
--- a/www/pages/artikel.php
+++ b/www/pages/artikel.php
@@ -8432,7 +8432,7 @@ padding: 10px;\">
FROM `datei_stichwoerter` AS `ds`
INNER JOIN `datei_version` AS `dv` ON dv.datei = ds.datei
INNER JOIN `datei` AS `d` ON dv.datei = d.id AND IFNULL(d.geloescht, 0) = 0
- WHERE ds.objekt LIKE 'artikel' AND ds.parameter = '%d'
+ WHERE ds.objekt LIKE 'artikel' AND ds.parameter = '%d' AND d.geloescht = 0
AND
(
ds.subjekt like 'Shopbild'
From 1775d0b47f95f92c093d9b80bdd1a9934de80624 Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Mon, 26 Aug 2024 22:10:47 +0200
Subject: [PATCH 69/87] FIX Article: Filter deleted files from default picture
selection
---
www/lib/class.erpapi.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 381e6114..24486c09 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -37436,7 +37436,8 @@ function Firmendaten($field,$projekt="")
SELECT dv.datei AS datei
FROM datei_stichwoerter AS ds
JOIN (SELECT datei, MAX(id) AS id FROM datei_version GROUP BY datei) AS dv ON dv.datei = ds.datei
- WHERE ds.objekt LIKE 'Artikel' AND
+ JOIN datei AS d on ds.datei = d.id
+ WHERE ds.objekt LIKE 'Artikel' AND d.geloescht = 0
ds.parameter = '%d' AND
(ds.subjekt LIKE 'Shopbild' OR ds.subjekt LIKE 'Druckbild' OR ds.subjekt LIKE 'Bild')
ORDER BY ds.subjekt LIKE 'Shopbild' DESC, ds.subjekt LIKE 'Druckbild' DESC, ds.sort
From a9656114a2ef5f8766d583847fdbb6dd293cf133 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 27 Aug 2024 11:59:03 +0200
Subject: [PATCH 70/87] Bugfix verbindlichkeit positionen
---
www/pages/verbindlichkeit.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index 119d8002..f73f12fa 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -1062,13 +1062,15 @@ class Verbindlichkeit {
if (empty($verbindlichkeit_from_db['freigabe'])) {
$this->app->YUI->TableSearch('PAKETDISTRIBUTION', 'verbindlichkeit_paketdistribution_list', "show", "", "", basename(__FILE__), __CLASS__);
- } else {
+ }
+
+ if (!empty($verbindlichkeit_from_db)) {
// -- POSITIONEN
$this->app->YUI->AutoComplete("positionen_sachkonto", "sachkonto", 1);
$this->app->YUI->TableSearch('POSITIONEN', 'verbindlichkeit_positionen', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('POSITIONENTAB', "verbindlichkeit_positionen.tpl");
// -- POSITIONEN
-
+
$this->verbindlichkeit_minidetail('MINIDETAIL',false);
}
From 543c52f2f1765b2d1ad11c1d0eccf51fa00e3bc3 Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Tue, 27 Aug 2024 14:04:07 +0200
Subject: [PATCH 71/87] FIX Article: Use default picture selection in
briefpapier
---
www/lib/dokumente/class.briefpapier.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/lib/dokumente/class.briefpapier.php b/www/lib/dokumente/class.briefpapier.php
index 46d1811d..f8a42cde 100644
--- a/www/lib/dokumente/class.briefpapier.php
+++ b/www/lib/dokumente/class.briefpapier.php
@@ -3525,7 +3525,7 @@ class Briefpapier extends SuperFPDF {
($this->doctype == "gutschrift" && $this->getStyleElement("gutschrift_artikelbild")) ||
($this->doctype == "angebot" && $this->getStyleElement("angebot_artikelbild"))
){
- $datei = $this->app->DB->Select("SELECT datei FROM `datei_stichwoerter` WHERE subjekt='Shopbild' AND objekt='Artikel' AND parameter='" . $item['artikel'] . "' ORDER by sort ASC LIMIT 1");
+ $datei = $this->app->erp->GetArtikelStandardbild($item['artikel'],true);
if(!empty($datei)){
$datei = $this->app->DB->Select("SELECT id FROM datei_version WHERE datei = '$datei' ORDER BY id DESC LIMIT 1");
}
From 586e1bd9b9932d52d101f3cf120344bcec3dccbc Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 29 Aug 2024 12:24:09 +0200
Subject: [PATCH 72/87] bugfix exciler PR
---
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 272cf42c..7cd563ff 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -37438,7 +37438,7 @@ function Firmendaten($field,$projekt="")
FROM datei_stichwoerter AS ds
JOIN (SELECT datei, MAX(id) AS id FROM datei_version GROUP BY datei) AS dv ON dv.datei = ds.datei
JOIN datei AS d on ds.datei = d.id
- WHERE ds.objekt LIKE 'Artikel' AND d.geloescht = 0
+ WHERE ds.objekt LIKE 'Artikel' AND d.geloescht = 0 AND
ds.parameter = '%d' AND
(ds.subjekt LIKE 'Shopbild' OR ds.subjekt LIKE 'Druckbild' OR ds.subjekt LIKE 'Bild')
ORDER BY ds.subjekt LIKE 'Shopbild' DESC, ds.subjekt LIKE 'Druckbild' DESC, ds.sort
From c31b1a2b0d521d0255a65dae12861baa148d9f5b Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 29 Aug 2024 14:19:19 +0200
Subject: [PATCH 73/87] Version 1.12
---
version.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/version.php b/version.php
index 2553c804..4a98a0a2 100755
--- a/version.php
+++ b/version.php
@@ -1,7 +1,7 @@
Date: Thu, 29 Aug 2024 14:58:31 +0200
Subject: [PATCH 74/87] Reordered navigation
---
www/lib/class.erpapi.php | 133 ++++++++----------
www/themes/new/images/sidebar/beschaffung.svg | 8 ++
2 files changed, 66 insertions(+), 75 deletions(-)
create mode 100644 www/themes/new/images/sidebar/beschaffung.svg
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 6776220c..9b153b78 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -7077,155 +7077,138 @@ title: 'Abschicken',
{
// admin menu
$menu = 0;
+
+ // ------ Stammdaten
$navarray['menu']['admin'][++$menu]['first'] = array('Stammdaten','adresse','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Adressen','adresse','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Artikel','artikel','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Projekte','projekt','list');
+ // ------ Verkauf
$navarray['menu']['admin'][++$menu]['first'] = array('Verkauf','auftrag','list');
if($this->ModulVorhanden("anfrage")){
$navarray['menu']['admin'][$menu]['sec'][] = array('Anfrage', 'anfrage', 'list');
}
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Angebot'.($this->Firmendaten("bezeichnungangebotersatz") && $this->Firmendaten("bezeichnungangebotersatz") != 'Angebot'? ' / '.$this->Firmendaten("bezeichnungangebotersatz"):''),'angebot','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Auftrag','auftrag','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('POS','pos','list');
- $navarray['menu']['admin'][++$menu]['first'] = array('Einkauf','auftrag','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Preisanfrage','preisanfrage','list');
+ // ------ Beschaffung
+ $navarray['menu']['admin'][++$menu]['first'] = array('Beschaffung','auftrag','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Bestellung','bestellung','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Bestellvorschlag','bestellvorschlag','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Erweiterter Bestellvorschlag','bestellvorschlagapp','list');
-
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Preisanfrage','preisanfrage','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Produktion','produktion','list');
+ // ------ Logistik
$navarray['menu']['admin'][++$menu]['first'] = array('Logistik','lager','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Wareneingang','wareneingang','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Lieferschein','lieferschein','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Versand','versandpakete','lieferungen');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Artikelkontingente','artikelkontingente','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Ein- und auslagern','lager','letztebewegungen');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Inventur','inventur','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Kommissionieraufkleber','kommissionieraufkleber','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Kommissionierung','kommissionierung','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Lagermindestmengen','lagermindestmengen','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Lagerverwaltung','lager','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Lieferschein','lieferschein','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Mindesthaltbarkeit','mhdwarning','list');
if($this->ModulVorhanden('lagermobil')) {
$navarray['menu']['admin'][$menu]['sec'][] = array('Mobile Lagerverwaltung','lagermobil','list');
}
if($this->ModulVorhanden('multiorderpicking')) {
$navarray['menu']['admin'][$menu]['sec'][] = array('Multiorder-Picking','multiorderpicking','list');
}
- $navarray['menu']['admin'][$menu]['sec'][] = array('Reservierung','lager','reservierungen');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Kommissionierung','kommissionierung','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Inventur','inventur','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Versandzentrum','versanderzeugen','offene');
$navarray['menu']['admin'][$menu]['sec'][] = array('Produktionszentrum','produktionszentrum','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Kommissionieraufkleber','kommissionieraufkleber','list');
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Mindesthaltbarkeit','mhdwarning','list');
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Lagermindestmengen','lagermindestmengen','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Artikelkontingente','artikelkontingente','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Ein- und auslagern','lager','letztebewegungen');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Reservierung','lager','reservierungen');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Versand','versandpakete','lieferungen');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Versandzentrum','versanderzeugen','offene');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Wareneingang','wareneingang','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Zwischenlager','lager','buchenzwischenlager');
+ // ------ Buchhaltung
$navarray['menu']['admin'][++$menu]['first'] = array('Buchhaltung','rechnung','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Rechnungen','rechnung','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Zahlungseingang','zahlungseingang','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Reisekosten','reisekosten','list');
- $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('Kontoauszüge','kontoauszuege','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Buchungen','fibu_buchungen','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Abolauf','rechnungslauf','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Arbeitsnachweis','arbeitsnachweis','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Buchungen','fibu_buchungen','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Dokumenten Scanner','docscan','list');
+
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Gutschriften / '.$this->Firmendaten("bezeichnungstornorechnung"),'gutschrift','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Kontoauszüge','kontoauszuege','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Lieferantengutschriften','lieferantengutschrift','list');
+
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Mahnwesen','mahnwesen','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Proformarechnung','proformarechnung','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Rechnungen','rechnung','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Reisekosten','reisekosten','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Finanzbuchhaltung Export','buchhaltungexport','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Zahlungsverkehr','zahlungsverkehr','ueberweisung');
$navarray['menu']['admin'][$menu]['sec'][] = array('Verbandsabrechnungen','verband','offene');
$navarray['menu']['admin'][$menu]['sec'][] = array('Vertreterabrechnungen','vertreter','list');
- if($this->ModulVorhanden('provisionenartikelvertreter'))
+ if ($this->ModulVorhanden('provisionenartikelvertreter'))
{
$navarray['menu']['admin'][$menu]['sec'][] = array('Provisionen','provisionenartikelvertreter','list');
- }else{
+ } else {
$navarray['menu']['admin'][$menu]['sec'][] = array('Provisionen','provisionenartikel','list');
}
-
if($this->Firmendaten("modul_mlm")=="1"){
$navarray['menu']['admin'][$menu]['sec'][] = array('Multilevel', 'multilevel', 'list');
}
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Lohnabrechnung','lohnabrechnung','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Verbindlichkeiten','verbindlichkeit','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Lieferantengutschriften','lieferantengutschrift','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Kassenbuch','kasse','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Zahlungseingang','zahlungseingang','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Zahlungsverkehr','zahlungsverkehr','ueberweisung');
+ // ------ Controlling
$navarray['menu']['admin'][++$menu]['first'] = array('Controlling','marketing','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Verkaufszahlen','verkaufszahlen','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Umsatzstatistik','umsatzstatistik','allgemein');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Statistiken','statistiken','dashboard');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Aktionscodes','aktionscodes','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Berichte','report','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Management Board','managementboard','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Aktionscodes','aktionscodes','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Statistiken','statistiken','dashboard');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Umsatzstatistik','umsatzstatistik','allgemein');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Verkaufszahlen','verkaufszahlen','list');
+ // ------ Verwaltung
$navarray['menu']['admin'][++$menu]['first'] = array('Verwaltung','rechnung','list');
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Ticketregeln','ticketregeln','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Zeitkonten','zeiterfassung','list');
if(!$this->RechteVorhanden('mitarbeiterzeiterfassung','dashboard')){
$navarray['menu']['admin'][$menu]['sec'][] = array('Antrag einreichen','mitarbeiterzeiterfassung','timemanagementrequest');
}
else{
$navarray['menu']['admin'][$menu]['sec'][] = array('Mitarbeiterzeiterfassung','mitarbeiterzeiterfassung','dashboard');
}
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Import/Export Zentrale','importvorlage','uebersicht');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Währungen','waehrungumrechnung','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Seriennummern','seriennummern','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Chargen','chargen','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('RMA Lieferungen','rma','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Service & Support','service','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Etikettendrucker','etikettendrucker','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Währungen','waehrungumrechnung','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Ticketregeln','ticketregeln','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Zeitkonten','zeiterfassung','list');
+ // ------ System
$navarray['menu']['admin'][++$menu]['first'] = array('System','rechnung','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Einstellungen','einstellungen','list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Online-Shops / Marktplätze','onlineshops','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Backup','backup','list','recover','delete','reset');
$navarray['menu']['admin'][$menu]['sec'][] = array('Upgrade','upgrade','list','recover','delete','reset');
- //$navarray['menu']['admin'][$menu]['sec'][] = array('AppStore','appstore','list');
+ // ------ Mein Bereich
$navarray['menu']['admin'][++$menu]['first'] = array('Mein Bereich','welcome','main');
$startseite = $this->app->DB->Select("SELECT startseite FROM user WHERE id='".$this->app->User->GetID()."' LIMIT 1");
- if($startseite!="")
- $navarray['menu']['admin'][$menu]['sec'][] = array('Meine Startseite','welcome','startseite');
-
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Startseite','welcome','start');
-// $navarray['menu']['admin'][$menu]['sec'][] = array('Meine Apps','welcome','meineapps');
- if($this->app->User->GetType() === 'admin') {
- // $navarray['menu']['admin'][$menu]['sec'][] = ['Learning Dashboard', 'learningdashboard', 'list'];
+ if($startseite!="") {
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Meine Startseite','welcome','startseite');
}
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Tickets','ticket','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Kalender','kalender','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Pinnwand','welcome','pinwand');
$navarray['menu']['admin'][$menu]['sec'][] = array('Aufgaben','aufgaben','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('E-Mail','webmail','list');
-
$navarray['menu']['admin'][$menu]['sec'][] = array('Chat','chat','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Zeiterfassung','zeiterfassung','create');
-
-// $navarray['menu']['admin'][$menu]['sec'][] = array('Stechuhr','stechuhr','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Wiedervorlage','wiedervorlage','list');
-
- $navarray['menu']['admin'][$menu]['sec'][] = array('Wiki','wiki','list');
- $navarray['menu']['admin'][$menu]['sec'][] = array('Interner Support', 'internalsupport', 'list');
$navarray['menu']['admin'][$menu]['sec'][] = array('Einstellungen','welcome','settings');
-// $navarray['menu']['admin'][$menu]['sec'][] = array('Datenschutz', 'dataprotection','list');
-// $navarray['menu']['admin'][$menu]['sec'][] = array('Lizenz','appstore','buy');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('E-Mail','webmail','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Kalender','kalender','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Interner Support', 'internalsupport', 'list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Pinnwand','welcome','pinwand');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Startseite','welcome','start');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Tickets','ticket','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Wiedervorlage','wiedervorlage','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Wiki','wiki','list');
+ $navarray['menu']['admin'][$menu]['sec'][] = array('Zeiterfassung','zeiterfassung','create');
$navarray['menu']['admin'][$menu]['sec'][] = array('Abmelden','welcome','logout');
return $this->CalculateNavigation($navarray);
diff --git a/www/themes/new/images/sidebar/beschaffung.svg b/www/themes/new/images/sidebar/beschaffung.svg
new file mode 100644
index 00000000..7447e4fc
--- /dev/null
+++ b/www/themes/new/images/sidebar/beschaffung.svg
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
From 9fbc4e2f6b6845f1234146d4dce9b8e5a434d9e9 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 29 Aug 2024 18:09:04 +0200
Subject: [PATCH 75/87] mirakl configuration_order_fetch_status
---
www/pages/shopimporter_mirakl.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index 063a18fc..b3f83aa0 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -30,6 +30,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
private $configuration_identifier;
private $mirakl_error_text_product_missing;
+ private $configuration_order_fetch_status;
private $normalTaxId;
private $reducedTaxId;
@@ -92,6 +93,13 @@ class Shopimporter_Mirakl extends ShopimporterBase {
'info' => 'Der Fehlertext der anzeigt dass das Produkt nicht existiert (Angebotsimport, Fehlerbericht)',
'default' => 'The product does not exist'
],
+ 'configuration_order_fetch_status' => [
+ 'typ' => 'text',
+ 'bezeichnung' => '{|Status für abzuholende Aufträge|}:',
+ 'size' => 40,
+ 'info' => 'STAGING, WAITING_ACCEPTANCE, WAITING_DEBIT, WAITING_DEBIT_PAYMENT, SHIPPING, SHIPPED, TO_COLLECT, RECEIVED, CLOSED, REFUSED, CANCELED',
+ 'default' => 'WAITING_ACCEPTANCE'
+ ],
'normalTaxId' => [
'typ' => 'text',
'bezeichnung' => '{|TaxId für Steuersatz "normal"|}',
@@ -182,6 +190,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$this->configuration_identifier = array($einstellungen['felder']['configuration_identifier_source'] => $einstellungen['felder']['configuration_identifier_source_value']);
$this->mirakl_error_text_product_missing = $einstellungen['felder']['mirakl_error_text_product_missing'];
+ $this->configuration_order_fetch_status = $einstellungen['felder']['configuration_order_fetch_status'];
$this->normalTaxId = $einstellungen['felder']['normalTaxId'];
$this->reducedTaxId = $einstellungen['felder']['reducedTaxId'];
@@ -450,7 +459,7 @@ class Shopimporter_Mirakl extends ShopimporterBase {
// STAGING, WAITING_ACCEPTANCE, WAITING_DEBIT, WAITING_DEBIT_PAYMENT, SHIPPING, SHIPPED, TO_COLLECT, RECEIVED, CLOSED, REFUSED, CANCELED
public function ImportGetAuftraegeAnzahl() {
- $response = $this->miraklRequest('orders', getdata: array('order_state_codes' => 'WAITING_ACCEPTANCE'), raw: true);
+ $response = $this->miraklRequest('orders', getdata: array('order_state_codes' => $this->configuration_order_fetch_status), raw: true);
$this->Log(Logger::DEBUG, 'ImportGetAuftraegeAnzahl', $response);
$result_array = json_decode($response);
return($result_array->total_count);
@@ -458,13 +467,13 @@ class Shopimporter_Mirakl extends ShopimporterBase {
public function ImportGetAuftrag() {
- $parameters = array('order_state_codes' => 'WAITING_ACCEPTANCE');
+ $parameters = array('order_state_codes' => $this->configuration_order_fetch_status);
if(!empty($this->data['nummer'])) {
$parameters['order_ids'] = $this->data['nummer'];
}
- $response = $this->miraklRequest('orders', getdata: $parameters, raw: true);
+ $response = $this->miraklRequest('orders', getdata: $parameters, raw: true);
$this->Log(Logger::DEBUG, 'ImportGetAuftrag', $response);
$result_array = json_decode($response);
From 389a29793ad1397559290ff47fbe4ceb6412cc2c Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Thu, 29 Aug 2024 18:43:26 +0200
Subject: [PATCH 76/87] mirakl auftrag import additional info
---
www/lib/class.erpapi.php | 3 +++
www/pages/shopimporter_mirakl.php | 15 ++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 1e28a58a..a436ed3e 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -17727,6 +17727,9 @@ function CheckShopTabelle($artikel)
if($doctype === 'angebot'){
$this->app->DB->Update("UPDATE angebot SET anfrage = '".$this->app->DB->real_escape_string($warenkorb['onlinebestellnummer'])."' WHERE id = '$auftrag' LIMIT 1");
}
+ if($doctype === 'auftrag'){
+ $this->app->DB->Update("UPDATE auftrag SET ihrebestellnummer = '".$this->app->DB->real_escape_string($warenkorb['ihrebestellnummer'])."' WHERE id = '$auftrag' LIMIT 1");
+ }
$this->app->DB->Update("UPDATE $doctype SET
belegnr='$belegnr',
diff --git a/www/pages/shopimporter_mirakl.php b/www/pages/shopimporter_mirakl.php
index b3f83aa0..5f50d34e 100644
--- a/www/pages/shopimporter_mirakl.php
+++ b/www/pages/shopimporter_mirakl.php
@@ -522,9 +522,9 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['lieferadresse_name'] = ($order->customer->shipping_address->civility?$order->customer->shipping_address->civility." ":"").$order->customer->shipping_address->firstname." ".$order->customer->shipping_address->lastname;
- if (!empty(strval($order->customer->shipping_address->company))) {
+ if (!empty($order->customer->shipping_address->company)) {
$cart['lieferadresse_ansprechpartner'] = $cart['lieferadresse_name'];
- $cart['lieferadresse_name'] = strval($deliveryAddress->company);
+ $cart['lieferadresse_name'] = strval($order->customer->shipping_address->company);
}
$cart['lieferadresse_strasse'] = strval($order->customer->shipping_address->street_1);
@@ -532,6 +532,16 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['lieferadresse_telefon'] = strval($order->customer->shipping_address->phone);
$cart['lieferadresse_plz'] = strval($order->customer->shipping_address->zip_code);
$cart['lieferadresse_ort'] = strval($order->customer->shipping_address->city);
+
+ $cart['internebemerkung'] = strval($order->customer->shipping_address->additional_info);
+
+ if (is_array($order->order_additional_fields)) {
+ $order_reference = array_search('customer-order-reference',array_column($order->order_additional_fields,'code'));
+
+ if ($order_reference !== false) {
+ $cart['ihrebestellnummer'] .= $order->order_additional_fields[$order_reference]->value;
+ }
+ }
$cart['zahlungsweise'] = strval($order->payment_type);
@@ -544,7 +554,6 @@ class Shopimporter_Mirakl extends ShopimporterBase {
$cart['articlelist'] = [];
-
$shipping_tax_amount = 0;
foreach ($order->order_lines as $order_row) {
From 8c3442c73d606bad15408203819f2cfeefea913c Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 31 Aug 2024 13:12:37 +0200
Subject: [PATCH 77/87] class.remote.php formatting
---
www/lib/class.remote.php | 4744 ++++++++++++++++++--------------------
1 file changed, 2265 insertions(+), 2479 deletions(-)
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 937ae7a7..e87eb432 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -1,4 +1,5 @@
app=$app;
- }
+class Remote {
- /**
- * @param int $shopId
- * @param null|bool $extra
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteConnection($shopId, $extra = null)
- {
- $ret = $this->RemoteCommand($shopId,'auth', $extra);
- if($ret !== 'success' && empty($extra) && method_exists($this->app->erp, 'setSystemHealth')) {
- $this->app->erp->setSystemHealth(
- 'shopexport',
- 'auth',
- 'warning',
- 'Verbindung zu '.
- $this->app->DB->Select(
- sprintf(
- 'SELECT bezeichnung FROM shopexport WHERE id = %d',
- $shopId
- )
- ).' fehlgeschlagen.'
- );
- try {
- /** @var Systemhealth $systemhealth */
- $systemhealth = $this->app->erp->LoadModul('systemhealth');
- if($systemhealth !== null && method_exists($systemhealth, 'createEvent')){
- $systemhealth->createEvent('shopexport', 'auth', 'warning', 'shopexport', $shopId);
+ /** @var ApplicationCore $app */
+ public $app;
+
+ public function __construct($app) {
+ $this->app = $app;
+ }
+
+ /**
+ * @param int $shopId
+ * @param null|bool $extra
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteConnection($shopId, $extra = null) {
+ $ret = $this->RemoteCommand($shopId, 'auth', $extra);
+ if ($ret !== 'success' && empty($extra) && method_exists($this->app->erp, 'setSystemHealth')) {
+ $this->app->erp->setSystemHealth(
+ 'shopexport',
+ 'auth',
+ 'warning',
+ 'Verbindung zu ' .
+ $this->app->DB->Select(
+ sprintf(
+ 'SELECT bezeichnung FROM shopexport WHERE id = %d',
+ $shopId
+ )
+ ) . ' fehlgeschlagen.'
+ );
+ try {
+ /** @var Systemhealth $systemhealth */
+ $systemhealth = $this->app->erp->LoadModul('systemhealth');
+ if ($systemhealth !== null && method_exists($systemhealth, 'createEvent')) {
+ $systemhealth->createEvent('shopexport', 'auth', 'warning', 'shopexport', $shopId);
+ }
+ } catch (Exception $d) {
+
+ }
}
- }
- catch (Exception $d) {
-
- }
- }
- return $ret;
- }
-
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteGetUpdateArticleList($shopId)
- {
- return $this->RemoteCommand($shopId,'getlist');
- }
-
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteGetFileList($shopId)
- {
- return $this->RemoteCommand($shopId,'getfilelist');
- }
-
- /**
- * @param int $shopId
- * @param int|string $articleId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteGetFileListArticle($shopId, $article)
- {
- $data['artikel'] = $article;
-
- return $this->RemoteCommand($shopId,'getfilelistarticle', $data);
- }
-
- /**
- * @param int $shopId
- * @param array|string $data
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteGetAuftraegeAnzahl($shopId,$data = '')
- {
- if(!empty($data))
- {
- return $this->RemoteCommand($shopId,'getauftraegeanzahl', $data);
- }
- $data = array();
- $shopexportArr = $this->app->DB->SelectRow(sprintf('SELECT * FROM shopexport WHERE id = %d LIMIT 1', $shopId));
- $holealle = $shopexportArr['holealle'];
- $holeallestati = $shopexportArr['holeallestati'];
- $zeitraum = [
- 'datumvon'=>$shopexportArr['datumvon'],
- 'datumbis'=>$shopexportArr['datumbis'],
- 'tmpdatumvon'=>$shopexportArr['tmpdatumvon'],
- 'tmpdatumbis'=>$shopexportArr['tmpdatumbis'],
- 'anzgleichzeitig'=>$shopexportArr['anzgleichzeitig'],
- ];
- if(!empty($zeitraum))
- {
- $data['datumvon'] = $zeitraum['datumvon'];
- $data['datumbis'] = $zeitraum['datumbis'];
- //if(strtotime($zeitraum[0]['tmpdatumbis']) > 0)$data['datumbis'] = $zeitraum[0]['tmpdatumbis'];
- //if(strtotime($zeitraum[0]['tmpdatumvon']) > 0)$data['datumvon'] = $zeitraum[0]['tmpdatumbis'];
- if($data['datumvon'] === null || $data['datumvon'] === '0000-00-00 00:00:00'|| strtotime($data['datumvon'])<=0) {
- $data['datumvon'] = '2000-01-01 00:00:00';
- }
- if($data['datumbis'] === null || $data['datumbis'] === '0000-00-00 00:00:00'|| strtotime($data['datumbis'])<=0) {
- $data['datumbis'] = date('Y-m-d H:i:s');
- $data['datumbis_utc'] = $this->app->DB->Select('select date_sub(UTC_TIMESTAMP, INTERVAL 0 MINUTE)');
- }
- $data['anzgleichzeitig'] = $zeitraum[0]['anzgleichzeitig'];
- if($holeallestati && $data['anzgleichzeitig'] > 1)
- {
- $data['holeallestati'] = 1;
- }
- }
- if($holealle)
- {
- $ab_nummer = $shopexportArr['ab_nummer'];
- $data = array('ab_nummer' => $ab_nummer);
- if($holeallestati)
- {
- $data['holeallestati'] = 1;
- }
-
- return $this->RemoteCommand($shopId,'getauftraegeanzahl', $data);
+ return $ret;
}
- return $this->RemoteCommand($shopId,'getauftraegeanzahl');
- }
-
- /**
- * @param int $shopId
- * @param string $nummer
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteGetAuftraegeAnzahlNummer($shopId, $nummer)
- {
- $data = array('nummer' => $nummer);
-
- return $this->RemoteCommand($shopId,'getauftraegeanzahl', $data);
- }
-
- /**
- * @param int $shopId
- * @param null|array $data
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteGetAuftrag($shopId, $data = null)
- {
- if(!empty($data)) {
- return $this->RemoteCommand($shopId,'getauftrag', $data);
- }
- $data = array();
-
- $shopexportArr = $this->app->DB->SelectRow(
- sprintf(
- 'SELECT * FROM shopexport WHERE id = %d LIMIT 1',
- $shopId
- )
- );
- $holealle = $shopexportArr['holealle'];
- $holeallestati = $shopexportArr['holeallestati'];
- $zeitraum = [
- 'datumvon'=>$shopexportArr['datumvon'],
- 'datumbis'=>$shopexportArr['datumbis'],
- 'tmpdatumvon'=>$shopexportArr['tmpdatumvon'],
- 'tmpdatumbis'=>$shopexportArr['tmpdatumbis'],
- 'anzgleichzeitig'=>$shopexportArr['anzgleichzeitig'],
- ];
- if(!empty($zeitraum)) {
- $data['datumvon'] = $zeitraum['datumvon'];
- $data['datumbis'] = $zeitraum['datumbis'];
- if($zeitraum['tmpdatumbis'] !== null && $zeitraum['tmpdatumbis'] !== '0000-00-00 00:00:00' &&
- strtotime($zeitraum['tmpdatumbis']) > 0) {
- $data['datumbis'] = $zeitraum['tmpdatumbis'];
- }
- //if(strtotime($zeitraum[0]['tmpdatumvon']) > 0)$data['datumvon'] = $zeitraum[0]['tmpdatumbis'];
- if($data['datumvon'] === null || $data['datumvon'] === '0000-00-00 00:00:00' || strtotime($data['datumvon'])<=0) {
- $data['datumvon'] = '2000-01-01 00:00:00';
- }
- if($data['datumbis'] === null || $data['datumbis'] === '0000-00-00 00:00:00' || strtotime($data['datumbis'])<=0) {
- $data['datumbis'] = date('Y-m-d H:i:s');
- $data['datumbis_utc'] = $this->app->DB->Select('select date_sub(UTC_TIMESTAMP, INTERVAL 0 MINUTE)');
- }
- $data['anzgleichzeitig'] = $zeitraum['anzgleichzeitig'];
- if($data['anzgleichzeitig'] > 1 && $shopexportArr['einzelsync']) {
- $data['anzgleichzeitig'] = 1;
- }
- if($holeallestati) {
- $data['holeallestati'] = 1;
- }
- }
- if($holealle) {
- $ab_nummer = $shopexportArr['ab_nummer'];
- $data['ab_nummer'] = $ab_nummer;
- if($holeallestati) {
- $data['holeallestati'] = 1;
- }
-
- return $this->RemoteCommand($shopId,'getauftrag', $data);
- }
- if(!empty($zeitraum)) {
- return $this->RemoteCommand($shopId,'getauftrag', $data);
- }
-
- return $this->RemoteCommand($shopId,'getauftrag');
- }
-
- /**
- * @param int $shopId
- * @param string $nummer
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteGetAuftragNummer($shopId, $nummer)
- {
- $holealle = $this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$shopId' LIMIT 1");
- if($holealle)
- {
- $data = array('nummer' => $nummer);
-
- return $this->RemoteCommand($shopId,'getauftrag', $data);
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteGetUpdateArticleList($shopId) {
+ return $this->RemoteCommand($shopId, 'getlist');
}
- return '';
- }
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteGetFileList($shopId) {
+ return $this->RemoteCommand($shopId, 'getfilelist');
+ }
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteSendExportlink($shopId)
- {
- // passwort erzeugen , daten verschluesseln, wenn passwort neu link an kunden senden
- // alternativ artikel umfrage
- // $all = $this->app->DB->SelectArr("SELECT * FROM artikelgruppen WHERE shop='$id'");
+ /**
+ * @param int $shopId
+ * @param int|string $articleId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteGetFileListArticle($shopId, $article) {
+ $data['artikel'] = $article;
- // alle artikelid = 38 die in einem auftrag sind
+ return $this->RemoteCommand($shopId, 'getfilelistarticle', $data);
+ }
+ /**
+ * @param int $shopId
+ * @param array|string $data
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteGetAuftraegeAnzahl($shopId, $data = '') {
+ if (!empty($data)) {
+ return $this->RemoteCommand($shopId, 'getauftraegeanzahl', $data);
+ }
+ $data = array();
+ $shopexportArr = $this->app->DB->SelectRow(sprintf('SELECT * FROM shopexport WHERE id = %d LIMIT 1', $shopId));
+ $holealle = $shopexportArr['holealle'];
+ $holeallestati = $shopexportArr['holeallestati'];
+ $zeitraum = [
+ 'datumvon' => $shopexportArr['datumvon'],
+ 'datumbis' => $shopexportArr['datumbis'],
+ 'tmpdatumvon' => $shopexportArr['tmpdatumvon'],
+ 'tmpdatumbis' => $shopexportArr['tmpdatumbis'],
+ 'anzgleichzeitig' => $shopexportArr['anzgleichzeitig'],
+ ];
+ if (!empty($zeitraum)) {
+ $data['datumvon'] = $zeitraum['datumvon'];
+ $data['datumbis'] = $zeitraum['datumbis'];
+ //if(strtotime($zeitraum[0]['tmpdatumbis']) > 0)$data['datumbis'] = $zeitraum[0]['tmpdatumbis'];
+ //if(strtotime($zeitraum[0]['tmpdatumvon']) > 0)$data['datumvon'] = $zeitraum[0]['tmpdatumbis'];
+ if ($data['datumvon'] === null || $data['datumvon'] === '0000-00-00 00:00:00' || strtotime($data['datumvon']) <= 0) {
+ $data['datumvon'] = '2000-01-01 00:00:00';
+ }
+ if ($data['datumbis'] === null || $data['datumbis'] === '0000-00-00 00:00:00' || strtotime($data['datumbis']) <= 0) {
+ $data['datumbis'] = date('Y-m-d H:i:s');
+ $data['datumbis_utc'] = $this->app->DB->Select('select date_sub(UTC_TIMESTAMP, INTERVAL 0 MINUTE)');
+ }
+ $data['anzgleichzeitig'] = $zeitraum[0]['anzgleichzeitig'];
+ if ($holeallestati && $data['anzgleichzeitig'] > 1) {
+ $data['holeallestati'] = 1;
+ }
+ }
+ if ($holealle) {
+ $ab_nummer = $shopexportArr['ab_nummer'];
+ $data = array('ab_nummer' => $ab_nummer);
+ if ($holeallestati) {
+ $data['holeallestati'] = 1;
+ }
- // usb90key
- $artikelid= 38;
+ return $this->RemoteCommand($shopId, 'getauftraegeanzahl', $data);
+ }
- $all = $this->app->DB->SelectArr("SELECT a.id as auftrag, a.adresse as adresse
+ return $this->RemoteCommand($shopId, 'getauftraegeanzahl');
+ }
+
+ /**
+ * @param int $shopId
+ * @param string $nummer
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteGetAuftraegeAnzahlNummer($shopId, $nummer) {
+ $data = array('nummer' => $nummer);
+
+ return $this->RemoteCommand($shopId, 'getauftraegeanzahl', $data);
+ }
+
+ /**
+ * @param int $shopId
+ * @param null|array $data
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteGetAuftrag($shopId, $data = null) {
+ if (!empty($data)) {
+ return $this->RemoteCommand($shopId, 'getauftrag', $data);
+ }
+ $data = array();
+
+ $shopexportArr = $this->app->DB->SelectRow(
+ sprintf(
+ 'SELECT * FROM shopexport WHERE id = %d LIMIT 1',
+ $shopId
+ )
+ );
+ $holealle = $shopexportArr['holealle'];
+ $holeallestati = $shopexportArr['holeallestati'];
+ $zeitraum = [
+ 'datumvon' => $shopexportArr['datumvon'],
+ 'datumbis' => $shopexportArr['datumbis'],
+ 'tmpdatumvon' => $shopexportArr['tmpdatumvon'],
+ 'tmpdatumbis' => $shopexportArr['tmpdatumbis'],
+ 'anzgleichzeitig' => $shopexportArr['anzgleichzeitig'],
+ ];
+ if (!empty($zeitraum)) {
+ $data['datumvon'] = $zeitraum['datumvon'];
+ $data['datumbis'] = $zeitraum['datumbis'];
+ if ($zeitraum['tmpdatumbis'] !== null && $zeitraum['tmpdatumbis'] !== '0000-00-00 00:00:00' &&
+ strtotime($zeitraum['tmpdatumbis']) > 0) {
+ $data['datumbis'] = $zeitraum['tmpdatumbis'];
+ }
+ //if(strtotime($zeitraum[0]['tmpdatumvon']) > 0)$data['datumvon'] = $zeitraum[0]['tmpdatumbis'];
+ if ($data['datumvon'] === null || $data['datumvon'] === '0000-00-00 00:00:00' || strtotime($data['datumvon']) <= 0) {
+ $data['datumvon'] = '2000-01-01 00:00:00';
+ }
+ if ($data['datumbis'] === null || $data['datumbis'] === '0000-00-00 00:00:00' || strtotime($data['datumbis']) <= 0) {
+ $data['datumbis'] = date('Y-m-d H:i:s');
+ $data['datumbis_utc'] = $this->app->DB->Select('select date_sub(UTC_TIMESTAMP, INTERVAL 0 MINUTE)');
+ }
+ $data['anzgleichzeitig'] = $zeitraum['anzgleichzeitig'];
+ if ($data['anzgleichzeitig'] > 1 && $shopexportArr['einzelsync']) {
+ $data['anzgleichzeitig'] = 1;
+ }
+ if ($holeallestati) {
+ $data['holeallestati'] = 1;
+ }
+ }
+ if ($holealle) {
+ $ab_nummer = $shopexportArr['ab_nummer'];
+ $data['ab_nummer'] = $ab_nummer;
+ if ($holeallestati) {
+ $data['holeallestati'] = 1;
+ }
+
+ return $this->RemoteCommand($shopId, 'getauftrag', $data);
+ }
+ if (!empty($zeitraum)) {
+ return $this->RemoteCommand($shopId, 'getauftrag', $data);
+ }
+
+ return $this->RemoteCommand($shopId, 'getauftrag');
+ }
+
+ /**
+ * @param int $shopId
+ * @param string $nummer
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteGetAuftragNummer($shopId, $nummer) {
+ $holealle = $this->app->DB->Select("SELECT holealle FROM shopexport WHERE id = '$shopId' LIMIT 1");
+ if ($holealle) {
+ $data = array('nummer' => $nummer);
+
+ return $this->RemoteCommand($shopId, 'getauftrag', $data);
+ }
+
+ return '';
+ }
+
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteSendExportlink($shopId) {
+ // passwort erzeugen , daten verschluesseln, wenn passwort neu link an kunden senden
+ // alternativ artikel umfrage
+ // $all = $this->app->DB->SelectArr("SELECT * FROM artikelgruppen WHERE shop='$id'");
+ // alle artikelid = 38 die in einem auftrag sind
+ // usb90key
+ $artikelid = 38;
+
+ $all = $this->app->DB->SelectArr("SELECT a.id as auftrag, a.adresse as adresse
FROM auftrag_position ap
LEFT JOIN auftrag a ON a.id=ap.auftrag
WHERE ap.artikel='$artikelid' AND ap.geliefert_menge < ap.menge AND a.status!='storniert'
AND a.status!='abgeschlossen'");
- // mail mit url senden
- if(empty($all)) {
- return '';
- }
- $loop = 0;
- $call = (!empty($all)?count($all):0);
- for($i=0;$i<$call;$i++)
- {
- $auftragid = $all[$i]['auftrag'];
- $adresse = $all[$i]['adresse'];
+ // mail mit url senden
+ if (empty($all)) {
+ return '';
+ }
+ $loop = 0;
+ $call = (!empty($all) ? count($all) : 0);
+ for ($i = 0; $i < $call; $i++) {
+ $auftragid = $all[$i]['auftrag'];
+ $adresse = $all[$i]['adresse'];
- $grund = 'artikel';
+ $grund = 'artikel';
- $check = $this->app->DB->Select("SELECT reg FROM exportlink_sent WHERE adresse='$adresse' AND objekt='$artikelid' AND ident='$auftragid' LIMIT 1");
+ $check = $this->app->DB->Select("SELECT reg FROM exportlink_sent WHERE adresse='$adresse' AND objekt='$artikelid' AND ident='$auftragid' LIMIT 1");
- if($check=='')
- {
- $checkreg = 1;
- while($checkreg!='')
- {
- $token1 = md5(uniqid(rand(), true));
- $token2 = md5(uniqid(rand(), true));
+ if ($check == '') {
+ $checkreg = 1;
+ while ($checkreg != '') {
+ $token1 = md5(uniqid(rand(), true));
+ $token2 = md5(uniqid(rand(), true));
- $token3 = md5(uniqid(rand(), true));
- $token4 = md5(uniqid(rand(), true));
+ $token3 = md5(uniqid(rand(), true));
+ $token4 = md5(uniqid(rand(), true));
- $zufall = $token1 . '-' . $token2;
- $zufall = md5($zufall);
+ $zufall = $token1 . '-' . $token2;
+ $zufall = md5($zufall);
- $zufall2 = $token3 . '-' . $token4;
- $zufall2 = md5($zufall2);
+ $zufall2 = $token3 . '-' . $token4;
+ $zufall2 = md5($zufall2);
- $reg = md5($zufall2.$zufall);
+ $reg = md5($zufall2 . $zufall);
- $checkreg = $this->app->DB->Select("SELECT reg FROM exportlink_sent WHERE reg='$reg' LIMIT 1");
+ $checkreg = $this->app->DB->Select("SELECT reg FROM exportlink_sent WHERE reg='$reg' LIMIT 1");
+ }
+
+ // pruefen ob es zahl schon gibt sonst nochmal
+
+ $data[$loop]['reg'] = $reg;
+ $data[$loop]['grund'] = $grund;
+ $data[$loop]['objekt'] = $artikelid; // artikel id
+ $data[$loop]['ident'] = $auftragid; //
+ $loop++;
+
+ $this->app->DB->Insert("INSERT INTO exportlink_sent (reg,grund,objekt,ident,adresse,datum) VALUES ($reg','$grund','$artikelid','$auftragid','$adresse',NOW())");
+ }
}
- // pruefen ob es zahl schon gibt sonst nochmal
-
- $data[$loop]['reg'] = $reg;
- $data[$loop]['grund'] = $grund;
- $data[$loop]['objekt'] = $artikelid; // artikel id
- $data[$loop]['ident'] = $auftragid;//
- $loop++;
-
- $this->app->DB->Insert("INSERT INTO exportlink_sent (reg,grund,objekt,ident,adresse,datum) VALUES ($reg','$grund','$artikelid','$auftragid','$adresse',NOW())");
- }
+ return $this->RemoteCommand($shopId, 'exportlink', $data);
}
- return $this->RemoteCommand($shopId,'exportlink',$data);
- }
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteSendNavigation($shopId) {
+ //$data[0] = array('aasas','asddd');
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteSendNavigation($shopId)
- {
- //$data[0] = array('aasas','asddd');
+ $all = $this->app->DB->SelectArr("SELECT * FROM shopnavigation WHERE shop='$shopId'");
+ $call = $all ? count($all) : 0;
+ $data = $call > 0 ? array() : null;
+ for ($i = 0; $i < $call; $i++) {
+ $data[$i]['id'] = $all[$i]['id'];
+ $data[$i]['bezeichnung'] = $all[$i]['bezeichnung'];
+ $data[$i]['position'] = $all[$i]['position'];
+ $data[$i]['parent'] = $all[$i]['parent'];
+ $data[$i]['bezeichnung_en'] = $all[$i]['bezeichnung_en'];
+ $data[$i]['plugin'] = $all[$i]['plugin'];
+ $data[$i]['pluginparameter'] = $all[$i]['pluginparameter'];
+ $data[$i]['target'] = $all[$i]['target'];
+ }
- $all = $this->app->DB->SelectArr("SELECT * FROM shopnavigation WHERE shop='$shopId'");
- $call = $all?count($all):0;
- $data = $call > 0?array():null;
- for($i=0;$i<$call;$i++)
- {
- $data[$i]['id'] = $all[$i]['id'];
- $data[$i]['bezeichnung'] = $all[$i]['bezeichnung'];
- $data[$i]['position'] = $all[$i]['position'];
- $data[$i]['parent'] = $all[$i]['parent'];
- $data[$i]['bezeichnung_en'] = $all[$i]['bezeichnung_en'];
- $data[$i]['plugin'] = $all[$i]['plugin'];
- $data[$i]['pluginparameter'] = $all[$i]['pluginparameter'];
- $data[$i]['target'] = $all[$i]['target'];
+ return $this->RemoteCommand($shopId, 'navigation', $data);
}
- return $this->RemoteCommand($shopId,'navigation',$data);
- }
-
- /**
- * @param int $shopId
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteSendArtikelgruppen($shopId)
- {
- $all = $this->app->DB->SelectArr("SELECT id, bezeichnung,bezeichnung_en,beschreibung_de,beschreibung_en
+ /**
+ * @param int $shopId
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteSendArtikelgruppen($shopId) {
+ $all = $this->app->DB->SelectArr("SELECT id, bezeichnung,bezeichnung_en,beschreibung_de,beschreibung_en
FROM artikelgruppen WHERE shop='$shopId'");
- if(empty($all)) {
- return '';
+ if (empty($all)) {
+ return '';
+ }
+
+ return $this->RemoteCommand($shopId, 'artikelgruppen', $all);
}
- return $this->RemoteCommand($shopId,'artikelgruppen',$all);
- }
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteSendInhalt($shopId) {
+ $all = $this->app->DB->SelectArr("SELECT * FROM inhalt WHERE shop='$shopId' AND aktiv=1");
+ if (empty($all)) {
+ return '';
+ }
+ $call = (!empty($all) ? count($all) : 0);
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteSendInhalt($shopId)
- {
- $all = $this->app->DB->SelectArr("SELECT * FROM inhalt WHERE shop='$shopId' AND aktiv=1");
- if(empty($all)) {
- return '';
- }
- $call = (!empty($all)?count($all):0);
+ $data = array();
+ for ($i = 0; $i < $call; $i++) {
+ $data[$i]['sprache'] = $all[$i]['sprache'];
+ $data[$i]['inhalt'] = $all[$i]['inhalt'];
+ $data[$i]['kurztext'] = $all[$i]['kurztext'];
+ $data[$i]['html'] = $all[$i]['html'];
+ $data[$i]['title'] = $all[$i]['title'];
+ $data[$i]['description'] = $all[$i]['description'];
+ $data[$i]['keywords'] = $all[$i]['keywords'];
+ $data[$i]['inhaltstyp'] = $all[$i]['inhaltstyp'];
+ $data[$i]['template'] = $all[$i]['template'];
+ $data[$i]['finalparse'] = $all[$i]['finalparse'];
+ $data[$i]['navigation'] = $all[$i]['navigation'];
+ $data[$i]['sichtbarbis'] = $all[$i]['sichtbarbis'];
+ $data[$i]['datum'] = $all[$i]['datum'];
+ $data[$i]['aktiv'] = $all[$i]['aktiv'];
+ }
- $data = array();
- for ($i = 0; $i < $call; $i++) {
- $data[$i]['sprache'] = $all[$i]['sprache'];
- $data[$i]['inhalt'] = $all[$i]['inhalt'];
- $data[$i]['kurztext'] = $all[$i]['kurztext'];
- $data[$i]['html'] = $all[$i]['html'];
- $data[$i]['title'] = $all[$i]['title'];
- $data[$i]['description'] = $all[$i]['description'];
- $data[$i]['keywords'] = $all[$i]['keywords'];
- $data[$i]['inhaltstyp'] = $all[$i]['inhaltstyp'];
- $data[$i]['template'] = $all[$i]['template'];
- $data[$i]['finalparse'] = $all[$i]['finalparse'];
- $data[$i]['navigation'] = $all[$i]['navigation'];
- $data[$i]['sichtbarbis'] = $all[$i]['sichtbarbis'];
- $data[$i]['datum'] = $all[$i]['datum'];
- $data[$i]['aktiv'] = $all[$i]['aktiv'];
+ return $this->RemoteCommand($shopId, 'inhalt', $data);
}
- return $this->RemoteCommand($shopId, 'inhalt', $data);
- }
+ /**
+ * @param int $shopId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteSendArtikelArtikelgruppen($shopId) {
+ $all = $this->app->DB->SelectArr('SELECT * FROM artikel_artikelgruppe');
+ $call = $all ? count($all) : 0;
+ if ($call > 0) {
+ $data = array();
+ for ($i = 0; $i < $call; $i++) {
+ $data[$i]['id'] = $all[$i]['id'];
+ $data[$i]['artikel'] = $all[$i]['artikel'];
+ $data[$i]['artikelgruppe'] = $all[$i]['artikelgruppe'];
+ $data[$i]['position'] = $all[$i]['position'];
+ }
- /**
- * @param int $shopId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteSendArtikelArtikelgruppen($shopId)
- {
- $all = $this->app->DB->SelectArr('SELECT * FROM artikel_artikelgruppe');
- $call = $all?count($all):0;
- if($call > 0){
- $data = array();
- for ($i = 0; $i < $call; $i++) {
- $data[$i]['id'] = $all[$i]['id'];
- $data[$i]['artikel'] = $all[$i]['artikel'];
- $data[$i]['artikelgruppe'] = $all[$i]['artikelgruppe'];
- $data[$i]['position'] = $all[$i]['position'];
- }
+ return $this->RemoteCommand($shopId, 'artikelartikelgruppen', $data);
+ }
- return $this->RemoteCommand($shopId, 'artikelartikelgruppen', $data);
+ return '';
}
- return '';
- }
-
- /**
- * @param int $shopId
- * @param string $tabelle
- * @param int $intid
- * @param int $intid2
- *
- * @return mixed
- */
- public function GetShopexportMappingExt($shopId, $tabelle, $intid, $intid2 = 0)
- {
- return $this->app->DB->Select("SELECT extid
+ /**
+ * @param int $shopId
+ * @param string $tabelle
+ * @param int $intid
+ * @param int $intid2
+ *
+ * @return mixed
+ */
+ public function GetShopexportMappingExt($shopId, $tabelle, $intid, $intid2 = 0) {
+ return $this->app->DB->Select("SELECT extid
FROM shopexport_mapping
- WHERE shop = '$shopId' AND tabelle = '$tabelle' AND intid = '$intid' ".($intid2?" AND intid2 = '$intid2' ":'')." LIMIT 1");
- }
+ WHERE shop = '$shopId' AND tabelle = '$tabelle' AND intid = '$intid' " . ($intid2 ? " AND intid2 = '$intid2' " : '') . " LIMIT 1");
+ }
- /**
- * @param int $shopId
- * @param string $tabelle
- * @param string $extid
- * @param int $intid2
- *
- * @return mixed
- */
- protected function GetShopexportMappingInt($shopId, $tabelle, $extid, $intid2 = 0)
- {
- return $this->app->DB->Select("SELECT intid
+ /**
+ * @param int $shopId
+ * @param string $tabelle
+ * @param string $extid
+ * @param int $intid2
+ *
+ * @return mixed
+ */
+ protected function GetShopexportMappingInt($shopId, $tabelle, $extid, $intid2 = 0) {
+ return $this->app->DB->Select("SELECT intid
FROM shopexport_mapping
- WHERE shop = '$shopId' AND tabelle = '$tabelle' AND extid = '$extid' ".($intid2?" AND intid2 = '$intid2' ":'')."
+ WHERE shop = '$shopId' AND tabelle = '$tabelle' AND extid = '$extid' " . ($intid2 ? " AND intid2 = '$intid2' " : '') . "
LIMIT 1");
- }
+ }
- /**
- * @param int $shop
- * @param string $tabelle
- * @param int $intid
- * @param string $extid
- * @param int $intid2
- *
- * @return mixed
- */
- public function ShopexportMappingSet($shop, $tabelle, $intid, $extid, $intid2 = 0)
- {
- $check = $this->app->DB->Select("SELECT id FROM shopexport_mapping
+ /**
+ * @param int $shop
+ * @param string $tabelle
+ * @param int $intid
+ * @param string $extid
+ * @param int $intid2
+ *
+ * @return mixed
+ */
+ public function ShopexportMappingSet($shop, $tabelle, $intid, $extid, $intid2 = 0) {
+ $check = $this->app->DB->Select("SELECT id FROM shopexport_mapping
WHERE shop = '$shop' AND tabelle = '$tabelle' AND intid = '$intid' AND intid2 = '$intid2' LIMIT 1");
- if(!$check)
- {
- $this->app->DB->Insert("INSERT INTO shopexport_mapping (shop, tabelle, intid, intid2, extid, zeitstempel)
+ if (!$check) {
+ $this->app->DB->Insert("INSERT INTO shopexport_mapping (shop, tabelle, intid, intid2, extid, zeitstempel)
VALUES ('$shop', '$tabelle', '$intid', '$intid2', '$extid', now())");
- return $this->app->DB->GetInsertID();
- }
- $this->app->DB->Update("UPDATE shopexport_mapping SET extid = '$extid' WHERE id = '$check' LIMIT 1");
+ return $this->app->DB->GetInsertID();
+ }
+ $this->app->DB->Update("UPDATE shopexport_mapping SET extid = '$extid' WHERE id = '$check' LIMIT 1");
- return $check;
- }
+ return $check;
+ }
- /**
- * @param int $id
- * @param string $nummer
- * @param bool $create
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteGetArticle($id,$nummer, $create = false)
- {
- if($create)
- {
- $data['nummerintern'] = $nummer;
- }else {
- $data['nummer'] = $nummer;
- }
- $ret = $this->RemoteCommand($id,'getarticle',$data);
- $variante_von = null;
- //if(!$create)return $ret;
- $_nummer = null;
- $shopexportArr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
- $projekt = $shopexportArr['projekt'];
- $nurneueartikel = $shopexportArr['nurneueartikel'];
- $artikelnummerbeimanlegenausshop = $shopexportArr['artikelnummerbeimanlegenausshop'];
- if(!$create){
- $nurneueartikel = false;
- }
- if(!isset($ret['nummer']) && isset($ret[0]) && isset($ret[0]['nummer']))
- {
- $reta = $ret;
- }elseif(isset($ret['nummer']))
- {
- $reta[] = $ret;
- }elseif(isset($ret[0]) && isset($ret[0]['name'])){
- $ret[0]['nummer'] = '';//$nummer;
- $reta = $ret;
- }elseif(isset($ret['name'])){
- $ret['nummer'] = '';//$nummer;
- $reta[] = $ret;
- }else
- {
- return $ret;
- }
- if(!$reta || !is_array($reta))
- {
- return $ret;
- }
- $stuecklistenmechanik = false;
- $variantevonorig = null;
- $steuersatz_normal = $this->app->erp->Firmendaten('steuersatz_normal');
- $steuersatz_ermaessigt = $this->app->erp->Firmendaten('steuersatz_ermaessigt');
- if(empty($steuersatz_ermaessigt))
- {
- $steuersatz_ermaessigt = 7;
- }
- if(empty($steuersatz_normal))
- {
- $steuersatz_normal = 19;
- }
- $crossellingInstalled = $this->app->erp->ModulVorhanden('crossselling');
- foreach($reta as $k => $ret)
- {
- if(isset($ret['stueckliste'])){
- $stuecklistenmechanik = $ret['stueckliste'];
- }
- $ret['nummer'] = $this->app->DB->real_escape_string(trim($ret['nummer']));
- $articleid = null;
- if($k == 0)
- {
- $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $nummer,true);
- if($articleid)
- {
- $variantevonorig = $this->app->DB->Select("SELECT variante_von
+ /**
+ * @param int $id
+ * @param string $nummer
+ * @param bool $create
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteGetArticle($id, $nummer, $create = false) {
+ if ($create) {
+ $data['nummerintern'] = $nummer;
+ } else {
+ $data['nummer'] = $nummer;
+ }
+ $ret = $this->RemoteCommand($id, 'getarticle', $data);
+ $variante_von = null;
+ //if(!$create)return $ret;
+ $_nummer = null;
+ $shopexportArr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
+ $projekt = $shopexportArr['projekt'];
+ $nurneueartikel = $shopexportArr['nurneueartikel'];
+ $artikelnummerbeimanlegenausshop = $shopexportArr['artikelnummerbeimanlegenausshop'];
+ if (!$create) {
+ $nurneueartikel = false;
+ }
+ if (!isset($ret['nummer']) && isset($ret[0]) && isset($ret[0]['nummer'])) {
+ $reta = $ret;
+ } elseif (isset($ret['nummer'])) {
+ $reta[] = $ret;
+ } elseif (isset($ret[0]) && isset($ret[0]['name'])) {
+ $ret[0]['nummer'] = ''; //$nummer;
+ $reta = $ret;
+ } elseif (isset($ret['name'])) {
+ $ret['nummer'] = ''; //$nummer;
+ $reta[] = $ret;
+ } else {
+ return $ret;
+ }
+ if (!$reta || !is_array($reta)) {
+ return $ret;
+ }
+ $stuecklistenmechanik = false;
+ $variantevonorig = null;
+ $steuersatz_normal = $this->app->erp->Firmendaten('steuersatz_normal');
+ $steuersatz_ermaessigt = $this->app->erp->Firmendaten('steuersatz_ermaessigt');
+ if (empty($steuersatz_ermaessigt)) {
+ $steuersatz_ermaessigt = 7;
+ }
+ if (empty($steuersatz_normal)) {
+ $steuersatz_normal = 19;
+ }
+ $crossellingInstalled = $this->app->erp->ModulVorhanden('crossselling');
+ foreach ($reta as $k => $ret) {
+ if (isset($ret['stueckliste'])) {
+ $stuecklistenmechanik = $ret['stueckliste'];
+ }
+ $ret['nummer'] = $this->app->DB->real_escape_string(trim($ret['nummer']));
+ $articleid = null;
+ if ($k == 0) {
+ $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $nummer, true);
+ if ($articleid) {
+ $variantevonorig = $this->app->DB->Select("SELECT variante_von
FROM artikel
WHERE id = '$articleid' AND variante = 1
LIMIT 1");
- if(!$variantevonorig)
- {
- $articleid = $this->app->DB->Select("SELECT id
+ if (!$variantevonorig) {
+ $articleid = $this->app->DB->Select("SELECT id
FROM artikel
WHERE id = '$articleid' AND ifnull(geloescht,0) = 0 AND nummer <> 'DEL'
LIMIT 1");
- }
- }
- }
- if((isset($ret['nummerintern']) && $ret['nummerintern'] != '') && !$articleid)
- {
- $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['nummerintern']);
- }
- if(($ret['nummer'] != '') && !$articleid)
- {
- $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['nummer']);
- }
- if(($ret['ean'] != '') && !$articleid)
- {
- $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['ean']);
- }
- if($articleid)
- {
- if(isset($ret['shoparticleid']) && $ret['shoparticleid'] != '' && trim($this->app->DB->real_escape_string($ret['shoparticleid'])) != '')
- {
- if(!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE shopid = '$id' AND artikel = '$articleid' AND nummer = '".trim($this->app->DB->real_escape_string($ret['shoparticleid']))."' LIMIT 1"))
- {
- $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, shopid, aktiv, nummer, bezeichnung)
- VALUES ('$articleid','$id','1','".trim($this->app->DB->real_escape_string($ret['shoparticleid']))."','SHOPID')");
- }
- }
- }
- if(!$articleid && !$create)
- {
- continue;
- }
- if(!$articleid || !$nurneueartikel)
- {
- if($articleid)
- {
- $arr['id'] = $articleid;
- $arr['nummer'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
- }elseif($ret['nummer'] == '')
- {
- $arr['nummer'] = $this->app->erp->GetNextArtikelnummer('',1,$shopexportArr['projekt']);
- }
- /*if(isset($ret['nummer']) && $ret['nummer'] == '' && !is_null($variante_von))
- {
- $ret['nummer'] = $_nummer.'-'.$ret['nummer'];
- $arr['nummer'] = $ret['nummer'];
- }*/
- if(isset($ret['stueckliste']) && empty($variante_von)){
- $arr['stueckliste'] = $ret['stueckliste'];
- }
- $arr['projekt'] = $shopexportArr['projekt'];
- $arr['name_de'] = $ret['name'];
- $arr['uebersicht_de'] = $ret['uebersicht_de'] ?? '';
- $arr['kurztext_de'] = $ret['kurztext_de'] ?? '';
- $arr['name_en'] = $ret['name_en'];
- $arr['uebersicht_en'] = $ret['uebersicht_en'] ?? '';
- $arr['kurztext_en'] = $ret['kurztext_en'] ?? '';
- $arr['metakeywords_de'] = $ret['metakeywords_de'] ?? '';
- $arr['metakeywords_en'] = $ret['metakeywords_en'] ?? '';
- $arr['metatitle_de'] = $ret['metatitle_de'] ?? '';
- $arr['metatitle_en'] = $ret['metatitle_en'] ?? '';
- $arr['metadescription_de'] = $ret['metadescription_de'] ?? '';
- $arr['metadescription_en'] = $ret['metadescription_en'] ?? '';
- //$arr['anabregs_text'] = isset($ret['uebersicht_de'])?$ret['uebersicht_de']:'';
- if(isset($ret['ean']) && $ret['ean'] != '')
- {
- $arr['ean'] = $ret['ean'];
- }
- if(isset($ret['gewicht']) && $ret['gewicht'] !== '')
- {
- $arr['gewicht'] = $ret['gewicht'];
- }
- if(isset($ret['laenge']) && $ret['laenge'] !== '')
- {
- $arr['laenge'] = $ret['laenge'];
- }
- if(isset($ret['hoehe']) && $ret['hoehe'] !== '')
- {
- $arr['hoehe'] = $ret['hoehe'];
- }
- if(isset($ret['breite']) && $ret['breite'] !== '')
- {
- $arr['breite'] = $ret['breite'];
- }
-
- if(!$articleid){
- $arr['lagerartikel'] = 1;
- }
- if(true)
- {
- if(!empty($ret['umsatzsteuer'])){
- if(is_numeric($ret['umsatzsteuer'])){
- if($ret['umsatzsteuer'] == $steuersatz_normal)
- {
- $arr['umsatzsteuer'] = 'normal';
- }elseif($ret['umsatzsteuer'] == $steuersatz_ermaessigt)
- {
- $arr['umsatzsteuer'] = 'ermaessigt';
- }
- }elseif(in_array($ret['umsatzsteuer'], array('normal', 'ermaessigt', 'befreit'))){
- $arr['umsatzsteuer'] = $ret['umsatzsteuer'];
+ }
+ }
}
- }
- }
+ if ((isset($ret['nummerintern']) && $ret['nummerintern'] != '') && !$articleid) {
+ $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['nummerintern']);
+ }
+ if (($ret['nummer'] != '') && !$articleid) {
+ $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['nummer']);
+ }
+ if (($ret['ean'] != '') && !$articleid) {
+ $articleid = $this->app->erp->GetArticleIDFromShopnumber($id, $ret['ean']);
+ }
+ if ($articleid) {
+ if (isset($ret['shoparticleid']) && $ret['shoparticleid'] != '' && trim($this->app->DB->real_escape_string($ret['shoparticleid'])) != '') {
+ if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE shopid = '$id' AND artikel = '$articleid' AND nummer = '" . trim($this->app->DB->real_escape_string($ret['shoparticleid'])) . "' LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, shopid, aktiv, nummer, bezeichnung)
+ VALUES ('$articleid','$id','1','" . trim($this->app->DB->real_escape_string($ret['shoparticleid'])) . "','SHOPID')");
+ }
+ }
+ }
+ if (!$articleid && !$create) {
+ continue;
+ }
+ if (!$articleid || !$nurneueartikel) {
+ if ($articleid) {
+ $arr['id'] = $articleid;
+ $arr['nummer'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
+ } elseif ($ret['nummer'] == '') {
+ $arr['nummer'] = $this->app->erp->GetNextArtikelnummer('', 1, $shopexportArr['projekt']);
+ }
+ /* if(isset($ret['nummer']) && $ret['nummer'] == '' && !is_null($variante_von))
+ {
+ $ret['nummer'] = $_nummer.'-'.$ret['nummer'];
+ $arr['nummer'] = $ret['nummer'];
+ } */
+ if (isset($ret['stueckliste']) && empty($variante_von)) {
+ $arr['stueckliste'] = $ret['stueckliste'];
+ }
+ $arr['projekt'] = $shopexportArr['projekt'];
+ $arr['name_de'] = $ret['name'];
+ $arr['uebersicht_de'] = $ret['uebersicht_de'] ?? '';
+ $arr['kurztext_de'] = $ret['kurztext_de'] ?? '';
+ $arr['name_en'] = $ret['name_en'];
+ $arr['uebersicht_en'] = $ret['uebersicht_en'] ?? '';
+ $arr['kurztext_en'] = $ret['kurztext_en'] ?? '';
+ $arr['metakeywords_de'] = $ret['metakeywords_de'] ?? '';
+ $arr['metakeywords_en'] = $ret['metakeywords_en'] ?? '';
+ $arr['metatitle_de'] = $ret['metatitle_de'] ?? '';
+ $arr['metatitle_en'] = $ret['metatitle_en'] ?? '';
+ $arr['metadescription_de'] = $ret['metadescription_de'] ?? '';
+ $arr['metadescription_en'] = $ret['metadescription_en'] ?? '';
+ //$arr['anabregs_text'] = isset($ret['uebersicht_de'])?$ret['uebersicht_de']:'';
+ if (isset($ret['ean']) && $ret['ean'] != '') {
+ $arr['ean'] = $ret['ean'];
+ }
+ if (isset($ret['gewicht']) && $ret['gewicht'] !== '') {
+ $arr['gewicht'] = $ret['gewicht'];
+ }
+ if (isset($ret['laenge']) && $ret['laenge'] !== '') {
+ $arr['laenge'] = $ret['laenge'];
+ }
+ if (isset($ret['hoehe']) && $ret['hoehe'] !== '') {
+ $arr['hoehe'] = $ret['hoehe'];
+ }
+ if (isset($ret['breite']) && $ret['breite'] !== '') {
+ $arr['breite'] = $ret['breite'];
+ }
- $arr['hersteller'] = $ret['hersteller'];
- if(!$stuecklistenmechanik && isset($ret['variante_von']) && !$articleid){
- $variantevon = $this->app->DB->Select("SELECT artikel
+ if (!$articleid) {
+ $arr['lagerartikel'] = 1;
+ }
+ if (true) {
+ if (!empty($ret['umsatzsteuer'])) {
+ if (is_numeric($ret['umsatzsteuer'])) {
+ if ($ret['umsatzsteuer'] == $steuersatz_normal) {
+ $arr['umsatzsteuer'] = 'normal';
+ } elseif ($ret['umsatzsteuer'] == $steuersatz_ermaessigt) {
+ $arr['umsatzsteuer'] = 'ermaessigt';
+ }
+ } elseif (in_array($ret['umsatzsteuer'], array('normal', 'ermaessigt', 'befreit'))) {
+ $arr['umsatzsteuer'] = $ret['umsatzsteuer'];
+ }
+ }
+ }
+
+ $arr['hersteller'] = $ret['hersteller'];
+ if (!$stuecklistenmechanik && isset($ret['variante_von']) && !$articleid) {
+ $variantevon = $this->app->DB->Select("SELECT artikel
FROM `artikelnummer_fremdnummern`
- WHERE shopid = '$id' AND aktiv = 1 AND nummer = '".trim($ret['variante_von'])."' AND nummer <> ''
+ WHERE shopid = '$id' AND aktiv = 1 AND nummer = '" . trim($ret['variante_von']) . "' AND nummer <> ''
LIMIT 1");
- if(empty($variantevon))
- {
- $variantevon = $this->app->DB->Select("SELECT id
+ if (empty($variantevon)) {
+ $variantevon = $this->app->DB->Select("SELECT id
FROM artikel
- WHERE ifnull(geloescht,0) = 0 AND nummer <> 'DEL' AND nummer <> '' AND nummer = '".trim($ret['variante_von'])."'
+ WHERE ifnull(geloescht,0) = 0 AND nummer <> 'DEL' AND nummer <> '' AND nummer = '" . trim($ret['variante_von']) . "'
ORDER BY projekt = '$projekt' DESC
LIMIT 1");
- }
- if(empty($variantevon))
- {
- $variantevon = $variantevonorig;
- }
- if(!empty($variantevon))
- {
- $arr['variante'] = 1;
- $arr['variante_von'] = $variantevon;
- }
- }elseif($variante_von)
- {
- if($variante_von)
- {
- $arr['variante'] = 1;
- }
- if($variante_von)
- {
- $arr['variante_von'] = $variante_von;
- }
- }
- $freifeldmapping = $this->app->DB->SelectArr("SELECT *
+ }
+ if (empty($variantevon)) {
+ $variantevon = $variantevonorig;
+ }
+ if (!empty($variantevon)) {
+ $arr['variante'] = 1;
+ $arr['variante_von'] = $variantevon;
+ }
+ } elseif ($variante_von) {
+ if ($variante_von) {
+ $arr['variante'] = 1;
+ }
+ if ($variante_von) {
+ $arr['variante_von'] = $variante_von;
+ }
+ }
+ $freifeldmapping = $this->app->DB->SelectArr("SELECT *
FROM shopexport_freifelder
WHERE shop = '$id' AND aktiv = 1 AND freifeld_shop <> '' AND freifeld_wawi <> ''");
- if(!empty($freifeldmapping))
- {
- foreach($freifeldmapping as $freifeldval)
- {
- $freifeldShopKey = 'freifeld_'.$freifeldval['freifeld_shop'];
- if(isset($ret[$freifeldShopKey]))
- {
- $arr[$freifeldval['freifeld_wawi']] = $ret[$freifeldShopKey];
- }
- }
- }
- $articleid = $this->app->erp->InsertUpdateArtikel($arr);
- unset($arr);
- if($artikelnummerbeimanlegenausshop && !empty($ret['artikelnummerausshop']))
- {
- $this->app->DB->Update("UPDATE artikel SET nummer = '".$ret['artikelnummerausshop']."' WHERE id = '$articleid'");
- }
-
- $ret['nummer'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
- if(isset($ret['bilder']) && $ret['bilder'] && is_array($ret['bilder']))
- {
- $dateien = $this->app->DB->SelectArr("SELECT * FROM datei_stichwoerter ds INNER JOIN datei_version dv ON ds.datei = dv.datei AND ds.parameter = '$articleid' AND ds.objekt LIKE 'Artikel' ORDER BY ds.sort");
- if(empty($dateien))
- {
- foreach($ret['bilder'] as $v)
- {
- if($v['path'] != '' && $v['content'] != '')
- {
- $path_parts = pathinfo($v['path']);
- $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'){
- $this->app->DB->Update("UPDATE datei_stichwoerter SET subjekt = 'Shopbild' WHERE id = '".$dateien[0]['id']."' AND subjekt = 'shopbild' LIMIT 1");
- }
- }
- if($variante_von === null)
- {
- $variante_von = $articleid;
- $_nummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
- $nummer = isset($ret['nummerintern'])?$ret['nummerintern']:(isset($ret['nummer'])?$ret['nummer']:'');
- }
- if(!empty($ret['preis_netto']) && $ret['preis_netto'] > 0)
- {
- $this->app->erp->AddVerkaufspreis($articleid,1,0,$ret['preis_netto']);
- }
-
- if(!empty($ret['bilder']) && is_array($ret['bilder']))
- {
- $dateien = $this->app->DB->SelectArr("SELECT *
+ if (!empty($freifeldmapping)) {
+ foreach ($freifeldmapping as $freifeldval) {
+ $freifeldShopKey = 'freifeld_' . $freifeldval['freifeld_shop'];
+ if (isset($ret[$freifeldShopKey])) {
+ $arr[$freifeldval['freifeld_wawi']] = $ret[$freifeldShopKey];
+ }
+ }
+ }
+ $articleid = $this->app->erp->InsertUpdateArtikel($arr);
+ unset($arr);
+ if ($artikelnummerbeimanlegenausshop && !empty($ret['artikelnummerausshop'])) {
+ $this->app->DB->Update("UPDATE artikel SET nummer = '" . $ret['artikelnummerausshop'] . "' WHERE id = '$articleid'");
+ }
+
+ $ret['nummer'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
+ if (isset($ret['bilder']) && $ret['bilder'] && is_array($ret['bilder'])) {
+ $dateien = $this->app->DB->SelectArr("SELECT * FROM datei_stichwoerter ds INNER JOIN datei_version dv ON ds.datei = dv.datei AND ds.parameter = '$articleid' AND ds.objekt LIKE 'Artikel' ORDER BY ds.sort");
+ if (empty($dateien)) {
+ foreach ($ret['bilder'] as $v) {
+ if ($v['path'] != '' && $v['content'] != '') {
+ $path_parts = pathinfo($v['path']);
+ $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') {
+ $this->app->DB->Update("UPDATE datei_stichwoerter SET subjekt = 'Shopbild' WHERE id = '" . $dateien[0]['id'] . "' AND subjekt = 'shopbild' LIMIT 1");
+ }
+ }
+ if ($variante_von === null) {
+ $variante_von = $articleid;
+ $_nummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleid' LIMIT 1");
+ $nummer = isset($ret['nummerintern']) ? $ret['nummerintern'] : (isset($ret['nummer']) ? $ret['nummer'] : '');
+ }
+ if (!empty($ret['preis_netto']) && $ret['preis_netto'] > 0) {
+ $this->app->erp->AddVerkaufspreis($articleid, 1, 0, $ret['preis_netto']);
+ }
+
+ if (!empty($ret['bilder']) && is_array($ret['bilder'])) {
+ $dateien = $this->app->DB->SelectArr("SELECT *
FROM datei_stichwoerter ds
INNER JOIN datei_version dv ON ds.datei = dv.datei AND ds.parameter = '$articleid' AND ds.objekt LIKE 'Artikel'
ORDER BY ds.sort");
- if(empty($dateien))
- {
- foreach($ret['bilder'] as $v)
- {
- if($v['path'] != '' && $v['content'] != '')
- {
- $path_parts = pathinfo($v['path']);
- $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);
+ if (empty($dateien)) {
+ foreach ($ret['bilder'] as $v) {
+ if ($v['path'] != '' && $v['content'] != '') {
+ $path_parts = pathinfo($v['path']);
+ $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);
+ }
+ }
+ }
}
- $this->app->erp->AddDateiStichwort($fileid, 'Shopbild', 'artikel', $articleid);
- if (@is_file($tmpfilename))
- unlink($tmpfilename);
- }
- }
- }
- }
- if($crossellingInstalled){
- if(!empty($ret['crossselling'])){
- if(!empty($ret['crossselling']['similar'])){
- foreach ($ret['crossselling']['similar'] as $cskey => $csvalue) {
- $crosssellingartikel = $this->app->DB->Select("SELECT id from artikel WHERE nummer= '".$csvalue."' and geloescht='0'");
- if($crosssellingartikel){
- if(!$this->app->DB->Select("SELECT id FROM crossselling_artikel WHERE artikel='$articleid' AND crosssellingartikel='$crosssellingartikel' AND shop='$id'")){
- $sort = $this->app->DB->Select("SELECT MAX(sort)+1 from crossselling_artikel WHERE artikel='$articleid' AND shop='$id'");
- $this->app->DB->Insert("INSERT INTO crossselling_artikel (aktiv, art, artikel, crosssellingartikel, shop, sort, bemerkung) VALUES ('1','1','$articleid','$crosssellingartikel','$id','$sort','Über Artikelimport hinzugefügt')");
- }
+ if ($crossellingInstalled) {
+ if (!empty($ret['crossselling'])) {
+ if (!empty($ret['crossselling']['similar'])) {
+ foreach ($ret['crossselling']['similar'] as $cskey => $csvalue) {
+ $crosssellingartikel = $this->app->DB->Select("SELECT id from artikel WHERE nummer= '" . $csvalue . "' and geloescht='0'");
+ if ($crosssellingartikel) {
+ if (!$this->app->DB->Select("SELECT id FROM crossselling_artikel WHERE artikel='$articleid' AND crosssellingartikel='$crosssellingartikel' AND shop='$id'")) {
+ $sort = $this->app->DB->Select("SELECT MAX(sort)+1 from crossselling_artikel WHERE artikel='$articleid' AND shop='$id'");
+ $this->app->DB->Insert("INSERT INTO crossselling_artikel (aktiv, art, artikel, crosssellingartikel, shop, sort, bemerkung) VALUES ('1','1','$articleid','$crosssellingartikel','$id','$sort','Über Artikelimport hinzugefügt')");
+ }
+ }
+ }
+ }
+ if (!empty($ret['crossselling']['related'])) {
+ foreach ($ret['crossselling']['related'] as $cskey => $csvalue) {
+ $crosssellingartikel = $this->app->DB->Select("SELECT id from artikel WHERE nummer= '" . $csvalue . "' and geloescht='0'");
+ if ($crosssellingartikel) {
+ if (!$this->app->DB->Select("SELECT id FROM crossselling_artikel WHERE artikel='$articleid' AND crosssellingartikel='$crosssellingartikel' AND shop='$id'")) {
+ $sort = $this->app->DB->Select("SELECT MAX(sort)+1 from crossselling_artikel WHERE artikel='$articleid' AND shop='$id'");
+ $this->app->DB->Insert("INSERT INTO crossselling_artikel (aktiv, art, artikel, crosssellingartikel, shop, sort, bemerkung) VALUES ('1','2','$articleid','$crosssellingartikel','$id','$sort','Über Artikelimport hinzugefügt')");
+ }
+ }
+ }
+ }
+ }
}
- }
- }
- if(!empty($ret['crossselling']['related'])){
- foreach ($ret['crossselling']['related'] as $cskey => $csvalue) {
- $crosssellingartikel = $this->app->DB->Select("SELECT id from artikel WHERE nummer= '".$csvalue."' and geloescht='0'");
- if($crosssellingartikel){
- if(!$this->app->DB->Select("SELECT id FROM crossselling_artikel WHERE artikel='$articleid' AND crosssellingartikel='$crosssellingartikel' AND shop='$id'")){
- $sort = $this->app->DB->Select("SELECT MAX(sort)+1 from crossselling_artikel WHERE artikel='$articleid' AND shop='$id'");
- $this->app->DB->Insert("INSERT INTO crossselling_artikel (aktiv, art, artikel, crosssellingartikel, shop, sort, bemerkung) VALUES ('1','2','$articleid','$crosssellingartikel','$id','$sort','Über Artikelimport hinzugefügt')");
- }
- }
- }
- }
- }
- }
- $katext = 0;
- if(isset($ret['kategorien_all']) && $ret['kategorien_all'])
- {
- foreach($ret['kategorien_all'] as $v)
- {
- if($katext == 0 && $v['parent'] == 0)
- {
- $katext = $v['id'];
- }
- if(!$this->app->DB->Select("SELECT id
+ $katext = 0;
+ if (isset($ret['kategorien_all']) && $ret['kategorien_all']) {
+ foreach ($ret['kategorien_all'] as $v) {
+ if ($katext == 0 && $v['parent'] == 0) {
+ $katext = $v['id'];
+ }
+ if (!$this->app->DB->Select("SELECT id
FROM shopexport_kategorien
- WHERE shop = '$id' AND extid = '".$this->app->DB->real_escape_string($v['id'])."' LIMIT 1")){
- $this->app->DB->Insert("INSERT INTO shopexport_kategorien (shop, extid, aktiv,extname,extparent,extsort) VALUES
- ('$id','" . $this->app->DB->real_escape_string($v['id']) . "','" . (int)$v['aktiv'] . "','" . $this->app->DB->real_escape_string($v['name']) . "','" . $this->app->DB->real_escape_string($v['parent']) . "','" . (int)$v['sort'] . "')");
- }
- }
- $shopkategorien = $this->getShopKatgeorien($id);
- /** @var Onlineshops $onlineShopObj */
- $onlineShopObj = $this->app->loadModule('onlineshops');
- $categoryRootId = 0;
- if(!empty($onlineShopObj) && method_exists($onlineShopObj, 'getJsonSettings')) {
- $categoryRootId = (int)$onlineShopObj->getJsonSettings($id, 'category_root_id');
- }
- $kategorientoint = [$categoryRootId];
+ WHERE shop = '$id' AND extid = '" . $this->app->DB->real_escape_string($v['id']) . "' LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO shopexport_kategorien (shop, extid, aktiv,extname,extparent,extsort) VALUES
+ ('$id','" . $this->app->DB->real_escape_string($v['id']) . "','" . (int) $v['aktiv'] . "','" . $this->app->DB->real_escape_string($v['name']) . "','" . $this->app->DB->real_escape_string($v['parent']) . "','" . (int) $v['sort'] . "')");
+ }
+ }
+ $shopkategorien = $this->getShopKatgeorien($id);
+ /** @var Onlineshops $onlineShopObj */
+ $onlineShopObj = $this->app->loadModule('onlineshops');
+ $categoryRootId = 0;
+ if (!empty($onlineShopObj) && method_exists($onlineShopObj, 'getJsonSettings')) {
+ $categoryRootId = (int) $onlineShopObj->getJsonSettings($id, 'category_root_id');
+ }
+ $kategorientoint = [$categoryRootId];
- if(!empty($shopkategorien))
- {
- foreach($shopkategorien as $v)
- {
- if(!$v['kategorie'])
- {
- $parentInXentral = $kategorientoint[$v['extparent']];
- if(empty($parentInXentral)){
- $parentInXentral = $this->app->DB->Select("SELECT kategorie FROM shopexport_kategorien WHERE shop='$id' AND extid='".$v['extparent']."' LIMIT 1");
+ if (!empty($shopkategorien)) {
+ foreach ($shopkategorien as $v) {
+ if (!$v['kategorie']) {
+ $parentInXentral = $kategorientoint[$v['extparent']];
+ if (empty($parentInXentral)) {
+ $parentInXentral = $this->app->DB->Select("SELECT kategorie FROM shopexport_kategorien WHERE shop='$id' AND extid='" . $v['extparent'] . "' LIMIT 1");
+ }
+ $this->app->DB->Insert("INSERT INTO `artikelkategorien` (bezeichnung,parent)
+ VALUES ('" . $this->app->DB->real_escape_string($v['extname']) . "','$parentInXentral')");
+ $kategorientoint[$v['extid']] = $this->app->DB->GetInsertID();
+ $this->app->DB->Update("UPDATE shopexport_kategorien
+ SET kategorie = '" . $kategorientoint[$v['extid']] . "'
+ WHERE id = '" . $v['id'] . "' LIMIT 1");
+ $v['kategorie'] = $kategorientoint[$v['extid']];
+ }
+ }
+ }
}
- $this->app->DB->Insert("INSERT INTO `artikelkategorien` (bezeichnung,parent)
- VALUES ('".$this->app->DB->real_escape_string($v['extname'])."','$parentInXentral')");
- $kategorientoint[$v['extid']] = $this->app->DB->GetInsertID();
- $this->app->DB->Update("UPDATE shopexport_kategorien
- SET kategorie = '".$kategorientoint[$v['extid']]."'
- WHERE id = '".$v['id']."' LIMIT 1");
- $v['kategorie'] = $kategorientoint[$v['extid']];
- }
- }
- }
- }
- if(!empty($ret['kategorien']))
- {
- $shopkategorien = $this->app->DB->SelectArr("SELECT *
+ if (!empty($ret['kategorien'])) {
+ $shopkategorien = $this->app->DB->SelectArr("SELECT *
FROM shopexport_kategorien
WHERE shop = '$id' AND kategorie > 0
ORDER BY extparent, extsort");
- if(!empty($shopkategorien))
- {
- foreach($shopkategorien as $v)
- {
- $kategorientoint[$v['extid']] = $v['kategorie'];
- }
- $kategoriezugewiesen = false;
- foreach($ret['kategorien'] as $v)
- {
- if(!$kategoriezugewiesen){
- $kategorieid = $this->app->DB->Select("SELECT id FROM artikelkategorien WHERE bezeichnung='".$v['name']."' AND parent=0 AND geloescht=0 LIMIT 1");
- if($kategorieid){
- $this->app->DB->Update("UPDATE artikel SET typ = '".$kategorieid."_kat' WHERE id = '$articleid' LIMIT 1");
- $kategoriezugewiesen = true;
- }
- }
+ if (!empty($shopkategorien)) {
+ foreach ($shopkategorien as $v) {
+ $kategorientoint[$v['extid']] = $v['kategorie'];
+ }
+ $kategoriezugewiesen = false;
+ foreach ($ret['kategorien'] as $v) {
+ if (!$kategoriezugewiesen) {
+ $kategorieid = $this->app->DB->Select("SELECT id FROM artikelkategorien WHERE bezeichnung='" . $v['name'] . "' AND parent=0 AND geloescht=0 LIMIT 1");
+ if ($kategorieid) {
+ $this->app->DB->Update("UPDATE artikel SET typ = '" . $kategorieid . "_kat' WHERE id = '$articleid' LIMIT 1");
+ $kategoriezugewiesen = true;
+ }
+ }
- if(isset($kategorientoint[$v['id']]) && $kategorientoint[$v['id']])
- {
- if(!$this->app->DB->Select("SELECT id FROM artikelbaum_artikel WHERE artikel = '$articleid' AND kategorie = '".$kategorientoint[$v['id']]."' LIMIT 1"))
- {
- $this->app->DB->Insert("INSERT INTO artikelbaum_artikel (artikel, kategorie)
- VALUES ('$articleid', '".$kategorientoint[$v['id']]."')");
+ if (isset($kategorientoint[$v['id']]) && $kategorientoint[$v['id']]) {
+ if (!$this->app->DB->Select("SELECT id FROM artikelbaum_artikel WHERE artikel = '$articleid' AND kategorie = '" . $kategorientoint[$v['id']] . "' LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO artikelbaum_artikel (artikel, kategorie)
+ VALUES ('$articleid', '" . $kategorientoint[$v['id']] . "')");
+ }
+ }
+ }
+ }
}
- }
- }
- }
- }
- if(!empty($ret['eigenschaften']))
- {
- foreach($ret['eigenschaften'] as $v)
- {
- if($v['name'] != '')
- {
- $eigenschaft = $this->app->DB->Select("SELECT id
+ if (!empty($ret['eigenschaften'])) {
+ foreach ($ret['eigenschaften'] as $v) {
+ if ($v['name'] != '') {
+ $eigenschaft = $this->app->DB->Select("SELECT id
FROM `artikeleigenschaften`
- WHERE name = '".$this->app->DB->real_escape_string($v['name'])."' AND geloescht = 0
+ WHERE name = '" . $this->app->DB->real_escape_string($v['name']) . "' AND geloescht = 0
LIMIT 1");
- if(!$eigenschaft)
- {
- $this->app->DB->Insert("INSERT INTO `artikeleigenschaften` (name)
- VALUES ('".$this->app->DB->real_escape_string($v['name'])."')");
- $eigenschaft = $this->app->DB->GetInsertID();
- }
- if($eigenschaft)
- {
- $wert = $this->app->DB->Select("SELECT id
+ if (!$eigenschaft) {
+ $this->app->DB->Insert("INSERT INTO `artikeleigenschaften` (name)
+ VALUES ('" . $this->app->DB->real_escape_string($v['name']) . "')");
+ $eigenschaft = $this->app->DB->GetInsertID();
+ }
+ if ($eigenschaft) {
+ $wert = $this->app->DB->Select("SELECT id
FROM artikeleigenschaftenwerte
- WHERE artikel = '$articleid' AND artikeleigenschaften = '$eigenschaft' AND wert = '".$this->app->DB->real_escape_string($v['values'])."'
+ WHERE artikel = '$articleid' AND artikeleigenschaften = '$eigenschaft' AND wert = '" . $this->app->DB->real_escape_string($v['values']) . "'
LIMIT 1");
- if(!$wert)
- {
- $this->app->DB->Insert("INSERT INTO artikeleigenschaftenwerte (artikel,artikeleigenschaften,wert)
- VALUES ('$articleid','$eigenschaft','".$this->app->DB->real_escape_string($v['values'])."')");
+ if (!$wert) {
+ $this->app->DB->Insert("INSERT INTO artikeleigenschaftenwerte (artikel,artikeleigenschaften,wert)
+ VALUES ('$articleid','$eigenschaft','" . $this->app->DB->real_escape_string($v['values']) . "')");
+ }
+ }
+ }
+ }
}
- }
- }
- }
- }
- if(!empty($ret['matrixprodukt_gruppe1'])){
- $query = sprintf("UPDATE artikel SET matrixprodukt=1 WHERE id='%s'",$articleid);
- $this->app->DB->Update($query);
- for($m=1;$m<=3;$m++){
- if(empty($ret['matrixprodukt_gruppe'.$m])){
- continue;
- }
+ if (!empty($ret['matrixprodukt_gruppe1'])) {
+ $query = sprintf("UPDATE artikel SET matrixprodukt=1 WHERE id='%s'", $articleid);
+ $this->app->DB->Update($query);
+ for ($m = 1; $m <= 3; $m++) {
+ if (empty($ret['matrixprodukt_gruppe' . $m])) {
+ continue;
+ }
- $gruppeName = $this->app->DB->real_escape_string($ret['matrixprodukt_gruppe'.$m]);
- $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftengruppen_artikel WHERE artikel='%s' AND name='%s'",
- $articleid, $gruppeName);
- $gruppeId = $this->app->DB->Select($query);
- if(empty($gruppeId)){
- $query = sprintf("SELECT MAX(sort) FROM matrixprodukt_eigenschaftengruppen_artikel WHERE artikel='%s' AND name='%s'",
- $articleid, $gruppeName);
- $sort = $this->app->DB->Select($query);
- if(empty($sort)){
- $sort = '0';
- }
- $query = sprintf("INSERT INTO matrixprodukt_eigenschaftengruppen_artikel
+ $gruppeName = $this->app->DB->real_escape_string($ret['matrixprodukt_gruppe' . $m]);
+ $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftengruppen_artikel WHERE artikel='%s' AND name='%s'",
+ $articleid, $gruppeName);
+ $gruppeId = $this->app->DB->Select($query);
+ if (empty($gruppeId)) {
+ $query = sprintf("SELECT MAX(sort) FROM matrixprodukt_eigenschaftengruppen_artikel WHERE artikel='%s' AND name='%s'",
+ $articleid, $gruppeName);
+ $sort = $this->app->DB->Select($query);
+ if (empty($sort)) {
+ $sort = '0';
+ }
+ $query = sprintf("INSERT INTO matrixprodukt_eigenschaftengruppen_artikel
(artikel, aktiv, name, name_ext,projekt,bearbeiter,erstellt,sort, pflicht, oeffentlich,typ) VALUES
('%s','1','%s','','0','','NOW()','%s','1','0','0')", $articleid, $gruppeName, $sort);
- $this->app->DB->Insert($query);
- $gruppeId = $this->app->DB->GetInsertID();
- }
+ $this->app->DB->Insert($query);
+ $gruppeId = $this->app->DB->GetInsertID();
+ }
- foreach ($ret['matrixprodukt_optionen'.$m] as $optionBezeichnung){
- $optionBezeichnung = $this->app->DB->real_escape_string($optionBezeichnung);
- $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
- $articleid, $optionBezeichnung);
- $optionId = $this->app->DB->Select($query);
- if(empty($optionId)){
- $query = sprintf("SELECT MAX(sort) FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
- $articleid, $optionBezeichnung);
- $sort = $this->app->DB->Select($query);
- if(empty($sort)){
- $sort = '1';
- }
- $query = sprintf("INSERT INTO matrixprodukt_eigenschaftenoptionen_artikel
+ foreach ($ret['matrixprodukt_optionen' . $m] as $optionBezeichnung) {
+ $optionBezeichnung = $this->app->DB->real_escape_string($optionBezeichnung);
+ $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
+ $articleid, $optionBezeichnung);
+ $optionId = $this->app->DB->Select($query);
+ if (empty($optionId)) {
+ $query = sprintf("SELECT MAX(sort) FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
+ $articleid, $optionBezeichnung);
+ $sort = $this->app->DB->Select($query);
+ if (empty($sort)) {
+ $sort = '1';
+ }
+ $query = sprintf("INSERT INTO matrixprodukt_eigenschaftenoptionen_artikel
(artikel, matrixprodukt_eigenschaftenoptionen, aktiv,name,name_ext,sort,erstellt,gruppe,bearbeiter,artikelnummer)
VALUES ('%s','0','1','%s','','%s','NOW()','%s','','')",
- $articleid, $optionBezeichnung, $sort, $gruppeId);
- $this->app->DB->Insert($query);
- }
- }
- }
- }
+ $articleid, $optionBezeichnung, $sort, $gruppeId);
+ $this->app->DB->Insert($query);
+ }
+ }
+ }
+ }
- if(!empty($ret['matrixprodukt_wert1'])){
- for($m=1;$m<=3;$m++){
- if(empty($ret['matrixprodukt_wert'.$m])){
- continue;
+ if (!empty($ret['matrixprodukt_wert1'])) {
+ for ($m = 1; $m <= 3; $m++) {
+ if (empty($ret['matrixprodukt_wert' . $m])) {
+ continue;
+ }
+
+ $optionBezeichnung = $this->app->DB->real_escape_string($ret['matrixprodukt_wert' . $m]);
+ $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
+ $variante_von, $optionBezeichnung);
+ $optionId = $this->app->DB->Select($query);
+ if (!empty($optionId)) {
+ $query = sprintf("SELECT id FROM matrixprodukt_optionen_zu_artikel WHERE artikel='%s' AND option_id='%s'",
+ $articleid, $optionId);
+ $zuordnungId = $this->app->DB->Select($query);
+ if (empty($zuordnungId)) {
+ $query = sprintf("INSERT INTO matrixprodukt_optionen_zu_artikel (artikel,option_id) VALUES ('%s','%s')",
+ $articleid, $optionId);
+ $this->app->DB->Insert($query);
+ }
+ }
+ }
+ }
+
+ if (!$this->app->DB->Select("SELECT id FROM `artikel_onlineshops` WHERE artikel = '$articleid' AND shop = '$id' AND aktiv = 1 LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO `artikel_onlineshops` (artikel, shop,aktiv, ausartikel) VALUES ('$articleid', '$id',1 ,1)");
+ }
+ if (isset($ret['nummerintern']) && trim($ret['nummerintern']) != '') {
+ $data['nummerintern'] = trim($ret['nummerintern']);
+ }
+ if (($ret['nummer'] != $data['nummerintern']) && $data['nummerintern'] != '' && trim($data['nummerintern']) != '') {
+ $data['nummerintern'] = trim($data['nummerintern']);
+ if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$articleid' AND shopid = '$id' AND nummer = '" . $this->app->DB->real_escape_string($data['nummerintern']) . "' AND nummer <> '' LIMIT 1")) {
+ $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, shopid, aktiv, bearbeiter, zeitstempel,nummer) VALUES ('$articleid','$id','1','Cronjob',now(),'" . $this->app->DB->real_escape_string($data['nummerintern']) . "')");
+ }
+ }
+ } elseif ($articleid) {
+ if (isset($ret['ean']) && ($ret['ean'] != '') && $this->app->DB->Select("SELECT id FROM artikel WHERE id = '$articleid' AND ifnull(ean,'') = '' LIMIT 1")) {
+ $this->app->DB->Update("UPDATE artikel SET ean = '" . $this->app->DB->real_escape_string($ret['ean']) . "' WHERE id = '$articleid' AND ifnull(ean,'') = '' LIMIT 1");
+ }
}
- $optionBezeichnung = $this->app->DB->real_escape_string($ret['matrixprodukt_wert'.$m]);
- $query = sprintf("SELECT id FROM matrixprodukt_eigenschaftenoptionen_artikel WHERE artikel='%s' AND name='%s'",
- $variante_von, $optionBezeichnung);
- $optionId = $this->app->DB->Select($query);
- if(!empty($optionId)){
- $query = sprintf("SELECT id FROM matrixprodukt_optionen_zu_artikel WHERE artikel='%s' AND option_id='%s'",
- $articleid, $optionId);
- $zuordnungId = $this->app->DB->Select($query);
- if(empty($zuordnungId)){
- $query = sprintf("INSERT INTO matrixprodukt_optionen_zu_artikel (artikel,option_id) VALUES ('%s','%s')",
- $articleid,$optionId);
- $this->app->DB->Insert($query);
- }
- }
- }
- }
-
- if(!$this->app->DB->Select("SELECT id FROM `artikel_onlineshops` WHERE artikel = '$articleid' AND shop = '$id' AND aktiv = 1 LIMIT 1")) {
- $this->app->DB->Insert("INSERT INTO `artikel_onlineshops` (artikel, shop,aktiv, ausartikel) VALUES ('$articleid', '$id',1 ,1)");
- }
- if(isset($ret['nummerintern']) && trim($ret['nummerintern']) != '')
- {
- $data['nummerintern'] = trim($ret['nummerintern']);
- }
- if(($ret['nummer'] != $data['nummerintern']) && $data['nummerintern'] != '' && trim($data['nummerintern']) != '')
- {
- $data['nummerintern'] = trim($data['nummerintern']);
- if(!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$articleid' AND shopid = '$id' AND nummer = '".$this->app->DB->real_escape_string($data['nummerintern'])."' AND nummer <> '' LIMIT 1"))
- {
- $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, shopid, aktiv, bearbeiter, zeitstempel,nummer) VALUES ('$articleid','$id','1','Cronjob',now(),'".$this->app->DB->real_escape_string($data['nummerintern'])."')");
- }
- }
- }elseif($articleid)
- {
- if(isset($ret['ean']) && ($ret['ean'] != '') && $this->app->DB->Select("SELECT id FROM artikel WHERE id = '$articleid' AND ifnull(ean,'') = '' LIMIT 1"))
- {
- $this->app->DB->Update("UPDATE artikel SET ean = '".$this->app->DB->real_escape_string($ret['ean'])."' WHERE id = '$articleid' AND ifnull(ean,'') = '' LIMIT 1");
- }
- }
-
- if($stuecklistenmechanik && !empty($variante_von) && !$this->app->erp->IstStuecklistenZirkel($articleid,$variante_von)){
- $stuecklistenmenge = 1;
- if(!empty($ret['stuecklistemenge'])){
- $stuecklistenmenge = $ret['stuecklistemenge'];
- }
- $query = sprintf('SELECT MAX(sort) FROM stueckliste WHERE stuecklistevonartikel=%d',$variante_von);
- $sort = $this->app->DB->Select($query);
- if($sort !== NULL){
- $sort++;
- }else{
- $sort = 0;
- }
- $query = sprintf("INSERT INTO stueckliste (sort, artikel, referenz, place, layer, stuecklistevonartikel,
+ if ($stuecklistenmechanik && !empty($variante_von) && !$this->app->erp->IstStuecklistenZirkel($articleid, $variante_von)) {
+ $stuecklistenmenge = 1;
+ if (!empty($ret['stuecklistemenge'])) {
+ $stuecklistenmenge = $ret['stuecklistemenge'];
+ }
+ $query = sprintf('SELECT MAX(sort) FROM stueckliste WHERE stuecklistevonartikel=%d', $variante_von);
+ $sort = $this->app->DB->Select($query);
+ if ($sort !== NULL) {
+ $sort++;
+ } else {
+ $sort = 0;
+ }
+ $query = sprintf("INSERT INTO stueckliste (sort, artikel, referenz, place, layer, stuecklistevonartikel,
menge, firma, wert, bauform, alternative, zachse, xpos, ypos, art)
VALUES (%d, %d, '', 'DP', 'Top', %d, %d, 1, '', '', 0, '', '', '', 'et')",
- $sort,$articleid,$variante_von,$stuecklistenmenge);
- $this->app->DB->Insert($query);
- }
-
- if($variante_von === null) {
- if(!empty($articleid) && $stuecklistenmechanik){
- $query = sprintf('DELETE FROM stueckliste WHERE stuecklistevonartikel=%d',$articleid);
- $this->app->DB->Delete($query);
- }
- $variante_von = $articleid;
- }
-
- if(isset($ret['inaktiv'])){
- $ret['aktiv'] = !$ret['inaktiv'];
- }
-
- if(isset($ret['aktiv']))
- {
- if($ret['aktiv']){
- $this->app->DB->Update("UPDATE artikel SET inaktiv = '0' WHERE id = '$articleid' LIMIT 1");
- }else{
- $this->app->DB->Update("UPDATE artikel SET inaktiv = '1' WHERE id = '$articleid' LIMIT 1");
- }
- }
- if(isset($ret['staffelpreise'])){
- $date = new DateTime();
- $date->sub(new DateInterval('P1D'));
- $gestern = $date->format('Y-m-d');
- $this->app->DB->Update("UPDATE verkaufspreise SET gueltig_bis='$gestern' WHERE artikel='$articleid' AND adresse='0' AND art='Kunde'");
-
- foreach ($ret['staffelpreise'] as $staffelpreis){
- $preis = $staffelpreis['preis'];
- if($staffelpreis['brutto']){
- $umsatzsteuer = $this->app->DB->Select("SELECT umsatzsteuer FROM artikel WHERE id='$articleid' LIMIT 1");
- $steuersatz = 0;
- if($umsatzsteuer === 'ermaessigt')
- {
- $steuersatz = $this->app->erp->Firmendaten('steuersatz_ermaessigt');
+ $sort, $articleid, $variante_von, $stuecklistenmenge);
+ $this->app->DB->Insert($query);
}
- if($umsatzsteuer === 'normal'){
- $steuersatz = $this->app->erp->Firmendaten('steuersatz_normal');
- }
- $preis /= 1+$steuersatz/100;
- }
- $this->app->erp->AddVerkaufspreis($articleid,$staffelpreis['ab_menge'],0,$preis);
- }
- }
- if(isset($ret['fremdnummern']) && !empty($ret['fremdnummern'])){
- foreach ($ret['fremdnummern'] as $fremdnummer){
- $query = sprintf("SELECT id FROM artikelnummer_fremdnummern WHERE shopid=%d AND nummer='%s' AND bezeichnung='%s' AND aktiv=%d AND artikel=%s",
- $id,$this->app->DB->real_escape_string($fremdnummer['nummer']),$this->app->DB->real_escape_string($fremdnummer['bezeichnung']),'1',$articleid);
- $fremdnummerfehlt = empty($this->app->DB->Select($query));
- if($fremdnummerfehlt){
- $query = sprintf("INSERT INTO artikelnummer_fremdnummern
+ if ($variante_von === null) {
+ if (!empty($articleid) && $stuecklistenmechanik) {
+ $query = sprintf('DELETE FROM stueckliste WHERE stuecklistevonartikel=%d', $articleid);
+ $this->app->DB->Delete($query);
+ }
+ $variante_von = $articleid;
+ }
+
+ if (isset($ret['inaktiv'])) {
+ $ret['aktiv'] = !$ret['inaktiv'];
+ }
+
+ if (isset($ret['aktiv'])) {
+ if ($ret['aktiv']) {
+ $this->app->DB->Update("UPDATE artikel SET inaktiv = '0' WHERE id = '$articleid' LIMIT 1");
+ } else {
+ $this->app->DB->Update("UPDATE artikel SET inaktiv = '1' WHERE id = '$articleid' LIMIT 1");
+ }
+ }
+ if (isset($ret['staffelpreise'])) {
+ $date = new DateTime();
+ $date->sub(new DateInterval('P1D'));
+ $gestern = $date->format('Y-m-d');
+ $this->app->DB->Update("UPDATE verkaufspreise SET gueltig_bis='$gestern' WHERE artikel='$articleid' AND adresse='0' AND art='Kunde'");
+
+ foreach ($ret['staffelpreise'] as $staffelpreis) {
+ $preis = $staffelpreis['preis'];
+ if ($staffelpreis['brutto']) {
+ $umsatzsteuer = $this->app->DB->Select("SELECT umsatzsteuer FROM artikel WHERE id='$articleid' LIMIT 1");
+ $steuersatz = 0;
+ if ($umsatzsteuer === 'ermaessigt') {
+ $steuersatz = $this->app->erp->Firmendaten('steuersatz_ermaessigt');
+ }
+ if ($umsatzsteuer === 'normal') {
+ $steuersatz = $this->app->erp->Firmendaten('steuersatz_normal');
+ }
+ $preis /= 1 + $steuersatz / 100;
+ }
+ $this->app->erp->AddVerkaufspreis($articleid, $staffelpreis['ab_menge'], 0, $preis);
+ }
+ }
+ if (isset($ret['fremdnummern']) && !empty($ret['fremdnummern'])) {
+ foreach ($ret['fremdnummern'] as $fremdnummer) {
+ $query = sprintf("SELECT id FROM artikelnummer_fremdnummern WHERE shopid=%d AND nummer='%s' AND bezeichnung='%s' AND aktiv=%d AND artikel=%s",
+ $id, $this->app->DB->real_escape_string($fremdnummer['nummer']), $this->app->DB->real_escape_string($fremdnummer['bezeichnung']), '1', $articleid);
+ $fremdnummerfehlt = empty($this->app->DB->Select($query));
+
+ if ($fremdnummerfehlt) {
+ $query = sprintf("INSERT INTO artikelnummer_fremdnummern
(artikel, bezeichnung, nummer, shopid, bearbeiter, aktiv) VALUES
(%d,'%s','%s',%d,'%s',%d)",
- $articleid,$this->app->DB->real_escape_string($fremdnummer['bezeichnung']),
- $this->app->DB->real_escape_string($fremdnummer['nummer']),$id,$this->app->User->GetName(),1);
- $this->app->DB->Insert($query);
- }
- }
- }
+ $articleid, $this->app->DB->real_escape_string($fremdnummer['bezeichnung']),
+ $this->app->DB->real_escape_string($fremdnummer['nummer']), $id, $this->app->User->GetName(), 1);
+ $this->app->DB->Insert($query);
+ }
+ }
+ }
+
+ if (isset($ret['pseudopreis'])) {
+ $this->app->DB->Update(sprintf("UPDATE artikel SET pseudopreis='%s' WHERE id=%d", $ret['pseudopreis'], $articleid));
+ }
+ if (!$create) {
+ return $ret;
+ }
+ }
- if(isset($ret['pseudopreis'])){
- $this->app->DB->Update(sprintf("UPDATE artikel SET pseudopreis='%s' WHERE id=%d",$ret['pseudopreis'],$articleid));
- }
- if(!$create)
- {
return $ret;
- }
}
- return $ret;
- }
-
- /**
- * @param int $shopId
- * @param int $parent
- * @param int $lvl
- *
- * @return array
- */
- protected function getShopKatgeorien($shopId, $parent = 0, $lvl = 0)
- {
- if($lvl > 20)
- {
- return [];
- }
- $ret = [];
- $shopkategorien = $this->app->DB->SelectArr("SELECT * FROM shopexport_kategorien WHERE shop = '$shopId' AND extparent = '$parent' AND extid <> '' ORDER BY extsort");
- if($shopkategorien)
- {
- foreach($shopkategorien as $v)
- {
- $ret[] = $v;
- $subkategorien = $this->getShopKatgeorien($shopId, $v['extid'], $lvl + 1);
- if(!empty($subkategorien))
- {
- foreach($subkategorien as $v2)
- {
- $ret[] = $v2;
- }
+ /**
+ * @param int $shopId
+ * @param int $parent
+ * @param int $lvl
+ *
+ * @return array
+ */
+ protected function getShopKatgeorien($shopId, $parent = 0, $lvl = 0) {
+ if ($lvl > 20) {
+ return [];
}
- }
- }
-
- return $ret;
- }
-
- /**
- * @param int $id
- * @param array $artikel_arr
- * @param string|array $extnummer
- * @param bool $nurlager
- *
- * @return mixed|null
- * @throws Exception
- */
- public function RemoteSendArticleList($id,$artikel_arr, $extnummer = '', $nurlager = false)
- {
- if(!class_exists('ObjGenArtikel') &&
- is_file(dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php')){
- include_once dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php';
- }
- $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
- $artikelexport = $shopexportarr['artikelexport'];
-
- $loadElements = [
- 'foreign_numbers' => true,
- 'article_descriptions' => true,
- 'translations' => true,
- 'categories' => true,
- 'properties' => true,
- 'pictures' => true,
- 'cross_selling' => true,
- 'bulk_prices' => true,
- 'standard_price' => true,
- 'variants' => true,
- 'free_fields' => true,
- ];
-
- if(
- ($nurlager || empty($artikelexport))
- && !empty($shopexportarr['modulename'])
- && !is_file(dirname(__DIR__).'/pages/'.$shopexportarr['modulename'].'_custom.php')
- ) {
- $elementsNotNeededByModule = ShopimporterBase::storageNotNeededElements($shopexportarr['modulename']);
- foreach($elementsNotNeededByModule as $element) {
- $loadElements[$element] = false;
- }
- }
-
- //$lagerexport = $shopexportarr['lagerexport'];
- $lagergrundlage = $shopexportarr['lagergrundlage'];
- $shopbilderuebertragen = $shopexportarr['shopbilderuebertragen'];
- $projekt = (int)$shopexportarr['projekt'];
- $projektlager = $this->app->DB->Select("SELECT id FROM projekt WHERE id = $projekt AND projektlager = 1 LIMIT 1");
- $tmp = new ObjGenArtikel($this->app);
- $cartikel_arr = !empty($artikel_arr)?count($artikel_arr):0;
-
- for($i=0;$i<$cartikel_arr;$i++)
- {
-
- $artikel = $artikel_arr[$i];
- $lagerexport = $this->app->erp->GetArtikelShopEinstellung('autolagerlampe', $artikel, $shopexportarr);
- $tmp->Select($artikel);
- $data[$i] = ['artikel' => $artikel,'artikelid' => $artikel];
- $data[$i]['nummer'] = $tmp->GetNummer();
- $projekt = $tmp->GetProjekt();
- if(is_array($extnummer) && (!empty($extnummer)?count($extnummer):0) > $i && !empty($extnummer[$i]) && trim($extnummer[$i]) != '')
- {
- if($data[$i]['nummer'] != trim($extnummer[$i])){
- $data[$i]['fremdnummer'] = trim($extnummer[$i]);
- }
- }
-
- $data[$i]['inaktiv'] = $tmp->GetInaktiv();
-
- if($tmp->GetIntern_Gesperrt()=='1'){
- $data[$i]['inaktiv'] = 1;
- }
-
- $data[$i]['name_de'] = $tmp->GetName_De();
- $data[$i]['name_en'] = $tmp->GetName_En();
- $data[$i]['einheit'] = $tmp->GetEinheit();
- $data[$i]['hersteller'] = $tmp->GetHersteller();
- $data[$i]['herstellernummer'] = $tmp->GetHerstellernummer();
- $data[$i]['ean'] = $tmp->GetEan();
- if(!empty($loadElements['foreign_numbers'])) {
- $data[$i]['artikelnummer_fremdnummern'] = $this->app->DB->SelectArr("SELECT * FROM artikelnummer_fremdnummern WHERE artikel = '" . $tmp->GetId() . "' AND shopid = '$id' AND aktiv = '1' AND nummer <> '' ORDER BY bezeichnung = 'SHOPID' DESC");
- if(!empty($data[$i]['artikelnummer_fremdnummern'])){
- foreach ($data[$i]['artikelnummer_fremdnummern'] as $fkey => $fval) {
- $data[$i]['artikelnummer_fremdnummern'][$fkey]['nummer'] = trim($fval['nummer']);
- }
- }
- }
-
- if(!empty($loadElements['article_descriptions'])) {
- $data[$i]['kurztext_de'] = $tmp->GetKurztext_De();
- $data[$i]['kurztext_en'] = $tmp->GetKurztext_En();
- $data[$i]['anabregs_text'] = htmlspecialchars($tmp->GetAnabregs_Text(),ENT_QUOTES);
- $data[$i]['anabregs_text_en'] = htmlspecialchars($tmp->GetAnabregs_Text_En(),ENT_QUOTES);
- $data[$i]['beschreibung_de'] = $tmp->GetBeschreibung_De();
- $data[$i]['beschreibung_en'] = $tmp->GetBeschreibung_En();
- $data[$i]['uebersicht_de'] = htmlspecialchars($tmp->GetUebersicht_De(),ENT_QUOTES);
- $data[$i]['uebersicht_en'] = htmlspecialchars($tmp->GetUebersicht_En(),ENT_QUOTES);
- $data[$i]['herkunftsland'] = $tmp->GetHerkunftsland();
-
- $data[$i]['texteuebertragen'] = $shopexportarr['texteuebertragen'];
-
- if(method_exists($tmp,'GetMetadescription_De'))
- {
- $data[$i]['metadescription_de'] = $tmp->GetMetadescription_De();
- }
- if(method_exists($tmp,'GetMetadescription_En'))
- {
- $data[$i]['metadescription_en'] = $tmp->GetMetadescription_En();
- }
- if(method_exists($tmp,'GetMetakeywords_De'))
- {
- $data[$i]['metakeywords_de'] = $tmp->GetMetakeywords_De();
- }
- if(method_exists($tmp,'GetMetakeywords_En'))
- {
- $data[$i]['metakeywords_en'] = $tmp->GetMetakeywords_En();
- }
- if(method_exists($tmp,'GetMetatitle_De'))
- {
- $data[$i]['metatitle_de'] = $tmp->GetMetatitle_De();
- }
- if(method_exists($tmp,'GetMetatitle_En'))
- {
- $data[$i]['metatitle_en'] = $tmp->GetMetatitle_En();
- }
- }
- if($tmp->GetVariante())
- {
- $variante_von = $tmp->GetVariante_Von();
- if($variante_von)
- {
- $tmp_2 = new ObjGenArtikel($this->app);
- $tmp_2->Select($variante_von);
- if($data[$i]['kurztext_de'] == '')
- {
- $data[$i]['kurztext_de'] = $tmp_2->GetKurztext_De();
- }
- if($data[$i]['kurztext_en'] == '')
- {
- $data[$i]['kurztext_en'] = $tmp_2->GetKurztext_En();
- }
- if($data[$i]['beschreibung_de'] == '')
- {
- $data[$i]['beschreibung_de'] = $tmp_2->GetBeschreibung_De();
- }
- if($data[$i]['beschreibung_en'] == '')
- {
- $data[$i]['beschreibung_en'] = $tmp_2->GetBeschreibung_En();
- }
- if($data[$i]['uebersicht_de'] == '')
- {
- $data[$i]['uebersicht_de'] = htmlspecialchars($tmp_2->GetUebersicht_De(),ENT_QUOTES);
- }
- if($data[$i]['uebersicht_en'] == '')
- {
- $data[$i]['uebersicht_en'] = htmlspecialchars($tmp_2->GetUebersicht_En(),ENT_QUOTES);
- }
- }
- }
-
- if($data[$i]['uebersicht_de'] == '' && $data[$i]['beschreibung_de'] == '' && $data[$i]['kurztext_de'] == '')
- {
- $data[$i]['uebersicht_de'] = $data[$i]['anabregs_text'];
- }
-
- $data[$i]['links_de'] = $tmp->GetLinks_De();
- $data[$i]['altersfreigabe'] = $tmp->GetAltersfreigabe();
- $data[$i]['links_en'] = $tmp->GetLinks_En();
- $data[$i]['startseite_de'] = $tmp->GetStartseite_De();
- $data[$i]['startseite_en'] = $tmp->GetStartseite_En();
- $data[$i]['restmenge'] = $this->app->erp->GetArtikelShopEinstellung('restmenge', $artikel, $shopexportarr);
- $data[$i]['startseite'] = $tmp->GetStartseite();
- $data[$i]['standardbild'] = $tmp->GetStandardbild();
- $data[$i]['herstellerlink'] = $tmp->GetHerstellerlink();
- $data[$i]['herstellernummer'] = $tmp->GetHerstellernummer();
- $data[$i]['hersteller'] = $tmp->GetHersteller();
- $data[$i]['lieferzeit'] = $tmp->GetLieferzeit();
- $data[$i]['lieferzeitmanuell'] = $this->app->erp->GetArtikelShopEinstellung('lieferzeitmanuell', $artikel, $shopexportarr);
- $data[$i]['gewicht'] = $tmp->GetGewicht();
- $data[$i]['laenge'] = $tmp->GetLaenge();
- $data[$i]['breite'] = $tmp->GetBreite();
- $data[$i]['hoehe'] = $tmp->GetHoehe();
-
- $data[$i]['wichtig'] = $tmp->GetWichtig();
- $data[$i]['porto'] = $tmp->GetPorto();
- $data[$i]['gesperrt'] = $tmp->GetGesperrt();
- $data[$i]['sperrgrund'] = $tmp->GetSperrgrund();
- $data[$i]['gueltigbis'] = $tmp->GetGueltigbis();
- $data[$i]['umsatzsteuer'] = $tmp->GetUmsatzsteuer();
- if($data[$i]['umsatzsteuer']!=='ermaessigt' && $data[$i]['umsatzsteuer']!=='befreit') {
- $data[$i]['umsatzsteuer']="normal";
- }
- $data[$i]['ausverkauft'] = $tmp->GetAusverkauft();
- $data[$i]['variante'] = $tmp->GetVariante();
- $data[$i]['variante_von_id'] = $tmp->GetVariante_Von();
- $data[$i]['variantevon'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id='".$tmp->GetVariante_Von()."' LIMIT 1");
- $data[$i]['variantevon_fremdnummer'] = trim($this->app->DB->Select("SELECT nummer FROM `artikelnummer_fremdnummern` WHERE shopid = '$id' AND aktiv = 1 AND artikel = '".$tmp->GetVariante_Von()."' AND trim(nummer) <> '' ORDER BY bezeichnung = 'SHOPID' DESC LIMIT 1"));
- if($data[$i]['variantevon_fremdnummer'] == '')
- {
- unset($data[$i]['variantevon_fremdnummer']);
- }
- //$data[$i]['pseudopreis'] = $tmp->GetPseudopreis();
- $data[$i]['pseudopreis'] = $this->app->erp->GetArtikelShopEinstellung('pseudopreis', $artikel, $shopexportarr);
- $data[$i]['keinrabatterlaubt'] = $tmp->GetKeinrabatterlaubt();
- $data[$i]['einkaufspreis'] = $this->app->erp->GetEinkaufspreis($artikel,1);
- //$data[$i]['pseudolager'] = $tmp->GetPseudolager();
- $data[$i]['pseudolager'] = $this->app->erp->GetArtikelShopEinstellung('pseudolager', $artikel, $shopexportarr);
- $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $artikel, $data[$i]['pseudolager']);
- if(is_numeric($data[$i]['pseudolager']) && $data[$i]['pseudolager'] < 0) {
- $data[$i]['pseudolager'] = 0;
- }
- $data[$i]['downloadartikel'] = $tmp->GetDownloadartikel();
- $data[$i]['zolltarifnummer'] = $tmp->GetZolltarifnummer();
- $preisgruppe = $this->app->DB->Select("SELECT s.preisgruppe FROM shopexport s INNER JOIN gruppen g ON s.preisgruppe = g.id AND g.aktiv = 1 WHERE s.id='$id' LIMIT 1");
-
- if(empty($loadElements['free_fields'])) {
- $freifelder = null;
- }
- else{
- $freifelder = $this->app->DB->SelectArr("SELECT freifeld_wawi, freifeld_shop FROM shopexport_freifelder WHERE shop = '$id' AND aktiv = 1 AND freifeld_wawi <> '' AND freifeld_shop <> ''");
- }
- if($freifelder)
- {
- /**
- * @deprecated 20.1
- * AP
- * Konstrunktion 'freifeld_Mappingname -> Wert' wird ersetzt durch 'Freifelder-> DE -> Mappingname -> Wert'
- */
- foreach($freifelder as $freifeld)
- {
- if(method_exists($tmp,'Get'.ucfirst($freifeld['freifeld_wawi'])))
- {
- $_funktionsname = 'Get'.ucfirst($freifeld['freifeld_wawi']);
- $data[$i]['freifeld_'.$freifeld['freifeld_shop']] = $tmp->$_funktionsname();
- }
- }
- /**
- * @deprecated Ende
- */
-
- foreach($freifelder as $freifeld)
- {
- $_funktionsname = 'Get'.ucfirst($freifeld['freifeld_wawi']);
- if(method_exists($tmp,$_funktionsname))
- {
- $data[$i]['freifelder']['DE'][$freifeld['freifeld_shop']] = $tmp->$_funktionsname();
- }
- }
-
- //Freifeldübersetzungen
- $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '$artikel' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
- if(!empty($freifelduebersetzungen)){
- foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
- $data[$i]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
- }
- }
- }
-
- $data[$i]['typ'] = $tmp->GetTyp();
- $data[$i]['kategoriename'] = $tmp->GetTyp();
- if(strpos($data[$i]['typ'], '_kat'))
- {
- $data[$i]['kategoriename'] = $this->app->DB->Select("SELECT bezeichnung FROM artikelkategorien WHERE id = '".(int)str_replace('_kat','',$data[$i]['typ'])."' LIMIT 1");
- }
-
- $kategorienuebertragen = $shopexportarr['kategorienuebertragen'];//$this->app->DB->Select("SELECT kategorienuebertragen FROM shopexport WHERE id = '$id' LIMIT 1");
- if(!empty($kategorienuebertragen) && !empty($loadElements['categories']))
- {
- $kategorienbaum = null;
- /** @var Onlineshops $onlineShopObj */
- $onlineShopObj = $this->app->loadModule('onlineshops');
- $categoryRootId = 0;
- if(!empty($onlineShopObj) && method_exists($onlineShopObj, 'getJsonSettings')) {
- $categoryRootId = (int)$onlineShopObj->getJsonSettings($id, 'category_root_id');
- }
- $this->app->erp->GetKategorienbaum($kategorienbaum, $categoryRootId, 0, $id);
- if(!empty($kategorienbaum))
- {
- $kategorien = $this->app->DB->SelectArr("SELECT ak.id, ak.bezeichnung FROM `artikelbaum_artikel` aa INNER JOIN `artikelkategorien` ak ON aa.kategorie = ak.id AND ak.geloescht <> 1 AND aa.artikel = '$artikel' ORDER by ak.bezeichnung");
- if($kategorien)
- {
- foreach($kategorien as $v)
- {
- $katid[$v['id']] = true;
+ $ret = [];
+ $shopkategorien = $this->app->DB->SelectArr("SELECT * FROM shopexport_kategorien WHERE shop = '$shopId' AND extparent = '$parent' AND extid <> '' ORDER BY extsort");
+ if ($shopkategorien) {
+ foreach ($shopkategorien as $v) {
+ $ret[] = $v;
+ $subkategorien = $this->getShopKatgeorien($shopId, $v['extid'], $lvl + 1);
+ if (!empty($subkategorien)) {
+ foreach ($subkategorien as $v2) {
+ $ret[] = $v2;
+ }
+ }
}
- }
- if(!empty($katid))
- {
- foreach($kategorienbaum as $v)
- {
- $data[$i]['kompletter_kategorienbaum'][] = array('name'=>$v['bezeichnung'],'parent'=>$v['parent'],'id'=>$v['id'],'lvl'=>$v['lvl'],'extid'=>$v['extid']);
- if(isset($katid[$v['id']]))
- {
- $data[$i]['kategorien'][] = array('name'=>$v['bezeichnung'],'parent'=>$v['parent'],'id'=>$v['id'],'lvl'=>$v['lvl'],'extid'=>$v['extid']);
- }
- }
- }
}
- }
- $eigenschaftenuebertragen = $shopexportarr['eigenschaftenuebertragen'];//$this->app->DB->Select("SELECT eigenschaftenuebertragen FROM shopexport WHERE id = '$id' LIMIT 1");
- if(!empty($eigenschaftenuebertragen) && !empty($loadElements['properties'])) {
- $eigenschaften = $this->app->DB->SelectArr("SELECT e.name, ew.wert FROM artikeleigenschaften e INNER JOIN artikeleigenschaftenwerte ew ON e.id = ew.artikeleigenschaften
+ return $ret;
+ }
+
+ /**
+ * @param int $id
+ * @param array $artikel_arr
+ * @param string|array $extnummer
+ * @param bool $nurlager
+ *
+ * @return mixed|null
+ * @throws Exception
+ */
+ public function RemoteSendArticleList($id, $artikel_arr, $extnummer = '', $nurlager = false) {
+ if (!class_exists('ObjGenArtikel') &&
+ is_file(dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php')) {
+ include_once dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php';
+ }
+ $shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
+ $artikelexport = $shopexportarr['artikelexport'];
+
+ $loadElements = [
+ 'foreign_numbers' => true,
+ 'article_descriptions' => true,
+ 'translations' => true,
+ 'categories' => true,
+ 'properties' => true,
+ 'pictures' => true,
+ 'cross_selling' => true,
+ 'bulk_prices' => true,
+ 'standard_price' => true,
+ 'variants' => true,
+ 'free_fields' => true,
+ ];
+
+ if (
+ ($nurlager || empty($artikelexport)) && !empty($shopexportarr['modulename']) && !is_file(dirname(__DIR__) . '/pages/' . $shopexportarr['modulename'] . '_custom.php')
+ ) {
+ $elementsNotNeededByModule = ShopimporterBase::storageNotNeededElements($shopexportarr['modulename']);
+ foreach ($elementsNotNeededByModule as $element) {
+ $loadElements[$element] = false;
+ }
+ }
+
+ //$lagerexport = $shopexportarr['lagerexport'];
+ $lagergrundlage = $shopexportarr['lagergrundlage'];
+ $shopbilderuebertragen = $shopexportarr['shopbilderuebertragen'];
+ $projekt = (int) $shopexportarr['projekt'];
+ $projektlager = $this->app->DB->Select("SELECT id FROM projekt WHERE id = $projekt AND projektlager = 1 LIMIT 1");
+ $tmp = new ObjGenArtikel($this->app);
+ $cartikel_arr = !empty($artikel_arr) ? count($artikel_arr) : 0;
+
+ for ($i = 0; $i < $cartikel_arr; $i++) {
+
+ $artikel = $artikel_arr[$i];
+ $lagerexport = $this->app->erp->GetArtikelShopEinstellung('autolagerlampe', $artikel, $shopexportarr);
+ $tmp->Select($artikel);
+ $data[$i] = ['artikel' => $artikel, 'artikelid' => $artikel];
+ $data[$i]['nummer'] = $tmp->GetNummer();
+ $projekt = $tmp->GetProjekt();
+ if (is_array($extnummer) && (!empty($extnummer) ? count($extnummer) : 0) > $i && !empty($extnummer[$i]) && trim($extnummer[$i]) != '') {
+ if ($data[$i]['nummer'] != trim($extnummer[$i])) {
+ $data[$i]['fremdnummer'] = trim($extnummer[$i]);
+ }
+ }
+
+ $data[$i]['inaktiv'] = $tmp->GetInaktiv();
+
+ if ($tmp->GetIntern_Gesperrt() == '1') {
+ $data[$i]['inaktiv'] = 1;
+ }
+
+ $data[$i]['name_de'] = $tmp->GetName_De();
+ $data[$i]['name_en'] = $tmp->GetName_En();
+ $data[$i]['einheit'] = $tmp->GetEinheit();
+ $data[$i]['hersteller'] = $tmp->GetHersteller();
+ $data[$i]['herstellernummer'] = $tmp->GetHerstellernummer();
+ $data[$i]['ean'] = $tmp->GetEan();
+ if (!empty($loadElements['foreign_numbers'])) {
+ $data[$i]['artikelnummer_fremdnummern'] = $this->app->DB->SelectArr("SELECT * FROM artikelnummer_fremdnummern WHERE artikel = '" . $tmp->GetId() . "' AND shopid = '$id' AND aktiv = '1' AND nummer <> '' ORDER BY bezeichnung = 'SHOPID' DESC");
+ if (!empty($data[$i]['artikelnummer_fremdnummern'])) {
+ foreach ($data[$i]['artikelnummer_fremdnummern'] as $fkey => $fval) {
+ $data[$i]['artikelnummer_fremdnummern'][$fkey]['nummer'] = trim($fval['nummer']);
+ }
+ }
+ }
+
+ if (!empty($loadElements['article_descriptions'])) {
+ $data[$i]['kurztext_de'] = $tmp->GetKurztext_De();
+ $data[$i]['kurztext_en'] = $tmp->GetKurztext_En();
+ $data[$i]['anabregs_text'] = htmlspecialchars($tmp->GetAnabregs_Text(), ENT_QUOTES);
+ $data[$i]['anabregs_text_en'] = htmlspecialchars($tmp->GetAnabregs_Text_En(), ENT_QUOTES);
+ $data[$i]['beschreibung_de'] = $tmp->GetBeschreibung_De();
+ $data[$i]['beschreibung_en'] = $tmp->GetBeschreibung_En();
+ $data[$i]['uebersicht_de'] = htmlspecialchars($tmp->GetUebersicht_De(), ENT_QUOTES);
+ $data[$i]['uebersicht_en'] = htmlspecialchars($tmp->GetUebersicht_En(), ENT_QUOTES);
+ $data[$i]['herkunftsland'] = $tmp->GetHerkunftsland();
+
+ $data[$i]['texteuebertragen'] = $shopexportarr['texteuebertragen'];
+
+ if (method_exists($tmp, 'GetMetadescription_De')) {
+ $data[$i]['metadescription_de'] = $tmp->GetMetadescription_De();
+ }
+ if (method_exists($tmp, 'GetMetadescription_En')) {
+ $data[$i]['metadescription_en'] = $tmp->GetMetadescription_En();
+ }
+ if (method_exists($tmp, 'GetMetakeywords_De')) {
+ $data[$i]['metakeywords_de'] = $tmp->GetMetakeywords_De();
+ }
+ if (method_exists($tmp, 'GetMetakeywords_En')) {
+ $data[$i]['metakeywords_en'] = $tmp->GetMetakeywords_En();
+ }
+ if (method_exists($tmp, 'GetMetatitle_De')) {
+ $data[$i]['metatitle_de'] = $tmp->GetMetatitle_De();
+ }
+ if (method_exists($tmp, 'GetMetatitle_En')) {
+ $data[$i]['metatitle_en'] = $tmp->GetMetatitle_En();
+ }
+ }
+ if ($tmp->GetVariante()) {
+ $variante_von = $tmp->GetVariante_Von();
+ if ($variante_von) {
+ $tmp_2 = new ObjGenArtikel($this->app);
+ $tmp_2->Select($variante_von);
+ if ($data[$i]['kurztext_de'] == '') {
+ $data[$i]['kurztext_de'] = $tmp_2->GetKurztext_De();
+ }
+ if ($data[$i]['kurztext_en'] == '') {
+ $data[$i]['kurztext_en'] = $tmp_2->GetKurztext_En();
+ }
+ if ($data[$i]['beschreibung_de'] == '') {
+ $data[$i]['beschreibung_de'] = $tmp_2->GetBeschreibung_De();
+ }
+ if ($data[$i]['beschreibung_en'] == '') {
+ $data[$i]['beschreibung_en'] = $tmp_2->GetBeschreibung_En();
+ }
+ if ($data[$i]['uebersicht_de'] == '') {
+ $data[$i]['uebersicht_de'] = htmlspecialchars($tmp_2->GetUebersicht_De(), ENT_QUOTES);
+ }
+ if ($data[$i]['uebersicht_en'] == '') {
+ $data[$i]['uebersicht_en'] = htmlspecialchars($tmp_2->GetUebersicht_En(), ENT_QUOTES);
+ }
+ }
+ }
+
+ if ($data[$i]['uebersicht_de'] == '' && $data[$i]['beschreibung_de'] == '' && $data[$i]['kurztext_de'] == '') {
+ $data[$i]['uebersicht_de'] = $data[$i]['anabregs_text'];
+ }
+
+ $data[$i]['links_de'] = $tmp->GetLinks_De();
+ $data[$i]['altersfreigabe'] = $tmp->GetAltersfreigabe();
+ $data[$i]['links_en'] = $tmp->GetLinks_En();
+ $data[$i]['startseite_de'] = $tmp->GetStartseite_De();
+ $data[$i]['startseite_en'] = $tmp->GetStartseite_En();
+ $data[$i]['restmenge'] = $this->app->erp->GetArtikelShopEinstellung('restmenge', $artikel, $shopexportarr);
+ $data[$i]['startseite'] = $tmp->GetStartseite();
+ $data[$i]['standardbild'] = $tmp->GetStandardbild();
+ $data[$i]['herstellerlink'] = $tmp->GetHerstellerlink();
+ $data[$i]['herstellernummer'] = $tmp->GetHerstellernummer();
+ $data[$i]['hersteller'] = $tmp->GetHersteller();
+ $data[$i]['lieferzeit'] = $tmp->GetLieferzeit();
+ $data[$i]['lieferzeitmanuell'] = $this->app->erp->GetArtikelShopEinstellung('lieferzeitmanuell', $artikel, $shopexportarr);
+ $data[$i]['gewicht'] = $tmp->GetGewicht();
+ $data[$i]['laenge'] = $tmp->GetLaenge();
+ $data[$i]['breite'] = $tmp->GetBreite();
+ $data[$i]['hoehe'] = $tmp->GetHoehe();
+
+ $data[$i]['wichtig'] = $tmp->GetWichtig();
+ $data[$i]['porto'] = $tmp->GetPorto();
+ $data[$i]['gesperrt'] = $tmp->GetGesperrt();
+ $data[$i]['sperrgrund'] = $tmp->GetSperrgrund();
+ $data[$i]['gueltigbis'] = $tmp->GetGueltigbis();
+ $data[$i]['umsatzsteuer'] = $tmp->GetUmsatzsteuer();
+ if ($data[$i]['umsatzsteuer'] !== 'ermaessigt' && $data[$i]['umsatzsteuer'] !== 'befreit') {
+ $data[$i]['umsatzsteuer'] = "normal";
+ }
+ $data[$i]['ausverkauft'] = $tmp->GetAusverkauft();
+ $data[$i]['variante'] = $tmp->GetVariante();
+ $data[$i]['variante_von_id'] = $tmp->GetVariante_Von();
+ $data[$i]['variantevon'] = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id='" . $tmp->GetVariante_Von() . "' LIMIT 1");
+ $data[$i]['variantevon_fremdnummer'] = trim($this->app->DB->Select("SELECT nummer FROM `artikelnummer_fremdnummern` WHERE shopid = '$id' AND aktiv = 1 AND artikel = '" . $tmp->GetVariante_Von() . "' AND trim(nummer) <> '' ORDER BY bezeichnung = 'SHOPID' DESC LIMIT 1"));
+ if ($data[$i]['variantevon_fremdnummer'] == '') {
+ unset($data[$i]['variantevon_fremdnummer']);
+ }
+ //$data[$i]['pseudopreis'] = $tmp->GetPseudopreis();
+ $data[$i]['pseudopreis'] = $this->app->erp->GetArtikelShopEinstellung('pseudopreis', $artikel, $shopexportarr);
+ $data[$i]['keinrabatterlaubt'] = $tmp->GetKeinrabatterlaubt();
+ $data[$i]['einkaufspreis'] = $this->app->erp->GetEinkaufspreis($artikel, 1);
+ //$data[$i]['pseudolager'] = $tmp->GetPseudolager();
+ $data[$i]['pseudolager'] = $this->app->erp->GetArtikelShopEinstellung('pseudolager', $artikel, $shopexportarr);
+ $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $artikel, $data[$i]['pseudolager']);
+ if (is_numeric($data[$i]['pseudolager']) && $data[$i]['pseudolager'] < 0) {
+ $data[$i]['pseudolager'] = 0;
+ }
+ $data[$i]['downloadartikel'] = $tmp->GetDownloadartikel();
+ $data[$i]['zolltarifnummer'] = $tmp->GetZolltarifnummer();
+ $preisgruppe = $this->app->DB->Select("SELECT s.preisgruppe FROM shopexport s INNER JOIN gruppen g ON s.preisgruppe = g.id AND g.aktiv = 1 WHERE s.id='$id' LIMIT 1");
+
+ if (empty($loadElements['free_fields'])) {
+ $freifelder = null;
+ } else {
+ $freifelder = $this->app->DB->SelectArr("SELECT freifeld_wawi, freifeld_shop FROM shopexport_freifelder WHERE shop = '$id' AND aktiv = 1 AND freifeld_wawi <> '' AND freifeld_shop <> ''");
+ }
+ if ($freifelder) {
+ /**
+ * @deprecated 20.1
+ * AP
+ * Konstrunktion 'freifeld_Mappingname -> Wert' wird ersetzt durch 'Freifelder-> DE -> Mappingname -> Wert'
+ */
+ foreach ($freifelder as $freifeld) {
+ if (method_exists($tmp, 'Get' . ucfirst($freifeld['freifeld_wawi']))) {
+ $_funktionsname = 'Get' . ucfirst($freifeld['freifeld_wawi']);
+ $data[$i]['freifeld_' . $freifeld['freifeld_shop']] = $tmp->$_funktionsname();
+ }
+ }
+ /**
+ * @deprecated Ende
+ */
+ foreach ($freifelder as $freifeld) {
+ $_funktionsname = 'Get' . ucfirst($freifeld['freifeld_wawi']);
+ if (method_exists($tmp, $_funktionsname)) {
+ $data[$i]['freifelder']['DE'][$freifeld['freifeld_shop']] = $tmp->$_funktionsname();
+ }
+ }
+
+ //Freifeldübersetzungen
+ $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '$artikel' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
+ if (!empty($freifelduebersetzungen)) {
+ foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
+ $data[$i]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
+ }
+ }
+ }
+
+ $data[$i]['typ'] = $tmp->GetTyp();
+ $data[$i]['kategoriename'] = $tmp->GetTyp();
+ if (strpos($data[$i]['typ'], '_kat')) {
+ $data[$i]['kategoriename'] = $this->app->DB->Select("SELECT bezeichnung FROM artikelkategorien WHERE id = '" . (int) str_replace('_kat', '', $data[$i]['typ']) . "' LIMIT 1");
+ }
+
+ $kategorienuebertragen = $shopexportarr['kategorienuebertragen']; //$this->app->DB->Select("SELECT kategorienuebertragen FROM shopexport WHERE id = '$id' LIMIT 1");
+ if (!empty($kategorienuebertragen) && !empty($loadElements['categories'])) {
+ $kategorienbaum = null;
+ /** @var Onlineshops $onlineShopObj */
+ $onlineShopObj = $this->app->loadModule('onlineshops');
+ $categoryRootId = 0;
+ if (!empty($onlineShopObj) && method_exists($onlineShopObj, 'getJsonSettings')) {
+ $categoryRootId = (int) $onlineShopObj->getJsonSettings($id, 'category_root_id');
+ }
+ $this->app->erp->GetKategorienbaum($kategorienbaum, $categoryRootId, 0, $id);
+ if (!empty($kategorienbaum)) {
+ $kategorien = $this->app->DB->SelectArr("SELECT ak.id, ak.bezeichnung FROM `artikelbaum_artikel` aa INNER JOIN `artikelkategorien` ak ON aa.kategorie = ak.id AND ak.geloescht <> 1 AND aa.artikel = '$artikel' ORDER by ak.bezeichnung");
+ if ($kategorien) {
+ foreach ($kategorien as $v) {
+ $katid[$v['id']] = true;
+ }
+ }
+ if (!empty($katid)) {
+ foreach ($kategorienbaum as $v) {
+ $data[$i]['kompletter_kategorienbaum'][] = array('name' => $v['bezeichnung'], 'parent' => $v['parent'], 'id' => $v['id'], 'lvl' => $v['lvl'], 'extid' => $v['extid']);
+ if (isset($katid[$v['id']])) {
+ $data[$i]['kategorien'][] = array('name' => $v['bezeichnung'], 'parent' => $v['parent'], 'id' => $v['id'], 'lvl' => $v['lvl'], 'extid' => $v['extid']);
+ }
+ }
+ }
+ }
+ }
+
+ $eigenschaftenuebertragen = $shopexportarr['eigenschaftenuebertragen']; //$this->app->DB->Select("SELECT eigenschaftenuebertragen FROM shopexport WHERE id = '$id' LIMIT 1");
+ if (!empty($eigenschaftenuebertragen) && !empty($loadElements['properties'])) {
+ $eigenschaften = $this->app->DB->SelectArr("SELECT e.name, ew.wert FROM artikeleigenschaften e INNER JOIN artikeleigenschaftenwerte ew ON e.id = ew.artikeleigenschaften
WHERE ew.artikel = '$artikel' AND e.name <> '' AND ew.wert <> '' AND e.geloescht <> 1");
- if(!empty($eigenschaften))
- {
- $eigenschaftind = 0;
- foreach($eigenschaften as $eigenschaft)
- {
- $eigenschaftind++;
- $data[$i]['eigenschaften'][] = array('name'=>$eigenschaft['name'], 'values'=>$eigenschaft['wert']);
- }
- }
+ if (!empty($eigenschaften)) {
+ $eigenschaftind = 0;
+ foreach ($eigenschaften as $eigenschaft) {
+ $eigenschaftind++;
+ $data[$i]['eigenschaften'][] = array('name' => $eigenschaft['name'], 'values' => $eigenschaft['wert']);
+ }
+ }
- $eigenschaftenuebersetzungen = $this->app->DB->SelectArr("SELECT language_from, language_to, property_from, property_to,property_value_from,property_value_to FROM article_property_translation WHERE article_id = '$artikel'");
- $data[$i]['eigenschaftenuebersetzungen'] = $eigenschaftenuebersetzungen;
- }
+ $eigenschaftenuebersetzungen = $this->app->DB->SelectArr("SELECT language_from, language_to, property_from, property_to,property_value_from,property_value_to FROM article_property_translation WHERE article_id = '$artikel'");
+ $data[$i]['eigenschaftenuebersetzungen'] = $eigenschaftenuebersetzungen;
+ }
- //Bilder
- $dateien = null;
- if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
- $dateien = $this->getImagesForArticle($artikel);
- if (!empty($dateien)) {
- $data[$i]['Dateien'] = [];
- foreach ($dateien as $datei) {
- $filename = $this->app->erp->GetDateiName($datei['id']);
- $path_info = pathinfo($filename);
- $data[$i]['Dateien'][] = array(
- 'datei' => base64_encode($this->app->erp->GetDatei($datei['id'])),
- 'filename' => $filename,
- 'extension' => $path_info['extension'],
- 'titel' => $datei['titel'],
- 'beschreibung' => $datei['beschreibung'],
- 'id' => $datei['id'],
- 'version' => $datei['version'],
- 'stichwort' => $datei['subjekt'],
- 'extid' => $this->GetShopexportMappingExt($id, 'datei', $datei['id']));
- }
- }
- $dateiengeloescht = $this->app->DB->SelectArr("SELECT s.extid FROM shopexport_mapping s LEFT JOIN datei d ON s.intid = d.id AND d.geloescht = 0 WHERE s.shop = '$id' AND s.tabelle = 'datei' AND s.intid2 = '$artikel' AND isnull(d.id)");
- if (!empty($dateiengeloescht)) {
- if (empty($dateien)) {
- $data[$i]['Dateien'] = [];
- }
- foreach ($dateiengeloescht as $datei) {
- $data[$i]['Dateien'][] = array('loeschen' => 1, 'extid' => $datei['extid']);
- }
- }
- }
+ //Bilder
+ $dateien = null;
+ if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
+ $dateien = $this->getImagesForArticle($artikel);
+ if (!empty($dateien)) {
+ $data[$i]['Dateien'] = [];
+ foreach ($dateien as $datei) {
+ $filename = $this->app->erp->GetDateiName($datei['id']);
+ $path_info = pathinfo($filename);
+ $data[$i]['Dateien'][] = array(
+ 'datei' => base64_encode($this->app->erp->GetDatei($datei['id'])),
+ 'filename' => $filename,
+ 'extension' => $path_info['extension'],
+ 'titel' => $datei['titel'],
+ 'beschreibung' => $datei['beschreibung'],
+ 'id' => $datei['id'],
+ 'version' => $datei['version'],
+ 'stichwort' => $datei['subjekt'],
+ 'extid' => $this->GetShopexportMappingExt($id, 'datei', $datei['id']));
+ }
+ }
+ $dateiengeloescht = $this->app->DB->SelectArr("SELECT s.extid FROM shopexport_mapping s LEFT JOIN datei d ON s.intid = d.id AND d.geloescht = 0 WHERE s.shop = '$id' AND s.tabelle = 'datei' AND s.intid2 = '$artikel' AND isnull(d.id)");
+ if (!empty($dateiengeloescht)) {
+ if (empty($dateien)) {
+ $data[$i]['Dateien'] = [];
+ }
+ foreach ($dateiengeloescht as $datei) {
+ $data[$i]['Dateien'][] = array('loeschen' => 1, 'extid' => $datei['extid']);
+ }
+ }
+ }
- if (method_exists($tmp, 'GetSteuer_Art_Produkt')) {
- $data[$i]['steuer_art_produkt'] = $tmp->GetSteuer_Art_Produkt();
- }
- if (method_exists($tmp, 'GetSteuer_Art_Produkt_Download')) {
- $data[$i]['steuer_art_produkt_download'] = $tmp->GetSteuer_Art_Produkt_Download();
- }
+ if (method_exists($tmp, 'GetSteuer_Art_Produkt')) {
+ $data[$i]['steuer_art_produkt'] = $tmp->GetSteuer_Art_Produkt();
+ }
+ if (method_exists($tmp, 'GetSteuer_Art_Produkt_Download')) {
+ $data[$i]['steuer_art_produkt_download'] = $tmp->GetSteuer_Art_Produkt_Download();
+ }
- $projekt = $tmp->GetProjekt();
- $projektlager = $this->app->DB->Select("SELECT id FROM projekt WHERE id = '$projekt' AND projektlager = 1 LIMIT 1");
- $data[$i]['anzahl_bilder'] = $this->app->DB->Select("SELECT COUNT(datei) FROM datei_stichwoerter WHERE subjekt='Shopbild' AND objekt='Artikel' AND parameter='$artikel'");
+ $projekt = $tmp->GetProjekt();
+ $projektlager = $this->app->DB->Select("SELECT id FROM projekt WHERE id = '$projekt' AND projektlager = 1 LIMIT 1");
+ $data[$i]['anzahl_bilder'] = $this->app->DB->Select("SELECT COUNT(datei) FROM datei_stichwoerter WHERE subjekt='Shopbild' AND objekt='Artikel' AND parameter='$artikel'");
- $bestandalternativartikel = method_exists($tmp, 'GetBestandalternativartikel') ? $tmp->GetBestandalternativartikel() : 0;
+ $bestandalternativartikel = method_exists($tmp, 'GetBestandalternativartikel') ? $tmp->GetBestandalternativartikel() : 0;
- if ($bestandalternativartikel) {
- $data[$i]['anzahl_lager'] = floor($this->app->erp->ArtikelAnzahlVerkaufbar($bestandalternativartikel, 0, $projektlager, $id, $lagergrundlage));
- $data[$i]['lagerkorrekturwert'] = floor(-($this->app->erp->ArtikelAnzahlVerkaufbar($bestandalternativartikel, 0, $projektlager, 0, $lagergrundlage) - $data[$i]['anzahl_lager']));
- } else {
- $data[$i]['anzahl_lager'] = floor($this->app->erp->ArtikelAnzahlVerkaufbar($artikel, 0, $projektlager, $id, $lagergrundlage));
- $data[$i]['lagerkorrekturwert'] = floor(-($this->app->erp->ArtikelAnzahlVerkaufbar($artikel, 0, $projektlager, 0, $lagergrundlage) - $data[$i]['anzahl_lager']));
- }
+ if ($bestandalternativartikel) {
+ $data[$i]['anzahl_lager'] = floor($this->app->erp->ArtikelAnzahlVerkaufbar($bestandalternativartikel, 0, $projektlager, $id, $lagergrundlage));
+ $data[$i]['lagerkorrekturwert'] = floor(-($this->app->erp->ArtikelAnzahlVerkaufbar($bestandalternativartikel, 0, $projektlager, 0, $lagergrundlage) - $data[$i]['anzahl_lager']));
+ } else {
+ $data[$i]['anzahl_lager'] = floor($this->app->erp->ArtikelAnzahlVerkaufbar($artikel, 0, $projektlager, $id, $lagergrundlage));
+ $data[$i]['lagerkorrekturwert'] = floor(-($this->app->erp->ArtikelAnzahlVerkaufbar($artikel, 0, $projektlager, 0, $lagergrundlage) - $data[$i]['anzahl_lager']));
+ }
- $data[$i]['pseudolager'] = $this->app->erp->GetArtikelShopEinstellung('pseudolager', $artikel, $shopexportarr);
- $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $artikel, $data[$i]['pseudolager']);
- if (is_numeric($data[$i]['pseudolager']) && $data[$i]['pseudolager'] < 0) {
- $data[$i]['pseudolager'] = 0;
- $data[$i]['anzahl_lager'] = 0;
- } elseif ($data[$i]['pseudolager'] > 0) {
- $data[$i]['anzahl_lager'] = $data[$i]['pseudolager'];
- }
- if ($data[$i]['anzahl_lager'] < 0) {
- $data[$i]['anzahl_lager'] = 0;
- }
- $data[$i]['autolagerlampe'] = $tmp->GetAutolagerlampe();
- if (method_exists($this->app->erp, 'GetArtikelShopEinstellung')) {
- $data[$i]['autolagerlampe'] = $this->app->erp->GetArtikelShopEinstellung('autolagerlampe', $artikel, $shopexportarr);
- }
- if ($data[$i]['autolagerlampe'] != '1') {
- $data[$i]['anzahl_lager'] = '';
- $data[$i]['pseudolager'] = '';
- $this->app->DB->Update(
- sprintf(
- 'UPDATE `artikel_onlineshops`
+ $data[$i]['pseudolager'] = $this->app->erp->GetArtikelShopEinstellung('pseudolager', $artikel, $shopexportarr);
+ $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $artikel, $data[$i]['pseudolager']);
+ if (is_numeric($data[$i]['pseudolager']) && $data[$i]['pseudolager'] < 0) {
+ $data[$i]['pseudolager'] = 0;
+ $data[$i]['anzahl_lager'] = 0;
+ } elseif ($data[$i]['pseudolager'] > 0) {
+ $data[$i]['anzahl_lager'] = $data[$i]['pseudolager'];
+ }
+ if ($data[$i]['anzahl_lager'] < 0) {
+ $data[$i]['anzahl_lager'] = 0;
+ }
+ $data[$i]['autolagerlampe'] = $tmp->GetAutolagerlampe();
+ if (method_exists($this->app->erp, 'GetArtikelShopEinstellung')) {
+ $data[$i]['autolagerlampe'] = $this->app->erp->GetArtikelShopEinstellung('autolagerlampe', $artikel, $shopexportarr);
+ }
+ if ($data[$i]['autolagerlampe'] != '1') {
+ $data[$i]['anzahl_lager'] = '';
+ $data[$i]['pseudolager'] = '';
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE `artikel_onlineshops`
SET `storage_cache` = NULL, `pseudostorage_cache` = NULL
WHERE `artikel` = %d AND `shop` = %d',
- $artikel, $id
- )
- );
- } else {
- $this->app->DB->Update(
- sprintf(
- 'UPDATE `artikel_onlineshops`
+ $artikel, $id
+ )
+ );
+ } else {
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE `artikel_onlineshops`
SET `storage_cache` = %d, `pseudostorage_cache` = %s
WHERE `artikel` = %d AND `shop` = %d',
- $data[$i]['anzahl_lager'],
- !isset($data[$i]['pseudolager']) || !is_numeric($data[$i]['pseudolager']) ? 'NULL' : $data[$i]['pseudolager'],
- $artikel,
- $id
- )
- );
- }
+ $data[$i]['anzahl_lager'],
+ !isset($data[$i]['pseudolager']) || !is_numeric($data[$i]['pseudolager']) ? 'NULL' : $data[$i]['pseudolager'],
+ $artikel,
+ $id
+ )
+ );
+ }
- $projekt = $shopexportarr['projekt'];// $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$id' LIMIT 1");
- if (!empty($shopexportarr['crosssellingartikeluebertragen']) && !empty($loadElements['cross_selling'])) {
- //if($this->app->DB->Select("SELECT crosssellingartikeluebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
- $data[$i]['crosssellingartikel'] = $this->app->DB->SelectArr("SELECT a.id, a.nummer, ak.bezeichnung as kategorie, a.name_de, a.name_en, ca.art, ca.gegenseitigzuweisen, af.nummer AS fremdnummer
+ $projekt = $shopexportarr['projekt']; // $this->app->DB->Select("SELECT projekt FROM shopexport WHERE id='$id' LIMIT 1");
+ if (!empty($shopexportarr['crosssellingartikeluebertragen']) && !empty($loadElements['cross_selling'])) {
+ //if($this->app->DB->Select("SELECT crosssellingartikeluebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
+ $data[$i]['crosssellingartikel'] = $this->app->DB->SelectArr("SELECT a.id, a.nummer, ak.bezeichnung as kategorie, a.name_de, a.name_en, ca.art, ca.gegenseitigzuweisen, af.nummer AS fremdnummer
FROM crossselling_artikel ca
JOIN artikel a ON ca.crosssellingartikel = a.id
LEFT JOIN artikelkategorien ak ON CONCAT(ak.id,'_kat') = a.typ
@@ -1587,14 +1436,12 @@ class Remote
WHERE ca.artikel='" . $tmp->GetId() . "' AND (ca.shop='$id' OR ca.shop='0')
GROUP BY ca.crosssellingartikel, ca.art");
- if (empty($data[$i]['crosssellingartikel'])) {
- $data[$i]['crosssellingartikel'] = [];
- }
+ if (empty($data[$i]['crosssellingartikel'])) {
+ $data[$i]['crosssellingartikel'] = [];
+ }
-
- $sql =
-
- "SELECT a.id, a.nummer, ak.bezeichnung as kategorie, a.name_de, a.name_en, ca.art, ca.gegenseitigzuweisen, af.nummer AS fremdnummer
+
+ $sql = "SELECT a.id, a.nummer, ak.bezeichnung as kategorie, a.name_de, a.name_en, ca.art, ca.gegenseitigzuweisen, af.nummer AS fremdnummer
FROM crossselling_artikel ca
JOIN artikel a ON ca.artikel = a.id
LEFT JOIN artikelkategorien ak ON CONCAT(ak.id,'_kat') = a.typ
@@ -1603,139 +1450,139 @@ class Remote
WHERE ca.crosssellingartikel='" . $tmp->GetId() . "' AND ca.gegenseitigzuweisen=1 AND (ca.shop='$id' OR ca.shop='0')
GROUP BY ca.artikel, ca.art";
- $gegenseitigzugewiesen = $this->app->DB->SelectArr($sql);
+ $gegenseitigzugewiesen = $this->app->DB->SelectArr($sql);
- if (!empty($gegenseitigzugewiesen)) {
- foreach ($gegenseitigzugewiesen as $gegenseitigzugewiesenercrosssellingartikel) {
- $data[$i]['crosssellingartikel'][] = $gegenseitigzugewiesenercrosssellingartikel;
- }
- }
- }
-
- if (!empty($loadElements['article_descriptions']) && $this->app->erp->ModulVorhanden('artikel_texte')) {
- $sprachen = ['de', 'en'];
- foreach ($sprachen as $sprache) {
- $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
- $id, strtoupper($sprache), $artikel);
- $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
- if (!empty($ersetzeStandardbeschreibung)) {
- $data[$i]['name_' . $sprache] = $ersetzeStandardbeschreibung['name'];
- $data[$i]['beschreibung_' . $sprache] = $ersetzeStandardbeschreibung['beschreibung_online'];
- $data[$i]['kurztext_' . $sprache] = $ersetzeStandardbeschreibung['kurztext'];
- $data[$i]['metadescription_' . $sprache] = $ersetzeStandardbeschreibung['meta_description'];
- $data[$i]['metakeywords_' . $sprache] = $ersetzeStandardbeschreibung['meta_keywords'];
- $data[$i]['metatitle_' . $sprache] = $ersetzeStandardbeschreibung['meta_title'];
- if ($sprache === 'de') {
- $data[$i]['anabregs_text'] = $ersetzeStandardbeschreibung['beschreibung'];
- } else {
- $data[$i]['anabregs_text_en'] = $ersetzeStandardbeschreibung['beschreibung'];
+ if (!empty($gegenseitigzugewiesen)) {
+ foreach ($gegenseitigzugewiesen as $gegenseitigzugewiesenercrosssellingartikel) {
+ $data[$i]['crosssellingartikel'][] = $gegenseitigzugewiesenercrosssellingartikel;
+ }
+ }
}
- }
- }
- }
- if(!empty($loadElements['standard_price'])){
+ if (!empty($loadElements['article_descriptions']) && $this->app->erp->ModulVorhanden('artikel_texte')) {
+ $sprachen = ['de', 'en'];
+ foreach ($sprachen as $sprache) {
+ $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
+ $id, strtoupper($sprache), $artikel);
+ $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
+ if (!empty($ersetzeStandardbeschreibung)) {
+ $data[$i]['name_' . $sprache] = $ersetzeStandardbeschreibung['name'];
+ $data[$i]['beschreibung_' . $sprache] = $ersetzeStandardbeschreibung['beschreibung_online'];
+ $data[$i]['kurztext_' . $sprache] = $ersetzeStandardbeschreibung['kurztext'];
+ $data[$i]['metadescription_' . $sprache] = $ersetzeStandardbeschreibung['meta_description'];
+ $data[$i]['metakeywords_' . $sprache] = $ersetzeStandardbeschreibung['meta_keywords'];
+ $data[$i]['metatitle_' . $sprache] = $ersetzeStandardbeschreibung['meta_title'];
+ if ($sprache === 'de') {
+ $data[$i]['anabregs_text'] = $ersetzeStandardbeschreibung['beschreibung'];
+ } else {
+ $data[$i]['anabregs_text_en'] = $ersetzeStandardbeschreibung['beschreibung'];
+ }
+ }
+ }
+ }
- $priceInformation = $this->app->DB->SelectArr("SELECT v.preis AS preis, v.waehrung
+ if (!empty($loadElements['standard_price'])) {
+
+ $priceInformation = $this->app->DB->SelectArr("SELECT v.preis AS preis, v.waehrung
FROM `verkaufspreise` AS `v`
WHERE v.artikel = '{$artikel}' AND v.ab_menge = 1 AND v.geloescht = 0 AND v.art != 'Gruppe'
AND (v.objekt = 'Standard' OR v.objekt = '') AND (v.adresse = '0' OR v.adresse = '')
AND (v.gueltig_bis >= NOW() OR v.gueltig_bis = '0000-00-00')
ORDER BY v.preis DESC LIMIT 1");
- $priceInformation = reset($priceInformation);
- $defaultPrice = $priceInformation['preis'];
- $defaultCurrency = $priceInformation['waehrung'] ?: 'EUR';
- if($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')){
- $defaultCurrency = 'EUR'; //the follow up function imply EUR as the default currency
- $defaultPrice = $this->app->erp->GetVerkaufspreisGruppe($artikel, 1, $preisgruppe);
- }
+ $priceInformation = reset($priceInformation);
+ $defaultPrice = $priceInformation['preis'];
+ $defaultCurrency = $priceInformation['waehrung'] ?: 'EUR';
+ if ($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')) {
+ $defaultCurrency = 'EUR'; //the follow up function imply EUR as the default currency
+ $defaultPrice = $this->app->erp->GetVerkaufspreisGruppe($artikel, 1, $preisgruppe);
+ }
- $data[$i]['waehrung'] = $defaultCurrency;
- $data[$i]['preis'] = $defaultPrice;
+ $data[$i]['waehrung'] = $defaultCurrency;
+ $data[$i]['preis'] = $defaultPrice;
- if(!empty($tmp->GetSteuersatz()) && $tmp->GetSteuersatz() != -1){
- $data[$i]['steuersatz'] = (float)$tmp->GetSteuersatz();
- }elseif($data[$i]['umsatzsteuer'] === 'ermaessigt'){
- $data[$i]['steuersatz'] = (float)$this->app->erp->GetStandardSteuersatzErmaessigt($projekt);
- }elseif($data[$i]['umsatzsteuer'] === 'befreit'){
- $data[$i]['steuersatz'] = 0;
- }else{
- $data[$i]['steuersatz'] = (float)$this->app->erp->GetStandardSteuersatzNormal($projekt);
- }
+ if (!empty($tmp->GetSteuersatz()) && $tmp->GetSteuersatz() != -1) {
+ $data[$i]['steuersatz'] = (float) $tmp->GetSteuersatz();
+ } elseif ($data[$i]['umsatzsteuer'] === 'ermaessigt') {
+ $data[$i]['steuersatz'] = (float) $this->app->erp->GetStandardSteuersatzErmaessigt($projekt);
+ } elseif ($data[$i]['umsatzsteuer'] === 'befreit') {
+ $data[$i]['steuersatz'] = 0;
+ } else {
+ $data[$i]['steuersatz'] = (float) $this->app->erp->GetStandardSteuersatzNormal($projekt);
+ }
- $steuer = ($data[$i]['steuersatz'] + 100) / 100.0;
+ $steuer = ($data[$i]['steuersatz'] + 100) / 100.0;
- if(!empty($shopexportarr['staffelpreiseuebertragen']) && !empty($loadElements['bulk_prices'])){
- $preisgruppenzusatz = " AND v.art = 'Kunde' AND v.adresse = 0";
- if(!empty($preisgruppe)){
- $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
- }
- $query = sprintf("SELECT v.adresse, g.name, g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung
+ if (!empty($shopexportarr['staffelpreiseuebertragen']) && !empty($loadElements['bulk_prices'])) {
+ $preisgruppenzusatz = " AND v.art = 'Kunde' AND v.adresse = 0";
+ if (!empty($preisgruppe)) {
+ $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
+ }
+ $query = sprintf("SELECT v.adresse, g.name, g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung
FROM `verkaufspreise` AS `v`
LEFT JOIN `gruppen` AS `g` on v.gruppe = g.id
WHERE v.artikel = %d AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND v.adresse = 0 AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab)) %s
ORDER by g.id, v.ab_menge", $artikel, $preisgruppenzusatz);
- $standardstaffelpreise = $this->app->DB->SelectArr($query);
- $data[$i]['staffelpreise_standard'] = [];
- if(!empty($standardstaffelpreise)){
- foreach ($standardstaffelpreise as $staffelpreis) {
- $data[$i]['staffelpreise_standard'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR'
- ];
- }
- }
+ $standardstaffelpreise = $this->app->DB->SelectArr($query);
+ $data[$i]['staffelpreise_standard'] = [];
+ if (!empty($standardstaffelpreise)) {
+ foreach ($standardstaffelpreise as $staffelpreis) {
+ $data[$i]['staffelpreise_standard'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR'
+ ];
+ }
+ }
- $query = sprintf("SELECT a.name AS `kundenname`, a.email, v.adresse, v.ab_menge, v.preis, v.waehrung
+ $query = sprintf("SELECT a.name AS `kundenname`, a.email, v.adresse, v.ab_menge, v.preis, v.waehrung
FROM `verkaufspreise` AS `v`
JOIN `adresse` AS `a` ON v.adresse = a.id AND v.art LIKE 'Kunde'
WHERE v.`artikel` = %d AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab))
ORDER by v.adresse, v.ab_menge", $artikel);
- $staffelpreisekunden = $this->app->DB->SelectArr($query);
- if(!empty($staffelpreisekunden)){
- foreach ($staffelpreisekunden as $staffelpreis) {
- $data[$i]['staffelpreise_kunden'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
- 'email' => $staffelpreis['email'],
- 'kundenname' => $staffelpreis['kundenname']
- ];
- }
- }
+ $staffelpreisekunden = $this->app->DB->SelectArr($query);
+ if (!empty($staffelpreisekunden)) {
+ foreach ($staffelpreisekunden as $staffelpreis) {
+ $data[$i]['staffelpreise_kunden'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
+ 'email' => $staffelpreis['email'],
+ 'kundenname' => $staffelpreis['kundenname']
+ ];
+ }
+ }
- $query = sprintf("SELECT g.name, g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, sk.extgruppename
+ $query = sprintf("SELECT g.name, g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, sk.extgruppename
FROM `verkaufspreise` AS `v`
JOIN `gruppen` AS `g` on v.gruppe = g.id
JOIN `shopexport_kundengruppen` AS `sk` ON sk.gruppeid = v.gruppe
WHERE v.`artikel` = %d AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND v.art like 'Gruppe' AND v.gruppe <> '%s' AND sk.shopid = %d AND sk.aktiv = 1 AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab))
ORDER by g.id, v.ab_menge", $artikel, $preisgruppe, $id);
- $staffelpreisegruppen = $this->app->DB->SelectArr($query);
- if(!empty($staffelpreisegruppen)){
- foreach ($staffelpreisegruppen as $staffelpreis) {
- $data[$i]['staffelpreise_gruppen'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
- 'kennziffer' => $staffelpreis['kennziffer'],
- 'gruppenname' => $staffelpreis['name'],
- 'gruppeextern' => $staffelpreis['extgruppename']
- ];
- }
- }
+ $staffelpreisegruppen = $this->app->DB->SelectArr($query);
+ if (!empty($staffelpreisegruppen)) {
+ foreach ($staffelpreisegruppen as $staffelpreis) {
+ $data[$i]['staffelpreise_gruppen'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
+ 'kennziffer' => $staffelpreis['kennziffer'],
+ 'gruppenname' => $staffelpreis['name'],
+ 'gruppeextern' => $staffelpreis['extgruppename']
+ ];
+ }
+ }
- /**
- * @deprecated 20.3
- * Staffelpreise werden gesondert uebergeben statt in einem sammelarray
- */
- $staffelpreise = $this->app->DB->SelectArr("
+ /**
+ * @deprecated 20.3
+ * Staffelpreise werden gesondert uebergeben statt in einem sammelarray
+ */
+ $staffelpreise = $this->app->DB->SelectArr("
SELECT a.name AS kundenname, a.email, v.adresse, g.name,g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, art.umsatzsteuer
FROM `verkaufspreise` AS v
INNER JOIN artikel art ON v.artikel = art.id
@@ -1744,63 +1591,62 @@ class Remote
WHERE v.`artikel` = '$artikel' AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab)) ORDER by g.id, ab_menge");
- if(!empty($staffelpreise)){
- foreach ($staffelpreise as $k => $v) {
- if(empty($v['adresse'])){
- $data[$i]['staffelpreise'][] = array('ab_menge' => $v['ab_menge'], 'preis' => $v['preis'], 'bruttopreis' => $v['preis'] * $steuer, 'waehrung' => ($v['waehrung'] ? $v['waehrung'] : 'EUR'));
- if($v['id']){
- $data[$i]['staffelpreise'][count($data[$i]['staffelpreise']) - 1]['gruppenkennziffer'] = $v['kennziffer'];
- $data[$i]['staffelpreise'][count($data[$i]['staffelpreise']) - 1]['gruppenname'] = $v['name'];
+ if (!empty($staffelpreise)) {
+ foreach ($staffelpreise as $k => $v) {
+ if (empty($v['adresse'])) {
+ $data[$i]['staffelpreise'][] = array('ab_menge' => $v['ab_menge'], 'preis' => $v['preis'], 'bruttopreis' => $v['preis'] * $steuer, 'waehrung' => ($v['waehrung'] ? $v['waehrung'] : 'EUR'));
+ if ($v['id']) {
+ $data[$i]['staffelpreise'][count($data[$i]['staffelpreise']) - 1]['gruppenkennziffer'] = $v['kennziffer'];
+ $data[$i]['staffelpreise'][count($data[$i]['staffelpreise']) - 1]['gruppenname'] = $v['name'];
+ }
+ }
+ }
+ }
+ /**
+ * @deprecated Ende
+ */
+ }
+
+
+ $data[$i]['bruttopreis'] = $data[$i]['preis'] * $steuer;
+ }
+ $data[$i]['checksum'] = $tmp->GetChecksum();
+ if ($data[$i]['preis'] == '' && !empty($artikelexport) && !$nurlager) {
+ if ($lagerexport) {
+ $nurlager = true;
+ } else {
+ $this->app->erp->Systemlog(
+ 'Shopexport bei Artikel ' . $data[$i]['nummer'] . ' ' . $data[$i]['name_de'] . ' fehlgeschlagen, da Verkaufspreis fehlt.'
+ );
+ $data[$i]['artikel'] = 'ignore';
}
- }
}
- }
- /**
- * @deprecated Ende
- */
- }
+ $steuerermaessigt = ($this->app->erp->GetStandardSteuersatzErmaessigt($projekt) + 100) / 100.0;
+ $steuernormal = ($this->app->erp->GetStandardSteuersatzNormal($projekt) + 100) / 100.0;
+ $steuermapping = [
+ 'befreit' => 1,
+ 'ermaessigt' => $steuerermaessigt,
+ 'normal' => $steuernormal
+ ];
- $data[$i]['bruttopreis'] = $data[$i]['preis'] * $steuer;
- }
- $data[$i]['checksum'] = $tmp->GetChecksum();
- if ($data[$i]['preis'] == '' && !empty($artikelexport) && !$nurlager) {
- if($lagerexport){
- $nurlager = true;
- } else {
- $this->app->erp->Systemlog(
- 'Shopexport bei Artikel ' . $data[$i]['nummer'] . ' ' . $data[$i]['name_de'] . ' fehlgeschlagen, da Verkaufspreis fehlt.'
- );
- $data[$i]['artikel'] = 'ignore';
- }
- }
+ if (!empty($loadElements['variants']) && !empty($shopexportarr['variantenuebertragen']) && $this->app->erp->ModulVorhanden('matrixprodukt') && $tmp->GetMatrixprodukt()) {
+ $artfreifeld = '';
+ for ($_i = 1; $_i <= 40; $_i++) {
+ $artfreifeld .= sprintf(' art.freifeld%d AS `freifeld%d`, ', $_i, $_i);
+ }
+ $varianten = null;
- $steuerermaessigt = ($this->app->erp->GetStandardSteuersatzErmaessigt($projekt) + 100) / 100.0;
- $steuernormal = ($this->app->erp->GetStandardSteuersatzNormal($projekt) + 100) / 100.0;
- $steuermapping = [
- 'befreit' => 1,
- 'ermaessigt' => $steuerermaessigt,
- 'normal' => $steuernormal
- ];
+ $data[$i]['artikel_varianten'] = [];
+ $db = $this->app->Container->get('Database');
- if (!empty($loadElements['variants']) && !empty($shopexportarr['variantenuebertragen'])
- && $this->app->erp->ModulVorhanden('matrixprodukt') && $tmp->GetMatrixprodukt()) {
- $artfreifeld = '';
- for ($_i = 1; $_i <= 40; $_i++) {
- $artfreifeld .= sprintf(' art.freifeld%d AS `freifeld%d`, ',$_i,$_i);
- }
- $varianten = null;
+ $offset = 0;
+ $eigenschaftind = 0;
- $data[$i]['artikel_varianten'] = [];
- $db = $this->app->Container->get('Database');
+ $gruppenuebersetzung = [];
+ $gruppenwertuebersetzung = [];
- $offset = 0;
- $eigenschaftind = 0;
-
- $gruppenuebersetzung = [];
- $gruppenwertuebersetzung = [];
-
- $query = sprintf('SELECT meoa.name AS wert,meoa.name_ext AS wert_ext, mega.name AS gruppe, mega.name_ext AS gruppe_ext
+ $query = sprintf('SELECT meoa.name AS wert,meoa.name_ext AS wert_ext, mega.name AS gruppe, mega.name_ext AS gruppe_ext
FROM matrixprodukt_optionen_zu_artikel AS moza
JOIN matrixprodukt_eigenschaftenoptionen_artikel AS meoa ON moza.option_id = meoa.id
JOIN matrixprodukt_eigenschaftengruppen_artikel AS mega ON mega.id = meoa.gruppe
@@ -1808,42 +1654,42 @@ class Remote
WHERE art.variante_von=%d ANd art.geloescht=0 AND art.nummer <> "DEL" AND art.intern_gesperrt=0
GROUP BY mega.id, meoa.id
ORDER BY SUM(POW(10,1-mega.sort) * meoa.sort) ASC', $artikel);
- foreach ($db->yieldAll($query) as $matrixdaten) {
- $data[$i]['matrix_varianten']['gruppen'][$matrixdaten['gruppe']][$matrixdaten['wert']] = true;
+ foreach ($db->yieldAll($query) as $matrixdaten) {
+ $data[$i]['matrix_varianten']['gruppen'][$matrixdaten['gruppe']][$matrixdaten['wert']] = true;
- if (!empty($loadElements['translations'])) {
- if (empty($gruppenuebersetzung[$matrixdaten['gruppe']])) {
- $gruppennamen = $this->app->DB->SelectArr("SELECT
+ if (!empty($loadElements['translations'])) {
+ if (empty($gruppenuebersetzung[$matrixdaten['gruppe']])) {
+ $gruppennamen = $this->app->DB->SelectArr("SELECT
IF(name_external_from<>'',name_external_from,name_from) AS name_from,
IF(name_external_to<>'',name_external_to,name_to) AS name_to, language_to
FROM `matrix_article_translation`
WHERE name_from='" . $matrixdaten['gruppe'] . "' AND (project=0 OR project='$projekt')");
- $gruppenuebersetzung[$matrixdaten['gruppe']] = true;
- if (!empty($gruppennamen)) {
- foreach ($gruppennamen as $gruppenname) {
- $data[$i]['matrix_varianten']['texte']['gruppen'][$gruppenname['language_to']][$gruppenname['name_from']] = $gruppenname['name_to'];
- }
- }
- }
- if (empty($gruppenwertuebersetzung[$matrixdaten['wert']])) {
- $gruppenwerte = $this->app->DB->SelectArr("SELECT
+ $gruppenuebersetzung[$matrixdaten['gruppe']] = true;
+ if (!empty($gruppennamen)) {
+ foreach ($gruppennamen as $gruppenname) {
+ $data[$i]['matrix_varianten']['texte']['gruppen'][$gruppenname['language_to']][$gruppenname['name_from']] = $gruppenname['name_to'];
+ }
+ }
+ }
+ if (empty($gruppenwertuebersetzung[$matrixdaten['wert']])) {
+ $gruppenwerte = $this->app->DB->SelectArr("SELECT
IF(maot.name_external_from<>'',maot.name_external_from,maot.name_from) AS `name_from`,
IF(maot.name_external_to<>'',maot.name_external_to,maot.name_to) AS `name_to`, maot.language_to
FROM `matrix_article_options_translation` AS `maot`
WHERE maot.name_from='" . $this->app->DB->real_escape_string($matrixdaten['wert']) . "'");
- $gruppenwertuebersetzung[$matrixdaten['wert']] = true;
- foreach ($gruppenwerte as $gruppenwert) {
- $data[$i]['matrix_varianten']['texte']['werte'][$gruppenwert['language_to']][$gruppenwert['name_from']] = $gruppenwert['name_to'];
- }
- }
- }
- }
+ $gruppenwertuebersetzung[$matrixdaten['wert']] = true;
+ foreach ($gruppenwerte as $gruppenwert) {
+ $data[$i]['matrix_varianten']['texte']['werte'][$gruppenwert['language_to']][$gruppenwert['name_from']] = $gruppenwert['name_to'];
+ }
+ }
+ }
+ }
- do {
- unset($data[$i]['matrix_varianten']['artikel']);
- unset($data[$i]['artikel_varianten']);
- //if($this->app->DB->Select("SELECT variantenuebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
- $varianten = "SELECT art.pseudolager AS `pseudolager`, art.nummer AS `nummer`, art.inaktiv AS `inaktiv`,
+ do {
+ unset($data[$i]['matrix_varianten']['artikel']);
+ unset($data[$i]['artikel_varianten']);
+ //if($this->app->DB->Select("SELECT variantenuebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
+ $varianten = "SELECT art.pseudolager AS `pseudolager`, art.nummer AS `nummer`, art.inaktiv AS `inaktiv`,
art.id AS `artikel`, art.gewicht AS `gewicht`, art.zolltarifnummer AS `zolltarifnummer`, art.name_en AS `name_en`,
$artfreifeld
art.pseudopreis AS `pseudopreis`, art.lieferzeitmanuell AS `lieferzeitmanuell`, art.altersfreigabe AS `altersfreigabe`,
@@ -1870,77 +1716,75 @@ class Remote
GROUP BY art.id
ORDER BY SUM(POW(10,1-mega.sort) * meoa.sort) ASC
LIMIT 5000 OFFSET $offset";
- $offset += 5000;
+ $offset += 5000;
- foreach ($db->yieldAll($varianten) as $eigenschaft) {
- $eigenschaftind++;
- $steuer = $steuermapping[$eigenschaft['umsatzsteuer']];
- if(!empty($eigenschaft['steuersatz']) && $eigenschaft['steuersatz'] != -1){
- $steuer = ($eigenschaft['steuersatz'] + 100) / 100;
- }
- if (empty($steuer)) {
- $steuer = $steuernormal;
- }
- $matrixPseudoStorage = $eigenschaft['pseudolager'];
- $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $eigenschaft['artikel'], $matrixPseudoStorage);
- if(is_numeric($matrixPseudoStorage) && $matrixPseudoStorage < 0) {
- $matrixPseudoStorage = 0;
- }
- if($matrixStock < 0) {
- $matrixStock = 0;
- }
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][] =
- array('zolltarifnummer' => $eigenschaft['zolltarifnummer'], 'gewicht' => $eigenschaft['gewicht'],
- 'artikel' => $eigenschaft['artikel'], 'preis' => $eigenschaft['preis'], 'gesperrt' => $eigenschaft['gesperrt'],
- 'nummer' => $eigenschaft['nummer'], 'lieferzeitmanuell' => $eigenschaft['lieferzeitmanuell'],
- 'altersfreigabe' => $eigenschaft['altersfreigabe'], 'ean' => $eigenschaft['ean'],
- 'lag' => $matrixStock,
- 'pseudolager' => $matrixPseudoStorage, 'pseudopreis' => $eigenschaft['pseudopreis'],
- 'restmenge' => $eigenschaft['restmenge'], 'steuersatz' => ($steuer - 1) * 100, 'umsatzsteuer' => $eigenschaft['umsatzsteuer'],
- 'bruttopreis' => $eigenschaft['preis'] * $steuer, 'inaktiv' => $eigenschaft['inaktiv'],
- 'name_de' => $eigenschaft['name_de'], 'name_en' => $eigenschaft['name_en'],
- 'uebersicht_de' => $eigenschaft['uebersicht_de'], 'uebersicht_en' => $eigenschaft['uebersicht_en']);
- if ($freifelder) {
- foreach ($freifelder as $freifeld) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']]) - 1]['freifelder']['DE'][$freifeld['freifeld_shop']] =
- $this->app->DB->Select('SELECT ' . $freifeld['freifeld_wawi'] . ' FROM artikel WHERE id=' . $eigenschaft['artikel']);
- }
+ foreach ($db->yieldAll($varianten) as $eigenschaft) {
+ $eigenschaftind++;
+ $steuer = $steuermapping[$eigenschaft['umsatzsteuer']];
+ if (!empty($eigenschaft['steuersatz']) && $eigenschaft['steuersatz'] != -1) {
+ $steuer = ($eigenschaft['steuersatz'] + 100) / 100;
+ }
+ if (empty($steuer)) {
+ $steuer = $steuernormal;
+ }
+ $matrixPseudoStorage = $eigenschaft['pseudolager'];
+ $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $eigenschaft['artikel'], $matrixPseudoStorage);
+ if (is_numeric($matrixPseudoStorage) && $matrixPseudoStorage < 0) {
+ $matrixPseudoStorage = 0;
+ }
+ if ($matrixStock < 0) {
+ $matrixStock = 0;
+ }
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][] = array('zolltarifnummer' => $eigenschaft['zolltarifnummer'], 'gewicht' => $eigenschaft['gewicht'],
+ 'artikel' => $eigenschaft['artikel'], 'preis' => $eigenschaft['preis'], 'gesperrt' => $eigenschaft['gesperrt'],
+ 'nummer' => $eigenschaft['nummer'], 'lieferzeitmanuell' => $eigenschaft['lieferzeitmanuell'],
+ 'altersfreigabe' => $eigenschaft['altersfreigabe'], 'ean' => $eigenschaft['ean'],
+ 'lag' => $matrixStock,
+ 'pseudolager' => $matrixPseudoStorage, 'pseudopreis' => $eigenschaft['pseudopreis'],
+ 'restmenge' => $eigenschaft['restmenge'], 'steuersatz' => ($steuer - 1) * 100, 'umsatzsteuer' => $eigenschaft['umsatzsteuer'],
+ 'bruttopreis' => $eigenschaft['preis'] * $steuer, 'inaktiv' => $eigenschaft['inaktiv'],
+ 'name_de' => $eigenschaft['name_de'], 'name_en' => $eigenschaft['name_en'],
+ 'uebersicht_de' => $eigenschaft['uebersicht_de'], 'uebersicht_en' => $eigenschaft['uebersicht_en']);
+ if ($freifelder) {
+ foreach ($freifelder as $freifeld) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']]) - 1]['freifelder']['DE'][$freifeld['freifeld_shop']] = $this->app->DB->Select('SELECT ' . $freifeld['freifeld_wawi'] . ' FROM artikel WHERE id=' . $eigenschaft['artikel']);
+ }
- //Freifeldübersetzungen
- $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '" . $eigenschaft['artikel'] . "' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
- if (!empty($freifelduebersetzungen)) {
- foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']]) - 1]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
- }
- }
- }
+ //Freifeldübersetzungen
+ $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '" . $eigenschaft['artikel'] . "' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
+ if (!empty($freifelduebersetzungen)) {
+ foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']]) - 1]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
+ }
+ }
+ }
- if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
- $dateien = $this->getImagesForArticle($eigenschaft['artikel']);
- if (!empty($dateien)) {
- foreach ($dateien as $datei) {
- $filename = $this->app->erp->GetDateiName($datei['id']);
- $path_info = pathinfo($filename);
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['datei'][] = base64_encode($this->app->erp->GetDatei($datei['id']));
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['filename'][] = $filename;
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['extension'][] = $path_info['extension'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['titel'][] = $datei['titel'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['beschreibung'][] = $datei['beschreibung'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['stichwort'][] = $datei['subjekt'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['id'][] = $datei['id'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['version'][] = $datei['version'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['extid'][] = $this->GetShopexportMappingExt($id, 'datei', $datei['id']);
- }
- }
- }
+ if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
+ $dateien = $this->getImagesForArticle($eigenschaft['artikel']);
+ if (!empty($dateien)) {
+ foreach ($dateien as $datei) {
+ $filename = $this->app->erp->GetDateiName($datei['id']);
+ $path_info = pathinfo($filename);
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['datei'][] = base64_encode($this->app->erp->GetDatei($datei['id']));
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['filename'][] = $filename;
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['extension'][] = $path_info['extension'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['titel'][] = $datei['titel'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['beschreibung'][] = $datei['beschreibung'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['stichwort'][] = $datei['subjekt'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['id'][] = $datei['id'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['version'][] = $datei['version'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']['extid'][] = $this->GetShopexportMappingExt($id, 'datei', $datei['id']);
+ }
+ }
+ }
- $standardstaffelpreise = null;
- if(!empty($loadElements['standard_price'])){
- $preisgruppenzusatz = " AND v.art = 'Kunde' AND v.adresse = 0";
- if(!empty($preisgruppe)){
- $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
- }
- $standardstaffelpreise = $this->app->DB->SelectArr("
+ $standardstaffelpreise = null;
+ if (!empty($loadElements['standard_price'])) {
+ $preisgruppenzusatz = " AND v.art = 'Kunde' AND v.adresse = 0";
+ if (!empty($preisgruppe)) {
+ $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
+ }
+ $standardstaffelpreise = $this->app->DB->SelectArr("
SELECT v.adresse, g.name,g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, art.umsatzsteuer
FROM `verkaufspreise` AS v
INNER JOIN artikel art ON v.artikel = art.id
@@ -1948,20 +1792,20 @@ class Remote
WHERE v.`artikel` = '" . $eigenschaft['artikel'] . "' AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND v.adresse=0 AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab)) $preisgruppenzusatz
ORDER by g.id, ab_menge");
- }
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_standard'] = [];
- if (!empty($standardstaffelpreise)) {
- foreach ($standardstaffelpreise as $staffelpreis) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_standard'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR'
- ];
- }
- }
- if(!empty($loadElements['bulk_prices'])){
- $staffelpreisekunden = $this->app->DB->SelectArr("
+ }
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_standard'] = [];
+ if (!empty($standardstaffelpreise)) {
+ foreach ($standardstaffelpreise as $staffelpreis) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_standard'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR'
+ ];
+ }
+ }
+ if (!empty($loadElements['bulk_prices'])) {
+ $staffelpreisekunden = $this->app->DB->SelectArr("
SELECT a.name AS kundenname, a.email, v.adresse, v.ab_menge, v.preis, v.waehrung, art.umsatzsteuer
FROM `verkaufspreise` AS v
INNER JOIN artikel art ON v.artikel = art.id
@@ -1969,20 +1813,20 @@ class Remote
WHERE v.`artikel` = '" . $eigenschaft['artikel'] . "' AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab))
ORDER by v.adresse, ab_menge");
- if(!empty($staffelpreisekunden)){
- foreach ($staffelpreisekunden as $staffelpreis) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_kunden'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
- 'email' => $staffelpreis['email'],
- 'kundenname' => $staffelpreis['kundenname']
- ];
- }
- }
+ if (!empty($staffelpreisekunden)) {
+ foreach ($staffelpreisekunden as $staffelpreis) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_kunden'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
+ 'email' => $staffelpreis['email'],
+ 'kundenname' => $staffelpreis['kundenname']
+ ];
+ }
+ }
- $staffelpreisegruppen = $this->app->DB->SelectArr("
+ $staffelpreisegruppen = $this->app->DB->SelectArr("
SELECT g.name,g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, art.umsatzsteuer,sk.extgruppename
FROM `verkaufspreise` AS v
INNER JOIN artikel art ON v.artikel = art.id
@@ -1991,217 +1835,212 @@ class Remote
WHERE v.`artikel` = '" . $eigenschaft['artikel'] . "' AND v.geloescht = 0 AND (v.gueltig_bis = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND v.art like 'Gruppe' AND v.gruppe<>'$preisgruppe' AND sk.shopid='$id' AND sk.aktiv=1 AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab))
ORDER by g.id, ab_menge");
- if(!empty($staffelpreisegruppen)){
- foreach ($staffelpreisegruppen as $staffelpreis) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_gruppen'][] = [
- 'ab_menge' => $staffelpreis['ab_menge'],
- 'preis' => $staffelpreis['preis'],
- 'bruttopreis' => $staffelpreis['preis'] * $steuer,
- 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
- 'kennziffer' => $staffelpreis['kennziffer'],
- 'gruppenname' => $staffelpreis['name'],
- 'gruppeextern' => $staffelpreis['extgruppename']
- ];
- }
- }
- }
- $staffelpreisema = null;
- if (!empty($shopexportarr['crosssellingartikeluebertragen']) && !empty($loadElements['cross_selling'])) {
- //if($this->app->DB->Select("SELECT crosssellingartikeluebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
- $preisgruppenzusatz = '';
- if (!empty($preisgruppe)) {
- $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
- }
- $staffelpreisema = $this->app->DB->SelectArr("
+ if (!empty($staffelpreisegruppen)) {
+ foreach ($staffelpreisegruppen as $staffelpreis) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise_gruppen'][] = [
+ 'ab_menge' => $staffelpreis['ab_menge'],
+ 'preis' => $staffelpreis['preis'],
+ 'bruttopreis' => $staffelpreis['preis'] * $steuer,
+ 'waehrung' => $staffelpreis['waehrung'] ?: 'EUR',
+ 'kennziffer' => $staffelpreis['kennziffer'],
+ 'gruppenname' => $staffelpreis['name'],
+ 'gruppeextern' => $staffelpreis['extgruppename']
+ ];
+ }
+ }
+ }
+ $staffelpreisema = null;
+ if (!empty($shopexportarr['crosssellingartikeluebertragen']) && !empty($loadElements['cross_selling'])) {
+ //if($this->app->DB->Select("SELECT crosssellingartikeluebertragen FROM shopexport WHERE id = '$id' LIMIT 1")){
+ $preisgruppenzusatz = '';
+ if (!empty($preisgruppe)) {
+ $preisgruppenzusatz = " AND v.gruppe = '$preisgruppe'";
+ }
+ $staffelpreisema = $this->app->DB->SelectArr("
SELECT g.name, g.kennziffer, v.ab_menge, v.preis, g.id, v.waehrung, v.id, v.adresse, v.art, sk.extgruppename
FROM `verkaufspreise` AS v
LEFT JOIN gruppen g on v.gruppe = g.id AND v.art like 'Gruppe'
LEFT JOIN shopexport_kundengruppen sk ON sk.gruppeid=v.gruppe
WHERE v.`artikel` = '" . $eigenschaft['artikel'] . "' AND v.geloescht = 0 AND (ifnull(v.gueltig_bis,'0000-00-00') = '0000-00-00' OR curdate() <= v.gueltig_bis OR isnull(v.gueltig_bis))
AND (v.gueltig_ab = '0000-00-00' OR curdate() >= v.gueltig_ab OR isnull(v.gueltig_ab)) $preisgruppenzusatz ORDER by g.id, ab_menge");
- }
- if (!empty($staffelpreisema)) {
- foreach ($staffelpreisema as $k => $v) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][] = array('ab_menge' => $v['ab_menge'], 'preis' => $v['preis'], 'bruttopreis' => $v['preis'] * $steuer, 'waehrung' => ($v['waehrung'] ? $v['waehrung'] : 'EUR'));
- if ($v['id']) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppenkennziffer'] = $v['kennziffer'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppenname'] = $v['name'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['adresse'] = $v['adresse'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['art'] = $v['art'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppeextern'] = $v['extgruppename'];
- }
- }
- }
+ }
+ if (!empty($staffelpreisema)) {
+ foreach ($staffelpreisema as $k => $v) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][] = array('ab_menge' => $v['ab_menge'], 'preis' => $v['preis'], 'bruttopreis' => $v['preis'] * $steuer, 'waehrung' => ($v['waehrung'] ? $v['waehrung'] : 'EUR'));
+ if ($v['id']) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppenkennziffer'] = $v['kennziffer'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppenname'] = $v['name'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['adresse'] = $v['adresse'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['art'] = $v['art'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise'][count($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['staffelpreise']) - 1]['gruppeextern'] = $v['extgruppename'];
+ }
+ }
+ }
- $articleVariant = $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0];
- $articleVariant['artikel'] = $eigenschaft['artikel'];
- $data[$i]['artikel_varianten'][] = $articleVariant;
- unset($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']);
+ $articleVariant = $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0];
+ $articleVariant['artikel'] = $eigenschaft['artikel'];
+ $data[$i]['artikel_varianten'][] = $articleVariant;
+ unset($data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][0]['Dateien']);
-
- $query = sprintf('SELECT meoa.name AS wert,meoa.name_ext AS wert_ext, mega.name AS gruppe, mega.name_ext AS gruppe_ext
+ $query = sprintf('SELECT meoa.name AS wert,meoa.name_ext AS wert_ext, mega.name AS gruppe, mega.name_ext AS gruppe_ext
FROM matrixprodukt_optionen_zu_artikel AS moza
JOIN matrixprodukt_eigenschaftenoptionen_artikel AS meoa ON moza.option_id = meoa.id
JOIN matrixprodukt_eigenschaftengruppen_artikel AS mega ON mega.id = meoa.gruppe
WHERE moza.artikel=%d
ORDER BY mega.id, moza.id', $eigenschaft['artikel']);
- $matrixdaten = $this->app->DB->SelectArr($query);
+ $matrixdaten = $this->app->DB->SelectArr($query);
- for ($iv = 0, $ivMax = (!empty($matrixdaten)?count($matrixdaten):0); $iv < $ivMax; $iv++) {
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][$iv]['name'] = $matrixdaten[$iv]['gruppe'];
- $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][$iv]['values'] = $matrixdaten[$iv]['wert'];
+ for ($iv = 0, $ivMax = (!empty($matrixdaten) ? count($matrixdaten) : 0); $iv < $ivMax; $iv++) {
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][$iv]['name'] = $matrixdaten[$iv]['gruppe'];
+ $data[$i]['matrix_varianten']['artikel'][$eigenschaft['artikel']][$iv]['values'] = $matrixdaten[$iv]['wert'];
+ }
+ }
+
+ $result = null;
+ if (empty($data)) {
+ continue;
+ }
+ if (!empty($lagerexport)) {
+ $result = $this->sendlistlager($i, $id, $data);
+ }
+ if (!empty($artikelexport) && !$nurlager) {
+ $result = $this->sendlist($i, $id, $data, true);
+ }
+ } while (count($data[$i]['matrix_varianten']['artikel'] ?? []) >= 5000);
+
+ return $result;
}
- }
- $result = null;
- if(empty($data)) {
- continue;
- }
- if (!empty($lagerexport)) {
- $result = $this->sendlistlager($i, $id, $data);
- }
- if (!empty($artikelexport) && !$nurlager) {
- $result = $this->sendlist($i, $id, $data, true);
- }
+ if (!empty($loadElements['variants']) && $this->app->DB->Select("SELECT id FROM artikel WHERE variante_von = '$artikel' AND variante = 1 AND geloescht <> 1 AND nummer != 'DEL' LIMIT 1")) {
+ if ($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikel' AND variante = 0 AND matrixprodukt=0 AND geloescht <> 1 AND nummer != 'DEL' LIMIT 1")) {
+ $data[$i]['artikel_varianten'] = [];
+ $data[$i]['variantevorhanden'] = 1;
+ $varianten = "SELECT * FROM artikel WHERE variante_von = '$artikel' AND variante = 1 AND geloescht <> 1 AND nummer != 'DEL'";
+ $db = $this->app->Container->get('Database');
+ foreach ($db->yieldAll($varianten) as $v) {
+ $steuer = $steuermapping[$v['umsatzsteuer']];
+ if ($v['steuersatz'] != -1 && !empty($v['steuersatz'])) {
+ $steuer = ($v['steuersatz'] + 100) / 100;
+ }
+ if (empty($steuer)) {
+ $steuer = $steuernormal;
+ }
+ $variantennettopreis = null;
+ if (!empty($loadElements['standard_price'])) {
+ if ($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')) {
+ $variantennettopreis = $this->app->erp->GetVerkaufspreisGruppe($v['id'], 1, $preisgruppe);
+ } else {
+ $variantennettopreis = $this->app->erp->GetVerkaufspreis($v['id'], 1, 0);
+ }
+ }
+ $sprachen = ['de', 'en'];
+ foreach ($sprachen as $sprache) {
+ $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
+ $id, strtoupper($sprache), $v['id']);
+ $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
+ if (!empty($ersetzeStandardbeschreibung)) {
+ $v['name_' . $sprache] = $ersetzeStandardbeschreibung['name'];
+ }
+ }
- } while (count($data[$i]['matrix_varianten']['artikel'] ?? [])>=5000);
+ $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $v['id'], $v['pseudolager']);
+ if (is_numeric($v['pseudolager']) && $v['pseudolager'] < 0) {
+ $v['pseudolager'] = 0;
+ }
+ $projectStockId = $this->app->DB->Select("SELECT `id` FROM `projekt` WHERE `id` = '{$projekt}' AND `projektlager` = 1 LIMIT 1");
+ $stock = (float) $this->app->erp->ArtikelAnzahlVerkaufbar(
+ $v['id'],
+ 0,
+ $projectStockId,
+ $id,
+ $lagergrundlage
+ );
+ if ($stock < 0) {
+ $stock = 0;
+ }
+ $data[$i]['artikel_varianten'][] = array('nummer' => $v['nummer'], 'name_de' => $v['name_de'], 'name_en' => $v['name_en'], 'restmenge' => $v['restmenge'], 'gesperrt' => ($v['gesperrt'] == 1 || $v['intern_gesperrt'] == 1 ? 1 : 0),
+ 'artikel' => $v['id'], 'zolltarifnummer' => $v['zolltarifnummer'], 'ean' => $v['ean'], 'gewicht' => $v['gewicht'], 'inaktiv' => $v['inaktiv'], 'uebersicht_de' => $v['uebersicht_de'],
+ 'lag' => $stock,
+ 'pseudolager' => $v['pseudolager'], 'pseudopreis' => $v['pseudopreis'], 'preis' => $variantennettopreis, 'bruttopreis' => $variantennettopreis * $steuer,
+ 'artikelnummer_fremdnummern' => $this->app->DB->SelectArr("SELECT * FROM artikelnummer_fremdnummern WHERE artikel = '" . $v['id'] . "' AND nummer <> '' AND shopid = '$id' AND aktiv = '1'"),
+ 'steuersatz' => ($steuer - 1) * 100);
+ if (!empty($data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['artikelnummer_fremdnummern'])) {
+ foreach ($data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['artikelnummer_fremdnummern'] as $fkey => $fval) {
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['artikelnummer_fremdnummern'][$fkey]['nummer'] = trim($fval['nummer']);
+ }
+ }
+ if ($eigenschaftenuebertragen && !empty($loadElements['properties'])) {
+ $varianteneigenschaften = $this->app->DB->SelectArr("SELECT e.name, ew.wert FROM artikeleigenschaften e INNER JOIN artikeleigenschaftenwerte ew ON e.id = ew.artikeleigenschaften
+ WHERE ew.artikel = '" . $v['id'] . "' AND e.name <> '' AND ew.wert <> '' AND e.geloescht <> 1 ORDER BY e.name");
+ if (!empty($varianteneigenschaften)) {
+ foreach ($varianteneigenschaften as $eigenschaft) {
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['eigenschaften'][] = array('name' => $eigenschaft['name'], 'values' => $eigenschaft['wert']);
+ }
+ }
+ $eigenschaftenuebersetzungen = $this->app->DB->SelectArr("SELECT language_from, language_to, property_from, property_to,property_value_from,property_value_to FROM article_property_translation WHERE article_id = '" . $v['id'] . "'");
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['eigenschaftenuebersetzungen'] = $eigenschaftenuebersetzungen;
+ }
+
+ if (!empty($freifelder) && !empty($loadElements['free_fields'])) {
+ foreach ($freifelder as $freifeld) {
+ if (method_exists($tmp, 'Get' . ucfirst($freifeld['freifeld_wawi']))) {
+ $_funktionsname = 'Get' . ucfirst($freifeld['freifeld_wawi']);
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['freifelder']['DE'][$freifeld['freifeld_shop']] = $v[$freifeld['freifeld_wawi']];
+ }
+ }
+ //Freifeldübersetzungen
+ $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '" . $v['id'] . "' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
+ if (!empty($freifelduebersetzungen)) {
+ foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
+ }
+ }
+ }
+ if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
+ $dateien = $this->getImagesForArticle($v['id']);
+ if (!empty($dateien)) {
+ foreach ($dateien as $datei) {
+ $filename = $this->app->erp->GetDateiName($datei['id']);
+ $path_info = pathinfo($filename);
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['datei'][] = base64_encode($this->app->erp->GetDatei($datei['id']));
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['filename'][] = $filename;
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['extension'][] = $path_info['extension'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['titel'][] = $datei['titel'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['beschreibung'][] = $datei['beschreibung'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['stichwort'][] = $datei['subjekt'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['id'][] = $datei['id'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['version'][] = $datei['version'];
+ $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['extid'][] = $this->GetShopexportMappingExt($id, 'datei', $datei['id']);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ $data[$i]['variantevorhanden'] = 0;
+ }
+
+ $result = null;
+ if (empty($data)) {
+ continue;
+ }
+ if (!empty($lagerexport)) {
+ $result = $this->sendlistlager($i, $id, $data);
+ }
+ if (!empty($artikelexport) && !$nurlager) {
+ $result = $this->sendlist($i, $id, $data, true);
+ }
+ }
return $result;
- }
-
- if(!empty($loadElements['variants']) && $this->app->DB->Select("SELECT id FROM artikel WHERE variante_von = '$artikel' AND variante = 1 AND geloescht <> 1 AND nummer != 'DEL' LIMIT 1")) {
- if($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikel' AND variante = 0 AND matrixprodukt=0 AND geloescht <> 1 AND nummer != 'DEL' LIMIT 1")){
- $data[$i]['artikel_varianten'] = [];
- $data[$i]['variantevorhanden'] = 1;
- $varianten = "SELECT * FROM artikel WHERE variante_von = '$artikel' AND variante = 1 AND geloescht <> 1 AND nummer != 'DEL'";
- $db = $this->app->Container->get('Database');
- foreach ($db->yieldAll($varianten) as $v) {
- $steuer = $steuermapping[$v['umsatzsteuer']];
- if($v['steuersatz'] != -1 && !empty($v['steuersatz'])){
- $steuer = ($v['steuersatz'] + 100) / 100;
- }
- if(empty($steuer)) {
- $steuer = $steuernormal;
- }
- $variantennettopreis = null;
- if(!empty($loadElements['standard_price'])){
- if($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')){
- $variantennettopreis = $this->app->erp->GetVerkaufspreisGruppe($v['id'], 1, $preisgruppe);
- }else{
- $variantennettopreis = $this->app->erp->GetVerkaufspreis($v['id'], 1, 0);
- }
- }
- $sprachen = ['de','en'];
- foreach ($sprachen as $sprache){
- $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
- $id,strtoupper($sprache),$v['id']);
- $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
- if(!empty($ersetzeStandardbeschreibung)) {
- $v['name_'.$sprache] = $ersetzeStandardbeschreibung['name'];
- }
- }
-
- $this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $v['id'], $v['pseudolager']);
- if(is_numeric($v['pseudolager']) && $v['pseudolager'] < 0) {
- $v['pseudolager'] = 0;
- }
- $projectStockId = $this->app->DB->Select("SELECT `id` FROM `projekt` WHERE `id` = '{$projekt}' AND `projektlager` = 1 LIMIT 1");
- $stock = (float)$this->app->erp->ArtikelAnzahlVerkaufbar(
- $v['id'],
- 0,
- $projectStockId,
- $id,
- $lagergrundlage
- );
- if($stock < 0) {
- $stock = 0;
- }
- $data[$i]['artikel_varianten'][] = array('nummer' => $v['nummer'], 'name_de' => $v['name_de'], 'name_en' => $v['name_en'],'restmenge' => $v['restmenge'], 'gesperrt' => ($v['gesperrt']==1||$v['intern_gesperrt']==1?1:0),
- 'artikel' => $v['id'],'zolltarifnummer' => $v['zolltarifnummer'],'ean' => $v['ean'],'gewicht' => $v['gewicht'], 'inaktiv' => $v['inaktiv'], 'uebersicht_de' => $v['uebersicht_de'],
- 'lag' => $stock,
- 'pseudolager' => $v['pseudolager'], 'pseudopreis' => $v['pseudopreis'], 'preis' => $variantennettopreis, 'bruttopreis' => $variantennettopreis * $steuer,
- 'artikelnummer_fremdnummern' => $this->app->DB->SelectArr("SELECT * FROM artikelnummer_fremdnummern WHERE artikel = '" . $v['id'] . "' AND nummer <> '' AND shopid = '$id' AND aktiv = '1'"),
- 'steuersatz' => ($steuer - 1) * 100);
- if(!empty($data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten'])-1]['artikelnummer_fremdnummern'])) {
- foreach($data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten'])-1]['artikelnummer_fremdnummern'] as $fkey => $fval) {
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten'])-1]['artikelnummer_fremdnummern'][$fkey]['nummer'] = trim($fval['nummer']);
- }
- }
- if($eigenschaftenuebertragen && !empty($loadElements['properties'])){
- $varianteneigenschaften = $this->app->DB->SelectArr("SELECT e.name, ew.wert FROM artikeleigenschaften e INNER JOIN artikeleigenschaftenwerte ew ON e.id = ew.artikeleigenschaften
- WHERE ew.artikel = '".$v['id']."' AND e.name <> '' AND ew.wert <> '' AND e.geloescht <> 1 ORDER BY e.name");
- if(!empty($varianteneigenschaften)){
- foreach($varianteneigenschaften as $eigenschaft){
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['eigenschaften'][] = array('name'=>$eigenschaft['name'], 'values'=>$eigenschaft['wert']);
- }
- }
- $eigenschaftenuebersetzungen = $this->app->DB->SelectArr("SELECT language_from, language_to, property_from, property_to,property_value_from,property_value_to FROM article_property_translation WHERE article_id = '".$v['id']."'");
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['eigenschaftenuebersetzungen'] = $eigenschaftenuebersetzungen;
- }
-
- if(!empty($freifelder) && !empty($loadElements['free_fields']))
- {
- foreach($freifelder as $freifeld)
- {
- if(method_exists($tmp,'Get'.ucfirst($freifeld['freifeld_wawi'])))
- {
- $_funktionsname = 'Get'.ucfirst($freifeld['freifeld_wawi']);
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['freifelder']['DE'][$freifeld['freifeld_shop']] = $v[$freifeld['freifeld_wawi']];
- }
- }
- //Freifeldübersetzungen
- $freifelduebersetzungen = $this->app->DB->SelectArr("SELECT sf.freifeld_shop, af.sprache, af.nummer, af.wert FROM shopexport_freifelder sf JOIN artikel_freifelder af ON sf.freifeld_wawi = CONCAT('freifeld',af.nummer) WHERE sf.shop = '$id' AND af.artikel = '".$v['id']."' AND sf.aktiv = 1 AND sf.freifeld_wawi <> '' AND sf.freifeld_shop <> '' AND af.wert <> ''");
- if(!empty($freifelduebersetzungen)){
- foreach ($freifelduebersetzungen as $ffukey => $ffuvalue) {
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['freifelder'][$ffuvalue['sprache']][] = array('mapping' => $ffuvalue['freifeld_shop'], 'freifeldnummer' => $ffuvalue['nummer'], 'wert' => $ffuvalue['wert']);
- }
- }
- }
- if ($shopbilderuebertragen && !empty($loadElements['pictures'])) {
- $dateien = $this->getImagesForArticle($v['id']);
- if (!empty($dateien)) {
- foreach ($dateien as $datei) {
- $filename = $this->app->erp->GetDateiName($datei['id']);
- $path_info = pathinfo($filename);
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['datei'][] = base64_encode($this->app->erp->GetDatei($datei['id']));
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['filename'][] = $filename;
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['extension'][] = $path_info['extension'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['titel'][] = $datei['titel'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['beschreibung'][] = $datei['beschreibung'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['stichwort'][] = $datei['subjekt'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['id'][] = $datei['id'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['version'][] = $datei['version'];
- $data[$i]['artikel_varianten'][count($data[$i]['artikel_varianten']) - 1]['Dateien']['extid'][] = $this->GetShopexportMappingExt($id, 'datei', $datei['id']);
- }
- }
- }
- }
- }
- }else{
- $data[$i]['variantevorhanden'] = 0;
- }
-
- $result = null;
- if(empty($data)){
- continue;
- }
- if(!empty($lagerexport)) {
- $result = $this->sendlistlager($i, $id, $data);
- }
- if (!empty($artikelexport) && !$nurlager) {
- $result = $this->sendlist($i, $id, $data, true);
- }
}
- return $result;
- }
-
/**
* @param int $articleId
* @return array|null
*/
- protected function getImagesForArticle($articleId){
- $query = sprintf("SELECT d.id AS `id`, dv.id AS `vid`, d.titel, d.beschreibung, ds.subjekt, ds.sort, dv.version AS `version`
+ protected function getImagesForArticle($articleId) {
+ $query = sprintf("SELECT d.id AS `id`, dv.id AS `vid`, d.titel, d.beschreibung, ds.subjekt, ds.sort, dv.version AS `version`
FROM `datei_stichwoerter` AS `ds`
INNER JOIN `datei` AS `d` ON ds.datei = d.id
INNER JOIN `datei_version` AS `dv` ON dv.datei = ds.datei
@@ -2209,117 +2048,111 @@ class Remote
WHERE ds.parameter = %d AND ds.objekt like 'Artikel' AND ds.subjekt LIKE 'Shopbild' AND d.geloescht = 0
ORDER BY ds.sort", $articleId);
- return $this->app->DB->SelectArr($query);
- }
-
- protected function sendlistlager($i,$id,$data){
- $data2 = $data;
- foreach ($data2 as $key => $value){
- $data2[$key]['artikel'] = $value['artikelid'];
+ return $this->app->DB->SelectArr($query);
}
- $result = $this->RemoteCommand($id,'sendlistlager',$data2);
- $this->app->DB->Update(
- sprintf(
- 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
- $data2[$i]['artikel'], $id
- )
- );
- return $result;
- }
- protected function sendlist($i,$id,$data,$isLagerExported){
- /** @var Shopexport $objShopexport */
- $objShopexport = $this->app->loadModule('shopexport');
- $changedHash = $objShopexport->hasArticleHashChanged($data[0]['artikel'], $id);
- $hash = $changedHash['hash'];
- //$changedHash = $changedHash['changed'];
+ protected function sendlistlager($i, $id, $data) {
+ $data2 = $data;
+ foreach ($data2 as $key => $value) {
+ $data2[$key]['artikel'] = $value['artikelid'];
+ }
+ $result = $this->RemoteCommand($id, 'sendlistlager', $data2);
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
+ $data2[$i]['artikel'], $id
+ )
+ );
+ return $result;
+ }
- $result = $this->RemoteCommand($id,'sendlist',$data);
- $checkAo = $this->app->DB->Select(
- sprintf(
- 'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
- $data[0]['artikel'], $id
- )
- );
- if(empty($checkAo)) {
- $this->app->DB->Insert(
- sprintf(
- 'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
+ protected function sendlist($i, $id, $data, $isLagerExported) {
+ /** @var Shopexport $objShopexport */
+ $objShopexport = $this->app->loadModule('shopexport');
+ $changedHash = $objShopexport->hasArticleHashChanged($data[0]['artikel'], $id);
+ $hash = $changedHash['hash'];
+ //$changedHash = $changedHash['changed'];
+
+ $result = $this->RemoteCommand($id, 'sendlist', $data);
+ $checkAo = $this->app->DB->Select(
+ sprintf(
+ 'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
+ $data[0]['artikel'], $id
+ )
+ );
+ if (empty($checkAo)) {
+ $this->app->DB->Insert(
+ sprintf(
+ 'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
VALUES (%d, %d, 1, 1) ',
- $data[0]['artikel'], $id
- )
- );
- }
- $this->app->DB->Update(
- sprintf(
- "UPDATE artikel_onlineshops
+ $data[0]['artikel'], $id
+ )
+ );
+ }
+ $this->app->DB->Update(
+ sprintf(
+ "UPDATE artikel_onlineshops
SET last_article_transfer = NOW(), last_article_hash = '%s'
WHERE artikel = %d AND shop = %d",
- $this->app->DB->real_escape_string($hash) ,$data[0]['artikel'], $id
- )
- );
- if(!empty($result) && is_array($result) && !empty($result['new']))
- {
- foreach($result['new'] as $artikelid => $fremdnummer)
- {
- $artikelid = (int)$artikelid;
- $artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
- if($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
- ($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$id' OR shop2 = '$id' OR shop3 = '$id') LIMIT 1") ||
- $this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
- ) && trim($fremdnummer) !== '')
- {
- //Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
- if(!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$id' AND nummer <> '' AND (aktiv = 1 OR nummer = '".trim($this->app->DB->real_escape_string($fremdnummer))."') LIMIT 1 "))
- {
- $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
- VALUES ('$artikelid','Erstellt durch Artikelexport','".trim($this->app->DB->real_escape_string($fremdnummer))."','$id','".((isset($this->app->User)&& method_exists($this->app->User,'GetName'))?$this->app->DB->real_escape_string($this->app->User->GetName()):'Cronjob') ."',now(),0)
+ $this->app->DB->real_escape_string($hash), $data[0]['artikel'], $id
+ )
+ );
+ if (!empty($result) && is_array($result) && !empty($result['new'])) {
+ foreach ($result['new'] as $artikelid => $fremdnummer) {
+ $artikelid = (int) $artikelid;
+ $artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
+ if ($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
+ ($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$id' OR shop2 = '$id' OR shop3 = '$id') LIMIT 1") ||
+ $this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
+ ) && trim($fremdnummer) !== '') {
+ //Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
+ if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
+ $this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
+ VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
");
- }
+ }
+ }
+ }
+ if (isset($result['anzahl'])) {
+ $result = $result['anzahl'];
+ }//Altes Verhalten
}
- }
- if(isset($result['anzahl']))
- {
- $result = $result['anzahl'];
- }//Altes Verhalten
+ if (!$isLagerExported) {
+ $data2 = $data;
+ foreach ($data2 as $key => $value) {
+ $data2[$key]['artikel'] = $value['artikelid'];
+ }
+ $this->RemoteCommand($id, 'sendlistlager', $data2);
+ $this->app->DB->Update(
+ sprintf(
+ 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
+ $data2[$i]['artikel'], $id
+ )
+ );
+ }
+ return $result;
}
- if(!$isLagerExported){
- $data2 = $data;
- foreach ($data2 as $key => $value){
- $data2[$key]['artikel'] = $value['artikelid'];
- }
- $this->RemoteCommand($id,'sendlistlager',$data2);
- $this->app->DB->Update(
- sprintf(
- 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
- $data2[$i]['artikel'], $id
- )
- );
- }
- return $result;
- }
- public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest
- {
- $orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
- if (empty($orderArr))
- return null;
+ public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest {
+ $orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
+ if (empty($orderArr))
+ return null;
- $data = new OrderStatusUpdateRequest();
- $data->orderId = $orderId;
- $data->shopOrderId = $orderArr['shopextid'];
+ $data = new OrderStatusUpdateRequest();
+ $data->orderId = $orderId;
+ $data->shopOrderId = $orderArr['shopextid'];
- $statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
- if (in_array('storniert', $statusArr))
- $data->orderStatus = OrderStatus::Cancelled;
- if (in_array('abgeschlossen', $statusArr))
- $data->orderStatus = OrderStatus::Completed;
- if (in_array('freigegeben', $statusArr))
- $data->orderStatus = OrderStatus::InProgress;
- if (in_array('angelegt', $statusArr))
- $data->orderStatus = OrderStatus::Imported;
+ $statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
+ if (in_array('storniert', $statusArr))
+ $data->orderStatus = OrderStatus::Cancelled;
+ if (in_array('abgeschlossen', $statusArr))
+ $data->orderStatus = OrderStatus::Completed;
+ if (in_array('freigegeben', $statusArr))
+ $data->orderStatus = OrderStatus::InProgress;
+ if (in_array('angelegt', $statusArr))
+ $data->orderStatus = OrderStatus::Imported;
- $sql = "
+ $sql = "
SELECT DISTINCT
v.id,
v.tracking,
@@ -2340,530 +2173,483 @@ class Remote
WHERE (a.id = $orderId OR a.teillieferungvon = $orderId) AND v.id IS NOT NULL
ORDER BY v.id";
- $shipments = $this->app->DB->SelectArr($sql);
- foreach ($shipments as $shipment) {
- $item = new Shipment();
- $item->id = $shipment['id'];
- $item->trackingNumber = $shipment['tracking'];
- $item->trackingUrl = $shipment['tracking_link'];
- $item->shippingMethod = $shipment['versandart'];
- $data->shipments[] = $item;
- }
+ $shipments = $this->app->DB->SelectArr($sql);
+ foreach ($shipments as $shipment) {
+ $item = new Shipment();
+ $item->id = $shipment['id'];
+ $item->trackingNumber = $shipment['tracking'];
+ $item->trackingUrl = $shipment['tracking_link'];
+ $item->shippingMethod = $shipment['versandart'];
+ $data->shipments[] = $item;
+ }
- return $data;
- }
+ return $data;
+ }
- /**
- * @param int $shopId
- * @param int $orderId
- *
- * @throws Exception
- */
- public function RemoteUpdateAuftrag($shopId, $orderId)
- {
- $data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
- if($data?->orderStatus !== OrderStatus::Completed)
- return;
+ /**
+ * @param int $shopId
+ * @param int $orderId
+ *
+ * @throws Exception
+ */
+ public function RemoteUpdateAuftrag($shopId, $orderId) {
+ $data = $this->getDataToSendForUpdateOrder((int) $shopId, (int) $orderId);
+ if ($data?->orderStatus !== OrderStatus::Completed)
+ return;
- $bearbeiter = 'Cronjob';
- if(isset($this->app->User)){
- $bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
- }
+ $bearbeiter = 'Cronjob';
+ if (isset($this->app->User)) {
+ $bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
+ }
- $response = $this->RemoteCommand($shopId, 'updateauftrag', $data);
- if($response instanceOf ShopConnectorResponseInterface && !$response->isSuccessful()){
- $query = sprintf('UPDATE `auftrag`
+ $response = $this->RemoteCommand($shopId, 'updateauftrag', $data);
+ if ($response instanceOf ShopConnectorResponseInterface && !$response->isSuccessful()) {
+ $query = sprintf('UPDATE `auftrag`
SET `shop_status_update_attempt` = `shop_status_update_attempt` + 1,
`shop_status_update_last_attempt_at` = NOW()
WHERE `id` = %d', $orderId);
- $this->app->DB->Update($query);
+ $this->app->DB->Update($query);
- $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
- $this->app->erp->Logfile('Versandmeldung an Shop fehlgeschlagen', print_r([
- 'orderId' => $orderId,
- 'shopId' => $shopId,
- 'message' => $response->getMessage()],true));
+ $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
+ $this->app->erp->Logfile('Versandmeldung an Shop fehlgeschlagen', print_r([
+ 'orderId' => $orderId,
+ 'shopId' => $shopId,
+ 'message' => $response->getMessage()], true));
- return;
- }
+ return;
+ }
- $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
- $this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
- }
-
- /**
- * @param int $shopId
- * @param string $auftrag
- *
- * @param string $internet
- *
- * @throws Exception
- */
- public function RemoteDeleteAuftrag($shopId, $auftrag, $internet='')
- {
- $data['auftrag'] = $auftrag;
- $data['internet'] = $internet;
- $this->RemoteCommand($shopId,'deleteauftrag',$data);
- }
-
- /**
- * @param int $shopId
- * @param int $orderId
- *
- * @throws Exception
- */
- public function RemoteStorniereAuftrag($shopId, $orderId)
- {
- $orderArr = $this->app->DB->SelectRow("SELECT shopextid, internet FROM auftrag WHERE id='$orderId' LIMIT 1");
- if(empty($orderArr)) {
- return;
+ $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
+ $this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
}
- $shopextid = $orderArr['shopextid'];
- $internet = $orderArr['internet'];
- $data['auftrag'] = $shopextid;
- $data['internet'] = $internet;
-
- $this->app->DB->Insert("
+
+ /**
+ * @param int $shopId
+ * @param string $auftrag
+ *
+ * @param string $internet
+ *
+ * @throws Exception
+ */
+ public function RemoteDeleteAuftrag($shopId, $auftrag, $internet = '') {
+ $data['auftrag'] = $auftrag;
+ $data['internet'] = $internet;
+ $this->RemoteCommand($shopId, 'deleteauftrag', $data);
+ }
+
+ /**
+ * @param int $shopId
+ * @param int $orderId
+ *
+ * @throws Exception
+ */
+ public function RemoteStorniereAuftrag($shopId, $orderId) {
+ $orderArr = $this->app->DB->SelectRow("SELECT shopextid, internet FROM auftrag WHERE id='$orderId' LIMIT 1");
+ if (empty($orderArr)) {
+ return;
+ }
+ $shopextid = $orderArr['shopextid'];
+ $internet = $orderArr['internet'];
+ $data['auftrag'] = $shopextid;
+ $data['internet'] = $internet;
+
+ $this->app->DB->Insert("
INSERT INTO auftrag_protokoll (auftrag, zeit, bearbeiter, grund)
- VALUES ($orderId,now(),'".(isset($this->app->User)?$this->app->DB->real_escape_string($this->app->User->GetName()):'Cronjob')."',
+ VALUES ($orderId,now(),'" . (isset($this->app->User) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',
'Stonierung an Shop übertragen')"
- );
- $this->RemoteCommand($shopId,'storniereauftrag',$data);
- $shopextstatus='storniert';
- $this->app->DB->Update("UPDATE auftrag SET shopextstatus='$shopextstatus' WHERE id='$orderId' LIMIT 1");
- }
+ );
+ $this->RemoteCommand($shopId, 'storniereauftrag', $data);
+ $shopextstatus = 'storniert';
+ $this->app->DB->Update("UPDATE auftrag SET shopextstatus='$shopextstatus' WHERE id='$orderId' LIMIT 1");
+ }
- /**
- * @param int $shopId
- * @param int $fileId
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteDeleteFile($shopId, $fileId)
- {
- $inhalt = $this->app->erp->GetDatei($fileId);
- $fileArr = $this->app->DB->SelectRow("SELECT titel,beschreibung FROM datei WHERE id='$fileId' LIMIT 1");
- $titel = $fileArr['titel'];
- $beschreibung = $fileArr['beschreibung'];
+ /**
+ * @param int $shopId
+ * @param int $fileId
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteDeleteFile($shopId, $fileId) {
+ $inhalt = $this->app->erp->GetDatei($fileId);
+ $fileArr = $this->app->DB->SelectRow("SELECT titel,beschreibung FROM datei WHERE id='$fileId' LIMIT 1");
+ $titel = $fileArr['titel'];
+ $beschreibung = $fileArr['beschreibung'];
- $data['datei'] = $fileId;
- //$data['checksum'] = md5($inhalt);
- $data['checksum'] = md5($inhalt.$titel.$beschreibung);
- return $this->RemoteCommand($shopId,'deletefile',$data);
- }
+ $data['datei'] = $fileId;
+ //$data['checksum'] = md5($inhalt);
+ $data['checksum'] = md5($inhalt . $titel . $beschreibung);
+ return $this->RemoteCommand($shopId, 'deletefile', $data);
+ }
- /**
- * @param int $articleId
- * @param int $shopId
- */
- public function RemoteUpdateFilesArtikel($articleId, $shopId)
- {
- $files = $this->app->DB->SelectArr("SELECT DISTINCT ds.datei
+ /**
+ * @param int $articleId
+ * @param int $shopId
+ */
+ public function RemoteUpdateFilesArtikel($articleId, $shopId) {
+ $files = $this->app->DB->SelectArr("SELECT DISTINCT ds.datei
FROM datei_stichwoerter ds, datei d, artikel a
WHERE d.id=ds.datei AND (ds.subjekt='Shopbild' OR ds.subjekt='Gruppenbild') AND ((ds.objekt='Artikel' AND
ds.parameter=a.id) OR (ds.objekt='Kampangen' AND ds.parameter='$shopId')) AND
- d.firma='".$this->app->User->GetFirma()."' AND a.shop='$shopId' AND a.id='$articleId'"
- );
+ d.firma='" . $this->app->User->GetFirma() . "' AND a.shop='$shopId' AND a.id='$articleId'"
+ );
- $tmp = $this->app->remote->RemoteGetFileListArticle($shopId,$articleId);
- if(!empty($tmp)){
- foreach ($tmp as $row) {
- $checkarray[$row['datei']] = $row['checksum'];
- }
- }
-
- if(!empty($files)){
- foreach($files as $file) {
- $fid = $file['datei'];
- $geloescht = $this->app->DB->Select("SELECT geloescht FROM datei WHERE id='$fid' LIMIT 1");
- if($geloescht){
- $this->app->remote->RemoteDeleteFile($shopId, $fid);
- $checkarray[$fid] = 'delete';
- }else{
- $md5 = !empty($checkarray[$fid]) ? (String)$checkarray[$fid] : '';
- $md5file = md5($this->app->erp->GetDatei($fid));
- if($md5 !== $md5file){
- $this->app->remote->RemoteSendFile($shopId, $fid);
- $this->app->remote->RemoteAddFileSubject($shopId, $fid);
- $checkarray[$fid] = 'update';
- }
+ $tmp = $this->app->remote->RemoteGetFileListArticle($shopId, $articleId);
+ if (!empty($tmp)) {
+ foreach ($tmp as $row) {
+ $checkarray[$row['datei']] = $row['checksum'];
+ }
}
- $checkarray[$fid] = 'mark';
- }
- }
- if(!empty($checkarray))
- {
- foreach($checkarray as $key=>$value)
- {
- if($checkarray[$key]!=='mark' && $checkarray[$key]!=='delete' && $checkarray[$key]!=='update')
- {
- $this->app->remote->RemoteDeleteFile($shopId,$key);
+
+ if (!empty($files)) {
+ foreach ($files as $file) {
+ $fid = $file['datei'];
+ $geloescht = $this->app->DB->Select("SELECT geloescht FROM datei WHERE id='$fid' LIMIT 1");
+ if ($geloescht) {
+ $this->app->remote->RemoteDeleteFile($shopId, $fid);
+ $checkarray[$fid] = 'delete';
+ } else {
+ $md5 = !empty($checkarray[$fid]) ? (String) $checkarray[$fid] : '';
+ $md5file = md5($this->app->erp->GetDatei($fid));
+ if ($md5 !== $md5file) {
+ $this->app->remote->RemoteSendFile($shopId, $fid);
+ $this->app->remote->RemoteAddFileSubject($shopId, $fid);
+ $checkarray[$fid] = 'update';
+ }
+ }
+ $checkarray[$fid] = 'mark';
+ }
+ }
+ if (!empty($checkarray)) {
+ foreach ($checkarray as $key => $value) {
+ if ($checkarray[$key] !== 'mark' && $checkarray[$key] !== 'delete' && $checkarray[$key] !== 'update') {
+ $this->app->remote->RemoteDeleteFile($shopId, $key);
+ }
+ }
}
- }
}
- }
+ /**
+ * @param int $shopId
+ * @param int $fileId
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteSendFile($shopId, $fileId) {
+ // sende stichwoerter
+ $fileArr = $this->app->DB->SelectRow("SELECT geloescht, titel, beschreibung FROM datei WHERE id='$fileId' LIMIT 1");
+ if (empty($fileArr)) {
+ return '';
+ }
+ $geloescht = $fileArr['geloescht'];
+ $titel = $fileArr['titel'];
+ $beschreibung = $fileArr['beschreibung'];
- /**
- * @param int $shopId
- * @param int $fileId
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteSendFile($shopId, $fileId)
- {
- // sende stichwoerter
- $fileArr = $this->app->DB->SelectRow("SELECT geloescht, titel, beschreibung FROM datei WHERE id='$fileId' LIMIT 1");
- if(empty($fileArr)) {
- return '';
+ $inhalt = $this->app->erp->GetDatei($fileId);
+ $data['datei'] = $fileId;
+ $data['titel'] = $titel;
+ $data['beschreibung'] = $beschreibung;
+ $data['inhalt'] = base64_encode($inhalt);
+ $data['checksum'] = md5($inhalt . $titel . $beschreibung);
+ if (!$geloescht) {
+ return $this->RemoteCommand($shopId, 'sendfile', $data);
+ }
+ return '';
}
- $geloescht = $fileArr['geloescht'];
- $titel = $fileArr['titel'];
- $beschreibung = $fileArr['beschreibung'];
- $inhalt = $this->app->erp->GetDatei($fileId);
- $data['datei'] = $fileId;
- $data['titel'] = $titel;
- $data['beschreibung'] =$beschreibung;
- $data['inhalt'] = base64_encode($inhalt);
- $data['checksum'] = md5($inhalt.$titel.$beschreibung);
- if(!$geloescht){
- return $this->RemoteCommand($shopId, 'sendfile', $data);
- }
- return '';
- }
-
- /**
- * @param int $shopId
- * @param int $fileId
- *
- * @throws Exception
- */
- public function RemoteAddFileSubject($shopId, $fileId)
- {
- // sende stichwoerter
- $fileList = $this->app->DB->SelectArr("SELECT subjekt, parameter
+ /**
+ * @param int $shopId
+ * @param int $fileId
+ *
+ * @throws Exception
+ */
+ public function RemoteAddFileSubject($shopId, $fileId) {
+ // sende stichwoerter
+ $fileList = $this->app->DB->SelectArr("SELECT subjekt, parameter
FROM datei_stichwoerter
WHERE (objekt='Artikel' OR objekt='Kampangen') AND datei='$fileId'"
- );
- if(empty($fileList)) {
- return;
- }
-
- foreach($fileList as $fileRow) {
- $geloescht = $this->app->DB->Select("SELECT geloescht FROM datei WHERE id='$fileId' LIMIT 1");
- $stichwort['subjekt'] = $fileRow['subjekt'];
- $stichwort['artikel'] = $fileRow['parameter'];
- $stichwort['datei'] = $fileId;
- if(!$geloescht){
- $this->RemoteCommand($shopId, 'addfilesubjekt', $stichwort);
- }
- }
- }
-
- /**
- * @param int $shopId
- * @param array $artikel
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteDeleteArticle($shopId,$artikel)
- {
- return $this->RemoteCommand($shopId,'deletearticle',$artikel);
- }
-
- /**
- * @param int $shopId
- * @param array $partner
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteSendPartner($shopId, $partner)
- {
- return $this->RemoteCommand($shopId, 'partnerlist', $partner);
- }
-
- /**
- * @param object $obj
- * @param string $methodname
- *
- * @return string
- */
- public function getMethod($obj, $methodname)
- {
- $methodname = trim((String)$methodname);
- if($methodname === '')
- {
- return '';
- }
- if(!$obj)
- {
- return '';
- }
- if(method_exists($obj, $methodname))
- {
- return $methodname;
- }
- $methods = get_class_methods($obj);
- $classname = get_class($obj);
- foreach($methods as $v)
- {
- if(strtolower($v) === 'import'.strtolower($methodname))
- {
- return $v;
- }
- if(strtolower($v) === strtolower($classname.$methodname))
- {
- return $v;
- }
- }
- foreach($methods as $v)
- {
- if(strtolower($v) === strtolower($methodname))
- {
- return $v;
- }
- }
- return '';
- }
-
- /**
- * @param int $id
- * @param string $action
- * @param string|array $data
- *
- * @return mixed
- * @throws Exception
- */
- public function RemoteCommand($id,$action,$data='')
- {
- $challenge = '';
- $shoptyp = $this->app->DB->Select("SELECT shoptyp FROM shopexport WHERE id='$id' LIMIT 1");
- $modulename = trim($this->app->DB->Select("SELECT modulename FROM shopexport WHERE id='$id' LIMIT 1"),'.');
- $isActionAuth = $action === 'auth';
- if($shoptyp === 'custom')
- {
- if($modulename != '')
- {
-
- $file = dirname(__DIR__) . '/plugins/external/shopimporter/'.$modulename;
- $classa = explode('_',str_replace('_'.$id.'.php','', $modulename));
- foreach($classa as $k => $v)
- {
- $classa[$k] = ucfirst($v);
+ );
+ if (empty($fileList)) {
+ return;
}
- $class = implode('_', $classa);
- if($this->app->DB->Select("SELECT aktiv FROM shopexport WHERE id = '$id' LIMIT 1"))
- {
- if(file_exists($file))
- {
- include_once($file);
- if(class_exists($class)){
- $obj = new $class($this->app, true);
- if($obj){
- if(method_exists($obj,'getKonfig'))
- {
- $obj->getKonfig($id, $data);
- }
- $method = $this->getMethod($obj, $action);
- if(method_exists($obj,$method))
- {
- $ret = $obj->$method();
- if(!empty($this->app->stringcleaner)){
- $this->app->stringcleaner->XMLArray_clean($ret);
- }
- }elseif($isActionAuth)
- {
- return 'Fehler: Importer konnte nicht initialisiert werden';
- }
- }elseif($isActionAuth)
- {
- return 'Fehler: Importer konnte nicht initialisiert werden';
- }
- }elseif($isActionAuth)
- {
- return 'Fehler: Importer konnte nicht initialisiert werden';
+
+ foreach ($fileList as $fileRow) {
+ $geloescht = $this->app->DB->Select("SELECT geloescht FROM datei WHERE id='$fileId' LIMIT 1");
+ $stichwort['subjekt'] = $fileRow['subjekt'];
+ $stichwort['artikel'] = $fileRow['parameter'];
+ $stichwort['datei'] = $fileId;
+ if (!$geloescht) {
+ $this->RemoteCommand($shopId, 'addfilesubjekt', $stichwort);
}
- }elseif($isActionAuth)
- {
- return 'Fehler: Datei '.$file.' existiert nicht';
- }
- }elseif($isActionAuth) {
- return 'Fehler: Schnittstelle nicht aktiv';
}
- }
- return '';
}
- if($shoptyp === 'intern')
- {
- if($modulename != '')
- {
- if($this->app->erp->ModulVorhanden($modulename))
- {
- $obj = $this->app->erp->LoadModul($modulename);
- if($obj){
- if(method_exists($obj,'getKonfig'))
- {
- $obj->getKonfig($id, $data);
+
+ /**
+ * @param int $shopId
+ * @param array $artikel
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteDeleteArticle($shopId, $artikel) {
+ return $this->RemoteCommand($shopId, 'deletearticle', $artikel);
+ }
+
+ /**
+ * @param int $shopId
+ * @param array $partner
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteSendPartner($shopId, $partner) {
+ return $this->RemoteCommand($shopId, 'partnerlist', $partner);
+ }
+
+ /**
+ * @param object $obj
+ * @param string $methodname
+ *
+ * @return string
+ */
+ public function getMethod($obj, $methodname) {
+ $methodname = trim((String) $methodname);
+ if ($methodname === '') {
+ return '';
+ }
+ if (!$obj) {
+ return '';
+ }
+ if (method_exists($obj, $methodname)) {
+ return $methodname;
+ }
+ $methods = get_class_methods($obj);
+ $classname = get_class($obj);
+ foreach ($methods as $v) {
+ if (strtolower($v) === 'import' . strtolower($methodname)) {
+ return $v;
}
- $method = 'Import'.$action;
- if(method_exists($obj,$method)) {
- try {
- $ret = $obj->$method();
- }
- catch(Exception $e) {
- if($isActionAuth) {
- return 'Fehler: '.$e->getMessage();
+ if (strtolower($v) === strtolower($classname . $methodname)) {
+ return $v;
+ }
+ }
+ foreach ($methods as $v) {
+ if (strtolower($v) === strtolower($methodname)) {
+ return $v;
+ }
+ }
+ return '';
+ }
+
+ /**
+ * @param int $id
+ * @param string $action
+ * @param string|array $data
+ *
+ * @return mixed
+ * @throws Exception
+ */
+ public function RemoteCommand($id, $action, $data = '') {
+ $challenge = '';
+ $shoptyp = $this->app->DB->Select("SELECT shoptyp FROM shopexport WHERE id='$id' LIMIT 1");
+ $modulename = trim($this->app->DB->Select("SELECT modulename FROM shopexport WHERE id='$id' LIMIT 1"), '.');
+ $isActionAuth = $action === 'auth';
+ if ($shoptyp === 'custom') {
+ if ($modulename != '') {
+
+ $file = dirname(__DIR__) . '/plugins/external/shopimporter/' . $modulename;
+ $classa = explode('_', str_replace('_' . $id . '.php', '', $modulename));
+ foreach ($classa as $k => $v) {
+ $classa[$k] = ucfirst($v);
}
+ $class = implode('_', $classa);
+ if ($this->app->DB->Select("SELECT aktiv FROM shopexport WHERE id = '$id' LIMIT 1")) {
+ if (file_exists($file)) {
+ include_once($file);
+ if (class_exists($class)) {
+ $obj = new $class($this->app, true);
+ if ($obj) {
+ if (method_exists($obj, 'getKonfig')) {
+ $obj->getKonfig($id, $data);
+ }
+ $method = $this->getMethod($obj, $action);
+ if (method_exists($obj, $method)) {
+ $ret = $obj->$method();
+ if (!empty($this->app->stringcleaner)) {
+ $this->app->stringcleaner->XMLArray_clean($ret);
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Importer konnte nicht initialisiert werden';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Importer konnte nicht initialisiert werden';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Importer konnte nicht initialisiert werden';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Datei ' . $file . ' existiert nicht';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Schnittstelle nicht aktiv';
+ }
+ }
+ return '';
+ }
+ if ($shoptyp === 'intern') {
+ if ($modulename != '') {
+ if ($this->app->erp->ModulVorhanden($modulename)) {
+ $obj = $this->app->erp->LoadModul($modulename);
+ if ($obj) {
+ if (method_exists($obj, 'getKonfig')) {
+ $obj->getKonfig($id, $data);
+ }
+ $method = 'Import' . $action;
+ if (method_exists($obj, $method)) {
+ try {
+ $ret = $obj->$method();
+ } catch (Exception $e) {
+ if ($isActionAuth) {
+ return 'Fehler: ' . $e->getMessage();
+ }
+ return '';
+ }
+
+ if (!empty($this->app->stringcleaner)) {
+ $this->app->stringcleaner->XMLArray_clean($ret);
+ }
+ $this->parseReturn($ret, $id, $action);
+ return $ret;
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Importer konnte nicht initialisiert werden';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Dieses Modul ist nicht verfügbar';
+ }
+ } elseif ($isActionAuth) {
+ return 'Fehler: Kein Modul vorhanden';
+ }
+ return '';
+ }
+ $shopexport = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
+ if ($shopexport) {
+ if ($shopexport['shoptyp'] === 'intern' || $shopexport['shoptyp'] === 'custom') {
return '';
- }
-
- if(!empty($this->app->stringcleaner)){
- $this->app->stringcleaner->XMLArray_clean($ret);
- }
- $this->parseReturn($ret, $id, $action);
- return $ret;
}
- }elseif($isActionAuth)
- {
- return 'Fehler: Importer konnte nicht initialisiert werden';
- }
- }elseif($isActionAuth)
- {
- return 'Fehler: Dieses Modul ist nicht verfügbar';
+ $token = $shopexport['token'];
+ $url = $shopexport['url'];
+ $z = $shopexport['passwort'];
+ $bezeichnung = $shopexport['bezeichnung'];
+ } else {
+ $token = '';
+ $z = '';
+ $url = '';
}
- }elseif($isActionAuth)
- {
- return 'Fehler: Kein Modul vorhanden';
- }
- return '';
- }
- $shopexport = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
- if($shopexport){
- if($shopexport['shoptyp'] === 'intern' || $shopexport['shoptyp'] === 'custom'){
- return '';
- }
- $token = $shopexport['token'];
- $url = $shopexport['url'];
- $z = $shopexport['passwort'];
- $bezeichnung = $shopexport['bezeichnung'];
- }
- else {
- $token = '';
- $z = '';
- $url = '';
- }
- if($isActionAuth) {
- if($token === '' || strlen($z) < 32 || $url === '') {
- return 'Fehler: Bitte Zugangsdaten prüfen';
- }
- }
- elseif($token === '' || strlen($z) < 32 || $url === '' || !$this->app->DB->Select("SELECT id FROM shopexport WHERE id = '$id' AND aktiv = 1 LIMIT 1")){
- return '';
- }
-
- $tmp = parse_url($url);
- $tmp['host'] = rtrim($tmp['host'],'/');
- $tmp['path'] = rtrim($tmp['path'],'/').'/';
-
- $aes = new AES($z);
- $token = base64_encode($aes->encrypt(serialize($token)));
- $client = new HttpClient($tmp['host'], stripos($url,'https') === 0?443:80);
- $geturl = $tmp['path'].'index.php?module=import&action='.$action.'&challenge='.(isset($challenge)?$challenge:'');
- //Kein Fragezeichen vor module=import...
- if(false !== stripos($bezeichnung, 'woocommerce')) {
- $geturl = $tmp['path'].'module=import&action='.$action.'&challenge='.(isset($challenge)?$challenge:'');
- }
- if(false !== stripos($bezeichnung, 'shopware plugin')) {
- $geturl = $tmp['path'].'wawisionimporter/?smodule=import&saction='.$action.'&challenge='.(isset($challenge)?$challenge:'');
- }
-
- $post_data['token'] = $token;
- $post_data['data'] = base64_encode(serialize($data));
- $client->timeout = 120;
- if(!$client->post($geturl,$post_data)) {
- $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection,'An error occurred: '.$client->getError()));
- throw new Exception('An error occurred: '.$client->getError());
- //return 'Netzwerkverbindung von WaWison zu Shopimporter fehlgeschlagen: '.$client->getError();
- }
- $ret = unserialize(base64_decode($client->getContent()));
- if(!empty($this->app->stringcleaner)){
- $this->app->stringcleaner->XMLArray_clean($ret);
- }
- $this->parseReturn($ret, $id, $action);
- return $ret;
- }
-
- /**
- * @param mixed $ret
- * @param int $id
- * @param string $action
- */
- public function parseReturn($ret, $id, $action)
- {
- if($action === 'getarticlelist') {
- if(empty($ret)) {
- return;
- }
- $anz = 0;
- if(empty($ret['errors'])) {
- foreach($ret as $v) {
- $anz++;
- $this->app->DB->Insert("INSERT INTO shopexport_getarticles (shop, nummer) VALUES ('$id', '".$this->app->DB->real_escape_string($v)."')");
+ if ($isActionAuth) {
+ if ($token === '' || strlen($z) < 32 || $url === '') {
+ return 'Fehler: Bitte Zugangsdaten prüfen';
+ }
+ } elseif ($token === '' || strlen($z) < 32 || $url === '' || !$this->app->DB->Select("SELECT id FROM shopexport WHERE id = '$id' AND aktiv = 1 LIMIT 1")) {
+ return '';
}
- if(!$this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE aktiv = 1 AND parameter = 'getarticles' LIMIT 1")) {
- $this->app->DB->Update("UPDATE `prozessstarter` SET aktiv = 1 WHERE parameter = 'getarticles' LIMIT 1");
+
+ $tmp = parse_url($url);
+ $tmp['host'] = rtrim($tmp['host'], '/');
+ $tmp['path'] = rtrim($tmp['path'], '/') . '/';
+
+ $aes = new AES($z);
+ $token = base64_encode($aes->encrypt(serialize($token)));
+ $client = new HttpClient($tmp['host'], stripos($url, 'https') === 0 ? 443 : 80);
+ $geturl = $tmp['path'] . 'index.php?module=import&action=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
+ //Kein Fragezeichen vor module=import...
+ if (false !== stripos($bezeichnung, 'woocommerce')) {
+ $geturl = $tmp['path'] . 'module=import&action=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
}
- $this->app->DB->Update("UPDATE `prozessstarter` SET letzteausfuerhung = DATE_SUB(now(), INTERVAL periode MINUTE) WHERE aktiv = 1 AND parameter = 'getarticles' AND mutex = 0 LIMIT 1");
- }
- $this->app->erp->SetKonfigurationValue('artikelimportanzahl_'.$id, $anz);
+ if (false !== stripos($bezeichnung, 'shopware plugin')) {
+ $geturl = $tmp['path'] . 'wawisionimporter/?smodule=import&saction=' . $action . '&challenge=' . (isset($challenge) ? $challenge : '');
+ }
+
+ $post_data['token'] = $token;
+ $post_data['data'] = base64_encode(serialize($data));
+ $client->timeout = 120;
+ if (!$client->post($geturl, $post_data)) {
+ $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection, 'An error occurred: ' . $client->getError()));
+ throw new Exception('An error occurred: ' . $client->getError());
+ //return 'Netzwerkverbindung von WaWison zu Shopimporter fehlgeschlagen: '.$client->getError();
+ }
+ $ret = unserialize(base64_decode($client->getContent()));
+ if (!empty($this->app->stringcleaner)) {
+ $this->app->stringcleaner->XMLArray_clean($ret);
+ }
+ $this->parseReturn($ret, $id, $action);
+ return $ret;
}
- }
- /**
- * @param int $id
- * @param string $action
- * @param string|array $data
- *
- * @return mixed|string
- * @throws Exception
- */
- public function RemoteCommandAES($id,$action,$data='')
- {
- $challenge = '';
- $shopexport = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
- if(!empty($shopexport)){
- if($shopexport['shoptyp'] === 'intern' || $shopexport['shoptyp'] === 'custom'){
- return '';
- }
- $token = $shopexport['token'];
- $url = $shopexport['url'];
- $z = $shopexport['passwort'];
- if($z === '' || $token === '' || $url === '')
- {
- throw new Exception('Der ImportKey/ImportToken/ImportUrl ist leer');
- }
+ /**
+ * @param mixed $ret
+ * @param int $id
+ * @param string $action
+ */
+ public function parseReturn($ret, $id, $action) {
+ if ($action === 'getarticlelist') {
+ if (empty($ret)) {
+ return;
+ }
+ $anz = 0;
+ if (empty($ret['errors'])) {
+ foreach ($ret as $v) {
+ $anz++;
+ $this->app->DB->Insert("INSERT INTO shopexport_getarticles (shop, nummer) VALUES ('$id', '" . $this->app->DB->real_escape_string($v) . "')");
+ }
+ if (!$this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE aktiv = 1 AND parameter = 'getarticles' LIMIT 1")) {
+ $this->app->DB->Update("UPDATE `prozessstarter` SET aktiv = 1 WHERE parameter = 'getarticles' LIMIT 1");
+ }
+ $this->app->DB->Update("UPDATE `prozessstarter` SET letzteausfuerhung = DATE_SUB(now(), INTERVAL periode MINUTE) WHERE aktiv = 1 AND parameter = 'getarticles' AND mutex = 0 LIMIT 1");
+ }
+ $this->app->erp->SetKonfigurationValue('artikelimportanzahl_' . $id, $anz);
+ }
}
- $tmp = parse_url($url);
- $aes = new AES($z);
- $token = base64_encode($aes->encrypt(serialize($token)));
+ /**
+ * @param int $id
+ * @param string $action
+ * @param string|array $data
+ *
+ * @return mixed|string
+ * @throws Exception
+ */
+ public function RemoteCommandAES($id, $action, $data = '') {
+ $challenge = '';
+ $shopexport = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
+ if (!empty($shopexport)) {
+ if ($shopexport['shoptyp'] === 'intern' || $shopexport['shoptyp'] === 'custom') {
+ return '';
+ }
+ $token = $shopexport['token'];
+ $url = $shopexport['url'];
+ $z = $shopexport['passwort'];
+ if ($z === '' || $token === '' || $url === '') {
+ throw new Exception('Der ImportKey/ImportToken/ImportUrl ist leer');
+ }
+ }
+ $tmp = parse_url($url);
- $client = new HttpClient($tmp['host']);
- $geturl = $tmp['path'].'index.php?module=import&action='.$action.'&challenge='.$challenge;
+ $aes = new AES($z);
+ $token = base64_encode($aes->encrypt(serialize($token)));
- $post_data['token'] = $token;
- $post_data['data'] = base64_encode($aes->encrypt(serialize($data)));
+ $client = new HttpClient($tmp['host']);
+ $geturl = $tmp['path'] . 'index.php?module=import&action=' . $action . '&challenge=' . $challenge;
- if(!$client->post($geturl,$post_data))
- {
- $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection,'An error occurred: '.$client->getError()));
- throw new Exception('An error occurred: '.$client->getError());
+ $post_data['token'] = $token;
+ $post_data['data'] = base64_encode($aes->encrypt(serialize($data)));
+
+ if (!$client->post($geturl, $post_data)) {
+ $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection, 'An error occurred: ' . $client->getError()));
+ throw new Exception('An error occurred: ' . $client->getError());
+ }
+ return unserialize($aes->decrypt(base64_decode($client->getContent())));
}
- return unserialize($aes->decrypt(base64_decode($client->getContent())));
- }
}
+
From 1cc50d5cd7846f145f105dc49596c4c9e03451f0 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Sat, 31 Aug 2024 13:13:08 +0200
Subject: [PATCH 78/87] class.remote.php improvements
---
www/lib/class.remote.php | 340 ++++++++++++++++++++++-----------------
1 file changed, 193 insertions(+), 147 deletions(-)
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index e87eb432..96f890aa 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2,6 +2,7 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Andreas Palm
+ * SPDX-FileCopyrightText: 2024 OpenXE project
* SPDX-FileCopyrightText: 2019 Xentral (c) Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg, Germany
*
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
@@ -26,14 +27,19 @@ use Xentral\Modules\Onlineshop\Data\OrderStatus;
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
use Xentral\Modules\Onlineshop\Data\Shipment;
use Xentral\Modules\Onlineshop\Data\ShopConnectorResponseInterface;
+use Xentral\Components\Logger\Logger;
class Remote {
/** @var ApplicationCore $app */
public $app;
+ /** @var Logger $logger */
+ public $logger;
+
public function __construct($app) {
$this->app = $app;
+ $this->logger = $app->Container->get('Logger');
}
/**
@@ -1059,15 +1065,44 @@ class Remote {
*
* @return mixed|null
* @throws Exception
+ *
+ * (NEW 2024-06-28)
+ *
+ * return value: (comes from Importsendlist or Importsendlistlager inside shopimporter_...)
+ * array (
+ * 'count' => int, // Number of successfully sent articles
+ * 'new' => array (artikelid, fremdnummer), // List of new articles with external number
+ * 'message' => string
+ * 'status' => bool, // false = failed
+ * 'articles' => array(
+ * 'id',
+ * 'status',
+ * 'message',
+ * ...
+ * )
+ * )
+ *
*/
public function RemoteSendArticleList($id, $artikel_arr, $extnummer = '', $nurlager = false) {
+
+ $this->logger->debug(
+ 'RemoteSendArticleList',
+ [
+ 'shop' => $id,
+ 'artikel_arr' => $artikel_arr
+ ]
+ );
+
if (!class_exists('ObjGenArtikel') &&
is_file(dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php')) {
include_once dirname(__DIR__) . '/objectapi/mysql/_gen/object.gen.artikel.php';
}
$shopexportarr = $this->app->DB->SelectRow("SELECT * FROM shopexport WHERE id='$id' LIMIT 1");
$artikelexport = $shopexportarr['artikelexport'];
-
+ $translationpossible = false;
+ if ($this->app->erp->ModulVorhanden('artikel_texte')) {
+ $translationpossible = true;
+ }
$loadElements = [
'foreign_numbers' => true,
'article_descriptions' => true,
@@ -1100,7 +1135,6 @@ class Remote {
$cartikel_arr = !empty($artikel_arr) ? count($artikel_arr) : 0;
for ($i = 0; $i < $cartikel_arr; $i++) {
-
$artikel = $artikel_arr[$i];
$lagerexport = $this->app->erp->GetArtikelShopEinstellung('autolagerlampe', $artikel, $shopexportarr);
$tmp->Select($artikel);
@@ -1489,16 +1523,18 @@ class Remote {
AND (v.objekt = 'Standard' OR v.objekt = '') AND (v.adresse = '0' OR v.adresse = '')
AND (v.gueltig_bis >= NOW() OR v.gueltig_bis = '0000-00-00')
ORDER BY v.preis DESC LIMIT 1");
- $priceInformation = reset($priceInformation);
- $defaultPrice = $priceInformation['preis'];
- $defaultCurrency = $priceInformation['waehrung'] ?: 'EUR';
- if ($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')) {
- $defaultCurrency = 'EUR'; //the follow up function imply EUR as the default currency
- $defaultPrice = $this->app->erp->GetVerkaufspreisGruppe($artikel, 1, $preisgruppe);
- }
- $data[$i]['waehrung'] = $defaultCurrency;
- $data[$i]['preis'] = $defaultPrice;
+ if (!empty($priceInformation)) {
+ $priceInformation = reset($priceInformation);
+ $defaultPrice = $priceInformation['preis'];
+ $defaultCurrency = $priceInformation['waehrung'] ?: 'EUR';
+ if ($preisgruppe && method_exists($this->app->erp, 'GetVerkaufspreisGruppe')) {
+ $defaultCurrency = 'EUR'; //the follow up function imply EUR as the default currency
+ $defaultPrice = $this->app->erp->GetVerkaufspreisGruppe($artikel, 1, $preisgruppe);
+ }
+ $data[$i]['waehrung'] = $defaultCurrency;
+ $data[$i]['preis'] = $defaultPrice;
+ }
if (!empty($tmp->GetSteuersatz()) && $tmp->GetSteuersatz() != -1) {
$data[$i]['steuersatz'] = (float) $tmp->GetSteuersatz();
@@ -1606,8 +1642,6 @@ class Remote {
* @deprecated Ende
*/
}
-
-
$data[$i]['bruttopreis'] = $data[$i]['preis'] * $steuer;
}
$data[$i]['checksum'] = $tmp->GetChecksum();
@@ -1657,7 +1691,7 @@ class Remote {
foreach ($db->yieldAll($query) as $matrixdaten) {
$data[$i]['matrix_varianten']['gruppen'][$matrixdaten['gruppe']][$matrixdaten['wert']] = true;
- if (!empty($loadElements['translations'])) {
+ if ($translationpossible && !empty($loadElements['translations'])) {
if (empty($gruppenuebersetzung[$matrixdaten['gruppe']])) {
$gruppennamen = $this->app->DB->SelectArr("SELECT
IF(name_external_from<>'',name_external_from,name_from) AS name_from,
@@ -1732,6 +1766,7 @@ class Remote {
if (is_numeric($matrixPseudoStorage) && $matrixPseudoStorage < 0) {
$matrixPseudoStorage = 0;
}
+ $matrixStock = (float) $this->app->erp->ArtikelAnzahlVerkaufbar($eigenschaft['artikel'], 0, $projektlager, $id, $lagergrundlage);
if ($matrixStock < 0) {
$matrixStock = 0;
}
@@ -1896,18 +1931,19 @@ class Remote {
}
}
- $result = null;
if (empty($data)) {
continue;
}
- if (!empty($lagerexport)) {
- $result = $this->sendlistlager($i, $id, $data);
- }
- if (!empty($artikelexport) && !$nurlager) {
- $result = $this->sendlist($i, $id, $data, true);
- }
- } while (count($data[$i]['matrix_varianten']['artikel'] ?? []) >= 5000);
+ } while (count($data[$i]['matrix_varianten']['artikel'] ?? [])>=5000);
+ // Bulk transfer (new 2024-06-28)
+ $result = null;
+ if (!empty($artikelexport) && !$nurlager) {
+ $result = $this->sendlist($id, $data, true);
+ }
+ if (!empty($lagerexport)) {
+ $result = $this->sendlistlager($id, $data);
+ }
return $result;
}
@@ -1933,16 +1969,17 @@ class Remote {
$variantennettopreis = $this->app->erp->GetVerkaufspreis($v['id'], 1, 0);
}
}
- $sprachen = ['de', 'en'];
- foreach ($sprachen as $sprache) {
- $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
- $id, strtoupper($sprache), $v['id']);
- $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
- if (!empty($ersetzeStandardbeschreibung)) {
- $v['name_' . $sprache] = $ersetzeStandardbeschreibung['name'];
+ if (!empty($loadElements['translations']) && $this->app->erp->ModulVorhanden('artikel_texte')) {
+ $sprachen = ['de', 'en'];
+ foreach ($sprachen as $sprache) {
+ $query = sprintf("SELECT * FROM artikel_texte WHERE shop=%d AND sprache='%s' AND artikel=%d AND aktiv=1 LIMIT 1",
+ $id, strtoupper($sprache), $v['id']);
+ $ersetzeStandardbeschreibung = $this->app->DB->SelectRow($query);
+ if (!empty($ersetzeStandardbeschreibung)) {
+ $v['name_' . $sprache] = $ersetzeStandardbeschreibung['name'];
+ }
}
}
-
$this->app->erp->RunHook('remote_send_article_list_pseudostorage', 3, $id, $v['id'], $v['pseudolager']);
if (is_numeric($v['pseudolager']) && $v['pseudolager'] < 0) {
$v['pseudolager'] = 0;
@@ -2020,18 +2057,19 @@ class Remote {
$data[$i]['variantevorhanden'] = 0;
}
- $result = null;
if (empty($data)) {
continue;
}
- if (!empty($lagerexport)) {
- $result = $this->sendlistlager($i, $id, $data);
- }
- if (!empty($artikelexport) && !$nurlager) {
- $result = $this->sendlist($i, $id, $data, true);
- }
}
+ // Bulk transfer (new 2024-06-28)
+ $result = null;
+ if (!empty($artikelexport) && !$nurlager) {
+ $result = $this->sendlist($id, $data, true);
+ }
+ if (!empty($lagerexport)) {
+ $result = $this->sendlistlager($id, $data);
+ }
return $result;
}
@@ -2051,108 +2089,97 @@ class Remote {
return $this->app->DB->SelectArr($query);
}
- protected function sendlistlager($i, $id, $data) {
- $data2 = $data;
- foreach ($data2 as $key => $value) {
- $data2[$key]['artikel'] = $value['artikelid'];
- }
- $result = $this->RemoteCommand($id, 'sendlistlager', $data2);
- $this->app->DB->Update(
- sprintf(
- 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
- $data2[$i]['artikel'], $id
- )
- );
+ protected function sendlistlager(int $shop_id, array $data) {
+ $result = $this->RemoteCommand($shop_id, 'sendlistlager', $data);
return $result;
}
- protected function sendlist($i, $id, $data, $isLagerExported) {
- /** @var Shopexport $objShopexport */
- $objShopexport = $this->app->loadModule('shopexport');
- $changedHash = $objShopexport->hasArticleHashChanged($data[0]['artikel'], $id);
- $hash = $changedHash['hash'];
- //$changedHash = $changedHash['changed'];
+ protected function sendlist(int $shop_id, array $data, $isLagerExported) {
- $result = $this->RemoteCommand($id, 'sendlist', $data);
- $checkAo = $this->app->DB->Select(
- sprintf(
- 'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
- $data[0]['artikel'], $id
- )
- );
- if (empty($checkAo)) {
- $this->app->DB->Insert(
- sprintf(
- 'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
- VALUES (%d, %d, 1, 1) ',
- $data[0]['artikel'], $id
- )
- );
+ // See description of return format in function RemoteSendArticleList()
+ $result = $this->RemoteCommand($shop_id, 'sendlist', $data);
+
+ if (!empty($result) && is_array($result)) {
+ foreach ($result['articles'] as $artikelid) {
+ /** @var Shopexport $objShopexport */
+ $objShopexport = $this->app->loadModule('shopexport');
+ $changedHash = $objShopexport->hasArticleHashChanged($artikelid, $shop_id);
+ $hash = $changedHash['hash'];
+
+ $checkAo = $this->app->DB->Select(
+ sprintf(
+ 'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
+ $artikelid, $shop_id
+ )
+ );
+ if (empty($checkAo)) {
+ $this->app->DB->Insert(
+ sprintf(
+ 'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
+ VALUES (%d, %d, 1, 1) ',
+ $artikelid, $shop_id
+ )
+ );
+ }
+ $this->app->DB->Update(
+ sprintf(
+ "UPDATE artikel_onlineshops
+ SET last_article_transfer = NOW(), last_article_hash = '%s'
+ WHERE artikel = %d AND shop = %d",
+ $this->app->DB->real_escape_string($hash), $artikelid, $shop_id
+ )
+ );
+ }
}
- $this->app->DB->Update(
- sprintf(
- "UPDATE artikel_onlineshops
- SET last_article_transfer = NOW(), last_article_hash = '%s'
- WHERE artikel = %d AND shop = %d",
- $this->app->DB->real_escape_string($hash), $data[0]['artikel'], $id
- )
- );
- if (!empty($result) && is_array($result) && !empty($result['new'])) {
+
+ if (!empty($result) && is_array($result)) {
foreach ($result['new'] as $artikelid => $fremdnummer) {
$artikelid = (int) $artikelid;
$artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
if ($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
- ($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$id' OR shop2 = '$id' OR shop3 = '$id') LIMIT 1") ||
+ ($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$shop_id' OR shop2 = '$shop_id' OR shop3 = '$shop_id') LIMIT 1") ||
$this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
) && trim($fremdnummer) !== '') {
//Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
- if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
+ if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$shop_id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
$this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
- VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
+ VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$shop_id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
");
}
}
}
if (isset($result['anzahl'])) {
- $result = $result['anzahl'];
+ $result['count'] = $result['anzahl'];
}//Altes Verhalten
}
+
if (!$isLagerExported) {
- $data2 = $data;
- foreach ($data2 as $key => $value) {
- $data2[$key]['artikel'] = $value['artikelid'];
- }
- $this->RemoteCommand($id, 'sendlistlager', $data2);
- $this->app->DB->Update(
- sprintf(
- 'UPDATE artikel_onlineshops SET last_storage_transfer = NOW() WHERE artikel = %d AND shop = %d',
- $data2[$i]['artikel'], $id
- )
- );
+ $this->sendlistlager($shop_id, $data);
}
return $result;
}
- public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest {
- $orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
- if (empty($orderArr))
- return null;
+ public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest
+ {
+ $orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
+ if (empty($orderArr))
+ return null;
- $data = new OrderStatusUpdateRequest();
- $data->orderId = $orderId;
- $data->shopOrderId = $orderArr['shopextid'];
+ $data = new OrderStatusUpdateRequest();
+ $data->orderId = $orderId;
+ $data->shopOrderId = $orderArr['shopextid'];
- $statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
- if (in_array('storniert', $statusArr))
- $data->orderStatus = OrderStatus::Cancelled;
- if (in_array('abgeschlossen', $statusArr))
- $data->orderStatus = OrderStatus::Completed;
- if (in_array('freigegeben', $statusArr))
- $data->orderStatus = OrderStatus::InProgress;
- if (in_array('angelegt', $statusArr))
- $data->orderStatus = OrderStatus::Imported;
+ $statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
+ if (in_array('storniert', $statusArr))
+ $data->orderStatus = OrderStatus::Cancelled;
+ if (in_array('abgeschlossen', $statusArr))
+ $data->orderStatus = OrderStatus::Completed;
+ if (in_array('freigegeben', $statusArr))
+ $data->orderStatus = OrderStatus::InProgress;
+ if (in_array('angelegt', $statusArr))
+ $data->orderStatus = OrderStatus::Imported;
- $sql = "
+ $sql = "
SELECT DISTINCT
v.id,
v.tracking,
@@ -2170,20 +2197,20 @@ class Remote {
vlp.versandpaket = v.id OR v.lieferschein_ohne_pos = l.id
LEFT JOIN shopexport_versandarten sv ON
sv.versandart_wawision = v.versandart AND sv.shop = $shopId
- WHERE (a.id = $orderId OR a.teillieferungvon = $orderId) AND v.id IS NOT NULL
+ WHERE a.id = $orderId OR a.teillieferungvon = $orderId
ORDER BY v.id";
- $shipments = $this->app->DB->SelectArr($sql);
- foreach ($shipments as $shipment) {
- $item = new Shipment();
- $item->id = $shipment['id'];
- $item->trackingNumber = $shipment['tracking'];
- $item->trackingUrl = $shipment['tracking_link'];
- $item->shippingMethod = $shipment['versandart'];
- $data->shipments[] = $item;
- }
+ $shipments = $this->app->DB->SelectArr($sql);
+ foreach ($shipments as $shipment) {
+ $item = new Shipment();
+ $item->id = $shipment['id'];
+ $item->trackingNumber = $shipment['tracking'];
+ $item->trackingUrl = $shipment['tracking_link'];
+ $item->shippingMethod = $shipment['versandart'];
+ $data->shipments[] = $item;
+ }
- return $data;
+ return $data;
}
/**
@@ -2193,36 +2220,40 @@ class Remote {
* @throws Exception
*/
public function RemoteUpdateAuftrag($shopId, $orderId) {
- $data = $this->getDataToSendForUpdateOrder((int) $shopId, (int) $orderId);
- if ($data?->orderStatus !== OrderStatus::Completed)
- return;
+ $data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
+ if($data?->orderStatus !== OrderStatus::Completed)
+ return;
- $bearbeiter = 'Cronjob';
- if (isset($this->app->User)) {
- $bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
- }
+ $bearbeiter = 'Cronjob';
+ if (isset($this->app->User)) {
+ $bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
+ }
- $response = $this->RemoteCommand($shopId, 'updateauftrag', $data);
- if ($response instanceOf ShopConnectorResponseInterface && !$response->isSuccessful()) {
- $query = sprintf('UPDATE `auftrag`
+ $response = $this->RemoteCommand($shopId, 'updateauftrag', $data);
+ if ($response instanceOf ShopConnectorResponseInterface && !$response->isSuccessful()) {
+ $query = sprintf('UPDATE `auftrag`
SET `shop_status_update_attempt` = `shop_status_update_attempt` + 1,
`shop_status_update_last_attempt_at` = NOW()
WHERE `id` = %d', $orderId);
- $this->app->DB->Update($query);
+ $this->app->DB->Update($query);
- $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
- $this->app->erp->Logfile('Versandmeldung an Shop fehlgeschlagen', print_r([
- 'orderId' => $orderId,
- 'shopId' => $shopId,
- 'message' => $response->getMessage()], true));
+ $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop fehlgeschlagen', $bearbeiter);
- return;
+ $this->logger->error('Versandmeldung an Shop fehlgeschlagen',
+ [
+ 'orderId' => $orderId,
+ 'shopId' => $shopId,
+ 'message' => $response->getMessage()
+ ]
+ );
+
+ return;
+ }
+
+ $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
+ $this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
}
- $this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
- $this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
- }
-
/**
* @param int $shopId
* @param string $auftrag
@@ -2497,6 +2528,7 @@ class Remote {
}
return '';
}
+
if ($shoptyp === 'intern') {
if ($modulename != '') {
if ($this->app->erp->ModulVorhanden($modulename)) {
@@ -2506,14 +2538,15 @@ class Remote {
$obj->getKonfig($id, $data);
}
$method = 'Import' . $action;
+
if (method_exists($obj, $method)) {
try {
$ret = $obj->$method();
} catch (Exception $e) {
if ($isActionAuth) {
- return 'Fehler: ' . $e->getMessage();
+ return 'Fehler Auth: ' . $e->getMessage();
}
- return '';
+ return 'Fehler: ' . $e->getMessage();
}
if (!empty($this->app->stringcleaner)) {
@@ -2521,6 +2554,8 @@ class Remote {
}
$this->parseReturn($ret, $id, $action);
return $ret;
+ } else {
+ return 'Fehler: Funktion nicht implementiert: ' . $method;
}
} elseif ($isActionAuth) {
return 'Fehler: Importer konnte nicht initialisiert werden';
@@ -2575,7 +2610,13 @@ class Remote {
$post_data['data'] = base64_encode(serialize($data));
$client->timeout = 120;
if (!$client->post($geturl, $post_data)) {
- $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection, 'An error occurred: ' . $client->getError()));
+
+ $this->logger->error('An error occurred',
+ [
+ 'error' => $client->getError()
+ ]
+ );
+
throw new Exception('An error occurred: ' . $client->getError());
//return 'Netzwerkverbindung von WaWison zu Shopimporter fehlgeschlagen: '.$client->getError();
}
@@ -2646,7 +2687,12 @@ class Remote {
$post_data['data'] = base64_encode($aes->encrypt(serialize($data)));
if (!$client->post($geturl, $post_data)) {
- $this->app->erp->LogFile(mysqli_real_escape_string($this->app->DB->connection, 'An error occurred: ' . $client->getError()));
+ $this->logger->error('An error occurred',
+ [
+ 'error' => $client->getError()
+ ]
+ );
+
throw new Exception('An error occurred: ' . $client->getError());
}
return unserialize($aes->decrypt(base64_decode($client->getContent())));
From 00da78e863b7e33534f20ba8efa17ce98ea7de7f Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 2 Sep 2024 20:33:50 +0200
Subject: [PATCH 79/87] verbindlichkeit drucken
---
www/pages/content/verbindlichkeit_list.tpl | 4 +++-
www/pages/verbindlichkeit.php | 27 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/www/pages/content/verbindlichkeit_list.tpl b/www/pages/content/verbindlichkeit_list.tpl
index 3db69445..066b0350 100644
--- a/www/pages/content/verbindlichkeit_list.tpl
+++ b/www/pages/content/verbindlichkeit_list.tpl
@@ -75,8 +75,10 @@
[MANUELLFREIGABEEINKAUF]
[MANUELLFREIGABEBUCHHALTUNG]
[ALSBEZAHLTMARKIEREN]
+ {|drucken|}
- {|Ausführen|}
+ {|Drucker|}: [SELDRUCKER]
+ {|Ausführen|}
[TAB1NEXT]
diff --git a/www/pages/verbindlichkeit.php b/www/pages/verbindlichkeit.php
index f73f12fa..dd22f79a 100644
--- a/www/pages/verbindlichkeit.php
+++ b/www/pages/verbindlichkeit.php
@@ -502,6 +502,31 @@ class Verbindlichkeit {
}
}
break;
+ case 'drucken':
+ $drucker = $this->app->Secure->GetPOST('seldrucker');
+ foreach ($selectedIds as $id) {
+ $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','verbindlichkeit',$id);
+ if (!empty($file_attachments)) {
+ foreach ($file_attachments as $file_attachment) {
+ if ($this->app->erp->GetDateiEndung($file_attachment) == 'pdf') {
+ $file_contents = $this->app->erp->GetDatei($file_attachment);
+ $verbindlichkeit = $this->app->DB->SelectRow("SELECT DATE_FORMAT(rechnungsdatum, '%Y%m%d') rechnungsdatum, belegnr FROM verbindlichkeit WHERE id = ".$id." LIMIT 1");
+ $file_name = $verbindlichkeit['rechnungsdatum']."_VB".$verbindlichkeit['belegnr'].".pdf";
+ $file_path = rtrim($this->app->erp->GetTMP(),'/')."/".$file_name;
+ $handle = fopen ($file_path, "wb");
+ if ($handle)
+ {
+ fwrite($handle, $file_contents);
+ fclose($handle);
+ $this->app->printer->Drucken($drucker,$file_path);
+ } else {
+ $this->app->YUI->Message('error',"Drucken fehlgeschlagen!");
+ }
+ }
+ }
+ }
+ }
+ break;
}
}
break;
@@ -530,6 +555,8 @@ class Verbindlichkeit {
$this->app->User->SetParameter('table_verbindlichkeit_list_zahlbarbis', '');
$this->app->User->SetParameter('table_verbindlichkeit_list_skontobis', '');
+ $this->app->Tpl->Set('SELDRUCKER', $this->app->erp->GetSelectDrucker());
+
$this->app->Tpl->Parse('PAGE', "verbindlichkeit_list.tpl");
}
From 04de0df0b669565cdc158e77b78995a4d5496d9a Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Mon, 2 Sep 2024 21:00:16 +0200
Subject: [PATCH 80/87] lieferantengutschrift drucken
---
.../content/lieferantengutschrift_list.tpl | 2 ++
www/pages/lieferantengutschrift.php | 27 +++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/www/pages/content/lieferantengutschrift_list.tpl b/www/pages/content/lieferantengutschrift_list.tpl
index 381fa508..7757490e 100644
--- a/www/pages/content/lieferantengutschrift_list.tpl
+++ b/www/pages/content/lieferantengutschrift_list.tpl
@@ -75,7 +75,9 @@
[MANUELLFREIGABEEINKAUF]
[MANUELLFREIGABEBUCHHALTUNG]
[ALSBEZAHLTMARKIEREN]
+ {|drucken|}
+ {|Drucker|}: [SELDRUCKER]
{|Ausführen|}
diff --git a/www/pages/lieferantengutschrift.php b/www/pages/lieferantengutschrift.php
index ae321994..0bc5ffa5 100644
--- a/www/pages/lieferantengutschrift.php
+++ b/www/pages/lieferantengutschrift.php
@@ -514,6 +514,31 @@ class lieferantengutschrift {
}
}
break;
+ case 'drucken':
+ $drucker = $this->app->Secure->GetPOST('seldrucker');
+ foreach ($selectedIds as $id) {
+ $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','lieferantengutschrift',$id);
+ if (!empty($file_attachments)) {
+ foreach ($file_attachments as $file_attachment) {
+ if ($this->app->erp->GetDateiEndung($file_attachment) == 'pdf') {
+ $file_contents = $this->app->erp->GetDatei($file_attachment);
+ $lieferantengutschrift = $this->app->DB->SelectRow("SELECT DATE_FORMAT(rechnungsdatum, '%Y%m%d') rechnungsdatum, belegnr FROM lieferantengutschrift WHERE id = ".$id." LIMIT 1");
+ $file_name = $lieferantengutschrift['rechnungsdatum']."_LG".$lieferantengutschrift['belegnr'].".pdf";
+ $file_path = rtrim($this->app->erp->GetTMP(),'/')."/".$file_name;
+ $handle = fopen ($file_path, "wb");
+ if ($handle)
+ {
+ fwrite($handle, $file_contents);
+ fclose($handle);
+ $this->app->printer->Drucken($drucker,$file_path);
+ } else {
+ $this->app->YUI->Message('error',"Drucken fehlgeschlagen!");
+ }
+ }
+ }
+ }
+ }
+ break;
}
}
break;
@@ -542,6 +567,8 @@ class lieferantengutschrift {
$this->app->User->SetParameter('table_lieferantengutschrift_list_zahlbarbis', '');
$this->app->User->SetParameter('table_lieferantengutschrift_list_skontobis', '');
+ $this->app->Tpl->Set('SELDRUCKER', $this->app->erp->GetSelectDrucker());
+
$this->app->Tpl->Parse('PAGE', "lieferantengutschrift_list.tpl");
}
From 1ff2878d0688369c080e0ddc1d1f2688c5b69430 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Tue, 3 Sep 2024 19:13:17 +0200
Subject: [PATCH 81/87] exportbuchhaltung PDFs
---
.../content/exportbuchhaltung_export.tpl | 6 +-
www/pages/exportbuchhaltung.php | 431 +++++++++++-------
2 files changed, 263 insertions(+), 174 deletions(-)
diff --git a/www/pages/content/exportbuchhaltung_export.tpl b/www/pages/content/exportbuchhaltung_export.tpl
index b73af264..980863de 100644
--- a/www/pages/content/exportbuchhaltung_export.tpl
+++ b/www/pages/content/exportbuchhaltung_export.tpl
@@ -61,7 +61,11 @@
-
+
+ {|PDF-Dateien exportieren:|}
+
+
+
diff --git a/www/pages/exportbuchhaltung.php b/www/pages/exportbuchhaltung.php
index b96476e1..fa400f7d 100644
--- a/www/pages/exportbuchhaltung.php
+++ b/www/pages/exportbuchhaltung.php
@@ -1,13 +1,13 @@
_data = $data;
parent::__construct($message);
@@ -46,6 +46,91 @@ class Exportbuchhaltung
var $belegnummer;
var $headerwritten = false;
+ function typen($rechnung, $gutschrift, $verbindlichkeit, $lieferantengutschrift) : array {
+ return(
+ array(
+ array(
+ 'typ' => 'rechnung',
+ 'subtable' => 'rechnung_position',
+ 'kennzeichen' => 'S',
+ 'kennzeichen_negativ' => 'H',
+ 'field_belegnr' => 'b.belegnr',
+ 'field_name' => 'b.name',
+ 'field_date' => 'datum',
+ 'field_auftrag' => 'MAKE_SET(3,b.auftrag,(SELECT auftrag.internet FROM auftrag WHERE auftrag.id = auftragid))',
+ 'field_zahlweise' => 'CONCAT(UCASE(LEFT(b.zahlungsweise, 1)),SUBSTRING(b.zahlungsweise, 2))',
+ 'field_kontonummer' => 'a.kundennummer_buchhaltung',
+ 'field_kundennummer' => 'b.kundennummer',
+ 'field_betrag_gesamt' => 'b.soll',
+ 'field_betrag' => 'p.umsatz_brutto_gesamt',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\',\'storniert\')',
+ 'Buchungstyp' => 'SR',
+ 'do' => $rechnung,
+ 'pdf' => 'print'
+ ),
+ array(
+ 'typ' => 'gutschrift',
+ 'subtable' => 'gutschrift_position',
+ 'kennzeichen' => 'H',
+ 'kennzeichen_negativ' => 'S',
+ 'field_belegnr' => 'b.belegnr',
+ 'field_name' => 'b.name',
+ 'field_date' => 'datum',
+ 'field_auftrag' => '\'\'',
+ 'field_zahlweise' => '\'\'',
+ 'field_kontonummer' => 'a.kundennummer_buchhaltung',
+ 'field_kundennummer' => 'b.kundennummer',
+ 'field_betrag_gesamt' => 'b.soll',
+ 'field_betrag' => 'p.umsatz_brutto_gesamt',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\')',
+ 'Buchungstyp' => '',
+ 'do' => $gutschrift,
+ 'pdf' => 'print'
+ ),
+ array(
+ 'typ' => 'verbindlichkeit',
+ 'subtable' => 'verbindlichkeit_position',
+ 'kennzeichen' => 'H',
+ 'kennzeichen_negativ' => 'S',
+ 'field_belegnr' => 'b.rechnung',
+ 'field_name' => 'a.name',
+ 'field_date' => 'rechnungsdatum',
+ 'field_auftrag' => 'b.auftrag',
+ 'field_zahlweise' => '\'\'',
+ 'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
+ 'field_kundennummer' => 'a.lieferantennummer',
+ 'field_betrag_gesamt' => 'b.betrag',
+ 'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
+ 'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\')',
+ 'Buchungstyp' => '',
+ 'do' => $verbindlichkeit,
+ 'pdf' => 'load'
+ ),
+ array(
+ 'typ' => 'lieferantengutschrift',
+ 'subtable' => 'lieferantengutschrift_position',
+ 'kennzeichen' => 'S',
+ 'kennzeichen_negativ' => 'H',
+ 'field_belegnr' => 'b.rechnung',
+ 'field_name' => 'a.name',
+ 'field_date' => 'rechnungsdatum',
+ 'field_auftrag' => '\'\'',
+ 'field_zahlweise' => '\'\'',
+ 'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
+ 'field_kundennummer' => 'a.lieferantennummer',
+ 'field_betrag_gesamt' => 'b.betrag',
+ 'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
+ 'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\')',
+ 'Buchungstyp' => '',
+ 'do' => $lieferantengutschrift,
+ 'pdf' => 'load'
+ )
+ )
+ );
+ }
+
/**
* Exportbelegepositionen constructor.
*
@@ -57,12 +142,12 @@ class Exportbuchhaltung
$this->app = $app;
if ($intern == true) {
return;
- }
+ }
$this->app->ActionHandlerInit($this);
$this->app->ActionHandler("export", "ExportBuchhaltungList");
$this->app->ActionHandlerListen($app);
- $this->app->erp->Headlines('Buchhaltung Export DATEV');
+ $this->app->erp->Headlines('Buchhaltung Export DATEV');
}
function ExportBuchhaltungList() {
@@ -70,7 +155,7 @@ class Exportbuchhaltung
$von_form = $this->app->Secure->GetPOST("von");
$bis_form = $this->app->Secure->GetPOST("bis");
$von = date_create($this->app->erp->ReplaceDatum(true, $von_form, true));
- $bis = date_create($this->app->erp->ReplaceDatum(true, $bis_form, true));
+ $bis = date_create($this->app->erp->ReplaceDatum(true, $bis_form, true));
$projektkuerzel = $this->app->Secure->GetPOST("projekt");
$projekt = $this->app->erp->ReplaceProjekt(true, $projektkuerzel, true);
@@ -81,12 +166,13 @@ class Exportbuchhaltung
$diffignore = $this->app->Secure->GetPOST("diffignore");
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
$format = $this->app->Secure->GetPOST('format');
+ $pdfexport = $this->app->Secure->GetPOST("pdfexport");
$account_id = null;
if (!empty($sachkonto)) {
$sachkonto_kennung = explode(' ',$sachkonto)[0];
- $account_id = $this->app->DB->SelectArr("SELECT id from kontorahmen WHERE sachkonto = '".$sachkonto_kennung."'")[0]['id'];
- }
+ $account_id = $this->app->DB->SelectArr("SELECT id from kontorahmen WHERE sachkonto = '".$sachkonto_kennung."'")[0]['id'];
+ }
$msg = "";
@@ -101,13 +187,13 @@ class Exportbuchhaltung
$vbchecked = true;
$lgchecked = true;
}
-
+
$missing_obligatory = array();
$buchhaltung_berater = $this->app->erp->Firmendaten('buchhaltung_berater');
$buchhaltung_mandant = $this->app->erp->Firmendaten('buchhaltung_mandant');
$buchhaltung_wj_beginn = $this->app->erp->Firmendaten('buchhaltung_wj_beginn');
- $buchhaltung_sachkontenlaenge = $this->app->erp->Firmendaten('buchhaltung_sachkontenlaenge');
+ $buchhaltung_sachkontenlaenge = $this->app->erp->Firmendaten('buchhaltung_sachkontenlaenge');
$buchhaltung_berater = $this->app->erp->Firmendaten('buchhaltung_berater');
if (empty($buchhaltung_berater)) {
@@ -124,15 +210,15 @@ class Exportbuchhaltung
$buchhaltung_sachkontenlaenge = $this->app->erp->Firmendaten('buchhaltung_sachkontenlaenge');
if (empty($buchhaltung_sachkontenlaenge)) {
$missing_obligatory[] = "Sachkontenlänge";
- }
+ }
if (!empty($missing_obligatory)) {
$msg = "Angaben in den Grundeinstellungen fehlen: ".implode(", ",$missing_obligatory).".
";
- }
+ }
//---------- DOWNLOAD HERE
if ($submit == 'Download') {
- $dataok = true;
+ $dataok = true;
if (
!$rgchecked &&
@@ -148,7 +234,7 @@ class Exportbuchhaltung
$von_next_year = $von_next_year->modify("+1 year");;
$buchhaltung_wj_beginn = date_create(date_format($von,'Y').$buchhaltung_wj_beginn);
- if ($buchhaltung_wj_beginn > $von) {
+ if ($buchhaltung_wj_beginn > $von) {
$buchhaltung_wj_beginn = $buchhaltung_wj_beginn->modify("-1 year");
}
@@ -161,20 +247,95 @@ class Exportbuchhaltung
}
if ($dataok) {
- $filename = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
+ $filename_csv = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
try {
- $csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung, $format);
- header("Content-Disposition: attachment; filename=" . $filename);
- header("Pragma: no-cache");
- header("Expires: 0");
- echo($csv);
+ $csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename_csv, $diffignore, $sachkonto_kennung, $format);
+ if ($pdfexport) {
+
+ $dateinamezip = 'Export_Buchhaltung_'.date('Y-m-d').'.zip';
+
+ $zip = new ZipArchive;
+ $zip->open($dateinamezip, ZipArchive::CREATE);
+
+ $zip->addFromString($typ['typ']."/".$filename_csv, $csv);
+
+ $typen = $this->typen($rgchecked, $gschecked, $vbchecked, $lgchecked);
+
+ foreach ($typen as $typ) {
+ $sql = "
+ SELECT id, ".$typ['field_belegnr']." belegnr FROM ".$typ['typ']." b
+ WHERE
+ b.".$typ['field_date']." BETWEEN '".date_format($von,"Y-m-d")."' AND '".date_format($bis,"Y-m-d")."' AND (b.projekt=$projekt OR $projekt=0)".$typ['condition_where'];
+ $belege = $this->app->DB->SelectArr($sql);
+ foreach ($belege as $beleg) {
+ switch ($typ['pdf']) {
+ case 'print':
+ switch ($typ['typ']) {
+ case 'rechnung':
+ if(class_exists('GutschriftPDFCustom')) {
+ $Brief = new RechnungPDFCustom($this->app,$projekt);
+ }
+ else{
+ $Brief = new RechnungPDF($this->app,$projekt);
+ }
+ $Brief->GetRechnung($beleg['id']);
+ break;
+ case 'gutschrift':
+ if(class_exists('RechnungPDFCustom')) {
+ $Brief = new GutschriftPDFCustom($this->app,$projekt);
+ }
+ else{
+ $Brief = new GutschriftPDF($this->app,$projekt);
+ }
+ $Brief->GetGutschrift($beleg['id']);
+ break;
+ default:
+ exit();
+ break;
+ }
+ $tmpfile = $Brief->displayTMP();
+ $file_name = $beleg['belegnr'].".pdf";
+ $zip->addFromString($typ['typ']."/".$file_name, file_get_contents($tmpfile));
+ break;
+ case 'load':
+ $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%',$typ['typ'],$beleg['id']);
+ $suffix = "";
+ $count = 0;
+ foreach ($file_attachments as $file_attachment) {
+ if ($this->app->erp->GetDateiEndung($file_attachment) == 'pdf') {
+ $file_contents = $this->app->erp->GetDatei($file_attachment);
+ $file_name = filter_var($beleg['belegnr'],FILTER_SANITIZE_EMAIL).$suffix.".pdf";
+ $zip->addFromString($typ['typ']."/".$file_name, $file_contents);
+ $count++;
+ $suffix = "_".$count;
+ }
+ }
+ break;
+ }
+ }
+ }
+ $zip->close();
+
+ // download
+ header('Content-Type: application/zip');
+ header("Content-Disposition: attachment; filename=$dateinamezip");
+ header('Content-Length: ' . filesize($dateinamezip));
+
+ readfile($dateinamezip);
+ unlink($dateinamezip);
+ } else {
+ header("Content-Disposition: attachment; filename=" . $filename_csv);
+ header("Pragma: no-cache");
+ header("Expires: 0");
+ echo($csv);
+ }
$this->app->ExitXentral();
- }
+ }
catch (ConsistencyException $e) {
$msg = "Inkonsistente Daten (".$e->getMessage()."): ";
$data = $e->getData();
-
+
$count = 0;
foreach($data as $item) {
$msg .= $item['typ']." ".$item['belegnr']." (Kopf ".$this->app->erp->ReplaceMengeBetrag(false,$item['betrag_gesamt'],false)." Positionen ".$this->app->erp->ReplaceMengeBetrag(false,$item['betrag_summe'],false).") ";
@@ -187,7 +348,7 @@ class Exportbuchhaltung
$msg .= "
";
}
}
- }
+ }
//---------- DOWNLOAD HERE
$this->app->erp->MenuEintrag("index.php?module=exportbuchhaltung&action=export", "Übersicht");
@@ -204,21 +365,22 @@ class Exportbuchhaltung
$this->app->Tpl->SET('VBCHECKED',$vbchecked?'checked':'');
$this->app->Tpl->SET('LGCHECKED',$lgchecked?'checked':'');
$this->app->Tpl->SET('DIFFIGNORE',$diffignore?'checked':'');
+ $this->app->Tpl->SET('PDFEXPORT',$pdfexport?'checked':'');
+
+ $this->app->Tpl->SET('VON', $von_form);
+ $this->app->Tpl->SET('BIS', $bis_form);
+ $this->app->Tpl->SET('PROJEKT', $projektkuerzel);
+ $this->app->Tpl->SET('SACHKONTO', $sachkonto);
- $this->app->Tpl->SET('VON', $von_form);
- $this->app->Tpl->SET('BIS', $bis_form);
- $this->app->Tpl->SET('PROJEKT', $projektkuerzel);
- $this->app->Tpl->SET('SACHKONTO', $sachkonto);
-
$this->app->Tpl->Parse('PAGE', "exportbuchhaltung_export.tpl");
}
/*
* Create DATEV Buchhungsstapel
* format: "ISO-8859-1", "UTF-8", "UTF-8-BOM"
- * @throws ConsistencyException with string (list of items) if consistency check fails and no sachkonto for differences is given
- */
- function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences, string $format = "ISO-8859-1") : string {
+ * @throws ConsistencyException with string (list of items) if consistency check fails and no sachkonto for differences is given
+ */
+ function DATEV_Buchuchungsstapel(bool $rechnung, bool $gutschrift, bool $verbindlichkeit, bool $lieferantengutschrift, string $berater, string $mandant, datetime $wj_beginn, int $sachkontenlaenge, datetime $von, datetime $bis, int $projekt = 0, string $filename = 'EXTF_Buchungsstapel_DATEV_export.csv', $diffignore = false, $sachkonto_differences, string $format = "ISO-8859-1") : string {
$datev_header_definition = array (
'1' => 'Kennzeichen',
@@ -254,7 +416,7 @@ class Exportbuchhaltung
'31' => 'Anwendungs- information'
);
- $datev_buchungsstapel_definition = array (
+ $datev_buchungsstapel_definition = array (
'1' => 'Umsatz',
'2' => 'Soll-/Haben-Kennzeichen',
'3' => 'WKZ Umsatz',
@@ -387,7 +549,7 @@ class Exportbuchhaltung
}
else {
$kuerzel = $usernamearr[0][0].$usernamearr[1][0];
- }
+ }
$data['Kennzeichen'] = 'EXTF';
$data['Versionsnummer'] = '700';
@@ -424,12 +586,12 @@ class Exportbuchhaltung
// Start
$csv = "";
- // Output data header row
+ // Output data header row
$comma = "";
foreach ($datev_header_definition as $key => $value) {
if (!isset($data[$value])) {
$data[$value] = '';
- }
+ }
$csv .= $comma.'"'.$data[$value].'"';
$comma = ";";
}
@@ -438,104 +600,27 @@ class Exportbuchhaltung
// Output column captions
$comma = "";
foreach ($datev_buchungsstapel_definition as $key => $value) {
- $csv .= $comma.'"'.$value.'"';
+ $csv .= $comma.'"'.$value.'"';
$comma = ";";
}
$csv .= "\r\n";
- // Collate data and transform in RAM
- $typen = array(
- array(
- 'typ' => 'rechnung',
- 'subtable' => 'rechnung_position',
- 'kennzeichen' => 'S',
- 'kennzeichen_negativ' => 'H',
- 'field_belegnr' => 'b.belegnr',
- 'field_name' => 'b.name',
- 'field_date' => 'datum',
- 'field_auftrag' => 'MAKE_SET(3,b.auftrag,(SELECT auftrag.internet FROM auftrag WHERE auftrag.id = auftragid))',
- 'field_zahlweise' => 'CONCAT(UCASE(LEFT(b.zahlungsweise, 1)),SUBSTRING(b.zahlungsweise, 2))',
- 'field_kontonummer' => 'a.kundennummer_buchhaltung',
- 'field_kundennummer' => 'b.kundennummer',
- 'field_betrag_gesamt' => 'b.soll',
- 'field_betrag' => 'p.umsatz_brutto_gesamt',
- 'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\',\'storniert\')',
- 'Buchungstyp' => 'SR',
- 'do' => $rechnung
- ),
- array(
- 'typ' => 'gutschrift',
- 'subtable' => 'gutschrift_position',
- 'kennzeichen' => 'H',
- 'kennzeichen_negativ' => 'S',
- 'field_belegnr' => 'b.belegnr',
- 'field_name' => 'b.name',
- 'field_date' => 'datum',
- 'field_auftrag' => '\'\'',
- 'field_zahlweise' => '\'\'',
- 'field_kontonummer' => 'a.kundennummer_buchhaltung',
- 'field_kundennummer' => 'b.kundennummer',
- 'field_betrag_gesamt' => 'b.soll',
- 'field_betrag' => 'p.umsatz_brutto_gesamt',
- 'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\')',
- 'Buchungstyp' => '',
- 'do' => $gutschrift
- ),
- array(
- 'typ' => 'verbindlichkeit',
- 'subtable' => 'verbindlichkeit_position',
- 'kennzeichen' => 'H',
- 'kennzeichen_negativ' => 'S',
- 'field_belegnr' => 'b.rechnung',
- 'field_name' => 'a.name',
- 'field_date' => 'rechnungsdatum',
- 'field_auftrag' => 'b.auftrag',
- 'field_zahlweise' => '\'\'',
- 'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
- 'field_kundennummer' => 'a.lieferantennummer',
- 'field_betrag_gesamt' => 'b.betrag',
- 'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
- 'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
- 'condition_where' => ' AND b.status IN (\'freigegeben\')',
- 'Buchungstyp' => '',
- 'do' => $verbindlichkeit
- ),
- array(
- 'typ' => 'lieferantengutschrift',
- 'subtable' => 'lieferantengutschrift_position',
- 'kennzeichen' => 'S',
- 'kennzeichen_negativ' => 'H',
- 'field_belegnr' => 'b.rechnung',
- 'field_name' => 'a.name',
- 'field_date' => 'rechnungsdatum',
- 'field_auftrag' => '\'\'',
- 'field_zahlweise' => '\'\'',
- 'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
- 'field_kundennummer' => 'a.lieferantennummer',
- 'field_betrag_gesamt' => 'b.betrag',
- 'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
- 'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
- 'condition_where' => ' AND b.status IN (\'freigegeben\')',
- 'Buchungstyp' => '',
- 'do' => $lieferantengutschrift
- )
- );
-
- foreach ($typen as $typ) {
+ // Collate data and transform in RAM
+ $typen = $this->typen($rechnung, $gutschrift, $verbindlichkeit, $lieferantengutschrift);
+ foreach ($typen as $typ) {
if (!$typ['do']) {
continue;
}
-
if (!empty($typ['field_gegenkonto'])) {
$sql_gegenkonto = $typ['field_gegenkonto'];
- } else
+ } else
{
$sql_gegenkonto = "NULL";
}
-
- $sql = "SELECT
+
+ $sql = "SELECT
".$typ['typ']." id,
".$typ['field_belegnr']." as belegnr,
".$typ['field_auftrag']." as auftrag,
@@ -550,18 +635,18 @@ class Exportbuchhaltung
ROUND(".$typ['field_betrag'].",2) as betrag,
".$sql_gegenkonto." as gegenkonto,
b.waehrung as pos_waehrung
- FROM
- ".$typ['typ']." b
- LEFT JOIN
- ".$typ['subtable']." p
- ON
- b.id = p.".$typ['typ']."
- INNER JOIN
- adresse a ON a.id = b.adresse
- WHERE
- b.".$typ['field_date']." BETWEEN '".date_format($von,"Y-m-d")."' AND '".date_format($bis,"Y-m-d")."' AND (b.projekt=$projekt OR $projekt=0)".$typ['condition_where'];
+ FROM
+ ".$typ['typ']." b
+ LEFT JOIN
+ ".$typ['subtable']." p
+ ON
+ b.id = p.".$typ['typ']."
+ INNER JOIN
+ adresse a ON a.id = b.adresse
+ WHERE
+ b.".$typ['field_date']." BETWEEN '".date_format($von,"Y-m-d")."' AND '".date_format($bis,"Y-m-d")."' AND (b.projekt=$projekt OR $projekt=0)".$typ['condition_where'];
- // Check consistency of positions
+ // Check consistency of positions
if (!$diffignore) {
$sql_check = "SELECT *
FROM
@@ -581,52 +666,52 @@ class Exportbuchhaltung
GROUP BY
id
) summen
- WHERE betrag_gesamt <> betrag_summe OR betrag_summe IS NULL";
-
+ WHERE betrag_gesamt <> betrag_summe OR betrag_summe IS NULL";
+
$result = $this->app->DB->SelectArr($sql_check);
- if (!empty($result)) {
-
- if (!$sachkonto_differences) {
+ if (!empty($result)) {
+
+ if (!$sachkonto_differences) {
$e = new ConsistencyException(ucfirst($typ['typ']),$result);
throw $e;
} else {
- // Create differences entries
+ // Create differences entries
foreach ($result as $row) {
-
+
$posid = $row['pos_id'];
$tmpsteuersatz = 0;
$tmpsteuertext = '';
$erloes = '';
$result = array();
- $this->app->erp->GetSteuerPosition($typ['typ'], $posid, $tmpsteuersatz, $tmpsteuertext, $erloes);
-
- $data = array();
-
- $difference = $row['betrag_gesamt']-$row['betrag_summe'];
-
+ $this->app->erp->GetSteuerPosition($typ['typ'], $posid, $tmpsteuersatz, $tmpsteuertext, $erloes);
+
+ $data = array();
+
+ $difference = $row['betrag_gesamt']-$row['betrag_summe'];
+
$data['Umsatz'] = number_format(abs($difference), 2, ',', ''); // obligatory
$data['EU-Steuersatz (Bestimmung)'] = 0;
$data['WKZ Umsatz'] = $row['waehrung'];
$data['Belegfeld 1'] = mb_strimwidth($row['belegnr'],0,36);
$data['Konto'] = $row['kundennummer'];
- $data['Soll-/Haben-Kennzeichen'] = ($difference < 0)?'S':'H'; // obligatory
-
- $data['Gegenkonto (ohne BU-Schlüssel)'] = $sachkonto_differences; // obligatory
-
- $data['Belegdatum'] = date_format(date_create($row['datum']),"dm"); // obligatory
+ $data['Soll-/Haben-Kennzeichen'] = ($difference < 0)?'S':'H'; // obligatory
+
+ $data['Gegenkonto (ohne BU-Schlüssel)'] = $sachkonto_differences; // obligatory
+
+ $data['Belegdatum'] = date_format(date_create($row['datum']),"dm"); // obligatory
$data['Buchungstext'] = "Differenz";
$data['EU-Mitgliedstaat u. UStID (Bestimmung)'] = $row['ustid'];
$data['Auftragsnummer'] = $row['auftrag'];
$data['Zahlweise'] = $row['zahlweise'];
$csv .= $this->create_line($datev_buchungsstapel_definition,$data);
- }
- }
+ }
+ }
}
- } // diffignore
+ } // diffignore
// Query position data
- $arr = $this->app->DB->Query($sql);
- while ($row = $this->app->DB->Fetch_Assoc($arr)) {
+ $arr = $this->app->DB->Query($sql);
+ while ($row = $this->app->DB->Fetch_Assoc($arr)) {
//print_r($row);
@@ -635,7 +720,7 @@ class Exportbuchhaltung
$tmpsteuertext = '';
$erloes = '';
$result = array();
- $this->app->erp->GetSteuerPosition($typ['typ'], $posid, $tmpsteuersatz, $tmpsteuertext, $erloes);
+ $this->app->erp->GetSteuerPosition($typ['typ'], $posid, $tmpsteuersatz, $tmpsteuertext, $erloes);
$data = array();
@@ -644,7 +729,7 @@ class Exportbuchhaltung
$data['Soll-/Haben-Kennzeichen'] = $typ['kennzeichen']; // obligatory
} else if ($row['betrag'] < 0) {
$data['Umsatz'] = number_format(-$row['betrag'], 2, ',', ''); // obligatory
- $data['Soll-/Haben-Kennzeichen'] = $typ['kennzeichen_negativ']; // obligatory
+ $data['Soll-/Haben-Kennzeichen'] = $typ['kennzeichen_negativ']; // obligatory
} else {
continue;
}
@@ -653,23 +738,23 @@ class Exportbuchhaltung
$data['WKZ Umsatz'] = $row['pos_waehrung'];
$data['Belegfeld 1'] = mb_strimwidth($row['belegnr'],0,36);
$data['Konto'] = $row['kundennummer']; // obligatory
-
+
if (!empty($typ['field_gegenkonto'])) {
- $data['Gegenkonto (ohne BU-Schlüssel)'] = $row['gegenkonto']; // obligatory
+ $data['Gegenkonto (ohne BU-Schlüssel)'] = $row['gegenkonto']; // obligatory
} else {
$data['Gegenkonto (ohne BU-Schlüssel)'] = $erloes; // obligatory
}
-
+
$data['Belegdatum'] = date_format(date_create($row['datum']),"dm"); // obligatory
$data['Buchungstext'] = mb_strimwidth($row['name'],0,60);
$data['EU-Mitgliedstaat u. UStID (Bestimmung)'] = $row['ustid'];
-
+
$data['Auftragsnummer'] = ($row['auftrag']!=0)?$row['auftrag']:'';
$data['Zahlweise'] = $row['zahlweise'];
-
+
$csv .= $this->create_line($datev_buchungsstapel_definition,$data);
}
- }
+ }
$csv .= '"0";"S";"EUR";"0";"";"";"1234";"1370";"";"101";"";"";"";"Testbuchung";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"0";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";"";""'; // Testbuchung
@@ -685,22 +770,22 @@ class Exportbuchhaltung
}
return($csv);
- }
-
- function create_line($definition, $data) : string {
+ }
+
+ function create_line($definition, $data) : string {
$csv = "";
- $comma = "";
+ $comma = "";
foreach ($definition as $key => $value) {
if (!isset($data[$value])) {
$data[$value] = '';
- }
+ }
$csv .= $comma.'"'.$data[$value].'"';
$comma = ";";
}
- $csv .= "\r\n";
- return($csv);
+ $csv .= "\r\n";
+ return($csv);
}
-
+
}
/*
From e51e1db15c607f957ec5f291b13775caa2fa03fd Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 4 Sep 2024 11:13:38 +0200
Subject: [PATCH 82/87] bugfix GetNextArtikelNummer skip existing numbers
---
www/lib/class.erpapi.php | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index 9b153b78..2e46db66 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -27558,6 +27558,16 @@ function Firmendaten($field,$projekt="")
return $buchstaben_anteil_string.$neue_nummer;
}
+ function CalcNextArtikelNummer($nummer) {
+ $check = null;
+ do {
+ $nummer = $this->CalcNextNummer($nummer);
+ $sql = "SELECT id FROM artikel WHERE nummer = '".$nummer."'";
+ $check = $this->app->DB->Select($sql);
+ } while (!empty($check));
+ return ($nummer);
+ }
+
function GetNextNummer($type,$projekt="",$data="")
{
$doctype = $type;
@@ -28032,7 +28042,7 @@ function Firmendaten($field,$projekt="")
$nurzahlen = preg_replace("/[^0-9]/","",$next_nummer_alt);
$laenge = strlen($nurzahlen);
- $next_nummer = $this->CalcNextNummer($next_nummer_alt);
+ $next_nummer = $this->CalcNextArtikelNummer($next_nummer_alt);
//$nurbuchstaben.str_pad($nurzahlen+1, $laenge ,'0', STR_PAD_LEFT);
$neue_nummer = $next_nummer;
@@ -28045,12 +28055,12 @@ function Firmendaten($field,$projekt="")
if($eigenernummernkreis=="1")
{
$neue_nummer = $this->app->DB->Select("SELECT next_artikelnummer FROM projekt WHERE id='$projekt' LIMIT 1");
- if($this->app->DB->Select("SELECT id FROM artikel WHERE nummer = '".$this->app->DB->real_escape_string($neue_nummer)."' LIMIT 1"))$neue_nummer = $this->CalcNextNummer($neue_nummer);
- $next_nummer = $this->CalcNextNummer($neue_nummer);
+ if($this->app->DB->Select("SELECT id FROM artikel WHERE nummer = '".$this->app->DB->real_escape_string($neue_nummer)."' LIMIT 1"))$neue_nummer = $this->CalcNextArtikelNummer($neue_nummer);
+ $next_nummer = $this->CalcNextArtikelNummer($neue_nummer);
$this->app->DB->Update("UPDATE projekt SET next_artikelnummer='".$next_nummer."' WHERE id='$projekt' LIMIT 1");
} else {
//zentraler nummernkreis mit prefix
- $next_nummer = $this->CalcNextNummer($this->Firmendaten("next_artikelnummer"));
+ $next_nummer = $this->CalcNextArtikelNummer($this->Firmendaten("next_artikelnummer"));
$this->FirmendatenSet("next_artikelnummer",$next_nummer);
if($next_nummer_alt!="") $neue_nummer=$next_nummer_alt.$next_nummer;
else $neue_nummer = $next_nummer;
@@ -28065,15 +28075,15 @@ function Firmendaten($field,$projekt="")
if($eigenernummernkreis)
{
$neue_nummer = $this->app->DB->Select("SELECT next_artikelnummer FROM projekt WHERE id='$projekt' LIMIT 1");
- if($this->app->DB->Select("SELECT id FROM artikel WHERE nummer = '".$this->app->DB->real_escape_string($neue_nummer)."' LIMIT 1"))$neue_nummer = $this->CalcNextNummer($neue_nummer);
- $next_nummer = $this->CalcNextNummer($neue_nummer);
+ if($this->app->DB->Select("SELECT id FROM artikel WHERE nummer = '".$this->app->DB->real_escape_string($neue_nummer)."' LIMIT 1"))$neue_nummer = $this->CalcNextArtikelNummer($neue_nummer);
+ $next_nummer = $this->CalcNextArtikelNummer($neue_nummer);
$this->app->DB->Update("UPDATE projekt SET next_artikelnummer='".$next_nummer."' WHERE id='$projekt' LIMIT 1");
}else{
$firmennummer = $this->app->erp->Firmendaten('next_artikelnummer');
if($firmennummer)
{
$next_nummer = $firmennummer;
- $neue_nummer = $this->CalcNextNummer($next_nummer);
+ $neue_nummer = $this->CalcNextArtikelNummer($next_nummer);
$this->FirmendatenSet('next_artikelnummer', $neue_nummer);
$neue_nummer = $this->app->erp->Firmendaten('next_artikelnummer');
} else {
@@ -28095,10 +28105,11 @@ function Firmendaten($field,$projekt="")
$neue_nummer = $this->app->DB->Select("SELECT MAX(CAST(nummer AS UNSIGNED)) FROM artikel WHERE nummer LIKE '1%'");
if(($neue_nummer=="" || $neue_nummer=="0")) $neue_nummer = "100000";
}
- $neue_nummer = $this->CalcNextNummer($neue_nummer);//$neue_nummer + 1;
+ $neue_nummer = $this->CalcNextArtikelNummer($neue_nummer);//$neue_nummer + 1;
}
}
}
+
$this->app->erp->ProzessUnlock($process_lock);
$neue_nummer = str_replace('{JAHR}',date('Y'),$neue_nummer);
$neue_nummer = str_replace('{MONAT}',date('m'),$neue_nummer);
From e81e404763c7b2c2812a0a9317e15d76724ad35e Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 4 Sep 2024 14:12:04 +0200
Subject: [PATCH 83/87] bugfix exportbuchhaltung abgeschlossen
---
www/pages/exportbuchhaltung.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/www/pages/exportbuchhaltung.php b/www/pages/exportbuchhaltung.php
index fa400f7d..a112d72a 100644
--- a/www/pages/exportbuchhaltung.php
+++ b/www/pages/exportbuchhaltung.php
@@ -102,7 +102,7 @@ class Exportbuchhaltung
'field_betrag_gesamt' => 'b.betrag',
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
- 'condition_where' => ' AND b.status IN (\'freigegeben\')',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\', \'abgeschlossen\')',
'Buchungstyp' => '',
'do' => $verbindlichkeit,
'pdf' => 'load'
@@ -122,7 +122,7 @@ class Exportbuchhaltung
'field_betrag_gesamt' => 'b.betrag',
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
- 'condition_where' => ' AND b.status IN (\'freigegeben\')',
+ 'condition_where' => ' AND b.status IN (\'freigegeben\', \'abgeschlossen\')',
'Buchungstyp' => '',
'do' => $lieferantengutschrift,
'pdf' => 'load'
From b7cf1dd04af288df6046ac80f25faaf058e102d8 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 4 Sep 2024 15:49:37 +0200
Subject: [PATCH 84/87] exportbuchhaltung filter for pdfs
---
www/pages/exportbuchhaltung.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/www/pages/exportbuchhaltung.php b/www/pages/exportbuchhaltung.php
index a112d72a..afa25dfa 100644
--- a/www/pages/exportbuchhaltung.php
+++ b/www/pages/exportbuchhaltung.php
@@ -268,6 +268,11 @@ class Exportbuchhaltung
b.".$typ['field_date']." BETWEEN '".date_format($von,"Y-m-d")."' AND '".date_format($bis,"Y-m-d")."' AND (b.projekt=$projekt OR $projekt=0)".$typ['condition_where'];
$belege = $this->app->DB->SelectArr($sql);
foreach ($belege as $beleg) {
+
+ if (!$typ['do']) {
+ continue;
+ }
+
switch ($typ['pdf']) {
case 'print':
switch ($typ['typ']) {
From e40e543a7d01f66b9d42535300da08734e51eb84 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 6 Sep 2024 20:12:37 +0200
Subject: [PATCH 85/87] bugfix remotesendlistlager result
---
www/lib/class.erpapi.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/www/lib/class.erpapi.php b/www/lib/class.erpapi.php
index fc1d4c21..ade72442 100644
--- a/www/lib/class.erpapi.php
+++ b/www/lib/class.erpapi.php
@@ -21064,9 +21064,9 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
}
- $this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.(is_array($result)?$result['status']:$result), $result);
+ $this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.(is_array($result)?$result['status']:$result), $result);
- if ((is_array($result)?$result['status'] == 1:false) || $status === 1) {
+ if ((is_array($result)?$result['status'] == 1:false) || $result === 1) {
$cacheQuantity = (int) $verkaufbare_menge_korrektur + (int) $pseudolager;
$this->app->DB->Update(
"UPDATE `artikel` SET `cache_lagerplatzinhaltmenge` = '{$cacheQuantity}'
From f725281d7e90ef666f0609d4103739b7357df3a8 Mon Sep 17 00:00:00 2001
From: Andreas Palm
Date: Tue, 10 Sep 2024 23:09:39 +0200
Subject: [PATCH 86/87] Re-add previous fix
---
www/lib/class.remote.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/www/lib/class.remote.php b/www/lib/class.remote.php
index 96f890aa..d1883f32 100644
--- a/www/lib/class.remote.php
+++ b/www/lib/class.remote.php
@@ -2197,7 +2197,7 @@ class Remote {
vlp.versandpaket = v.id OR v.lieferschein_ohne_pos = l.id
LEFT JOIN shopexport_versandarten sv ON
sv.versandart_wawision = v.versandart AND sv.shop = $shopId
- WHERE a.id = $orderId OR a.teillieferungvon = $orderId
+ WHERE (a.id = $orderId OR a.teillieferungvon = $orderId) AND v.id IS NOT NULL
ORDER BY v.id";
$shipments = $this->app->DB->SelectArr($sql);
From 616e3e8ee758285d87800344a8ee7bab4b7bb3e9 Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Wed, 11 Sep 2024 09:54:43 +0200
Subject: [PATCH 87/87] Bugfix add lieferadresse
---
www/pages/bundesstaaten.php | 812 ++++++++++++++++++------------------
1 file changed, 407 insertions(+), 405 deletions(-)
diff --git a/www/pages/bundesstaaten.php b/www/pages/bundesstaaten.php
index c4d75973..1437a176 100644
--- a/www/pages/bundesstaaten.php
+++ b/www/pages/bundesstaaten.php
@@ -1,408 +1,410 @@
-";
- $menu .= "";
- $menu .= "";
- $menu .= '';
- $menu .= " Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">";
- $menu .= " ";
- $menu .= '';
- $menu .= " Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">";
- $menu .= " ";
- $menu .= " ";
- $menu .= " ";
- $menu .= "";
-
- $finaktiv = $app->YUI->TableSearchFilter($name, 5, 'inaktiv', '0', 0, 'checkbox');
- $subwhere = '';
- if($finaktiv == 0){
- $subwhere .= ' AND b.aktiv = 1';
- }
-
- $where = " b.id > 0".$subwhere;
-
- $sql = "SELECT SQL_CALC_FOUND_ROWS b.id, l.bezeichnung_de, b.iso, b.bundesstaat, if(b.aktiv, 'ja', '-') as aktiv, b.id FROM bundesstaaten b LEFT JOIN laender l ON b.land = l.iso";
-
- $count = "SELECT count(b.id) FROM bundesstaaten b WHERE $where";
- break;
-
- }
-
- $erg = [];
-
- foreach($erlaubtevars as $k => $v)
- {
- if(isset($$v))$erg[$v] = $$v;
- }
- return $erg;
- }
-
-
- 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("list", "BundesstaatenList");
- $this->app->ActionHandler("edit", "BundesstaatenEdit");
- $this->app->ActionHandler("save", "BundesstaatenSave");
- $this->app->ActionHandler("delete", "BundesstaatenDelete");
-
- $this->app->ActionHandlerListen($app);
-
- $this->Install();
-
- }
-
- function Install(){
- $this->app->erp->CheckTable("bundesstaaten");
- $this->app->erp->CheckColumn("id", "int(11)", "bundesstaaten", "NOT NULL AUTO_INCREMENT");
- $this->app->erp->CheckColumn("land", "varchar(255)", "bundesstaaten", "NOT NULL");
- $this->app->erp->CheckColumn("iso", "varchar(255)", "bundesstaaten", "NOT NULL");
- $this->app->erp->CheckColumn("bundesstaat", "varchar(255)", "bundesstaaten", "NOT NULL");
- $this->app->erp->CheckColumn("aktiv", "int(11)", "bundesstaaten", "NOT NULL DEFAULT 0");
- }
-
- /**
- * @param $target
- * @param $landid
- * @param $bundeslandid
- * @param string $valueland
- * @param string $valuebundesland
- * @param bool $disabled
- */
- function BundeslaenderSelect($target, $landid, $bundeslandid, $valueland = '', $valuebundesland = '', $disabled = false)
- {
- if($valueland == '')$valueland = $this->app->erp->Firmendaten('land');
- $arr = $this->app->DB->SelectArr("SELECT * FROM bundesstaaten WHERE land <> '' AND iso <> '' AND ( aktiv = 1 OR (land = '$valueland' AND iso = '$valuebundesland')) ORDER BY land, bundesstaat");
- $this->app->Tpl->Add($target,' ');
- if($arr)
- {
- foreach($arr as $i => $v)
- {
- if($v['land'] == $valueland)
- {
- $this->app->Tpl->Add($target,''.htmlspecialchars($v['bundesstaat']).' ');
- }
- }
- }
- $this->app->Tpl->Add($target,' ');
- $this->app->Tpl->Add($target,'');
- }
-
- function BundesstaatenMenu()
- {
-
- $this->app->erp->MenuEintrag("index.php?module=bundesstaaten&action=list","Zurück zur Übersicht");
- $this->app->erp->MenuEintrag("index.php?module=bundesstaaten&action=list","Details");
- $this->app->erp->MenuEintrag("BundesstaatenEdit(0)","Neuer Eintrag");
- }
-
- /**
- * @param string $needle
- * @param $haystack
- * @param bool $strict
- * @return bool
- */
- function in_array_r($needle, $haystack, $strict = false){
- foreach($haystack as $item){
- if(($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))){
- return true;
- }
- }
-
- return false;
- }
-
- function BundesstaatenList()
- {
- $this->BundesstaatenMenu();
- $this->app->Tpl->Set("KURZUEBERSCHRIFT","Bundesstaaten");
-
- $bundesstaatende = $this->app->erp->GetSelectStaatenliste('DE');
- $bundesstaatendedb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'DE'");
- $fehlende = array();
- foreach($bundesstaatende as $key=>$value){
- if($this->in_array_r($value,$bundesstaatendedb)){
- }else{
- $fehlende[$key] = $value;
- }
- }
-
- $bundesstaatenat = $this->app->erp->GetSelectStaatenliste('AT');
- $bundesstaatenatdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'AT'");
- $fehlenat = array();
- foreach($bundesstaatenat as $key=>$value){
- if($this->in_array_r($value,$bundesstaatenatdb)){
- }else{
- $fehlenat[$key] = $value;
- }
- }
-
- $bundesstaatench = $this->app->erp->GetSelectStaatenliste('CH');
- $bundesstaatenchdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'CH'");
- $fehlench = array();
- foreach($bundesstaatench as $key=>$value){
- if($this->in_array_r($value,$bundesstaatenchdb)){
- }else{
- $fehlench[$key] = $value;
- }
- }
-
- $bundesstaatenus = $this->app->erp->GetSelectStaatenliste('US');
- $bundesstaatenusdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'US'");
- $fehlenus = array();
- foreach($bundesstaatenus as $key=>$value){
- if($this->in_array_r($value,$bundesstaatenusdb)){
- }else{
- $fehlenus[$key] = $value;
- }
- }
-
- $bundesstaatenca = $this->app->erp->GetSelectStaatenliste('CA');
- $bundesstaatencadb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'CA'");
- $fehlenca = array();
- foreach($bundesstaatenca as $key=>$value){
- if($this->in_array_r($value,$bundesstaatencadb)){
- }else{
- $fehlenca[$key] = $value;
- }
- }
-
- $anzahlfehlen = (!empty($fehlende)?count($fehlende):0) + (!empty($fehlenat)?count($fehlenat):0) + (!empty($fehlench)?count($fehlench):0) + (!empty($fehlenus)?count($fehlenus):0) + (!empty($fehlenca)?count($fehlenca):0);
-
-
- if($anzahlfehlen > 0){
- if($anzahlfehlen == 1){
- $info = "Es steht ".$anzahlfehlen." neuer Bundesstaaten Eintrag in Xentral zur Verfügung.";
- }else{
- $info = "Es stehen ".$anzahlfehlen." neue Bundesstaaten Einträge in Xentral zur Verfügung.";
- }
- $nachladebutton = " ";
- $info .= $nachladebutton;
- $this->app->Tpl->Set('MESSAGE',"$info
");
- }
-
- $nachladen = $this->app->Secure->GetPOST("nachladen");
- if($nachladen != ""){
- if((!empty($fehlende)?count($fehlende):0) > 0){
- foreach($fehlende as $key=>$value){
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('DE', '$key', '$value', 1)");
- }
- }
-
- if((!empty($fehlenat)?count($fehlenat):0) > 0){
- foreach($fehlenat as $key=>$value){
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('AT', '$key', '$value', 1)");
- }
- }
-
- if((!empty($fehlench)?count($fehlench):0) > 0){
- foreach($fehlench as $key=>$value){
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('CH', '$key', '$value', 1)");
- }
- }
-
- if((!empty($fehlenus)?count($fehlenus):0) > 0){
- foreach($fehlenus as $key=>$value){
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('US', '$key', '$value', 1)");
- }
- }
-
- if((!empty($fehlenca)?count($fehlenca):0) > 0){
- foreach($fehlenca as $key=>$value){
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('CA', '$key', '$value', 1)");
- }
- }
-
- header("Location:index.php?module=bundesstaaten&action=list");
- exit;
- }
-
- $laenderanzahl = $this->app->DB->Select("SELECT COUNT(id) FROM laender");
- //if($laenderanzahl <= 0){
- $select = '';
- $laender = $this->app->erp->GetSelectLaenderliste();
- foreach($laender as $key=>$value){
- if(trim($key) != "" && trim($key) != "0"){
- $select .= "".htmlspecialchars($value)." ";
- }
-
- }
- //}else{
- //$laender = $this->app->DB->SelectArr("SELECT iso, bezeichnung_de FROM laender");
- //foreach($laender as $key=>$value){
- //$select .= "".$value['bezeichnung_de']." ";
- //}
-
- $this->app->Tpl->Add("LAENDER", $select);
- //}
-
- $this->app->YUI->TableSearch('TAB1','bundesstaaten_list', "show","","",basename(__FILE__), __CLASS__);
- $this->app->Tpl->Parse("PAGE","bundesstaaten_list.tpl");
- }
-
- function BundesstaatenEdit()
- {
- if($this->app->Secure->GetGET('cmd')=='get'){
- $id = (int)$this->app->Secure->GetPOST('id');
-
- $data = $this->app->DB->SelectArr("SELECT b.id, b.land, b.iso, b.bundesstaat, b.aktiv FROM bundesstaaten b WHERE b.id = '$id' LIMIT 1");
-
- if($data){
- $data = reset($data);
-
- }else{
- $data['id'] = 0;
- $data['land'] = '';
- $data['iso'] = '';
- $data['bundesstaat'] = '';
- $data['aktiv'] = 1;
-
- }
- echo json_encode($data);
- exit;
- }
-
- $this->app->Tpl->Parse('PAGE', "bundesstaaten_list.tpl");
- }
-
- function BundesstaatenSave()
- {
- $id = (int)$this->app->Secure->GetPOST('id');
- $land = trim($this->app->Secure->GetPOST('land'));
- $iso = trim($this->app->Secure->GetPOST('iso'));
- $bundesstaat = trim($this->app->Secure->GetPOST('bundesstaat'));
- $aktiv = $this->app->Secure->GetPOST('aktiv');
-
- $error = "";
-
- if($land == ""){
- $error .= "Bitte Land ausfüllen\n";
- }
-
- if($iso == ""){
- $error .= "Bitte ISO-Code ausfüllen"."\n";
- }
-
- if(strlen($iso) > 2){
- $error .= "Bitte 2-stelligen ISO-Code für den Bundesstaat ausfüllen"."\n";
- }
-
- if($bundesstaat == ""){
- $error .= "Bitte Bundesstaat ausfüllen"."\n";
- }
-
- if($land != "" && $bundesstaat != ""){
- $isovorhanden = $this->app->DB->Select("SELECT id FROM bundesstaaten WHERE land = '$land' AND iso = '$iso' AND id != '$id' LIMIT 1");
- if($isovorhanden != ""){
- $error .= "Es gibt diesen ISO-Code bereits für dieses Land"."\n";
- }else{
- $schonvorhanden = $this->app->DB->Select("SELECT id FROM bundesstaaten WHERE land = '$land' AND iso = '$iso' AND bundesstaat = '$bundesstaat' AND id != '$id' LIMIT 1");
- if($schonvorhanden != ""){
- $error .= "Diesen Eintrag gibt es bereits"."\n";
- }
- }
-
- }
-
- if($error == ""){
- if($id){
- $this->app->DB->Update("UPDATE bundesstaaten SET land = '$land', iso = '$iso', bundesstaat = '$bundesstaat', aktiv = '$aktiv' WHERE id = '$id'");
-
- echo json_encode(array('status'=>1));
- exit;
- }else{
- $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('$land', '$iso', '$bundesstaat', '$aktiv')");
-
- echo json_encode(array('status'=>1));
- exit;
-
- }
- }else{
- echo json_encode(array('status'=>0,'statusText'=>$error));
- exit;
-
- }
-
- }
-
- function BundesstaatenDelete()
- {
- $id = (int) $this->app->Secure->GetPOST('id');
- if($id)
- $this->app->DB->Update("DELETE FROM bundesstaaten WHERE id = '$id'");
-
- echo json_encode(array('status'=>1));
- exit;
-
- }
-
-}
+";
+ $menu .= "";
+ $menu .= "";
+ $menu .= '';
+ $menu .= " Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\">";
+ $menu .= " ";
+ $menu .= '';
+ $menu .= " Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\">";
+ $menu .= " ";
+ $menu .= " ";
+ $menu .= " ";
+ $menu .= "";
+
+ $finaktiv = $app->YUI->TableSearchFilter($name, 5, 'inaktiv', '0', 0, 'checkbox');
+ $subwhere = '';
+ if($finaktiv == 0){
+ $subwhere .= ' AND b.aktiv = 1';
+ }
+
+ $where = " b.id > 0".$subwhere;
+
+ $sql = "SELECT SQL_CALC_FOUND_ROWS b.id, l.bezeichnung_de, b.iso, b.bundesstaat, if(b.aktiv, 'ja', '-') as aktiv, b.id FROM bundesstaaten b LEFT JOIN laender l ON b.land = l.iso";
+
+ $count = "SELECT count(b.id) FROM bundesstaaten b WHERE $where";
+ break;
+
+ }
+
+ $erg = [];
+
+ foreach($erlaubtevars as $k => $v)
+ {
+ if(isset($$v))$erg[$v] = $$v;
+ }
+ return $erg;
+ }
+
+
+ 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("list", "BundesstaatenList");
+ $this->app->ActionHandler("edit", "BundesstaatenEdit");
+ $this->app->ActionHandler("save", "BundesstaatenSave");
+ $this->app->ActionHandler("delete", "BundesstaatenDelete");
+
+ $this->app->ActionHandlerListen($app);
+
+ $this->Install();
+
+ }
+
+ function Install(){
+ $this->app->erp->CheckTable("bundesstaaten");
+ $this->app->erp->CheckColumn("id", "int(11)", "bundesstaaten", "NOT NULL AUTO_INCREMENT");
+ $this->app->erp->CheckColumn("land", "varchar(255)", "bundesstaaten", "NOT NULL");
+ $this->app->erp->CheckColumn("iso", "varchar(255)", "bundesstaaten", "NOT NULL");
+ $this->app->erp->CheckColumn("bundesstaat", "varchar(255)", "bundesstaaten", "NOT NULL");
+ $this->app->erp->CheckColumn("aktiv", "int(11)", "bundesstaaten", "NOT NULL DEFAULT 0");
+ }
+
+ /**
+ * @param $target
+ * @param $landid
+ * @param $bundeslandid
+ * @param string $valueland
+ * @param string $valuebundesland
+ * @param bool $disabled
+ */
+ function BundeslaenderSelect($target, $landid, $bundeslandid, $valueland = '', $valuebundesland = '', $disabled = false)
+ {
+ if($valueland == '')$valueland = $this->app->erp->Firmendaten('land');
+ $arr = $this->app->DB->SelectArr("SELECT * FROM bundesstaaten WHERE land <> '' AND iso <> '' AND ( aktiv = 1 OR (land = '$valueland' AND iso = '$valuebundesland')) ORDER BY land, bundesstaat");
+ $this->app->Tpl->Add($target,' ');
+ if($arr)
+ {
+ foreach($arr as $i => $v)
+ {
+ if($v['land'] == $valueland)
+ {
+ $this->app->Tpl->Add($target,''.htmlspecialchars($v['bundesstaat']).' ');
+ }
+ }
+ }
+ $this->app->Tpl->Add($target,' ');
+ $this->app->Tpl->Add($target,'');
+ }
+
+ function BundesstaatenMenu()
+ {
+
+ $this->app->erp->MenuEintrag("index.php?module=bundesstaaten&action=list","Zurück zur Übersicht");
+ $this->app->erp->MenuEintrag("index.php?module=bundesstaaten&action=list","Details");
+ $this->app->erp->MenuEintrag("BundesstaatenEdit(0)","Neuer Eintrag");
+ }
+
+ /**
+ * @param string $needle
+ * @param $haystack
+ * @param bool $strict
+ * @return bool
+ */
+ function in_array_r($needle, $haystack, $strict = false){
+ foreach($haystack as $item){
+ if(($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))){
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function BundesstaatenList()
+ {
+ $this->BundesstaatenMenu();
+ $this->app->Tpl->Set("KURZUEBERSCHRIFT","Bundesstaaten");
+
+ $bundesstaatende = $this->app->erp->GetSelectStaatenliste('DE');
+ $bundesstaatendedb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'DE'");
+ $fehlende = array();
+ foreach($bundesstaatende as $key=>$value){
+ if($this->in_array_r($value,$bundesstaatendedb)){
+ }else{
+ $fehlende[$key] = $value;
+ }
+ }
+
+ $bundesstaatenat = $this->app->erp->GetSelectStaatenliste('AT');
+ $bundesstaatenatdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'AT'");
+ $fehlenat = array();
+ foreach($bundesstaatenat as $key=>$value){
+ if($this->in_array_r($value,$bundesstaatenatdb)){
+ }else{
+ $fehlenat[$key] = $value;
+ }
+ }
+
+ $bundesstaatench = $this->app->erp->GetSelectStaatenliste('CH');
+ $bundesstaatenchdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'CH'");
+ $fehlench = array();
+ foreach($bundesstaatench as $key=>$value){
+ if($this->in_array_r($value,$bundesstaatenchdb)){
+ }else{
+ $fehlench[$key] = $value;
+ }
+ }
+
+ $bundesstaatenus = $this->app->erp->GetSelectStaatenliste('US');
+ $bundesstaatenusdb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'US'");
+ $fehlenus = array();
+ foreach($bundesstaatenus as $key=>$value){
+ if($this->in_array_r($value,$bundesstaatenusdb)){
+ }else{
+ $fehlenus[$key] = $value;
+ }
+ }
+
+ $bundesstaatenca = $this->app->erp->GetSelectStaatenliste('CA');
+ $bundesstaatencadb = $this->app->DB->SelectArr("SELECT bundesstaat, iso FROM bundesstaaten WHERE land = 'CA'");
+ $fehlenca = array();
+ foreach($bundesstaatenca as $key=>$value){
+ if($this->in_array_r($value,$bundesstaatencadb)){
+ }else{
+ $fehlenca[$key] = $value;
+ }
+ }
+
+ $anzahlfehlen = (!empty($fehlende)?count($fehlende):0) + (!empty($fehlenat)?count($fehlenat):0) + (!empty($fehlench)?count($fehlench):0) + (!empty($fehlenus)?count($fehlenus):0) + (!empty($fehlenca)?count($fehlenca):0);
+
+
+ if($anzahlfehlen > 0){
+ if($anzahlfehlen == 1){
+ $info = "Es steht ".$anzahlfehlen." neuer Bundesstaaten Eintrag in Xentral zur Verfügung.";
+ }else{
+ $info = "Es stehen ".$anzahlfehlen." neue Bundesstaaten Einträge in Xentral zur Verfügung.";
+ }
+ $nachladebutton = " ";
+ $info .= $nachladebutton;
+ $this->app->Tpl->Set('MESSAGE',"$info
");
+ }
+
+ $nachladen = $this->app->Secure->GetPOST("nachladen");
+ if($nachladen != ""){
+ if((!empty($fehlende)?count($fehlende):0) > 0){
+ foreach($fehlende as $key=>$value){
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('DE', '$key', '$value', 1)");
+ }
+ }
+
+ if((!empty($fehlenat)?count($fehlenat):0) > 0){
+ foreach($fehlenat as $key=>$value){
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('AT', '$key', '$value', 1)");
+ }
+ }
+
+ if((!empty($fehlench)?count($fehlench):0) > 0){
+ foreach($fehlench as $key=>$value){
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('CH', '$key', '$value', 1)");
+ }
+ }
+
+ if((!empty($fehlenus)?count($fehlenus):0) > 0){
+ foreach($fehlenus as $key=>$value){
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('US', '$key', '$value', 1)");
+ }
+ }
+
+ if((!empty($fehlenca)?count($fehlenca):0) > 0){
+ foreach($fehlenca as $key=>$value){
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('CA', '$key', '$value', 1)");
+ }
+ }
+
+ header("Location:index.php?module=bundesstaaten&action=list");
+ exit;
+ }
+
+ $laenderanzahl = $this->app->DB->Select("SELECT COUNT(id) FROM laender");
+ //if($laenderanzahl <= 0){
+ $select = '';
+ $laender = $this->app->erp->GetSelectLaenderliste();
+ foreach($laender as $key=>$value){
+ if(trim($key) != "" && trim($key) != "0"){
+ $select .= "".htmlspecialchars($value)." ";
+ }
+
+ }
+ //}else{
+ //$laender = $this->app->DB->SelectArr("SELECT iso, bezeichnung_de FROM laender");
+ //foreach($laender as $key=>$value){
+ //$select .= "".$value['bezeichnung_de']." ";
+ //}
+
+ $this->app->Tpl->Add("LAENDER", $select);
+ //}
+
+ $this->app->YUI->TableSearch('TAB1','bundesstaaten_list', "show","","",basename(__FILE__), __CLASS__);
+ $this->app->Tpl->Parse("PAGE","bundesstaaten_list.tpl");
+ }
+
+ function BundesstaatenEdit()
+ {
+ if($this->app->Secure->GetGET('cmd')=='get'){
+ $id = (int)$this->app->Secure->GetPOST('id');
+
+ $data = $this->app->DB->SelectArr("SELECT b.id, b.land, b.iso, b.bundesstaat, b.aktiv FROM bundesstaaten b WHERE b.id = '$id' LIMIT 1");
+
+ if($data){
+ $data = reset($data);
+
+ }else{
+ $data['id'] = 0;
+ $data['land'] = '';
+ $data['iso'] = '';
+ $data['bundesstaat'] = '';
+ $data['aktiv'] = 1;
+
+ }
+ echo json_encode($data);
+ exit;
+ }
+
+ $this->app->Tpl->Parse('PAGE', "bundesstaaten_list.tpl");
+ }
+
+ function BundesstaatenSave()
+ {
+ $id = (int)$this->app->Secure->GetPOST('id');
+ $land = trim($this->app->Secure->GetPOST('land'));
+ $iso = trim($this->app->Secure->GetPOST('iso'));
+ $bundesstaat = trim($this->app->Secure->GetPOST('bundesstaat'));
+ $aktiv = $this->app->Secure->GetPOST('aktiv');
+
+ $error = "";
+
+ if($land == ""){
+ $error .= "Bitte Land ausfüllen\n";
+ }
+
+ if($iso == ""){
+ $error .= "Bitte ISO-Code ausfüllen"."\n";
+ }
+
+ if(strlen($iso) > 2){
+ $error .= "Bitte 2-stelligen ISO-Code für den Bundesstaat ausfüllen"."\n";
+ }
+
+ if($bundesstaat == ""){
+ $error .= "Bitte Bundesstaat ausfüllen"."\n";
+ }
+
+ if($land != "" && $bundesstaat != ""){
+ $isovorhanden = $this->app->DB->Select("SELECT id FROM bundesstaaten WHERE land = '$land' AND iso = '$iso' AND id != '$id' LIMIT 1");
+ if($isovorhanden != ""){
+ $error .= "Es gibt diesen ISO-Code bereits für dieses Land"."\n";
+ }else{
+ $schonvorhanden = $this->app->DB->Select("SELECT id FROM bundesstaaten WHERE land = '$land' AND iso = '$iso' AND bundesstaat = '$bundesstaat' AND id != '$id' LIMIT 1");
+ if($schonvorhanden != ""){
+ $error .= "Diesen Eintrag gibt es bereits"."\n";
+ }
+ }
+
+ }
+
+ if($error == ""){
+ if($id){
+ $this->app->DB->Update("UPDATE bundesstaaten SET land = '$land', iso = '$iso', bundesstaat = '$bundesstaat', aktiv = '$aktiv' WHERE id = '$id'");
+
+ echo json_encode(array('status'=>1));
+ exit;
+ }else{
+ $this->app->DB->Insert("INSERT INTO bundesstaaten (land, iso, bundesstaat, aktiv) VALUES ('$land', '$iso', '$bundesstaat', '$aktiv')");
+
+ echo json_encode(array('status'=>1));
+ exit;
+
+ }
+ }else{
+ echo json_encode(array('status'=>0,'statusText'=>$error));
+ exit;
+
+ }
+
+ }
+
+ function BundesstaatenDelete()
+ {
+ $id = (int) $this->app->Secure->GetPOST('id');
+ if($id)
+ $this->app->DB->Update("DELETE FROM bundesstaaten WHERE id = '$id'");
+
+ echo json_encode(array('status'=>1));
+ exit;
+
+ }
+
+}