- 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>
147 lines
4.7 KiB
PHP
Executable file
147 lines
4.7 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/tab_supplierorder.php
|
|
* \ingroup idsconnect
|
|
* \brief IDS Connect Tab in Lieferantenbestellungen
|
|
*/
|
|
|
|
// 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.'/fourn/class/fournisseur.commande.class.php';
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.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", "orders"));
|
|
|
|
if (!$user->hasRight('idsconnect', 'use')) {
|
|
accessforbidden();
|
|
}
|
|
|
|
$id = GETPOSTINT('id');
|
|
|
|
// Bestellung laden
|
|
$object = new CommandeFournisseur($db);
|
|
$object->fetch($id);
|
|
$object->fetch_thirdparty();
|
|
|
|
/*
|
|
* View
|
|
*/
|
|
|
|
llxHeader('', $langs->trans("IdsConnectTab"), '', '', 0, 0, '', '', '', 'mod-idsconnect page-tab_supplierorder');
|
|
|
|
// Tabs der Lieferantenbestellung
|
|
$head = ordersupplier_prepare_head($object);
|
|
print dol_get_fiche_head($head, 'idsconnect', $langs->trans("SupplierOrder"), -1, 'order');
|
|
|
|
// Bestellungs-Info
|
|
print '<table class="border centpercent tableforfield">';
|
|
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
|
|
print '<tr><td>'.$langs->trans("Supplier").'</td><td>'.$object->thirdparty->getNomUrl(1).'</td></tr>';
|
|
print '</table>';
|
|
|
|
print '<br>';
|
|
|
|
idsconnectShowTestModeBanner();
|
|
|
|
// Passende Großhändler für diesen Lieferanten finden
|
|
$supplierObj = new IdsSupplier($db);
|
|
$allSuppliers = $supplierObj->fetchAll(1);
|
|
$matchingSuppliers = array();
|
|
|
|
if (is_array($allSuppliers)) {
|
|
foreach ($allSuppliers as $sup) {
|
|
// Großhändler die mit diesem Dolibarr-Lieferanten verknüpft sind
|
|
if ($sup->fk_soc == $object->socid) {
|
|
$matchingSuppliers[] = $sup;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($matchingSuppliers)) {
|
|
print '<h3>'.$langs->trans("IdsconnectSuppliers").'</h3>';
|
|
|
|
foreach ($matchingSuppliers as $sup) {
|
|
print '<div class="idsconnect-supplier-card">';
|
|
print '<div class="supplier-name">'.htmlspecialchars($sup->label).' <span class="opacitymedium">('.htmlspecialchars($sup->ref).')</span></div>';
|
|
print '<div class="supplier-url">'.htmlspecialchars($sup->ids_url).' | IDS '.htmlspecialchars($sup->ids_version).'</div>';
|
|
|
|
if ($sup->testmode) {
|
|
print ' <span class="badge badge-warning">Testmodus</span>';
|
|
}
|
|
|
|
print '<div class="idsconnect-action-buttons" style="margin-top:10px;">';
|
|
|
|
// Shop öffnen (WKE)
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/custom/idsconnect/launch.php?supplier_id='.$sup->id.'&ids_action=WKE&token='.newToken().'" target="_blank">';
|
|
print $langs->trans("IdsconnectOpenShop");
|
|
print '</a>';
|
|
|
|
// Warenkorb aus Bestellung senden (WKS)
|
|
if (count($object->lines) > 0) {
|
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/custom/idsconnect/launch.php?supplier_id='.$sup->id.'&ids_action=WKS&fk_commande='.$object->id.'&token='.newToken().'" target="_blank">';
|
|
print $langs->trans("IdsconnectSendCart");
|
|
print '</a>';
|
|
}
|
|
|
|
print '</div></div>';
|
|
}
|
|
} else {
|
|
print '<div class="opacitymedium">';
|
|
print 'Kein IDS Connect Großhändler für diesen Lieferanten konfiguriert.<br>';
|
|
if ($user->hasRight('idsconnect', 'config')) {
|
|
print '<a href="'.DOL_URL_ROOT.'/custom/idsconnect/supplier_card.php?action=create&fk_soc='.$object->socid.'">';
|
|
print $langs->trans("IdsconnectNewSupplier");
|
|
print '</a>';
|
|
}
|
|
print '</div>';
|
|
}
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
llxFooter();
|
|
$db->close();
|