Commit 880e3e36 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

finalisation recherche intervenant

parent f73ff256
Loading
Loading
Loading
Loading
+68 −37
Original line number Diff line number Diff line
<template>
    <h1>Recherche Intervenant</h1>
    <h3>Saisissez le nom suivi éventuellement du prénom (2 lettres minimum)</h3>

    <div class="intervenant-recherche">
        <div class="critere">
            <div>
                <input id="term" v-on:keyup="rechercher" class="form-control input" type="text"
                       placeholder="Saisissez le nom suivi éventuellement du prénom (2 lettres au moins)"/><br/>
                       placeholder="votre recherche..."/><br/>
            </div>
            <div>
                Types d'intervenant :
                <span class="fw-bold">Types d'intervenant : </span>
                <input v-on:change="reload()" type="checkbox" name="type[]" value="permanent" checked="checked" v-model="checkedTypes"> Permanent
                <input v-on:change="reload()" type="checkbox" name="type[]" value="vacataire" checked="checked" v-model="checkedTypes"> Vacataire
                <input v-on:change="reload()" type="checkbox" name="type[]" value="etudiant" checked="checked" v-model="checkedTypes"> Etudiant
                
            </div>
            <br/>
        </div>
    </div>


    <table class="table table-bordered table-sm">
    <table v-if="intervenants.length > 0" class="table table-bordered table-hover">
        <thead>
        <tr>
            <th></th>
            <th style="width:90px"></th>
            <th>Civilité</th>
            <th>Prenom</th>
            <th>Nom</th>
            <th>Prenom</th>
            <th>Structure</th>
            <th>Statut</th>
            <th>Type</th>
            <th>Date de naissance</th>
            <th>N° Personnel</th>
        </tr>
@@ -35,23 +35,44 @@
        <tbody>
        <tr :class="{'bg-danger': intervenant.destruction!==null}" :title="(intervenant.destruction!==null) ? 'Fiche historisé' : ''"
            v-for="(intervenant,code) in intervenants">
            <td>
                <a :href="urlFiche(code)">Fiche</a>
            <td style="">
                <a :href="urlFiche(intervenant['code'])"><i class="fas fa-eye"></i> Fiche</a>
            </td>
            <td>{{ intervenant.civilite }}</td>
            <td>{{ intervenant.prenom }}</td>
            <td>{{ intervenant.nom }}</td>
            <td>{{ intervenant.structure }}</td>
            <td>{{ intervenant.statut }}</td>
            <td>{{ intervenant.typeIntervenantLibelle }}</td>
            <td>{{ intervenant.dateNaissance.toLocaleString() }}</td>
            <td>{{ intervenant.numeroPersonnel }}</td>
            <td>{{ intervenant['civilite'] }}</td>
            <td>{{ intervenant['nom'] }}</td>
            <td>{{ intervenant['prenom'] }}</td>
            <td>{{ intervenant['structure'] }}</td>
            <td>{{ intervenant['statut'] }}</td>
            <td>{{ intervenant['date-naissance'] }}</td>
            <td>{{ intervenant['numero-personnel'] }}</td>
        </tr>

        </tbody>
    </table>

    <table v-if="intervenants.length == 0 && noResult == 1" class="table table-bordered table-hover">
        <thead>
        <tr>
            <th style="width:90px"></th>
            <th>Civilité</th>
            <th>Nom</th>
            <th>Prenom</th>
            <th>Structure</th>
            <th>Statut</th>
            <th>Date de naissance</th>
            <th>N° Personnel</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td style="text-align:center" colspan="8">Aucun intervenant trouvé</td>
        </tr>

        </tbody>
    </table>
</template>


<script>


