* * 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/netdiagprotocol_card.php * \ingroup netdiag * \brief Detailansicht eines Diagnose-Protokolls (Backend) */ // 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.'/commande/class/commande.class.php'; require_once __DIR__.'/class/netdiagprotocol.class.php'; require_once __DIR__.'/class/netdiagdevice.class.php'; require_once __DIR__.'/class/netdiagmeasurement.class.php'; require_once __DIR__.'/lib/netdiag.lib.php'; require_once __DIR__.'/lib/netdiag_pdf.lib.php'; /** * @var Conf $conf * @var DoliDB $db * @var Translate $langs * @var User $user */ $langs->loadLangs(array("netdiag@netdiag", "companies", "orders", "other")); if (!$user->hasRight('netdiag', 'protocol', 'read')) { accessforbidden(); } $id = GETPOSTINT('id'); $action = GETPOST('action', 'aZ09'); $object = new NetDiagProtocol($db); if ($id <= 0 || $object->fetch($id) <= 0) { accessforbidden('Protocol not found'); } // Aktion: PDF generieren if ($action == 'builddoc' && $user->hasRight('netdiag', 'protocol', 'read')) { $result = netdiagGeneratePdf($db, $object, $langs); if ($result > 0) { setEventMessages($langs->trans("FileGenerated"), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); } header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } // Aktion: löschen if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->hasRight('netdiag', 'protocol', 'delete')) { if ($object->delete($user) > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: ".dol_buildpath('/netdiag/netdiagindex.php', 1)); exit; } setEventMessages($object->error, $object->errors, 'errors'); } /* * Ansicht */ $form = new Form($db); llxHeader('', $object->ref, '', '', 0, 0, '', '', '', 'mod-netdiag page-card'); $head = netdiagProtocolPrepareHead($object); print dol_get_fiche_head($head, 'card', $langs->trans("NetDiagProtocol"), -1, 'fa-network-wired'); // Lösch-Bestätigung if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteObject"), "confirm_delete", '', '', 1); } $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref'); print '
'; print '
'; print ''; print ''; $soc = new Societe($db); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Label").''.dol_escape_htmltag($object->label).'
'.$langs->trans("ThirdParty").''; if ($object->fk_soc > 0 && $soc->fetch($object->fk_soc) > 0) { print $soc->getNomUrl(1); } print '
'.$langs->trans("Order").''; if ($object->fk_commande > 0) { $cmd = new Commande($db); if ($cmd->fetch($object->fk_commande) > 0) { print $cmd->getNomUrl(1); } } print '
'.$langs->trans("DateDiag").''.dol_print_date($object->date_diag, 'dayhour').'
'.$langs->trans("Location").''.dol_escape_htmltag($object->standort).'
'.$langs->trans("Subnet").''.dol_escape_htmltag($object->subnet).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Note").''.dol_nl2br(dol_escape_htmltag($object->note)).'
'; print '
'; print dol_get_fiche_end(); // Aktionsknöpfe print '
'; print ''.$langs->trans("BuildDoc").''; if ($user->hasRight('netdiag', 'protocol', 'delete')) { print ''.$langs->trans("Delete").''; } print '
'; // Vorhandene PDF-Dokumente $upload_dir = netdiagGetOutputDir().'/'.dol_sanitizeFileName($object->ref); if (is_dir($upload_dir)) { $files = dol_dir_list($upload_dir, 'files', 0, '\.pdf$'); if (!empty($files)) { print '
'; foreach ($files as $f) { $durl = DOL_URL_ROOT.'/document.php?modulepart=netdiag&file='.urlencode(dol_sanitizeFileName($object->ref).'/'.$f['name']); print ''; } print '
'.$langs->trans("Documents").'
'.img_mime($f['name']).' '.dol_escape_htmltag($f['name']).'
'; } } // Geräteliste $devObj = new NetDiagDevice($db); $devices = $devObj->fetchAllByProtocol($object->id); print '
'; print load_fiche_titre($langs->trans("NetDiagDevices").' ('.count($devices).')', '', 'fa-desktop'); print '
'; print ''; print ''; print ''; print ''; foreach ($devices as $dev) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; } if (empty($devices)) { print ''; } print '
'.$langs->trans("IpAddress").''.$langs->trans("MacAddress").''.$langs->trans("Hostname").''.$langs->trans("Vendor").''.$langs->trans("DeviceType").'
'.dol_escape_htmltag($dev->ip).''.dol_escape_htmltag($dev->mac).''.dol_escape_htmltag($dev->hostname).''.dol_escape_htmltag($dev->vendor).''.dol_escape_htmltag($dev->devicetype).'
-
'; // Messungen $measObj = new NetDiagMeasurement($db); $measurements = $measObj->fetchAllByProtocol($object->id); $statuslabels = array(0 => 'NetDiagMeasureOk', 1 => 'NetDiagMeasureWarn', 2 => 'NetDiagMeasureFail'); $statuscss = array(0 => 'badge-status4', 1 => 'badge-status1', 2 => 'badge-status8'); print '
'; print load_fiche_titre($langs->trans("NetDiagMeasurements").' ('.count($measurements).')', '', 'fa-wave-square'); print '
'; print ''; print ''; print ''; print ''; print ''; foreach ($measurements as $m) { $st = (int) $m->measure_status; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } if (empty($measurements)) { print ''; } print '
'.$langs->trans("DateMeasure").''.$langs->trans("ToolCategory").''.$langs->trans("Tool").''.$langs->trans("Label").''.$langs->trans("Result").''.$langs->trans("MeasureStatus").'
'.dol_print_date($m->date_measure, 'dayhour').''.dol_escape_htmltag($m->category).''.dol_escape_htmltag($m->tool).''.dol_escape_htmltag($m->label).''.netdiagFormatResult($m->result).''.$langs->trans($statuslabels[$st]).'
-
'; llxFooter(); $db->close();