mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch '129-export-filter-course-having-activity' into 'master'
[export] Add a filter "filter course having an activity between two dates" Closes #129 See merge request Chill-Projet/chill-bundles!574
This commit is contained in:
commit
f3912e5544
5
.changes/unreleased/Feature-20230711-155929.yaml
Normal file
5
.changes/unreleased/Feature-20230711-155929.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: '[export] Add a filter "filter course having an activity between two dates"'
|
||||||
|
time: 2023-07-11T15:59:29.065329834+02:00
|
||||||
|
custom:
|
||||||
|
Issue: "129"
|
@ -0,0 +1,90 @@
|
|||||||
|
<?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\ActivityBundle\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
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\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private RollingDateConverterInterface $rollingDateConverter,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return 'export.filter.activity.course_having_activity_between_date.Title';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('start_date', PickRollingDateType::class, [
|
||||||
|
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity after'
|
||||||
|
])
|
||||||
|
->add('end_date', PickRollingDateType::class, [
|
||||||
|
'label' => 'export.filter.activity.course_having_activity_between_date.Receiving an activity before'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormDefaultData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||||
|
'end_date' => new RollingDate(RollingDate::T_TODAY)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'export.filter.activity.course_having_activity_between_date.Only course having an activity between from and to',
|
||||||
|
[
|
||||||
|
'from' => $this->rollingDateConverter->convert($data['start_date']),
|
||||||
|
'to' => $this->rollingDateConverter->convert($data['end_date']),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$alias = 'act_period_having_act_betw_date_alias';
|
||||||
|
$from = 'act_period_having_act_betw_date_start';
|
||||||
|
$to = 'act_period_having_act_betw_date_end';
|
||||||
|
|
||||||
|
$qb->andWhere(
|
||||||
|
$qb->expr()->exists(
|
||||||
|
'SELECT 1 FROM ' . Activity::class . " {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->setParameter($from, $this->rollingDateConverter->convert($data['start_date']))
|
||||||
|
->setParameter($to, $this->rollingDateConverter->convert($data['end_date']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return \Chill\PersonBundle\Export\Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -135,6 +135,10 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: 'accompanyingcourse_has_no_activity_filter' }
|
- { name: chill.export_filter, alias: 'accompanyingcourse_has_no_activity_filter' }
|
||||||
|
|
||||||
|
Chill\ActivityBundle\Export\Filter\ACPFilters\PeriodHavingActivityBetweenDatesFilter:
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_filter, alias: 'period_having_activity_betw_dates_filter' }
|
||||||
|
|
||||||
## Aggregators
|
## Aggregators
|
||||||
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator:
|
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator:
|
||||||
tags:
|
tags:
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
export:
|
||||||
|
filter:
|
||||||
|
activity:
|
||||||
|
course_having_activity_between_date:
|
||||||
|
Only course having an activity between from and to: Seulement les parcours ayant reçu au moins un échange entre le {from, date, short} et le {to, date, short}
|
@ -373,6 +373,12 @@ export:
|
|||||||
by_usersscope:
|
by_usersscope:
|
||||||
Filter by users scope: Filtrer les échanges par services d'au moins un utilisateur participant
|
Filter by users scope: Filtrer les échanges par services d'au moins un utilisateur participant
|
||||||
'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%'
|
'Filtered activity by users scope: only %scopes%': 'Filtré par service d''au moins un utilisateur participant: seulement %scopes%'
|
||||||
|
course_having_activity_between_date:
|
||||||
|
Title: Filtre les parcours ayant reçu un échange entre deux dates
|
||||||
|
Receiving an activity after: Ayant reçu un échange après le
|
||||||
|
Receiving an activity before: Ayant reçu un échange avant le
|
||||||
|
|
||||||
|
|
||||||
aggregator:
|
aggregator:
|
||||||
activity:
|
activity:
|
||||||
by_sent_received:
|
by_sent_received:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user