mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Features: [export] Remove old unnecessary filters for person with accompanying period
Those filters applyed on persons and allowed to select person which has a new, closing, or active accompanying period. But this is deprecated: there are now a dedicated Export for that ( CountPersonWithAccompanyingCourse)
This commit is contained in:
parent
a7c44830d2
commit
8e44f20535
@ -97,11 +97,11 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
$loader->load('services/exports_person.yaml');
|
||||
|
||||
if ($container->getParameter('chill_person.accompanying_period') !== 'hidden') {
|
||||
$loader->load('services/exports_accompanying_period.yaml');
|
||||
$loader->load('services/exports_accompanying_course.yaml');
|
||||
$loader->load('services/exports_social_actions.yaml');
|
||||
$loader->load('services/exports_evaluation.yaml');
|
||||
}
|
||||
$loader->load('services/exports_accompanying_course.yaml');
|
||||
$loader->load('services/exports_social_actions.yaml');
|
||||
$loader->load('services/exports_evaluation.yaml');
|
||||
|
||||
$loader->load('services/exports_household.yaml');
|
||||
}
|
||||
|
||||
@ -944,10 +944,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
|
||||
/**
|
||||
* Add a widget "add a person" on the homepage, automatically.
|
||||
*
|
||||
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
||||
*/
|
||||
protected function prependHomepageWidget(containerBuilder $container)
|
||||
protected function prependHomepageWidget(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'widgets' => [
|
||||
|
@ -1,78 +0,0 @@
|
||||
<?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\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
{
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->lte('acp.closingDate', ':date_to'),
|
||||
$qb->expr()->gte('acp.closingDate', ':date_from')
|
||||
);
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period closed after this date',
|
||||
'data' => new DateTime('-1 month'),
|
||||
]);
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period closed before this date',
|
||||
'data' => new DateTime(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'Filtered by accompanying period: persons having an accompanying period'
|
||||
. ' closed between the %date_from% and %date_to%',
|
||||
[
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by accompanying period: closed between two dates';
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?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\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
{
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
$clause = $qb->expr()->andX();
|
||||
|
||||
$clause->add(
|
||||
$qb->expr()->lte('acp.openingDate', ':date_to')
|
||||
);
|
||||
$clause->add(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->gte('acp.closingDate', ':date_from'),
|
||||
$qb->expr()->isNull('acp.closingDate')
|
||||
)
|
||||
);
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period opened after this date',
|
||||
'data' => new DateTime('-1 month'),
|
||||
]);
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period ending before this date, or '
|
||||
. 'still opened at this date',
|
||||
'data' => new DateTime(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'Filtered by accompanying period: persons having an accompanying period'
|
||||
. ' opened after the %date_from% and closed before the %date_to% (or still opened '
|
||||
. 'at the %date_to%)',
|
||||
[
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by accompanying period: active period';
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
<?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\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\PersonBundle\Export\AbstractAccompanyingPeriodExportElement;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use DateTime;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportElement implements FilterInterface
|
||||
{
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$this->addJoinAccompanyingPeriod($qb);
|
||||
|
||||
$clause = $qb->expr()->andX(
|
||||
$qb->expr()->lte('acp.openingDate', ':date_to'),
|
||||
$qb->expr()->gte('acp.openingDate', ':date_from')
|
||||
);
|
||||
|
||||
$qb->andWhere($clause);
|
||||
$qb->setParameter('date_from', $data['date_from'], Types::DATE_MUTABLE);
|
||||
$qb->setParameter('date_to', $data['date_to'], Types::DATE_MUTABLE);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period opened after this date',
|
||||
'data' => new DateTime('-1 month'),
|
||||
]);
|
||||
|
||||
$builder->add('date_to', ChillDateType::class, [
|
||||
'label' => 'Having an accompanying period opened before this date',
|
||||
'data' => new DateTime(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return [
|
||||
'Filtered by accompanying period: persons having an accompanying period'
|
||||
. ' opened between the %date_from% and %date_to%',
|
||||
[
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Filter by accompanying period: starting between two dates';
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?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\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodClosingFilter;
|
||||
use DateTime;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodClosingFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private AccompanyingPeriodClosingFilter $filter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
try {
|
||||
$this->filter = self::$container->get('chill.person.export.filter_accompanying_period_closing');
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
$this->markTestSkipped('The current configuration does not use accompanying_periods');
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders(): array
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$container
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person'),
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('activity.date AS date')
|
||||
->select('activity.attendee as attendee')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
->join('person.center', 'center'),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?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\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodFilter;
|
||||
use DateTime;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private AccompanyingPeriodFilter $filter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
try {
|
||||
$this->filter = self::$container->get('chill.person.export.filter_accompanying_period');
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
$this->markTestSkipped('The current configuration does not use accompanying_periods');
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$container
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person'),
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('activity.date AS date')
|
||||
->select('activity.attendee as attendee')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
->join('person.center', 'center'),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
<?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\Tests\Export\Filter\PersonFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodOpeningFilter;
|
||||
use DateTime;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodOpeningFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private AccompanyingPeriodOpeningFilter $filter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
try {
|
||||
$this->filter = self::$container->get('chill.person.export.filter_accompanying_period_opening');
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
$this->markTestSkipped('The current configuration does not use accompanying_periods');
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'date_from' => DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||
'date_to' => DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (null === self::$kernel) {
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
$em = self::$container
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person'),
|
||||
$em->createQueryBuilder()
|
||||
->select('person.firstName')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('count(IDENTITY(p))')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('activity.date AS date')
|
||||
->select('activity.attendee as attendee')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.person', 'person')
|
||||
->join('person.center', 'center'),
|
||||
];
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
services:
|
||||
|
||||
chill.person.export.filter_accompanying_period:
|
||||
class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodFilter
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_accc_period_filter }
|
||||
|
||||
chill.person.export.filter_accompanying_period_opening:
|
||||
class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodOpeningFilter
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_acc_pe_op_filter }
|
||||
|
||||
chill.person.export.filter_accompanying_period_closing:
|
||||
class: Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodClosingFilter
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_acc_pe_cl_filter }
|
Loading…
x
Reference in New Issue
Block a user