Commit 7ae8e991 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Apparition de l'année universitaire de 1ere inscription : mapping, filtre, page identité.

parent ef3ee4eb
Loading
Loading
Loading
Loading
+1 −0
Changes for module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.These.dcm.xml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
        <field name="etatThese" type="string" column="ETAT_THESE" length="20" nullable="false"/>
        <field name="resultat" type="integer" column="RESULTAT" nullable="true"/>
        <field name="datePremiereInscription" type="datetime" column="DATE_PREM_INSC" nullable="true"/>
        <field name="anneeUniv1ereInscription" type="integer" column="ANNEE_UNIV_1ERE_INSC" nullable="true"/>
        <field name="libelleDiscipline" type="string" column="LIB_DISC" length="200" nullable="true"/>
        <field name="datePrevisionSoutenance" type="datetime" column="DATE_PREV_SOUTENANCE" nullable="true"/>
        <field name="dateSoutenance" type="datetime" column="DATE_SOUTENANCE" nullable="true"/>
+25 −0
Changes for module/Application/src/Application/Entity/Db/Repository/TheseRepository.php: 25 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -62,6 +62,31 @@ class TheseRepository extends DefaultEntityRepository
        return $results;
    }

    /**
     * @param Etablissement|null $etablissement
     * @return int[]
     */
    public function fetchDistinctAnneesUniv1ereInscription(Etablissement $etablissement = null)
    {
        $qb = $this->createQueryBuilder('t');
        $qb
            ->distinct()
            ->select("t.anneeUniv1ereInscription")
            ->orderBy("t.anneeUniv1ereInscription");

        if ($etablissement !== null) {
            $qb
                ->join('t.etablissement', 'etab', Join::WITH, 'etab = :etablissement')
                ->setParameter('etablissement', $etablissement);
        }

        $results = array_map(function($value) {
            return current($value);
        }, $qb->getQuery()->getScalarResult());

        return $results;
    }

    /**
     * @param Etablissement|null $etablissement
     * @return int[]
+32 −0
Changes for module/Application/src/Application/Entity/Db/These.php: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -98,6 +98,11 @@ class These implements HistoriqueAwareInterface, ResourceInterface
     */
    private $datePremiereInscription;

    /**
     * @var integer
     */
    private $anneeUniv1ereInscription;

    /**
     * @var string
     */
@@ -1099,6 +1104,33 @@ class These implements HistoriqueAwareInterface, ResourceInterface
        return $this;
    }

    /**
     * @return int
     */
    public function getAnneeUniv1ereInscription()
    {
        return $this->anneeUniv1ereInscription;
    }

    /**
     * @return int
     */
    public function getAnneeUniv1ereInscriptionToString()
    {
        return $this->anneeUniv1ereInscription . '/' . ($this->anneeUniv1ereInscription + 1);
    }

    /**
     * @param int $anneeUniv1ereInscription
     * @return These
     */
    public function setAnneeUniv1ereInscription($anneeUniv1ereInscription)
    {
        $this->anneeUniv1ereInscription = (int) $anneeUniv1ereInscription;

        return $this;
    }

    /**
     * @return string
     */
+12 −0
Changes for module/Application/src/Application/Service/These/Filter/TheseSelectFilter.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ class TheseSelectFilter extends TheseFilter
    const NAME_ecoleDoctorale = 'ecoleDoctorale';
    const NAME_uniteRecherche = 'uniteRecherche';
    const NAME_anneePremiereInscription = 'anneePremiereInscription';
    const NAME_anneeUniv1ereInscription = 'anneeUnivPremiereInscription';
    const NAME_anneeSoutenance = 'anneeSoutenance';
    const NAME_discipline = 'discipline';
    const NAME_domaineScientifique = 'domaineScientifique';
