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

Amélioration au niveau des suppressions/restaurations.

Recherche dans les intervenants historisés aussi si on en a le privilège
parent fb6c5315
Loading
Loading
Loading
Loading
+8 −1
Changes for module/Application/config/intervenant.config.php: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -486,11 +486,18 @@ return [
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['saisir', 'definir-par-defaut', 'synchronisation', 'synchroniser', 'restaurer'],
                    'action'     => ['saisir', 'definir-par-defaut', 'synchronisation', 'synchroniser'],
                    'privileges' => [
                        Privileges::INTERVENANT_EDITION,
                    ],
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['restaurer'],
                    'privileges' => [
                        Privileges::INTERVENANT_AJOUT_STATUT,
                    ],
                ],
                [
                    'controller' => 'Application\Controller\Intervenant',
                    'action'     => ['supprimer', 'historiser'],
+9 −4
Changes for module/Application/src/Application/Controller/IntervenantController.php: 9 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -103,7 +103,12 @@ class IntervenantController extends AbstractController
        ]);

        $critere   = $this->params()->fromPost('critere');
        $intervenants = $this->getProcessusIntervenant()->recherche()->rechercher($critere, 21);
        $recherche = $this->getProcessusIntervenant()->recherche();

        $canRestaure = $this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_AJOUT_STATUT));
        $recherche->setShowHisto($canRestaure);

        $intervenants = $recherche->rechercher($critere, 21);

        return compact('intervenants');
    }
