# SubtotalTitle - Dolibarr Modul Erweitert Rechnungen, Angebote und KundenauftrΓ€ge um **Sections**, **Textzeilen** und **Zwischensummen**. --- ## πŸ”‘ ODT Template SchlΓΌsselwΓΆrter ### Zeilen-Variablen (pro Zeile in row.lines) | Variable | Wert | Beschreibung | |----------|------|--------------| | `{line_is_section}` | 1/"" | Zeile ist eine Section (Überschrift) | | `{line_is_textline}` | 1/"" | Zeile ist eine Textzeile | | `{line_is_subtotal}` | 1/"" | Zeile ist eine Zwischensumme | | `{line_is_product}` | 1/"" | Zeile ist ein Produkt mit Produktreferenz | | `{line_is_free_line}` | 1/"" | Zeile ist eine freie Zeile (ohne Produktreferenz) | | `{line_is_normal}` | 1/"" | Zeile ist normal (special_code = 0) | | `{line_is_special}` | 1/"" | Zeile ist Section, Text ODER Subtotal | | `{line_special_code}` | 0-102 | special_code Wert der Zeile | ### Globale Variablen (fΓΌr das gesamte Dokument) | Variable | Wert | Beschreibung | |----------|------|--------------| | `{object_has_sections}` | 1/"" | Dokument enthΓ€lt mindestens eine Section | | `{object_has_textlines}` | 1/"" | Dokument enthΓ€lt mindestens eine Textzeile | | `{object_has_speciallines}` | 1/"" | Dokument enthΓ€lt Sections, Textzeilen oder Subtotals | | `{object_count_sections}` | Zahl | Anzahl der Sections im Dokument | | `{object_count_textlines}` | Zahl | Anzahl der Textzeilen im Dokument | | `{object_count_subtotals}` | Zahl | Anzahl der Zwischensummen im Dokument | ### special_code Werte | Typ | special_code | |-----|-------------| | Normales Produkt | 0 | | Section (Überschrift) | 100 | | Textzeile | 101 | | Zwischensumme | 102 | ### ODT Template Beispiel ``` [!-- IF {object_has_sections} --] Dieses Dokument enthΓ€lt {object_count_sections} Section(s). [!-- ENDIF {object_has_sections} --] [!-- BEGIN row.lines --] [!-- IF {line_is_section} --] ═══════════════════════════════════════ {line_desc} ═══════════════════════════════════════ [!-- ENDIF {line_is_section} --] [!-- IF {line_is_textline} --] {line_desc} [!-- ENDIF {line_is_textline} --] [!-- IF {line_is_product} --] {line_pos} {line_qty} {line_ref} {line_desc} {line_up_locale} € {line_price_ht_locale} € [!-- ENDIF {line_is_product} --] [!-- IF {line_is_free_line} --] {line_pos} {line_qty} {line_desc} {line_up_locale} € {line_price_ht_locale} € [!-- ENDIF {line_is_free_line} --] [!-- IF {line_is_subtotal} --] ─────────────────────────────────────── Zwischensumme: {line_price_ht_locale} € ─────────────────────────────────────── [!-- ENDIF {line_is_subtotal} --] [!-- END row.lines --] ``` --- ## πŸ“‹ Modul-Funktionen ### Sections (Überschriften) - Erstellen von Überschriften zur Strukturierung - Produkte kΓΆnnen per Drag & Drop oder Link-Button zugeordnet werden - Optional: Zwischensumme fΓΌr jede Section anzeigen - Ein-/Ausklappen von Sections ### Textzeilen - Freie Textzeilen ohne Preis - Ideal fΓΌr Hinweise, Bedingungen oder ErklΓ€rungen ### Zwischensummen - Automatische Berechnung der Summe aller Produkte in einer Section - Checkbox zum Ein-/Ausschalten pro Section ### Dokument-Synchronisation - **πŸ“„ Checkbox** bei jeder Section/Textzeile/Subtotal: Element zum Dokument hinzufΓΌgen - **β†’ Zum Dokument / ← Aus Dokument** Buttons: Alle Elemente auf einmal synchronisieren - **GrΓΌner Rand** = Element ist im Dokument/PDF enthalten - Buttons werden nur angezeigt wenn Sections oder Textzeilen vorhanden sind ### UnterstΓΌtzte Dokumenttypen - Rechnungen (Factures) - Angebote (Propals) - KundenauftrΓ€ge (Commandes) --- ## πŸ”§ Installation ### 1. Dateien kopieren ``` htdocs/custom/subtotaltitle/ β”œβ”€β”€ class/ β”‚ β”œβ”€β”€ actions_subtotaltitle.class.php β”‚ └── DocumentTypeHelper.class.php β”œβ”€β”€ ajax/ β”‚ β”œβ”€β”€ add_to_section.php β”‚ β”œβ”€β”€ assign_last_product.php β”‚ β”œβ”€β”€ cleanup_subtotals.php β”‚ β”œβ”€β”€ create_section.php β”‚ β”œβ”€β”€ create_textline.php β”‚ β”œβ”€β”€ get_textlines.php β”‚ β”œβ”€β”€ move_section.php β”‚ β”œβ”€β”€ reorder_all.php β”‚ β”œβ”€β”€ sync_to_facturedet.php β”‚ └── toggle_subtotal.php β”œβ”€β”€ core/ β”‚ β”œβ”€β”€ modules/ β”‚ β”‚ └── modSubtotalTitle.class.php β”‚ └── substitutions/ β”‚ └── functions_subtotaltitle.lib.php β”œβ”€β”€ js/ β”‚ └── subtotaltitle.js β”œβ”€β”€ css/ β”‚ └── subtotaltitle.css β”œβ”€β”€ lib/ β”‚ └── subtotaltitle.lib.php └── sql/ └── llx_facture_lines_manager.sql ``` ### 2. Modul aktivieren Im Dolibarr Backend unter **Home β†’ Setup β†’ Modules** das Modul **SubtotalTitle** aktivieren. Die Datenbanktabelle `llx_facture_lines_manager` wird automatisch erstellt. ### 3. Modul-Konfiguration In `core/modules/modSubtotalTitle.class.php` muss folgendes gesetzt sein: ```php $this->module_parts = array( 'substitutions' => 1, // FΓΌr ODT-Variablen 'hooks' => array( 'data' => array('invoicecard', 'propalcard', 'ordercard'), 'entity' => '0' ) ); ``` --- ## πŸ—„οΈ Datenbank ### Tabelle: llx_facture_lines_manager | Feld | Typ | Beschreibung | |------|-----|--------------| | rowid | INT | Primary Key | | fk_facture | INT | FK zu Rechnung | | fk_propal | INT | FK zu Angebot | | fk_commande | INT | FK zu Kundenauftrag | | document_type | VARCHAR(20) | 'invoice', 'propal', 'order' | | line_type | VARCHAR(20) | 'section', 'product', 'text', 'subtotal' | | fk_facturedet | INT | FK zu llx_facturedet | | fk_propaldet | INT | FK zu llx_propaldet | | fk_commandedet | INT | FK zu llx_commandedet | | title | VARCHAR(255) | Titel fΓΌr Sections/Text | | parent_section | INT | FK zur ΓΌbergeordneten Section | | line_order | INT | Sortierreihenfolge | | show_subtotal | TINYINT | Zwischensumme anzeigen (0/1) | | collapsed | TINYINT | Section eingeklappt (0/1) | | in_facturedet | TINYINT | Im Dokument enthalten (0/1) | --- ## πŸ“ Changelog ### Version 1.0 - Initiale Version mit Section-, Text- und Subtotal-UnterstΓΌtzung - ODT-Substitutionsvariablen - Multi-Dokument-Support (Rechnungen, Angebote, KundenauftrΓ€ge) - Drag & Drop Sortierung - Dokument-Synchronisation --- ## πŸ“„ Lizenz Copyright (C) 2026 Eduard Wisch Dieses Programm ist freie Software: Sie kΓΆnnen es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation verΓΆffentlicht, weitergeben und/oder modifizieren, entweder Version 3 der Lizenz oder (nach Ihrer Wahl) jede spΓ€tere Version.