Improve allowed running records (#528)

This commit is contained in:
Kevin Papst
2019-01-29 20:45:04 +01:00
committed by GitHub
parent fe4c3c10d6
commit 974806d145
4 changed files with 14 additions and 8 deletions

View File

@@ -194,10 +194,13 @@ class TimesheetController extends BaseApiController
}
}
$this->repository->stopActiveEntries(
$timesheet->getUser(),
$this->hardLimit
);
if (null === $timesheet->getEnd()) {
$this->repository->stopActiveEntries(
$timesheet->getUser(),
$this->hardLimit
);
}
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($timesheet);
$entityManager->flush();

View File

@@ -165,11 +165,12 @@ class TimesheetController extends AbstractController
if (count($errors) > 0) {
$this->flashError('timesheet.start.error', ['%reason%' => $errors[0]->getPropertyPath() . ' = ' . $errors[0]->getMessage()]);
} else {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entry);
$this->stopActiveEntries($user);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($entry);
$entityManager->flush();
$this->flashSuccess('timesheet.start.success');
}
} catch (\Exception $ex) {

View File

@@ -172,7 +172,9 @@ trait TimesheetControllerTrait
$entityManager = $this->getDoctrine()->getManager();
try {
$this->stopActiveEntries($entry->getUser());
if (null === $entry->getEnd()) {
$this->stopActiveEntries($entry->getUser());
}
$entityManager->persist($entry);
$entityManager->flush();

View File

@@ -5,7 +5,7 @@
{% block page_title %}{{ 'calendar.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'calendar.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ widgets.page_actions({'list': path('timesheet'), 'create': path('timesheet_create')}) }}{% endblock %}
{% block page_actions %}{{ widgets.page_actions({'list': path('timesheet'), 'create': path('timesheet_create', {'origin': 'calendar'})}) }}{% endblock %}
{% block main %}
<div class="row">