Commit d35f5bfd authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Merge branch 'StructurePDC'

parents 3b6acc5d 4334bf44
Loading
Loading
Loading
Loading
Loading
+48 −56
Changes for module/Application/src/Application/Service/Fichier/FichierService.php: 48 added lines, 56 removed lines.
Original line number Diff line number Diff line
@@ -527,104 +527,96 @@ class FichierService extends BaseService
     * Cette fonction a pour vocation de récupérer les informations utile pour la génération de la page de couverture.
     * Si une clef est vide cela indique un problème associé à la thèse
     * @param These $these
     * @return []
     * @return PdcData
     */
    public function fetchInformationsPageDeCouverture(These $these) {
        $pdcData = new PdcData();
        $informations = [];

        if ($these === null) throw new LogicException("Une these doit être fournie pour pouvoir effectuer la récupération de ces données.");

        /**  informations générales */
        $informationsGenerales = ["titre", "etablissement", "specialité", "doctorant", "date de soutenance"];
        foreach ($informationsGenerales as $informationGenerale) $informations[$informationGenerale] = "";
        $pdcData->setTitre($these->getTitre());
        $pdcData->setSpecialite($these->getLibelleDiscipline());
        if ($these->getEtablissement()) $pdcData->setEtablissement($these->getEtablissement()->getLibelle());
        if ($these->getDoctorant()) $pdcData->setDoctorant($these->getDoctorant()->getIndividu()->getNomComplet(false, true, false, true, true));
        if ($these->getDateSoutenance()) $pdcData->setDate($these->getDateSoutenance()->format("d/m/Y"));

        $informations["titre"]                  = ($these->getTitre())?$these->getTitre():"";
        $informations["specialité"]             = ($these->getLibelleDiscipline())?$these->getLibelleDiscipline():"";
        $informations["etablissement"]          = ($these->getEtablissement())?$these->getEtablissement()->getLibelle():"";
        $informations["doctorant"]              = ($these->getDoctorant())?$these->getDoctorant()->getIndividu()->getNomComplet(false, true, false, true, true):"";
        $informations["date de soutenance"]     = ($these->getDateSoutenance())?$these->getDateSoutenance()->format("d/m/Y"):"";
        /** cotutelle */
        $pdcData->setCotutuelle(false);
        if($these->getLibelleEtabCotutelle() !== null && $these->getLibelleEtabCotutelle() !== "") {
            $pdcData->setCotutuelle(true);
            $pdcData->setCotutuelleLibelle($these->getLibelleEtabCotutelle());
            if ($these->getLibellePaysCotutelle()) $pdcData->setCotutuellePays($these->getLibellePaysCotutelle());
        }

        /** Jury de thèses */
        // TODO chercher les libellés des rôles dans des constantes
        $jury = [];
        $acteurs = $these->getActeurs()->toArray();
        $rapporteurs =  array_filter($acteurs, function(Acteur $a) { return $a->estRapporteur(); });
        $directeurs =  array_filter($acteurs, function(Acteur $a) { return $a->estDirecteur(); });
        $membres = array_diff($acteurs, $rapporteurs, $directeurs);
        $informations["cotut-libelle"] = ($these->getLibelleEtabCotutelle())?($these->getLibelleEtabCotutelle()):"non";
        $informations["cotut-pays"]    = ($these->getLibellePaysCotutelle())?($these->getLibellePaysCotutelle()):"non";

        $informations["avec-associe"] = "non";
        /** associée */
        $pdcData->setAssocie(false);
        /** @var Acteur $directeur */
        foreach ($directeurs as $directeur) {
            if ($directeur->getEtablissement()->estAssocie()) {
                $informations["avec-associe"] = "oui";
                $informations["logo-associe"] = $directeur->getEtablissement()->getCheminLogo();
                $informations["titre"] .= $informations["logo-associe"];
            }
                $pdcData->setAssocie(true);
                $pdcData->setLogoAssocie($directeur->getEtablissement()->getCheminLogo());
            }

        $informations["nombre de membres"]      = count($membres);
        $informations["nombre de rapporteurs"]  = count($rapporteurs)?count($rapporteurs):"";
        $informations["nombre de directeurs"]   = count($directeurs)?count($directeurs):"";
        $position = 1;
        foreach ($membres as $membre) {
            $informations["nom ".$position] = "";
            $informations["qualité ".$position] = "";
            $informations["etablissement ".$position] = "";
            $informations["role ".$position] = "";
            $position++;
        }

        $position = 1;
        /** @var Acteur $rapporteur */
        foreach ($rapporteurs as $rapporteur) {
            $informations["nom ".$position]             = $rapporteur->getIndividu()->getNomComplet(true,true,false, true, true);
            $informations["qualité ".$position]         = $rapporteur->getQualite();
            $informations["etablissement ".$position]   = ($etab = $rapporteur->getEtablissement()) ? $etab->getStructure()->getLibelle() : null;
            $informations["role ".$position]            = "Rapporteur du jury";
            $position++;
            $rapporteurData = new MembreData();
            $rapporteurData->setDenomination($rapporteur->getIndividu()->getNomComplet(true,true,false, true, true));
            $rapporteurData->setQualite($rapporteur->getQualite());
            $rapporteurData->setRole("Rapporteur du jury");
            if ($rapporteur->getEtablissement()) $rapporteurData->setEtablissement($rapporteur->getEtablissement()->getStructure()->getLibelle());
            $pdcData->addRapporteur($rapporteurData);
        }

        /** @var Acteur $membre */
        foreach ($membres as $membre) {
            $informations["nom ".$position]             = $membre->getIndividu()->getNomComplet(true,true,false, true, true);
            $informations["qualité ".$position]         = $membre->getQualite();
            $informations["etablissement ".$position]   = ($etab = $membre->getEtablissement()) ? $etab->getStructure()->getLibelle() : null;
            $informations["role ".$position]            = "Membre du jury";
            $position++;
            $membreData = new MembreData();
            $membreData->setDenomination($membre->getIndividu()->getNomComplet(true,true,false, true, true));
            $membreData->setQualite($membre->getQualite());
            $membreData->setRole("Membre du jury");
            if ($membre->getEtablissement()) $membreData->setEtablissement($membre->getEtablissement()->getStructure()->getLibelle());
            $pdcData->addMembre($membreData);
        }

        /** @var Acteur $directeur */
        foreach ($directeurs as $directeur) {
            $informations["nom ".$position]             = $directeur->getIndividu()->getNomComplet(true,true,false, true, true);
            $informations["qualité ".$position]         = $directeur->getQualite();
            $informations["etablissement ".$position]   = ($etab = $directeur->getEtablissement()) ? $etab->getStructure()->getLibelle() : null;
            $informations["role ".$position]            = "Directeur de thèse";
            $position++;
            $directeurData = new MembreData();
            $directeurData->setDenomination($directeur->getIndividu()->getNomComplet(true,true,false, true, true));
            $directeurData->setQualite($directeur->getQualite());
            $directeurData->setRole("Directeur de thèse");
            if ($directeur->getEtablissement()) $directeurData->setEtablissement($directeur->getEtablissement()->getStructure()->getLibelle());
            $pdcData->addDirecteur($directeurData);
        }

        /** Directeurs de thèses */
        $informationsGenerales = ["liste des directeurs", "Unité de recherche"];
        foreach ($informationsGenerales as $informationGenerale) $informations[$informationGenerale] = "";
        $nomination = [];
        /** @var Acteur $directeur */
        foreach ($directeurs as $directeur) $nomination[] = $directeur->getIndividu()->getNomComplet(false, true, false, true, true);
        $informations["liste des directeurs"]          = implode(" et ", $nomination);
        $informations["Unité de recherche"]            = ($these->getUniteRecherche())?$these->getUniteRecherche()->getStructure()->getLibelle():"";
        foreach ($directeurs as $directeur) {
            $nomination[] = $directeur->getIndividu()->getNomComplet(false, true, false, true, true);
        }
        $pdcData->setListing(implode(" et ", $nomination).", ");
        if ($these->getUniteRecherche()) $pdcData->setUniteRecherche($these->getUniteRecherche()->getStructure()->getLibelle());

        /** Logos à afficher */
        $logos = ["logo-comue", "logo-etablissement", "logo-ecoleDoctorale", "logo-uniteRecherche"];
        foreach ($logos as $logo) $informations[$logo] = "";

        $comue = $this->getEtablissementService()->getRepository()->find(1);
        $informations["logo-comue"]             = ($comue)?$comue->getCheminLogo():"";
        $informations["logo-etablissement"]     = ($these->getEtablissement())?$these->getEtablissement()->getCheminLogo():"";
        $informations["logo-ecoleDoctorale"]    = ($these->getEcoleDoctorale())?$these->getEcoleDoctorale()->getCheminLogo():"";
        $informations["logo-uniteRecherche"]    = ($these->getUniteRecherche())?$these->getUniteRecherche()->getCheminLogo():"";
        $pdcData->setLogoCOMUE( ($comue)?$comue->getCheminLogo():null);
        $pdcData->setLogoEtablissement($these->getEtablissement()?$these->getEtablissement()->getCheminLogo():null);
        $pdcData->setLogoEcoleDoctorale($these->getEcoleDoctorale()?$these->getEcoleDoctorale()->getCheminLogo():null);
        $pdcData->setLogoUniteRecherche($these->getUniteRecherche()?$these->getUniteRecherche()->getCheminLogo():null);


        return $informations;
        return $pdcData;
    }

    /**
@@ -635,11 +627,11 @@ class FichierService extends BaseService
    public function generatePageDeCouverture(These $these, RendererInterface $renderer, $filepath = null)
    {

        $informations = $this->fetchInformationsPageDeCouverture($these);
        $pdcData = $this->fetchInformationsPageDeCouverture($these);

        $exporter = new PageDeCouverturePdfExporter($renderer, 'A4');
        $exporter->setVars([
            'informations' => $informations,
            'informations' => $pdcData,
        ]);
        if ($filepath !== null) {
            $exporter->export($filepath, Pdf::DESTINATION_FILE);
+526
Changes for module/Application/src/Application/Service/Fichier/PdcData.php: 526 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Service\Fichier;

class MembreData {
    private $denomination;
    private $qualite;
    private $etablissement;
    private $role;

    /**
     * @return mixed
     */
    public function getDenomination()
    {
        return $this->denomination;
    }

    /**
     * @param mixed $denomination
     * @return MembreData
     */
    public function setDenomination($denomination)
    {
        $this->denomination = $denomination;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getQualite()
    {
        return $this->qualite;
    }

    /**
     * @param mixed $qualite
     * @return MembreData
     */
    public function setQualite($qualite)
    {
        $this->qualite = $qualite;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getEtablissement()
    {
        return $this->etablissement;
    }

    /**
     * @param mixed $etablissement
     * @return MembreData
     */
    public function setEtablissement($etablissement)
    {
        $this->etablissement = $etablissement;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getRole()
    {
        return $this->role;
    }

    /**
     * @param mixed $role
     * @return MembreData
     */
    public function setRole($role)
    {
        $this->role = $role;
        return $this;
    }
}

/** Les informations ici sont des chaines de caractères */
class PdcData {

    /** @var string */
    private $titre;
    /** @var string */
    private $specialite;
    /** @var string */
    private $etablissement;
    /** @var string */
    private $doctorant;
    /** @var string */
    private $date;

    /** @var bool */
    private $cotutuelle;
    /** @var string */
    private $cotutuelleLibelle;
    /** @var string */
    private $cotutuellePays;

    /** @var bool */
    private $associe;
    /** @var string */
    private $logoAssocie;


    /** @var MembreData[] */
    private $directeurs;
    /** @var MembreData[] */
    private $rapporteurs;
    /** @var MembreData[] */
    private $membres;

    /** @var string */
    private $logoCOMUE;
    /** @var string */
    private $logoEtablissement;
    /** @var string */
    private $logoEcoleDoctorale;
    /** @var string */
    private $logoUniteRecherche;

    /** @var string */
    private $listing;
    /** @var string */
    private $uniteRecherche;

    /**
     * @return string
     */
    public function getUniteRecherche()
    {
        return $this->uniteRecherche;
    }

    /**
     * @param string $uniteRecherche
     * @return PdcData
     */
    public function setUniteRecherche($uniteRecherche)
    {
        $this->uniteRecherche = $uniteRecherche;
        return $this;
    }

    /**
     * @return string
     */
    public function getTitre()
    {
        return $this->titre;
    }

    /**
     * @param string $titre
     * @return PdcData
     */
    public function setTitre($titre)
    {
        $this->titre = $titre;
        return $this;
    }

    /**
     * @return string
     */
    public function getSpecialite()
    {
        return $this->specialite;
    }

    /**
     * @param string $specialite
     * @return PdcData
     */
    public function setSpecialite($specialite)
    {
        $this->specialite = $specialite;
        return $this;
    }

    /**
     * @return string
     */
    public function getEtablissement()
    {
        return $this->etablissement;
    }

    /**
     * @param string $etablissement
     * @return PdcData
     */
    public function setEtablissement($etablissement)
    {
        $this->etablissement = $etablissement;
        return $this;
    }

    /**
     * @return string
     */
    public function getDoctorant()
    {
        return $this->doctorant;
    }

    /**
     * @param string $doctorant
     * @return PdcData
     */
    public function setDoctorant($doctorant)
    {
        $this->doctorant = $doctorant;
        return $this;
    }

    /**
     * @return string
     */
    public function getDate()
    {
        return $this->date;
    }

    /**
     * @param string $date
     * @return PdcData
     */
    public function setDate($date)
    {
        $this->date = $date;
        return $this;
    }

    /**
     * @return bool
     */
    public function isCotutuelle()
    {
        return $this->cotutuelle;
    }

    /**
     * @param bool $cotutuelle
     * @return PdcData
     */
    public function setCotutuelle($cotutuelle)
    {
        $this->cotutuelle = $cotutuelle;
        return $this;
    }

    /**
     * @return string
     */
    public function getCotutuelleLibelle()
    {
        return $this->cotutuelleLibelle;
    }

    /**
     * @param string $cotutuelleLibelle
     * @return PdcData
     */
    public function setCotutuelleLibelle($cotutuelleLibelle)
    {
        $this->cotutuelleLibelle = $cotutuelleLibelle;
        return $this;
    }

    /**
     * @return string
     */
    public function getCotutuellePays()
    {
        return $this->cotutuellePays;
    }

    /**
     * @param string $cotutuellePays
     * @return PdcData
     */
    public function setCotutuellePays($cotutuellePays)
    {
        $this->cotutuellePays = $cotutuellePays;
        return $this;
    }

    /**
     * @return bool
     */
    public function isAssocie()
    {
        return $this->associe;
    }

    /**
     * @param bool $associe
     * @return PdcData
     */
    public function setAssocie($associe)
    {
        $this->associe = $associe;
        return $this;
    }

    /**
     * @return string
     */
    public function getLogoAssocie()
    {
        return $this->logoAssocie;
    }

    /**
     * @param string $logoAssocie
     * @return PdcData
     */
    public function setLogoAssocie($logoAssocie)
    {
        $this->logoAssocie = $logoAssocie;
        return $this;
    }

    /**
     * @return MembreData[]
     */
    public function getDirecteurs()
    {
        return $this->directeurs;
    }

    /**
     * @param MembreData $directeur
     * @return PdcData
     */
    public function addDirecteur($directeur)
    {
        $this->directeurs[] = $directeur;
        return $this;
    }

    /**
     * @return MembreData[]
     */
    public function getRapporteurs()
    {
        return $this->rapporteurs;
    }

    /**
     * @param MembreData $rapporteur
     * @return PdcData
     */
    public function addRapporteur($rapporteur)
    {
        $this->rapporteurs[] = $rapporteur;
        return $this;
    }

    /**
     * @return MembreData[]
     */
    public function getMembres()
    {
        return $this->membres;
    }

    /**
     * @param MembreData $membre
     * @return PdcData
     */
    public function addMembre($membre)
    {
        $this->membres[] = $membre;
        return $this;
    }

    /**
     * @return string
     */
    public function getLogoCOMUE()
    {
        return $this->logoCOMUE;
    }

    /**
     * @param string $logoCOMUE
     * @return PdcData
     */
    public function setLogoCOMUE($logoCOMUE)
    {
        $this->logoCOMUE = $logoCOMUE;
        return $this;
    }

    /**
     * @return string
     */
    public function getLogoEtablissement()
    {
        return $this->logoEtablissement;
    }

    /**
     * @param string $logoEtablissement
     * @return PdcData
     */
    public function setLogoEtablissement($logoEtablissement)
    {
        $this->logoEtablissement = $logoEtablissement;
        return $this;
    }

    /**
     * @return string
     */
    public function getLogoEcoleDoctorale()
    {
        return $this->logoEcoleDoctorale;
    }

    /**
     * @param string $logoEcoleDoctorale
     * @return PdcData
     */
    public function setLogoEcoleDoctorale($logoEcoleDoctorale)
    {
        $this->logoEcoleDoctorale = $logoEcoleDoctorale;
        return $this;
    }

    /**
     * @return string
     */
    public function getLogoUniteRecherche()
    {
        return $this->logoUniteRecherche;
    }

    /**
     * @param string $logoUniteRecherche
     * @return PdcData
     */
    public function setLogoUniteRecherche($logoUniteRecherche)
    {
        $this->logoUniteRecherche = $logoUniteRecherche;
        return $this;
    }

    /**
     * @return string
     */
    public function getListing()
    {
        return $this->listing;
    }

    /**
     * @param string $listing
     */
    public function setListing($listing)
    {
        $this->listing = $listing;
    }

    public function getWarnings() {
        $warnings = [];

        //logos
        if (!$this->getLogoCOMUE())                 $warnings[] = "Logo de la COMUE absent";
        if (!$this->getLogoEcoleDoctorale())        $warnings[] = "Logo de l'école doctorale absent";
        if (!$this->getLogoEtablissement())         $warnings[] = "Logo de l'établissement absent";
        if (!$this->getLogoUniteRecherche())        $warnings[] = "Logo de l'unité de recherche absent";

        if ($this->isAssocie() && !$this->getLogoAssocie()) $warnings[] = "Logo de l'établissement associé absent";

        //infos generales
        if(!$this->getTitre())                      $warnings[] = "Titre de thèse manquant";
        if(!$this->getSpecialite())                 $warnings[] = "Spécialité manquante";
        if(!$this->getEtablissement())              $warnings[] = "Établissement d'encadrement manquant";
        if(!$this->getUniteRecherche())             $warnings[] = "Unité de recherche d'encadrement manquant";
        if(!$this->getDoctorant())                  $warnings[] = "Les informations sur le doctorant sont manquantes";

        //soutenance
        if(!$this->getDate())                       $warnings[] = "La date de soutenance est manquante";
        if(count($this->getRapporteurs())<2)        $warnings[] = "Nombre de rapporteurs trop faible (".count($this->getRapporteurs()).")";
        if(count($this->getDirecteurs())<1)         $warnings[] = "Nombre de directeurs trop faible (".count($this->getDirecteurs()).")";

        //membres du jury
        if ($this->getRapporteurs()) {
            /** @var MembreData $rapporteur */
            foreach($this->getRapporteurs() as $rapporteur) {
                if (!$rapporteur->getDenomination())    $warnings[] = "Un rapporteur ne possèdent pas de nom.";
                if (!$rapporteur->getEtablissement())   $warnings[] = "Établissement absent pour le rapporteur (".$rapporteur->getDenomination().").";
                if (!$rapporteur->getQualite())         $warnings[] = "Qualité absente pour le rapporteur (".$rapporteur->getDenomination().").";
            }
        }
        /** @var MembreData $membre */
        if ($this->getMembres()) {
            foreach ($this->getMembres() as $membre) {
                if (!$membre->getDenomination()) $warnings[] = "Un membre ne possèdent pas de nom.";
                if (!$membre->getEtablissement()) $warnings[] = "Établissement absent pour le membre (" . $membre->getDenomination() . ").";
                if (!$membre->getQualite()) $warnings[] = "Qualité absente pour le membre (" . $membre->getDenomination() . ").";
            }
        }
        /** @var MembreData $directeur */
        if ($this->getDirecteurs()) {
            foreach ($this->getDirecteurs() as $directeur) {
                if (!$directeur->getDenomination()) $warnings[] = "Un directeur ne possèdent pas de nom.";
                if (!$directeur->getEtablissement()) $warnings[] = "Établissement absent pour le directeur (" . $directeur->getDenomination() . ").";
                if (!$directeur->getQualite()) $warnings[] = "Qualité absente pour le directeur (" . $directeur->getDenomination() . ").";
            }
        }
        //cotutuelle :: aucun warning ca l'info sert à détecter la cotutelle


        return $warnings;
    }

}
 No newline at end of file
+52 −51

File changed.

Preview size limit exceeded, changes collapsed.

+4 −34
Changes for module/Application/view/application/these/validation-page-de-couverture.phtml: 4 added lines, 34 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ use Application\Constants;use Application\Controller\TheseController;
use Application\Entity\Db\These;
use Application\Entity\Db\Validation;
use Application\Provider\Privilege\ValidationPrivileges;
use Application\Service\Fichier\PdcData;
use Application\View\Renderer\PhpRenderer;
use UnicaenApp\Service\MessageCollector;

@@ -18,7 +19,7 @@ use UnicaenApp\Service\MessageCollector;
 * @var string      $devaliderUrl
 * @var string      $nextStepUrl
 * @var MessageCollector    $msgCollector
 * @var []          $informations
 * @var PdcData          $informations
 *
 * @see TheseController::validationPageDeCouvertureAction()
 */
@@ -57,12 +58,7 @@ $canUnvalidate = $this->isAllowed($these, ValidationPrivileges::VALIDATION_PAGE_
</div>

<?php
    $problemes = [];
    foreach ($informations as $clef => $information) {
        if ($information == "") {
            $problemes[] = $clef;
        }
    }
    $problemes = $informations->getWarnings()
?>

<?php if (!empty($problemes)): ?>
@@ -76,7 +72,7 @@ $canUnvalidate = $this->isAllowed($these, ValidationPrivileges::VALIDATION_PAGE_
            Liste des informations manquantes :
            <ul>
            <?php foreach ($problemes as $probleme): ?>
                <li> <?php echo informationManquante($probleme, $informations); ?> </li>
                <li> <?php echo $probleme; ?> </li>
            <?php endforeach; ?>
            </ul>
        </div>
@@ -190,29 +186,3 @@ $canUnvalidate = $this->isAllowed($these, ValidationPrivileges::VALIDATION_PAGE_
        });
    });
</script>
 No newline at end of file

<?php
function informationManquante($clef, $informations) {

    //justification des logos
    $splits = explode("-",$clef);
    if($splits[0] === "logo") {
        switch($splits[1]) {
            case "comue" : return "le logo de la structure de 'Normandie Université' est manquant";
            case "ecoleDoctorale" : return "le logo de l'école doctorale est manquant";
            case "uniteRecherche" : return "le logo de l'unité de recherche est manquant";
            case "etablissement" : return "le logo de l'établissement de rattachement est manquant";
        }

    }
    $splits = explode(" ",$clef);
    $acteur = "nom ". $splits[1];
    switch($splits[0]) {
        case "etablissement" : return "l'établissement du membre ".$splits[1]." (".$informations[$acteur].") n'est pas renseigné";
        case "qualite" : return "la qualité du membre ".$splits[1]." (".$informations[$acteur].") n'est pas renseignée";
        case "nom": return "le nom du membre ".$splits[1]." (".$informations[$acteur].") n'est pas renseigné";
        case "role": return "le rôle du membre ".$splits[1]." (".$informations[$acteur].") n'est pas renseigné";
    }
    return $clef;
}
?>
 No newline at end of file