Skip to content

Commit

Permalink
fixes #69 and #71
Browse files Browse the repository at this point in the history
show history of approvals and support ongoing timeentries (no end date)
  • Loading branch information
KatjaGlassConsulting committed Jan 26, 2025
1 parent 78fed54 commit 11c01c7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion Repository/ApprovalRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
6 changes: 5 additions & 1 deletion Toolbox/BreakTimeCheckToolGER.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 11c01c7

Please sign in to comment.