diff options
author | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
---|---|---|
committer | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
commit | 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch) | |
tree | e08bf04f0823650a231227ac3499121270172a23 /demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php | |
parent | 3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff) |
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php')
-rw-r--r-- | demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php | 222 |
1 files changed, 111 insertions, 111 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php index 2c8f0f3b..71d29b78 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php +++ b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php @@ -1,112 +1,112 @@ -<?php
-
-class LogTimeEntry extends TPage
-{
-
- protected function getProjectDao()
- {
- return $this->Application->Modules['daos']->getDao('ProjectDao');
- }
-
- protected function getCategoryDao()
- {
- return $this->Application->Modules['daos']->getDao('CategoryDao');
- }
-
- protected function getTimeEntryDao()
- {
- return $this->Application->Modules['daos']->getDao('TimeEntryDao');
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $projects = $this->getProjects();
- $this->projects->DataSource = $projects;
- $this->projects->dataBind();
- $this->showCategories(key($projects));
- }
- }
-
- protected function showCategories($projectID)
- {
- $categories = array();
- foreach($this->getCategoryDao()->getCategoriesByProjectID($projectID) as $cat)
- {
- $categories[$cat->ID] = $cat->Name;
- }
- $this->category->DataSource = $categories;
- $this->category->dataBind();
- $this->showProjectUsers($projectID);
- }
-
- protected function showProjectUsers($projectID)
- {
- if($this->User->isInRole('manager'))
- $users = $this->getProjectDao()->getProjectMembers($projectID);
- else
- $users = array($this->User->Name);
- $this->projectMembers->DataSource = $users;
- $this->projectMembers->dataBind();
- if(is_int($index = array_search($this->User->Name, $users)))
- {
- $this->projectMembers->SelectedIndex = $index;
- $this->showTimeSheet();
- }
- }
-
- public function showTimeSheet()
- {
- $user = $this->projectMembers->SelectedItem->Text;
- $project = $this->projects->SelectedValue;
- $this->entryList->setProjectEntry($user,$project);
- $this->entryList->refreshEntryList();
- }
-
- protected function getProjects()
- {
- $projects = array();
- if($this->User->isInRole('admin'))
- $list = $this->getProjectDao()->getAllProjects();
- else if($this->User->isInRole('manager'))
- $list = $this->getProjectDao()->getProjectsByManagerName($this->User->Name);
- else
- $list = $this->getProjectDao()->getProjectsByUserName($this->User->Name);
- foreach($list as $project)
- $projects[$project->ID] = $project->Name;
- return $projects;
- }
-
- public function projects_Changed($sender, $param)
- {
- $this->showCategories($sender->SelectedValue);
- }
-
- public function AddNewEntry($sender, $param)
- {
- if(!$this->IsValid)
- return;
-
- if($this->projectMembers->SelectedItem)
- {
- $entry = new TimeEntryRecord;
- $entry->CreatorUserName = $this->User->Name;
- $category = new CategoryRecord;
- $category->ID = $this->category->SelectedValue;
- $entry->Category = $category;
- $entry->Description = $this->description->Text;
- $entry->Duration = floatval($this->hours->Text);
- $entry->ReportDate = $this->day->TimeStamp;
- $entry->Username = $this->projectMembers->SelectedItem->Text;
-
- $this->hours->Text = '';
- $this->description->Text = '';
-
- $this->getTimeEntryDao()->addNewTimeEntry($entry);
- $this->showTimeSheet();
- }
- }
-}
-
+<?php + +class LogTimeEntry extends TPage +{ + + protected function getProjectDao() + { + return $this->Application->Modules['daos']->getDao('ProjectDao'); + } + + protected function getCategoryDao() + { + return $this->Application->Modules['daos']->getDao('CategoryDao'); + } + + protected function getTimeEntryDao() + { + return $this->Application->Modules['daos']->getDao('TimeEntryDao'); + } + + public function onLoad($param) + { + if(!$this->IsPostBack) + { + $projects = $this->getProjects(); + $this->projects->DataSource = $projects; + $this->projects->dataBind(); + $this->showCategories(key($projects)); + } + } + + protected function showCategories($projectID) + { + $categories = array(); + foreach($this->getCategoryDao()->getCategoriesByProjectID($projectID) as $cat) + { + $categories[$cat->ID] = $cat->Name; + } + $this->category->DataSource = $categories; + $this->category->dataBind(); + $this->showProjectUsers($projectID); + } + + protected function showProjectUsers($projectID) + { + if($this->User->isInRole('manager')) + $users = $this->getProjectDao()->getProjectMembers($projectID); + else + $users = array($this->User->Name); + $this->projectMembers->DataSource = $users; + $this->projectMembers->dataBind(); + if(is_int($index = array_search($this->User->Name, $users))) + { + $this->projectMembers->SelectedIndex = $index; + $this->showTimeSheet(); + } + } + + public function showTimeSheet() + { + $user = $this->projectMembers->SelectedItem->Text; + $project = $this->projects->SelectedValue; + $this->entryList->setProjectEntry($user,$project); + $this->entryList->refreshEntryList(); + } + + protected function getProjects() + { + $projects = array(); + if($this->User->isInRole('admin')) + $list = $this->getProjectDao()->getAllProjects(); + else if($this->User->isInRole('manager')) + $list = $this->getProjectDao()->getProjectsByManagerName($this->User->Name); + else + $list = $this->getProjectDao()->getProjectsByUserName($this->User->Name); + foreach($list as $project) + $projects[$project->ID] = $project->Name; + return $projects; + } + + public function projects_Changed($sender, $param) + { + $this->showCategories($sender->SelectedValue); + } + + public function AddNewEntry($sender, $param) + { + if(!$this->IsValid) + return; + + if($this->projectMembers->SelectedItem) + { + $entry = new TimeEntryRecord; + $entry->CreatorUserName = $this->User->Name; + $category = new CategoryRecord; + $category->ID = $this->category->SelectedValue; + $entry->Category = $category; + $entry->Description = $this->description->Text; + $entry->Duration = floatval($this->hours->Text); + $entry->ReportDate = $this->day->TimeStamp; + $entry->Username = $this->projectMembers->SelectedItem->Text; + + $this->hours->Text = ''; + $this->description->Text = ''; + + $this->getTimeEntryDao()->addNewTimeEntry($entry); + $this->showTimeSheet(); + } + } +} + ?>
\ No newline at end of file |