@@ -112,8 +117,7 @@ class IntervenantController extends AbstractController

    public function voirAction()
    {
        $role        = $this->getServiceContext()->getSelectedIdentityRole();
        $intervenant = $role->getIntervenant() ?: $this->getEvent()->getParam('intervenant');
        $intervenant = $this->getEvent()->getParam('intervenant');
        $tab         = $this->params()->fromQuery('tab');

        if (!$intervenant) {
@@ -129,7 +133,7 @@ class IntervenantController extends AbstractController

        $this->addIntervenantRecent($intervenant);

        return compact('intervenant', 'role', 'tab');
        return compact('intervenant', 'tab');
    }


@@ -519,6 +523,7 @@ class IntervenantController extends AbstractController
        $tree = $intSuppr->getTree();
        if (!$tree) {
            $intervenant = $this->getServiceIntervenant()->getByCode($intervenantCode);
            if ($intervenant && $intervenant->estHistorise()) $intervenant = null;
        }

        return compact('intervenant', 'tree');
+43 −5
Changes for module/Application/src/Application/Processus/Intervenant/RechercheProcessus.php: 43 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,11 @@ class RechercheProcessus
    use EntityManagerAwareTrait;
    use ContextServiceAwareTrait;

    /**
     * @var bool
     */
    protected $showHisto = false;



    /**
@@ -31,6 +36,30 @@ class RechercheProcessus



    /**
     * @return bool
     */
    public function isShowHisto(): bool
    {
        return $this->showHisto;
    }



    /**
     * @param bool $showHisto
     *
     * @return RechercheProcessus
     */
    public function setShowHisto(bool $showHisto): RechercheProcessus
    {
        $this->showHisto = $showHisto;

        return $this;
    }



    /**
     * @param string  $critere
     * @param integer $limit
@@ -46,7 +75,7 @@ class RechercheProcessus

    private function sqlLocale(): string
    {
        return "
        $sql = "
        SELECT
          i.id,
          i.code,
@@ -59,15 +88,19 @@ class RechercheProcessus
          c.libelle_long civilite,
          si.libelle statut,
          i.critere_recherche critere,
          i.annee_id
          i.annee_id,
          i.histo_destruction
        FROM
          intervenant i
          LEFT JOIN structure s ON s.id = i.structure_id
          LEFT JOIN civilite c ON c.id = i.civilite_id
          LEFT JOIN statut_intervenant si ON si.id = i.statut_id
        WHERE
          i.histo_destruction IS NULL
        ";
        if (!$this->showHisto) {
            $sql .= "WHERE i.histo_destruction IS NULL";
        }

        return $sql;
    }


@@ -87,7 +120,8 @@ class RechercheProcessus
          c.libelle_long civilite,
          si.libelle statut,
          i.critere_recherche critere,
          i.annee_id
          i.annee_id,
          null histo_destruction
        FROM
          src_intervenant i
          LEFT JOIN structure s ON s.id = i.structure_id
@@ -168,8 +202,12 @@ class RechercheProcessus
                    'structure'        => $r['STRUCTURE'],
                    'statut'           => $r['STATUT'],
                    'numero-personnel' => $r['CODE'],
                    'destruction'      => $r['HISTO_DESTRUCTION'],
                ];
            } else {
                if ($intervenants[$k]['destruction'] && !$r['destruction']) {
                    $intervenants[$k]['destruction'] = null;
                }
                if ($intervenants[$k]['statut'] && !is_array($intervenants[$k]['statut'])) {
                    $intervenants[$k]['statut'] = [$intervenants[$k]['statut']];
                }
+11 −1
Changes for module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -97,6 +97,11 @@ class IntervenantViewHelper extends AbstractHtmlElement
                $msg .= ' Sa fiche ne remonte plus depuis l\'application ' . $entity->getSource() . '.';
            }

            $canRestaure = $this->getView()->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_AJOUT_STATUT));
            if ($canRestaure) {
                $msg .= "<br />" . $this->getView()->tag('a', ['href' => $this->getView()->url('intervenant/restaurer', ['intervenant' => $entity->getId()])])->html('Restaurer la fiche');
            }

            $html .= '<div class="alert alert-danger">' . $msg . '</div>';
        }

@@ -131,10 +136,14 @@ class IntervenantViewHelper extends AbstractHtmlElement

        $this->getView()->headTitle()->append($intervenant->getNomUsuel())->append($title);
        $title .= ' <small>' . $intervenant . '</small>';
        if ($intervenant->estHistorise()) {
            $title .= ' ' . $this->getView()->tag('span', ['class' => 'text-danger glyphicon glyphicon-warning-sign', 'title' => 'Intervenant historisé'])->text('');
        }

        echo $this->getView()->tag('h1', ['class' => 'page-header'])->open();
        echo $title . '<br />';
        $statuts = $this->getStatuts();
        if (!empty($statuts)) {
            ?>
            <nav class="navbar navbar-default intervenant-statuts">
                <ul class="nav navbar-nav">
@@ -150,7 +159,7 @@ class IntervenantViewHelper extends AbstractHtmlElement
                    <?php endforeach; ?>
                    <?php if ($canAddIntervenant): ?>
                        <li class="ajout-intervenant">
                        <a href="<?= $this->getView()->url('intervenant/dupliquer', ['intervenant' => $intervenantId]); ?>"
                            <a href="<?= $this->getView()->url('intervenant/dupliquer', ['intervenant' => $intervenant->getId()]); ?>"
                               title="Ajout d'un nouveau statut à l'intervenant"><span
                                        class="glyphicon glyphicon-plus"></span></a>
                        </li>
@@ -158,6 +167,7 @@ class IntervenantViewHelper extends AbstractHtmlElement
                </ul>
            </nav>
            <?php
        }
        echo $this->getView()->tag('h1')->close();
    }

+3 −1
Changes for module/Application/view/application/intervenant/liste.phtml: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@
    <?php foreach ($intervenants

    as $code => $intervenant): ?>
    <tr>
    <tr<?php if (isset($intervenant['destruction']) && $intervenant['destruction']) {
        echo ' class="bg-danger" title="Fiche historisée" style="color:gray"';
    } ?>>
        <td style="white-space: nowrap"><a href="<?= $this->url('intervenant/voir', ['intervenant' => 'code:' . $code]); ?>">
                <span class="glyphicon glyphicon-eye-open"></span> Fiche
            </a></td>
Loading