-- ============================================================================
-- KundenKarte Module Update 3.3.0
-- Correct terminal configurations (bidirectional format)
-- Audit Log table for tracking changes
-- Medium Types for connections (cable types)
-- Building Types (global structure elements)
-- Tree view display options per system
-- ============================================================================

-- Add tree display configuration to system table
ALTER TABLE llx_c_kundenkarte_anlage_system
ADD COLUMN tree_display_config TEXT COMMENT 'JSON config for tree display options';

-- Anlage Connections table (Verbindungen zwischen Anlagen-Elementen)
CREATE TABLE IF NOT EXISTS llx_kundenkarte_anlage_connection
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 1 NOT NULL,
    fk_source           integer NOT NULL,
    fk_target           integer NOT NULL,
    label               varchar(255),
    fk_medium_type      integer,
    medium_type_text    varchar(100),
    medium_spec         varchar(100),
    medium_length       varchar(50),
    medium_color        varchar(50),
    route_description   text,
    installation_date   date,
    status              integer DEFAULT 1,
    note_private        text,
    note_public         text,
    date_creation       datetime,
    tms                 timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    fk_user_creat       integer,
    fk_user_modif       integer,
    INDEX idx_anlage_conn_source (fk_source),
    INDEX idx_anlage_conn_target (fk_target)
) ENGINE=innodb;

-- Building Types table (Gebäudetypen)
CREATE TABLE IF NOT EXISTS llx_kundenkarte_building_type
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 0 NOT NULL,
    ref                 varchar(50) NOT NULL,
    label               varchar(128) NOT NULL,
    label_short         varchar(32),
    description         text,
    fk_parent           integer DEFAULT 0,
    level_type          varchar(32),
    icon                varchar(64),
    color               varchar(20),
    picto               varchar(128),
    is_system           tinyint DEFAULT 0,
    can_have_children   tinyint DEFAULT 1,
    position            integer DEFAULT 0,
    active              tinyint DEFAULT 1,
    date_creation       datetime,
    tms                 timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    fk_user_creat       integer,
    fk_user_modif       integer,
    UNIQUE KEY uk_building_type_ref (ref, entity),
    INDEX idx_building_parent (fk_parent),
    INDEX idx_building_level (level_type)
) ENGINE=innodb;

-- Medium Types table (Kabeltypen)
CREATE TABLE IF NOT EXISTS llx_kundenkarte_medium_type
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 0 NOT NULL,
    ref                 varchar(50) NOT NULL,
    label               varchar(128) NOT NULL,
    label_short         varchar(32),
    description         text,
    fk_system           integer DEFAULT 0,
    category            varchar(50),
    default_spec        varchar(100),
    available_specs     text,
    color               varchar(20),
    picto               varchar(128),
    fk_product          integer,
    is_system           tinyint DEFAULT 0,
    position            integer DEFAULT 0,
    active              tinyint DEFAULT 1,
    date_creation       datetime,
    tms                 timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    fk_user_creat       integer,
    fk_user_modif       integer,
    UNIQUE KEY uk_medium_type_ref (ref, entity),
    INDEX idx_medium_system (fk_system),
    INDEX idx_medium_category (category)
) ENGINE=innodb;

-- Audit Log table
CREATE TABLE IF NOT EXISTS llx_kundenkarte_audit_log
(
    rowid               integer AUTO_INCREMENT PRIMARY KEY,
    entity              integer DEFAULT 1 NOT NULL,
    object_type         varchar(64) NOT NULL,
    object_id           integer NOT NULL,
    object_ref          varchar(128),
    fk_societe          integer,
    fk_anlage           integer,
    action              varchar(32) NOT NULL,
    field_changed       varchar(64),
    old_value           text,
    new_value           text,
    fk_user             integer NOT NULL,
    user_login          varchar(64),
    date_action         datetime NOT NULL,
    note                text,
    ip_address          varchar(45),
    INDEX idx_audit_object (object_type, object_id),
    INDEX idx_audit_societe (fk_societe),
    INDEX idx_audit_anlage (fk_anlage),
    INDEX idx_audit_date (date_action),
    INDEX idx_audit_user (fk_user)
) ENGINE=innodb;

