- WKE-Flow (Warenkorb empfangen): Sonepar-Integration komplett funktionsfähig inkl. PriceBasis-Handling, Namespace-Stripping, OCI-Unterstützung - WKS-Flow (Warenkorb senden): Lieferantenbestellung → Shop mit vorausgefüllten Artikeln, IDS Connect 2.0 XML-Format - Callback v2.0: NOLOGIN-Seite statt Redirect, 7 Datenquellen, Debug-Daten - URL-Handling: user_base_url-Tracking für Cross-Domain-Szenarien - Sicherheit: CSRF, HMAC-SHA256 Tokens, XXE-Schutz, PIN für WKS - Mock-Server für lokale Tests - Dokumentation mit Roadmap (fehlende Features, Möglichkeiten) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
235 lines
8.3 KiB
PHP
Executable file
235 lines
8.3 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.
|
|
*/
|
|
|
|
/**
|
|
* \file idsconnect/admin/setup.php
|
|
* \ingroup idsconnect
|
|
* \brief IDS Connect Konfigurationsseite
|
|
*/
|
|
|
|
// Dolibarr laden
|
|
$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/idsconnect.lib.php';
|
|
|
|
/**
|
|
* @var Conf $conf
|
|
* @var DoliDB $db
|
|
* @var HookManager $hookmanager
|
|
* @var Translate $langs
|
|
* @var User $user
|
|
*/
|
|
|
|
$langs->loadLangs(array("admin", "idsconnect@idsconnect"));
|
|
|
|
// Zugriffskontrolle
|
|
if (!$user->admin) {
|
|
accessforbidden();
|
|
}
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
$backtopage = GETPOST('backtopage', 'alpha');
|
|
|
|
$error = 0;
|
|
|
|
|
|
/*
|
|
* Actions
|
|
*/
|
|
|
|
if ($action == 'update' && $user->admin) {
|
|
// CSRF-Schutz
|
|
if (!verifCond(GETPOST('token', 'alpha') == newToken())) {
|
|
accessforbidden('Bad CSRF token');
|
|
}
|
|
|
|
// Öffentliche URL
|
|
dolibarr_set_const($db, 'IDSCONNECT_PUBLIC_URL', trim(GETPOST('IDSCONNECT_PUBLIC_URL', 'alphanohtml')), 'chaine', 0, '', $conf->entity);
|
|
// Testmodus
|
|
dolibarr_set_const($db, 'IDSCONNECT_TESTMODE', GETPOSTINT('IDSCONNECT_TESTMODE'), 'chaine', 0, '', $conf->entity);
|
|
// Logging
|
|
dolibarr_set_const($db, 'IDSCONNECT_LOG_ENABLED', GETPOSTINT('IDSCONNECT_LOG_ENABLED'), 'chaine', 0, '', $conf->entity);
|
|
// WKS-Warnschwellen
|
|
dolibarr_set_const($db, 'IDSCONNECT_WKS_WARN_QTY', GETPOSTINT('IDSCONNECT_WKS_WARN_QTY'), 'chaine', 0, '', $conf->entity);
|
|
dolibarr_set_const($db, 'IDSCONNECT_WKS_WARN_VALUE', GETPOST('IDSCONNECT_WKS_WARN_VALUE', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
|
|
// WKS-PIN (nur speichern wenn neue eingegeben)
|
|
$new_pin = GETPOST('IDSCONNECT_WKS_PIN', 'none');
|
|
if (!empty($new_pin)) {
|
|
$pin_hash = password_hash($new_pin, PASSWORD_DEFAULT);
|
|
dolibarr_set_const($db, 'IDSCONNECT_WKS_PIN', $pin_hash, 'chaine', 0, '', $conf->entity);
|
|
}
|
|
|
|
if (!$error) {
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
}
|
|
|
|
$action = 'edit';
|
|
}
|
|
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
|
|
$form = new Form($db);
|
|
$title = "IdsconnectSetup";
|
|
|
|
llxHeader('', $langs->trans($title), '', '', 0, 0, '', '', '', 'mod-idsconnect page-admin');
|
|
|
|
$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');
|
|
|
|
$head = idsconnectAdminPrepareHead();
|
|
print dol_get_fiche_head($head, 'settings', $langs->trans($title), -1, "fa-plug");
|
|
|
|
print '<span class="opacitymedium">'.$langs->trans("IdsconnectSetupPage").'</span><br><br>';
|
|
|
|
|
|
// Formular
|
|
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">';
|
|
|
|
// Überschrift: Allgemein
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2">'.$langs->trans("IdsconnectGeneralSettings").'</td>';
|
|
print '</tr>';
|
|
|
|
// Öffentliche URL (für HOOKURL bei Reverse-Proxy)
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectPublicUrl").'</td>';
|
|
print '<td>';
|
|
print '<input type="text" name="IDSCONNECT_PUBLIC_URL" class="minwidth500" value="'.htmlspecialchars(getDolGlobalString('IDSCONNECT_PUBLIC_URL')).'" placeholder="https://awl.data-it-solution.de">';
|
|
print '<br><span class="opacitymedium">'.$langs->trans("IdsconnectPublicUrlHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// Testmodus
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectTestMode").'</td>';
|
|
print '<td>';
|
|
print $form->selectyesno('IDSCONNECT_TESTMODE', getDolGlobalInt('IDSCONNECT_TESTMODE', 1), 1);
|
|
print ' <span class="opacitymedium">'.$langs->trans("IdsconnectTestModeHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// Logging
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectLogEnabled").'</td>';
|
|
print '<td>';
|
|
print $form->selectyesno('IDSCONNECT_LOG_ENABLED', getDolGlobalInt('IDSCONNECT_LOG_ENABLED', 1), 1);
|
|
print '</td></tr>';
|
|
|
|
// Überschrift: WKS-Sicherheit
|
|
print '<tr class="liste_titre">';
|
|
print '<td colspan="2">'.$langs->trans("IdsconnectWksSecuritySettings").'</td>';
|
|
print '</tr>';
|
|
|
|
// Mengen-Warnschwelle
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectWksWarnQty").'</td>';
|
|
print '<td>';
|
|
print '<input type="number" name="IDSCONNECT_WKS_WARN_QTY" value="'.getDolGlobalInt('IDSCONNECT_WKS_WARN_QTY', 100).'" min="0" class="width100">';
|
|
print ' <span class="opacitymedium">'.$langs->trans("IdsconnectWksWarnQtyHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// Wert-Warnschwelle
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectWksWarnValueLabel").'</td>';
|
|
print '<td>';
|
|
print '<input type="number" name="IDSCONNECT_WKS_WARN_VALUE" value="'.getDolGlobalString('IDSCONNECT_WKS_WARN_VALUE', '10000').'" min="0" step="100" class="width100">';
|
|
print ' € <span class="opacitymedium">'.$langs->trans("IdsconnectWksWarnValueHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// WKS-PIN
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectWksPinLabel").'</td>';
|
|
print '<td>';
|
|
print '<input type="password" name="IDSCONNECT_WKS_PIN" value="" class="width100" autocomplete="new-password" placeholder="'.$langs->trans("IdsconnectWksPinPlaceholder").'">';
|
|
$has_pin = !empty(getDolGlobalString('IDSCONNECT_WKS_PIN'));
|
|
if ($has_pin) {
|
|
print ' <span class="badge badge-status4">'.$langs->trans("IdsconnectWksPinSet").'</span>';
|
|
} else {
|
|
print ' <span class="badge badge-status8">'.$langs->trans("IdsconnectWksPinNotSet").'</span>';
|
|
}
|
|
print ' <span class="opacitymedium">'.$langs->trans("IdsconnectWksPinHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// Callback-URL anzeigen (nur lesen, berechnet aus öffentlicher URL)
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectCallbackUrl").'</td>';
|
|
print '<td>';
|
|
global $dolibarr_main_url_root;
|
|
$public_url = getDolGlobalString('IDSCONNECT_PUBLIC_URL');
|
|
$url_base = !empty($public_url) ? rtrim($public_url, '/') : $dolibarr_main_url_root;
|
|
$callback_url = $url_base.'/custom/idsconnect/callback.php';
|
|
print '<input type="text" class="minwidth500" value="'.htmlspecialchars($callback_url).'" readonly onclick="this.select()">';
|
|
if (empty($public_url)) {
|
|
print ' <span class="badge badge-warning">Intern - '.$langs->trans("IdsconnectPublicUrlMissing").'</span>';
|
|
}
|
|
print '<br><span class="opacitymedium">'.$langs->trans("IdsconnectCallbackUrlHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
// Mock-Server URL anzeigen (nur lesen, immer intern)
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.$langs->trans("IdsconnectMockServerUrl").'</td>';
|
|
print '<td>';
|
|
$mock_url = $dolibarr_main_url_root.'/custom/idsconnect/mockserver.php';
|
|
print '<input type="text" class="minwidth500" value="'.htmlspecialchars($mock_url).'" readonly onclick="this.select()">';
|
|
print ' <span class="opacitymedium">'.$langs->trans("IdsconnectMockServerHelp").'</span>';
|
|
print '</td></tr>';
|
|
|
|
print '</table>';
|
|
|
|
print '<div class="center">';
|
|
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
|
|
|
|
// Sicherheitsinfo
|
|
print '<br>';
|
|
print '<div class="info">';
|
|
print '<strong>'.$langs->trans("IdsconnectSecurityInfo").'</strong><br>';
|
|
print $langs->trans("IdsconnectSecurityInfoText");
|
|
print '</div>';
|
|
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
llxFooter();
|
|
$db->close();
|