Commit 9aac5dc3 authored by Johnny Leveneur's avatar Johnny Leveneur
Browse files

ajout filtre inscriptions et corrections mineures

parent e8c928eb
Loading
Loading
Loading
Loading
+25 −24
Original line number Diff line number Diff line
@@ -56,8 +56,10 @@ $rattachement = isset($params['rattachement'])?$params['rattachement']['label']:
                    <label for="rattachement"> Compte : </label>
                    <select id="compte" name="compte" class="selectpicker">
                        <option value="">Peu importe</option>
                        <option value="1" <?php if ($params['compte'] === "1") echo " selected "; ?>>Avec un compte</option>
                        <option value="0" <?php if ($params['compte'] === "0") echo " selected "; ?>>Sans compte</option>
                        <option value="1" <?php if ($params['compte'] === "1") echo " selected "; ?>>Avec un compte
                        </option>
                        <option value="0" <?php if ($params['compte'] === "0") echo " selected "; ?>>Sans compte
                        </option>
                    </select>
                </div>
                <!-- BOUTON -->
@@ -109,7 +111,6 @@ $rattachement = isset($params['rattachement'])?$params['rattachement']['label']:
        $('input[name="formateur[label]"]').val("<?php echo $formateurDenomination; ?>");
        <?php endif; ?>
        <?php if ($rattachement !== null) :?>
        //$('input[name="formateur[id]"]').val("<?php //echo $formateurId; ?>//");
        $('input[name="rattachement[label]"]').val("<?php echo $rattachement; ?>");
        <?php endif; ?>
    });
+4 −4
Original line number Diff line number Diff line
@@ -139,11 +139,11 @@ use UnicaenApp\Form\Element\SearchAndSelect;
    $(function () {
        const urlSearchParams = new URLSearchParams(window.location.search);

        const intervenantId = urlSearchParams.get('intervenant[id]');
        const intervenantDenomination = urlSearchParams.get('intervenant[label]');
        const intervenantId = urlSearchParams.get('etudiant[id]');
        const intervenantDenomination = urlSearchParams.get('etudiant[label]');
        if (intervenantId !== undefined && intervenantDenomination !== undefined) {
            $('input[name="intervenant[id]"]').val(intervenantId);
            $('input[name="intervenant[label]"]').val(intervenantDenomination);
            $('input[name="etudiant[id]"]').val(intervenantId);
            $('input[name="etudiant[label]"]').val(intervenantDenomination);
        }
    });
</script>
+2 −2
Original line number Diff line number Diff line
@@ -74,9 +74,9 @@ class EvenementController extends AbstractActionController
            $paramsFiltre['annee_univ'] = $paramsQuery['annee'];
        }

        $entities = $this->getEvenementService()->getEvenementsWithFiltre($paramsFiltre);
        $evenements = $this->getEvenementService()->getEvenementsWithFiltre($paramsFiltre);
        return new ViewModel([
            "entities" => $entities,
            "evenements" => $evenements,
            'paramsQuery' => $paramsQuery,
            'anneeUnivAsOptions' => $anneeUnivAsOptions
        ]);
+32 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Evenementiel\Controller;

use Etudiant\Service\Etudiant\EtudiantServiceAwareTrait;
use Evenementiel\Entity\Db\Inscription;
use Evenementiel\Entity\Db\Participant;
use Evenementiel\Provider\Etat\EvenementEtats;
use Evenementiel\Provider\Template\TemplatesMail;
use Evenementiel\Service\Evenement\EvenementServiceAwareTrait;
@@ -44,9 +45,37 @@ class InscriptionController extends AbstractActionController
     */
    public function indexAction(): ViewModel
    {
        $entities = $this->getInscriptionService()->getEntities();
        $anneeUnivAsOptions = $this->getEvenementService()->getAnneeUniv();
        $typeParticipantAsOptions = Participant::getTypesParticipant();

        $paramsQuery = $this->params()->fromQuery();

        // si anneeUniv nest pas défini on utilise la derniere année universitaire disponible
        if (!array_key_exists('annee', $paramsQuery)) {
            $paramsQuery['annee'] = array_key_last($anneeUnivAsOptions);
            $paramsFiltre['annee_univ'] = array_key_last($anneeUnivAsOptions);
        } else {
            $paramsFiltre['annee_univ'] = $paramsQuery['annee'];
        }

        if (array_key_exists('typeParticipant', $paramsQuery)
            && array_key_exists($paramsQuery['typeParticipant'], $typeParticipantAsOptions)) {
            $paramsFiltre['typeParticipant'] = $typeParticipantAsOptions[$paramsQuery['typeParticipant']];
        }

        if (array_key_exists('participant', $paramsQuery)) {
            if(array_key_exists('id', $paramsQuery['participant'])) {
                $paramsFiltre['id'] = $paramsQuery['participant']['id'];
            }
        }

        $inscriptions = $this->getInscriptionService()->getInscriptionsWithFiltre($paramsFiltre);

        return new ViewModel([
            "entities" => $entities,
            "inscriptions" => $inscriptions,
            'paramsQuery' => $paramsQuery,
            'anneeUnivAsOptions' => $anneeUnivAsOptions,
            'typeParticipantAsOptions' => $typeParticipantAsOptions,
        ]);
    }

+38 −1
Original line number Diff line number Diff line
@@ -115,6 +115,44 @@ class InscriptionService
        return $qb->getQuery()->getResult();
    }

    public function getInscriptionsWithFiltre(array $params = [], string $champ = 'id', string $ordre = 'ASC'): array
    {
        foreach ($params as $key => $value) {
            if ($value == null) {
                unset($params[$key]);
            }
        }

        $keysParticipant = ['typeParticipant', 'id'];

        $qb = $this->createQueryBuilder();
        $qb->leftJoin('entity.participant', 'participant');

        foreach ($params as $key => $value) {
            if ($key == 'annee_univ') {
                $debut = new \DateTimeImmutable($value  . '-09-01 00:00:00');
                $fin = $debut->modify('+1 year');

                $qb->andWhere('evenement.jour >= :debutAnneeUniv')
                    ->andWhere('evenement.jour < :finAnneeUniv')
                    ->setParameter('debutAnneeUniv', $debut)
                    ->setParameter('finAnneeUniv', $fin);
            }
            if (in_array($key, $keysParticipant, true)) {
                if($key == 'typeParticipant') {
                    $qb = $qb->andWhere('participant.typeParticipant = :typeParticipant')
                        ->setParameter('typeParticipant', $value);
                } else {
                    $qb = $qb->andWhere('participant.' . $key . ' = :' . $key)->setParameter($key, $value);
                }
            }
        }

        $qb = $qb->orderBy('entity.' . $champ, $ordre);
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * Get a single entity by ID
     *
@@ -259,4 +297,3 @@ class InscriptionService
//
//    }
}
Loading