kundenkarte/admin/setup.php
2026-01-31 08:18:54 +01:00

160 lines
4.5 KiB
PHP
Executable file

<?php
/* 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 kundenkarte/admin/setup.php
* \ingroup kundenkarte
* \brief KundenKarte setup page.
*/
// Load Dolibarr environment
$res = 0;
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/kundenkarte.lib.php';
// Translations
$langs->loadLangs(array("admin", "kundenkarte@kundenkarte"));
// Access control
if (!$user->admin && !$user->hasRight('kundenkarte', 'admin')) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
/*
* Actions
*/
if ($action == 'update') {
$error = 0;
// Save settings
$res = dolibarr_set_const($db, 'KUNDENKARTE_SHOW_FAVORITES_TAB', GETPOSTINT('KUNDENKARTE_SHOW_FAVORITES_TAB'), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'KUNDENKARTE_SHOW_ANLAGEN_TAB', GETPOSTINT('KUNDENKARTE_SHOW_ANLAGEN_TAB'), 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
$res = dolibarr_set_const($db, 'KUNDENKARTE_DEFAULT_ORDER_TYPE', GETPOSTINT('KUNDENKARTE_DEFAULT_ORDER_TYPE'), '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 = $langs->trans("KundenKarteSetup");
llxHeader('', $title);
// Subheader
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($title, $linkback, 'title_setup');
// Configuration header
$head = kundenkarteAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', $langs->trans('ModuleKundenKarteName'), -1, "fa-address-card");
print '<span class="opacitymedium">'.$langs->trans("KundenKarteSetupPage").'</span><br><br>';
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">';
// Header
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
// Show Favorites Tab
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ShowFavoritesTab").'</td>';
print '<td>';
print $form->selectyesno('KUNDENKARTE_SHOW_FAVORITES_TAB', getDolGlobalInt('KUNDENKARTE_SHOW_FAVORITES_TAB', 1), 1);
print '</td>';
print '</tr>';
// Show Anlagen Tab
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ShowAnlagenTab").'</td>';
print '<td>';
print $form->selectyesno('KUNDENKARTE_SHOW_ANLAGEN_TAB', getDolGlobalInt('KUNDENKARTE_SHOW_ANLAGEN_TAB', 1), 1);
print '</td>';
print '</tr>';
// Default Order Type for Favorites
print '<tr class="oddeven">';
print '<td>'.$langs->trans("DefaultOrderType").'</td>';
print '<td>';
$orderTypes = array(
0 => $langs->trans("OrderTypeOrder"),
1 => $langs->trans("OrderTypeProposal"),
);
print $form->selectarray('KUNDENKARTE_DEFAULT_ORDER_TYPE', $orderTypes, getDolGlobalInt('KUNDENKARTE_DEFAULT_ORDER_TYPE', 0));
print '</td>';
print '</tr>';
print '</table>';
print '<br>';
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
// Info section
print '<br>';
print '<div class="info">';
print '<strong>'.$langs->trans("ConfigurationHelp").':</strong><br>';
print '&bull; '.$langs->trans("ConfigHelpSystems").'<br>';
print '&bull; '.$langs->trans("ConfigHelpTypes").'<br>';
print '</div>';
print dol_get_fiche_end();
llxFooter();
$db->close();