summaryrefslogtreecommitdiff
path: root/app/php/controls/CalendarGrid.php
blob: 4ebfacd1a949a9cf546d6d843ebd95c7bd0e06e2 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

Prado::using('Application.web.FacadeTemplateControl');
Prado::using('Application.facades.EventFacade');
Prado::using('Application.user.DbUser');

class CalendarGrid extends FacadeTemplateControl {

    public function setMonth($month) {
        $this->setControlState('Month', $month);
    }

    public function getMonth() {
        return $this->getControlState('Month');
    }

    public function setYear($year) {
        $this->setControlState('Year', $year);
    }

    public function getYear() {
        return $this->getControlState('Year');
    }

    public function setUserToDisplay(DbUser $user) {
        $this->setControlState('User', $user);
    }

    public function getUserToDisplay() {
        return $this->getControlState('User');
    }

    private function _getGrid() {
        return $this->getFacade()->getCalendarListForUser(
            $this->UserToDisplay,
            $this->Month,
            $this->Year
        );
    }

    public function onPreRender($param) {
        parent::onPreRender($param);
        $this->Weeks->DataSource = $this->_getGrid()->Weeks;
        $this->Weeks->dataBind();
    }

    public function weekDataBind($sender, $param) {
        $param->Item->Days->DataSource = $param->Item->Data;
        $param->Item->Days->dataBind();
    }

    public function dayDataBind($sender, $param) {
        $param->Item->Events->DataSource = $param->Item->Data->Events;
        $param->Item->Events->dataBind();
    }

}

?>