diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/user.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/user.html.twig
index 77dc959a2..12a1a618c 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Entity/user.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/user.html.twig
@@ -6,4 +6,9 @@
{%- if opts['main_scope'] and user.mainScope is not null %}
({{ user.mainScope.name|localize_translatable_string }})
{%- endif -%}
+ {%- if opts['absence'] and user.absenceStart is not null %}
+ {%- if date(user.absenceStart) < date() %}
+ ({{ 'absence.Absent'|trans }})
+ {%- endif %}
+ {%- endif -%}
diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php
index 141de2649..2cef950d5 100644
--- a/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php
+++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserRender.php
@@ -13,8 +13,10 @@ namespace Chill\MainBundle\Templating\Entity;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Templating\TranslatableStringHelper;
-use Symfony\Component\Templating\EngineInterface;
+use DateTimeImmutable;
+use Symfony\Component\Templating\EngineInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
use function array_merge;
class UserRender implements ChillEntityRenderInterface
@@ -22,16 +24,20 @@ class UserRender implements ChillEntityRenderInterface
public const DEFAULT_OPTIONS = [
'main_scope' => true,
'user_job' => true,
+ 'absence' => true,
];
private EngineInterface $engine;
private TranslatableStringHelper $translatableStringHelper;
- public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
+ private TranslatorInterface $translator;
+
+ public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine, TranslatorInterface $translator)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->engine = $engine;
+ $this->translator = $translator;
}
public function renderBox($entity, array $options): string
@@ -63,6 +69,12 @@ class UserRender implements ChillEntityRenderInterface
->localize($entity->getMainScope()->getName()) . ')';
}
+ $current_date = new DateTimeImmutable();
+
+ if (null !== $entity->getAbsenceStart() && $entity->getAbsenceStart() < $current_date && $opts['main_scope']) {
+ $str .= ' (' . $this->translator->trans('absence.Absent') . ')';
+ }
+
return $str;
}
diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
index b80171c8c..c7d376c48 100644
--- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml
@@ -580,3 +580,4 @@ absence:
Unset absence: Supprimer la date d'absence
Set absence date: Indiquer date d'absence
Absence start: Absence à partir de
+ Absent: Absent