All checks were successful
Deploy bericht / deploy (push) Successful in 1s
- api/_jwt.php: HS256 JWT encode/decode/from_request, Secret aus
dolibarr_main_instance_unique_id, 7 Tage TTL
- api/_inc.php: gemeinsamer API-Init mit CORS, JSON-Helpers,
api_authenticate() lädt User aus JWT und prüft bericht/read
- api/auth.php: POST { login, password } → JWT mit user + perms
- api/orders.php:
- GET /api/orders.php — Liste der Aufträge des Users (Multi-User
Filter über fk_user_*, Admin sieht alle)
- GET /api/orders.php?id=X — Auftrags-Detail mit Kunde + Berichten
- GET /api/orders.php?id=X&action=photos — Anhänge
- POST /api/orders.php?id=X&action=upload_photo — Foto hochladen,
Bericht wird automatisch angelegt falls nicht vorhanden
- api/reports.php:
- GET /api/reports.php?id=X — Bericht-Detail + Seiten
- POST /api/reports.php?id=X&action=finalize — Status auf final
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
[deploy]
58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php
|
|
/* GET /api/reports.php?id=<id> — Detail eines Berichts
|
|
* POST /api/reports.php?id=<id>&action=finalize — Finalisierung anstoßen
|
|
*
|
|
* Listing aller Berichte läuft über orders.php (pro Auftrag).
|
|
*/
|
|
require_once __DIR__.'/_inc.php';
|
|
|
|
api_authenticate();
|
|
global $db, $user;
|
|
|
|
$id = (int) ($_GET['id'] ?? 0);
|
|
$action = $_GET['action'] ?? '';
|
|
|
|
if (!$id) api_fail('id erforderlich');
|
|
|
|
$bericht = new Bericht($db);
|
|
if ($bericht->fetch($id) <= 0) api_fail('Bericht nicht gefunden', 404);
|
|
|
|
if ($action === 'finalize') {
|
|
if (!$user->hasRight('bericht', 'write')) api_fail('Schreibrechte fehlen', 403);
|
|
// Wir rufen generate_pdf.php intern auf, indem wir die Logik laden — einfacher: redirect
|
|
// Hier simpler Ansatz: setze Status auf Final (echte PDF-Generierung sollte separat triggern)
|
|
$bericht->status = Bericht::STATUS_FINAL;
|
|
$bericht->update($user);
|
|
api_ok(array('status' => 'final'));
|
|
}
|
|
|
|
// Detail
|
|
$pages = BerichtPage::fetchAllForBericht($db, $bericht->id);
|
|
$pages_out = array();
|
|
foreach ($pages as $p) {
|
|
$pages_out[] = array(
|
|
'id' => (int) $p->id,
|
|
'page_order' => (int) $p->page_order,
|
|
'source_type'=> $p->source_type,
|
|
'source_path'=> $p->source_path,
|
|
'rotation' => (int) $p->rotation,
|
|
'note' => $p->note,
|
|
'layout' => $p->layout,
|
|
);
|
|
}
|
|
|
|
api_ok(array(
|
|
'report' => array(
|
|
'id' => (int) $bericht->id,
|
|
'ref' => $bericht->ref,
|
|
'titel' => $bericht->titel,
|
|
'auftragsnummer' => $bericht->auftragsnummer,
|
|
'element_type' => $bericht->element_type,
|
|
'fk_element' => (int) $bericht->fk_element,
|
|
'page_format' => $bericht->page_format,
|
|
'page_orientation'=> $bericht->page_orientation,
|
|
'status' => (int) $bericht->status,
|
|
'datec' => (int) $bericht->datec,
|
|
),
|
|
'pages' => $pages_out,
|
|
));
|