| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/seaside.pacim.de/web/ |
Upload File : |
<?php
/**
* booking-notes.php – Notizen-Verwaltung im CRM (Admin-Session).
*
* Aktionen (?action=): list | add | edit | del. Je Buchung (b=booking_id).
* Felder: Sichtbarkeit (web = auch in der Web-App) + Hervorhebung (highlight = Lauftext in der Web-App).
* Die Web-App (checkin.php) verwaltet ihre Notizen selbst (Token-Auth); hier ausschließlich Admin.
*/
require_once( __DIR__ . '/includes/config.inc.php' );
require_once( __DIR__ . '/includes/booking-notes.php' );
@ini_set( 'display_errors', '0' );
error_reporting( 0 );
while ( ob_get_level() > 0 ) ob_end_clean();
function bn_json( $a ) { header( 'Content-Type: application/json; charset=utf-8' ); header( 'Cache-Control: no-store' ); echo json_encode( $a ); exit(); }
function bn_fail( $m, $code = 400 ) { http_response_code( $code ); bn_json( array( 'success' => false, 'error' => $m ) ); }
if ( ! ( function_exists( 'is_admin' ) && is_admin() ) ) bn_fail( 'Nicht berechtigt.', 403 );
$db = new MysqliDb( MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB );
$action = (string) ( $_GET['action'] ?? ( $_POST['action'] ?? '' ) );
$bid = (int) ( $_GET['b'] ?? ( $_POST['b'] ?? 0 ) );
$uname = trim( (string) ( $_SESSION['user_name'] ?? 'Administrator' ) );
function bn_item( $n ) {
return array(
'id' => (int) $n['note_id'], 'text' => (string) $n['note_text'], 'user' => (string) $n['note_user'],
'web' => ! empty( $n['note_web'] ), 'highlight' => ! empty( $n['note_highlight'] ),
'created' => pacim_bn_fmt_dt( $n['note_created'] ),
'updated' => ! empty( $n['note_updated'] ) ? pacim_bn_fmt_dt( $n['note_updated'] ) : '',
'updatedBy' => (string) $n['note_updated_by'],
'canEdit' => true, 'canDel' => true,
);
}
if ( $action === 'list' ) {
if ( $bid <= 0 ) bn_fail( 'Buchung fehlt.' );
$out = array();
foreach ( pacim_bn_list( $db, $bid ) as $n ) $out[] = bn_item( $n );
bn_json( array( 'success' => true, 'notes' => $out, 'count' => count( $out ) ) );
}
if ( $action === 'add' ) {
if ( $bid <= 0 ) bn_fail( 'Buchung fehlt.' );
if ( ! $db->rawQueryOne( "SELECT 1 x FROM pacim_booking WHERE booking_id = ?", array( $bid ) ) ) bn_fail( 'Buchung nicht gefunden.', 404 );
$web = ! empty( $_POST['web'] ) ? 1 : 0;
$hl = ! empty( $_POST['highlight'] ) ? 1 : 0;
$id = pacim_bn_add( $db, $bid, (string) ( $_POST['text'] ?? '' ), $uname, null, $web, $hl );
if ( ! $id ) bn_fail( 'Notiz konnte nicht gespeichert werden (leer oder Limit erreicht).' );
bn_json( array( 'success' => true, 'id' => $id ) );
}
if ( $action === 'edit' || $action === 'del' ) {
$nid = (int) ( $_POST['id'] ?? 0 );
$n = pacim_bn_get( $db, $nid );
if ( ! $n || ( $bid > 0 && (int) $n['note_booking'] !== $bid ) || $n['note_deleted_at'] ) bn_fail( 'Notiz nicht gefunden.', 404 );
if ( $action === 'del' ) { pacim_bn_delete( $db, $nid, $uname ); bn_json( array( 'success' => true ) ); }
$web = ! empty( $_POST['web'] ) ? 1 : 0;
$hl = ! empty( $_POST['highlight'] ) ? 1 : 0;
if ( ! pacim_bn_update( $db, $nid, (string) ( $_POST['text'] ?? '' ), $uname, $web, $hl ) ) bn_fail( 'Speichern fehlgeschlagen.' );
bn_json( array( 'success' => true ) );
}
bn_fail( 'Unbekannte Aktion.' );