@@ -61,39 +82,39 @@ export default {
    data()
    {
        return {
            searchTerm: [],
            searchTerm: '',
            noResult: 0,
            intervenants: [],
            checkedTypes: ['vacataire', 'permanent', 'etudiant'],
        };
    },
    mounted()
    {
        this.reload();
    },

    methods: {
        rechercher: function (event)
        {
            this.searchTerm = event.target.value;

            if (this.searchTerm == '') {
                this.noResult = 0;
            }
            if (this.searchTerm != '') {
                this.reload();
            }
        },
        filtrer: function ()
        {

        },
        urlFiche(code)
        {
            return '/intervenant/code:'+code+'/voir';
        },

        reload()
        {
            console.log(this.checkedTypes);

            if (this.timer) {
                clearTimeout(this.timer);
                this.timer = null;
            }
            this.timer = setTimeout(() => {

                axios.post(
                    Util.url("intervenant/recherche-json"), {
                        term: this.searchTerm
@@ -101,22 +122,32 @@ export default {
                )
                    .then(response => {
                        let datas = response.data;
                        let datasFiltered = [];

                        for (const intervenant in datas) {
                            if (datas[intervenant].typeIntervenantCode == 'E' && !this.checkedTypes.includes('vacataire')) {
                                delete datas[intervenant]
                            if (datas[intervenant].typeIntervenantCode == 'E' && this.checkedTypes.includes('vacataire')) {
                                datasFiltered.push(datas[intervenant]);
                                continue;
                            }
                            if (datas[intervenant].typeIntervenantCode == 'P' && !this.checkedTypes.includes('permanent')) {
                                delete datas[intervenant]
                            if (datas[intervenant].typeIntervenantCode == 'P' && this.checkedTypes.includes('permanent')) {
                                datasFiltered.push(datas[intervenant]);
                                continue;
                            }
                            if (datas[intervenant].typeIntervenantCode == 'S' && !this.checkedTypes.includes('etudiant')) {
                                delete datas[intervenant]
                            if (datas[intervenant].typeIntervenantCode == 'S' && this.checkedTypes.includes('etudiant')) {
                                datasFiltered.push(datas[intervenant]);
                                continue;
                            }

                        }
                        this.intervenants = datas;
                        this.intervenants = datasFiltered;

                        if (this.intervenants.length == 0) {
                            this.noResult = 1;
                        } else {
                            this.noResult = 0;
                        }



                    })
                    .catch(response => {
@@ -129,7 +160,7 @@ export default {


    }
    ,


}
</script>
+3 −34
Original line number Diff line number Diff line
@@ -90,33 +90,16 @@ class IntervenantController extends AbstractController



    public function rechercheAction()
    public function rechercheJsonAction()
    {
        $this->em()->getFilters()->enable('historique')->init([
            Intervenant::class,
        ]);

        $critere   = $this->params()->fromPost('critere');
        $recherche         = $this->getProcessusIntervenant()->recherche();

        $canShowHistorises = $this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_VISUALISATION_HISTORISES));
        $recherche->setShowHisto($canShowHistorises);

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

        return compact('intervenants');
    }



    public function rechercheJsonAction()
    {
        $recherche    = $this->getProcessusIntervenant()->recherche();
        $intervenants = [];
        $term         = $this->axios()->fromPost('term');

        if (!empty($term)) {
            $intervenants = $recherche->rechercher($term, 21);
            $intervenants = $recherche->rechercher($term, 40);
        }

        return $this->axios()->send($intervenants);
@@ -124,20 +107,6 @@ class IntervenantController extends AbstractController



    /**
     * Page d'index des missions
     *
     * @return array|\Laminas\View\Model\ViewModel
     */
    public function rechercheIntervenantAction()
    {


        return [];
    }



    public function voirAction()
    {
        $intervenant = $this->getEvent()->getParam('intervenant');
+3 −2
Original line number Diff line number Diff line
@@ -205,13 +205,14 @@ class RechercheProcessus
                    'civilite'               => $r['CIVILITE'],
                    'nom'                    => $r['NOM_USUEL'],
                    'prenom'                 => $r['PRENOM'],
                    'dateNaissance'          => new \DateTime($r['DATE_NAISSANCE']),
                    'date-naissance'         => new \DateTime($r['DATE_NAISSANCE']),
                    'structure'              => $r['STRUCTURE'],
                    'statut'                 => $r['STATUT'],
                    'typeIntervenantCode'    => $r['TYPE_INTERVENANT_CODE'],
                    'typeIntervenantLibelle' => $r['TYPE_INTERVENANT_LIBELLE'],
                    'numeroPersonnel'        => $r['CODE_RH'],
                    'numero-personnel'       => $r['CODE_RH'],
                    'destruction'            => $r['HISTO_DESTRUCTION'],
                    'code'                   => $r['CODE'],

                ];
            } else {
+0 −11
Original line number Diff line number Diff line
<?php


$title = 'Recherche intervenant';


echo $this->messenger()->addCurrentMessagesFromFlashMessenger();

echo $this->vue('intervenant/recherche', []);

+8 −14
Original line number Diff line number Diff line
@@ -6,23 +6,10 @@
<?= $this->messenger()->addCurrentMessagesFromFlashMessenger(); ?>

<div style="padding:1em">
    <div class="intervenant-recherche">
        <div class="critere">
            Saisissez le nom suivi éventuellement du prénom (2 lettres au moins) :<br/>
            <input id="critere" class="form-control input" type="text" style="width:15em;display:inline"/>
        </div>
        <div class="recherche" data-url="<?= $this->url('intervenant/recherche') ?>">

        </div>
    </div>

    <?php

    if (!empty($recents)) {
        echo '<h3>Fiches récemment consultées :</h3>';
        echo $this->partial('liste', ['intervenants' => $recents]);
    }

    echo $this->vue('intervenant/recherche', []);

    $canAddIntervenant = $this->isAllowed(\Application\Provider\Privilege\Privileges::getResourceId(\Application\Provider\Privilege\Privileges::INTERVENANT_CREATION));

@@ -31,5 +18,12 @@
        echo $this->tag('a', ['class' => 'btn btn-primary', 'href' => $url])->html("Ajout d'un nouvel intervenant");
    }


    if (!empty($recents)) {
        echo '<h3 style="margin-top:20px;">Intervenants récemment consultés :</h3>';
        echo $this->partial('liste', ['intervenants' => $recents]);
    }


    ?>
</div>
Loading