28 lines
743 B
PHP
28 lines
743 B
PHP
<?php
|
|
|
|
class DashboardController
|
|
{
|
|
public function index()
|
|
{
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: /logowanie');
|
|
exit;
|
|
}
|
|
|
|
$userModel = new User();
|
|
$user = $userModel->getUserById($_SESSION['user_id']);
|
|
|
|
$calendarModel = new CalendarEvent();
|
|
$today = new DateTime('today');
|
|
$weekStart = (clone $today)->modify('monday this week');
|
|
$weekEnd = (clone $weekStart)->modify('+6 days');
|
|
$eventsThisWeek = $calendarModel->countByDateRange(
|
|
$_SESSION['user_id'],
|
|
$weekStart->format('Y-m-d'),
|
|
$weekEnd->format('Y-m-d')
|
|
);
|
|
|
|
require_once __DIR__ . '/../views/dashboard.php';
|
|
}
|
|
}
|