mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 11:18:25 +00:00 
			
		
		
		
	Feature: [export] Finalize HasTemporaryLocation filter on accompanying
course
This commit is contained in:
		@@ -12,8 +12,12 @@ declare(strict_types=1);
 | 
			
		||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Export\FilterInterface;
 | 
			
		||||
use Chill\MainBundle\Form\Type\ChillDateType;
 | 
			
		||||
use Chill\PersonBundle\Export\Declarations;
 | 
			
		||||
use DateTimeImmutable;
 | 
			
		||||
use Doctrine\ORM\QueryBuilder;
 | 
			
		||||
use LogicException;
 | 
			
		||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
 | 
			
		||||
use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class HasTemporaryLocationFilter implements FilterInterface
 | 
			
		||||
@@ -26,10 +30,25 @@ class HasTemporaryLocationFilter implements FilterInterface
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        $qb
 | 
			
		||||
            ->andWhere(
 | 
			
		||||
                $qb->expr()->in('', ':')
 | 
			
		||||
            )
 | 
			
		||||
            ->setParameter('', $data[]);
 | 
			
		||||
            ->join('acp.locationHistories', 'acp_having_temporarily_location')
 | 
			
		||||
            ->andWhere('acp_having_temporarily_location.startDate <= :acp_having_temporarily_location_date
 | 
			
		||||
                 AND (acp_having_temporarily_location.endDate IS NULL OR acp_having_temporarily_location.endDate > :acp_having_temporarily_location_date)')
 | 
			
		||||
            ->setParameter('acp_having_temporarily_location_date', $data['calc_date']);
 | 
			
		||||
 | 
			
		||||
        switch ($data['having_temporarily']) {
 | 
			
		||||
            case true:
 | 
			
		||||
                $qb->andWhere('acp_having_temporarily_location.addressLocation IS NOT NULL');
 | 
			
		||||
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            case false:
 | 
			
		||||
                $qb->andWhere('acp_having_temporarily_location.personLocation IS NOT NULL');
 | 
			
		||||
 | 
			
		||||
                break;
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                throw new LogicException('value not supported');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function applyOn(): string
 | 
			
		||||
@@ -39,13 +58,44 @@ class HasTemporaryLocationFilter implements FilterInterface
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
        //$builder->add();
 | 
			
		||||
        $builder
 | 
			
		||||
            ->add('having_temporarily', ChoiceType::class, [
 | 
			
		||||
                'choices' => [
 | 
			
		||||
                    'export.filter.course.having_temporarily.Having a temporarily location' => true,
 | 
			
		||||
                    'export.filter.course.having_temporarily.Having a person\'s location' => false,
 | 
			
		||||
                ],
 | 
			
		||||
                'choice_label' => static function ($choice) {
 | 
			
		||||
                    switch ($choice) {
 | 
			
		||||
                        case true:
 | 
			
		||||
                            return 'export.filter.course.having_temporarily.Having a temporarily location';
 | 
			
		||||
 | 
			
		||||
                        case false:
 | 
			
		||||
                            return 'export.filter.course.having_temporarily.Having a person\'s location';
 | 
			
		||||
 | 
			
		||||
                        default:
 | 
			
		||||
                            throw new LogicException('this choice is not supported');
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
            ])
 | 
			
		||||
            ->add('calc_date', ChillDateType::class, [
 | 
			
		||||
                'label' => 'export.filter.course.having_temporarily.Calculation date',
 | 
			
		||||
                'input' => 'datetime_immutable',
 | 
			
		||||
                'data' => new DateTimeImmutable(),
 | 
			
		||||
            ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function describeAction($data, $format = 'string'): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['', [
 | 
			
		||||
        ]];
 | 
			
		||||
        switch ($data['having_temporarily']) {
 | 
			
		||||
            case true:
 | 
			
		||||
                return ['export.filter.course.having_temporarily.Having a temporarily location', []];
 | 
			
		||||
 | 
			
		||||
            case false:
 | 
			
		||||
                return ['export.filter.course.having_temporarily.Having a person\'s location', []];
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                throw new LogicException('value not supported');
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getTitle(): string
 | 
			
		||||
 
 | 
			
		||||
@@ -574,7 +574,7 @@ Group by number of actions: Grouper les parcours par nombre d’actions
 | 
			
		||||
Filter by creator: Filtrer les parcours par créateur
 | 
			
		||||
Filter by creator job: Filtrer les parcours par métier du créateur
 | 
			
		||||
Group by creator job: Grouper les parcours par métier du créateur
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
Filter by current actions: Filtrer les actions en cours
 | 
			
		||||
Filtered by current action: Filtré les actions en cours
 | 
			
		||||
Group by current actions: Grouper les actions en cours
 | 
			
		||||
@@ -1019,6 +1019,10 @@ export:
 | 
			
		||||
                Computation date for referrer: Date à laquelle le référent était actif
 | 
			
		||||
            by_referrer:
 | 
			
		||||
                Computation date for referrer: Date à laquelle le référent était actif
 | 
			
		||||
            having_temporarily:
 | 
			
		||||
                Having a temporarily location: Ayant une localisation temporaire
 | 
			
		||||
                Having a person's location: Ayant une localisation auprès d'un usager
 | 
			
		||||
                Calculation date: Date de la localisation
 | 
			
		||||
    list:
 | 
			
		||||
        person_with_acp:
 | 
			
		||||
            List peoples having an accompanying period: Liste des personnes ayant un parcours d'accompagnement
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user