feat(launch): Konfigurationsvalidierung & GlobalNotify-Integration v3.4

- 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 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-03-17 12:58:23 +01:00
parent 39f8a22f21
commit 81646f5ea4
4 changed files with 127 additions and 1 deletions

View file

@ -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

View file

@ -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);

View file

@ -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);

View file

@ -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
*