Commit e3a20622 authored by Thomas Hamel's avatar Thomas Hamel Committed by Bertrand Gauthier
Browse files

ajout d'un filtre 'soutenances terminées incluses' sur l'index des soutenances HDR

parent 25a8b368
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -47,6 +47,13 @@ class HDR implements HistoriqueAwareInterface, HasHorodatagesInterface, Resource
        self::ETAT_SOUTENANCE_PROGRAMMEE
    ];

    public const ETATS_TOUS = [
        self::ETAT_EN_COURS,
        self::ETAT_SOUTENANCE_PROGRAMMEE,
        self::ETAT_SOUTENUE,
        self::ETAT_ABANDONNEE,
    ];

    public static array $etatsLibelles = [
        self::ETAT_EN_COURS   => "En cours",
        self::ETAT_SOUTENANCE_PROGRAMMEE   => "Soutenance programmée",
+18 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ class Etat implements HistoriqueAwareInterface, SearchFilterValueInterface
    private $code;
    /** @var string */
    private $libelle;
    /** @var int */
    private $ordre;

    /**
     * @return int
@@ -68,6 +70,22 @@ class Etat implements HistoriqueAwareInterface, SearchFilterValueInterface
        return $this;
    }

    /**
     * @return int
     */
    public function getOrdre(): int
    {
        return $this->ordre;
    }

    /**
     * @param int $ordre
     */
    public function setOrdre(int $ordre): void
    {
        $this->ordre = $ordre;
    }

    /**
     * @inheritDoc
     */
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@

        <field name="code"              type="string"       length="64"         column="code"           nullable="false"/>
        <field name="libelle"           type="string"       length="256"        column="libelle"        nullable="false"/>
        <field name="ordre" type="integer" column="ordre" nullable="false" />

        <!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        <field name="histoCreation" type="datetime" column="histo_creation" nullable="false"/>
+45 −0
Original line number Diff line number Diff line
<?php

namespace Soutenance\Search\Proposition\estTerminee;

use Doctrine\ORM\QueryBuilder;
use UnicaenSearch\Filter\CheckboxSearchFilter;

/**
 * Filtre de type case à cocher dont le fonctionnement est le suivant :
 *   - s'il est décoché : n'ajoute rien au query builder.
 *   - s'il est coché : ajoute au query builder une clause écartant les propositions dont la thèse/HDR est en cours ;
 */
class EstTermineeSearchFilter extends CheckboxSearchFilter
{
    public const NAME = 'estTerminee';

    protected string $name = self::NAME;
    protected string $label = "Soutenances terminées incluses";

    /** @var string Le préfixe d'alias de l'entité dans le QueryBuilder (ex: "hdr", "these") */
    protected string $entityAlias;

    /** @var string Le nom du champ à filtrer (ex: "etatHDR", "etatThese") */
    protected string $stateField = 'etatThese';

    /** @var array les états sur lesquels filtrer */
    protected array $etats = [];

    public function __construct(string $entityAlias = 'these', string $stateField = 'etatThese', array $etats = [])
    {
        parent::__construct();

        $this->entityAlias = $entityAlias;
        $this->stateField = $stateField;
        $this->etats = $etats;
    }

    public function applyToQueryBuilder(QueryBuilder $qb): void
    {
        if ($this->getValue()) {
            $field = "{$this->entityAlias}.{$this->stateField}";
            $qb->andWhere("$field in (:$this->stateField)")->setParameter($this->stateField, $this->etats);
        }
    }
}
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
<?php

namespace Soutenance\Search\Proposition\estTerminee;

trait EstTermineeSearchFilterAwareTrait
{
    protected ?EstTermineeSearchFilter $estTermineeSearchFilter = null;

    public function getEstTermineeSearchFilter(string $entityAlias = 'these', string $stateField = 'etatThese', array $etats = []): EstTermineeSearchFilter
    {
        if ($this->estTermineeSearchFilter === null) {
            $this->estTermineeSearchFilter = new EstTermineeSearchFilter($entityAlias, $stateField, $etats);
        }
        return $this->estTermineeSearchFilter;
    }

    public function setEstTermineeSearchFilter(EstTermineeSearchFilter $estTermineeSearchFilter): void
    {
        $this->estTermineeSearchFilter = $estTermineeSearchFilter;
    }
}
 No newline at end of file
Loading