Define the project and specify which users will be part of the project.
@@ -10,22 +10,51 @@
-
-
-
+
+ Define Project Categories for Project Management
+
+ Categories can be added in two ways. You can ADD a category
+ by specifying name, abbreviation, and duration -
+ the amount of hours that may be charged under the category. Or,
+ You can COPY categories that already have been defined in
+ another project to this project.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Press the SAVE button for your configuration to take effect.
+ deleteButton->Visible %>>
+ Press the DELETE button to delete the current project.
+
+
+
+
+
+
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
index 16c10e6f..767e259c 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php
@@ -2,7 +2,30 @@
class ProjectDetails extends TPage
{
- private $allUsers = null;
+ 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)
{
@@ -12,7 +35,53 @@ class ProjectDetails extends TPage
$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)
@@ -26,10 +95,97 @@ class ProjectDetails extends TPage
foreach($this->allUsers as $user)
{
if($user->isInRole($role))
- $users[] = $user->Name;
+ $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 Project;
+
+ $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.page b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page
index 1bc50a4b..f55360c4 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.page
@@ -1,4 +1,42 @@
-Projects
+Projects
+
+
\ 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
new file mode 100644
index 00000000..eb92dcb7
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/ProjectList.php
@@ -0,0 +1,34 @@
+Application->Modules['daos']->getDao('ProjectDao');
+ $this->projectList->DataSource = $dao->getAllProjects($sort, $order);
+ $this->projectList->dataBind();
+ }
+
+ protected function getSortOrder($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->getSortOrder($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.page b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page
index 699c2544..065b6b17 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.page
@@ -1,4 +1,17 @@
-Project Reports
+Project Reports
+
+
\ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
index 808c233b..5bea2811 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
+++ b/demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl
@@ -1,7 +1,7 @@
">
-
+
User->isInRole('manager') %> >
">
diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page b/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page
deleted file mode 100644
index f934ca02..00000000
--- a/demos/time-tracker/protected/pages/TimeTracker/TimeEntry.page
+++ /dev/null
@@ -1,4 +0,0 @@
-
-Time Entry
-
-
\ 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
new file mode 100644
index 00000000..2b5f7a0f
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php
@@ -0,0 +1,89 @@
+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
diff --git a/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.tpl b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.tpl
new file mode 100644
index 00000000..ace8a95b
--- /dev/null
+++ b/demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.tpl
@@ -0,0 +1,66 @@
+
+
+ There are no time entries for this user.
+
+
+
+
+ Category Name |
+ Description |
+ Duration |
+ Reported Date |
+ Edit/Delete |
+
+
+
+
+
+
+
+
+ <%# $this->DataItem->Category->Name %> |
+ <%# $this->DataItem->Description %> |
+ <%# $this->DataItem->Duration %> |
+
+ DataItem->ReportDate %> />
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+ DataItem->Description %> />
+ |
+
+ DataItem->Duration %> />
+ |
+
+ DataItem->ReportDate %> />
+ |
+
+
+
+ |
+
+
+
+
\ No newline at end of file
diff --git a/demos/time-tracker/protected/pages/TimeTracker/UserList.page b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
index f0c88112..3696e1db 100644
--- a/demos/time-tracker/protected/pages/TimeTracker/UserList.page
+++ b/demos/time-tracker/protected/pages/TimeTracker/UserList.page
@@ -1,31 +1,20 @@
-List Users
+Users