Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class TimeEntryList extends TTemplateControl
4
{
5
	protected function getTimeEntryDao()
6
	{
7
		return $this->Application->Modules['daos']->getDao('TimeEntryDao');
8
	}
9
 
10
	protected function getCategoryDao()
11
	{
12
		return $this->Application->Modules['daos']->getDao('CategoryDao');
13
	}
14
 
15
	public function setProjectEntry($userID,$projectID)
16
	{
17
		$this->setViewState('ProjectEntry', array($userID,$projectID));
18
	}
19
 
20
	protected function getCategories()
21
	{
22
		$project = $this->getViewState('ProjectEntry');
23
		foreach($this->getCategoryDao()->getCategoriesByProjectID($project[1]) as $cat)
24
		{
25
			$categories[$cat->ID] = $cat->Name;
26
		}
27
		return $categories;
28
	}
29
 
30
	protected function showEntryList()
31
	{
32
		$project = $this->getViewState('ProjectEntry');
33
		$list = $this->getTimeEntryDao()->getTimeEntriesInProject($project[0], $project[1]);
34
		$this->entries->DataSource = $list;
35
		$this->entries->dataBind();
36
	}
37
 
38
	public function refreshEntryList()
39
	{
40
		$this->entries->EditItemIndex=-1;
41
		$this->showEntryList();
42
	}
43
 
44
	public function editEntryItem($sender, $param)
45
	{
46
		$this->entries->EditItemIndex=$param->Item->ItemIndex;
47
		$this->showEntryList();
48
	}
49
 
50
	public function deleteEntryItem($sender, $param)
51
	{
52
		$id = $this->entries->DataKeys[$param->Item->ItemIndex];
53
		$this->getTimeEntryDao()->deleteTimeEntry($id);
54
		$this->refreshEntryList();
55
	}
56
 
57
	public function updateEntryItem($sender, $param)
58
	{
59
		if(!$this->Page->IsValid)
60
			return;
61
 
62
		$item = $param->Item;
63
 
64
		$id = $this->entries->DataKeys[$param->Item->ItemIndex];
65
 
66
		$entry = $this->getTimeEntryDao()->getTimeEntryByID($id);
67
		$category = new CategoryRecord;
68
		$category->ID = $param->Item->category->SelectedValue;
69
		$entry->Category = $category;
70
		$entry->Description = $param->Item->description->Text;
71
		$entry->Duration = floatval($param->Item->hours->Text);
72
		$entry->ReportDate = $param->Item->day->TimeStamp;
73
 
74
		$this->getTimeEntryDao()->updateTimeEntry($entry);
75
		$this->refreshEntryList();
76
	}
77
 
78
	public function EntryItemCreated($sender, $param)
79
	{
80
		if($param->Item->ItemType == 'EditItem' && $param->Item->DataItem)
81
		{
82
			$param->Item->category->DataSource = $this->getCategories();
83
			$param->Item->category->dataBind();
84
			$param->Item->category->SelectedValue = $param->Item->DataItem->Category->ID;
85
		}
86
	}
87
}
88
 
89
?>