summaryrefslogtreecommitdiff
path: root/app/Controller/Timetable.php
blob: 65edb44c1dcb2be0e980647b02a2fec18a3b5cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

namespace Controller;

use DateTime;

/**
 * Timetable controller
 *
 * @package  controller
 * @author   Frederic Guillot
 */
class Timetable extends User
{
    /**
     * Display timetable for the user
     *
     * @access public
     */
    public function index()
    {
        $user = $this->getUser();
        $from = $this->request->getStringParam('from', date('Y-m-d'));
        $to = $this->request->getStringParam('to', date('Y-m-d', strtotime('next week')));
        $timetable = $this->timetable->calculate($user['id'], new DateTime($from), new DateTime($to));

        $this->response->html($this->layout('timetable/index', array(
            'user' => $user,
            'timetable' => $timetable,
            'values' => array(
                'from' => $from,
                'to' => $to,
                'controller' => 'timetable',
                'action' => 'index',
                'user_id' => $user['id'],
            ),
        )));
    }
}