summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/pages/TimeTracker
diff options
context:
space:
mode:
Diffstat (limited to 'demos/time-tracker/protected/pages/TimeTracker')
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php186
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php222
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Login.php108
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/Logout.php66
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/MainLayout.php12
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php380
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ProjectList.php66
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ReportProject.php104
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/ReportResource.php140
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/SiteMap.php112
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php176
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserCreate.php222
-rw-r--r--demos/time-tracker/protected/pages/TimeTracker/UserList.php66
13 files changed, 930 insertions, 930 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
index dd04dbf3..cc21a486 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/CategoryDataList.php
@@ -1,94 +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 CategoryRecord;
- $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 CategoryRecord;
- $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();
- }
-}
-
+<?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 CategoryRecord;
+ $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 CategoryRecord;
+ $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
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
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Login.php b/demos/time-tracker/protected/pages/TimeTracker/Login.php
index 2bd02cc1..d306cf63 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/Login.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/Login.php
@@ -1,55 +1,55 @@
-<?php
-/**
- * Login Page class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Demos
- */
-
-/**
- * Login page class.
- *
- * Validate the user credentials and redirect to requested page
- * if successful.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package Demos
- * @since 3.1
- */
-class Login extends TPage
-{
- /**
- * Validates the username and password.
- * @param TControl custom validator that created the event.
- * @param TServerValidateEventParameter validation parameters.
- */
- public function validateUser($sender, $param)
- {
- $authManager=$this->Application->getModule('auth');
- if(!$authManager->login($this->username->Text,$this->password->Text))
- $param->IsValid=false;;
- }
-
- /**
- * Redirect to the requested page if login is successful.
- * @param TControl button control that created the event.
- * @param TEventParameter event parameters.
- */
- public function doLogin($sender, $param)
- {
- if($this->Page->IsValid)
- {
- $auth = $this->Application->getModule('auth');
- if($this->remember->Checked)
- $auth->rememberSignon($this->User);
- $this->Response->redirect($auth->getReturnUrl());
- }
- }
-}
-
+<?php
+/**
+ * Login Page class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package Demos
+ */
+
+/**
+ * Login page class.
+ *
+ * Validate the user credentials and redirect to requested page
+ * if successful.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package Demos
+ * @since 3.1
+ */
+class Login extends TPage
+{
+ /**
+ * Validates the username and password.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ public function validateUser($sender, $param)
+ {
+ $authManager=$this->Application->getModule('auth');
+ if(!$authManager->login($this->username->Text,$this->password->Text))
+ $param->IsValid=false;;
+ }
+
+ /**
+ * Redirect to the requested page if login is successful.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ public function doLogin($sender, $param)
+ {
+ if($this->Page->IsValid)
+ {
+ $auth = $this->Application->getModule('auth');
+ if($this->remember->Checked)
+ $auth->rememberSignon($this->User);
+ $this->Response->redirect($auth->getReturnUrl());
+ }
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/Logout.php b/demos/time-tracker/protected/pages/TimeTracker/Logout.php
index 2e3d3ccc..f82f137c 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/Logout.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/Logout.php
@@ -1,34 +1,34 @@
-<?php
-/**
- * Logout class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Demos
- */
-
-/**
- * Logout page class.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package Demos
- * @since 3.1
- */
-class Logout extends TPage
-{
- /**
- * Logs out the current user and redirect to default page.
- */
- function onLoad($param)
- {
- $this->Application->getModule('auth')->logout();
- $url = $this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($url);
- }
-}
-
+<?php
+/**
+ * Logout class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package Demos
+ */
+
+/**
+ * Logout page class.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package Demos
+ * @since 3.1
+ */
+class Logout extends TPage
+{
+ /**
+ * Logs out the current user and redirect to default page.
+ */
+ function onLoad($param)
+ {
+ $this->Application->getModule('auth')->logout();
+ $url = $this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($url);
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php
index 253d6c03..c966ba85 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/MainLayout.php
@@ -1,7 +1,7 @@
-<?php
-
-class MainLayout extends TTemplateControl
-{
-}
-
+<?php
+
+class MainLayout extends TTemplateControl
+{
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
index 98a93148..f4fb9718 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
@@ -1,191 +1,191 @@
-<?php
-
-class ProjectDetails extends TPage
-{
- private $allUsers;
-
- private $currentProject;
-
- protected function getCurrentProject()
- {
- if(!$this->currentProject)
- {
- $id = intval($this->Request['ProjectID']);
- if($id > 0)
- $this->currentProject = $this->getProjectDao()->getProjectByID($id);
- }
- return $this->currentProject;
- }
-
- protected function getProjectDao()
- {
- return $this->Application->Modules['daos']->getDao('ProjectDao');
- }
-
- protected function getCategoryDao()
- {
- return $this->Application->Modules['daos']->getDao('CategoryDao');
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $this->manager->DataSource = $this->getUsersWithRole('manager');
- $this->manager->dataBind();
- $this->members->DataSource = $this->getUsersWithRole('consultant');
- $this->members->dataBind();
-
- $project = $this->getCurrentProject();
-
- if($project !== null)
- {
- $this->projectName->Text = $project->Name;
- $this->completionDate->TimeStamp = $project->CompletionDate;
- $this->description->Text = $project->Description;
- $this->estimateHours->Text = $project->EstimateDuration;
- $this->manager->SelectedValue = $project->ManagerUserName;
-
- $this->selectProjectMembers($project->ID);
-
- $this->projectCategoryColumn->Visible = true;
- $this->categories->ProjectID = $project->ID;
- $this->categories->showCategories();
-
- $this->deleteButton->Visible = true;
-
- $this->projectList->DataSource = $this->getProjects();
- $this->projectList->dataBind();
-
- }
- else
- {
- $this->projectCategoryColumn->Visible = false;
- $this->deleteButton->Visible = false;
- }
-
- }
- }
-
- protected function getProjects()
- {
- $projects = array();
- foreach($this->getProjectDao()->getAllProjects() as $project)
- {
- if($project->Name != $this->currentProject->Name)
- $projects[$project->ID] = $project->Name;
- }
- return $projects;
- }
-
- protected function selectProjectMembers($projectID)
- {
- $members = $this->getProjectDao()->getProjectMembers($projectID);
- $this->members->SelectedValues = $members;
- }
-
- protected function getUsersWithRole($role)
- {
- if(is_null($this->allUsers))
- {
- $dao = $this->Application->Modules['daos']->getDao('UserDao');
- $this->allUsers = $dao->getAllUsers();
- }
- $users = array();
- foreach($this->allUsers as $user)
- {
- if($user->isInRole($role))
- $users[$user->Name] = $user->Name;
- }
- return $users;
- }
-
- public function onPreRender($param)
- {
- $ids = array();
- foreach($this->members->Items as $item)
- {
- if($item->Selected)
- $ids[] = $item->Value;
- }
- $this->setViewState('ActiveConsultants', $ids);
- }
-
- public function saveButton_clicked($sender, $param)
- {
- if(!$this->Page->IsValid)
- return;
-
- $newProject = new ProjectRecord;
-
- $projectDao = $this->getProjectDao();
-
- if($project = $this->getCurrentProject())
- $newProject = $projectDao->getProjectByID($project->ID);
- else
- $newProject->CreatorUserName = $this->User->Name;
-
- $newProject->Name = $this->projectName->Text;
- $newProject->CompletionDate = $this->completionDate->TimeStamp;
- $newProject->Description = $this->description->Text;
- $newProject->EstimateDuration = floatval($this->estimateHours->Text);
- $newProject->ManagerUserName = $this->manager->SelectedValue;
-
- if($this->currentProject)
- $projectDao->updateProject($newProject);
- else
- $projectDao->addNewProject($newProject);
-
- $this->updateProjectMembers($newProject->ID);
-
- $url = $this->Service->constructUrl('TimeTracker.ProjectDetails',
- array('ProjectID'=> $newProject->ID));
-
- $this->Response->redirect($url);
- }
-
- protected function updateProjectMembers($projectID)
- {
- $active = $this->getViewState('ActiveConsultants');
- $projectDao = $this->getProjectDao();
- foreach($this->members->Items as $item)
- {
- if($item->Selected)
- {
- if(!in_array($item->Value, $active))
- $projectDao->addUserToProject($projectID, $item->Value);
- }
- else
- {
- if(in_array($item->Value, $active))
- $projectDao->removeUserFromProject($projectID, $item->Value);
- }
- }
- }
-
- public function deleteButton_clicked($sender, $param)
- {
- if($project = $this->getCurrentProject())
- {
- $this->getProjectDao()->deleteProject($project->ID);
- $url = $this->Service->constructUrl('TimeTracker.ProjectList');
- $this->Response->redirect($url);
- }
- }
-
- public function copyButton_clicked($sender, $param)
- {
- $project = $this->projectList->SelectedValue;
- $categoryDao = $this->getCategoryDao();
- $categories = $categoryDao->getCategoriesByProjectID($project);
- $currentProject = $this->getCurrentProject();
- foreach($categories as $cat)
- {
- $cat->ProjectID = $currentProject->ID;
- $categoryDao->addNewCategory($cat);
- }
- $this->categories->showCategories();
- }
-}
-
+<?php
+
+class ProjectDetails extends TPage
+{
+ private $allUsers;
+
+ private $currentProject;
+
+ protected function getCurrentProject()
+ {
+ if(!$this->currentProject)
+ {
+ $id = intval($this->Request['ProjectID']);
+ if($id > 0)
+ $this->currentProject = $this->getProjectDao()->getProjectByID($id);
+ }
+ return $this->currentProject;
+ }
+
+ protected function getProjectDao()
+ {
+ return $this->Application->Modules['daos']->getDao('ProjectDao');
+ }
+
+ protected function getCategoryDao()
+ {
+ return $this->Application->Modules['daos']->getDao('CategoryDao');
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->manager->DataSource = $this->getUsersWithRole('manager');
+ $this->manager->dataBind();
+ $this->members->DataSource = $this->getUsersWithRole('consultant');
+ $this->members->dataBind();
+
+ $project = $this->getCurrentProject();
+
+ if($project !== null)
+ {
+ $this->projectName->Text = $project->Name;
+ $this->completionDate->TimeStamp = $project->CompletionDate;
+ $this->description->Text = $project->Description;
+ $this->estimateHours->Text = $project->EstimateDuration;
+ $this->manager->SelectedValue = $project->ManagerUserName;
+
+ $this->selectProjectMembers($project->ID);
+
+ $this->projectCategoryColumn->Visible = true;
+ $this->categories->ProjectID = $project->ID;
+ $this->categories->showCategories();
+
+ $this->deleteButton->Visible = true;
+
+ $this->projectList->DataSource = $this->getProjects();
+ $this->projectList->dataBind();
+
+ }
+ else
+ {
+ $this->projectCategoryColumn->Visible = false;
+ $this->deleteButton->Visible = false;
+ }
+
+ }
+ }
+
+ protected function getProjects()
+ {
+ $projects = array();
+ foreach($this->getProjectDao()->getAllProjects() as $project)
+ {
+ if($project->Name != $this->currentProject->Name)
+ $projects[$project->ID] = $project->Name;
+ }
+ return $projects;
+ }
+
+ protected function selectProjectMembers($projectID)
+ {
+ $members = $this->getProjectDao()->getProjectMembers($projectID);
+ $this->members->SelectedValues = $members;
+ }
+
+ protected function getUsersWithRole($role)
+ {
+ if(is_null($this->allUsers))
+ {
+ $dao = $this->Application->Modules['daos']->getDao('UserDao');
+ $this->allUsers = $dao->getAllUsers();
+ }
+ $users = array();
+ foreach($this->allUsers as $user)
+ {
+ if($user->isInRole($role))
+ $users[$user->Name] = $user->Name;
+ }
+ return $users;
+ }
+
+ public function onPreRender($param)
+ {
+ $ids = array();
+ foreach($this->members->Items as $item)
+ {
+ if($item->Selected)
+ $ids[] = $item->Value;
+ }
+ $this->setViewState('ActiveConsultants', $ids);
+ }
+
+ public function saveButton_clicked($sender, $param)
+ {
+ if(!$this->Page->IsValid)
+ return;
+
+ $newProject = new ProjectRecord;
+
+ $projectDao = $this->getProjectDao();
+
+ if($project = $this->getCurrentProject())
+ $newProject = $projectDao->getProjectByID($project->ID);
+ else
+ $newProject->CreatorUserName = $this->User->Name;
+
+ $newProject->Name = $this->projectName->Text;
+ $newProject->CompletionDate = $this->completionDate->TimeStamp;
+ $newProject->Description = $this->description->Text;
+ $newProject->EstimateDuration = floatval($this->estimateHours->Text);
+ $newProject->ManagerUserName = $this->manager->SelectedValue;
+
+ if($this->currentProject)
+ $projectDao->updateProject($newProject);
+ else
+ $projectDao->addNewProject($newProject);
+
+ $this->updateProjectMembers($newProject->ID);
+
+ $url = $this->Service->constructUrl('TimeTracker.ProjectDetails',
+ array('ProjectID'=> $newProject->ID));
+
+ $this->Response->redirect($url);
+ }
+
+ protected function updateProjectMembers($projectID)
+ {
+ $active = $this->getViewState('ActiveConsultants');
+ $projectDao = $this->getProjectDao();
+ foreach($this->members->Items as $item)
+ {
+ if($item->Selected)
+ {
+ if(!in_array($item->Value, $active))
+ $projectDao->addUserToProject($projectID, $item->Value);
+ }
+ else
+ {
+ if(in_array($item->Value, $active))
+ $projectDao->removeUserFromProject($projectID, $item->Value);
+ }
+ }
+ }
+
+ public function deleteButton_clicked($sender, $param)
+ {
+ if($project = $this->getCurrentProject())
+ {
+ $this->getProjectDao()->deleteProject($project->ID);
+ $url = $this->Service->constructUrl('TimeTracker.ProjectList');
+ $this->Response->redirect($url);
+ }
+ }
+
+ public function copyButton_clicked($sender, $param)
+ {
+ $project = $this->projectList->SelectedValue;
+ $categoryDao = $this->getCategoryDao();
+ $categories = $categoryDao->getCategoriesByProjectID($project);
+ $currentProject = $this->getCurrentProject();
+ foreach($categories as $cat)
+ {
+ $cat->ProjectID = $currentProject->ID;
+ $categoryDao->addNewCategory($cat);
+ }
+ $this->categories->showCategories();
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
index 4e3ac485..6ea6afe1 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
@@ -1,34 +1,34 @@
-<?php
-
-class ProjectList extends TPage
-{
- protected function showProjects($sort='', $order='')
- {
- $dao = $this->Application->Modules['daos']->getDao('ProjectDao');
- $this->projectList->DataSource = $dao->getAllProjects($sort, $order);
- $this->projectList->dataBind();
- }
-
- protected function getSortOrdering($sort)
- {
- $ordering = $this->getViewState('SortOrder', array());
- $order = isset($ordering[$sort]) ? $ordering[$sort] : 'DESC';
- $ordering[$sort] = $order == 'DESC' ? 'ASC' : 'DESC';
- $this->setViewState('SortOrder', $ordering);
- return $ordering[$sort];
- }
-
- protected function sortProjects($sender, $param)
- {
- $sort = $param->SortExpression;
- $this->showProjects($sort, $this->getSortOrdering($sort));
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- $this->showProjects();
- }
-}
-
+<?php
+
+class ProjectList extends TPage
+{
+ protected function showProjects($sort='', $order='')
+ {
+ $dao = $this->Application->Modules['daos']->getDao('ProjectDao');
+ $this->projectList->DataSource = $dao->getAllProjects($sort, $order);
+ $this->projectList->dataBind();
+ }
+
+ protected function getSortOrdering($sort)
+ {
+ $ordering = $this->getViewState('SortOrder', array());
+ $order = isset($ordering[$sort]) ? $ordering[$sort] : 'DESC';
+ $ordering[$sort] = $order == 'DESC' ? 'ASC' : 'DESC';
+ $this->setViewState('SortOrder', $ordering);
+ return $ordering[$sort];
+ }
+
+ protected function sortProjects($sender, $param)
+ {
+ $sort = $param->SortExpression;
+ $this->showProjects($sort, $this->getSortOrdering($sort));
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ $this->showProjects();
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php
index fcb1c865..6ce849b9 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php
@@ -1,53 +1,53 @@
-<?php
-
-class ReportProject extends TPage
-{
- protected function getProjects()
- {
- $projectDao = $this->Application->Modules['daos']->getDao('ProjectDao');
- $projects = array();
- foreach($projectDao->getAllProjects() as $project)
- $projects[$project->ID] = $project->Name;
- return $projects;
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $this->projectList->DataSource = $this->getProjects();
- $this->dataBind();
- }
- }
-
- public function generateReport_Clicked($sender, $param)
- {
- if(count($this->projectList->SelectedValues) > 0)
- $this->showReport();
- }
-
- protected function showReport()
- {
- $reportDao = $this->Application->Modules['daos']->getDao('ReportDao');
- $reports = $reportDao->getTimeReportsByProjectIDs($this->projectList->SelectedValues);
- $this->views->ActiveViewIndex = 1;
- $this->projects->DataSource = $reports;
- $this->projects->dataBind();
- }
-
- public function project_itemCreated($sender, $param)
- {
- $item = $param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- $item->category->DataSource = $item->DataItem->Categories;
- }
-
- public function category_itemCreated($sender, $param)
- {
- $item = $param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- $item->members->DataSource = $item->DataItem->members;
- }
-}
-
+<?php
+
+class ReportProject extends TPage
+{
+ protected function getProjects()
+ {
+ $projectDao = $this->Application->Modules['daos']->getDao('ProjectDao');
+ $projects = array();
+ foreach($projectDao->getAllProjects() as $project)
+ $projects[$project->ID] = $project->Name;
+ return $projects;
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->projectList->DataSource = $this->getProjects();
+ $this->dataBind();
+ }
+ }
+
+ public function generateReport_Clicked($sender, $param)
+ {
+ if(count($this->projectList->SelectedValues) > 0)
+ $this->showReport();
+ }
+
+ protected function showReport()
+ {
+ $reportDao = $this->Application->Modules['daos']->getDao('ReportDao');
+ $reports = $reportDao->getTimeReportsByProjectIDs($this->projectList->SelectedValues);
+ $this->views->ActiveViewIndex = 1;
+ $this->projects->DataSource = $reports;
+ $this->projects->dataBind();
+ }
+
+ public function project_itemCreated($sender, $param)
+ {
+ $item = $param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ $item->category->DataSource = $item->DataItem->Categories;
+ }
+
+ public function category_itemCreated($sender, $param)
+ {
+ $item = $param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ $item->members->DataSource = $item->DataItem->members;
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php
index 65283417..26644bc9 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php
@@ -1,71 +1,71 @@
-<?php
-
-class ReportResource extends TPage
-{
- protected function getProjects()
- {
- $projectDao = $this->Application->Modules['daos']->getDao('ProjectDao');
- $projects = array();
- foreach($projectDao->getAllProjects() as $project)
- $projects[$project->ID] = $project->Name;
- return $projects;
- }
-
- protected function getUsers()
- {
- $dao = $this->Application->Modules['daos']->getDao('UserDao');
- $users = array();
- foreach($dao->getAllUsers() as $user)
- {
- $users[$user->Name] = $user->Name;
- }
- return $users;
- }
-
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $this->projectList->DataSource = $this->getProjects();
- $this->resourceList->DataSource = $this->getUsers();
- $this->dataBind();
- }
- }
-
- public function generateReport_Clicked($sender, $param)
- {
- if(count($this->projectList->SelectedValues) > 0
- && count($this->resourceList->SelectedValues) >0)
- {
- $this->showReport();
- }
- }
-
- protected function showReport()
- {
- $this->views->ActiveViewIndex = 1;
- $reportDao = $this->Application->Modules['daos']->getDao('ReportDao');
- $projects = $this->projectList->SelectedValues;
- $users = $this->resourceList->SelectedValues;
- $start = $this->dateFrom->TimeStamp;
- $end = $this->dateTo->TimeStamp;
-
- $report = $reportDao->getUserProjectTimeReports($users, $projects, $start, $end);
-
- $this->resource_report->DataSource = $report;
- $this->resource_report->dataBind();
- }
-
- public function resource_report_itemCreated($sender, $param)
- {
- $item = $param->Item;
- if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
- {
- if(count($item->DataItem->Projects) > 0 &&
- $item->DataItem->Projects[0]->ProjectName !== null)
- $item->time_entries->DataSource = $item->DataItem->Projects;
- }
- }
-}
-
+<?php
+
+class ReportResource extends TPage
+{
+ protected function getProjects()
+ {
+ $projectDao = $this->Application->Modules['daos']->getDao('ProjectDao');
+ $projects = array();
+ foreach($projectDao->getAllProjects() as $project)
+ $projects[$project->ID] = $project->Name;
+ return $projects;
+ }
+
+ protected function getUsers()
+ {
+ $dao = $this->Application->Modules['daos']->getDao('UserDao');
+ $users = array();
+ foreach($dao->getAllUsers() as $user)
+ {
+ $users[$user->Name] = $user->Name;
+ }
+ return $users;
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->projectList->DataSource = $this->getProjects();
+ $this->resourceList->DataSource = $this->getUsers();
+ $this->dataBind();
+ }
+ }
+
+ public function generateReport_Clicked($sender, $param)
+ {
+ if(count($this->projectList->SelectedValues) > 0
+ && count($this->resourceList->SelectedValues) >0)
+ {
+ $this->showReport();
+ }
+ }
+
+ protected function showReport()
+ {
+ $this->views->ActiveViewIndex = 1;
+ $reportDao = $this->Application->Modules['daos']->getDao('ReportDao');
+ $projects = $this->projectList->SelectedValues;
+ $users = $this->resourceList->SelectedValues;
+ $start = $this->dateFrom->TimeStamp;
+ $end = $this->dateTo->TimeStamp;
+
+ $report = $reportDao->getUserProjectTimeReports($users, $projects, $start, $end);
+
+ $this->resource_report->DataSource = $report;
+ $this->resource_report->dataBind();
+ }
+
+ public function resource_report_itemCreated($sender, $param)
+ {
+ $item = $param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ if(count($item->DataItem->Projects) > 0 &&
+ $item->DataItem->Projects[0]->ProjectName !== null)
+ $item->time_entries->DataSource = $item->DataItem->Projects;
+ }
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
index dde4b44d..cb923178 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.php
@@ -1,57 +1,57 @@
-<?php
-/**
- * SiteMap template class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Demos
- */
-
-/**
- * SiteMap menu is rendered depending on user roles.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package Demos
- * @since 3.1
- */
-class SiteMap extends TTemplateControl
-{
- /**
- * Sets the active menu item using css class.
- */
- public function onPreRender($param)
- {
- parent::onPreRender($param);
-
- $page = explode('.',$this->Request->ServiceParameter);
- $active = null;
- switch($page[count($page)-1])
- {
- case 'ProjectList':
- case 'ProjectDetails':
- $active = $this->ProjectMenu;
- break;
- case 'UserList':
- case 'UserCreate':
- $active = $this->AdminMenu;
- break;
- case 'ReportProject':
- case 'ReportResource':
- $active = $this->ReportMenu;
- break;
- default:
- $active = $this->LogMenu;
- break;
- }
-
- //add 'active' string to place holder body.
- if(!is_null($active))
- $active->Controls[] = 'active';
- }
-}
-
+<?php
+/**
+ * SiteMap template class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package Demos
+ */
+
+/**
+ * SiteMap menu is rendered depending on user roles.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package Demos
+ * @since 3.1
+ */
+class SiteMap extends TTemplateControl
+{
+ /**
+ * Sets the active menu item using css class.
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+
+ $page = explode('.',$this->Request->ServiceParameter);
+ $active = null;
+ switch($page[count($page)-1])
+ {
+ case 'ProjectList':
+ case 'ProjectDetails':
+ $active = $this->ProjectMenu;
+ break;
+ case 'UserList':
+ case 'UserCreate':
+ $active = $this->AdminMenu;
+ break;
+ case 'ReportProject':
+ case 'ReportResource':
+ $active = $this->ReportMenu;
+ break;
+ default:
+ $active = $this->LogMenu;
+ break;
+ }
+
+ //add 'active' string to place holder body.
+ if(!is_null($active))
+ $active->Controls[] = 'active';
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
index ee3f4bb2..0730505f 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
@@ -1,89 +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 CategoryRecord;
- $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;
- }
- }
-}
-
+<?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 CategoryRecord;
+ $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
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
index 8ee077ac..eddb87cb 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserCreate.php
@@ -1,112 +1,112 @@
-<?php
-/**
- * UserCreate page class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Demos
- */
-
-/**
- * Create new user wizard page class. Validate that the usernames are unique and
- * set the new user credentials as the current application credentials.
- *
- * If logged in as admin, the user role can be change during creation.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package Demos
- * @since 3.1
- */
-class UserCreate extends TPage
-{
- /**
- * Sets the default new user roles, default role is set in config.xml
- */
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- {
- $this->role->SelectedValue =
- $this->Application->Parameters['NewUserRoles'];
- }
- }
-
- /**
- * Verify that the username is not taken.
- * @param TControl custom validator that created the event.
- * @param TServerValidateEventParameter validation parameters.
- */
- public function checkUsername($sender, $param)
- {
- $userDao = $this->Application->Modules['daos']->getDao('UserDao');
- if($userDao->usernameExists($this->username->Text))
- {
- $param->IsValid = false;
- $sender->ErrorMessage =
- "The user name is already taken, try '{$this->username->Text}01'";
- }
- }
-
- /**
- * Skip the role assignment step if not admin.
- */
- public function userWizardNextStep($sender, $param)
- {
- if($param->CurrentStepIndex == 0)
- {
- //create user with admin credentials
- if(!$this->User->isInRole('admin'))
- {
- $this->createNewUser($sender, $param);
- $param->NextStepIndex = 2;
- }
- }
- }
-
- /**
- * Create a new user if all data entered are valid.
- * The default user roles are obtained from "config.xml". The new user
- * details is saved to the database and the new credentials are used as the
- * application user. The user is redirected to the requested page.
- * @param TControl button control that created the event.
- * @param TEventParameter event parameters.
- */
- public function createNewUser($sender, $param)
- {
- if($this->IsValid)
- {
- $newUser = new TimeTrackerUser($this->User->Manager);
- $newUser->EmailAddress = $this->email->Text;
- $newUser->Name = $this->username->Text;
- $newUser->IsGuest = false;
- $newUser->Roles = $this->role->SelectedValue;
-
- //save the user
- $userDao = $this->Application->Modules['daos']->getDao('UserDao');
- $userDao->addNewUser($newUser, $this->password->Text);
-
- //update the user credentials if not admin
- if(!$this->User->isInRole('admin'))
- {
- $auth = $this->Application->getModule('auth');
- $auth->updateCredential($newUser);
- }
- }
- }
-
- /**
- * Continue with requested page.
- */
- public function wizardCompleted($sender, $param)
- {
- //return to requested page
- $auth = $this->Application->getModule('auth');
- $this->Response->redirect($auth->getReturnUrl());
- }
-}
-
+<?php
+/**
+ * UserCreate page class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package Demos
+ */
+
+/**
+ * Create new user wizard page class. Validate that the usernames are unique and
+ * set the new user credentials as the current application credentials.
+ *
+ * If logged in as admin, the user role can be change during creation.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package Demos
+ * @since 3.1
+ */
+class UserCreate extends TPage
+{
+ /**
+ * Sets the default new user roles, default role is set in config.xml
+ */
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->role->SelectedValue =
+ $this->Application->Parameters['NewUserRoles'];
+ }
+ }
+
+ /**
+ * Verify that the username is not taken.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ public function checkUsername($sender, $param)
+ {
+ $userDao = $this->Application->Modules['daos']->getDao('UserDao');
+ if($userDao->usernameExists($this->username->Text))
+ {
+ $param->IsValid = false;
+ $sender->ErrorMessage =
+ "The user name is already taken, try '{$this->username->Text}01'";
+ }
+ }
+
+ /**
+ * Skip the role assignment step if not admin.
+ */
+ public function userWizardNextStep($sender, $param)
+ {
+ if($param->CurrentStepIndex == 0)
+ {
+ //create user with admin credentials
+ if(!$this->User->isInRole('admin'))
+ {
+ $this->createNewUser($sender, $param);
+ $param->NextStepIndex = 2;
+ }
+ }
+ }
+
+ /**
+ * Create a new user if all data entered are valid.
+ * The default user roles are obtained from "config.xml". The new user
+ * details is saved to the database and the new credentials are used as the
+ * application user. The user is redirected to the requested page.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ public function createNewUser($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $newUser = new TimeTrackerUser($this->User->Manager);
+ $newUser->EmailAddress = $this->email->Text;
+ $newUser->Name = $this->username->Text;
+ $newUser->IsGuest = false;
+ $newUser->Roles = $this->role->SelectedValue;
+
+ //save the user
+ $userDao = $this->Application->Modules['daos']->getDao('UserDao');
+ $userDao->addNewUser($newUser, $this->password->Text);
+
+ //update the user credentials if not admin
+ if(!$this->User->isInRole('admin'))
+ {
+ $auth = $this->Application->getModule('auth');
+ $auth->updateCredential($newUser);
+ }
+ }
+ }
+
+ /**
+ * Continue with requested page.
+ */
+ public function wizardCompleted($sender, $param)
+ {
+ //return to requested page
+ $auth = $this->Application->getModule('auth');
+ $this->Response->redirect($auth->getReturnUrl());
+ }
+}
+
?> \ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserList.php b/demos/time-tracker/protected/pages/TimeTracker/UserList.php
index 22974d29..ad35a758 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserList.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserList.php
@@ -1,34 +1,34 @@
-<?php
-/**
- * UserList page class file.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2006 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package Demos
- */
-
-/**
- * List all users in a repeater.
- *
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Id$
- * @package Demos
- * @since 3.1
- */
-class UserList extends TPage
-{
- /**
- * Load all the users and display them in a repeater.
- */
- function onLoad($param)
- {
- $userDao = $this->Application->Modules['daos']->getDao('UserDao');
- $this->list->DataSource = $userDao->getAllUsers();
- $this->list->dataBind();
- }
-}
-
+<?php
+/**
+ * UserList page class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005-2006 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package Demos
+ */
+
+/**
+ * List all users in a repeater.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Id$
+ * @package Demos
+ * @since 3.1
+ */
+class UserList extends TPage
+{
+ /**
+ * Load all the users and display them in a repeater.
+ */
+ function onLoad($param)
+ {
+ $userDao = $this->Application->Modules['daos']->getDao('UserDao');
+ $this->list->DataSource = $userDao->getAllUsers();
+ $this->list->dataBind();
+ }
+}
+
?> \ No newline at end of file