Skip to content
Snippets Groups Projects
Select Git revision
  • 2fa8aa33a9fc8aaa6525e7fd041c3d852e2cc31f
  • master default protected
  • b24
  • ll-workflow
  • alc-scindage-donnees-pj
  • FJ_LL_Tbl_Contrat
  • alc-docker-node
  • ll-apiplatform
  • php84
  • ll-rgpd
  • b23
  • alc-filtre-type-intervenant
  • ll-sans-mdb5
  • formules-ancienne-infra
  • ll-formules
  • alc-intervenant-dmep
  • ll-suppr-v_vol-s
  • b20
  • ll-postgresql
  • b23.0.1
  • b22
  • 24.7
  • 24.6
  • 24.5
  • 24.4
  • 24.3
  • 24.2
  • 24.1
  • 24.0
  • 23.15
  • 24.0-beta19
  • 24.0-beta18
  • 24.0-beta17
  • 24.0-beta16
  • 24.0-beta15
  • 24.0-beta14
  • 24.0-beta13
  • 23.14
  • 24.0-beta12
  • 24.0-beta11
  • 24.0-beta10
41 results

IntervenantViewHelper.php

Blame
  • user avatar
    lecluse authored
    #3226
    #7335
    2fa8aa33
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    IntervenantViewHelper.php 4.07 KiB
    <?php
    
    namespace Application\View\Helper\Intervenant;
    
    use Application\Util;
    use Zend\View\Helper\AbstractHtmlElement;
    use Application\Entity\Db\Intervenant;
    use Application\Entity\Db\Traits\IntervenantAwareTrait;
    
    /**
     * Description of Intervenant
     *
     * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr>
     */
    class IntervenantViewHelper extends AbstractHtmlElement
    {
        use IntervenantAwareTrait;
    
    
    
        /**
         *
         * @param Intervenant $intervenant
         *
         * @return self
         */
        public function __invoke(Intervenant $intervenant = null)
        {
            if ($intervenant) $this->setIntervenant($intervenant);
    
            return $this;
        }
    
    
    
        public function __toString()
        {
            return $this->render();
        }
    
    
    
        /**
         *
         *
         * @return string Code HTML
         */
        public function render()
        {
            $entity = $this->getIntervenant();
    
            if (!$entity) {
                return '';
            }
    
            $adresse = $entity->getAdressePrincipale();
    
            $vars = [
                'identite'    => [
                    "NOM prénom"         => $entity,
                    "Civilité"           => $entity->getCiviliteToString(),
                    "Date de naissance"  => $entity->getDateNaissanceToString(),
                    "Ville de naissance" => $entity->getVilleNaissanceLibelle() ?: '<span class="inconnu">(Inconnue)</span>',
                    "Pays de naissance"  => $entity->getPaysNaissance(),
                    "N° INSEE"           => $entity->getNumeroInsee(),
                ],
                'coordonnees' => [
                    "Email"            => $entity->getEmail() ?: '<span class="inconnu">(Inconnu)</span>',
                    "Téléphone mobile" => $entity->getTelMobile() ?: '<span class="inconnu">(Inconnu)</span>',
                    "Téléphone pro"    => $entity->getTelPro() ?: '<span class="inconnu">(Inconnu)</span>',
                    "Adresse"          => nl2br($entity->getAdressePrincipale()),
                ],
                'metier'      => [
                    "Type d'intervenant"        => $entity->getStatut()->getTypeIntervenant(),
                    "Statut de l'intervenant"   => $entity->getStatut(),
                    "N° {$entity->getSource()}" => $entity->getSourceCode(),
                    "Affectation principale"    => $entity->getStructure() ?: '<span class="inconnu">(Inconnue)</span>',
                    "Affectation recherche"     => count($aff = $entity->getAffectation()) ? implode(" ; ", $aff->toArray()) : '<span class="inconnu">(Inconnue)</span>',
                    "Discipline"                => $entity->getDiscipline() ?: '<span class="inconnu">(Inconnue)</span>',
                    "Grade"                     => $entity->getGrade() ?: '<span class="inconnu">(Aucun ou inconnu)</span>',
                    "Montant de l'indemnité FC" => $entity->getMontantIndemniteFc() !== null ? \UnicaenApp\Util::formattedEuros($entity->getMontantIndemniteFc()) : '<span class="inconnu">(Inconnue)</span>',
                ],
                'divers'      => [
                    "Id" => $entity->getId(),
                    //"Id de connexion" => ($u = $entity->getUtilisateur()) ? $u->getUsername() : "(Aucun)",
                ],
            ];
    
            $html = '';
            foreach ($vars as $bloc => $vvs) {
                $html .= "<dl class=\"intervenant intervenant-$bloc dl-horizontal\">\n";
                foreach ($vvs as $key => $value) {
                    $html .= "\t<dt>$key :</dt><dd>$value</dd>\n";
                }
                $html .= "</dl>";
            }
    
            //$html .= $this->getView()->historique($entity); => pas de sens ici
    
            return $html;
        }
    
    
    
        public function renderLink()
        {
            $intervenant = $this->getIntervenant();
            if (!$intervenant) return '';
    
            if ($intervenant->getHistoDestruction()) {
                return '<span class="bg-danger"><abbr title="Cet intervenant a été supprimé de OSE">' . $intervenant . '</abbr></span>';
            }
    
            $pourl = $this->getView()->url('intervenant/voir', ['intervenant' => $intervenant->getRouteParam()]);
            $out   = '<a href="' . $pourl . '" data-po-href="' . $pourl . '" class="ajax-modal">' . $intervenant . '</a>';
    
            return $out;
        }
    }