summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
blob: e8615c6ca71be5e77fbbacd7b6e2e611a4afaa3d (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
<?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 getSortOrdering($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->getSortOrdering($sort));
	}
		
	public function onLoad($param)
	{
		if(!$this->IsPostBack)
			$this->showProjects();
	}
}