* * 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/log_detail.php * \ingroup idsconnect * \brief Detailansicht eines Log-Eintrags */ // 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"); } dol_include_once('/idsconnect/class/idslog.class.php'); dol_include_once('/idsconnect/class/idssupplier.class.php'); dol_include_once('/idsconnect/lib/idsconnect.lib.php'); /** * @var DoliDB $db * @var Translate $langs * @var User $user */ $langs->loadLangs(array("idsconnect@idsconnect")); if (!$user->hasRight('idsconnect', 'read')) { accessforbidden(); } $id = GETPOSTINT('id'); if (empty($id)) { setEventMessages('Keine Log-ID angegeben', null, 'errors'); header('Location: '.DOL_URL_ROOT.'/custom/idsconnect/log_list.php'); exit; } // Log laden $log = new IdsLog($db); $result = $log->fetch($id); if ($result <= 0) { setEventMessages('Log-Eintrag #'.$id.' nicht gefunden', null, 'errors'); header('Location: '.DOL_URL_ROOT.'/custom/idsconnect/log_list.php'); exit; } // Großhändler laden $supplier = new IdsSupplier($db); $supplier->fetch($log->fk_supplier); // Benutzer laden $userObj = new User($db); $userObj->fetch($log->fk_user); /* * View */ llxHeader('', $langs->trans("IdsconnectLogDetail").' #'.$id, '', '', 0, 0, '', '', '', 'mod-idsconnect page-log_detail'); print load_fiche_titre($langs->trans("IdsconnectLogDetail").' #'.$id, ''.$langs->trans("IdsconnectLogList").'', 'fa-search'); // ============================================================ // Basis-Informationen // ============================================================ print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($log->fk_commande > 0) { print ''; print ''; } if (!empty($log->error_message)) { print ''; print ''; } print '
'.$langs->trans("ID").''.$log->id.'
'.$langs->trans("IdsconnectLogDate").''.dol_print_date($log->date_creation, 'dayhour').'
'.$langs->trans("IdsconnectLogSupplier").''; if ($supplier->id > 0) { print ''.htmlspecialchars($supplier->label).''; print ' ('.htmlspecialchars($supplier->ref).')'; } else { print 'Großhändler #'.$log->fk_supplier.' (gelöscht?)'; } print '
'.$langs->trans("IdsconnectLogUser").''.($userObj->id > 0 ? $userObj->getNomUrl(1) : 'User #'.$log->fk_user).'
'.$langs->trans("IdsconnectLogAction").''.$log->getActionLabel().' ('.$log->action_type.')
'.$langs->trans("IdsconnectLogDirection").''.$log->direction.'
'.$langs->trans("IdsconnectLogStatus").''.$log->getStatusLabel().'
IP-Adresse'.htmlspecialchars($log->ip_address ?: '-').'
Lieferantenbestellung#'.$log->fk_commande.'
Fehlermeldung'.htmlspecialchars($log->error_message).'
'; // ============================================================ // Request-Daten (was wurde gesendet) // ============================================================ if (!empty($log->request_data)) { print '
'; print load_fiche_titre('Request-Daten (gesendet)', '', 'fa-arrow-up'); $request = json_decode($log->request_data, true); if (is_array($request)) { print ''; foreach ($request as $key => $value) { print ''; print ''; print ''; } print '
'.$key.''; if (is_array($value)) { print '
'.htmlspecialchars(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)).'
'; } elseif ($key === 'hookurl' || $key === 'target_url' || $key === 'shop_url') { print ''.htmlspecialchars($value).''; } elseif ($key === 'testmode') { print $value ? 'Testmodus' : 'LIVE'; } else { print htmlspecialchars($value); } print '
'; } else { print '
'.htmlspecialchars($log->request_data).'
'; } } // ============================================================ // Response-Daten (was kam zurück) // ============================================================ if (!empty($log->response_data)) { print '
'; print load_fiche_titre('Response-Daten (empfangen)', '', 'fa-arrow-down'); $response = json_decode($log->response_data, true); if (is_array($response)) { // Callback-Meta-Informationen separat anzeigen if (!empty($response['callback_meta'])) { print ''; print ''; foreach ($response['callback_meta'] as $key => $value) { print ''; print ''; print ''; } print '
Callback-Informationen
'.$key.''; if (is_array($value)) { print htmlspecialchars(implode(', ', $value)); } else { print htmlspecialchars($value); } print '
'; print '
'; } // Empfangene Artikel anzeigen if (!empty($response['items']) && is_array($response['items'])) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $total = 0; foreach ($response['items'] as $item) { $line_total = (float) ($item['gesamtpreis'] ?? ((float) ($item['menge'] ?? 0) * (float) ($item['einzelpreis'] ?? 0))); $total += $line_total; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } print ''; print ''; print ''; print ''; print '
'.$langs->trans("IdsconnectCartArticleNr").''.$langs->trans("IdsconnectCartDescription").''.$langs->trans("IdsconnectCartQty").''.$langs->trans("IdsconnectCartUnit").''.$langs->trans("IdsconnectCartUnitPrice").''.$langs->trans("IdsconnectCartTotalPrice").''.$langs->trans("IdsconnectCartManufacturer").'
'.htmlspecialchars($item['artikelnr'] ?? '-').''.htmlspecialchars($item['bezeichnung'] ?? '-').''.((float) ($item['menge'] ?? 0)).''.htmlspecialchars($item['einheit'] ?? 'STK').''.price($item['einzelpreis'] ?? 0).''.price($line_total).''.htmlspecialchars($item['hersteller'] ?? '-').'
'.$langs->trans("Total").''.price($total).'
'; } // Restliche Response-Felder $skip_keys = array('callback_meta', 'items'); $remaining = array_diff_key($response, array_flip($skip_keys)); if (!empty($remaining)) { print '
'; print ''; foreach ($remaining as $key => $value) { print ''; print ''; print ''; } print '
Weitere Response-Daten
'.$key.''; if (is_array($value)) { print '
'.htmlspecialchars(json_encode($value, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)).'
'; } else { print htmlspecialchars($value); } print '
'; } } else { print '
'.htmlspecialchars($log->response_data).'
'; } } // ============================================================ // Warenkorb-XML (Rohdaten) // ============================================================ if (!empty($log->cart_xml)) { print '
'; print load_fiche_titre('Warenkorb-XML ('.strlen($log->cart_xml).' Bytes)', '', 'fa-code'); // XML formatiert ausgeben $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $formatted_xml = $log->cart_xml; if (@$dom->loadXML($log->cart_xml)) { $formatted_xml = $dom->saveXML(); } print '
'; print htmlspecialchars($formatted_xml); print '
'; } // ============================================================ // Callback-Token (für Debugging) // ============================================================ if (!empty($log->callback_token)) { print '
'; print load_fiche_titre('Callback-Token', '', 'fa-key'); print ''; print ''; print ''; print ''; print ''; print '
Token'.htmlspecialchars($log->callback_token).'
Token-Status'; if ($log->status === 'pending') { $token_age = dol_now() - $log->date_creation; if ($token_age < 7200) { $remaining = 7200 - $token_age; print 'Gültig (noch '.round($remaining / 60).' Min.)'; } else { print 'Abgelaufen'; } } else { print 'Eingelöst ('.$log->status.')'; } print '
'; } // Aktionsbuttons print '
'; // Warenkorb prüfen / Bestellung erstellen - wenn WKE mit Artikeln und noch keine Bestellung verknüpft if ($log->action_type === 'WKE' && $log->status === 'success' && $log->fk_commande <= 0) { $response_check = json_decode($log->response_data, true); if (!empty($response_check['items']) || !empty($log->cart_xml)) { print ''.$langs->trans("IdsconnectCartCreateOrder").''; } } // Link zur verknüpften Bestellung wenn vorhanden if ($log->fk_commande > 0) { print 'Bestellung #'.$log->fk_commande.' anzeigen'; } print ''.$langs->trans("Back").''; print '
'; llxFooter(); $db->close();