Added: favicon, Dashboard, Habits list, some styles, dashboard redirect

This commit is contained in:
2024-12-27 02:06:32 +01:00
parent d33d233f0f
commit 2847231376
17 changed files with 266 additions and 45 deletions

View File

@ -0,0 +1,16 @@
<?php
class DashboardController extends Controller {
public function index() {
$habit = new Habit();
$habits = $habit->getHabitsByUser($_SESSION['user']['id']);
$this->view('dashboard/index', [
'title' => 'Dashboard',
'habits' => $habits,
]);
}
public function reroute(){
$this->redirect('/dashboard');
}
}

View File

@ -2,7 +2,9 @@
class HabitController extends Controller {
public function index() {
// Display the list of habits (to be implemented later)
$habit = new Habit();
$habits = $habit->getHabitsByUser($_SESSION['user']['id']);
$this->view('habits/index', ['title' => 'Habits', 'habits' => $habits]);
}
public function create() {
@ -17,15 +19,12 @@ class HabitController extends Controller {
}
if ($frequency === 'Custom') {
var_dump($_POST);
$daysOfWeek = $_POST['days_of_week'] ?? [];
$daysOfMonth = $_POST['days_of_month'] ?? '*';
$months = $_POST['months'] ?? '*';
// Combine into crontab-like string
$customFrequency = implode(',', $daysOfWeek) . " $daysOfMonth $months";
var_dump($customFrequency);
}
$habit = new Habit();
@ -38,7 +37,7 @@ class HabitController extends Controller {
]);
if ($result) {
//$this->redirect('/habits');
$this->redirect('/habits');
} else {
$this->view('habits/create', ['error' => 'Failed to create habit.']);
}