From 81646f5ea455766ef8814a1d58e3242748039caf Mon Sep 17 00:00:00 2001 From: data Date: Tue, 17 Mar 2026 12:58:23 +0100 Subject: [PATCH] feat(launch): Konfigurationsvalidierung & GlobalNotify-Integration v3.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Neue Funktion idsconnect_notify() für GlobalNotify-Benachrichtigungen mit Fallback auf dol_syslog falls Modul nicht installiert - Neue Funktion idsconnect_validateSupplierConfig() prüft Supplier- Konfiguration vor dem Launch auf Vollständigkeit - launch.php: Validierung vor Formular-Submit - Fehler (leeres Passwort): blockiert Launch, Redirect zur Konfiguration - Warnung (leerer Username): erlaubt Launch aber warnt User + Admin - Löst Problem: Klux "Weiter"-Button fehlte weil ids_username leer war, Login schlug still fehl ohne jede Fehlermeldung Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 36 ++++++++++++++ core/modules/modIdsconnect.class.php | 2 +- launch.php | 17 +++++++ lib/idsconnect.lib.php | 73 ++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f2588..cd867b7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,42 @@ --- +## v3.4 - Klux-Support & Konfigurationsvalidierung (17.03.2026) + +### 🐛 BUGFIX: Klux "Weiter"-Button fehlte + +- **Problem**: Beim WKS (Warenkorb senden) an Klux fehlte im Klux-Shop der "Weiter"-Button zur Bestellbestätigung. +- **Ursache**: `ids_username` (→ `name_kunde`) war leer in der Klux-Supplier-Konfiguration. Ohne gültigen Login-Namen zeigt der Klux-Shop den Katalog, aber keinen IDS-Checkout-Button. +- **Fix**: `ids_username = ids-1222925` (Kundennummer) in der Produktiv-DB gesetzt. +- **Hintergrund**: Bei deutschen Elektrogroßhändlern (Klux, Sonepar) wird die Kundennummer oft auch als Login-Username verwendet. Das `name_kunde`-Feld darf nicht leer sein. + +### ✨ Feature: Konfigurationsvalidierung vor IDS-Launch + +Neue Validierung in [launch.php](launch.php) bevor das Formular an den Großhändler-Shop gesendet wird: + +- **Fehler (blockiert Launch)**: Kein Passwort konfiguriert → Redirect zur Supplier-Konfiguration +- **Warnung (erlaubt aber warnt)**: Kein Benutzername konfiguriert → `name_kunde` wäre leer → "Weiter"-Button fehlt im Shop +- Verhindert das stille Fehlschlagen ("Shop lädt, aber kein Bestell-Button, niemand weiß warum") + +### ✨ Feature: GlobalNotify-Integration + +- **Neue Funktion** `idsconnect_notify()` in [lib/idsconnect.lib.php](lib/idsconnect.lib.php) + - Sendet Benachrichtigungen an Admins über GlobalNotify (falls Modul aktiv) + - Fallback auf `dol_syslog()` wenn GlobalNotify nicht installiert + - Typen: `error`, `warning`, `info`, `action` +- **Neue Funktion** `idsconnect_validateSupplierConfig()` in [lib/idsconnect.lib.php](lib/idsconnect.lib.php) + - Prüft Supplier-Konfiguration vor dem Launch auf Vollständigkeit + - Gibt strukturierte `errors` und `warnings` zurück +- Bei unvollständiger Konfiguration: Admin erhält GlobalNotify-Meldung mit direktem Link zur Supplier-Konfigurationsseite + +### 🔧 Technische Details + +- **Validierte Felder**: `ids_password` (Error), `ids_username` (Warning) +- **GlobalNotify-Typ**: `action` für Fehler (Link zur Konfiguration), `warning` für Warnungen +- **Keine Code-Änderungen** an der Formular-Generierung (`idsconnect.class.php`) - nur Vorbedingung in `launch.php` + +--- + ## v2.9 - Preis-Vergleich & Kritische Bugfixes (12.03.2026) ### 🐛 KRITISCHER BUGFIX: SQL-Spaltenname korrigiert diff --git a/core/modules/modIdsconnect.class.php b/core/modules/modIdsconnect.class.php index 8fbe5c1..3d5b811 100755 --- a/core/modules/modIdsconnect.class.php +++ b/core/modules/modIdsconnect.class.php @@ -59,7 +59,7 @@ class modIdsconnect extends DolibarrModules $this->editor_name = 'Alles Watt laeuft'; $this->editor_url = ''; - $this->version = '3.2'; + $this->version = '3.4'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); diff --git a/launch.php b/launch.php index 522882d..6391f9d 100755 --- a/launch.php +++ b/launch.php @@ -95,6 +95,23 @@ if (!$supplier->active) { exit; } +// Supplier-Konfiguration auf Vollständigkeit prüfen +$config_issues = idsconnect_validateSupplierConfig($supplier); +$supplier_config_url = dol_buildpath('/idsconnect/supplier_card.php?id='.$supplier_id, 1); + +foreach ($config_issues['errors'] as $err) { + setEventMessages($err, null, 'errors'); + idsconnect_notify('action', 'IDS Connect: Konfigurationsfehler', $err, $supplier_config_url, 'Konfiguration öffnen'); +} +foreach ($config_issues['warnings'] as $warn) { + setEventMessages($warn, null, 'warnings'); + idsconnect_notify('warning', 'IDS Connect: Konfiguration unvollständig', $warn, $supplier_config_url, 'Konfiguration öffnen'); +} +if (!empty($config_issues['errors'])) { + header('Location: '.$supplier_config_url); + exit; +} + // IDS Connect initialisieren $idsconnect = new IdsConnect($db); $testmode = $idsconnect->isTestMode($supplier); diff --git a/lib/idsconnect.lib.php b/lib/idsconnect.lib.php index fe67e82..3685c27 100755 --- a/lib/idsconnect.lib.php +++ b/lib/idsconnect.lib.php @@ -71,6 +71,79 @@ function idsconnectSupplierPrepareHead($object) return $head; } +/** + * Sendet Benachrichtigung über GlobalNotify (falls verfügbar). + * Fallback: Schreibt ins Dolibarr-Log. + * + * @param string $type 'error', 'warning', 'info', 'action' + * @param string $title Kurzer Titel + * @param string $message Detaillierte Nachricht + * @param string $actionUrl URL für Aktions-Button (optional) + * @param string $actionLabel Label für Aktions-Button (optional) + * @return bool True wenn über GlobalNotify gesendet + */ +function idsconnect_notify($type, $title, $message, $actionUrl = '', $actionLabel = '') +{ + if (!isModEnabled('globalnotify')) { + dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); + return false; + } + + $classFile = dol_buildpath('/globalnotify/class/globalnotify.class.php', 0); + if (!file_exists($classFile)) { + dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); + return false; + } + + require_once $classFile; + + if (!class_exists('GlobalNotify')) { + dol_syslog("IDSCONNECT [{$type}]: {$title} - {$message}", LOG_WARNING); + return false; + } + + try { + switch ($type) { + case 'error': + GlobalNotify::error('idsconnect', $title, $message, $actionUrl, $actionLabel); + break; + case 'warning': + GlobalNotify::warning('idsconnect', $title, $message, $actionUrl, $actionLabel); + break; + case 'action': + GlobalNotify::actionRequired('idsconnect', $title, $message, $actionUrl, $actionLabel ?: 'Jetzt beheben'); + break; + default: + GlobalNotify::info('idsconnect', $title, $message, $actionUrl, $actionLabel); + } + return true; + } catch (Exception $e) { + dol_syslog("GlobalNotify error in idsconnect: ".$e->getMessage(), LOG_ERR); + return false; + } +} + +/** + * Prüft die Supplier-Konfiguration auf Vollständigkeit vor dem Launch. + * + * @param object $supplier IdsSupplier-Objekt + * @return array ['errors' => string[], 'warnings' => string[]] + */ +function idsconnect_validateSupplierConfig($supplier) +{ + $result = array('errors' => array(), 'warnings' => array()); + + if (empty($supplier->ids_password)) { + $result['errors'][] = 'Kein Passwort konfiguriert für "'.$supplier->label.'" – IDS-Login nicht möglich.'; + } + + if (empty($supplier->ids_username)) { + $result['warnings'][] = 'Kein Benutzername (name_kunde) konfiguriert für "'.$supplier->label.'" – Login könnte fehlschlagen und der "Weiter"-Button fehlt ggf. im Shop.'; + } + + return $result; +} + /** * Testmodus-Banner ausgeben *