first commit
This commit is contained in:
27
controllers/DashboardController.php
Normal file
27
controllers/DashboardController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user