| 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
/**
* dashboard-api.php – Lazy-Load-Endpunkt für die Anreiseübersicht (tasks/dashboard).
* Hinter dem PaCIM-Login. Liefert die nächste Charge an Tageskarten als HTML.
*
* GET offset, limit -> { html, has_more, count }
*/
require_once( __DIR__ . "/includes/config.inc.php" );
@ini_set( 'display_errors', '0' );
if ( !isset( $_SESSION['user'] ) || $_SESSION['user'] != LOGIN_USER ) {
http_response_code( 403 );
echo 'unauthorized';
exit();
}
global $smarty;
$dash = new dashboard();
$action = isset( $_GET['action'] ) ? $_GET['action'] : '';
if ( class_exists( 'perflog' ) ) perflog::wholeRequest( 'dashboard', $action !== '' ? preg_replace( '/[^a-z_]/i', '', $action ) : '?', 'dashboard_ajax' );
// Monatsübersicht für den Kalender (Auslastung je Tag + Zusammenfassung)
if ( $action === 'month' ) {
header( 'Content-Type: application/json; charset=utf-8' );
echo json_encode( $dash->monthOverview(
isset( $_GET['year'] ) ? (int) $_GET['year'] : (int) date('Y'),
isset( $_GET['month'] ) ? (int) $_GET['month'] : (int) date('n')
) );
exit();
}
// Rechte Tagesansicht als HTML (per AJAX beim Klick auf einen Kalendertag)
if ( $action === 'day' ) {
header( 'Content-Type: text/html; charset=utf-8' );
$date = ( isset( $_GET['date'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', $_GET['date'] ) ) ? $_GET['date'] : date('Y-m-d');
$days = $dash->events( array( $date ) );
$smarty->assign( 'day', !empty( $days ) ? $days[0] : false );
$smarty->assign( 'dayDate', $date );
echo $smarty->fetch( 'tasks/_day_detail.tpl' );
exit();
}
// Fallback: bisheriger Lazy-Load der Tageskarten (JSON)
header( 'Content-Type: application/json; charset=utf-8' );
$offset = isset( $_GET['offset'] ) ? max( 0, (int) $_GET['offset'] ) : 0;
$limit = isset( $_GET['limit'] ) ? min( 20, max( 1, (int) $_GET['limit'] ) ) : 5;
$dates = $dash->eventDates( $offset, $limit );
$events = $dash->events( $dates );
$html = '';
foreach ( $events as $day ) {
$smarty->assign( 'day', $day );
$html .= $smarty->fetch( 'tasks/_event_card.tpl' );
}
echo json_encode( array(
'html' => $html,
'count' => count( $events ),
'has_more' => count( $dates ) === $limit,
) );