From 994065ffd524ade2db3de900226143f5123c5fb1 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 28 Jul 2006 06:24:40 +0000 Subject: Update time-tracker --- .gitattributes | 2 + .../time-tracker/protected/App_Code/ReportsDao.php | 12 ----- .../protected/App_Code/TimeEntryDao.php | 9 ---- demos/time-tracker/protected/App_Code/UserDao.php | 4 +- demos/time-tracker/protected/application.xml | 3 ++ .../protected/pages/TimeTracker/LogTimeEntry.php | 33 ++++++------ .../protected/pages/TimeTracker/ReportProject.php | 47 +++++++++++++++++ .../protected/pages/TimeTracker/ReportResource.php | 61 ++++++++++++++++++++++ .../tests/unit/CategoryDaoTestCase.php | 4 +- .../tests/unit/TimeEntryDaoTestCase.php | 53 ------------------- 10 files changed, 134 insertions(+), 94 deletions(-) create mode 100644 demos/time-tracker/protected/pages/TimeTracker/ReportProject.php create mode 100644 demos/time-tracker/protected/pages/TimeTracker/ReportResource.php diff --git a/.gitattributes b/.gitattributes index 4a11530d..76bab26e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1126,7 +1126,9 @@ demos/time-tracker/protected/pages/TimeTracker/ProjectDetails.php -text demos/time-tracker/protected/pages/TimeTracker/ProjectList.page -text demos/time-tracker/protected/pages/TimeTracker/ProjectList.php -text demos/time-tracker/protected/pages/TimeTracker/ReportProject.page -text +demos/time-tracker/protected/pages/TimeTracker/ReportProject.php -text demos/time-tracker/protected/pages/TimeTracker/ReportResource.page -text +demos/time-tracker/protected/pages/TimeTracker/ReportResource.php -text demos/time-tracker/protected/pages/TimeTracker/SiteMap.php -text demos/time-tracker/protected/pages/TimeTracker/SiteMap.tpl -text demos/time-tracker/protected/pages/TimeTracker/TimeEntryList.php -text diff --git a/demos/time-tracker/protected/App_Code/ReportsDao.php b/demos/time-tracker/protected/App_Code/ReportsDao.php index 8d2e2627..50005d06 100644 --- a/demos/time-tracker/protected/App_Code/ReportsDao.php +++ b/demos/time-tracker/protected/App_Code/ReportsDao.php @@ -61,18 +61,6 @@ class UserProjectReport class ReportsDao extends BaseDao { - public function getUserTimeReport($username) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForObject('GetTimeReportByUsername', $username); - } - - public function getTimeReportsByCategoryID($categoryID) - { - $sqlmap = $this->getConnection(); - return $sqlmap->queryForList('GetTimeReportByCategoryID', $categoryID); - } - public function getTimeReportsByProjectIDs($projects) { $ids = implode(',', array_map('intval', $projects)); diff --git a/demos/time-tracker/protected/App_Code/TimeEntryDao.php b/demos/time-tracker/protected/App_Code/TimeEntryDao.php index 60301f3b..7207ed47 100644 --- a/demos/time-tracker/protected/App_Code/TimeEntryDao.php +++ b/demos/time-tracker/protected/App_Code/TimeEntryDao.php @@ -33,15 +33,6 @@ class TimeEntryDao extends BaseDao $sqlmap = $this->getConnection(); $sqlmap->update('UpdateTimeEntry', $entry); } - - public function getTimeEntriesByDate($username, $start, $end) - { - $sqlmap = $this->getConnection(); - $param['username'] = $username; - $param['startDate'] = $start; - $param['endDate'] = $end; - return $sqlmap->queryForList('GetTimeEntriesByDate', $param); - } } ?> \ No newline at end of file diff --git a/demos/time-tracker/protected/App_Code/UserDao.php b/demos/time-tracker/protected/App_Code/UserDao.php index a0a80f7e..95a85410 100644 --- a/demos/time-tracker/protected/App_Code/UserDao.php +++ b/demos/time-tracker/protected/App_Code/UserDao.php @@ -30,9 +30,7 @@ class UserDao extends BaseDao public function getUserByName($username) { $sqlmap = $this->getConnection(); - $user = $sqlmap->queryForObject('GetUserByName', $username); - var_dump($user); - return $user; + return $sqlmap->queryForObject('GetUserByName', $username); } /** diff --git a/demos/time-tracker/protected/application.xml b/demos/time-tracker/protected/application.xml index 1622073e..98dc3a79 100644 --- a/demos/time-tracker/protected/application.xml +++ b/demos/time-tracker/protected/application.xml @@ -10,9 +10,12 @@ + + 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 @@ +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 @@ +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 diff --git a/demos/time-tracker/tests/unit/CategoryDaoTestCase.php b/demos/time-tracker/tests/unit/CategoryDaoTestCase.php index 53ed9c3e..4b13a948 100644 --- a/demos/time-tracker/tests/unit/CategoryDaoTestCase.php +++ b/demos/time-tracker/tests/unit/CategoryDaoTestCase.php @@ -125,11 +125,11 @@ class CategoryDaoTestCase extends BaseTestCase try { $this->categoryDao->addNewCategory($category); - $this->fail(); + $this->pass(); } catch(TSqlMapQueryExecutionException $e) { - $this->pass(); + $this->fail(); } $check = $this->categoryDao->getCategoryByID(1); $this->assertEqual($category, $check); diff --git a/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php b/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php index 20b1266e..cd1044b8 100644 --- a/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php +++ b/demos/time-tracker/tests/unit/TimeEntryDaoTestCase.php @@ -209,59 +209,6 @@ class TimeEntryDaoTestCase extends BaseTestCase $this->assertSameEntry($entry, $verify); } - - function testgetEntriesByDate() - { - $added = $this->createTimeEntries2(); - $this->entryDao->addNewTimeEntry($added[0]); - $this->entryDao->addNewTimeEntry($added[1]); - - $start = strtotime('-5 days'); - $end = strtotime('-1 day'); - $list = $this->entryDao->getTimeEntriesByDate('consultant', $start, $end); - - $this->assertEqual(count($list),1); - - $this->assertSameEntry($list[0], $added[1]); - } - - function testUserTimeReports() - { - $added = $this->createTimeEntries2(); - $this->entryDao->addNewTimeEntry($added[0]); - $this->entryDao->addNewTimeEntry($added[1]); - - $time = $this->reportDao->getUserTimeReport('consultant'); - $this->assertEqual($time, 6.7); - } - - - function testTimeReportsByCategory() - { - $added = $this->createTimeEntries2(); - $this->entryDao->addNewTimeEntry($added[0]); - $this->entryDao->addNewTimeEntry($added[1]); - - $list = $this->reportDao->getTimeReportsByCategoryID(1); - $this->assertEqual(count($list),1); - $this->assertEqual($list[0]->Username, 'consultant'); - $this->assertEqual($list[0]->ActualDuration, 1.2); - } - - function testTimeReportsByProject() - { - $added = $this->createTimeEntries2(); - $this->entryDao->addNewTimeEntry($added[0]); - $this->entryDao->addNewTimeEntry($added[1]); - - $list = $this->reportDao->getTimeReportsByProjectID(1); - - $this->assertEqual(count($list),1); - $this->assertEqual($list[0]->Username, 'consultant'); - $this->assertEqual($list[0]->CategoryID, 1); - $this->assertEqual($list[0]->ActualDuration, 6.7); - } - } ?> \ No newline at end of file -- cgit v1.2.3