-- Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
-- GPL v3+

CREATE TABLE llx_bericht (
    rowid           INTEGER AUTO_INCREMENT PRIMARY KEY,
    entity          INTEGER DEFAULT 1 NOT NULL,
    ref             VARCHAR(128) NOT NULL,
    titel           VARCHAR(255) DEFAULT NULL,
    element_type    VARCHAR(32) NOT NULL,            -- invoice, order, propal
    fk_element      INTEGER NOT NULL,                -- ID des Parent-Objekts
    auftragsnummer  VARCHAR(255) DEFAULT NULL,
    template_odt    VARCHAR(255) DEFAULT NULL,       -- Dateiname aus templates/
    page_format     VARCHAR(8) DEFAULT 'A4',         -- A4, A3, Letter
    page_orientation VARCHAR(8) DEFAULT 'P',          -- P=Portrait, L=Landscape
    status          INTEGER DEFAULT 0 NOT NULL,      -- 0=Entwurf, 1=Final
    final_pdf_path  VARCHAR(512) DEFAULT NULL,       -- Pfad relativ zu DOL_DATA_ROOT
    fk_user_creat   INTEGER NOT NULL,
    fk_user_modif   INTEGER DEFAULT NULL,
    datec           DATETIME NOT NULL,
    tms             TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL,
    note            TEXT DEFAULT NULL
) ENGINE=innodb;
