* * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file subtotaltitle/lib/subtotaltitle.lib.php * \ingroup subtotaltitle * \brief Library files with common functions for SubtotalTitle */ /** * Prepare admin pages header * * @return array */ function subtotaltitleAdminPrepareHead() { global $langs, $conf; // global $db; // $extrafields = new ExtraFields($db); // $extrafields->fetch_name_optionals_label('myobject'); $langs->load("subtotaltitle@subtotaltitle"); $h = 0; $head = array(); $head[$h][0] = dol_buildpath("/subtotaltitle/admin/setup.php", 1); $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; /* $head[$h][0] = dol_buildpath("/subtotaltitle/admin/myobject_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtraFields"); $nbExtrafields = (isset($extrafields->attributes['myobject']['label']) && is_countable($extrafields->attributes['myobject']['label'])) ? count($extrafields->attributes['myobject']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= '' . $nbExtrafields . ''; } $head[$h][2] = 'myobject_extrafields'; $h++; $head[$h][0] = dol_buildpath("/subtotaltitle/admin/myobjectline_extrafields.php", 1); $head[$h][1] = $langs->trans("ExtraFieldsLines"); $nbExtrafields = (isset($extrafields->attributes['myobjectline']['label']) && is_countable($extrafields->attributes['myobjectline']['label'])) ? count($extrafields->attributes['myobject']['label']) : 0; if ($nbExtrafields > 0) { $head[$h][1] .= '' . $nbExtrafields . ''; } $head[$h][2] = 'myobject_extrafieldsline'; $h++; */ $head[$h][0] = dol_buildpath("/subtotaltitle/admin/about.php", 1); $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( // 'entity:+tabname:Title:@subtotaltitle:/subtotaltitle/mypage.php?id=__ID__' //); // to add new tab //$this->tabs = array( // 'entity:-tabname:Title:@subtotaltitle:/subtotaltitle/mypage.php?id=__ID__' //); // to remove a tab complete_head_from_modules($conf, $langs, null, $head, $h, 'subtotaltitle@subtotaltitle'); complete_head_from_modules($conf, $langs, null, $head, $h, 'subtotaltitle@subtotaltitle', 'remove'); return $head; } /** * Debug-Log-Funktion die nur bei aktiviertem Debug-Modus schreibt * * @param string $message Die Log-Nachricht * @param bool $force Erzwingt Logging auch wenn Debug-Modus aus ist * @return void */ function subtotaltitle_debug_log($message, $force = false) { global $conf; // Debug-Modus aus Config laden $debug_mode = getDolGlobalInt('SUBTOTALTITLE_DEBUG_MODE', 0); // Nur loggen wenn Debug-Modus an ist oder force=true if ($debug_mode || $force) { error_log('[SubtotalTitle] ' . $message); } } /** * Sendet Benachrichtigung über GlobalNotify (falls verfügbar) * Fallback: Schreibt ins Dolibarr-Log * * @param string $type 'error', 'warning', 'info', 'action' * @param string $title Kurzer Titel * @param string $message Detaillierte Nachricht * @param string $actionUrl URL für Aktions-Button (optional) * @param string $actionLabel Label für Aktions-Button (optional) * @return bool True wenn über GlobalNotify gesendet */ function subtotaltitle_notify($type, $title, $message, $actionUrl = '', $actionLabel = '') { global $db; // Prüfe ob GlobalNotify aktiv und verfügbar if (!isModEnabled('globalnotify')) { dol_syslog("SubtotalTitle [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } $classFile = dol_buildpath('/globalnotify/class/globalnotify.class.php', 0); if (!file_exists($classFile)) { dol_syslog("SubtotalTitle [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } require_once $classFile; if (!class_exists('GlobalNotify')) { dol_syslog("SubtotalTitle [{$type}]: {$title} - {$message}", LOG_WARNING); return false; } try { switch ($type) { case 'error': GlobalNotify::error('subtotaltitle', $title, $message, $actionUrl, $actionLabel); break; case 'warning': GlobalNotify::warning('subtotaltitle', $title, $message, $actionUrl, $actionLabel); break; case 'action': GlobalNotify::actionRequired('subtotaltitle', $title, $message, $actionUrl, $actionLabel ?: 'Aktion erforderlich'); break; default: GlobalNotify::info('subtotaltitle', $title, $message, $actionUrl, $actionLabel); } return true; } catch (Exception $e) { dol_syslog("GlobalNotify error: ".$e->getMessage(), LOG_ERR); return false; } }