mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into export/allow-check-multiple-geographical-zones
This commit is contained in:
@@ -128,9 +128,7 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function (GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -86,13 +86,19 @@ final class StepAggregator implements AggregatorInterface
|
||||
return function ($value): string {
|
||||
switch ($value) {
|
||||
case AccompanyingPeriod::STEP_DRAFT:
|
||||
return $this->translator->trans('Draft');
|
||||
return $this->translator->trans('course.draft');
|
||||
|
||||
case AccompanyingPeriod::STEP_CONFIRMED:
|
||||
return $this->translator->trans('Confirmed');
|
||||
return $this->translator->trans('course.confirmed');
|
||||
|
||||
case AccompanyingPeriod::STEP_CLOSED:
|
||||
return $this->translator->trans('Closed');
|
||||
return $this->translator->trans('course.closed');
|
||||
|
||||
case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT:
|
||||
return $this->translator->trans('course.inactive_short');
|
||||
|
||||
case AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG:
|
||||
return $this->translator->trans('course.inactive_long');
|
||||
|
||||
case '_header':
|
||||
return 'Step';
|
||||
|
@@ -147,9 +147,7 @@ final class CountryOfBirthAggregator implements AggregatorInterface, ExportEleme
|
||||
];
|
||||
}
|
||||
|
||||
return static function (string $value) use ($labels): string {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn (string $value): string => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
|
@@ -100,9 +100,7 @@ class GeographicalUnitAggregator implements AggregatorInterface
|
||||
'placeholder' => 'Select a geographical layer',
|
||||
'class' => GeographicalUnitLayer::class,
|
||||
'choices' => $this->geographicalUnitLayerRepository->findAllHavingUnits(),
|
||||
'choice_label' => function (GeographicalUnitLayer $item) {
|
||||
return $this->translatableStringHelper->localize($item->getName());
|
||||
},
|
||||
'choice_label' => fn (GeographicalUnitLayer $item) => $this->translatableStringHelper->localize($item->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -141,9 +141,7 @@ final class NationalityAggregator implements AggregatorInterface, ExportElementV
|
||||
];
|
||||
}
|
||||
|
||||
return static function ($value) use ($labels): string {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value): string => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
|
@@ -64,9 +64,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value) => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
@@ -91,9 +89,7 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->repository->createQueryBuilder('acp');
|
||||
|
||||
|
@@ -63,9 +63,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value) => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
@@ -90,9 +88,7 @@ class CountAccompanyingPeriodWork implements ExportInterface, GroupedExportInter
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
|
||||
|
@@ -62,9 +62,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value) => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
@@ -89,9 +87,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -113,9 +113,7 @@ class CountHousehold implements ExportInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -62,9 +62,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value) => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
@@ -94,9 +92,7 @@ class CountPerson implements ExportInterface, GroupedExportInterface
|
||||
*/
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->personRepository->createQueryBuilder('person');
|
||||
|
||||
|
@@ -64,9 +64,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
|
||||
$labels = array_combine($values, $values);
|
||||
$labels['_header'] = $this->getTitle();
|
||||
|
||||
return static function ($value) use ($labels) {
|
||||
return $labels[$value];
|
||||
};
|
||||
return static fn ($value) => $labels[$value];
|
||||
}
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
@@ -91,9 +89,7 @@ class CountPersonWithAccompanyingCourse implements ExportInterface, GroupedExpor
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->repository->createQueryBuilder('acp');
|
||||
|
||||
|
@@ -41,6 +41,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function strlen;
|
||||
|
||||
class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
@@ -100,6 +101,8 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
private UserHelper $userHelper;
|
||||
|
||||
public function __construct(
|
||||
@@ -113,6 +116,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
SocialIssueRepository $socialIssueRepository,
|
||||
SocialIssueRender $socialIssueRender,
|
||||
TranslatableStringHelperInterface $translatableStringHelper,
|
||||
TranslatorInterface $translator,
|
||||
RollingDateConverterInterface $rollingDateConverter,
|
||||
UserHelper $userHelper
|
||||
) {
|
||||
@@ -126,6 +130,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
$this->thirdPartyRender = $thirdPartyRender;
|
||||
$this->thirdPartyRepository = $thirdPartyRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->translator = $translator;
|
||||
$this->rollingDateConverter = $rollingDateConverter;
|
||||
$this->userHelper = $userHelper;
|
||||
}
|
||||
@@ -182,7 +187,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->translatableStringHelper->localize(json_decode($value, true));
|
||||
return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
|
||||
};
|
||||
|
||||
case 'locationPersonName':
|
||||
@@ -226,7 +231,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->translatableStringHelper->localize($s),
|
||||
json_decode($value, true)
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
@@ -245,11 +250,32 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
'|',
|
||||
array_map(
|
||||
fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []),
|
||||
json_decode($value, true)
|
||||
json_decode($value, true, 512, JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
case 'step':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.step',
|
||||
null => '',
|
||||
AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'),
|
||||
AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'),
|
||||
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
case 'intensity':
|
||||
return fn ($value) => match ($value) {
|
||||
'_header' => 'export.list.acp.intensity',
|
||||
null => '',
|
||||
AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'),
|
||||
AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'),
|
||||
default => $value,
|
||||
};
|
||||
|
||||
default:
|
||||
return static function ($value) use ($key) {
|
||||
if ('_header' === $value) {
|
||||
@@ -290,9 +316,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -263,9 +263,7 @@ class ListAccompanyingPeriodWork implements ListInterface, GroupedExportInterfac
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -241,9 +241,7 @@ class ListEvaluation implements ListInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -146,9 +146,7 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
|
@@ -191,9 +191,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
|
||||
*/
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
@@ -334,7 +332,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
|
||||
|
||||
return $this->customFieldProvider
|
||||
->getCustomFieldByType($cf->getType())
|
||||
->render(json_decode($value, true), $cf, 'csv');
|
||||
->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv');
|
||||
};
|
||||
|
||||
if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) {
|
||||
@@ -344,7 +342,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
|
||||
if (null === $value) {
|
||||
return '';
|
||||
}
|
||||
$decoded = json_decode($value, true);
|
||||
$decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
if ('_header' === $value) {
|
||||
$label = $cfType->getChoices($cf)[$slugChoice];
|
||||
|
@@ -159,9 +159,7 @@ class ListPersonWithAccompanyingPeriod implements ExportElementValidatedInterfac
|
||||
*/
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
// throw an error if any fields are present
|
||||
if (!array_key_exists('fields', $data)) {
|
||||
|
@@ -112,9 +112,7 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||
{
|
||||
$centers = array_map(static function ($el) {
|
||||
return $el['center'];
|
||||
}, $acl);
|
||||
$centers = array_map(static fn ($el) => $el['center'], $acl);
|
||||
|
||||
$qb = $this->repository->createQueryBuilder('acp');
|
||||
|
||||
|
@@ -59,9 +59,7 @@ class ClosingMotiveFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('accepted_closingmotives', EntityType::class, [
|
||||
'class' => ClosingMotive::class,
|
||||
'choice_label' => function (ClosingMotive $cm) {
|
||||
return $this->translatableStringHelper->localize($cm->getName());
|
||||
},
|
||||
'choice_label' => fn (ClosingMotive $cm) => $this->translatableStringHelper->localize($cm->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -61,11 +61,9 @@ class CreatorJobFilter implements FilterInterface
|
||||
$builder->add('creator_job', EntityType::class, [
|
||||
'class' => UserJob::class,
|
||||
'choices' => $this->userJobRepository->findAllActive(),
|
||||
'choice_label' => function (UserJob $j) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
);
|
||||
},
|
||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'label' => 'Job',
|
||||
|
@@ -69,9 +69,7 @@ class EvaluationFilter implements FilterInterface
|
||||
$builder->add('accepted_evaluations', EntityType::class, [
|
||||
'class' => Evaluation::class,
|
||||
'choices' => $this->evaluationRepository->findAllActive(),
|
||||
'choice_label' => function (Evaluation $ev) {
|
||||
return $this->translatableStringHelper->localize($ev->getTitle());
|
||||
},
|
||||
'choice_label' => fn (Evaluation $ev) => $this->translatableStringHelper->localize($ev->getTitle()),
|
||||
'multiple' => true,
|
||||
'expanded' => false,
|
||||
'attr' => ['class' => 'select2'],
|
||||
|
@@ -107,9 +107,7 @@ class GeographicalUnitStatFilter implements FilterInterface
|
||||
'placeholder' => 'Select a geographical unit',
|
||||
'choices' => $this->geographicalUnitRepository->findAll(),
|
||||
'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id,
|
||||
'choice_label' => function (SimpleGeographicalUnitDTO $item) {
|
||||
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
|
||||
},
|
||||
'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
|
||||
'attr' => [
|
||||
'class' => 'select2',
|
||||
],
|
||||
@@ -124,9 +122,7 @@ class GeographicalUnitStatFilter implements FilterInterface
|
||||
'%units' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
function (SimpleGeographicalUnitDTO $item) {
|
||||
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
|
||||
},
|
||||
fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
|
||||
$data['units']
|
||||
)
|
||||
),
|
||||
|
@@ -0,0 +1,91 @@
|
||||
<?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\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\DateIntervalType;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodInfo;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* Filter accompanying course which have a row in AccompanyingPeriodInfo within the given
|
||||
* interval
|
||||
*/
|
||||
final readonly class HavingAnAccompanyingPeriodInfoWithinDatesFilter implements FilterInterface
|
||||
{
|
||||
public function __construct(
|
||||
private RollingDateConverterInterface $rollingDateConverter,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
->add('start_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.having_info_within_interval.start_date',
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
])
|
||||
->add('end_date', PickRollingDateType::class, [
|
||||
'label' => 'export.filter.course.having_info_within_interval.end_date',
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.having_info_within_interval.title';
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'export.filter.course.having_info_within_interval.Only course with events between %startDate% and %endDate%',
|
||||
[
|
||||
'%startDate%' => $this->rollingDateConverter->convert($data['start_date'])->format('d-m-Y'),
|
||||
'%endDate%' => $this->rollingDateConverter->convert($data['end_date'])->format('d-m-Y'),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$ai = 'having_ai_within_interval_acc_info';
|
||||
$as = 'having_ai_within_interval_start_date';
|
||||
$ae = 'having_ai_within_interval_end_date';
|
||||
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
'SELECT 1 FROM ' . AccompanyingPeriodInfo::class . " {$ai} WHERE {$ai}.infoDate BETWEEN :{$as} AND :{$ae} AND IDENTITY({$ai}.accompanyingPeriod) = acp.id"
|
||||
)
|
||||
)
|
||||
->setParameter($as, $this->rollingDateConverter->convert($data['start_date']), Types::DATETIME_IMMUTABLE)
|
||||
->setParameter($ae, $this->rollingDateConverter->convert($data['end_date']), Types::DATETIME_IMMUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -59,9 +59,7 @@ class OriginFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('accepted_origins', EntityType::class, [
|
||||
'class' => Origin::class,
|
||||
'choice_label' => function (Origin $o) {
|
||||
return $this->translatableStringHelper->localize($o->getLabel());
|
||||
},
|
||||
'choice_label' => fn (Origin $o) => $this->translatableStringHelper->localize($o->getLabel()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -32,9 +32,11 @@ class StepFilter implements FilterInterface
|
||||
private const P = 'acp_step_filter_date';
|
||||
|
||||
private const STEPS = [
|
||||
'Draft' => AccompanyingPeriod::STEP_DRAFT,
|
||||
'Confirmed' => AccompanyingPeriod::STEP_CONFIRMED,
|
||||
'Closed' => AccompanyingPeriod::STEP_CLOSED,
|
||||
'course.draft' => AccompanyingPeriod::STEP_DRAFT,
|
||||
'course.confirmed' => AccompanyingPeriod::STEP_CONFIRMED,
|
||||
'course.closed' => AccompanyingPeriod::STEP_CLOSED,
|
||||
'course.inactive_short' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT,
|
||||
'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG,
|
||||
];
|
||||
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
@@ -96,7 +98,7 @@ class StepFilter implements FilterInterface
|
||||
'data' => self::DEFAULT_CHOICE,
|
||||
])
|
||||
->add('calc_date', PickRollingDateType::class, [
|
||||
'label' => 'export.acp.filter.by_step.date_calc',
|
||||
'label' => 'export.filter.course.by_step.date_calc',
|
||||
'data' => new RollingDate(RollingDate::T_TODAY),
|
||||
]);
|
||||
}
|
||||
|
@@ -0,0 +1,88 @@
|
||||
<?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\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* Filter course where a user is "working" on it
|
||||
*
|
||||
* Makes use of AccompanyingPeriodInfo
|
||||
*/
|
||||
readonly class UserWorkingOnCourseFilter implements FilterInterface
|
||||
{
|
||||
private const AI_ALIAS = 'user_working_on_course_filter_acc_info';
|
||||
private const AI_USERS = 'user_working_on_course_filter_users';
|
||||
|
||||
public function __construct(
|
||||
private UserRender $userRender,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder): void
|
||||
{
|
||||
$builder
|
||||
->add('users', PickUserDynamicType::class, [
|
||||
'multiple' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'export.filter.course.by_user_working.title';
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
return [
|
||||
'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [
|
||||
'%users%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
fn (User $u) => $this->userRender->renderString($u, []),
|
||||
$data['users']
|
||||
)
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data): void
|
||||
{
|
||||
$qb
|
||||
->andWhere(
|
||||
$qb->expr()->exists(
|
||||
"SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " .
|
||||
"WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id"
|
||||
)
|
||||
)
|
||||
->setParameter(self::AI_USERS, $data['users'])
|
||||
;
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
}
|
@@ -59,9 +59,7 @@ final class EvaluationTypeFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('accepted_evaluationtype', EntityType::class, [
|
||||
'class' => Evaluation::class,
|
||||
'choice_label' => function (Evaluation $ev): string {
|
||||
return $this->translatableStringHelper->localize($ev->getTitle());
|
||||
},
|
||||
'choice_label' => fn (Evaluation $ev): string => $this->translatableStringHelper->localize($ev->getTitle()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -78,11 +78,9 @@ class CompositionFilter implements FilterInterface
|
||||
$builder
|
||||
->add('accepted_composition', EntityType::class, [
|
||||
'class' => HouseholdCompositionType::class,
|
||||
'choice_label' => function (HouseholdCompositionType $type) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$type->getLabel()
|
||||
);
|
||||
},
|
||||
'choice_label' => fn (HouseholdCompositionType $type) => $this->translatableStringHelper->localize(
|
||||
$type->getLabel()
|
||||
),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
])
|
||||
|
@@ -81,9 +81,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||
->add('ref_statuses', ChoiceType::class, [
|
||||
'label' => 'export.filter.person.by_address_ref_status.Status',
|
||||
'choices' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW, Address::ADDR_REFERENCE_STATUS_REVIEWED, Address::ADDR_REFERENCE_STATUS_MATCH],
|
||||
'choice_label' => function (string $item) {
|
||||
return 'export.filter.person.by_address_ref_status.'.$item;
|
||||
},
|
||||
'choice_label' => fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'data' => [Address::ADDR_REFERENCE_STATUS_TO_REVIEW]
|
||||
@@ -99,9 +97,7 @@ class AddressRefStatusFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||
'%statuses%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
function (string $item) {
|
||||
return 'export.filter.person.by_address_ref_status.'.$item;
|
||||
},
|
||||
fn (string $item) => 'export.filter.person.by_address_ref_status.'.$item,
|
||||
$data['ref_statuses'] ?? RollingDate::T_TODAY
|
||||
)
|
||||
),
|
||||
|
@@ -42,8 +42,8 @@ class AgeFilter implements ExportElementValidatedInterface, FilterInterface
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
$min = null !== $data['min_age'] ? $data['min_age'] : 0;
|
||||
$max = null !== $data['max_age'] ? $data['max_age'] : 150;
|
||||
$min = $data['min_age'] ?? 0;
|
||||
$max = $data['max_age'] ?? 150;
|
||||
$calc = $this->rollingDateConverter->convert($data['date_calc']);
|
||||
|
||||
$minDate = $calc->sub(new DateInterval('P' . $max . 'Y'));
|
||||
|
@@ -67,9 +67,7 @@ class GenderFilter implements
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('person_gender', array_filter(
|
||||
$data['accepted_genders'],
|
||||
static function ($el) {
|
||||
return 'null' !== $el;
|
||||
}
|
||||
static fn ($el) => 'null' !== $el
|
||||
));
|
||||
}
|
||||
|
||||
|
@@ -98,9 +98,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||
'placeholder' => 'Select a geographical unit',
|
||||
'choices' => $this->geographicalUnitRepository->findAll(),
|
||||
'choice_value' => static fn (SimpleGeographicalUnitDTO $item) => $item->id,
|
||||
'choice_label' => function (SimpleGeographicalUnitDTO $item) {
|
||||
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
|
||||
},
|
||||
'choice_label' => fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
|
||||
'attr' => [
|
||||
'class' => 'select2',
|
||||
],
|
||||
@@ -117,9 +115,7 @@ class GeographicalUnitFilter implements \Chill\MainBundle\Export\FilterInterface
|
||||
'%units%' => implode(
|
||||
', ',
|
||||
array_map(
|
||||
function (SimpleGeographicalUnitDTO $item) {
|
||||
return $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName;
|
||||
},
|
||||
fn (SimpleGeographicalUnitDTO $item) => $this->translatableStringHelper->localize($this->geographicalUnitLayerRepository->find($item->layerId)->getName()) . ' > ' . $item->unitName,
|
||||
$data['units']
|
||||
)
|
||||
),
|
||||
|
@@ -49,11 +49,9 @@ class MaritalStatusFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('maritalStatus', EntityType::class, [
|
||||
'class' => MaritalStatus::class,
|
||||
'choice_label' => function (MaritalStatus $ms) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$ms->getName()
|
||||
);
|
||||
},
|
||||
'choice_label' => fn (MaritalStatus $ms) => $this->translatableStringHelper->localize(
|
||||
$ms->getName()
|
||||
),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -72,9 +72,7 @@ class NationalityFilter implements
|
||||
{
|
||||
$countries = $data['nationalities'];
|
||||
|
||||
$names = array_map(function (Country $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
}, [$countries]);
|
||||
$names = array_map(fn (Country $c) => $this->translatableStringHelper->localize($c->getName()), [$countries]);
|
||||
|
||||
return [
|
||||
'Filtered by nationality : %nationalities%',
|
||||
|
@@ -100,9 +100,7 @@ class ResidentialAddressAtThirdpartyFilter implements FilterInterface
|
||||
$builder->add('thirdparty_cat', EntityType::class, [
|
||||
'class' => ThirdPartyCategory::class,
|
||||
'label' => 'Category',
|
||||
'choice_label' => function (ThirdPartyCategory $tpc) {
|
||||
return $this->translatableStringHelper->localize($tpc->getName());
|
||||
},
|
||||
'choice_label' => fn (ThirdPartyCategory $tpc) => $this->translatableStringHelper->localize($tpc->getName()),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -69,11 +69,9 @@ class JobFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('job', EntityType::class, [
|
||||
'class' => UserJob::class,
|
||||
'choice_label' => function (UserJob $j) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
);
|
||||
},
|
||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -69,11 +69,9 @@ class ScopeFilter implements FilterInterface
|
||||
{
|
||||
$builder->add('scope', EntityType::class, [
|
||||
'class' => Scope::class,
|
||||
'choice_label' => function (Scope $s) {
|
||||
return $this->translatableStringHelper->localize(
|
||||
$s->getName()
|
||||
);
|
||||
},
|
||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
||||
$s->getName()
|
||||
),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
]);
|
||||
|
@@ -136,7 +136,7 @@ class SocialWorkTypeFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered actions by type, goals and results: %selected%', [
|
||||
'%selected%' => implode(', ', array_merge($actionTypes, $goals, $results)),
|
||||
'%selected%' => implode(', ', [...$actionTypes, ...$goals, ...$results]),
|
||||
]];
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ class LabelPersonHelper
|
||||
return '';
|
||||
}
|
||||
|
||||
$decoded = json_decode($value);
|
||||
$decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
if (0 === count($decoded)) {
|
||||
return '';
|
||||
|
@@ -361,7 +361,7 @@ class ListPersonHelper
|
||||
return '';
|
||||
}
|
||||
|
||||
$ids = json_decode($value);
|
||||
$ids = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
return
|
||||
implode(
|
||||
|
Reference in New Issue
Block a user