From 11c01c78e71f1e0056f88724539d0a6095cab18f Mon Sep 17 00:00:00 2001 From: Katja Glass Date: Sun, 26 Jan 2025 08:12:30 +0100 Subject: [PATCH] fixes #69 and #71 show history of approvals and support ongoing timeentries (no end date) --- CHANGELOG.md | 5 +++++ Repository/ApprovalRepository.php | 8 +++++++- Toolbox/BreakTimeCheckToolGER.php | 6 +++++- composer.json | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c90e14..90ece63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2.2.1 + +- fix: "History" of approvals had not been shown +- fix: When timesheets are not all finished (e.g. no end-time), the approval view had an error and was not showing up + ## 2.2.0 - **API endpoints changed** to support Kimai naming conventions diff --git a/Repository/ApprovalRepository.php b/Repository/ApprovalRepository.php index 8bec498..27abd2d 100644 --- a/Repository/ApprovalRepository.php +++ b/Repository/ApprovalRepository.php @@ -464,6 +464,12 @@ private function addAllNotSubmittedUsers($parseToViewArray, array $users) public function findHistoryForUserAndWeek($userId, $week) { + if ($week instanceof DateTime) { + $weekString = $week->format('Y-m-d'); + } else { + $weekString = $week; + } + $em = $this->getEntityManager(); return $em->createQueryBuilder() @@ -473,7 +479,7 @@ public function findHistoryForUserAndWeek($userId, $week) ->join('ap.history', 'ah') ->where('ap.startDate = :startDate') ->andWhere('u.id = :userId') - ->setParameter('startDate', $week) + ->setParameter('startDate', $weekString) ->setParameter('userId', $userId) ->orderBy('ah.date', 'ASC') ->getQuery() diff --git a/Toolbox/BreakTimeCheckToolGER.php b/Toolbox/BreakTimeCheckToolGER.php index 36c31da..51ab2b7 100644 --- a/Toolbox/BreakTimeCheckToolGER.php +++ b/Toolbox/BreakTimeCheckToolGER.php @@ -84,6 +84,10 @@ private function checkSixHoursWithoutBreak($timesheets, &$errors) $blockStart = 0; $blockEnd = 0; foreach ($timesheets as $timesheet) { + if($timesheet->getEnd() == null) { + continue; + } + if ($lastDay != $timesheet->getBegin()->format('Y-m-d')) { $lastDay = $timesheet->getBegin()->format('Y-m-d'); $blockStart = $timesheet->getBegin()->getTimestamp(); @@ -198,7 +202,7 @@ function ($result, Timesheet $timesheet) { }); for ($i = 0; $i < \count($value) - 1; $i++) { - if ($value[$i]->getEnd() != null) { + if ($value[$i]->getEnd() != null && $value[$i + 1]->getEnd() != null) { $timesheetOne = $value[$i]->getEnd()->getTimestamp(); $timesheetTwo = $value[$i + 1]->getBegin()->getTimestamp(); if ($value[$i]->getEnd() == null) { diff --git a/composer.json b/composer.json index 74205de..55584d8 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "A Kimai plugin to manage approvals and supporting related API", "homepage": "https://www.kimai.org/store/katjaglass-approval-bundle.html", "type": "kimai-plugin", - "version": "2.2.0", + "version": "2.2.1", "keywords": [ "kimai", "kimai-plugin"