summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
diff options
context:
space:
mode:
authorwei <>2006-07-23 11:11:21 +0000
committerwei <>2006-07-23 11:11:21 +0000
commitcbb7a11179b9c1c46e35f04d07d6386a44e400b2 (patch)
treedacfc2a5fdbcce3973e228eaca8002ff799e45d1 /demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
parentc0d9d27f16bae2e428225302da144e9cc6d4adc8 (diff)
Update time-tracker demo and add simple dynamic SQLMap
Diffstat (limited to 'demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php')
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php94
1 files changed, 94 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
new file mode 100644
index 00000000..d2772067
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
@@ -0,0 +1,94 @@
+<?php
+
+class CategoryDataList extends TTemplateControl
+{
+ public function setProjectID($value)
+ {
+ $this->setViewState('ProjectID', $value, '');
+ }
+
+ public function getProjectID()
+ {
+ return $this->getViewState('ProjectID', '');
+ }
+
+ public function getCategories()
+ {
+ $this->ensureChildControls();
+ return $this->getRegisteredObject('categories');
+ }
+
+ protected function getCategoryDao()
+ {
+ return $this->Application->Modules['daos']->getDao('CategoryDao');
+ }
+
+ public function showCategories()
+ {
+ $categoryDao = $this->getCategoryDao();
+ $list = $categoryDao->getCategoriesByProjectID($this->getProjectID());
+ $this->categories->DataSource = $list;
+ $this->categories->dataBind();
+ }
+
+ public function deleteCategoryItem($sender, $param)
+ {
+ $id = $this->categories->DataKeys[$param->Item->ItemIndex];
+ $this->getCategoryDao()->deleteCategory($id);
+ $this->refreshCategoryList($sender, $param);
+ }
+
+ public function editCategoryItem($sender, $param)
+ {
+ $this->categories->EditItemIndex=$param->Item->ItemIndex;
+ $this->showCategories();
+ }
+
+ public function refreshCategoryList($sender, $param)
+ {
+ $this->categories->EditItemIndex=-1;
+ $this->showCategories();
+ }
+
+ public function updateCategoryItem($sender, $param)
+ {
+ if(!$this->Page->IsValid)
+ return;
+
+ $item = $param->Item;
+
+ $id = $this->categories->DataKeys[$param->Item->ItemIndex];
+ $category = new Category;
+ $category->ID = $id;
+ $category->Name = $item->name->Text;
+ $category->Abbreviation = $item->abbrev->Text;
+ $category->EstimateDuration = floatval($item->duration->Text);
+ $category->ProjectID = $this->getProjectID();
+
+ $this->getCategoryDao()->updateCategory($category);
+
+ $this->refreshCategoryList($sender, $param);
+ }
+
+ public function addCategory_clicked($sender, $param)
+ {
+ if(!$this->Page->IsValid)
+ return;
+
+ $newCategory = new Category;
+ $newCategory->Name = $this->categoryName->Text;
+ $newCategory->Abbreviation = $this->abbrev->Text;
+ $newCategory->EstimateDuration = floatval($this->duration->Text);
+ $newCategory->ProjectID = $this->getProjectID();
+
+ $this->getCategoryDao()->addNewCategory($newCategory);
+
+ $this->categoryName->Text = '';
+ $this->abbrev->Text = '';
+ $this->duration->Text = '';
+
+ $this->showCategories();
+ }
+}
+
+?> \ No newline at end of file