diff --git a/ajax/pwa_api.php b/ajax/pwa_api.php index eb7584a..dc0f056 100644 --- a/ajax/pwa_api.php +++ b/ajax/pwa_api.php @@ -6,7 +6,8 @@ * Auth: Header "X-Eplan-Token: " gegen Const EPLAN_PWA_SECRET (hash_equals). * * Actions (?action=...): - * - ping → {aktiv: true, version: "1.1.0"} + * - ping → {aktiv: true, version: "1.3.0"} + * - firma_info → Firmen-Stammdaten + Logo (für Plankopf) * - auftraege_listen → Liste offener Aufträge (Commande) * - auftrag_details&id= → Einzelner Auftrag mit Positionen * - kunden_suchen&such= → Third-Party-Suche @@ -64,11 +65,41 @@ try { echo json_encode([ 'aktiv' => true, 'modul' => 'eplan', - 'version' => '1.2.0', + 'version' => '1.3.0', 'dolibarr' => DOL_VERSION, ]); break; + case 'firma_info': + // Firmen-Stammdaten (MAIN_INFO_SOCIETE_*) + Logo für den Plankopf + $zip = getDolGlobalString('MAIN_INFO_SOCIETE_ZIP'); + $town = getDolGlobalString('MAIN_INFO_SOCIETE_TOWN'); + $logoUrl = null; + $logo = getDolGlobalString('MAIN_INFO_SOCIETE_LOGO'); + if (!empty($logo)) { + $logofile = $conf->mycompany->dir_output.'/logos/'.$logo; + if (is_readable($logofile) && filesize($logofile) <= 400 * 1024) { + $ext = strtolower(pathinfo($logofile, PATHINFO_EXTENSION)); + $mime = $ext === 'png' ? 'image/png' + : (($ext === 'jpg' || $ext === 'jpeg') ? 'image/jpeg' + : ($ext === 'svg' ? 'image/svg+xml' : '')); + if ($mime) { + $logoUrl = 'data:'.$mime.';base64,'.base64_encode(file_get_contents($logofile)); + } + } + } + echo json_encode([ + 'name' => getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), + 'strasse' => getDolGlobalString('MAIN_INFO_SOCIETE_ADDRESS'), + 'plzOrt' => trim($zip.' '.$town), + 'telefon' => getDolGlobalString('MAIN_INFO_SOCIETE_PHONE'), + 'mail' => getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'), + 'web' => getDolGlobalString('MAIN_INFO_SOCIETE_WEB'), + 'nummer' => getDolGlobalString('MAIN_INFO_SIRET'), + 'logoUrl' => $logoUrl, + ]); + break; + case 'auftraege_listen': $such = GETPOST('such', 'alphanohtml'); $limit = max(1, min(200, (int) GETPOST('limit', 'int') ?: 50));