kundenkarte/sql/update_3.2.0.sql
data 844e6060c6 feat(pwa): Offline-fähige Progressive Web App für Elektriker
PWA Mobile App für Schaltschrank-Dokumentation vor Ort:
- Token-basierte Authentifizierung (15 Tage gültig)
- Kundensuche mit Offline-Cache
- Anlagen-Auswahl und Offline-Laden
- Felder/Hutschienen/Automaten erfassen
- Automatische Synchronisierung wenn wieder online
- Installierbar auf dem Smartphone Home Screen
- Touch-optimiertes Dark Mode Design
- Quick-Select für Automaten-Werte (B16, C32, etc.)

Schaltplan-Editor Verbesserungen:
- Block Hover-Tooltip mit show_in_hover Feldern
- Produktinfo mit Icon im Tooltip
- Position und Breite in TE

Neue Dateien:
- pwa.php, pwa_auth.php - PWA Einstieg & Auth
- ajax/pwa_api.php - PWA AJAX API
- js/pwa.js, css/pwa.css - PWA App & Styles
- sw.js, manifest.json - Service Worker & Manifest
- img/pwa-icon-192.png, img/pwa-icon-512.png

Version: 5.2.0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-23 15:27:06 +01:00

78 lines
5.5 KiB
SQL
Executable file

-- ============================================================================
-- KundenKarte Module Update 3.2.0
-- Add terminals configuration for equipment types
-- ============================================================================
-- Add terminals_config field to equipment_type table
-- JSON format for defining input/output terminals
-- Example: {"inputs": [{"id": "in_L", "label": "L"}, {"id": "in_N", "label": "N"}], "outputs": [{"id": "out_L", "label": "L"}, {"id": "out_N", "label": "N"}]}
ALTER TABLE llx_kundenkarte_equipment_type
ADD COLUMN terminals_config TEXT DEFAULT NULL COMMENT 'JSON config for terminals (inputs/outputs)';
-- Add free position fields for equipment in the schematic editor
ALTER TABLE llx_kundenkarte_equipment
ADD COLUMN editor_x INTEGER DEFAULT NULL COMMENT 'X position in schematic editor',
ADD COLUMN editor_y INTEGER DEFAULT NULL COMMENT 'Y position in schematic editor';
-- Update connection table to support terminal-based connections
ALTER TABLE llx_kundenkarte_equipment_connection
ADD COLUMN source_terminal_id VARCHAR(64) DEFAULT NULL COMMENT 'Source terminal ID (e.g., out_L, out_N)',
ADD COLUMN target_terminal_id VARCHAR(64) DEFAULT NULL COMMENT 'Target terminal ID (e.g., in_L, in_N)';
-- Default terminal configurations for common equipment types
-- These can be customized by the user
-- LS (Leitungsschutzschalter) - 1 input, 1 output
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in","label":"●","pos":"top"}],"outputs":[{"id":"out","label":"●","pos":"bottom"}]}'
WHERE ref IN ('LS', 'LSS', 'B16', 'C16') AND terminals_config IS NULL;
-- FI (Fehlerstromschutzschalter) - 2 inputs, 2 outputs (L+N)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L","label":"L","pos":"top-left"},{"id":"in_N","label":"N","pos":"top-right"}],"outputs":[{"id":"out_L","label":"L","pos":"bottom-left"},{"id":"out_N","label":"N","pos":"bottom-right"}]}'
WHERE ref IN ('FI', 'RCD', 'RCCB') AND terminals_config IS NULL;
-- FI/LS Kombi - 2 inputs, 2 outputs
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L","label":"L","pos":"top-left"},{"id":"in_N","label":"N","pos":"top-right"}],"outputs":[{"id":"out_L","label":"L","pos":"bottom-left"},{"id":"out_N","label":"N","pos":"bottom-right"}]}'
WHERE ref IN ('FILS', 'RCBO') AND terminals_config IS NULL;
-- 3-poliger LS - 3 inputs, 3 outputs
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L1","label":"L1","pos":"top"},{"id":"in_L2","label":"L2","pos":"top"},{"id":"in_L3","label":"L3","pos":"top"}],"outputs":[{"id":"out_L1","label":"L1","pos":"bottom"},{"id":"out_L2","label":"L2","pos":"bottom"},{"id":"out_L3","label":"L3","pos":"bottom"}]}'
WHERE ref IN ('LS3P', 'C3P') AND terminals_config IS NULL;
-- 4-poliger FI - 4 inputs, 4 outputs
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L1","label":"L1","pos":"top"},{"id":"in_L2","label":"L2","pos":"top"},{"id":"in_L3","label":"L3","pos":"top"},{"id":"in_N","label":"N","pos":"top"}],"outputs":[{"id":"out_L1","label":"L1","pos":"bottom"},{"id":"out_L2","label":"L2","pos":"bottom"},{"id":"out_L3","label":"L3","pos":"bottom"},{"id":"out_N","label":"N","pos":"bottom"}]}'
WHERE ref IN ('FI4P', 'RCD4P') AND terminals_config IS NULL;
-- Hauptschalter - variable (default 3P+N)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L1","label":"L1","pos":"top"},{"id":"in_L2","label":"L2","pos":"top"},{"id":"in_L3","label":"L3","pos":"top"},{"id":"in_N","label":"N","pos":"top"}],"outputs":[{"id":"out_L1","label":"L1","pos":"bottom"},{"id":"out_L2","label":"L2","pos":"bottom"},{"id":"out_L3","label":"L3","pos":"bottom"},{"id":"out_N","label":"N","pos":"bottom"}]}'
WHERE ref IN ('HS', 'HAUPTSCHALTER') AND terminals_config IS NULL;
-- Schütz/Relais - 2 inputs, 2 outputs (Steuerstromkreis + Lastkreis)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_A1","label":"A1","pos":"top-left"},{"id":"in_1","label":"1","pos":"top-right"}],"outputs":[{"id":"out_A2","label":"A2","pos":"bottom-left"},{"id":"out_2","label":"2","pos":"bottom-right"}]}'
WHERE ref IN ('SCHUETZ', 'RELAIS', 'K') AND terminals_config IS NULL;
-- Stromstoßschalter - Steuerung + 2 Lastanschlüsse
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_A1","label":"A1","pos":"top-left"},{"id":"in_1","label":"1","pos":"top-right"}],"outputs":[{"id":"out_A2","label":"A2","pos":"bottom-left"},{"id":"out_2","label":"2","pos":"bottom-right"}]}'
WHERE ref IN ('SSS', 'STROMSTOSS') AND terminals_config IS NULL;
-- Klemme - durchgehend
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in","label":"●","pos":"top"}],"outputs":[{"id":"out","label":"●","pos":"bottom"}]}'
WHERE ref IN ('KLEMME', 'REIHENKLEMME', 'RK') AND terminals_config IS NULL;
-- Überspannungsschutz - 3P+N+PE
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in_L1","label":"L1","pos":"top"},{"id":"in_L2","label":"L2","pos":"top"},{"id":"in_L3","label":"L3","pos":"top"},{"id":"in_N","label":"N","pos":"top"}],"outputs":[{"id":"out_PE","label":"PE","pos":"bottom"}]}'
WHERE ref IN ('SPD', 'UESP') AND terminals_config IS NULL;
-- Default for any equipment without config: 1 input, 1 output
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"inputs":[{"id":"in","label":"●","pos":"top"}],"outputs":[{"id":"out","label":"●","pos":"bottom"}]}'
WHERE terminals_config IS NULL;