Commit fb6c5315 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Détails affichés pour la synchro, possibilité de restaurer/historiser un intervenant

parent 8ea77cc4
Loading
Loading
Loading
Loading
+29 −2
Changes for module/Application/config/intervenant.config.php: 29 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -87,6 +87,15 @@ return [
                            ],
                        ],
                    ],
                    'synchronisation'         => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/:intervenant/synchronisation',
                            'defaults' => [
                                'action' => 'synchronisation',
                            ],
                        ],
                    ],
                    'synchroniser'            => [
                        'type'    => 'Segment',
                        'options' => [
@@ -105,6 +114,24 @@ return [
                            ],
                        ],
                    ],
                    'historiser'              => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/:intervenant/historiser',
                            'defaults' => [
                                'action' => 'historiser',
                            ],
                        ],
                    ],
                    'restaurer'               => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/:intervenant/restaurer',
                            'defaults' => [
                                'action' => 'restaurer',
                            ],
                        ],
                    ],
                    'definir-par-defaut'      => [
                        'type'    => 'Segment',
                        'options' => [
@@ -459,14 +486,14 @@ return [
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['saisir', 'definir-par-defaut', 'synchroniser'],
                    'action'     => ['saisir', 'definir-par-defaut', 'synchronisation', 'synchroniser', 'restaurer'],
                    'privileges' => [
                        Privileges::INTERVENANT_EDITION,
                    ],
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['supprimer'],
                    'action'     => ['supprimer', 'historiser'],
                    'privileges' => [
                        Privileges::INTERVENANT_SUPPRESSION,
                    ],
+92 −4
Changes for module/Application/src/Application/Controller/IntervenantController.php: 92 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -359,23 +359,80 @@ class IntervenantController extends AbstractController
            }
        }

        $isImportable = $this->getServiceIntervenant()->isImportable($intervenant);

        $vm = new ViewModel();
        $vm->setTemplate('application/intervenant/saisir');
        $vm->setVariables(compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail', 'isImportable'));
        $vm->setVariables(compact('intervenant', 'form', 'errors', 'title', 'definiParDefaut', 'actionDetail'));

        return $vm;
    }



    public function synchronisationAction()
    {
        $intervenant = $this->getEvent()->getParam('intervenant');

        $isImportable = $this->getServiceIntervenant()->isImportable($intervenant);
        $data         = [];

        if ($isImportable) {
            $sql = "
            SELECT 
              i.id,
              si.libelle statut
             FROM 
              src_intervenant i 
              JOIN statut_intervenant si ON si.id = i.statut_id
            WHERE 
              i.annee_id = :annee AND i.code = :code";
            $d   = $this->em()->getConnection()->fetchAll($sql, ['annee' => $intervenant->getAnnee()->getID(), 'code' => $intervenant->getCode()]);
            foreach ($d as $da) {
                $id        = $da['ID'] ? (int)$da['ID'] : $da['STATUT'];
                $data[$id] = [
                    'source-statut'      => $da['STATUT'],
                    'id'                 => $da['ID'] ? (int)$da['ID'] : null,
                    'intervenant-statut' => null,
                    'histo-destruction'  => null,
                    'histo-destructeur'  => null,
                ];
            }

            $sql = "
            SELECT 
              i.id,
              si.libelle statut,
              to_char(i.histo_destruction, 'dd/mm/YYYY') histo_destruction, 
              u.display_name destructeur
             FROM 
              intervenant i 
              JOIN statut_intervenant si ON si.id = i.statut_id
              LEFT JOIN utilisateur u ON u.id = i.histo_destructeur_id
            WHERE 
              i.annee_id = :annee AND i.code = :code";
            $d   = $this->em()->getConnection()->fetchAll($sql, ['annee' => $intervenant->getAnnee()->getID(), 'code' => $intervenant->getCode()]);
            foreach ($d as $da) {
                $id = (int)$da['ID'];
                if (!isset($data[$id])) {
                    $data[$id] = ['source-statut' => null];
                }
                $data[$id]['id']                 = $id;
                $data[$id]['intervenant-statut'] = $da['STATUT'];
                $data[$id]['histo-destruction']  = $da['HISTO_DESTRUCTION'];
                $data[$id]['histo-destructeur']  = $da['DESTRUCTEUR'];
            }
        }

        return compact('intervenant', 'isImportable', 'data');
    }



    public function synchroniserAction()
    {
        $intervenant = $this->getEvent()->getParam('intervenant');
        $this->getProcessusImport()->execMaj('INTERVENANT', 'CODE', $intervenant->getCode());

        return $this->saisirAction();
        return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getId()], ['query' => ['tab' => 'synchronisation']]);
    }


@@ -469,6 +526,37 @@ class IntervenantController extends AbstractController



    public function historiserAction()
    {
        /* @var $intervenant \Application\Entity\Db\Intervenant */
        $intervenant = $this->getEvent()->getParam('intervenant');

        if (!$intervenant) {
            throw new \Exception('Intervenant introuvable');
        }
        $this->getServiceIntervenant()->delete($intervenant);

        return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => 'code:' . $intervenant->getCode()]);
    }



    public function restaurerAction()
    {
        /* @var $intervenant \Application\Entity\Db\Intervenant */
        $intervenant = $this->getEvent()->getParam('intervenant');

        if (!$intervenant) {
            throw new \Exception('Intervenant introuvable');
        }
        $intervenant->dehistoriser();
        $this->getServiceIntervenant()->save($intervenant);

        return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getId()]);
    }



    public function validationVolumeHoraireTypeIntervenantAction()
    {
        $serviceRVS = $this->getServiceRegleStructureValidation();
−8
Changes for module/Application/view/application/intervenant/saisir.phtml: 0 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
 * @var $errors          array
 * @var $definiParDefaut bool
 * @var $actionDetail    string
 * @var $isImportable    bool
 */

if ($intervenant && 'dupliquer' == $actionDetail) {
@@ -200,10 +199,3 @@ if ($intervenant->getId()) {
            'class' => 'btn btn-info pop-ajax' . ($definiParDefaut ? ' active' : ''),
        ])->html($definiParDefaut ? 'Ne plus définir par défaut' : 'Définir par défaut');
}
 No newline at end of file
