*
* 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 '| '.$langs->trans("Label").' | '.dol_escape_htmltag($object->label).' |
';
$soc = new Societe($db);
print '| '.$langs->trans("ThirdParty").' | ';
if ($object->fk_soc > 0 && $soc->fetch($object->fk_soc) > 0) {
print $soc->getNomUrl(1);
}
print ' |
';
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 ' |
';
print '| '.$langs->trans("DateDiag").' | '.dol_print_date($object->date_diag, 'dayhour').' |
';
print '| '.$langs->trans("Location").' | '.dol_escape_htmltag($object->standort).' |
';
print '| '.$langs->trans("Subnet").' | '.dol_escape_htmltag($object->subnet).' |
';
print '| '.$langs->trans("Status").' | '.$object->getLibStatut(4).' |
';
print '| '.$langs->trans("Note").' | '.dol_nl2br(dol_escape_htmltag($object->note)).' |
';
print '
';
print '
';
print dol_get_fiche_end();
// Aktionsknöpfe
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 '
| '.$langs->trans("Documents").' |
';
foreach ($files as $f) {
$durl = DOL_URL_ROOT.'/document.php?modulepart=netdiag&file='.urlencode(dol_sanitizeFileName($object->ref).'/'.$f['name']);
print '| '.img_mime($f['name']).' '.dol_escape_htmltag($f['name']).' |
';
}
print '
';
}
}
// 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 '| '.$langs->trans("IpAddress").' | '.$langs->trans("MacAddress").' | ';
print ''.$langs->trans("Hostname").' | '.$langs->trans("Vendor").' | '.$langs->trans("DeviceType").' | ';
print '
';
foreach ($devices as $dev) {
print '';
print '| '.dol_escape_htmltag($dev->ip).' | ';
print ''.dol_escape_htmltag($dev->mac).' | ';
print ''.dol_escape_htmltag($dev->hostname).' | ';
print ''.dol_escape_htmltag($dev->vendor).' | ';
print ''.dol_escape_htmltag($dev->devicetype).' | ';
print '
';
}
if (empty($devices)) {
print '| - |
';
}
print '
';
// 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 '| '.$langs->trans("DateMeasure").' | '.$langs->trans("ToolCategory").' | ';
print ''.$langs->trans("Tool").' | '.$langs->trans("Label").' | ';
print ''.$langs->trans("Result").' | '.$langs->trans("MeasureStatus").' | ';
print '
';
foreach ($measurements as $m) {
$st = (int) $m->measure_status;
print '';
print '| '.dol_print_date($m->date_measure, 'dayhour').' | ';
print ''.dol_escape_htmltag($m->category).' | ';
print ''.dol_escape_htmltag($m->tool).' | ';
print ''.dol_escape_htmltag($m->label).' | ';
print ''.netdiagFormatResult($m->result).' | ';
print ''.$langs->trans($statuslabels[$st]).' | ';
print '
';
}
if (empty($measurements)) {
print '| - |
';
}
print '
';
llxFooter();
$db->close();