kundenkarte/sql/llx_kundenkarte_equipment_connection.sql
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

64 lines
3.5 KiB
SQL
Executable file

-- Copyright (C) 2026 Alles Watt lauft
--
-- Equipment connections (Verbindungen zwischen Equipment)
-- Generic connection system for any installation type (electrical, network, security, etc.)
CREATE TABLE llx_kundenkarte_equipment_connection (
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
entity INTEGER DEFAULT 1 NOT NULL,
-- Source equipment (where connection comes FROM)
fk_source INTEGER, -- NULL = external input
source_terminal VARCHAR(20) DEFAULT 'output', -- Terminal identifier (flexible)
-- Target equipment (where connection goes TO)
fk_target INTEGER, -- NULL = output/endpoint
target_terminal VARCHAR(20) DEFAULT 'input', -- Terminal identifier (flexible)
-- Connection properties (flexible, user-defined)
connection_type VARCHAR(50), -- User-defined type (e.g., "L1N", "CAT6", "2-Draht", etc.)
color VARCHAR(20), -- Display color (hex code)
-- Output/endpoint info (when fk_target is NULL)
output_label VARCHAR(255), -- e.g., "Küche Steckdosen", "Büro PC1", "Haustür"
-- Medium info (cable, wire, etc.) - all flexible text fields
medium_type VARCHAR(100), -- e.g., "NYM-J", "CAT6 S/FTP", "2x0.8 J-Y(St)Y"
medium_spec VARCHAR(100), -- e.g., "3x2.5", "AWG23", "Ring 1"
medium_length VARCHAR(50), -- Length as text (allows "ca. 15m", "5-10m", etc.)
-- Rail/bar connections (spans multiple equipment)
is_rail TINYINT DEFAULT 0, -- 1 = this is a rail/bar spanning multiple slots
rail_start_te INTEGER, -- Start position on carrier
rail_end_te INTEGER, -- End position on carrier
rail_phases VARCHAR(20), -- '3P', '3P+N', 'L1', 'L1N', etc. for multi-line display
excluded_te VARCHAR(100), -- Comma-separated TE positions to exclude (gaps for FI)
fk_carrier INTEGER, -- Carrier where this connection is rendered
position_y INTEGER DEFAULT 0, -- Y offset for rendering (0=first row, 1=second row, etc.)
-- Manual path data (SVG path string for manually drawn connections)
path_data TEXT, -- SVG path like "M 100 200 L 150 200 L 150 300"
note_private TEXT,
status INTEGER DEFAULT 1,
date_creation DATETIME,
tms TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
fk_user_creat INTEGER,
fk_user_modif INTEGER
) ENGINE=InnoDB;
-- Indexes
ALTER TABLE llx_kundenkarte_equipment_connection ADD INDEX idx_connection_source (fk_source);
ALTER TABLE llx_kundenkarte_equipment_connection ADD INDEX idx_connection_target (fk_target);
ALTER TABLE llx_kundenkarte_equipment_connection ADD INDEX idx_connection_carrier (fk_carrier);
ALTER TABLE llx_kundenkarte_equipment_connection ADD INDEX idx_connection_entity (entity);
-- Foreign keys
ALTER TABLE llx_kundenkarte_equipment_connection ADD CONSTRAINT fk_connection_source
FOREIGN KEY (fk_source) REFERENCES llx_kundenkarte_equipment(rowid) ON DELETE CASCADE;
ALTER TABLE llx_kundenkarte_equipment_connection ADD CONSTRAINT fk_connection_target
FOREIGN KEY (fk_target) REFERENCES llx_kundenkarte_equipment(rowid) ON DELETE CASCADE;
ALTER TABLE llx_kundenkarte_equipment_connection ADD CONSTRAINT fk_connection_carrier
FOREIGN KEY (fk_carrier) REFERENCES llx_kundenkarte_equipment_carrier(rowid) ON DELETE CASCADE;