summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.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/TimeEntryList.php
parentc0d9d27f16bae2e428225302da144e9cc6d4adc8 (diff)
Update time-tracker demo and add simple dynamic SQLMap
Diffstat (limited to 'demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php')
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
new file mode 100644
index 00000000..2b5f7a0f
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
@@ -0,0 +1,89 @@
+<?php
+
+class TimeEntryList extends TTemplateControl
+{
+ protected function getTimeEntryDao()
+ {
+ return $this->Application->Modules['daos']->getDao('TimeEntryDao');
+ }
+
+ protected function getCategoryDao()
+ {
+ return $this->Application->Modules['daos']->getDao('CategoryDao');
+ }
+
+ public function setProjectEntry($userID,$projectID)
+ {
+ $this->setViewState('ProjectEntry', array($userID,$projectID));
+ }
+
+ protected function getCategories()
+ {
+ $project = $this->getViewState('ProjectEntry');
+ foreach($this->getCategoryDao()->getCategoriesByProjectID($project[1]) as $cat)
+ {
+ $categories[$cat->ID] = $cat->Name;
+ }
+ return $categories;
+ }
+
+ protected function showEntryList()
+ {
+ $project = $this->getViewState('ProjectEntry');
+ $list = $this->getTimeEntryDao()->getTimeEntriesInProject($project[0], $project[1]);
+ $this->entries->DataSource = $list;
+ $this->entries->dataBind();
+ }
+
+ public function refreshEntryList()
+ {
+ $this->entries->EditItemIndex=-1;
+ $this->showEntryList();
+ }
+
+ public function editEntryItem($sender, $param)
+ {
+ $this->entries->EditItemIndex=$param->Item->ItemIndex;
+ $this->showEntryList();
+ }
+
+ public function deleteEntryItem($sender, $param)
+ {
+ $id = $this->entries->DataKeys[$param->Item->ItemIndex];
+ $this->getTimeEntryDao()->deleteTimeEntry($id);
+ $this->refreshEntryList();
+ }
+
+ public function updateEntryItem($sender, $param)
+ {
+ if(!$this->Page->IsValid)
+ return;
+
+ $item = $param->Item;
+
+ $id = $this->entries->DataKeys[$param->Item->ItemIndex];
+
+ $entry = $this->getTimeEntryDao()->getTimeEntryByID($id);
+ $category = new Category;
+ $category->ID = $param->Item->category->SelectedValue;
+ $entry->Category = $category;
+ $entry->Description = $param->Item->description->Text;
+ $entry->Duration = floatval($param->Item->hours->Text);
+ $entry->ReportDate = $param->Item->day->TimeStamp;
+
+ $this->getTimeEntryDao()->updateTimeEntry($entry);
+ $this->refreshEntryList();
+ }
+
+ public function EntryItemCreated($sender, $param)
+ {
+ if($param->Item->ItemType == 'EditItem' && $param->Item->DataItem)
+ {
+ $param->Item->category->DataSource = $this->getCategories();
+ $param->Item->category->dataBind();
+ $param->Item->category->SelectedValue = $param->Item->DataItem->Category->ID;
+ }
+ }
+}
+
+?> \ No newline at end of file