bericht/ajax/save_annotations.php
Eduard Wisch 40fb738ccf
All checks were successful
Deploy bericht / deploy (push) Successful in 1s
feat: Seitenrotation (Hoch/Quer) per Toolbar-Buttons
Die ⟲/⟳-Buttons rotieren jetzt die SEITE statt Fabric-Objekte:
- Image: ctx.rotate beim drawImage, Buffer-Größe getauscht
- PDF: pdfjsLib viewport mit rotation-Param
- Rotation in llx_bericht_page.rotation persistiert
- Beim Seitenwechsel wird die gespeicherte Rotation aus page_meta geladen
- Annotationen werden bei Rotation gelöscht (rotieren VOR dem Annotieren)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
[deploy]
2026-04-08 16:11:41 +02:00

29 lines
1.1 KiB
PHP

<?php
/* Speichert Fabric.js-JSON für eine Seite + ggf. Notiz.
* POST: pageid, fabric_json, note, token
*/
require_once __DIR__.'/_inc.php';
global $db, $user;
if (!$user->hasRight('bericht', 'write')) bericht_ajax_fail('Permission denied', 403);
$pageid = (int) ($_POST['pageid'] ?? 0);
if (!$pageid) bericht_ajax_fail('pageid fehlt');
$fabric = (string) ($_POST['fabric_json'] ?? '');
$note = (string) ($_POST['note'] ?? '');
$rotation = (int) ($_POST['rotation'] ?? 0);
$rotation = (($rotation % 360) + 360) % 360;
// Page laden
$res = $db->query("SELECT rowid FROM ".$db->prefix()."bericht_page WHERE rowid = ".((int) $pageid));
if (!$res || !$db->fetch_object($res)) bericht_ajax_fail('Page nicht gefunden', 404);
$sql = "UPDATE ".$db->prefix()."bericht_page SET "
."fabric_json = ".($fabric !== '' ? "'".$db->escape($fabric)."'" : "NULL").","
."note = ".($note !== '' ? "'".$db->escape($note)."'" : "NULL").","
."rotation = ".((int) $rotation)
." WHERE rowid = ".((int) $pageid);
if (!$db->query($sql)) bericht_ajax_fail('DB-Fehler: '.$db->lasterror());
bericht_ajax_ok();