* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ /** * \file subtotaltitle/core/substitutions/functions_subtotaltitle.lib.php * \brief Substitution functions for SubtotalTitle module (ODT templates) * * Stellt folgende ODT-Variablen bereit: * - {line_special_code} : Der numerische Code (0, 100, 101, 102) * - {line_is_section} : "1" wenn Section, sonst leer * - {line_is_textline} : "1" wenn Textzeile, sonst leer * - {line_is_subtotal} : "1" wenn Zwischensumme, sonst leer * - {line_is_product} : "1" wenn Produkt, sonst leer * - {line_is_normal} : "1" wenn special_code = 0, sonst leer * - {line_is_special} : "1" wenn eine Spezialzeile (100-102), sonst leer */ /** * Function called for each line to add custom substitution tags * * @param array $substitutionarray Array with substitution key=>val * @param Translate $langs Output langs * @param Object $object Object to use to get values * @param Object $line Current line being processed * @return void */ function subtotaltitle_completesubstitutionarray_lines(&$substitutionarray, $langs, $object, $line) { global $conf, $db; // special_code direkt verfügbar machen $special_code = isset($line->special_code) ? (int)$line->special_code : 0; $substitutionarray['line_special_code'] = $special_code; // Typ-Flags für einfachere IF-Bedingungen im ODT // Werte: '1' für true, '' (leer) für false - so funktioniert [!-- IF {xxx} --] // Section/Titel (special_code = 100) $substitutionarray['line_is_section'] = ($special_code == 100) ? '1' : ''; // Textzeile (special_code = 101) $substitutionarray['line_is_textline'] = ($special_code == 101) ? '1' : ''; // Zwischensumme (special_code = 102) $substitutionarray['line_is_subtotal'] = ($special_code == 102) ? '1' : ''; // Normales Produkt (special_code = 0 und hat Produkt-Referenz) $is_product = ($special_code == 0 && isset($line->fk_product) && $line->fk_product > 0); $substitutionarray['line_is_product'] = $is_product ? '1' : ''; // Freie Zeile (special_code = 0 und kein Produkt) $is_free_line = ($special_code == 0 && (!isset($line->fk_product) || $line->fk_product <= 0)); $substitutionarray['line_is_free_line'] = $is_free_line ? '1' : ''; // Kombinierter Check: Ist es KEINE unserer Spezialzeilen? $is_normal = ($special_code == 0); $substitutionarray['line_is_normal'] = $is_normal ? '1' : ''; // Ist es EINE unserer Spezialzeilen? $is_special = ($special_code >= 100 && $special_code <= 102); $substitutionarray['line_is_special'] = $is_special ? '1' : ''; } /** * Function called once for global substitutions (not per line) * * @param array $substitutionarray Array with substitution key=>val * @param Translate $langs Output langs * @param Object $object Object to use to get values * @return void */ function subtotaltitle_completesubstitutionarray(&$substitutionarray, $langs, $object) { global $conf, $db; // Zähle Sections, Textzeilen und Subtotals in diesem Dokument if (is_object($object) && isset($object->lines) && is_array($object->lines)) { $count_sections = 0; $count_textlines = 0; $count_subtotals = 0; foreach ($object->lines as $line) { $special_code = isset($line->special_code) ? (int)$line->special_code : 0; if ($special_code == 100) $count_sections++; if ($special_code == 101) $count_textlines++; if ($special_code == 102) $count_subtotals++; } $substitutionarray['object_count_sections'] = $count_sections; $substitutionarray['object_count_textlines'] = $count_textlines; $substitutionarray['object_count_subtotals'] = $count_subtotals; $substitutionarray['object_has_sections'] = ($count_sections > 0) ? '1' : ''; $substitutionarray['object_has_textlines'] = ($count_textlines > 0) ? '1' : ''; $substitutionarray['object_has_speciallines'] = ($count_sections > 0 || $count_textlines > 0 || $count_subtotals) ? '1' : ''; } }