kundenkarte/ajax/type_fields.php
data 6b3b6d7e95 feat(schematic): Terminal-Farben, Leitungen hinter Blöcken, Zeichenmodus v11.0
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>
2026-03-04 13:44:52 +01:00

61 lines
1.6 KiB
PHP

<?php
/* Copyright (C) 2026 Alles Watt lauft
*
* AJAX endpoint to get fields for an anlage type
*/
$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");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
dol_include_once('/kundenkarte/class/anlagetype.class.php');
dol_include_once('/kundenkarte/class/anlage.class.php');
header('Content-Type: application/json');
$typeId = GETPOSTINT('type_id');
$anlageId = GETPOSTINT('anlage_id');
if (empty($typeId)) {
echo json_encode(array('fields' => array()));
exit;
}
$type = new AnlageType($db);
if ($type->fetch($typeId) <= 0) {
echo json_encode(array('fields' => array()));
exit;
}
$fields = $type->fetchFields();
// Get existing values if editing
$existingValues = array();
if ($anlageId > 0) {
$anlage = new Anlage($db);
if ($anlage->fetch($anlageId) > 0) {
$existingValues = $anlage->getFieldValues();
}
}
$result = array('fields' => array());
foreach ($fields as $field) {
$fieldData = array(
'code' => $field->field_code,
'label' => $field->field_label,
'type' => $field->field_type,
'options' => $field->field_options,
'required' => (int)$field->required === 1,
'autocomplete' => (int)$field->enable_autocomplete === 1,
'value' => isset($existingValues[$field->field_code]) ? $existingValues[$field->field_code] : ''
);
$result['fields'][] = $fieldData;
}
// Also include type_id for autocomplete
$result['type_id'] = $typeId;
echo json_encode($result);