@@ -103,6 +104,17 @@ class TheseSelectFilter extends TheseFilter
                }
                break;

            case self::NAME_anneeUniv1ereInscription:
                if ($filterValue === 'NULL') {
                    $qb
                        ->andWhere('t.anneeUniv1ereInscription IS NULL');
                } else {
                    $qb
                        ->andWhere('t.anneeUniv1ereInscription = :anneeUniv1ereInscription')
                        ->setParameter('anneeUniv1ereInscription', $filterValue);
                }
                break;

            case self::NAME_anneeSoutenance:
                if ($filterValue === 'NULL') {
                    $qb
+40 −2
Changes for module/Application/src/Application/Service/These/TheseRechercheService.php: 40 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ class TheseRechercheService
            TheseSelectFilter::NAME_uniteRecherche           => [],
            TheseSelectFilter::NAME_financement              => [],
            TheseSelectFilter::NAME_anneePremiereInscription => [],
            TheseSelectFilter::NAME_anneeUniv1ereInscription => [],
            TheseSelectFilter::NAME_anneeSoutenance          => [],
//            TheseSelectFilter::NAME_discipline               => [],
            TheseSelectFilter::NAME_domaineScientifique      => [],
@@ -99,6 +100,7 @@ class TheseRechercheService
            TheseSelectFilter::NAME_uniteRecherche           => $this->fetchUnitesRecherchesOptions(),
            TheseSelectFilter::NAME_financement              => $this->fetchOriginesFinancementsOptions(),
            TheseSelectFilter::NAME_anneePremiereInscription => $this->fetchAnneesInscriptionOptions(),
            TheseSelectFilter::NAME_anneeUniv1ereInscription => $this->fetchAnneesUniv1ereInscriptionOptions(),
            TheseSelectFilter::NAME_anneeSoutenance          => $this->fetchAnneesSoutenance(),
//            TheseSelectFilter::NAME_discipline               => $this->fetchDisciplinesOptions(),
            TheseSelectFilter::NAME_domaineScientifique      => $this->fetchDomainesScientifiquesOptions(),
@@ -144,10 +146,15 @@ class TheseRechercheService
                ['width' => '125px', 'liveSearch' => true]
            ),
            TheseSelectFilter::NAME_anneePremiereInscription => new TheseSelectFilter(
                "1ère inscr.",
                "Année civile<br>1ère inscr.",
                TheseSelectFilter::NAME_anneePremiereInscription,
                $optionsArray[TheseSelectFilter::NAME_anneePremiereInscription]
            ),
            TheseSelectFilter::NAME_anneeUniv1ereInscription => new TheseSelectFilter(
                "Année univ.<br>1ère inscr.",
                TheseSelectFilter::NAME_anneeUniv1ereInscription,
                $optionsArray[TheseSelectFilter::NAME_anneeUniv1ereInscription]
            ),
            TheseSelectFilter::NAME_anneeSoutenance => new TheseSelectFilter(
                "Soutenance",
                TheseSelectFilter::NAME_anneeSoutenance,
@@ -561,6 +568,37 @@ class TheseRechercheService
        return $this->addEmptyOption($options, "Toutes");
    }

    private function fetchAnneesUniv1ereInscriptionOptions()
    {
        $role = $this->getSelectedIdentityRole();

        $etablissement = null;
        if ($role->isEtablissementDependant()) {
            $etablissement = $role->getStructure()->getEtablissement();
        }
        $annees = $this->theseService->getRepository()->fetchDistinctAnneesUniv1ereInscription($etablissement);

        $annees = array_reverse(array_filter($annees));

        $options = [];
        $options[] = $this->optionify(null); // option spéciale pour valeur === null
        foreach ($annees as $annee) {
            $options[] = $this->optionify($annee);
        }

        // formattage spécial du label: "2018" devient "2018/2019"
        $options = array_map(function($value) {
            if (! is_numeric($value['label'])) {
                return $value;
            }
            $annee = (int) $value['label'];
            $value['label'] = $annee . '/' . ($annee+1);
            return $value;
        }, $options);

        return $this->addEmptyOption($options, "Toutes");
    }

    private function fetchAnneesSoutenance()
    {
        $role = $this->getSelectedIdentityRole();
@@ -679,7 +717,7 @@ class TheseRechercheService
        } elseif ($value instanceof OrigineFinancement) {
            return ['value' => (string) $value->getId(), 'label' => $value->getLibelleLong()];
        } elseif ($value === null) {
            return ['value' => 'NULL', 'label' => $label ?: "Inconnue"];
            return ['value' => 'NULL', 'label' => $label ?: "Inconnu(e)"];
        } elseif ($value === '') {
            return ['value' => '', 'label' => $label];
        } else {
Loading