| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class ReportResource extends TPage
|
|
|
4 |
{
|
|
|
5 |
protected function getProjects()
|
|
|
6 |
{
|
|
|
7 |
$projectDao = $this->Application->Modules['daos']->getDao('ProjectDao');
|
|
|
8 |
$projects = array();
|
|
|
9 |
foreach($projectDao->getAllProjects() as $project)
|
|
|
10 |
$projects[$project->ID] = $project->Name;
|
|
|
11 |
return $projects;
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
protected function getUsers()
|
|
|
15 |
{
|
|
|
16 |
$dao = $this->Application->Modules['daos']->getDao('UserDao');
|
|
|
17 |
$users = array();
|
|
|
18 |
foreach($dao->getAllUsers() as $user)
|
|
|
19 |
{
|
|
|
20 |
$users[$user->Name] = $user->Name;
|
|
|
21 |
}
|
|
|
22 |
return $users;
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
public function onLoad($param)
|
|
|
26 |
{
|
|
|
27 |
if(!$this->IsPostBack)
|
|
|
28 |
{
|
|
|
29 |
$this->projectList->DataSource = $this->getProjects();
|
|
|
30 |
$this->resourceList->DataSource = $this->getUsers();
|
|
|
31 |
$this->dataBind();
|
|
|
32 |
}
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public function generateReport_Clicked($sender, $param)
|
|
|
36 |
{
|
|
|
37 |
if(count($this->projectList->SelectedValues) > 0
|
|
|
38 |
&& count($this->resourceList->SelectedValues) >0)
|
|
|
39 |
{
|
|
|
40 |
$this->showReport();
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
protected function showReport()
|
|
|
45 |
{
|
|
|
46 |
$this->views->ActiveViewIndex = 1;
|
|
|
47 |
$reportDao = $this->Application->Modules['daos']->getDao('ReportDao');
|
|
|
48 |
$projects = $this->projectList->SelectedValues;
|
|
|
49 |
$users = $this->resourceList->SelectedValues;
|
|
|
50 |
$start = $this->dateFrom->TimeStamp;
|
|
|
51 |
$end = $this->dateTo->TimeStamp;
|
|
|
52 |
|
|
|
53 |
$report = $reportDao->getUserProjectTimeReports($users, $projects, $start, $end);
|
|
|
54 |
|
|
|
55 |
$this->resource_report->DataSource = $report;
|
|
|
56 |
$this->resource_report->dataBind();
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public function resource_report_itemCreated($sender, $param)
|
|
|
60 |
{
|
|
|
61 |
$item = $param->Item;
|
|
|
62 |
if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
|
|
|
63 |
{
|
|
|
64 |
if(count($item->DataItem->Projects) > 0 &&
|
|
|
65 |
$item->DataItem->Projects[0]->ProjectName !== null)
|
|
|
66 |
$item->time_entries->DataSource = $item->DataItem->Projects;
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
?>
|