mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
urgency and calendarrange exports
This commit is contained in:
parent
d62c09993f
commit
9da410afb8
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\CalendarBundle\Export\Aggregator;
|
||||||
|
|
||||||
|
use Chill\CalendarBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Closure;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use LogicException;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class UrgencyAggregator implements AggregatorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TranslatorInterface $translator
|
||||||
|
) {
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$qb->addSelect('cal.urgent AS urgency_aggregator');
|
||||||
|
|
||||||
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
if (!empty($groupBy)) {
|
||||||
|
$qb->addGroupBy('urgency_aggregator');
|
||||||
|
} else {
|
||||||
|
$qb->groupBy('urgency_aggregator');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::CALENDAR_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
// no form
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabels($key, array $values, $data): Closure
|
||||||
|
{
|
||||||
|
return function ($value): string {
|
||||||
|
if ('_header' === $value) {
|
||||||
|
return 'Urgency';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($value) {
|
||||||
|
case true:
|
||||||
|
return $this->translator->trans('is urgent');
|
||||||
|
|
||||||
|
case false:
|
||||||
|
return $this->translator->trans('is not urgent');
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new LogicException(sprintf('The value %s is not valid', $value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryKeys($data): array
|
||||||
|
{
|
||||||
|
return ['urgency_aggregator'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Group calendars by urgency';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\CalendarBundle\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\CalendarBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\Query\Expr\Andx;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class CalendarRangeFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
private const CHOICES = [
|
||||||
|
'Not made within a calendar range' => true,
|
||||||
|
'Made within a calendar range' => false
|
||||||
|
];
|
||||||
|
|
||||||
|
private const DEFAULT_CHOICE = false;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(TranslatorInterface $translator)
|
||||||
|
{
|
||||||
|
$this->translator = $translator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
|
||||||
|
dump($data);
|
||||||
|
|
||||||
|
if ($data['hasCalendarRange']) {
|
||||||
|
$clause = $qb->expr()->isNotNull('cal.calendarRange');
|
||||||
|
} else {
|
||||||
|
$clause = $qb->expr()->isNull('cal.calendarRange');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($where instanceof Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::CALENDAR_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('hasCalendarRange', ChoiceType::class, [
|
||||||
|
'choices' => self::CHOICES,
|
||||||
|
'label' => 'has calendar range',
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true,
|
||||||
|
'empty_data' => self::DEFAULT_CHOICE,
|
||||||
|
'data' => self::DEFAULT_CHOICE,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string'): array
|
||||||
|
{
|
||||||
|
foreach (self::CHOICES as $k => $v) {
|
||||||
|
if ($v === $data['hasCalendarRange']) {
|
||||||
|
$choice = $k;
|
||||||
|
} else {
|
||||||
|
$choice = 'Not made within a calendar range';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Filtered by calendar range: only %calendarRange%', [
|
||||||
|
'%calendarRange%' => $this->translator->trans($choice),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Filter by calendar range';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -52,6 +52,13 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: between_dates_filter }
|
- { name: chill.export_filter, alias: between_dates_filter }
|
||||||
|
|
||||||
|
chill.calendar.export.calendar_range_filter:
|
||||||
|
class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: calendar_range_filter }
|
||||||
|
|
||||||
## Aggregator
|
## Aggregator
|
||||||
|
|
||||||
chill.calendar.export.agent_aggregator:
|
chill.calendar.export.agent_aggregator:
|
||||||
@ -102,3 +109,10 @@ services:
|
|||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: month_aggregator }
|
- { name: chill.export_aggregator, alias: month_aggregator }
|
||||||
|
|
||||||
|
chill.calendar.export.urgency_aggregator:
|
||||||
|
class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_aggregator, alias: urgency_aggregator }
|
||||||
|
@ -89,6 +89,8 @@ Filter calendars by agent scope: Filtrer les rendez-vous par services des agents
|
|||||||
'Filtered by agent scope: only %scopes%': 'Filtré par services des agents: uniquement les services %scopes%'
|
'Filtered by agent scope: only %scopes%': 'Filtré par services des agents: uniquement les services %scopes%'
|
||||||
Filter calendars between certain dates: Filtrer les rendez-vous par date du rendez-vous
|
Filter calendars between certain dates: Filtrer les rendez-vous par date du rendez-vous
|
||||||
'Filtered by calendars between %dateFrom% and %dateTo%': 'Filtré par rendez-vous entre %dateFrom% et %dateTo%'
|
'Filtered by calendars between %dateFrom% and %dateTo%': 'Filtré par rendez-vous entre %dateFrom% et %dateTo%'
|
||||||
|
'Filtered by calendar range: only %calendarRange%': 'Filtré par rendez-vous par plage de disponibilité: uniquement les %calendarRange%'
|
||||||
|
Filter by calendar range: Filtrer par rendez-vous dans une plage de disponibilité ou non
|
||||||
|
|
||||||
Group calendars by agent: Grouper les rendez-vous par agent
|
Group calendars by agent: Grouper les rendez-vous par agent
|
||||||
Group calendars by agent job: Grouper les rendez-vous par métier de l'agent
|
Group calendars by agent job: Grouper les rendez-vous par métier de l'agent
|
||||||
@ -97,8 +99,16 @@ Group calendars by location type: Grouper les rendez-vous par type de localisati
|
|||||||
Group calendars by location: Grouper les rendez-vous par lieu de rendez-vous
|
Group calendars by location: Grouper les rendez-vous par lieu de rendez-vous
|
||||||
Group calendars by cancel reason: Grouper les rendez-vous par motif d'annulation
|
Group calendars by cancel reason: Grouper les rendez-vous par motif d'annulation
|
||||||
Group calendars by month and year: Grouper les rendez-vous par mois et année
|
Group calendars by month and year: Grouper les rendez-vous par mois et année
|
||||||
|
Group calendars by urgency: Grouper les rendez-vous par urgent ou non
|
||||||
|
|
||||||
Scope: Service
|
Scope: Service
|
||||||
Job: Métier
|
Job: Métier
|
||||||
Location type: Type de localisation
|
Location type: Type de localisation
|
||||||
Location: Lieu de rendez-vous
|
Location: Lieu de rendez-vous
|
||||||
by month and year: Par mois et année
|
by month and year: Par mois et année
|
||||||
|
is urgent: Urgent
|
||||||
|
is not urgent: Pas urgent
|
||||||
|
has calendar range: Dans une plage de disponibilité?
|
||||||
|
Not made within a calendar range: Rendez-vous dans une plage de disponibilité
|
||||||
|
Made within a calendar range: Rendez-vous en dehors d'une plage de disponibilité
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user