if ($isImportable) {
    echo ' ' . $this->tag('a', [
            'href'  => $this->url('intervenant/synchroniser', ['intervenant' => $intervenant->getId()]),
            'title' => 'Synchroniser (import vers OSE)',
            'class' => 'btn btn-default',
        ])->html('Synchroniser (import vers OSE)');
}
 No newline at end of file
+23 −4
Changes for module/Application/view/application/intervenant/supprimer.phtml: 23 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ if (!$tree) {

echo $this->tag('div', [
    'id'                  => 'int-suppr-div',
    'data-url' => $this->url('intervenant/supprimer', ['intervenant' => $intervenant->getId()]),
    'data-supprimer-url'  => $this->url('intervenant/supprimer', ['intervenant' => $intervenant->getId()]),
    'data-historiser-url' => $this->url('intervenant/historiser', ['intervenant' => $intervenant->getId()]),
])->open();

echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
@@ -44,6 +45,10 @@ echo $this->tree($tree, ['id' => 'intervenant-suppr']);
    <div id="supprEnCours" style="display:none" class="loading">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Suppression en cours
        ...
    </div>
    <button id="historisationIntervenantData" type="button" class="btn btn-default" data-toggle="popover" data-trigger="focus"
            title="Historisation de la fiche de l'intervenant">
        Historiser la fiche de l'intervenant
    </button>
    <script>
        $(function () {
            $('#suppressionIntervenantData').popover({
@@ -53,8 +58,16 @@ echo $this->tree($tree, ['id' => 'intervenant-suppr']);
                    'Souhaitez-vous vraiment supprimer les données sélectionnées ?<br /><br />' +
                    '<button onclick="supprimer()" class="btn btn-danger">Oui, supprimer</button>' +
                    '&nbsp;<button onclick="$(\'#suppressionIntervenantData\').popover(\'hide\')" class="btn btn-default">Non, laisser telle qu\'elle la fiche</button>'
            })
            ;
            });

            $('#historisationIntervenantData').popover({
                html: true,
                content:
                    '<div class="alert alert-warning">Attention : Aucune donnée ne sera véritablement supprimée. La fiche de l\'intervenant ne sera simplement plus visible dans OSE ni dans les extractions (CSV, PDF, ...)</div>' +
                    'Souhaitez-vous vraiment historiser la fiche de l\'intervenant ?<br /><br />' +
                    '<button onclick="historiser()" class="btn btn-warning">Oui, historiser</button>' +
                    '&nbsp;<button onclick="$(\'#historisationIntervenantData\').popover(\'hide\')" class="btn btn-default">Non, laisser telle qu\'elle la fiche</button>'
            });
        });


@@ -71,11 +84,17 @@ echo $this->tree($tree, ['id' => 'intervenant-suppr']);
                ids.push(this.id);
            });

            div.load(div.data('url'), {
            div.load(div.data('supprimer-url'), {
                ids: ids
            });
        }

        function historiser()
        {
            var div = $('#int-suppr-div');
            window.location.href = div.data('historiser-url');
        }

    </script>

<?php
 No newline at end of file
+48
Changes for module/Application/view/application/intervenant/synchronisation.phtml: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

/**
 * @var $this            \Application\View\Renderer\PhpRenderer
 * @var $intervenant     \Application\Entity\Db\Intervenant
 * @var $isImportable    bool
 * @var $data            array
 */

if (!$isImportable) {
    echo $this->tag('div', ['class' => 'alert alert-warning'])->html('Cet intervenant n\'est pas synchronisable');

    return;
}


?>
    <table class="table table-bordered table-condensed">
        <tr>
            <th>Source</th>
            <th colspan="2">OSE</th>
        </tr>
        <?php foreach ($data as $d): ?>
            <tr>
                <td><?= $d['source-statut'] ?></td>
                <td><?= $d['intervenant-statut'] ?></td>
                <td><?php
                    if ($d['histo-destruction']) {
                        echo 'Supprimée le ' . $d['histo-destruction'] . ' par ' . $d['histo-destructeur'] . ' ';
                        echo $this->tag('a', [
                            'class' => 'no-intranavigation',
                            'href'  => $this->url('intervenant/restaurer', ['intervenant' => $d['id']]),
                            'title' => 'Restaurer la fiche de l\'intervenant',
                        ])->html($this->tag('span', ['class' => 'glyphicon glyphicon-open']));
                    }
                    ?></td>
            </tr>
        <?php endforeach; ?>
    </table>
<?php

if ($isImportable) {
    echo $this->tag('a', [
        'href'  => $this->url('intervenant/synchroniser', ['intervenant' => $intervenant->getId()]),
        'title' => 'Synchroniser (import vers OSE)',
        'class' => 'btn btn-default no-intranavigation',
    ])->html('Synchroniser (import vers OSE)');
}
 No newline at end of file
Loading