Some checks are pending
Deploy netdiag / deploy (push) Waiting to run
Netzwerk-Diagnose-Modul mit JSON-API für die NetDiag-App: - 3 Tabellen (protocol/device/measurement), generisches JSON-result - JSON-API: auth, customers, orders, protocols (idempotenter Sync), pdf - JWT-Auth (HS256), CORS für die Capacitor-App - Tabs an Thirdparty + Auftrag, Protokoll-Card, PDF-Generator - QR-Code zum App-Download in der Modul-Konfiguration - de_DE + en_US, Rechtesystem netdiag->protocol read/write/delete Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
/* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
*
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* \file netdiag/api/pdf.php
|
|
* \ingroup netdiag
|
|
* \brief API-Endpunkt: Protokoll-PDF streamen (GET ?id=&jwt=).
|
|
*/
|
|
|
|
require_once __DIR__.'/netdiag_api.lib.php';
|
|
|
|
netdiag_api_bootstrap();
|
|
|
|
/**
|
|
* @var DoliDB $db
|
|
* @var Translate $langs
|
|
*/
|
|
|
|
$user = netdiag_api_authenticate($db);
|
|
|
|
require_once __DIR__.'/../class/netdiagprotocol.class.php';
|
|
require_once __DIR__.'/../lib/netdiag.lib.php';
|
|
require_once __DIR__.'/../lib/netdiag_pdf.lib.php';
|
|
|
|
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
|
if ($id <= 0) {
|
|
netdiag_api_error('Parameter id fehlt', 400);
|
|
}
|
|
|
|
$protocol = new NetDiagProtocol($db);
|
|
if ($protocol->fetch($id) <= 0) {
|
|
netdiag_api_error('Protokoll nicht gefunden', 404);
|
|
}
|
|
|
|
$file = netdiagGetOutputDir().'/'.dol_sanitizeFileName($protocol->ref).'/'.dol_sanitizeFileName($protocol->ref).'.pdf';
|
|
|
|
// PDF erzeugen, wenn noch nicht vorhanden oder Neuerzeugung verlangt
|
|
if (!dol_is_file($file) || !empty($_GET['regenerate'])) {
|
|
if (netdiagGeneratePdf($db, $protocol, $langs) <= 0) {
|
|
netdiag_api_error('PDF-Erzeugung fehlgeschlagen', 500);
|
|
}
|
|
}
|
|
if (!dol_is_file($file)) {
|
|
netdiag_api_error('PDF nicht gefunden', 404);
|
|
}
|
|
|
|
// PDF ausliefern
|
|
header('Content-Type: application/pdf');
|
|
header('Content-Disposition: inline; filename="'.dol_sanitizeFileName($protocol->ref).'.pdf"');
|
|
header('Content-Length: '.dol_filesize($file));
|
|
header('Cache-Control: private, max-age=0');
|
|
readfile($file);
|
|
exit;
|