';
+
+ $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 .= '
'.dol_escape_htmltag(implode(' | ', $sum)).'
';
+ }
+
+ if (!empty($data['warnungen']) && is_array($data['warnungen'])) {
+ $out .= '
Hinweise:
';
+ foreach ($data['warnungen'] as $w) {
+ $out .= '- '.dol_escape_htmltag((string) $w).'
';
+ }
+ $out .= '
';
+ }
+
+ $netze = (isset($data['netze']) && is_array($data['netze'])) ? $data['netze'] : array();
+ if (!empty($netze)) {
+ $out .= '
';
+ $out .= '| SSID | Kanal | Band | ';
+ $out .= 'Breite | Standard | Sicherheit | Pegel | ';
+ $out .= '
';
+ foreach ($netze as $n) {
+ if (!is_array($n)) {
+ continue;
+ }
+ $out .= '';
+ $out .= '| '.dol_escape_htmltag((string) ($n['ssid'] ?? '')).' | ';
+ $out .= ''.dol_escape_htmltag((string) ($n['kanal'] ?? '')).' | ';
+ $out .= ''.dol_escape_htmltag((string) ($n['band'] ?? '')).' | ';
+ $out .= ''.(isset($n['breiteMhz']) && $n['breiteMhz'] !== null ? dol_escape_htmltag($n['breiteMhz'].' MHz') : '-').' | ';
+ $out .= ''.dol_escape_htmltag((string) ($n['standard'] ?? '-')).' | ';
+ $out .= ''.dol_escape_htmltag((string) ($n['sicherheit'] ?? '-')).' | ';
+ $out .= ''.dol_escape_htmltag((string) ($n['rssi'] ?? '')).' dBm | ';
+ $out .= '
';
+ }
+ $out .= '
';
+ }
+
+ $out .= '
';
+ return $out;
+}
diff --git a/lib/netdiag_pdf.lib.php b/lib/netdiag_pdf.lib.php
index c7b2a59..53b2f09 100644
--- a/lib/netdiag_pdf.lib.php
+++ b/lib/netdiag_pdf.lib.php
@@ -141,8 +141,10 @@ function netdiagGeneratePdf($db, $protocol, $outputlangs)
2 => $outputlangs->transnoentities("NetDiagMeasureFail"),
3 => $outputlangs->transnoentities("NetDiagMeasureUnmeasurable"),
);
- // Zusätzlich ein Zeichen, damit die Ampel auch im Schwarz-Weiß-Ausdruck lesbar bleibt
- $statusmarks = array(0 => 'OK', 1 => '!', 2 => 'X', 3 => '?');
+ // Zusätzlich ein Zeichen, damit die Ampel auch im Schwarz-Weiß-Ausdruck lesbar
+ // 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) {
$st = (int) $m->measure_status;
if ($st < 0 || $st > 3) {
@@ -160,10 +162,12 @@ function netdiagGeneratePdf($db, $protocol, $outputlangs)
$pdf->SetFont('', 'B', 9);
$title = ($m->category ? '['.$m->category.'] ' : '').$m->tool.($m->label ? ' — '.$m->label : '');
$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);
if ($m->tool === 'stresstest') {
netdiagPdfStressTest($pdf, $m->result);
+ } elseif ($m->tool === 'wifikanal') {
+ netdiagPdfWifiKanal($pdf, $m->result);
} else {
$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');
}
}
+
+/**
+ * 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');
+ }
+}