Skip to content

Commit caca6a9

Browse files
committed
added support for no aggregation reports
1 parent 8d24230 commit caca6a9

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Time Tracker</name>
66
<summary>Time Tracker App</summary>
77
<description><![CDATA[Time Tracker App]]></description>
8-
<version>0.0.37</version>
8+
<version>0.0.38</version>
99
<licence>agpl</licence>
1010
<author mail="[email protected]" >MTier Ltd.</author>
1111
<namespace>TimeTracker</namespace>

js/reports.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
//{title:"Id", field:"id", width:100}, //column has a fixed width of 100px;
166166
{title:"#", field:"", formatter:"rownum"},
167167
{title:"Name", field:"name", widthGrow:1}, //column will be allocated 1/5 of the remaining space
168+
{title:"Details", field:"details", widthGrow:1}, //column will be allocated 1/5 of the remaining space
168169
{title:"User", field:"userUid", widthGrow:1}, //column will be allocated 1/5 of the remaining space
169170
{title:"Project", field:"project", widthGrow:1}, //column will be allocated 1/5 of the remaining space
170171
{title:"Client", field:"client", widthGrow:1}, //column will be allocated 1/5 of the remaining space
@@ -187,11 +188,11 @@
187188
return response.items; //return the tableData property of a response json object
188189
},
189190
});
190-
$("#download-csv").click(function(){
191+
$("#download-csv").off().click(function(){
191192
table.download("csv", "data.csv");
192193
return false;
193194
});
194-
$("#download-json").click(function(){
195+
$("#download-json").off().click(function(){
195196
table.download("json", "data.json");
196197
return false;
197198
});

lib/Db/ReportItem.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ReportItem extends Entity {
88

99
public $id;
1010
public $name;
11+
public $details;
1112
public $projectId;
1213
public $userUid;
1314
public $time;
@@ -23,6 +24,7 @@ public function __construct() {
2324

2425
$this->addType('id', 'integer');
2526
$this->addType('name', 'string');
27+
$this->addType('name', 'details');
2628
$this->addType('projectId', 'integer');
2729
$this->addType('userUid', 'string');
2830
$this->addType('time', 'string');

lib/Db/ReportItemMapper.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
5151
}
5252
} else {
5353
if(empty($timegroup)){
54-
$selectFields[]= "DATE_FORMAT(FROM_UNIXTIME(min(start)),'%Y-%m-%d') as time";
54+
if (empty($groupOn1) && empty($groupOn2)) {
55+
$selectFields[]= "DATE_FORMAT(FROM_UNIXTIME(start),'%Y-%m-%d %H:%i') as time";
56+
} else {
57+
$selectFields[]= "DATE_FORMAT(FROM_UNIXTIME(min(start)),'%Y-%m-%d') as time";
58+
}
5559
} elseif ($timegroup == 'week') {
5660
$selectFields[]= "STR_TO_DATE(CONCAT(YEARWEEK(FROM_UNIXTIME(start)),' Monday'), '%x%v %W') as time";
5761
}elseif ($timegroup == 'day') {
@@ -63,7 +67,7 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
6367
}
6468

6569
}
66-
if(($groupOn1 != 'name') && ($groupOn2 != 'name')){
70+
if(($groupOn1 != 'name') && ($groupOn2 != 'name') && !empty($groupOn1) && !empty($groupOn2)){
6771
if ($this->dbengine != 'MYSQL') {
6872
$selectFields[] = '\'*\' as name';
6973
} else {
@@ -73,7 +77,14 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
7377
} else {
7478
$selectFields[] = 'wi.name as name';
7579
}
76-
if(($groupOn1 != 'project') && ($groupOn2 != 'project')){
80+
81+
if(($groupOn1 != 'name') && ($groupOn2 != 'name') && !empty($groupOn1) && !empty($groupOn2)){
82+
$selectFields[] = '\'*\' as details';
83+
} else {
84+
$selectFields[] = 'wi.details as details';
85+
}
86+
87+
if(($groupOn1 != 'project') && ($groupOn2 != 'project' && !empty($groupOn1) && !empty($groupOn2))){
7788
$selectFields[] = '\'*\' as "projectId"';
7889
if ($this->dbengine != 'MYSQL') {
7990
$selectFields[] = 'string_agg(distinct p.name, \',\') as project';
@@ -198,6 +209,8 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
198209
}
199210
if (!empty($groups)){
200211
$group = "group by ".implode(",",$groups);
212+
} else {
213+
$group = "group by wi.id";
201214
}
202215
if (empty($start)){
203216
$start = 0;
@@ -206,7 +219,7 @@ public function report($user, $from, $to, $filterProjectId, $filterClientId, $fi
206219
$limit = 10000;
207220
}
208221
$sql = 'SELECT '.$selectItems.' where '.implode(" and ",$filters).' '.$group. ' order by time desc';
209-
// var_dump($sql);
222+
//var_dump($sql);
210223
// var_dump($params);
211224
return $this->findEntities($sql, $params, $limit, $start);
212225
}

templates/content/reports.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
<div class="group-controls">
3131
<label for="group1">
3232
Group by
33-
<select id="group1" style="width: 200px;">>
34-
<option value="project">Project</option>
33+
<select id="group1" style="width: 200px;">
34+
<option value="">None</option>
35+
<option value="project" selected>Project</option>
3536
<option value="userUid">User</option>
3637
<option value="client">Client</option>
3738
</select>
@@ -41,12 +42,13 @@
4142
<select id="group2" style="width: 200px;">
4243
<option value="">None</option>
4344
<option value="name">Time Entry</option>
44-
<option value="userUid">User</option>
45+
<option value="userUid" selected >User</option>
4546
<option value="project">Project</option>
4647
</select>
4748
</label>
4849
<select id="group3" style="width: 200px;">
49-
<option value="day">Daily</option>
50+
<option value="">None</option>
51+
<option value="day" selected>Daily</option>
5052
<option value="week">Weekly</option>
5153
<option value="month">Monthly</option>
5254
<option value="year">Yearly</option>

0 commit comments

Comments
 (0)