summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
blob: eb92dcb74590a20a183dad767e62bfced47618ea (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
<?php

class ProjectList extends TPage
{
	protected function showProjects($sort='', $order='')
	{
		$dao = $this->Application->Modules['daos']->getDao('ProjectDao');
		$this->projectList->DataSource = $dao->getAllProjects($sort, $order);
		$this->projectList->dataBind();
	}
	
	protected function getSortOrder($sort)
	{
		$ordering = $this->getViewState('SortOrder', array());
		$order = isset($ordering[$sort]) ? $ordering[$sort] : 'DESC';
		$ordering[$sort] = $order == 'DESC' ? 'ASC' : 'DESC';
		$this->setViewState('SortOrder', $ordering);
		return $ordering[$sort];
	}
	
	protected function sortProjects($sender, $param)
	{
		$sort = $param->SortExpression;
		$this->showProjects($sort, $this->getSortOrder($sort));
	}
		
	public function onLoad($param)
	{
		if(!$this->IsPostBack)
			$this->showProjects();
	}
}

?>