Commit a6e9b25c authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Affichage du nom complet d'un individu : choc de simplification en supprimant...

Affichage du nom complet d'un individu : choc de simplification en supprimant 2 options d'affichage dans le formatteur.
parent 56bd91ad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Journal des modifications
- [FIX] Signature de méthode setObject() modifiée en PHP8 dans Doctrine\Laminas\Hydrator\Strategy\AbstractCollectionStrategy.
- Mise en place d'une zone de dépot du pv de soutrenance sur la page de présoutenance
- Rapport d'activité : implémentation pour les rapports de fin de contrat du même circuit de validation/avis que les annuels.
- Affichage du nom complet d'un individu : choc de simplification en supprimant 2 options d'affichage dans le formatteur.

6.0.2
-----
+19 −36
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@

namespace Application\Filter;

use Application\Entity\Db\Utilisateur;
use Doctorant\Entity\Db\Doctorant;
use Individu\Entity\Db\Individu;
use Laminas\Filter\AbstractFilter;
use UnicaenApp\Entity\Ldap\People;
use Application\Entity\Db\Utilisateur;

/**
 * Formatte le nom complet d'un individu (nom usuel, patronymique, etc.)
@@ -15,13 +15,11 @@ use Application\Entity\Db\Utilisateur;
 */
class NomCompletFormatter extends AbstractFilter
{
    protected $nomEnMajuscule = true;
    protected $avecCivilite   = false;
    protected $avecNomPatro   = false;
    protected $prenomDabord   = false;
    protected $tousLesPrenoms = false;
    protected $court = false;
    protected $patroPlutotQueUsuel = false;
    protected bool $nomEnMajuscule = true;
    protected bool $avecCivilite   = false;
    protected bool $avecNomPatro   = false;
    protected bool $prenomDabord   = false;
    protected bool $tousLesPrenoms = false;

    /**
     * Constructeur.
@@ -32,15 +30,18 @@ class NomCompletFormatter extends AbstractFilter
     * @param bool $prenomDabord
     * @param bool $tousLesPrenoms
     */
    public function __construct($nomEnMajuscule = true, $avecCivilite = false, $avecNomPatro = false, $prenomDabord = false, $tousLesPrenoms = false, $court = false, $patroPlutotQueUsuel=false)
    public function __construct(
        bool $nomEnMajuscule = true,
        bool $avecCivilite = false,
        bool $avecNomPatro = false,
        bool $prenomDabord = false,
        bool $tousLesPrenoms = false)
    {
        $this->nomEnMajuscule       = $nomEnMajuscule;
        $this->avecCivilite         = $avecCivilite;
        $this->avecNomPatro         = $avecNomPatro;
        $this->prenomDabord         = $prenomDabord;
        $this->tousLesPrenoms       = $tousLesPrenoms;
        $this->court                = $court;
        $this->patroPlutotQueUsuel  = $patroPlutotQueUsuel;
    }

    /**
@@ -48,9 +49,8 @@ class NomCompletFormatter extends AbstractFilter
     *
     * @param  mixed $value
     * @throws \RuntimeException If filtering $value is impossible
     * @return mixed
     */
    public function filter($value)
    public function filter($value): string
    {
        // normalisation
        if ($value instanceof Individu) {
@@ -113,32 +113,15 @@ class NomCompletFormatter extends AbstractFilter
        $nomPatro = ucfirst($this->nomEnMajuscule ? mb_strtoupper($nomPatro) : $nomPatro);
        $civilite = $this->avecCivilite ? $civilite : null;

        if ($this->patroPlutotQueUsuel && $nomPatro != '') {
            $parts = [
                $civilite,
                $this->prenomDabord ? "$prenom $nomPatro" : "$nomPatro $prenom",
            ];
        } else {
        $parts = [
            $civilite,
            $this->prenomDabord ? "$prenom $nomUsuel" : "$nomUsuel $prenom",
        ];
        }

        $result = implode(' ', array_filter($parts));

        if (! $this->patroPlutotQueUsuel) {
        if ($this->avecNomPatro && $nomPatro !== $nomUsuel) {
                if ($this->court) {
                    $result = "";
                    if ($this->avecCivilite) $result .= "$civilite";
                    if ($this->prenomDabord) $result .= " $prenom";
                    $result .= " $nomPatro-$nomUsuel";
                    if (!$this->prenomDabord) $result .= " $prenom";
                } else {
                    $result .= ", née $nomPatro";
                }
            }
            $result .= ", né·e $nomPatro";
        }

	    return $result;
+6 −10
Original line number Diff line number Diff line
@@ -542,19 +542,15 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface, Resour
     * @param bool $avecNomPatro
     * @param bool $prenoms
     * @param bool $prenomfirst
     * @param bool $court
     * @param bool $patroPlutotQueUsuel
     * @return string
     */
    public function getNomComplet(
        $avecCivilite = false,
        $avecNomPatro = false,
        $prenoms = false,
        $prenomfirst = false,
        $court = false,
        $patroPlutotQueUsuel=false)
    {
        $f = new NomCompletFormatter(true, $avecCivilite, $avecNomPatro, $prenomfirst, $prenoms, $court, $patroPlutotQueUsuel);
        bool $avecCivilite = false,
        bool $avecNomPatro = false,
        bool $prenoms = false,
        bool $prenomfirst = false): string
    {
        $f = new NomCompletFormatter(true, $avecCivilite, $avecNomPatro, $prenomfirst, $prenoms);

        return $f->filter($this);
    }
+1 −1
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ class RapportActiviteService extends BaseService

        // doctorant
        if ($these->getDoctorant()) {
            $exportData->doctorant = strtoupper($these->getDoctorant()->getIndividu()->getNomComplet(true, true, false, true, true, false));
            $exportData->doctorant = strtoupper($these->getDoctorant()->getIndividu()->getNomComplet(true, true, false, true));
        }

        // structures
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ use Application\View\Renderer\PhpRenderer;use Soutenance\Entity\Proposition;
 * @var string $url
 */

$doctorant = $these->getDoctorant()->getIndividu()->getNomComplet(false, false, false, true, false, true);
$doctorant = $these->getDoctorant()->getIndividu()->getNomComplet(false, false, false, true);
$titre = $these->getTitre();

$justification = true;
Loading