- Menü unter Einkauf > Lieferantenbestellungen statt eigenes Top-Menü - ADL-Buttons auf Produkt-Lieferantenpreisen per Hook (pricesuppliercard) - Admin-Seite: Großhändler-Schnellübersicht mit Version-Check - Dashboard: Shop-öffnen-Button (LI-Action) - Neue Datei: class/actions_idsconnect.class.php Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
380 lines
14 KiB
PHP
Executable file
380 lines
14 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/supplier_card.php
|
|
* \ingroup idsconnect
|
|
* \brief Großhändler anlegen/bearbeiten
|
|
*/
|
|
|
|
// 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 DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
|
dol_include_once('/idsconnect/class/idssupplier.class.php');
|
|
dol_include_once('/idsconnect/class/idsconnect.class.php');
|
|
dol_include_once('/idsconnect/lib/idsconnect.lib.php');
|
|
|
|
/**
|
|
* @var Conf $conf
|
|
* @var DoliDB $db
|
|
* @var Translate $langs
|
|
* @var User $user
|
|
*/
|
|
|
|
$langs->loadLangs(array("idsconnect@idsconnect", "admin"));
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
$confirm = GETPOST('confirm', 'alpha');
|
|
$id = GETPOSTINT('id');
|
|
|
|
$object = new IdsSupplier($db);
|
|
if ($id > 0) {
|
|
$object->fetch($id);
|
|
}
|
|
|
|
// Berechtigungsprüfung
|
|
if ($action == 'create' || $action == 'add') {
|
|
if (!$user->hasRight('idsconnect', 'config')) {
|
|
accessforbidden();
|
|
}
|
|
} elseif ($action == 'edit' || $action == 'update') {
|
|
if (!$user->hasRight('idsconnect', 'config')) {
|
|
accessforbidden();
|
|
}
|
|
} elseif ($action == 'confirm_delete') {
|
|
if (!$user->hasRight('idsconnect', 'delete')) {
|
|
accessforbidden();
|
|
}
|
|
} else {
|
|
if (!$user->hasRight('idsconnect', 'read')) {
|
|
accessforbidden();
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* Actions
|
|
*/
|
|
|
|
// Anlegen
|
|
if ($action == 'add' && $user->hasRight('idsconnect', 'config')) {
|
|
if (!verifCond(GETPOST('token', 'alpha') == newToken())) {
|
|
accessforbidden('Bad CSRF token');
|
|
}
|
|
|
|
$object->ref = GETPOST('ref', 'alphanohtml');
|
|
$object->label = GETPOST('label', 'alphanohtml');
|
|
$object->fk_soc = GETPOSTINT('fk_soc');
|
|
$object->ids_url = GETPOST('ids_url', 'alphanohtml');
|
|
$object->ids_version = GETPOST('ids_version', 'alphanohtml');
|
|
$object->ids_customer_no = GETPOST('ids_customer_no', 'alphanohtml');
|
|
$object->ids_username = GETPOST('ids_username', 'alphanohtml');
|
|
$object->ids_password = GETPOST('ids_password', 'none');
|
|
$object->testmode = GETPOSTINT('testmode');
|
|
$object->active = GETPOSTINT('active');
|
|
$object->note_public = GETPOST('note_public', 'restricthtml');
|
|
$object->note_private = GETPOST('note_private', 'restricthtml');
|
|
|
|
// Validierung
|
|
$error = 0;
|
|
if (empty($object->ref)) {
|
|
setEventMessages('Referenz ist Pflichtfeld', null, 'errors');
|
|
$error++;
|
|
}
|
|
if (empty($object->label)) {
|
|
setEventMessages('Bezeichnung ist Pflichtfeld', null, 'errors');
|
|
$error++;
|
|
}
|
|
if (empty($object->ids_url)) {
|
|
setEventMessages('Shop-URL ist Pflichtfeld', null, 'errors');
|
|
$error++;
|
|
}
|
|
if (empty($object->ids_customer_no)) {
|
|
setEventMessages('Kundennummer ist Pflichtfeld', null, 'errors');
|
|
$error++;
|
|
}
|
|
|
|
if (!$error) {
|
|
$result = $object->create($user);
|
|
if ($result > 0) {
|
|
setEventMessages($langs->trans("IdsconnectSupplierCreated"), null, 'mesgs');
|
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$result);
|
|
exit;
|
|
} else {
|
|
setEventMessages($object->error, null, 'errors');
|
|
$action = 'create';
|
|
}
|
|
} else {
|
|
$action = 'create';
|
|
}
|
|
}
|
|
|
|
// Aktualisieren
|
|
if ($action == 'update' && $user->hasRight('idsconnect', 'config')) {
|
|
if (!verifCond(GETPOST('token', 'alpha') == newToken())) {
|
|
accessforbidden('Bad CSRF token');
|
|
}
|
|
|
|
$object->ref = GETPOST('ref', 'alphanohtml');
|
|
$object->label = GETPOST('label', 'alphanohtml');
|
|
$object->fk_soc = GETPOSTINT('fk_soc');
|
|
$object->ids_url = GETPOST('ids_url', 'alphanohtml');
|
|
$object->ids_version = GETPOST('ids_version', 'alphanohtml');
|
|
$object->ids_customer_no = GETPOST('ids_customer_no', 'alphanohtml');
|
|
$object->ids_username = GETPOST('ids_username', 'alphanohtml');
|
|
|
|
// Passwort nur aktualisieren wenn ein neues eingegeben wurde
|
|
$new_password = GETPOST('ids_password', 'none');
|
|
if (!empty($new_password)) {
|
|
$object->ids_password = $new_password;
|
|
}
|
|
|
|
$object->testmode = GETPOSTINT('testmode');
|
|
$object->active = GETPOSTINT('active');
|
|
$object->note_public = GETPOST('note_public', 'restricthtml');
|
|
$object->note_private = GETPOST('note_private', 'restricthtml');
|
|
|
|
$result = $object->update($user);
|
|
if ($result > 0) {
|
|
setEventMessages($langs->trans("IdsconnectSupplierUpdated"), null, 'mesgs');
|
|
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
|
|
exit;
|
|
} else {
|
|
setEventMessages($object->error, null, 'errors');
|
|
$action = 'edit';
|
|
}
|
|
}
|
|
|
|
// Löschen
|
|
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('idsconnect', 'delete')) {
|
|
if (!verifCond(GETPOST('token', 'alpha') == newToken())) {
|
|
accessforbidden('Bad CSRF token');
|
|
}
|
|
|
|
$result = $object->delete($user);
|
|
if ($result > 0) {
|
|
setEventMessages($langs->trans("IdsconnectSupplierDeleted"), null, 'mesgs');
|
|
header('Location: '.DOL_URL_ROOT.'/custom/idsconnect/idsconnectindex.php');
|
|
exit;
|
|
} else {
|
|
setEventMessages($object->error, null, 'errors');
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
|
|
$form = new Form($db);
|
|
|
|
$title = ($action == 'create') ? $langs->trans("IdsconnectSupplierNew") : $langs->trans("IdsconnectSupplierCard");
|
|
llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-idsconnect page-supplier_card');
|
|
|
|
// ============================================================
|
|
// Formular: Anlegen oder Bearbeiten
|
|
// ============================================================
|
|
if ($action == 'create' || $action == 'edit') {
|
|
$isEdit = ($action == 'edit');
|
|
|
|
print load_fiche_titre($title, '', 'fa-plug');
|
|
|
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
print '<input type="hidden" name="action" value="'.($isEdit ? 'update' : 'add').'">';
|
|
if ($isEdit) {
|
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
|
}
|
|
|
|
print dol_get_fiche_head(array(), '', '', 0);
|
|
|
|
print '<table class="border centpercent tableforfieldcreate">';
|
|
|
|
// Referenz
|
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("IdsconnectSupplierRef").'</td>';
|
|
print '<td><input type="text" name="ref" value="'.htmlspecialchars($object->ref ?: GETPOST('ref')).'" class="minwidth200" maxlength="128" required></td></tr>';
|
|
|
|
// Bezeichnung
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("IdsconnectSupplierLabel").'</td>';
|
|
print '<td><input type="text" name="label" value="'.htmlspecialchars($object->label ?: GETPOST('label')).'" class="minwidth300" maxlength="255" required></td></tr>';
|
|
|
|
// Dolibarr-Lieferant
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierSoc").'</td>';
|
|
print '<td>'.$form->select_company($object->fk_soc ?: GETPOSTINT('fk_soc'), 'fk_soc', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300').'</td></tr>';
|
|
|
|
// Shop-URL
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("IdsconnectSupplierUrl").'</td>';
|
|
print '<td><input type="url" name="ids_url" value="'.htmlspecialchars($object->ids_url ?: GETPOST('ids_url')).'" class="minwidth400" placeholder="https://webshop.example.de/ids" required></td></tr>';
|
|
|
|
// IDS-Version
|
|
$versions = array('2.5' => 'IDS 2.5 (empfohlen)', '2.3' => 'IDS 2.3', '2.0' => 'IDS 2.0', '1.3' => 'IDS 1.3 (veraltet)');
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierVersion").'</td>';
|
|
print '<td>'.$form->selectarray('ids_version', $versions, $object->ids_version ?: '2.5').'</td></tr>';
|
|
|
|
// Kundennummer
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("IdsconnectSupplierCustomerNo").'</td>';
|
|
print '<td><input type="text" name="ids_customer_no" value="'.htmlspecialchars($object->ids_customer_no ?: GETPOST('ids_customer_no')).'" class="minwidth200" required></td></tr>';
|
|
|
|
// Benutzerkennung
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierUsername").'</td>';
|
|
print '<td><input type="text" name="ids_username" value="'.htmlspecialchars($object->ids_username ?: GETPOST('ids_username')).'" class="minwidth200" autocomplete="off"></td></tr>';
|
|
|
|
// Passwort
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierPassword").'</td>';
|
|
print '<td><input type="password" name="ids_password" value="" class="minwidth200" autocomplete="new-password"';
|
|
if ($isEdit) {
|
|
print ' placeholder="(unverändert lassen wenn leer)"';
|
|
}
|
|
print '></td></tr>';
|
|
|
|
// Testmodus
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierTestmode").'</td>';
|
|
print '<td>'.$form->selectyesno('testmode', isset($object->testmode) ? $object->testmode : 1, 1).'</td></tr>';
|
|
|
|
// Aktiv
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierActive").'</td>';
|
|
print '<td>'.$form->selectyesno('active', isset($object->active) ? $object->active : 1, 1).'</td></tr>';
|
|
|
|
// Notizen
|
|
print '<tr><td>'.$langs->trans("NotePublic").'</td>';
|
|
print '<td><textarea name="note_public" class="minwidth400" rows="3">'.htmlspecialchars($object->note_public ?: '').'</textarea></td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("NotePrivate").'</td>';
|
|
print '<td><textarea name="note_private" class="minwidth400" rows="3">'.htmlspecialchars($object->note_private ?: '').'</textarea></td></tr>';
|
|
|
|
print '</table>';
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
print '<div class="center">';
|
|
print '<input type="submit" class="button" value="'.$langs->trans($isEdit ? "Save" : "Create").'">';
|
|
print ' <a class="button button-cancel" href="'.($isEdit ? $_SERVER['PHP_SELF'].'?id='.$object->id : DOL_URL_ROOT.'/custom/idsconnect/idsconnectindex.php').'">'.$langs->trans("Cancel").'</a>';
|
|
print '</div>';
|
|
|
|
print '</form>';
|
|
}
|
|
|
|
// ============================================================
|
|
// Anzeige: Großhändler-Details
|
|
// ============================================================
|
|
elseif ($id > 0 && $object->id > 0) {
|
|
|
|
// Lösch-Bestätigung
|
|
if ($action == 'delete') {
|
|
$formconfirm = $form->formconfirm(
|
|
$_SERVER["PHP_SELF"].'?id='.$object->id,
|
|
$langs->trans('Delete'),
|
|
$langs->trans('IdsconnectSupplierConfirmDelete'),
|
|
'confirm_delete',
|
|
'',
|
|
0,
|
|
1
|
|
);
|
|
print $formconfirm;
|
|
}
|
|
|
|
$head = idsconnectSupplierPrepareHead($object);
|
|
print dol_get_fiche_head($head, 'supplier', $langs->trans("IdsconnectSupplierCard"), -1, 'fa-plug');
|
|
|
|
// Testmodus-Banner
|
|
idsconnectShowTestModeBanner();
|
|
|
|
print '<table class="border centpercent tableforfield">';
|
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("IdsconnectSupplierRef").'</td>';
|
|
print '<td>'.htmlspecialchars($object->ref).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierLabel").'</td>';
|
|
print '<td>'.htmlspecialchars($object->label).'</td></tr>';
|
|
|
|
if ($object->fk_soc > 0) {
|
|
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
|
$soc = new Societe($db);
|
|
$soc->fetch($object->fk_soc);
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierSoc").'</td>';
|
|
print '<td>'.$soc->getNomUrl(1).'</td></tr>';
|
|
}
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierUrl").'</td>';
|
|
print '<td><a href="'.htmlspecialchars($object->ids_url).'" target="_blank">'.htmlspecialchars($object->ids_url).'</a></td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierVersion").'</td>';
|
|
print '<td>IDS '.htmlspecialchars($object->ids_version).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierCustomerNo").'</td>';
|
|
print '<td>'.htmlspecialchars($object->ids_customer_no).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierUsername").'</td>';
|
|
print '<td>'.htmlspecialchars($object->ids_username).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierPassword").'</td>';
|
|
print '<td>'.$object->getMaskedPassword().'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierTestmode").'</td>';
|
|
print '<td>'.yn($object->testmode).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("IdsconnectSupplierActive").'</td>';
|
|
print '<td>'.yn($object->active).'</td></tr>';
|
|
|
|
print '<tr><td>'.$langs->trans("DateCreation").'</td>';
|
|
print '<td>'.dol_print_date($object->date_creation, 'dayhour').'</td></tr>';
|
|
|
|
print '</table>';
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
// Aktionsbuttons
|
|
print '<div class="tabsAction">';
|
|
|
|
if ($object->active && $user->hasRight('idsconnect', 'use')) {
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/custom/idsconnect/launch.php?supplier_id='.$object->id.'&ids_action=WKE&token='.newToken().'" target="_blank">'.$langs->trans("IdsconnectReceiveCart").'</a>';
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/custom/idsconnect/launch.php?supplier_id='.$object->id.'&ids_action=SV&token='.newToken().'" target="_blank">'.$langs->trans("IdsconnectActionSV").'</a>';
|
|
}
|
|
|
|
if ($user->hasRight('idsconnect', 'config')) {
|
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>';
|
|
}
|
|
|
|
if ($user->hasRight('idsconnect', 'delete')) {
|
|
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>';
|
|
}
|
|
|
|
print '</div>';
|
|
}
|
|
|
|
llxFooter();
|
|
$db->close();
|