Skip to content

Commit f71463f

Browse files
committed
fixup timelines by doing some null checks and by showing the proper formatted date
1 parent 2d5ef8a commit f71463f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/Controller/AjaxController.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,10 @@ public function getProjects(){
697697
$projects = $this->projectMapper->findAll($this->userId);
698698
$parray = json_decode(json_encode($projects), true);
699699
foreach($parray as $pi => $pv){
700-
$tags = $this->tagMapper->findAllAlowedForProject($pv->id);
701-
$parray[$pi]['allowedtags'] = $tags;
700+
if (isset($pv->id)) {
701+
$tags = $this->tagMapper->findAllAlowedForProject($pv->id);
702+
$parray[$pi]['allowedtags'] = $tags;
703+
}
702704

703705
}
704706
return new JSONResponse(["Projects" => $parray]);
@@ -952,7 +954,7 @@ public function postTimeline(){
952954
$timeline->setTimeGroup($this->request->timegroup);
953955
$timeline->setFilterProjects(implode(', ',$filterProjectId));
954956
$timeline->setFilterClients(implode(', ',$filterClientId));
955-
$timeline->setTimeInterval(gmdate("d/m/Y", $from). ' - '. gmdate("d/m/Y", $to));
957+
$timeline->setTimeInterval($this->l10n->l('date', $from) . ' - '. $this->l10n->l('date', $to));
956958
$totalDuration = 0;
957959
foreach($items as $i){
958960
$totalDuration += $i->totalDuration;
@@ -967,8 +969,8 @@ public function postTimeline(){
967969
$te->setTimelineId($timeline->id);
968970
$te->setUserUid($timeline->userUid);
969971
$te->setName($i->name);
970-
$te->setProjectName($i->project);
971-
//$te->setClientName();
972+
$te->setProjectName($i->project ? $i->project : "");
973+
$te->setClientName($i->client ? $i->client : "");
972974
$te->setTimeInterval($i->time);
973975
$te->setTotalDuration($i->totalDuration);
974976
$te->setCreatedAt(time());
@@ -1068,8 +1070,7 @@ public function deleteTimeline($id) {
10681070
if ($tl->userUid == $this->userId){
10691071
$this->timelineMapper->delete($tl);
10701072
}
1071-
1072-
return new JSONResponse(["Timeline" => $timeline]);
1073+
return $this->getTimelines();
10731074
}
10741075

10751076
/**

0 commit comments

Comments
 (0)