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( if (null === $timesheet->getEnd()) {
$timesheet->getUser(), $this->repository->stopActiveEntries(
$this->hardLimit $timesheet->getUser(),
); $this->hardLimit
);
}
$entityManager = $this->getDoctrine()->getManager(); $entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($timesheet); $entityManager->persist($timesheet);
$entityManager->flush(); $entityManager->flush();

View File

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

View File

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

View File

@@ -5,7 +5,7 @@
{% block page_title %}{{ 'calendar.title'|trans }}{% endblock %} {% block page_title %}{{ 'calendar.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'calendar.subtitle'|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 %} {% block main %}
<div class="row"> <div class="row">