diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php
index 2c9074488..1f6b42dea 100644
--- a/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php
+++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarDocController.php
@@ -16,6 +16,7 @@ use Chill\CalendarBundle\Security\Voter\CalendarVoter;
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
use RuntimeException;
use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -23,6 +24,7 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Templating\EngineInterface;
+use UnexpectedValueException;
class CalendarDocController
{
@@ -47,7 +49,7 @@ class CalendarDocController
/**
* @Route("/{_locale}/calendar/docgen/pick/{id}", name="chill_calendar_calendardoc_pick_template")
*/
- public function pickTemplate(Calendar $calendar): Response
+ public function pickTemplate(Calendar $calendar, Request $request): Response
{
if (!$this->security->isGranted(CalendarVoter::SEE, $calendar)) {
throw new AccessDeniedException('Not authorized to see this calendar');
@@ -60,23 +62,42 @@ class CalendarDocController
if (1 === $number) {
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
+ if ($request->query->has('returnPath')) {
+ $returnPathParam = ['returnPath' => $request->query->get('returnPath')];
+ }
+
return new RedirectResponse(
$this->urlGenerator->generate(
'chill_docgenerator_generate_from_template',
- [
- 'template' => $templates[0]->getId(),
- 'entityClassName' => Calendar::class,
- 'entityId' => $calendar->getId(),
- ]
+ array_merge(
+ $returnPathParam ?? [],
+ [
+ 'template' => $templates[0]->getId(),
+ 'entityClassName' => Calendar::class,
+ 'entityId' => $calendar->getId(),
+ ]
+ )
)
);
}
- return new Response(
- $this->engine->render('@ChillCalendar/CalendarDoc/pick_template.html.twig', [
- 'calendar' => $calendar,
- 'accompanyingCourse' => $calendar->getAccompanyingPeriod(),
- ])
- );
+ switch ($calendar->getContext()) {
+ case 'person':
+ return new Response(
+ $this->engine->render('@ChillCalendar/CalendarDoc/pick_template_person.html.twig', [
+ 'calendar' => $calendar,
+ ])
+ );
+
+ case 'accompanying_period':
+ return new Response(
+ $this->engine->render('@ChillCalendar/CalendarDoc/pick_template_accompanying_period.html.twig', [
+ 'calendar' => $calendar,
+ ])
+ );
+
+ default:
+ throw new UnexpectedValueException('calendar context not expected : ' . $calendar->getContext());
+ }
}
}
diff --git a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php
index 8194e8c7c..59019ac03 100644
--- a/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php
+++ b/src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php
@@ -16,7 +16,6 @@ use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
-use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -36,20 +35,12 @@ class BetweenDatesFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
- $where = $qb->getDQLPart('where');
-
$clause = $qb->expr()->andX(
$qb->expr()->gte('cal.startDate', ':dateFrom'),
$qb->expr()->lte('cal.endDate', ':dateTo')
);
- if ($where instanceof Andx) {
- $where->add($clause);
- } else {
- $where = $qb->expr()->andX($clause);
- }
-
- $qb->add('where', $where);
+ $qb->andWhere($clause);
$qb->setParameter(
'dateFrom',
$this->rollingDateConverter->convert($data['date_from'])
@@ -79,7 +70,7 @@ class BetweenDatesFilter implements FilterInterface
public function describeAction($data, $format = 'string'): array
{
- return ['Filtered by appointments between %dateFrom% and %dateTo%', [
+ return ['Filtered by calendars between %dateFrom% and %dateTo%', [
'%dateFrom%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
'%dateTo%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
]];
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig
index 3eb1d6634..af22a96ec 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/_list.html.twig
@@ -1,7 +1,5 @@
{# list used in context of person or accompanyingPeriod #}
-{{ filterOrder|chill_render_filter_order_helper }}
-
{% if calendarItems|length > 0 %}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
index f1b0c6110..56c1ba880 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig
@@ -23,6 +23,8 @@
{{ 'Calendar list' |trans }}
+ {{ filterOrder|chill_render_filter_order_helper }}
+
{% if calendarItems|length == 0 %}
{{ "There is no calendar items."|trans }}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig
index 6d991fb53..dc849202e 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByPerson.html.twig
@@ -22,6 +22,8 @@
{{ 'Calendar list' |trans }}
+ {{ filterOrder|chill_render_filter_order_helper }}
+
{% if calendarItems|length == 0 %}
{{ "There is no calendar items."|trans }}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig
similarity index 58%
rename from src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig
rename to src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig
index 561f92f0c..8e5226faa 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template.html.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_accompanying_period.html.twig
@@ -5,6 +5,7 @@
{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %}
{% set user_id = null %}
+{% set accompanyingCourse = calendar.accompanyingPeriod %}
{% set accompanying_course_id = accompanyingCourse.id %}
{% block js %}
@@ -19,6 +20,18 @@
{% block content %}
+
{{ 'chill_calendar.Add a document'|trans }}
+
+
+ {% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
+ {{ calendar.startDate|format_datetime('short', 'short') }}
+ - {{ calendar.endDate|format_datetime('short', 'short') }}
+ {% else %}
+ {{ calendar.startDate|format_datetime('short', 'short') }}
+ - {{ calendar.endDate|format_datetime('none', 'short') }}
+ {% endif %}
+
+
{% endblock %}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig
new file mode 100644
index 000000000..a331f7fd7
--- /dev/null
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarDoc/pick_template_person.html.twig
@@ -0,0 +1,35 @@
+{% extends "@ChillPerson/Person/layout.html.twig" %}
+
+{% set activeRouteKey = 'chill_calendar_calendar_list' %}
+
+{% block title %}{{ 'chill_calendar.Add a document' |trans }}{% endblock title %}
+
+{% set person = calendar.person %}
+
+{% block js %}
+ {{ parent() }}
+ {{ encore_entry_script_tags('mod_docgen_picktemplate') }}
+{% endblock %}
+
+{% block css %}
+ {{ parent() }}
+ {{ encore_entry_link_tags('mod_docgen_picktemplate') }}
+{% endblock %}
+
+{% block content %}
+
+
{{ 'chill_calendar.Add a document'|trans }}
+
+
+ {% if calendar.endDate.diff(calendar.startDate).days >= 1 %}
+ {{ calendar.startDate|format_datetime('short', 'short') }}
+ - {{ calendar.endDate|format_datetime('short', 'short') }}
+ {% else %}
+ {{ calendar.startDate|format_datetime('short', 'short') }}
+ - {{ calendar.endDate|format_datetime('none', 'short') }}
+ {% endif %}
+
+
+
+
+{% endblock %}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message.txt.twig b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message.txt.twig
index d6c46a7e9..1669ac1d1 100644
--- a/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message.txt.twig
+++ b/src/Bundle/ChillCalendarBundle/Resources/views/CalendarShortMessage/short_message.txt.twig
@@ -1 +1 @@
-Votre travailleur social {{ calendar.mainUser.label }} vous rencontrera le {{ calendar.startDate|format_date('short', locale='fr') }} à {{ calendar.startDate|format_time('short', locale='fr') }} - LIEU.{% if calendar.mainUser.mainLocation is not null and calendar.mainUser.mainLocation.phonenumber1 is not null %} En cas d'indisponibilité, appelez-nous au {{ calendar.mainUser.mainLocation.phonenumber1|chill_format_phonenumber }}.{% endif %}
+Votre travailleur social {{ calendar.mainUser.label }} vous rencontrera le {{ calendar.startDate|format_date('short', locale='fr') }} à {{ calendar.startDate|format_time('short', locale='fr') }} - {% if calendar.location is not null%}{{ calendar.location.name }}{% endif %}{% if calendar.mainUser.mainLocation is not null and calendar.mainUser.mainLocation.phonenumber1 is not null %} En cas d'indisponibilité, appelez-nous au {{ calendar.mainUser.mainLocation.phonenumber1|chill_format_phonenumber }}.{% endif %}
diff --git a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php
index ded8d2062..996b5ebfb 100644
--- a/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php
+++ b/src/Bundle/ChillCalendarBundle/Security/Voter/CalendarVoter.php
@@ -61,6 +61,9 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
public function getRoles(): array
{
return [
+ self::CREATE,
+ self::DELETE,
+ self::EDIT,
self::SEE,
];
}
@@ -72,7 +75,12 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
public function getRolesWithoutScope(): array
{
- return [];
+ return [
+ self::CREATE,
+ self::DELETE,
+ self::EDIT,
+ self::SEE,
+ ];
}
protected function supports($attribute, $subject): bool
diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20221125144205.php b/src/Bundle/ChillCalendarBundle/migrations/Version20221125144205.php
new file mode 100644
index 000000000..624fdda00
--- /dev/null
+++ b/src/Bundle/ChillCalendarBundle/migrations/Version20221125144205.php
@@ -0,0 +1,41 @@
+throwIrreversibleMigrationException();
+ }
+
+ public function getDescription(): string
+ {
+ return 'Calendar: remove association between scope and calendar';
+ }
+
+ public function up(Schema $schema): void
+ {
+ $this->addSql(
+ sprintf(
+ 'UPDATE role_scopes SET scope_id=NULL WHERE role IN (\'%s\', \'%s\', \'%s\', \'%s\')',
+ 'CHILL_CALENDAR_CALENDAR_CREATE',
+ 'CHILL_CALENDAR_CALENDAR_DELETE',
+ 'CHILL_CALENDAR_CALENDAR_EDIT',
+ 'CHILL_CALENDAR_CALENDAR_SEE'
+ )
+ );
+ }
+}
diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml
index 60d97d17f..e468db875 100644
--- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml
+++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml
@@ -131,3 +131,9 @@ docgen:
Destinee: Destinataire
None: Aucun choix
title of the generated document: Titre du document généré
+
+CHILL_CALENDAR_CALENDAR_CREATE: Créer les rendez-vous
+CHILL_CALENDAR_CALENDAR_EDIT: Modifier les rendez-vous
+CHILL_CALENDAR_CALENDAR_DELETE: Supprimer les rendez-vous
+CHILL_CALENDAR_CALENDAR_SEE: Voir les rendez-vous
+
diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php
index 5b5bff6b3..a4492526f 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php
@@ -44,6 +44,11 @@ class PickRollingDateType extends AbstractType
$builder->setDataMapper(new RollingDateDataMapper());
}
+ public function buildView(FormView $view, FormInterface $form, array $options)
+ {
+ $view->vars['uniqid'] = uniqid('rollingdate-');
+ }
+
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
@@ -65,9 +70,4 @@ class PickRollingDateType extends AbstractType
->addViolation();
}
}
-
- public function buildView(FormView $view, FormInterface $form, array $options)
- {
- $view->vars['uniqid'] = uniqid('rollingdate-');
- }
}