Commit d650b7fa authored by Thomas Hamel's avatar Thomas Hamel
Browse files

Affichage de l'état dans un dossier d'admission

parent 2610a109
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ echo $this->partial('admission/admission/partial/header', []); ?>
                    <td><?php echo $admission->getIndividu()->getNomCompletFormatter()->avecNomPatronymique()->f() ?></td>
                    <td >
                        <div class="d-flex align-items-center">
                            <?php echo $this->etatHelper($admission->getEtat(), null, "") ?>
                            <?php echo $this->etatHelper($admission->getEtat()) ?>
                            <a href="<?php echo $this->url('admission/generer-statut-dossier', ['action' => 'generer-statut-dossier','admission' => $admission->getId()], [], true) ?>"
                               title="Appuyer pour avoir plus de détails"
                               data-bs-toggle="tooltip" data-bs-html="true" data-event="acces-statut-dossier" class="action ajax-modal" style="margin-left: 5px">
+3 −2
Original line number Diff line number Diff line
@@ -30,11 +30,12 @@ $canConfigurerModule = $this->isAllowed(AdmissionPrivileges::getResourceId(Admis
        </a>
    <?php endif; ?>

    <?php if(isset($individu)): ?>
        <?php echo $this->etatHelper($admission->getEtat(), null, '', ['css' => 'margin-left:10px;', 'textTooltip' => 'État du dossier d\'admission', 'afficherLibelleLong' => true]) ?>
    <?php endif; ?>

    <p class="introduction">Ce module permet dans un premier temps de candidater à un parcours doctoral.
        <br>Vous devrez remplir un formulaire en ligne et déposer les documents demandés.<br>
        Les données que vous saisissez dans ce formulaire sont automatiquement sauvegardées dès que vous avancez vers l'étape suivante, ou que vous revenez à l'étape précédente.
    </p>


</div>
+68 −21
Original line number Diff line number Diff line
@@ -11,65 +11,100 @@ use These\Entity\Db\These;

class EtatViewHelper extends AbstractHelper
{
    public function __invoke(string|Etat $etat = null, int|null $resultat = null, string $resultatString): string
    /**
     * Génère la représentation d'un état dans la vue.
     *
     * @param array<string, string>|object|null $etat  Soit un tableau ['libelle' => ..., 'code' => ...], soit une entité Etat*
     * @param int|null $resultat Facultatif. Utile pour afficher le résultat de la thèse ($these->getResultat)
     * @param string|null $resultatString Chaîne correspondant à une description plus longue du résultat, ($these->getResultatToString)
     * @param array{
     *      afficherLibelleLong?: bool,
     *      textTooltip?: string,
     *      css?: string
     *  } $options Options d'affichage supplémentaires.
     *
     * @return string   Le rendu HTML de l'état.
     */
    public function __invoke(mixed $etat = null, int|null $resultat = null, string|null $resultatString = "", $options = []): string
    {
        /** @var PhpRenderer $view */
        $view = $this->getView();
        $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));

        $colorClass = $this->getColorClass($etat, $resultat);
        $afficherLibelleLong = isset($options['afficherLibelleLong']) && $options['afficherLibelleLong'] === true ?? false;
        $css = $this->getCss($etat, $resultat, $afficherLibelleLong);
        $css .= $options['css'] ?? '';
        $iconEtatClass = $this->getIconEtatClass($etat, $resultat);
        $etatTextTooltipClass = $this->getEtatTextTooltipClass($etat, $resultat, $resultatString);
        $textTooltip = $options["textTooltip"] ?? $this->getEtatTextTooltip($etat, $resultat, $resultatString);

        return $this->view->partial('etat.phtml', [
            'colorClass' => $colorClass,
            'etat' => $etat,
            'css' => $css,
            'iconEtatClass' => $iconEtatClass,
            'etatTextTooltipClass' => $etatTextTooltipClass
            'textTooltip' => $textTooltip,
            'etatLibelle' => is_array($etat) ? $etat["libelle"] : $etat->getLibelle(),
            'options' => $options
        ]);
    }

    private function getColorClass(string|Etat $etat, int|null $resultat): string
    private function getCss(mixed $etat, int|null $resultat, bool $libelleLong): string
    {
        $etatCode = $etat instanceof Etat ? $etat->getCode() : $etat;
        $etatCode = is_array($etat) ? $etat["code"] : $etat->getCode();
        switch ($etatCode){
            case Etat::CODE_EN_COURS_SAISIE :
            case HDR::ETAT_SOUTENANCE_PROGRAMMEE :
                $colorEtat = "#ffba00";
            case \Soutenance\Entity\Etat::EN_COURS_SAISIE:
                $baseColor = "#ffba00";
                break;
            case Etat::CODE_EN_COURS_VALIDATION :
            case These::ETAT_EN_COURS :
                $colorEtat = "#f1732d";
            case \Soutenance\Entity\Etat::EN_COURS_EXAMEN:
                $baseColor = "#f1732d";
                break;
            case Etat::CODE_REJETE:
            case Etat::CODE_ABANDONNE:
            case These::ETAT_ABANDONNEE:
                $colorEtat = "#d23544";
            case \Soutenance\Entity\Etat::REJETEE:
                $baseColor = "#d23544";
                break;
            case These::ETAT_TRANSFEREE :
                $colorEtat = "grey";
                $baseColor = "grey";
                break;
            case Etat::CODE_VALIDE :
                $colorEtat = "var(--success-color)";
            case \Soutenance\Entity\Etat::VALIDEE :
                $baseColor = "var(--success-color)";
                break;
            case \Soutenance\Entity\Etat::ETABLISSEMENT :
                $baseColor = "teal";
                break;
            case \Soutenance\Entity\Etat::COMPLET :
                $baseColor = "dodgerblue";
                break;
            case These::ETAT_SOUTENUE :
                if(!$resultat){
                    $colorEtat = "var(--primary-color)";
                    $baseColor = "var(--primary-color)";
                }else{
                    $colorEtat = $resultat === 1 ? "var(--success-color)" : "#d23544";
                    $baseColor = $resultat === 1 ? "var(--success-color)" : "#d23544d23544;";
                }
                break;
            default:
                $colorEtat = "";
                $baseColor = "";
        }
        if ($libelleLong) {
            $style = "color:$baseColor; border-left: 5px solid {$baseColor};";
        } else {
            $style = "background-color:{$baseColor};";
        }

        return $colorEtat;
        return $style;
    }

    private function getIconEtatClass(string|Etat $etat, int|null $resultat): string
    private function getIconEtatClass(mixed $etat, int|null $resultat): string
    {
        $etatCode = $etat instanceof Etat ? $etat->getCode() : $etat;
        $etatCode = is_array($etat) ? $etat["code"] : $etat->getCode();
        switch ($etatCode){
            case Etat::CODE_EN_COURS_SAISIE :
            case \Soutenance\Entity\Etat::EN_COURS_SAISIE:
            $iconEtat = "icon icon-edit";
                break;
            case HDR::ETAT_SOUTENANCE_PROGRAMMEE :
@@ -77,6 +112,8 @@ class EtatViewHelper extends AbstractHelper
                break;
            case Etat::CODE_EN_COURS_VALIDATION :
            case These::ETAT_EN_COURS :
            case \Soutenance\Entity\Etat::EN_COURS_EXAMEN:
            case \Soutenance\Entity\Etat::COMPLET :
                $iconEtat = "icon icon-hourglass";
                break;
            case Etat::CODE_ABANDONNE:
@@ -87,11 +124,16 @@ class EtatViewHelper extends AbstractHelper
                $iconEtat = "icon icon-export";
                break;
            case Etat::CODE_REJETE:
            case \Soutenance\Entity\Etat::REJETEE :
                $iconEtat = "icon icon-ko";
                break;
            case Etat::CODE_VALIDE :
            case \Soutenance\Entity\Etat::VALIDEE :
                $iconEtat = "icon icon-ok";
                break;
            case \Soutenance\Entity\Etat::ETABLISSEMENT:
                $iconEtat = "icon icon-checked";
                break;
            case These::ETAT_SOUTENUE :
                if(!$resultat){
                    $iconEtat = "icon icon-question";
@@ -106,9 +148,9 @@ class EtatViewHelper extends AbstractHelper
        return $iconEtat;
    }

    private function getEtatTextTooltipClass(string|Etat $etat, int|null $resultat, string $resultatString): string
    private function getEtatTextTooltip(mixed $etat, int|null $resultat, string $resultatString): string
    {
        $etatCode = $etat instanceof Etat ? $etat->getCode() : $etat;
        $etatCode = is_array($etat) ? $etat["code"] : $etat->getCode();
        switch ($etatCode){
            case Etat::CODE_EN_COURS_SAISIE :
            case These::ETAT_EN_COURS :
@@ -142,4 +184,9 @@ class EtatViewHelper extends AbstractHelper

        return $etatTextTooltip;
    }

    public function __toString()
    {
        return '<div>État par défaut</div>';
    }
}
 No newline at end of file
+25 −6
Original line number Diff line number Diff line
<?php

/**
 * @var string $colorClass
 * @var mixed $etat
 * @var string $css
 * @var string $iconEtatClass
 * @var string $etatTextTooltipClass
 * @var string $textTooltip
 * @var string $etatLibelle
 * @var array $options
 **/

$afficherLibelleLong = isset($options['afficherLibelleLong']) && $options['afficherLibelleLong'] === true ?? false;
?>

<span class="badge text-white" style="background-color: <?= $colorClass ?>"
      data-bs-toggle="tooltip" data-bs-original-title="<?= $etatTextTooltipClass ?>">
<?php if($etat === null): ?>
    <p>Pas d'état</p>
<?php else: ?>
    <?php if($afficherLibelleLong): ?>
        <div class="row etat-informations-div">
            <div class="col-md-6 etat-informations-card"
                 style="<?=$css?>"
                 data-bs-toggle="tooltip" data-bs-original-title="<?=$textTooltip?>">
                <span class="<?=$iconEtatClass?>"></span>
                <h2><?= $etatLibelle; ?></h2>
            </div>
        </div>
    <?php else: ?>
        <span class="badge text-white" style="<?=$css?>"
              data-bs-toggle="tooltip" data-bs-original-title="<?= $textTooltip ?>">
          <span class="<?= $iconEtatClass ?>" style="padding-right: unset"></span>
    </span>
    <?php endif; ?>
<?php endif; ?>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Application\View\Renderer;

use Application\View\Helper\Etat\EtatViewHelper;
use Depot\View\Helper\Url\UrlDepotHelper;
use Fichier\Entity\Db\Fichier;
use Fichier\View\Helper\Fichier\FichierViewHelper;
@@ -165,6 +166,7 @@ use UnicaenIdref\View\Helper\IdrefLinkViewHelper;
 * @method ActualiteViewHelper actualite()
 * @method StructureViewHelper structure(Structure|Etablissement|EcoleDoctorale|UniteRecherche $structure, bool $afficherLibelle = true, bool $sansOmbre = false, $options = [])
 * @method FichierViewHelper fichier(Fichier $object, string $urlTelechargementFichier, string $urlSuppressionFichier, bool $canGererFichier, string $libelleOptionnel = "", bool $voirHistoInfo = true, bool $canVoirSuppression = true, bool $isTargetBlank = false, array $options = [])
 * @method EtatViewHelper etatHelper(mixed $etat = null, int|null $resultat = null, string|null $resultatString = "", $options = [])
 *
 * @method IdrefLinkViewHelper idrefLink(string $ppn)
 *
Loading