-- FI (Fehlerstromschutzschalter) - 4 Terminals (2 oben: L+N, 2 unten: L+N)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L","pos":"top"},{"id":"t2","label":"N","pos":"top"},{"id":"t3","label":"L","pos":"bottom"},{"id":"t4","label":"N","pos":"bottom"}]}'
WHERE ref IN ('FI', 'RCD', 'RCCB');

-- FI/LS Kombi - 4 Terminals
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L","pos":"top"},{"id":"t2","label":"N","pos":"top"},{"id":"t3","label":"L","pos":"bottom"},{"id":"t4","label":"N","pos":"bottom"}]}'
WHERE ref IN ('FILS', 'RCBO');

-- HS (Hauptschalter) - 3 Pole (L1, L2, L3) ohne N
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L1","pos":"top"},{"id":"t2","label":"L2","pos":"top"},{"id":"t3","label":"L3","pos":"top"},{"id":"t4","label":"L1","pos":"bottom"},{"id":"t5","label":"L2","pos":"bottom"},{"id":"t6","label":"L3","pos":"bottom"}]}'
WHERE ref IN ('HS', 'HAUPTSCHALTER');

-- LS (Leitungsschutzschalter) - 2 Terminals (1 oben, 1 unten)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"●","pos":"top"},{"id":"t2","label":"●","pos":"bottom"}]}'
WHERE ref IN ('LS', 'LSS', 'B16', 'C16') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- 3-poliger LS - 6 Terminals
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L1","pos":"top"},{"id":"t2","label":"L2","pos":"top"},{"id":"t3","label":"L3","pos":"top"},{"id":"t4","label":"L1","pos":"bottom"},{"id":"t5","label":"L2","pos":"bottom"},{"id":"t6","label":"L3","pos":"bottom"}]}'
WHERE ref IN ('LS3P', 'C3P') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- 4-poliger FI - 8 Terminals (3P+N)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L1","pos":"top"},{"id":"t2","label":"L2","pos":"top"},{"id":"t3","label":"L3","pos":"top"},{"id":"t4","label":"N","pos":"top"},{"id":"t5","label":"L1","pos":"bottom"},{"id":"t6","label":"L2","pos":"bottom"},{"id":"t7","label":"L3","pos":"bottom"},{"id":"t8","label":"N","pos":"bottom"}]}'
WHERE ref IN ('FI4P', 'RCD4P') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- Schuetz/Relais - 4 Terminals
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"A1","pos":"top"},{"id":"t2","label":"1","pos":"top"},{"id":"t3","label":"A2","pos":"bottom"},{"id":"t4","label":"2","pos":"bottom"}]}'
WHERE ref IN ('SCHUETZ', 'RELAIS', 'K') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- Klemme - 2 Terminals
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"●","pos":"top"},{"id":"t2","label":"●","pos":"bottom"}]}'
WHERE ref IN ('KLEMME', 'REIHENKLEMME', 'RK') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- Ueberspannungsschutz - 5 Terminals (3P+N oben, PE unten)
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"L1","pos":"top"},{"id":"t2","label":"L2","pos":"top"},{"id":"t3","label":"L3","pos":"top"},{"id":"t4","label":"N","pos":"top"},{"id":"t5","label":"PE","pos":"bottom"}]}'
WHERE ref IN ('SPD', 'UESP') AND (terminals_config IS NULL OR terminals_config LIKE '%inputs%');

-- Default: 2 Terminals fuer alle ohne Konfiguration
UPDATE llx_kundenkarte_equipment_type
SET terminals_config = '{"terminals":[{"id":"t1","label":"●","pos":"top"},{"id":"t2","label":"●","pos":"bottom"}]}'
WHERE terminals_config IS NULL OR terminals_config = '';

-- ============================================================================
-- Default Medium Types (Kabeltypen)
-- Insert only if not exists
-- ============================================================================

-- NYM-J (Mantelleitung für Innenbereich)
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'NYM-J', 'NYM-J Mantelleitung', 'NYM', 'stromkabel', 1, '3x1,5', '["1,5", "2,5", "4", "6", "10", "16", "3x1,5", "3x2,5", "3x4", "3x6", "5x1,5", "5x2,5", "5x4", "5x6", "5x10", "5x16"]', '#666666', 1, 10, 1, NOW());

-- NYY-J (Erdkabel)
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'NYY-J', 'NYY-J Erdkabel', 'NYY', 'stromkabel', 1, '3x1,5', '["3x1,5", "3x2,5", "3x4", "3x6", "5x1,5", "5x2,5", "5x4", "5x6", "5x10", "5x16", "5x25"]', '#333333', 1, 20, 1, NOW());

