155 lines
4.6 KiB
PHP
Executable file
155 lines
4.6 KiB
PHP
Executable file
<?php
|
|
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
|
* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
*
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* \file buchaltungswidget/admin/setup.php
|
|
* \ingroup buchaltungswidget
|
|
* \brief BuchaltungsWidget setup page.
|
|
*/
|
|
|
|
// Load Dolibarr environment
|
|
$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");
|
|
}
|
|
|
|
// Libraries
|
|
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
|
|
require_once '../lib/buchaltungswidget.lib.php';
|
|
|
|
// Translations
|
|
$langs->loadLangs(array("admin", "buchaltungswidget@buchaltungswidget"));
|
|
|
|
// Parameters
|
|
$action = GETPOST('action', 'aZ09');
|
|
$backtopage = GETPOST('backtopage', 'alpha');
|
|
|
|
// Access control
|
|
if (!$user->admin) {
|
|
accessforbidden();
|
|
}
|
|
|
|
/*
|
|
* Actions
|
|
*/
|
|
|
|
if ($action == 'update') {
|
|
$error = 0;
|
|
|
|
// Save settings
|
|
$res = dolibarr_set_const($db, 'BUCHALTUNGSWIDGET_SHOW_PAYMENT_STATS', GETPOST('BUCHALTUNGSWIDGET_SHOW_PAYMENT_STATS', 'int'), 'chaine', 0, '', $conf->entity);
|
|
if (!($res > 0)) {
|
|
$error++;
|
|
}
|
|
|
|
$res = dolibarr_set_const($db, 'BUCHALTUNGSWIDGET_SHOW_MENU', GETPOST('BUCHALTUNGSWIDGET_SHOW_MENU', 'int'), 'chaine', 0, '', $conf->entity);
|
|
if (!($res > 0)) {
|
|
$error++;
|
|
}
|
|
|
|
if (!$error) {
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
} else {
|
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
}
|
|
}
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
|
|
$form = new Form($db);
|
|
|
|
$title = "BuchaltungsWidgetSetup";
|
|
|
|
llxHeader('', $langs->trans($title), '', '', 0, 0, '', '', '', 'mod-buchaltungswidget page-admin');
|
|
|
|
// Subheader
|
|
$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
|
|
|
|
print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
|
|
|
|
// Configuration header
|
|
$head = buchaltungswidgetAdminPrepareHead();
|
|
print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "fa-chart-line");
|
|
|
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
print '<table class="noborder centpercent">';
|
|
|
|
// Table header
|
|
print '<tr class="liste_titre">';
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
print '<td>'.$langs->trans("Value").'</td>';
|
|
print '</tr>';
|
|
|
|
// Show payment statistics on customer card
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("ShowPaymentStatsOnCustomerCard").'</td>';
|
|
print '<td>';
|
|
print $form->selectyesno('BUCHALTUNGSWIDGET_SHOW_PAYMENT_STATS', getDolGlobalInt('BUCHALTUNGSWIDGET_SHOW_PAYMENT_STATS', 1), 1);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
|
|
print '<br>';
|
|
print '<div class="center">';
|
|
print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
// Info box
|
|
print '<br>';
|
|
print '<div class="info">';
|
|
print '<strong>'.$langs->trans("Note").':</strong> ';
|
|
print $langs->trans("SettingsNote");
|
|
print '</div>';
|
|
|
|
// Page end
|
|
print dol_get_fiche_end();
|
|
|
|
llxFooter();
|
|
$db->close();
|