mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
FEATURE [genericDoc] generic doc interface implemented for rendez-vous
This commit is contained in:
parent
20489813f0
commit
47a3e30ec5
@ -0,0 +1,72 @@
|
|||||||
|
{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
|
||||||
|
{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
|
||||||
|
{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}
|
||||||
|
|
||||||
|
{% set c = document.calendar %}
|
||||||
|
|
||||||
|
<div class="item-bloc">
|
||||||
|
<div class="item-row">
|
||||||
|
<div class="item-col" style="width: unset">
|
||||||
|
{% if document.storedObject.isPending %}
|
||||||
|
<div class="badge text-bg-info" data-docgen-is-pending="{{ document.storedObject.id }}">{{ 'docgen.Doc generation is pending'|trans }}</div>
|
||||||
|
{% elseif document.storedObject.isFailure %}
|
||||||
|
<div class="badge text-bg-warning">{{ 'docgen.Doc generation failed'|trans }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="denomination h2">
|
||||||
|
{{ document.storedObject.title }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ 'chill_calendar.Document'|trans }}
|
||||||
|
</div>
|
||||||
|
{% if document.storedObject.hasTemplate %}
|
||||||
|
<div>
|
||||||
|
<p>{{ document.storedObject.template.name|localize_translatable_string }}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-col">
|
||||||
|
<div class="container">
|
||||||
|
<div class="dates row text-end">
|
||||||
|
<span>{{ document.storedObject.createdAt|format_date('short') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-row separator">
|
||||||
|
<div class="item-col">
|
||||||
|
<p class="date-label">
|
||||||
|
{% if c.endDate.diff(c.startDate).days >= 1 %}
|
||||||
|
{{ c.startDate|format_datetime('short', 'short') }}
|
||||||
|
- {{ c.endDate|format_datetime('short', 'short') }}
|
||||||
|
{% else %}
|
||||||
|
{{ c.startDate|format_datetime('short', 'short') }}
|
||||||
|
- {{ c.endDate|format_datetime('none', 'short') }}
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-row separator">
|
||||||
|
<div class="item-col item-meta">
|
||||||
|
{{ mmm.createdBy(document) }}
|
||||||
|
</div>
|
||||||
|
<ul class="item-col record_actions flex-shrink-1">
|
||||||
|
<li>
|
||||||
|
{{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
|
||||||
|
</li>
|
||||||
|
{% if is_granted('CHILL_CALENDAR_DOC_SEE', document) %}
|
||||||
|
<li>
|
||||||
|
{{ document.storedObject|chill_document_button_group(document.storedObject.title, is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c)) }}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_CALENDAR_CALENDAR_EDIT', c) %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ chill_path_add_return_path('chill_calendar_calendar_edit', {'id': c.id, 'docId': document.id}) }}" class="btn btn-edit"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\CalendarBundle\Service\GenericDoc\Providers;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Entity\Calendar;
|
||||||
|
use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||||
|
use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
|
use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
||||||
|
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||||
|
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Doctrine\DBAL\Types\Types;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
|
final class AccompanyingPeriodCalendarGenericDocProvider implements GenericDocForAccompanyingPeriodProviderInterface
|
||||||
|
{
|
||||||
|
public const KEY = 'accompanying_period_calendar_document';
|
||||||
|
|
||||||
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
|
private Security $security;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
Security $security,
|
||||||
|
EntityManagerInterface $entityManager
|
||||||
|
) {
|
||||||
|
$this->security = $security;
|
||||||
|
$this->em = $entityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||||
|
{
|
||||||
|
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||||
|
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||||
|
$calendarMetadata = $this->em->getClassMetadata(Calendar::class);
|
||||||
|
|
||||||
|
$query = new FetchQuery(
|
||||||
|
self::KEY,
|
||||||
|
sprintf("jsonb_build_object('id', cd.%s)", $classMetadata->getColumnName('id')),
|
||||||
|
'cd.'.$storedObjectMetadata->getColumnName('createdAt'),
|
||||||
|
$classMetadata->getSchemaName().'.'.$classMetadata->getTableName().' AS cd'
|
||||||
|
);
|
||||||
|
$query->addJoinClause(
|
||||||
|
'JOIN chill_doc.stored_object doc_store ON doc_store.id = cd.storedobject_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$query->addJoinClause(
|
||||||
|
'JOIN chill_calendar.calendar calendar ON calendar.id = cd.calendar_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$query->addWhereClause(
|
||||||
|
'calendar.accompanyingperiod_id = ?',
|
||||||
|
[$accompanyingPeriod->getId()],
|
||||||
|
[Types::INTEGER]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (null !== $startDate) {
|
||||||
|
$query->addWhereClause(
|
||||||
|
sprintf('doc_store.%s >= ?', $storedObjectMetadata->getColumnName('createdAt')),
|
||||||
|
[$startDate],
|
||||||
|
[Types::DATE_IMMUTABLE]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $endDate) {
|
||||||
|
$query->addWhereClause(
|
||||||
|
sprintf('doc_store.%s < ?', $storedObjectMetadata->getColumnName('createdAt')),
|
||||||
|
[$endDate],
|
||||||
|
[Types::DATE_IMMUTABLE]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $content) {
|
||||||
|
$query->addWhereClause(
|
||||||
|
'doc_store.title ilike ?',
|
||||||
|
['%' . $content . '%'],
|
||||||
|
[Types::STRING]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
|
||||||
|
{
|
||||||
|
return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\CalendarBundle\Service\GenericDoc\Renderers;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Repository\CalendarDocRepository;
|
||||||
|
use Chill\CalendarBundle\Service\GenericDoc\Providers\AccompanyingPeriodCalendarGenericDocProvider;
|
||||||
|
use Chill\DocStoreBundle\GenericDoc\GenericDocDTO;
|
||||||
|
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
||||||
|
|
||||||
|
final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRendererInterface
|
||||||
|
{
|
||||||
|
private CalendarDocRepository $repository;
|
||||||
|
|
||||||
|
public function __construct(CalendarDocRepository $calendarDocRepository)
|
||||||
|
{
|
||||||
|
$this->repository = $calendarDocRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
||||||
|
{
|
||||||
|
return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
||||||
|
{
|
||||||
|
return '@ChillCalendar/GenericDoc/calendar_document.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'document' => $this->repository->find($genericDocDTO->identifiers['id'])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,7 @@ crud:
|
|||||||
title_edit: Modifier le motif d'annulation
|
title_edit: Modifier le motif d'annulation
|
||||||
|
|
||||||
chill_calendar:
|
chill_calendar:
|
||||||
|
Document: Document d'un rendez-vous
|
||||||
form:
|
form:
|
||||||
The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement.
|
The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement.
|
||||||
Create for referrer: Créer pour le référent
|
Create for referrer: Créer pour le référent
|
||||||
@ -65,6 +66,7 @@ chill_calendar:
|
|||||||
Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document
|
Document outdated: La date et l'heure du rendez-vous ont été modifiés après la création du document
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
remote_ms_graph:
|
remote_ms_graph:
|
||||||
freebusy_statuses:
|
freebusy_statuses:
|
||||||
busy: Occupé
|
busy: Occupé
|
||||||
|
@ -26,6 +26,7 @@ generic_doc:
|
|||||||
filter:
|
filter:
|
||||||
keys:
|
keys:
|
||||||
accompanying_course_document: Document du parcours
|
accompanying_course_document: Document du parcours
|
||||||
|
accompanying_period_calendar_document: Document des rendez-vous
|
||||||
date-range: Date du document
|
date-range: Date du document
|
||||||
|
|
||||||
# delete
|
# delete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user