Skip to content

Commit 46d3199

Browse files
author
David Tahir
committed
fix #147
1 parent 710cd33 commit 46d3199

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/Controller/AjaxController.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,18 +1245,26 @@ public function getGoals(){
12451245
foreach($intervals as $interval){
12461246
$workedInInterval = 0;
12471247
foreach($repItems as $repItem) {
1248-
if ($interval == $repItem->time) {
1249-
$workedInInterval = $repItem->totalDuration;
1250-
break;
1251-
}
1248+
1249+
if ($goal->interval == 'Weekly'){
1250+
if ($interval == $this->getStartOfWeek($repItem->time)->format('Y-m-d')) {
1251+
$workedInInterval = $repItem->totalDuration;
1252+
break;
1253+
}
1254+
} elseif ($goal->interval == 'Monthly'){
1255+
if ($interval == $this->getStartOfMonth($repItem->time)->format('Y-m')) {
1256+
$workedInInterval = $repItem->totalDuration;
1257+
break;
1258+
}
1259+
}
12521260
}
12531261
$debtSeconds += ($goal->hours*3600 - $workedInInterval);
12541262
}
12551263

12561264
foreach($repItems as $period){
1257-
if ($goal->interval == 'Weekly' && $period->time == $weekStart){
1265+
if ($goal->interval == 'Weekly' && $this->getStartOfWeek($period->time)->format('Y-m-d') == $weekStart){
12581266
$workedSecondsCurrentPeriod += $period->totalDuration;
1259-
} elseif ($goal->interval == 'Monthly' && $period->time == $monthStart){
1267+
} elseif ($goal->interval == 'Monthly' && $this->getStartOfMonth($period->time)->format('Y-m') == $monthStart){
12601268
$workedSecondsCurrentPeriod += $period->totalDuration;
12611269
}
12621270
}

0 commit comments

Comments
 (0)