Some checks are pending
Deploy netdiag / deploy (push) Waiting to run
Netzwerk-Diagnose-Modul mit JSON-API für die NetDiag-App: - 3 Tabellen (protocol/device/measurement), generisches JSON-result - JSON-API: auth, customers, orders, protocols (idempotenter Sync), pdf - JWT-Auth (HS256), CORS für die Capacitor-App - Tabs an Thirdparty + Auftrag, Protokoll-Card, PDF-Generator - QR-Code zum App-Download in der Modul-Konfiguration - de_DE + en_US, Rechtesystem netdiag->protocol read/write/delete Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
170 lines
5.9 KiB
PHP
170 lines
5.9 KiB
PHP
<?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 netdiag/netdiag_object_tab.php
|
|
* \ingroup netdiag
|
|
* \brief Tab "Netzwerk-Diagnose" an Kunde (thirdparty) und Auftrag (order)
|
|
*/
|
|
|
|
// Dolibarr-Umgebung 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.'/societe/class/societe.class.php';
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
|
require_once __DIR__.'/class/netdiagprotocol.class.php';
|
|
|
|
/**
|
|
* @var DoliDB $db
|
|
* @var Translate $langs
|
|
* @var User $user
|
|
*/
|
|
|
|
$langs->loadLangs(array("netdiag@netdiag", "companies", "orders"));
|
|
|
|
if (!$user->hasRight('netdiag', 'protocol', 'read')) {
|
|
accessforbidden();
|
|
}
|
|
|
|
$objecttype = GETPOST('objecttype', 'aZ09');
|
|
$id = GETPOSTINT('id');
|
|
$socid = GETPOSTINT('socid');
|
|
|
|
// Parent-Objekt laden und passenden Filter aufbauen
|
|
$parent = null;
|
|
$head = array();
|
|
$picto = 'company';
|
|
$filtersql = '';
|
|
|
|
if ($objecttype == 'order') {
|
|
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
|
|
$parent = new Commande($db);
|
|
if ($id <= 0 || $parent->fetch($id) <= 0) {
|
|
accessforbidden('Order not found');
|
|
}
|
|
$parent->fetch_thirdparty();
|
|
$head = commande_prepare_head($parent);
|
|
$picto = 'order';
|
|
$filtersql = " AND p.fk_commande = ".((int) $parent->id);
|
|
} else {
|
|
$parent = new Societe($db);
|
|
if ($socid <= 0 || $parent->fetch($socid) <= 0) {
|
|
accessforbidden('ThirdParty not found');
|
|
}
|
|
$head = societe_prepare_head($parent);
|
|
$picto = 'company';
|
|
$filtersql = " AND p.fk_soc = ".((int) $parent->id);
|
|
}
|
|
|
|
/*
|
|
* Ansicht
|
|
*/
|
|
|
|
llxHeader('', $langs->trans("NetDiagTab"), '', '', 0, 0, '', '', '', 'mod-netdiag');
|
|
|
|
print dol_get_fiche_head($head, 'netdiag', $langs->trans($objecttype == 'order' ? 'CustomerOrder' : 'ThirdParty'), -1, $picto);
|
|
|
|
if ($objecttype == 'order') {
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/commande/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
|
dol_banner_tab($parent, 'ref', $linkback, 1, 'ref', 'ref');
|
|
} else {
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
|
dol_banner_tab($parent, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
|
|
}
|
|
|
|
print dol_get_fiche_end();
|
|
|
|
// Protokolle des Objekts auflisten
|
|
$sql = "SELECT p.rowid, p.ref, p.label, p.date_diag, p.standort, p.subnet, p.status,";
|
|
$sql .= " (SELECT COUNT(*) FROM ".$db->prefix()."netdiag_device d WHERE d.fk_protocol = p.rowid) as devcount,";
|
|
$sql .= " (SELECT COUNT(*) FROM ".$db->prefix()."netdiag_measurement m WHERE m.fk_protocol = p.rowid) as meascount";
|
|
$sql .= " FROM ".$db->prefix()."netdiag_protocol as p";
|
|
$sql .= " WHERE p.entity IN (".getEntity('netdiagprotocol').")";
|
|
$sql .= $filtersql;
|
|
$sql .= " ORDER BY p.date_diag DESC, p.rowid DESC";
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
print '<div class="fichecenter"><br>';
|
|
print load_fiche_titre($langs->trans("NetDiagProtocols"), '', 'fa-network-wired');
|
|
|
|
print '<div class="div-table-responsive-no-min">';
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre">';
|
|
print '<th>'.$langs->trans("Ref").'</th>';
|
|
print '<th>'.$langs->trans("DateDiag").'</th>';
|
|
print '<th>'.$langs->trans("Location").'</th>';
|
|
print '<th>'.$langs->trans("Subnet").'</th>';
|
|
print '<th class="right">'.$langs->trans("NetDiagDevices").'</th>';
|
|
print '<th class="right">'.$langs->trans("NetDiagMeasurements").'</th>';
|
|
print '<th class="center">'.$langs->trans("Status").'</th>';
|
|
print '</tr>';
|
|
|
|
$proto = new NetDiagProtocol($db);
|
|
$nb = 0;
|
|
if ($resql) {
|
|
while ($obj = $db->fetch_object($resql)) {
|
|
$nb++;
|
|
$proto->status = $obj->status;
|
|
$cardurl = dol_buildpath('/netdiag/netdiagprotocol_card.php', 1).'?id='.$obj->rowid;
|
|
print '<tr class="oddeven">';
|
|
print '<td><a href="'.$cardurl.'">'.img_picto('', 'fa-network-wired').' '.dol_escape_htmltag($obj->ref).'</a></td>';
|
|
print '<td>'.dol_print_date($db->jdate($obj->date_diag), 'dayhour').'</td>';
|
|
print '<td>'.dol_escape_htmltag($obj->standort).'</td>';
|
|
print '<td>'.dol_escape_htmltag($obj->subnet).'</td>';
|
|
print '<td class="right">'.((int) $obj->devcount).'</td>';
|
|
print '<td class="right">'.((int) $obj->meascount).'</td>';
|
|
print '<td class="center">'.$proto->getLibStatut(3).'</td>';
|
|
print '</tr>';
|
|
}
|
|
}
|
|
if (!$nb) {
|
|
print '<tr><td colspan="7" class="opacitymedium center">'.$langs->trans("NetDiagNoProtocol").'</td></tr>';
|
|
}
|
|
print '</table>';
|
|
print '</div>';
|
|
print '</div>';
|
|
|
|
llxFooter();
|
|
$db->close();
|