kundenkarte/ajax/type_fields.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

61 lines
1.6 KiB
PHP
Executable file

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