* GPL v3+
*
* Admin-Setup für das Bericht-Modul.
* Verwaltung von ODT-Templates + globalen Konstanten.
*/
$res = 0;
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if (!$res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once __DIR__.'/../lib/bericht.lib.php';
if (!$user->admin && !$user->hasRight('bericht', 'admin')) accessforbidden();
$langs->loadLangs(array("admin", "bericht@bericht"));
$action = GETPOST('action', 'alpha');
$templates_dir = DOL_DATA_ROOT.'/bericht/templates';
if (!is_dir($templates_dir)) {
dol_mkdir($templates_dir);
}
// --- Aktionen ---
if ($action === 'upload_template' && !empty($_FILES['template_file']['name'])) {
$name = dol_sanitizeFileName($_FILES['template_file']['name']);
if (!preg_match('/\.odt$/i', $name)) {
setEventMessages('Nur .odt-Dateien erlaubt', null, 'errors');
} else {
$dest = $templates_dir.'/'.$name;
if (move_uploaded_file($_FILES['template_file']['tmp_name'], $dest)) {
setEventMessages($langs->trans("BerichtSetupTemplateUploaded"), null, 'mesgs');
} else {
setEventMessages('Upload fehlgeschlagen', null, 'errors');
}
}
header("Location: ".$_SERVER['PHP_SELF']);
exit;
}
if ($action === 'delete_template') {
$name = dol_sanitizeFileName(GETPOST('name', 'alphanohtml'));
$path = $templates_dir.'/'.$name;
if ($name && file_exists($path)) {
@unlink($path);
setEventMessages($langs->trans("BerichtSetupTemplateDeleted"), null, 'mesgs');
}
header("Location: ".$_SERVER['PHP_SELF']);
exit;
}
if ($action === 'save_const') {
$consts = array(
'BERICHT_DEFAULT_TEMPLATE' => GETPOST('default_template', 'alphanohtml'),
'BERICHT_TAB_ON_INVOICE' => GETPOST('tab_invoice', 'int') ? '1' : '0',
'BERICHT_TAB_ON_ORDER' => GETPOST('tab_order', 'int') ? '1' : '0',
'BERICHT_TAB_ON_PROPAL' => GETPOST('tab_propal', 'int') ? '1' : '0',
'BERICHT_BURN_ANNOTATIONS' => GETPOST('burn', 'int') ? '1' : '0',
'BERICHT_LIBREOFFICE_BIN' => GETPOST('lobin', 'alphanohtml'),
'BERICHT_WHISPER_URL' => GETPOST('whisper_url', 'alphanohtml'),
'BERICHT_WHISPER_MODE' => GETPOST('whisper_mode', 'alphanohtml'),
'BERICHT_WHISPER_API_KEY' => GETPOST('whisper_key', 'alphanohtml'),
'BERICHT_WHISPER_LANG' => GETPOST('whisper_lang', 'alphanohtml'),
);
foreach ($consts as $k => $v) {
dolibarr_set_const($db, $k, $v, 'chaine', 0, '', $conf->entity);
}
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']);
exit;
}
// --- Anzeige ---
llxHeader('', $langs->trans("BerichtSetup"));
$linkback = ''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans("BerichtSetup"), $linkback, 'title_setup');
print ''.$langs->trans("BerichtSetupDescription").'
';
// --- PWA-Link prominent oben ---
$pwa_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].'/custom/baustelle/';
print '
Mobile Progressive Web App für die Baustelle. Installierbar auf Handy oder Tablet, funktioniert offline.
'; print 'Funktionen: Auftragsliste, Foto-Aufnahme direkt aus der Kamera, automatische Synchronisierung bei Verbindung, Multi-User-Filter pro angemeldetem User
'; print ''.dol_escape_htmltag($pwa_url).'';
print 'Endpoint: '.dol_escape_htmltag($api_url).'
POST '.dol_escape_htmltag($api_url).'/auth.php | Login → JWT |
GET '.dol_escape_htmltag($api_url).'/orders.php | Aufträge des Users |
GET '.dol_escape_htmltag($api_url).'/orders.php?id=X | Auftrags-Detail |
POST '.dol_escape_htmltag($api_url).'/orders.php?id=X&action=upload_photo | Foto hochladen |
GET '.dol_escape_htmltag($api_url).'/reports.php?id=X | Bericht-Detail |
JWT-Token sind 7 Tage gültig. Multi-User über fk_user_author/valid/modif gefiltert.
'; print ''.$langs->trans("BerichtSetupTemplatesDesc").'
'; $templates = bericht_list_templates(); if (empty($templates)) { print '| '.$langs->trans("File").' | '.$langs->trans("Size").' | '.$langs->trans("Action").' |
|---|---|---|
| 📄 '.dol_escape_htmltag($tpl).' | '; print ''.dol_print_size(filesize($path)).' | '; print ''; print ''.$langs->trans("Delete").''; print ' | '; print '
'.$k.' | '.$desc.' |