-- H07V-U (Aderleitung starr)
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'H07V-U', 'H07V-U Aderleitung starr', 'H07V-U', 'stromkabel', 1, '1,5', '["1,5", "2,5", "4", "6", "10"]', '#0066cc', 1, 30, 1, NOW());

-- H07V-K (Aderleitung flexibel)
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'H07V-K', 'H07V-K Aderleitung flexibel', 'H07V-K', 'stromkabel', 1, '1,5', '["1,5", "2,5", "4", "6", "10", "16", "25"]', '#3498db', 1, 40, 1, NOW());

-- H05VV-F (Schlauchleitung)
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'H05VV-F', 'H05VV-F Schlauchleitung', 'H05VV-F', 'stromkabel', 1, '3x1,0', '["2x0,75", "2x1,0", "3x0,75", "3x1,0", "3x1,5", "5x1,0", "5x1,5"]', '#ffffff', 1, 50, 1, NOW());

-- CAT5e
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'CAT5E', 'CAT5e Netzwerkkabel', 'CAT5e', 'netzwerkkabel', 2, 'U/UTP', '["U/UTP", "F/UTP", "S/FTP"]', '#f39c12', 1, 100, 1, NOW());

-- CAT6
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'CAT6', 'CAT6 Netzwerkkabel', 'CAT6', 'netzwerkkabel', 2, 'U/UTP', '["U/UTP", "F/UTP", "S/FTP", "S/STP"]', '#e67e22', 1, 110, 1, NOW());

-- CAT6a
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'CAT6A', 'CAT6a Netzwerkkabel', 'CAT6a', 'netzwerkkabel', 2, 'S/FTP', '["U/UTP", "F/UTP", "S/FTP", "S/STP"]', '#d35400', 1, 120, 1, NOW());

-- CAT7
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'CAT7', 'CAT7 Netzwerkkabel', 'CAT7', 'netzwerkkabel', 2, 'S/FTP', '["S/FTP", "S/STP"]', '#c0392b', 1, 130, 1, NOW());

-- CAT8
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'CAT8', 'CAT8 Netzwerkkabel', 'CAT8', 'netzwerkkabel', 2, 'S/FTP', '["S/FTP"]', '#8e44ad', 1, 140, 1, NOW());

-- LWL Singlemode
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'LWL-SM', 'LWL Singlemode', 'SM', 'lwl', 2, 'OS2 9/125', '["OS2 9/125", "2 Fasern", "4 Fasern", "8 Fasern", "12 Fasern", "24 Fasern"]', '#f1c40f', 1, 150, 1, NOW());

-- LWL Multimode
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'LWL-MM', 'LWL Multimode', 'MM', 'lwl', 2, 'OM3 50/125', '["OM1 62.5/125", "OM2 50/125", "OM3 50/125", "OM4 50/125", "OM5 50/125"]', '#2ecc71', 1, 160, 1, NOW());

-- RG6
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'RG6', 'RG6 Koaxialkabel', 'RG6', 'koax', 3, '75 Ohm', '["75 Ohm", "Quad-Shield"]', '#1abc9c', 1, 200, 1, NOW());

-- RG59
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'RG59', 'RG59 Koaxialkabel', 'RG59', 'koax', 3, '75 Ohm', '["75 Ohm"]', '#16a085', 1, 210, 1, NOW());

-- SAT-Kabel
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'SAT-KOAX', 'SAT Koaxialkabel', 'SAT', 'koax', 4, '120dB', '["90dB", "100dB", "110dB", "120dB", "130dB"]', '#9b59b6', 1, 220, 1, NOW());

-- Leerrohr
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'LEERROHR', 'Leerrohr/Kabelkanal', 'Rohr', 'sonstiges', 0, 'M20', '["M16", "M20", "M25", "M32", "M40", "M50", "DN50", "DN75", "DN100"]', '#95a5a6', 1, 300, 1, NOW());

-- Kabelrinne
INSERT IGNORE INTO llx_kundenkarte_medium_type (entity, ref, label, label_short, category, fk_system, default_spec, available_specs, color, is_system, position, active, date_creation)
VALUES (0, 'KABELRINNE', 'Kabelrinne/Kabeltrasse', 'Rinne', 'sonstiges', 0, '100x60', '["60x40", "100x60", "200x60", "300x60", "400x60", "500x100"]', '#7f8c8d', 1, 310, 1, NOW());

