- Kategorie-Baum mit Farben, Auf-/Zuklappen und Inline-Bearbeitung - AJAX-Handler für Produkt- und Kategorieaktionen (Best EK, Status-Toggle) - Admin: Ref-Schema und Standard-Aufklapp-Einstellung - CSS/JS erweitert für Baumansicht und modale Dialoge - bin/ zu .gitignore hinzugefügt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
171 lines
6.1 KiB
PHP
Executable file
171 lines
6.1 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 produktverwaltung/admin/setup.php
|
|
* \ingroup produktverwaltung
|
|
* \brief ProduktVerwaltung setup page - Ref-Schema Konfiguration
|
|
*/
|
|
|
|
// 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");
|
|
}
|
|
|
|
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
|
|
require_once '../lib/produktverwaltung.lib.php';
|
|
|
|
$langs->loadLangs(array("admin", "produktverwaltung@produktverwaltung"));
|
|
|
|
if (!$user->admin) {
|
|
accessforbidden();
|
|
}
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
|
|
// Default Ref-Schema
|
|
$defaultSchema = 'KAT-HER-[TYP-]SPEC[-SERIE]
|
|
|
|
<b>KAT</b> = Produktkategorie (2-4 Zeichen), z.B. LSS, FI, STK, NYM
|
|
<b>HER</b> = Hersteller (2-4 Zeichen), z.B. HAG, EAT, WAG, BJ
|
|
<b>TYP</b> = Variante (optional), z.B. FLX, STD, AP, UP
|
|
<b>SPEC</b> = Spezifikation/Groesse, z.B. B16, 3F, 5x1_5, 60x110
|
|
<b>SERIE</b> = Produktserie (optional), z.B. 221, 2273, 914';
|
|
|
|
$defaultExample = 'LSS-HAG-B16-1P = Hager Leitungsschutzschalter B16A 1-polig
|
|
STK-WAG-FLX-3F-221 = Wago Flex 3-fach (Serie 221)
|
|
NYM-5x1_5 = NYM-J Mantelleitung 5x1,5mm²
|
|
RAH-BJ-1F-914 = Busch-Jaeger Rahmen 1-fach Balance SI';
|
|
|
|
|
|
/*
|
|
* Actions
|
|
*/
|
|
if ($action == 'update' && $user->admin) {
|
|
$showSchema = GETPOST('PRODUKTVERWALTUNG_SHOW_SCHEMA', 'alpha');
|
|
$refSchema = GETPOST('PRODUKTVERWALTUNG_REF_SCHEMA', 'restricthtml');
|
|
$refExample = GETPOST('PRODUKTVERWALTUNG_REF_EXAMPLE', 'restricthtml');
|
|
$defaultExpanded = GETPOST('PRODUKTVERWALTUNG_DEFAULT_EXPANDED', 'alpha');
|
|
|
|
dolibarr_set_const($db, 'PRODUKTVERWALTUNG_SHOW_SCHEMA', $showSchema, 'chaine', 0, '', $conf->entity);
|
|
dolibarr_set_const($db, 'PRODUKTVERWALTUNG_REF_SCHEMA', $refSchema, 'chaine', 0, '', $conf->entity);
|
|
dolibarr_set_const($db, 'PRODUKTVERWALTUNG_REF_EXAMPLE', $refExample, 'chaine', 0, '', $conf->entity);
|
|
dolibarr_set_const($db, 'PRODUKTVERWALTUNG_DEFAULT_EXPANDED', $defaultExpanded, 'chaine', 0, '', $conf->entity);
|
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
}
|
|
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
$form = new Form($db);
|
|
|
|
llxHeader('', $langs->trans("ProduktVerwaltungSetup"), '', '', 0, 0, '', '', '', 'mod-produktverwaltung page-admin');
|
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
|
print load_fiche_titre($langs->trans("ProduktVerwaltungSetup"), $linkback, 'title_setup');
|
|
|
|
$head = produktverwaltungAdminPrepareHead();
|
|
print dol_get_fiche_head($head, 'settings', $langs->trans("ProduktVerwaltungSetup"), -1, "fa-sitemap");
|
|
|
|
// Current values
|
|
$showSchema = getDolGlobalString('PRODUKTVERWALTUNG_SHOW_SCHEMA', '1');
|
|
$defaultExpanded = getDolGlobalString('PRODUKTVERWALTUNG_DEFAULT_EXPANDED', '0');
|
|
$refSchema = getDolGlobalString('PRODUKTVERWALTUNG_REF_SCHEMA', $defaultSchema);
|
|
$refExample = getDolGlobalString('PRODUKTVERWALTUNG_REF_EXAMPLE', $defaultExample);
|
|
|
|
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">';
|
|
|
|
// Section title
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2">'.$langs->trans("RefSchemaTitle").'</td>';
|
|
print '</tr>';
|
|
|
|
// Show schema on main page
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("RefSchemaShow").'</td>';
|
|
print '<td>';
|
|
print $form->selectyesno('PRODUKTVERWALTUNG_SHOW_SCHEMA', $showSchema, 1);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
// Default expanded
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("DefaultExpanded").'</td>';
|
|
print '<td>';
|
|
print $form->selectyesno('PRODUKTVERWALTUNG_DEFAULT_EXPANDED', $defaultExpanded, 1);
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
// Schema pattern
|
|
print '<tr class="oddeven">';
|
|
print '<td class="titlefield">'.$langs->trans("RefSchemaPattern").'</td>';
|
|
print '<td>';
|
|
print '<textarea name="PRODUKTVERWALTUNG_REF_SCHEMA" class="flat minwidth500" rows="8">'.dol_htmlentitiesbr_decode(dol_escape_htmltag($refSchema, 0, 0, '', 1)).'</textarea>';
|
|
print '<br><span class="opacitymedium">'.$langs->trans("RefSchemaHelp").'</span>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
// Examples
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("RefSchemaExample").'</td>';
|
|
print '<td>';
|
|
print '<textarea name="PRODUKTVERWALTUNG_REF_EXAMPLE" class="flat minwidth500" rows="5">'.dol_htmlentitiesbr_decode(dol_escape_htmltag($refExample, 0, 0, '', 1)).'</textarea>';
|
|
print '</td>';
|
|
print '</tr>';
|
|
|
|
print '</table>';
|
|
|
|
print '<div class="center">';
|
|
print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
llxFooter();
|
|
$db->close();
|