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

[EMC2] Premier index de gestion des statuts de mobilité

parent 556fff40
Loading
Loading
Loading
Loading
+1 −0
Changes for documentation/release/4.2.0.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ Version 4.2.0 (XX/11/2023)
- [Mes Formations] Possibilité de vider un plan de formation
- [EMC2] Déclaration de type de mobilité
- [EMC2] Déclaration pour un agent de son statut de mobilité
- [EMC2] Premier index de gestion des statuts de mobilité
- 

Modification en BD
+31 −1
Changes for module/Application/config/merged/agent-mobilite.config.php: 31 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -19,6 +19,15 @@ return [
    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => AgentMobiliteController::class,
                    'action' => [
                        'index',
                    ],
                    'privileges' => [
                        AgentMobilitePrivileges::AGENTMOBILITE_INDEX
                    ],
                ],
                [
                    'controller' => AgentMobiliteController::class,
                    'action' => [
@@ -74,9 +83,10 @@ return [
                            'route' => '/mobilite',
                            'defaults' => [
                                'controller' => AgentMobiliteController::class,
                                'action' => 'index'
                            ],
                        ],
                        'may_terminate' => false,
                        'may_terminate' => true,
                        'child_routes' => [
                            'ajouter' => [
                                'type' => Segment::class,
@@ -135,6 +145,26 @@ return [
        ],
    ],

    'navigation'      => [
        'default' => [
            'home' => [
                'pages' => [
                    'gestion' => [
                        'pages' => [
                            'agent-mobilite' => [
                                'label'    => 'Gestion des statuts de mobilités des agents',
                                'route'    => 'agent/mobilite',
                                'resource' => PrivilegeController::getResourceId(AgentMobiliteController::class, 'index') ,
                                'order'    => 100000,
                                'icon' => 'fas fa-angle-right',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            AgentMobiliteService::class => AgentMobiliteServiceFactory::class
+10 −0
Changes for module/Application/src/Application/Controller/AgentMobiliteController.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,15 @@ class AgentMobiliteController extends AgentController {
    use AgentMobiliteServiceAwareTrait;
    use AgentMobiliteFormAwareTrait;

    public function indexAction(): ViewModel
    {
        $mobilites = $this->getAgentMobiliteService()->getAgentsMobilites();

        return new ViewModel([
            'mobilites' => $mobilites,
        ]);
    }

    public function ajouterAction() : ViewModel
    {
        $agent = $this->getAgentService()->getRequestedAgent($this);
@@ -29,6 +38,7 @@ class AgentMobiliteController extends AgentController {

            if ($form->isValid()) {
                //historiser les éventuelles ouvertes
                $agent = $agentMobilite->getAgent();
                $mobilites = $this->getAgentMobiliteService()->getAgentsMobilitesByAgent($agent);
                foreach ($mobilites as $mobilite) $this->getAgentMobiliteService()->historise($mobilite);
                // enregistrer la nouvelle
+143 −0
Changes for module/Application/view/application/agent-mobilite/index.phtml: 143 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @see \Application\Controller\AgentMobiliteController::indexAction()
 * @var \Application\Entity\Db\AgentMobilite[] $mobilites
 */

use Application\Provider\Privilege\AgentmobilitePrivileges;
use Application\Provider\Privilege\AgentPrivileges;

$this->headTitle("Gestion des statuts de mobilité des agent·es");

$canAjouter = $this->isAllowed(AgentmobilitePrivileges::getResourceId(AgentmobilitePrivileges::AGENTMOBILITE_AJOUTER));
?>

<h1 class="page-header">
    Gestion des statuts de mobilité des agent·es
</h1>

<?php if ($canAjouter): ?>
    <a href="<?php echo $this->url('agent/mobilite/ajouter', [], [], true); ?>"
       class="btn btn-primary ajax-modal" data-event="modification"
    >
        <span class="icon icon-ajouter"></span>
        Déclarer un statut de mobilité
    </a>
<?php endif; ?>

<table class="table table-condensed datatable">
    <thead>
    <tr>
        <th data-type="string">Agent</th>
        <th>Affectation</th>
        <th>Statut</th>
        <th data-type="num">Date</th>
        <th class="action">Action</th>
    </tr>
    </thead>
    <tbody>
        <?php foreach ($mobilites as $amobilite): ?>
            <?php
                $agent = $amobilite->getAgent();
                $mobilite = $amobilite->getMobilite();

                $canAfficher = $this->isAllowed($agent, AgentPrivileges::AGENT_AFFICHER);
                $canModifier = $this->isAllowed(AgentmobilitePrivileges::getResourceId(AgentmobilitePrivileges::AGENTMOBILITE_MODIFIER));
                $canHistoriser = $this->isAllowed(AgentmobilitePrivileges::getResourceId(AgentmobilitePrivileges::AGENTMOBILITE_HISTORISER));
                $canSupprimer = $this->isAllowed(AgentmobilitePrivileges::getResourceId(AgentmobilitePrivileges::AGENTMOBILITE_SUPPRIMER));

            ?>
            <tr>
                <td data-order="<?php echo $agent->getDenomination(); ?>"> <?php echo $agent->getDenomination(true); ?> </td>
                <td>
                    <?php $affectations = $agent->getAffectationsActifs(); ?>
                    <?php if (empty($affectations)) : ?>
                        <em> Aucune affectation </em>
                    <?php else : ?>
                        <?php foreach ($affectations as $affectation): ?>
                            <span class="<?php if ($affectation->isPrincipale()) echo " principale "; ?>">
                                <?php echo $affectation->getStructure()->getLibelleLong(); ?>
                            </span><br>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </td>
                <td>
                    <?php echo $mobilite->getLibelle(); ?>
                    <?php if ($amobilite->getCommentaire()): ?>
                        <span class="icon icon-information" data-bs-toggle="tooltip" data-bs-html="true"
                              title="<?php echo $amobilite->getCommentaire(); ?>"></span>
                    <?php endif; ?>
                </td>
                <td data-order="<?php echo $amobilite->getHistoCreation()->getTimestamp(); ?>">
                    <?php echo $amobilite->getHistoCreation()->format('d/m/Y à H:i'); ?>
                </td>
                <td class="action">
                    <?php if ($canAfficher) : ?>
                        <?php /** @see \Application\Controller\AgentController::afficherAction() */ ?>
                        <a href="<?php echo $this->url('agent/afficher', ['agent' => $agent->getId()], ['fragment' => 'mobilite'], true); ?>">
                            <span class="icon icon-user"></span> Afficher
                        </a>
                    <?php endif; ?>
                    <?php if ($canModifier) : ?>
                        <br>
                        <?php /** @see \Application\Controller\AgentMobiliteController::modifierAction() */ ?>
                        <a href="<?php echo $this->url('agent/mobilite/modifier', ['agent-mobilite' => $amobilite->getId()], [], true); ?>"
                           class="ajax-modal" data-event="modification"
                        >
                            <span class="icon icon-editer"></span> Modifier
                        </a>
                    <?php endif; ?>
                    <?php if ($canHistoriser) : ?>
                        <br>
                        <?php if ($amobilite->estNonHistorise()) : ?>
                            <?php /** @see \Application\Controller\AgentMobiliteController::historiserAction() */ ?>
                            <a href="<?php echo $this->url('agent/mobilite/historiser', ['agent-mobilite' => $amobilite->getId()], [], true); ?>"
                               class="ajax-modal" data-event="modification"
                            >
                                <span class="icon icon-historiser"></span> Historiser
                            </a>
                        <?php else : ?>
                            <?php /** @see \Application\Controller\AgentMobiliteController::restaurerAction() */ ?>
                            <a href="<?php echo $this->url('agent/mobilite/restaurer', ['agent-mobilite' => $amobilite->getId()], ['query' => ['retour' => $this->url('agent/mobilite', [], [], true)]], true); ?>"
                            >
                                <span class="icon icon-restaurer"></span> Restaurer
                            </a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php if ($canSupprimer) : ?>
                        <br>
                        <?php /** @see \Application\Controller\AgentMobiliteController::supprimerAction() */ ?>
                        <a href="<?php echo $this->url('agent/mobilite/supprimer', ['agent-mobilite' => $amobilite->getId()], [], true); ?>"
                           class="ajax-modal" data-event="modification"
                        >
                            <span class="text-danger">
                                <span class="icon icon-unchecked"></span> Supprimer
                            </span>
                        </a>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<style>
    span.principale {
        font-weight: bold;
    }
</style>


<script>
    $(function () {
        $("body").on("modification", function (event) {
            event.div.modal('hide');
            window.location.reload();
        });
        $('.datatable').DataTable({
            paging: false,
        });
    });

</script>
 No newline at end of file