Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class CategoryDataList extends TTemplateControl
4
{
5
	public function setProjectID($value)
6
	{
7
		$this->setViewState('ProjectID', $value, '');
8
	}
9
 
10
	public function getProjectID()
11
	{
12
		return $this->getViewState('ProjectID', '');
13
	}
14
 
15
	public function getCategories()
16
	{
17
		$this->ensureChildControls();
18
        return $this->getRegisteredObject('categories');
19
	}
20
 
21
	protected function getCategoryDao()
22
	{
23
		return $this->Application->Modules['daos']->getDao('CategoryDao');
24
	}
25
 
26
	public function showCategories()
27
	{
28
		$categoryDao = $this->getCategoryDao();
29
		$list = $categoryDao->getCategoriesByProjectID($this->getProjectID());
30
		$this->categories->DataSource = $list;
31
		$this->categories->dataBind();
32
	}
33
 
34
	public function deleteCategoryItem($sender, $param)
35
	{
36
		$id = $this->categories->DataKeys[$param->Item->ItemIndex];
37
		$this->getCategoryDao()->deleteCategory($id);
38
		$this->refreshCategoryList($sender, $param);
39
	}
40
 
41
	public function editCategoryItem($sender, $param)
42
	{
43
		$this->categories->EditItemIndex=$param->Item->ItemIndex;
44
		$this->showCategories();
45
	}
46
 
47
	public function refreshCategoryList($sender, $param)
48
	{
49
		$this->categories->EditItemIndex=-1;
50
		$this->showCategories();
51
	}
52
 
53
	public function updateCategoryItem($sender, $param)
54
	{
55
		if(!$this->Page->IsValid)
56
			return;
57
 
58
		$item = $param->Item;
59
 
60
		$id = $this->categories->DataKeys[$param->Item->ItemIndex];
61
		$category = new CategoryRecord;
62
		$category->ID = $id;
63
		$category->Name = $item->name->Text;
64
		$category->Abbreviation = $item->abbrev->Text;
65
		$category->EstimateDuration = floatval($item->duration->Text);
66
		$category->ProjectID = $this->getProjectID();
67
 
68
		$this->getCategoryDao()->updateCategory($category);
69
 
70
		$this->refreshCategoryList($sender, $param);
71
	}
72
 
73
	public function addCategory_clicked($sender, $param)
74
	{
75
		if(!$this->Page->IsValid)
76
			return;
77
 
78
		$newCategory = new CategoryRecord;
79
		$newCategory->Name = $this->categoryName->Text;
80
		$newCategory->Abbreviation = $this->abbrev->Text;
81
		$newCategory->EstimateDuration = floatval($this->duration->Text);
82
		$newCategory->ProjectID = $this->getProjectID();
83
 
84
		$this->getCategoryDao()->addNewCategory($newCategory);
85
 
86
		$this->categoryName->Text = '';
87
		$this->abbrev->Text = '';
88
		$this->duration->Text = '';
89
 
90
		$this->showCategories();
91
	}
92
}
93
 
94
?>