-- ============================================================================
-- Default Building Types (Gebaeudetypen)
-- ============================================================================

-- BUILDING LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'HAUS', 'Haus', 'Haus', 'building', 'fa-home', '#3498db', 1, 1, 10, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'HALLE', 'Halle', 'Halle', 'building', 'fa-warehouse', '#e67e22', 1, 1, 20, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'STALL', 'Stall', 'Stall', 'building', 'fa-horse', '#8e44ad', 1, 1, 30, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'GARAGE', 'Garage', 'Garage', 'building', 'fa-car', '#2c3e50', 1, 1, 40, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'BUEROGEBAEUDE', 'Buerogebaeude', 'Buero', 'building', 'fa-building', '#1abc9c', 1, 1, 50, 1, NOW());

-- FLOOR LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'KELLER', 'Keller', 'KG', 'floor', 'fa-level-down-alt', '#34495e', 1, 1, 100, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'ERDGESCHOSS', 'Erdgeschoss', 'EG', 'floor', 'fa-layer-group', '#27ae60', 1, 1, 110, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'OBERGESCHOSS', 'Obergeschoss', 'OG', 'floor', 'fa-level-up-alt', '#2980b9', 1, 1, 120, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'DACHGESCHOSS', 'Dachgeschoss', 'DG', 'floor', 'fa-home', '#9b59b6', 1, 1, 130, 1, NOW());

-- WING LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'NORDFLUEGL', 'Nordfluegel', 'Nord', 'wing', 'fa-compass', '#3498db', 1, 1, 200, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'SUEDFLUEGL', 'Suedfluegel', 'Sued', 'wing', 'fa-compass', '#e74c3c', 1, 1, 210, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'ANBAU', 'Anbau', 'Anbau', 'wing', 'fa-plus-square', '#1abc9c', 1, 1, 220, 1, NOW());

-- CORRIDOR LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'FLUR', 'Flur', 'Flur', 'corridor', 'fa-arrows-alt-h', '#16a085', 1, 1, 300, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'EINGANGSHALLE', 'Eingangshalle', 'Eingang', 'corridor', 'fa-door-open', '#2c3e50', 1, 1, 310, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'TREPPENHAUS', 'Treppenhaus', 'Treppe', 'corridor', 'fa-stairs', '#8e44ad', 1, 1, 320, 1, NOW());

-- ROOM LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'ZIMMER', 'Zimmer', 'Zi', 'room', 'fa-door-closed', '#3498db', 1, 0, 400, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'WOHNZIMMER', 'Wohnzimmer', 'WoZi', 'room', 'fa-couch', '#e67e22', 1, 0, 410, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'SCHLAFZIMMER', 'Schlafzimmer', 'SchZi', 'room', 'fa-bed', '#9b59b6', 1, 0, 420, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'KUECHE', 'Kueche', 'Kue', 'room', 'fa-utensils', '#27ae60', 1, 0, 430, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'BAD', 'Badezimmer', 'Bad', 'room', 'fa-bath', '#3498db', 1, 0, 440, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'BUERO', 'Buero', 'Buero', 'room', 'fa-desktop', '#2c3e50', 1, 0, 450, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'TECHNIKRAUM', 'Technikraum', 'Tech', 'room', 'fa-cogs', '#e74c3c', 1, 1, 460, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'SERVERRAUM', 'Serverraum', 'Server', 'room', 'fa-server', '#8e44ad', 1, 1, 470, 1, NOW());

-- AREA LEVEL
INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'AUSSENBEREICH', 'Aussenbereich', 'Aussen', 'area', 'fa-tree', '#27ae60', 1, 1, 500, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'TERRASSE', 'Terrasse', 'Terrasse', 'area', 'fa-sun', '#f1c40f', 1, 0, 510, 1, NOW());

INSERT IGNORE INTO llx_kundenkarte_building_type (entity, ref, label, label_short, level_type, icon, color, is_system, can_have_children, position, active, date_creation)
VALUES (0, 'GARTEN', 'Garten', 'Garten', 'area', 'fa-leaf', '#2ecc71', 1, 1, 520, 1, NOW());
