Terminal-Farben nach Verbindung: - Terminals zeigen Farbe der angeschlossenen Leitung - Grau = keine Verbindung, farbig = Leitung angeschlossen - Neue Hilfsfunktion getTerminalConnectionColor() Leitungen hinter Blöcken: - Layer-Reihenfolge geändert: connections vor blocks - Professionelleres Erscheinungsbild Zeichenmodus-Verbesserungen: - Rechtsklick/Escape bricht nur Linie ab, nicht Modus - Crosshair-Cursor überall im SVG während Zeichenmodus - 30px Hit-Area für bessere Klickbarkeit Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
/* Copyright (C) 2026 Alles Watt lauft
|
|
*
|
|
* AJAX endpoint to get documents 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', 'docs' => 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', 'docs' => array()));
|
|
exit;
|
|
}
|
|
|
|
// Get documents for this element (pdf and document types)
|
|
$anlagefile = new AnlageFile($db);
|
|
$files = $anlagefile->fetchAllByAnlage($anlageId);
|
|
|
|
$docs = array();
|
|
foreach ($files as $file) {
|
|
// Only include PDFs and documents, not images
|
|
if (in_array($file->file_type, array('pdf', 'document'))) {
|
|
$docs[] = array(
|
|
'id' => $file->id,
|
|
'name' => $file->filename,
|
|
'url' => $file->getUrl(),
|
|
'type' => $file->file_type,
|
|
'icon' => $file->file_type == 'pdf' ? 'fa-file-pdf-o' : 'fa-file-text-o',
|
|
);
|
|
}
|
|
}
|
|
|
|
echo json_encode(array('docs' => $docs));
|