Skip to content

Commit 93762fc

Browse files
committed
fix #56
1 parent 8bf67d6 commit 93762fc

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

js/timer.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
$( function() {
7-
var days='31';
8-
var start = moment().subtract(29, 'days');
9-
var end = moment();
7+
var days='30';
8+
var start = moment().startOf('day').subtract(29, 'days');
9+
var end = moment().endOf('day');
1010

1111
function cb(start, end) {
1212
$('#report-range span').html(start.format('DD/MM/YY') + ' - ' + end.format('DD/MM/YY'));
@@ -15,25 +15,25 @@
1515
timePicker: false,
1616
startDate: start,
1717
endDate: end,
18+
showCustomRangeLabel: false,
1819
ranges: {
19-
'Today': [moment(), moment()],
20-
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
21-
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
22-
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
23-
'Last 90 Days': [moment().subtract(89, 'days'), moment()],
24-
'Last 365 Days': [moment().subtract(364, 'days'), moment()],
25-
'This Month': [moment().startOf('month'), moment().endOf('month')],
26-
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
27-
'The Month Before Last': [moment().subtract(2, 'month').startOf('month'), moment().subtract(2, 'month').endOf('month')],
28-
'This Year': [moment().startOf('year'), moment().endOf('year')],
29-
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')],
20+
'Today': [moment().startOf('day'), moment().endOf('day')],
21+
'Last 7 Days': [moment().startOf('day').subtract(6, 'days'), moment().endOf('day')],
22+
'Last 30 Days': [moment().startOf('day').subtract(29, 'days'), moment().endOf('day')],
23+
'Last 90 Days': [moment().startOf('day').subtract(89, 'days'), moment().endOf('day')],
24+
'Last 365 Days': [moment().startOf('day').subtract(364, 'days'), moment().endOf('day')],
25+
'This Month': [moment().startOf('month'), moment().endOf('day')],
26+
'This Year': [moment().startOf('year'), moment().endOf('day')],
27+
'Starting last year': [moment().startOf('year').subtract(1, 'year'), moment().endOf('day')],
28+
'Last 3 years': [moment().startOf('day').subtract(3, 'year'), moment().endOf('day')],
29+
'Last 5 years': [moment().startOf('day').subtract(5, 'year'), moment().endOf('day')],
3030
},
3131
locale: {
3232
format: 'DD/MM/YY'
3333
}
3434
},cb);
3535
$("#report-range").on('apply.daterangepicker', function(ev, picker) {
36-
days = (picker.endDate.unix()-picker.startDate.unix()) / 86400;
36+
days = Math.round((picker.endDate.unix()-picker.startDate.unix()) / 86400);
3737
getWorkItems();
3838
});
3939
cb(start, end);

lib/Controller/AjaxController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ public function __construct($AppName, IRequest $request, IUserSession $userSessi
7373
*
7474
* @NoAdminRequired
7575
*/
76-
public function workIntervals($days) {
77-
$i = 0;
78-
$tryIntervals=[$days,90,180,365,365*5];
79-
do {
80-
$l = $this->workIntervalMapper->findLatestDays($this->userId,$tryIntervals[$i],0);
81-
$i++;
82-
} while ((count($l) == 0) && ($i < count($tryIntervals)));
76+
public function workIntervals() {
77+
$ndays = 30;
78+
if (isset($this->request->days)){
79+
$ndays = $this->request->days;
80+
}
81+
82+
$l = $this->workIntervalMapper->findLatestDays($this->userId, $ndays, 0);
8383
$days = [];
8484
foreach ($l as $wi){
8585
//$dt = date("d/m/Y", $wi->start);

lib/Db/WorkIntervalMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function findLatestByName($user, $name){
6060
}
6161
}
6262

63-
public function findLatestDays($user, $limitDays = 10, $startDay = 0, $limit = 100, $offset = 0){
63+
public function findLatestDays($user, $limitDays = 10, $startDay = 0, $limit = 5000, $offset = 0){
6464
if ($this->dbengine == 'MYSQL'){
6565
$sql = 'SELECT * FROM `*PREFIX*timetracker_work_interval` where user_uid = ? and
6666
start > unix_timestamp(curdate() + interval 1 day - interval ? day) and

0 commit comments

Comments
 (0)