mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge remote-tracking branch 'origin/111_exports_suite' into calendar/finalization
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?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\Aggregator\ACPAggregators;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class ByActivityNumberAggregator implements AggregatorInterface
|
||||
{
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb
|
||||
->addSelect('(SELECT COUNT(activity.id) FROM ' . Activity::class . ' activity WHERE activity.accompanyingPeriod = acp) AS activity_by_number_aggregator')
|
||||
->addGroupBy('activity_by_number_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
return static function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['activity_by_number_aggregator'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Group acp by activity number';
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
<?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\Aggregator;
|
||||
|
||||
use Chill\ActivityBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class SentReceivedAggregator 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): void
|
||||
{
|
||||
$qb->addSelect('activity.sentReceived AS activity_sentreceived_aggregator')
|
||||
->addGroupBy('activity_sentreceived_aggregator');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACTIVITY;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): callable
|
||||
{
|
||||
return function (?string $value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'export.aggregator.activity.by_sent_received.Sent or received';
|
||||
}
|
||||
|
||||
switch ($value) {
|
||||
case null:
|
||||
return '';
|
||||
|
||||
case 'sent':
|
||||
return $this->translator->trans('export.aggregator.activity.by_sent_received.is sent');
|
||||
|
||||
case 'received':
|
||||
return $this->translator->trans('export.aggregator.activity.by_sent_received.is received');
|
||||
|
||||
default:
|
||||
throw new LogicException(sprintf('The value %s is not valid', $value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return ['activity_sentreceived_aggregator'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.aggregator.activity.by_sent_received.Group activity by sentreceived';
|
||||
}
|
||||
}
|
@@ -210,10 +210,20 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
||||
|
||||
$qb
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
->join('actperson.center', 'actcenter')
|
||||
->andWhere('actcenter IN (:authorized_centers)')
|
||||
->setParameter('authorized_centers', $centers);
|
||||
->join('activity.person', 'actperson')
|
||||
->join('actperson.centerHistory', 'centerHistory');
|
||||
|
||||
$qb->where(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte('centerHistory.startDate', 'activity.date'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('centerHistory.endDate'),
|
||||
$qb->expr()->gt('centerHistory.endDate', 'activity.date')
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in('centerHistory.center', ':centers'))
|
||||
->setParameter('centers', $centers);
|
||||
|
||||
foreach ($this->fields as $f) {
|
||||
if (in_array($f, $data['fields'], true)) {
|
||||
@@ -224,17 +234,17 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
||||
break;
|
||||
|
||||
case 'person_firstname':
|
||||
$qb->addSelect('person.firstName AS person_firstname');
|
||||
$qb->addSelect('actperson.firstName AS person_firstname');
|
||||
|
||||
break;
|
||||
|
||||
case 'person_lastname':
|
||||
$qb->addSelect('person.lastName AS person_lastname');
|
||||
$qb->addSelect('actperson.lastName AS person_lastname');
|
||||
|
||||
break;
|
||||
|
||||
case 'person_id':
|
||||
$qb->addSelect('person.id AS person_id');
|
||||
$qb->addSelect('actperson.id AS person_id');
|
||||
|
||||
break;
|
||||
|
||||
@@ -251,7 +261,7 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
||||
break;
|
||||
|
||||
case 'type_name':
|
||||
$qb->join('activity.type', 'type');
|
||||
$qb->join('activity.activityType', 'type');
|
||||
$qb->addSelect('type.name AS type_name');
|
||||
|
||||
break;
|
||||
@@ -263,6 +273,11 @@ class ListActivity implements ListInterface, GroupedExportInterface
|
||||
|
||||
break;
|
||||
|
||||
case 'attendee':
|
||||
$qb->addSelect('IDENTITY(activity.attendee) AS attendee');
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$qb->addSelect(sprintf('activity.%s as %s', $f, $f));
|
||||
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<?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\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class HasNoActivityFilter implements FilterInterface
|
||||
{
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb
|
||||
->andWhere('
|
||||
NOT EXISTS (
|
||||
SELECT 1 FROM ' . Activity::class . ' activity
|
||||
WHERE activity.accompanyingPeriod = acp
|
||||
)
|
||||
');
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
//no form needed
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return ['Filtered acp which has no activities', []];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter acp which has no activity';
|
||||
}
|
||||
}
|
@@ -13,9 +13,10 @@ namespace Chill\ActivityBundle\Export\Filter;
|
||||
|
||||
use Chill\ActivityBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\Export\FilterType;
|
||||
use DateTime;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -28,9 +29,14 @@ class ActivityDateFilter implements FilterInterface
|
||||
{
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
public function __construct(
|
||||
TranslatorInterface $translator,
|
||||
RollingDateConverterInterface $rollingDateConverter
|
||||
) {
|
||||
$this->translator = $translator;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
@@ -54,8 +60,14 @@ class ActivityDateFilter implements FilterInterface
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('date_from', $data['date_from']);
|
||||
$qb->setParameter('date_to', $data['date_to']);
|
||||
$qb->setParameter(
|
||||
'date_from',
|
||||
$this->rollingDateConverter->convert($data['date_from'])
|
||||
);
|
||||
$qb->setParameter(
|
||||
'date_to',
|
||||
$this->rollingDateConverter->convert($data['date_to'])
|
||||
);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@@ -66,13 +78,13 @@ class ActivityDateFilter implements FilterInterface
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder
|
||||
->add('date_from', ChillDateType::class, [
|
||||
->add('date_from', PickRollingDateType::class, [
|
||||
'label' => 'Activities after this date',
|
||||
'data' => new DateTime(),
|
||||
'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START),
|
||||
])
|
||||
->add('date_to', ChillDateType::class, [
|
||||
->add('date_to', PickRollingDateType::class, [
|
||||
'label' => 'Activities before this date',
|
||||
'data' => new DateTime(),
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
]);
|
||||
|
||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
||||
@@ -121,8 +133,8 @@ class ActivityDateFilter implements FilterInterface
|
||||
return [
|
||||
'Filtered by date of activity: only between %date_from% and %date_to%',
|
||||
[
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||
'%date_from%' => $this->rollingDateConverter->convert($data['date_from'])->format('d-m-Y'),
|
||||
'%date_to%' => $this->rollingDateConverter->convert($data['date_to'])->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@@ -39,9 +39,9 @@ class UsersJobFilter implements FilterInterface
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . Activity::class . ' activity_users_job_filter_act
|
||||
'SELECT 1 FROM ' . Activity::class . ' activity_users_job_filter_act
|
||||
JOIN activity_users_job_filter_act.users users WHERE users.userJob IN (:activity_users_job_filter_jobs) AND activity_users_job_filter_act = activity '
|
||||
)
|
||||
)
|
||||
)
|
||||
->setParameter('activity_users_job_filter_jobs', $data['jobs']);
|
||||
}
|
||||
|
@@ -369,8 +369,12 @@ final class ActivityControllerTest extends WebTestCase
|
||||
$center
|
||||
);
|
||||
$reachableScopesId = array_intersect(
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesDelete),
|
||||
array_map(static function ($s) { return $s->getId(); }, $reachableScopesUpdate)
|
||||
array_map(static function ($s) {
|
||||
return $s->getId();
|
||||
}, $reachableScopesDelete),
|
||||
array_map(static function ($s) {
|
||||
return $s->getId();
|
||||
}, $reachableScopesUpdate)
|
||||
);
|
||||
|
||||
if (count($reachableScopesId) === 0) {
|
||||
|
@@ -188,7 +188,9 @@ final class ActivityTypeTest extends KernelTestCase
|
||||
|
||||
// map all the values in an array
|
||||
$values = array_map(
|
||||
static function ($choice) { return $choice->value; },
|
||||
static function ($choice) {
|
||||
return $choice->value;
|
||||
},
|
||||
$view['activity']['durationTime']->vars['choices']
|
||||
);
|
||||
|
||||
|
@@ -120,6 +120,10 @@ services:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: 'activity_usersscope_filter' }
|
||||
|
||||
Chill\ActivityBundle\Export\Filter\ACPFilters\HasNoActivityFilter:
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: 'accompanyingcourse_has_no_activity_filter' }
|
||||
|
||||
## Aggregators
|
||||
Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator:
|
||||
tags:
|
||||
@@ -179,3 +183,11 @@ services:
|
||||
Chill\ActivityBundle\Export\Aggregator\ActivityUsersJobAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: activity_users_job_aggregator }
|
||||
|
||||
Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByActivityNumberAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: accompanyingcourse_by_activity_number_aggregator }
|
||||
|
||||
Chill\ActivityBundle\Export\Aggregator\SentReceivedAggregator:
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: activity_sentreceived_aggregator }
|
||||
|
@@ -260,8 +260,6 @@ activity is not emergency: l'activité n'est pas urgente
|
||||
Filter activity by sentreceived: Filtrer les activités par envoyé/reçu
|
||||
'Filtered activity by sentreceived: only %sentreceived%': "Filtré par envoyé/reçu: uniquement %sentreceived%"
|
||||
Accepted sentreceived: ''
|
||||
is sent: envoyé
|
||||
is received: reçu
|
||||
Filter activity by linked socialaction: Filtrer les activités par action liée
|
||||
'Filtered activity by linked socialaction: only %actions%': "Filtré par action liée: uniquement %actions%"
|
||||
Filter activity by linked socialissue: Filtrer les activités par problématique liée
|
||||
@@ -276,6 +274,10 @@ Creators: Créateurs
|
||||
Filter activity by userscope: Filtrer les activités par service du créateur
|
||||
'Filtered activity by userscope: only %scopes%': "Filtré par service du créateur: uniquement %scopes%"
|
||||
Accepted userscope: Services
|
||||
|
||||
Filter acp which has no activity: Filtrer les parcours qui n’ont pas d’activité
|
||||
Filtered acp which has no activities: Filtrer les parcours sans activité associée
|
||||
Group acp by activity number: Grouper les parcours par nombre d’activité
|
||||
|
||||
#aggregators
|
||||
Activity type: Type d'activité
|
||||
@@ -332,3 +334,10 @@ export:
|
||||
by_usersscope:
|
||||
Filter by users scope: Filtrer les activités 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%'
|
||||
aggregator:
|
||||
activity:
|
||||
by_sent_received:
|
||||
Sent or received: Envoyé ou reçu
|
||||
is sent: envoyé
|
||||
is received: reçu
|
||||
Group activity by sentreceived: Grouper les activités par envoyé / reçu
|
||||
|
Reference in New Issue
Block a user