kundenkarte/ajax/anlage_images.php
data 71272fa425 fix(schematic): Terminal-Farbpropagierung, Auto-Naming, PWA-Abgänge
- buildTerminalPhaseMap: Schritt 1b - Leitungen mit expliziter Farbe als
  Startpunkte (nur Gerät→Gerät, keine Abgänge)
- buildTerminalPhaseMap: Block-Durchreichung (Top↔Bottom) entfernt
- buildTerminalPhaseMap: Junction-Verbindungen (Terminal→Leitung)
  bidirektional verarbeitet via _connectionById Index
- PWA: Abgangs-Rendering mit Index-Fallback wenn source_terminal_id fehlt
- PWA: Abgangs-Labels max-height 130px, min-height 30px
- Auto-Naming: EquipmentCarrier create/update → 'R' + count
- Auto-Naming: EquipmentPanel update → 'Feld ' + count
- pwa_api.php: Hardcoded Fallbacks 'Feld'/'Hutschiene' entfernt
- pwa.js: Hutschiene Auto-Naming dynamisch aus Panel-Carrier-Anzahl
- kundenkarte.js: Carrier-Dialog Placeholder 'z.B. R1 (automatisch)'
- SW Cache auf v12.5 hochgezählt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 09:57:58 +01:00

57 lines
1.6 KiB
PHP
Executable file

<?php
/* Copyright (C) 2026 Alles Watt lauft
*
* AJAX endpoint to get images for an installation element
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
$res = 0;
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res && file_exists("../../../../main.inc.php")) $res = @include "../../../../main.inc.php";
if (!$res) die("Include of main fails");
dol_include_once('/kundenkarte/class/anlagefile.class.php');
dol_include_once('/kundenkarte/class/anlage.class.php');
header('Content-Type: application/json');
// Berechtigungsprüfung
if (!$user->hasRight('kundenkarte', 'read')) {
http_response_code(403);
echo json_encode(['error' => 'Permission denied']);
exit;
}
$anlageId = GETPOSTINT('anlage_id');
if ($anlageId <= 0) {
echo json_encode(array('error' => 'Invalid ID', 'images' => array()));
exit;
}
// Get the anlage to know the socid
$anlage = new Anlage($db);
if ($anlage->fetch($anlageId) <= 0) {
echo json_encode(array('error' => 'Element not found', 'images' => array()));
exit;
}
// Get images for this element
$anlagefile = new AnlageFile($db);
$files = $anlagefile->fetchAllByAnlage($anlageId, 'image');
$images = array();
foreach ($files as $file) {
$images[] = array(
'id' => $file->id,
'name' => $file->filename,
'url' => $file->getUrl(),
'thumb' => $file->getThumbUrl() ?: $file->getUrl(),
);
}
echo json_encode(array('images' => $images));