Only one running timesheet: automatically stop others (#386)

This commit is contained in:
Lukas
2019-01-21 12:49:22 +01:00
committed by Kevin Papst
parent 5539f68a54
commit 47ac50b4d0
18 changed files with 215 additions and 77 deletions

View File

@@ -30,11 +30,11 @@ class TimesheetController extends AbstractController
use TimesheetControllerTrait;
/**
* @param bool $durationOnly
* @param int $hardLimit
*/
public function __construct(bool $durationOnly)
public function __construct(int $hardLimit)
{
$this->setDurationMode($durationOnly);
$this->setHardLimit($hardLimit);
}
/**
@@ -168,6 +168,8 @@ class TimesheetController extends AbstractController
} else {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entry);
$this->stopActiveEntries($user);
$entityManager->flush();
$this->flashSuccess('timesheet.start.success');
}
@@ -238,9 +240,7 @@ class TimesheetController extends AbstractController
{
return $this->createForm(TimesheetEditForm::class, $entry, [
'action' => $this->generateUrl('timesheet_create'),
'method' => 'POST',
'include_rate' => $this->isGranted('edit_rate', $entry),
'duration_only' => $this->isDurationOnlyMode(),
]);
}
@@ -256,9 +256,7 @@ class TimesheetController extends AbstractController
'id' => $entry->getId(),
'page' => $page
]),
'method' => 'POST',
'include_rate' => $this->isGranted('edit_rate', $entry),
'duration_only' => $this->isDurationOnlyMode(),
]);
}