* * 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 . */ /** * \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 = ''.$langs->trans("BackToList").''; dol_banner_tab($parent, 'ref', $linkback, 1, 'ref', 'ref'); } else { $linkback = ''.$langs->trans("BackToList").''; 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 '

'; print load_fiche_titre($langs->trans("NetDiagProtocols"), '', 'fa-network-wired'); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $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 ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } } if (!$nb) { print ''; } print '
'.$langs->trans("Ref").''.$langs->trans("DateDiag").''.$langs->trans("Location").''.$langs->trans("Subnet").''.$langs->trans("NetDiagDevices").''.$langs->trans("NetDiagMeasurements").''.$langs->trans("Status").'
'.img_picto('', 'fa-network-wired').' '.dol_escape_htmltag($obj->ref).''.dol_print_date($db->jdate($obj->date_diag), 'dayhour').''.dol_escape_htmltag($obj->standort).''.dol_escape_htmltag($obj->subnet).''.((int) $obj->devcount).''.((int) $obj->meascount).''.$proto->getLibStatut(3).'
'.$langs->trans("NetDiagNoProtocol").'
'; print '
'; print '
'; llxFooter(); $db->close();