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

Interface autorité

parent 78ea01ce
Loading
Loading
Loading
Loading
+20 −20
Changes for module/Application/src/Application/Controller/IndexController.php: 20 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Application\Controller;

use Application\Entity\Db\AgentAutorite;
use Application\Entity\Db\AgentSuperieur;
use Application\Provider\Role\RoleProvider as AppRoleProvider;
use Application\Entity\Db\Agent;
@@ -130,7 +131,7 @@ class IndexController extends AbstractActionController

        return new ViewModel([
            'agents' => $agents,
            'connectedAgent' => $this->getAgentService()->getAgentByUser($user),
            'connectedAgent' => $agent,
            'campagnes' => $campagnes,
            'entretiens' => $entretiens,
        ]);
@@ -139,29 +140,28 @@ class IndexController extends AbstractActionController
    public function indexAutoriteAction() : ViewModel
    {
        $user = $this->getUserService()->getConnectedUser();
        $complements = $this->getAgentService()->getAutoriteByUser($user);
        $agent = $this->getAgentService()->getAgentByUser($user);
        $agents = array_map(function (AgentAutorite $a) { return $a->getAgent(); },$this->getAgentAutoriteService()->getAgentsAutoritesByAutorite($agent));
        usort($agents, function (Agent $a, Agent $b) { return $a->getNomUsuel()." ".$a->getPrenom() > $b->getNomUsuel()." ".$b->getPrenom();});

        $agents = [];
        if ($complements) {
            foreach ($complements as $complement) {
                $agent = $this->getAgentService()->getAgent($complement->getAttachmentId());
                if ($agent !== null) $agents[$agent->getId()] = $agent;
            }
        /** Campagne d'entretien professionnel ************************************************************************/
        $last =  $this->getCampagneService()->getLastCampagne();
        $campagnes =  $this->getCampagneService()->getCampagnesActives();
        $campagnes[] = $last;
        usort($campagnes, function (Campagne $a, Campagne $b) { return $a->getDateDebut() > $b->getDateDebut();});

        /** récuperation des eps **************************************************************************************/
        $entretiens = [];
        foreach ($campagnes as $campagne) {
            $entretiens[$campagne->getId()] = $this->getEntretienProfessionnelService()->getEntretienProfessionnelByCampagneAndAgents($campagne, $agents);
        }
        usort($agents, function (Agent $a, Agent $b) {
            $aaa = $a->getNomUsuel() . " "  . $a->getPrenom();
            $bbb = $b->getNomUsuel() . " "  . $b->getPrenom();
            return $aaa > $bbb;
        });

        $vm =  new ViewModel();
        $vm->setVariables([

        return new ViewModel([
            'agents' => $agents,
            'connectedAgent' => $this->getAgentService()->getAgentByUser($user),
            'campagnePrevious' => $this->getCampagneService()->getLastCampagne(),
            'campagnesCurrents' => $this->getCampagneService()->getCampagnesActives(),
            'connectedAgent' => $agent,
            'campagnes' => $campagnes,
            'entretiens' => $entretiens,
        ]);
        return $vm;
    }

    public function infosAction() : ViewModel
+45 −125
Changes for module/Application/view/application/index/index-autorite.phtml: 45 added lines, 125 removed lines.
Original line number Diff line number Diff line
@@ -4,146 +4,66 @@
 * @see \Application\Controller\IndexController::indexAutoriteAction()
 * @var Agent $connectedAgent
 * @var Agent[] $agents
 * @var Campagne $campagnePrevious
 * @var Campagne $campagnesCurrents
 * @var Campagne[] $campagnes
 * @var EntretienProfessionnel[] $entretiens
 *
 */

use Application\Entity\Db\Agent;
use Application\Provider\Privilege\AgentPrivileges;
use Application\Provider\Privilege\FichePostePrivileges;
use EntretienProfessionnel\Entity\Db\Campagne;
use EntretienProfessionnel\Entity\Db\EntretienProfessionnel;

$canVoirAgent = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::AGENT_AFFICHER));
?>

<h1 class="card-header">
    Liste des agents dont vous êtes l'autorite hiérarchique
<h1 class="page-header">
    Liste des agents dont vous êtes l'autorité hiérarchique direct·e
</h1>

<div class="alert alert-info">
    <span class="icon icon-attention"></span>
    Ici ne figurent que les agents pour lesquels vous avez été désigné manuellement en tant qu'autorité hiérarchique
</div>

<?php echo $this->messenger()->addMessagesFromFlashMessenger(); ?>

<table class="table table-condensed table-hover">
    <thead>
        <tr>
            <th> Agent & Affectation </th>
            <th> Fiche de poste </th>
            <th> Entretien professionnel </th>
        </tr>
    </thead>
    <tbody>
    <?php foreach ($agents as $agent) : ?>
        <tr>
            <td>
                <?php echo $agent->getDenomination(); ?>
                <?php if ($canVoirAgent) : ?>
                    <a href="<?php echo $this->url('agent/afficher', ['agent' => $agent->getId()], [], true); ?>">
                        <span class="icon icon-voir" title="Afficher les informations de l'agent"></span>
                    </a>
                <?php endif; ?>
                <br/>
                <?php $affectation = $agent->getAffectationPrincipale(); ?>
                <?php if ($affectation) : ?>
                    <?php $niveau2 = $affectation->getStructure()->getNiv2(); ?>
                    <?php if ($niveau2 !== null) : ?>
                        [<?php echo $niveau2->getLibelleCourt(); ?>]
                    <?php endif; ?>
                    <?php echo $affectation->getStructure()->getLibelleLong(); ?>
                <?php else : ?>
                    Aucune affectation principale
                <?php endif; ?>
            </td>
            <td>
                <?php $fichePoste = $agent->getFichePosteBest(); ?>
                <?php $canVoirFichePoste = $this->isAllowed($fichePoste, FichePostePrivileges::FICHEPOSTE_AFFICHER); ?>
                <?php if ($fichePoste) : ?>
                    <?php echo $this->etatbadge($fichePoste->getEtat()); ?>
                    <?php echo $fichePoste->getLibelleMetierPrincipal(); ?>
                    <?php if ($fichePoste->getLibelle()) : ?>
                        <br/>
                        <?php echo $fichePoste->getLibelle; ?>
                    <?php endif; ?>
                <?php else : ?>
                    Aucune fiche de poste
                <?php endif; ?>
                <br/>
                <?php if ($canVoirAgent) : ?>
                    <a href="<?php echo $this->url('agent/afficher', ['agent' => $agent->getId()], ['fragment' => 'fiches'], true); ?>">
                        <span class="icon gerer" title="Accéder à la gestion des fiches postes"></span>
                        <span class="small-lettrine">FP</span></a>
                <?php endif; ?>
                <?php if ($fichePoste AND $canVoirFichePoste) : ?>
                    <a href="<?php echo $this->url('fiche-poste/afficher', ['fiche-poste' => $fichePoste->getId()],[], true); ?>">
                        <span class="icon icon-voir" title="Afficher la fiche de poste"></span>
                        <span class="small-lettrine">FP</span></a>
                    <a href="<?php echo $this->url('fiche-poste/exporter', ['fiche-poste' => $fichePoste->getId()],[], true); ?>">
                        <span class="icon icon-pdf" title="Exporter la fiche de poste"></span>
                        <span class="small-lettrine">FP</span></a>
                <?php endif; ?>
            </td>
            <td>
                <?php if ($campagnePrevious === null) : ?>
                    Aucune campagne précédente
                <?php else : ?>
                    Précédent (<?php echo $campagnePrevious->getAnnee(); ?>):
                    <?php $entretien = $agent->getEntretienProfessionnelByCampagne($campagnePrevious); ?>
                    <?php if ($entretien !== null) : ?>
                        Entretien du <?php echo $entretien->getDateEntretien()->format('d/m/Y'); ?>
                        <a href="<?php echo $this->url('entretien-professionnel/acceder', ['entretien' => $entretien->getId()], [], true); ?>"
                           target="_blank">
                            <span class="icon icon-voir"></span></a>
                        <a href="<?php echo $this->url('entretien-professionnel/exporter-crep', ['entretien' => $entretien->getId()], [], true); ?>"
                           target="_blank">
                            <span class="icon icon-pdf"></span><span class="small-lettrine">CREP</span></a>
                        <a href="<?php echo $this->url('entretien-professionnel/exporter-cref', ['entretien' => $entretien->getId()], [], true); ?>"
                           target="_blank">
                            <span class="icon icon-pdf"></span><span class="small-lettrine">CREF</span></a>
                    <?php else : ?>
                        Aucun entretien
                    <?php endif; ?>
                <?php endif; ?>
                <br/>

                <?php if ($campagnesCurrents !== null or $campagnesCurrents !== []) : ?>
                    <?php /** @var Campagne $campagneCurrent */ ?>
                    <?php foreach ($campagnesCurrents as $campagneCurrent) : ?>
                        Courant (<?php echo $campagneCurrent->getAnnee(); ?>):
                        <?php $entretien = $agent->getEntretienProfessionnelByCampagne($campagneCurrent); ?>
                        <?php if ($entretien !== null) : ?>
                            Entretien du <?php echo $entretien->getDateEntretien()->format('d/m/Y'); ?>
                            <a href="<?php echo $this->url('entretien-professionnel/modifier', ['entretien' => $entretien->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon gerer"></span></a>
                            <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::accederAction() */ ?>
                            <a href="<?php echo $this->url('entretien-professionnel/acceder', ['entretien-professionnel' => $entretien->getId()], [], true); ?>"
                               target="_blank">
                                <span class="icon icon-editer"></span></a>
                            <a href="<?php echo $this->url('entretien-professionnel/exporter-crep', ['entretien' => $entretien->getId()], [], true); ?>"
                               target="_blank">
                                <span class="icon icon-pdf"></span><span class="small-lettrine">CREP</span></a>
                            <a href="<?php echo $this->url('entretien-professionnel/exporter-cref', ['entretien' => $entretien->getId()], [], true); ?>"
                               target="_blank">
                                <span class="icon icon-pdf"></span><span class="small-lettrine">CREF</span></a>
                        <?php else : ?>
                            Aucun entretien
                            <?php /** @see \EntretienProfessionnel\Controller\EntretienProfessionnelController::creerAction() */?>
                            <a href="<?php echo $this->url('entretien-professionnel/creer', ["campagne" => $campagneCurrent->getId()], ["query" => ["agent" => $agent->getId(), 'structure' => ($affectation AND $affectation->getStructure())?$affectation->getStructure()->getId():null]], true); ?>"
                               class="ajax-modal" data-event="modification">
                                <span class="icon icon-ajouter"></span></a>
                        <?php endif; ?>
<ul class="nav">
    <li class="nav-item">
        <a class="nav-link" href="#agent" aria-controls="agent" role="tab"   data-toggle="tabz">
            Liste des <br/> Agent·es
        </a>
    </li>
    <?php foreach ($campagnes as $campagne) : ?>
        <li class="nav-item" >
            <a class="nav-link" href="#entretien_<?php echo $campagne->getId(); ?>" aria-controls="entretien_<?php echo $campagne->getId(); ?>" role="tab"   data-toggle="tabz">
                Entretiens professionnels <br/> <?php echo $campagne->getAnnee(); ?>
            </a>
        </li>
    <?php endforeach; ?>
                <?php endif; ?>
                <br/>
            </td>
        </tr>
</ul>


<div class="tab-content">
    <div id="agent" class="tab-pane " role="tabpanel">
        <?php echo $this->partial('partial/agents', ['agents' => $agents], [], true); ?>
    </div>
    <?php foreach ($campagnes as $campagne) : ?>
        <div id="entretien_<?php echo $campagne->getId(); ?>" class="tab-pane " role="tabpanel">
            <?php echo $this->partial('partial/entretien', ['campagne' => $campagne, 'agents' => $agents, 'entretiens' => $entretiens[$campagne->getId()]], [], true); ?>
        </div>
    <?php endforeach; ?>
    </tbody>
</table>
</div>


<script>
    $(function() {
        let hash = $(location).attr('hash');
        let name = hash.substr(1);
        if (name === undefined || name === "") name = "agent";

        $('a[aria-controls=' + name + ']').tab('show');

        $('.nav-item a').click(function (e) {
            // No e.preventDefault() here
            $(this).tab('show');
        });
    });

    $(function() {
        $("body").on("modification", function (event) {
            event.div.modal('hide');
+1 −2
Changes for module/Application/view/application/index/index-superieur.phtml: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -8,12 +8,11 @@
 * @var EntretienProfessionnel[] $entretiens
 *
 */

use Application\Entity\Db\Agent;
use Application\Provider\Privilege\AgentPrivileges;
use EntretienProfessionnel\Entity\Db\Campagne;
use EntretienProfessionnel\Entity\Db\EntretienProfessionnel;

$canVoirAgent = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::AGENT_AFFICHER));
?>

<h1 class="page-header">