From cbb7a11179b9c1c46e35f04d07d6386a44e400b2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 23 Jul 2006 11:11:21 +0000 Subject: Update time-tracker demo and add simple dynamic SQLMap --- .../pages/TimeTracker/CategoryDataList.php | 94 ++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php (limited to 'demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php') 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 @@ +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 -- cgit v1.2.3