diff options
author | wei <> | 2006-07-28 06:06:32 +0000 |
---|---|---|
committer | wei <> | 2006-07-28 06:06:32 +0000 |
commit | 5fc75a5f53fa07971b604c5318da5bf07379ef89 (patch) | |
tree | 2a88f91df64f0182e245e3b87ee3c2658fdc06aa /demos/time-tracker/protected/App_Code/ReportsDao.php | |
parent | caa348ceabba58447bf8deddb8c6316ff3dc88ce (diff) |
Complete Time-Tracker demo app.
Diffstat (limited to 'demos/time-tracker/protected/App_Code/ReportsDao.php')
-rw-r--r-- | demos/time-tracker/protected/App_Code/ReportsDao.php | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/App_Code/ReportsDao.php b/demos/time-tracker/protected/App_Code/ReportsDao.php new file mode 100644 index 00000000..8d2e2627 --- /dev/null +++ b/demos/time-tracker/protected/App_Code/ReportsDao.php @@ -0,0 +1,99 @@ +<?php
+
+class ProjectReport extends TComponent
+{
+ public $ProjectName = '';
+ public $EstimateHours = 0;
+ public $EstimateCompletion = 0;
+ public $Categories;
+
+ public function __construct()
+ {
+ $this->Categories = new TList;
+ }
+
+ public function getActualHours()
+ {
+ $total = 0;
+ foreach($this->Categories as $cat)
+ $total += $cat->getActualHours();
+ return $total;
+ }
+}
+
+class CategoryReport extends TComponent
+{
+ public $CategoryName = '';
+ public $EstimateHours = 0;
+ public $members = array();
+
+ public function getActualHours()
+ {
+ $total = 0;
+ foreach($this->members as $member)
+ $total += $member['hours'];
+ return $total;
+ }
+}
+
+class UserReport extends TComponent
+{
+ public $Username;
+ public $Projects = array();
+
+ public function getTotalHours()
+ {
+ $hours = 0;
+ foreach($this->Projects as $project)
+ $hours += $project->Duration;
+ return $hours;
+ }
+}
+
+class UserProjectReport
+{
+ public $ProjectName = '';
+ public $CategoryName = '';
+ public $Duration = 0;
+ public $Description='';
+ public $ReportDate=0;
+}
+
+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));
+ $sqlmap = $this->getConnection();
+ return $sqlmap->queryForList('GetTimeReportByProjectIDs', $ids);
+ }
+
+ public function getUserProjectTimeReports($users, $projects, $startDate, $endDate)
+ {
+ $sqlmap = $this->getConnection();
+ $driver = $sqlmap->openConnection();
+ $ids = implode(',', array_map('intval', $projects));
+ $usernames = implode(',', array_map(array($driver, 'quote'), $users));
+
+ $param['projects'] = $ids;
+ $param['members'] = $usernames;
+ $param['startDate'] = intval($startDate);
+ $param['endDate'] = intval($endDate);
+
+ return $sqlmap->queryForList('GetTimeReportByUsername', $param);
+ }
+}
+
+?>
\ No newline at end of file |