WLAN-Kanal-Momentaufnahme darstellen (HTML + PDF)
Die App legt eine WLAN-Momentaufnahme jetzt als Messung ab (tool='wifikanal'), damit sie beim Kunden aufgenommen auch im Protokoll auf dem Server ankommt — bisher lag sie nur lokal auf dem Handy. - netdiagFormatWifiKanal(): Zusammenfassung (Anzahl Netze, eigenes Netz mit Kanal/Pegel/Bewertung, störungsärmster 2,4-GHz-Kanal), Hinweisliste und vollständige Netztabelle. Eigener Zweig wie beim Dauertest, weil die generische Darstellung das Netz-Array per dol_trunc(...,200) mitten im Satz abschneiden würde. - netdiagPdfWifiKanal(): dieselbe Aufbereitung als PDF-Tabelle. - Nebenbei: PDF zeigte bei Status 0 doppelt "OK OK" (Zeichen + Label). Gegen das Test-Dolibarr geprüft: Kartenansicht rendert Zusammenfassung, beide Warnhinweise und alle 12 Netze; PDF-Erzeugung ebenfalls verifiziert.
This commit is contained in:
parent
75986ee1c8
commit
9b69438d17
2 changed files with 164 additions and 3 deletions
|
|
@ -121,6 +121,9 @@ function netdiagFormatResult($json, $tool = '')
|
||||||
if ($tool === 'stresstest') {
|
if ($tool === 'stresstest') {
|
||||||
return netdiagFormatStressTest($data);
|
return netdiagFormatStressTest($data);
|
||||||
}
|
}
|
||||||
|
if ($tool === 'wifikanal') {
|
||||||
|
return netdiagFormatWifiKanal($data);
|
||||||
|
}
|
||||||
|
|
||||||
$out = '<div class="netdiag-result">';
|
$out = '<div class="netdiag-result">';
|
||||||
foreach ($data as $key => $val) {
|
foreach ($data as $key => $val) {
|
||||||
|
|
@ -201,3 +204,80 @@ function netdiagFormatStressTest($data)
|
||||||
$out .= '</div>';
|
$out .= '</div>';
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WLAN-Kanal-Momentaufnahme strukturiert als HTML aufbereiten.
|
||||||
|
*
|
||||||
|
* Wie beim Dauertest ein eigener Zweig statt der generischen Darstellung:
|
||||||
|
* `netze` ist eine Liste von Objekten und würde dort als JSON-Text mit
|
||||||
|
* dol_trunc(…,200) mitten im Satz abgeschnitten.
|
||||||
|
*
|
||||||
|
* @param array<string,mixed> $data bereits dekodiertes result-JSON
|
||||||
|
* @return string HTML-Schnipsel
|
||||||
|
*/
|
||||||
|
function netdiagFormatWifiKanal($data)
|
||||||
|
{
|
||||||
|
$out = '<div class="netdiag-result">';
|
||||||
|
|
||||||
|
$sum = array();
|
||||||
|
if (isset($data['anzahlNetze'])) {
|
||||||
|
$sum[] = $data['anzahlNetze'].' Netze sichtbar';
|
||||||
|
}
|
||||||
|
if (!empty($data['eigenesNetz']) && is_array($data['eigenesNetz'])) {
|
||||||
|
$e = $data['eigenesNetz'];
|
||||||
|
$teil = 'Eigenes Netz: '.($e['ssid'] ?? '?').' — Kanal '.($e['kanal'] ?? '?');
|
||||||
|
if (!empty($e['band'])) {
|
||||||
|
$teil .= ' ('.$e['band'].')';
|
||||||
|
}
|
||||||
|
if (isset($e['rssi'])) {
|
||||||
|
$teil .= ', '.$e['rssi'].' dBm';
|
||||||
|
}
|
||||||
|
if (!empty($e['bewertung'])) {
|
||||||
|
$teil .= ' — '.$e['bewertung'];
|
||||||
|
}
|
||||||
|
$sum[] = $teil;
|
||||||
|
}
|
||||||
|
if (!empty($data['empfehlung24GHz']) && is_array($data['empfehlung24GHz'])) {
|
||||||
|
$best = reset($data['empfehlung24GHz']);
|
||||||
|
if (is_array($best) && isset($best['kanal'])) {
|
||||||
|
$sum[] = 'Störungsärmster 2,4-GHz-Kanal: '.$best['kanal'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($sum)) {
|
||||||
|
$out .= '<div class="netdiag-kv">'.dol_escape_htmltag(implode(' | ', $sum)).'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['warnungen']) && is_array($data['warnungen'])) {
|
||||||
|
$out .= '<div><strong>Hinweise:</strong></div><ul class="netdiag-outages">';
|
||||||
|
foreach ($data['warnungen'] as $w) {
|
||||||
|
$out .= '<li>'.dol_escape_htmltag((string) $w).'</li>';
|
||||||
|
}
|
||||||
|
$out .= '</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$netze = (isset($data['netze']) && is_array($data['netze'])) ? $data['netze'] : array();
|
||||||
|
if (!empty($netze)) {
|
||||||
|
$out .= '<table class="noborder centpercent"><tr class="liste_titre">';
|
||||||
|
$out .= '<th>SSID</th><th class="center">Kanal</th><th>Band</th>';
|
||||||
|
$out .= '<th class="center">Breite</th><th>Standard</th><th>Sicherheit</th><th class="right">Pegel</th>';
|
||||||
|
$out .= '</tr>';
|
||||||
|
foreach ($netze as $n) {
|
||||||
|
if (!is_array($n)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$out .= '<tr class="oddeven">';
|
||||||
|
$out .= '<td>'.dol_escape_htmltag((string) ($n['ssid'] ?? '')).'</td>';
|
||||||
|
$out .= '<td class="center">'.dol_escape_htmltag((string) ($n['kanal'] ?? '')).'</td>';
|
||||||
|
$out .= '<td>'.dol_escape_htmltag((string) ($n['band'] ?? '')).'</td>';
|
||||||
|
$out .= '<td class="center">'.(isset($n['breiteMhz']) && $n['breiteMhz'] !== null ? dol_escape_htmltag($n['breiteMhz'].' MHz') : '-').'</td>';
|
||||||
|
$out .= '<td>'.dol_escape_htmltag((string) ($n['standard'] ?? '-')).'</td>';
|
||||||
|
$out .= '<td>'.dol_escape_htmltag((string) ($n['sicherheit'] ?? '-')).'</td>';
|
||||||
|
$out .= '<td class="right">'.dol_escape_htmltag((string) ($n['rssi'] ?? '')).' dBm</td>';
|
||||||
|
$out .= '</tr>';
|
||||||
|
}
|
||||||
|
$out .= '</table>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= '</div>';
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,8 +141,10 @@ function netdiagGeneratePdf($db, $protocol, $outputlangs)
|
||||||
2 => $outputlangs->transnoentities("NetDiagMeasureFail"),
|
2 => $outputlangs->transnoentities("NetDiagMeasureFail"),
|
||||||
3 => $outputlangs->transnoentities("NetDiagMeasureUnmeasurable"),
|
3 => $outputlangs->transnoentities("NetDiagMeasureUnmeasurable"),
|
||||||
);
|
);
|
||||||
// Zusätzlich ein Zeichen, damit die Ampel auch im Schwarz-Weiß-Ausdruck lesbar bleibt
|
// Zusätzlich ein Zeichen, damit die Ampel auch im Schwarz-Weiß-Ausdruck lesbar
|
||||||
$statusmarks = array(0 => 'OK', 1 => '!', 2 => 'X', 3 => '?');
|
// bleibt. Bei Status 0 bewusst leer: das Label heißt dort bereits "OK", sonst
|
||||||
|
// stünde im PDF doppelt "OK OK".
|
||||||
|
$statusmarks = array(0 => '', 1 => '! ', 2 => 'X ', 3 => '? ');
|
||||||
foreach ($measurements as $m) {
|
foreach ($measurements as $m) {
|
||||||
$st = (int) $m->measure_status;
|
$st = (int) $m->measure_status;
|
||||||
if ($st < 0 || $st > 3) {
|
if ($st < 0 || $st > 3) {
|
||||||
|
|
@ -160,10 +162,12 @@ function netdiagGeneratePdf($db, $protocol, $outputlangs)
|
||||||
$pdf->SetFont('', 'B', 9);
|
$pdf->SetFont('', 'B', 9);
|
||||||
$title = ($m->category ? '['.$m->category.'] ' : '').$m->tool.($m->label ? ' — '.$m->label : '');
|
$title = ($m->category ? '['.$m->category.'] ' : '').$m->tool.($m->label ? ' — '.$m->label : '');
|
||||||
$pdf->Cell(150, 6, dol_trunc($title, 80), 1, 0, 'L');
|
$pdf->Cell(150, 6, dol_trunc($title, 80), 1, 0, 'L');
|
||||||
$pdf->Cell(30, 6, $statusmarks[$st].' '.$statuslabels[$st], 1, 1, 'C', true);
|
$pdf->Cell(30, 6, $statusmarks[$st].$statuslabels[$st], 1, 1, 'C', true);
|
||||||
$pdf->SetFont('', '', 8);
|
$pdf->SetFont('', '', 8);
|
||||||
if ($m->tool === 'stresstest') {
|
if ($m->tool === 'stresstest') {
|
||||||
netdiagPdfStressTest($pdf, $m->result);
|
netdiagPdfStressTest($pdf, $m->result);
|
||||||
|
} elseif ($m->tool === 'wifikanal') {
|
||||||
|
netdiagPdfWifiKanal($pdf, $m->result);
|
||||||
} else {
|
} else {
|
||||||
$pdf->MultiCell(180, 5, netdiagPdfFlattenResult($m->result), 1, 'L');
|
$pdf->MultiCell(180, 5, netdiagPdfFlattenResult($m->result), 1, 'L');
|
||||||
}
|
}
|
||||||
|
|
@ -290,3 +294,80 @@ function netdiagPdfStressTest($pdf, $json)
|
||||||
$pdf->Cell(180, 5, dol_trunc((string) $line, 120), 1, 1, 'L');
|
$pdf->Cell(180, 5, dol_trunc((string) $line, 120), 1, 1, 'L');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WLAN-Kanal-Momentaufnahme im PDF als Tabelle ausgeben.
|
||||||
|
*
|
||||||
|
* Wie netdiagPdfStressTest ein eigener Zweig, weil die generische
|
||||||
|
* Flach-Darstellung die Netzliste (Array von Objekten) unlesbar macht.
|
||||||
|
*
|
||||||
|
* @param TCPDF $pdf PDF-Objekt
|
||||||
|
* @param string $json JSON-String des Ergebnisses
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function netdiagPdfWifiKanal($pdf, $json)
|
||||||
|
{
|
||||||
|
$data = json_decode($json, true);
|
||||||
|
if (!is_array($data)) {
|
||||||
|
$pdf->MultiCell(180, 5, netdiagPdfFlattenResult($json), 1, 'L');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kopfzeile: Anzahl, eigenes Netz, Empfehlung
|
||||||
|
$sum = array();
|
||||||
|
if (isset($data['anzahlNetze'])) {
|
||||||
|
$sum[] = $data['anzahlNetze'].' Netze sichtbar';
|
||||||
|
}
|
||||||
|
if (!empty($data['eigenesNetz']) && is_array($data['eigenesNetz'])) {
|
||||||
|
$e = $data['eigenesNetz'];
|
||||||
|
$teil = 'Eigenes Netz: '.($e['ssid'] ?? '?').' Kanal '.($e['kanal'] ?? '?');
|
||||||
|
if (isset($e['rssi'])) {
|
||||||
|
$teil .= ', '.$e['rssi'].' dBm';
|
||||||
|
}
|
||||||
|
if (!empty($e['bewertung'])) {
|
||||||
|
$teil .= ' ('.$e['bewertung'].')';
|
||||||
|
}
|
||||||
|
$sum[] = $teil;
|
||||||
|
}
|
||||||
|
if (!empty($data['empfehlung24GHz']) && is_array($data['empfehlung24GHz'])) {
|
||||||
|
$best = reset($data['empfehlung24GHz']);
|
||||||
|
if (is_array($best) && isset($best['kanal'])) {
|
||||||
|
$sum[] = 'Störungsärmster 2,4-GHz-Kanal: '.$best['kanal'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($sum)) {
|
||||||
|
$pdf->MultiCell(180, 5, implode(' | ', $sum), 1, 'L');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($data['warnungen']) && is_array($data['warnungen'])) {
|
||||||
|
foreach ($data['warnungen'] as $w) {
|
||||||
|
$pdf->MultiCell(180, 5, '! '.dol_trunc((string) $w, 160), 1, 'L');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$netze = (isset($data['netze']) && is_array($data['netze'])) ? $data['netze'] : array();
|
||||||
|
if (empty($netze)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tabellenkopf
|
||||||
|
$pdf->SetFont('', 'B', 7);
|
||||||
|
$pdf->Cell(60, 5, 'SSID', 1, 0, 'L');
|
||||||
|
$pdf->Cell(18, 5, 'Kanal', 1, 0, 'C');
|
||||||
|
$pdf->Cell(22, 5, 'Band', 1, 0, 'L');
|
||||||
|
$pdf->Cell(20, 5, 'Breite', 1, 0, 'C');
|
||||||
|
$pdf->Cell(35, 5, 'Standard', 1, 0, 'L');
|
||||||
|
$pdf->Cell(25, 5, 'Pegel', 1, 1, 'R');
|
||||||
|
$pdf->SetFont('', '', 7);
|
||||||
|
foreach ($netze as $n) {
|
||||||
|
if (!is_array($n)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$pdf->Cell(60, 5, dol_trunc((string) ($n['ssid'] ?? ''), 34), 1, 0, 'L');
|
||||||
|
$pdf->Cell(18, 5, (string) ($n['kanal'] ?? ''), 1, 0, 'C');
|
||||||
|
$pdf->Cell(22, 5, (string) ($n['band'] ?? ''), 1, 0, 'L');
|
||||||
|
$pdf->Cell(20, 5, (isset($n['breiteMhz']) && $n['breiteMhz'] !== null) ? $n['breiteMhz'].' MHz' : '-', 1, 0, 'C');
|
||||||
|
$pdf->Cell(35, 5, dol_trunc((string) ($n['standard'] ?? '-'), 20), 1, 0, 'L');
|
||||||
|
$pdf->Cell(25, 5, (string) ($n['rssi'] ?? '').' dBm', 1, 1, 'R');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue