mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 11:18:25 +00:00 
			
		
		
		
	exports: fix acp requestor aggregator
This commit is contained in:
		@@ -35,10 +35,10 @@ class DurationAggregator implements AggregatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getLabels($key, array $values, $data)
 | 
			
		||||
    {
 | 
			
		||||
        return function ($value) use ($data): string {
 | 
			
		||||
        return function ($value) use ($data): ?string {
 | 
			
		||||
 | 
			
		||||
            if ($value === '_header') {
 | 
			
		||||
                return $this->translator->trans('Rounded month duration');
 | 
			
		||||
                return 'Rounded month duration';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($value === null) {
 | 
			
		||||
@@ -105,12 +105,14 @@ class DurationAggregator implements AggregatorInterface
 | 
			
		||||
            // https://packagist.org/packages/doctrineum/date-interval#3.1.0
 | 
			
		||||
            // (composer fait un conflit de dépendance)
 | 
			
		||||
 | 
			
		||||
            //->addSelect("
 | 
			
		||||
            //    EXTRACT(
 | 
			
		||||
            //        month FROM
 | 
			
		||||
            //        DATE_INTERVAL(acp.closingDate, acp.openingDate)
 | 
			
		||||
            //    )
 | 
			
		||||
            //    AS duration_aggregator")
 | 
			
		||||
            /*
 | 
			
		||||
            ->addSelect("
 | 
			
		||||
                EXTRACT(
 | 
			
		||||
                    month FROM
 | 
			
		||||
                    DATE_INTERVAL(acp.closingDate, acp.openingDate)
 | 
			
		||||
                )
 | 
			
		||||
                AS duration_aggregator")
 | 
			
		||||
            */
 | 
			
		||||
 | 
			
		||||
            // NON
 | 
			
		||||
            //->addSelect("BETWEEN acp.openingDate AND acp.closingDate AS duration_aggregator")
 | 
			
		||||
 
 | 
			
		||||
@@ -30,27 +30,11 @@ class RequestorAggregator implements AggregatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getLabels($key, array $values, $data)
 | 
			
		||||
    {
 | 
			
		||||
        return function ($value): string {
 | 
			
		||||
            switch ($value) {
 | 
			
		||||
 | 
			
		||||
                case '_header':
 | 
			
		||||
                    return 'Requestor';
 | 
			
		||||
 | 
			
		||||
                case 'participation':
 | 
			
		||||
                    return $this->translator->trans('is person concerned');
 | 
			
		||||
 | 
			
		||||
                case 'other_person':
 | 
			
		||||
                    return $this->translator->trans('is other person');
 | 
			
		||||
 | 
			
		||||
                case 'thirdparty':
 | 
			
		||||
                    return $this->translator->trans('is thirdparty');
 | 
			
		||||
 | 
			
		||||
                case 'no_requestor':
 | 
			
		||||
                    return $this->translator->trans('no requestor');
 | 
			
		||||
 | 
			
		||||
                default:
 | 
			
		||||
                    throw new \LogicException(sprintf('The value %s is not valid', $value));
 | 
			
		||||
        return function ($value) use ($data): string {
 | 
			
		||||
            if ($value === '_header') {
 | 
			
		||||
                return 'Requestor';
 | 
			
		||||
            }
 | 
			
		||||
            return $this->translator->trans($value);
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -59,7 +43,9 @@ class RequestorAggregator implements AggregatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function getQueryKeys($data): array
 | 
			
		||||
    {
 | 
			
		||||
        return ['requestor_aggregator'];
 | 
			
		||||
        return [
 | 
			
		||||
            'requestor_aggregator'
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -91,17 +77,27 @@ class RequestorAggregator implements AggregatorInterface
 | 
			
		||||
     */
 | 
			
		||||
    public function alterQuery(QueryBuilder $qb, $data)
 | 
			
		||||
    {
 | 
			
		||||
        /*
 | 
			
		||||
        La requête va être différente par chaque regroupement. comment faire ?
 | 
			
		||||
        if (!in_array('part', $qb->getAllAliases())) {
 | 
			
		||||
            $qb->join('acp.participations', 'part');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $qb
 | 
			
		||||
            ->join('acp.requestorPerson','rp')
 | 
			
		||||
            ->join('acp.requestorThirdParty','rt')
 | 
			
		||||
            ->join('acp.participations', 'part')
 | 
			
		||||
        ;
 | 
			
		||||
 | 
			
		||||
        $qb->addSelect('rp.id AS requestor_aggregator');
 | 
			
		||||
        */
 | 
			
		||||
        $qb->addSelect("
 | 
			
		||||
            ( CASE 
 | 
			
		||||
                WHEN acp.requestorPerson IS NOT NULL
 | 
			
		||||
                THEN
 | 
			
		||||
                    ( CASE
 | 
			
		||||
                        WHEN acp.requestorPerson = part.person
 | 
			
		||||
                        THEN 'is person concerned'
 | 
			
		||||
                        ELSE 'is other person'
 | 
			
		||||
                    END )
 | 
			
		||||
                ELSE
 | 
			
		||||
                    ( CASE
 | 
			
		||||
                        WHEN acp.requestorThirdParty IS NOT NULL
 | 
			
		||||
                        THEN 'is thirdparty'
 | 
			
		||||
                        ELSE 'no requestor'
 | 
			
		||||
                    END ) 
 | 
			
		||||
            END ) AS requestor_aggregator
 | 
			
		||||
        ");
 | 
			
		||||
 | 
			
		||||
        $groupBy = $qb->getDQLPart('groupBy');
 | 
			
		||||
 | 
			
		||||
@@ -110,6 +106,8 @@ class RequestorAggregator implements AggregatorInterface
 | 
			
		||||
        } else {
 | 
			
		||||
            $qb->groupBy('requestor_aggregator');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // TODO 'order by' ne fonctionne pas, l'ordre n'est pas terrible
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -481,11 +481,11 @@ Group by administrative location: Grouper les parcours par localisation administ
 | 
			
		||||
Filter by requestor: Filtrer les parcours selon la présence du demandeur au sein des usagers concernés
 | 
			
		||||
Accepted choices: ''
 | 
			
		||||
is person concerned: Le demandeur est un usager concerné
 | 
			
		||||
is other person: Le demandeur est un autre usager
 | 
			
		||||
is other person: Le demandeur est un usager, mais n'est pas concerné
 | 
			
		||||
is thirdparty: Le demandeur est un tiers
 | 
			
		||||
no requestor: Il n'y a pas de demandeur
 | 
			
		||||
no requestor: Le parcours ne comporte pas de demandeur
 | 
			
		||||
"Filtered by requestor: only %choice%": "Filtré par présence du demandeur au sein des usagers concernés: uniquement si %choice%"
 | 
			
		||||
Group by requestor: Grouper selon la nature du demandeur
 | 
			
		||||
Group by requestor: Grouper les parcours selon la nature du demandeur
 | 
			
		||||
 | 
			
		||||
Filter by confidential: Filtrer les parcours par confidentialité
 | 
			
		||||
Accepted confidentials: ''
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user