diff options
Diffstat (limited to 'demos/time-tracker/protected/pages')
3 files changed, 126 insertions, 15 deletions
diff --git a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php index a134289c..28611c3c 100644 --- a/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php +++ b/demos/time-tracker/protected/pages/TimeTracker/LogTimeEntry.php @@ -88,21 +88,24 @@ class LogTimeEntry extends TPage if(!$this->IsValid)
return;
- $entry = new TimeEntry;
- $entry->CreatorUserName = $this->User->Name;
- $category = new Category;
- $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();
+ if($this->projectMembers->SelectedItem)
+ {
+ $entry = new TimeEntry;
+ $entry->CreatorUserName = $this->User->Name;
+ $category = new Category;
+ $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();
+ }
}
}
diff --git a/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php new file mode 100644 index 00000000..fea372be --- /dev/null +++ b/demos/time-tracker/protected/pages/TimeTracker/ReportProject.php @@ -0,0 +1,47 @@ +<?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)
+ {
+ $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 new file mode 100644 index 00000000..a233e127 --- /dev/null +++ b/demos/time-tracker/protected/pages/TimeTracker/ReportResource.php @@ -0,0 +1,61 @@ +<?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)
+ {
+ $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 |