Laravel 5

Erreur fonctionnalités profil

  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    Bonjour dans mon application j'ai plusieurs profils dont l'administrateur qui a la possibilité de poster des messages. Si deux administrateurs sont identifiés ils ne peuvent plus déposer de messages.
    Je n'arrive pas à trouver ou cela se trouve pour modifier le fichier pour éviter ce conflit.

  • Avatar de MaitrePylos
    Membre depuis :
    27/05/2013
    Messages :
    264

    On peut voir un peu de code sur le contexte ?

  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    Le problème c'est que je ne sais pas quel fichier est concerné

  • Avatar de MaitrePylos
    Membre depuis :
    27/05/2013
    Messages :
    264

    Ha, alors on peux pas t'aider.
    On ne sait ap de quoi parle, dans quel contexte et sur quelle application.
    Même avec la meilleur volonté du monde.

  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    @extends('layouts.app')

    @section('content')

    <div class="container">

    <div class="row justify-content-center">

    <div class="col-md-12">

    <div class="card">

    <div class="card-header">Tableau de bord</div>

    <div class="card-body">

    <ul class="nav md-pills nav-justified pills-secondary">

    @if (auth()->user()->isAdmin()||auth()->user()->isSuperAdmin())

    <li class="nav-item">

    <a class="nav-link active" data-toggle="tab" href="#panelUser" role="tab">Utilisateurs</a>

    </li>

    @endif

    <li class="nav-item">

    <a class="nav-link" data-toggle="tab" href="#panelDispo" role="tab">Disponibilités</a>

    </li>

    @if (auth()->user()->isAdmin()||auth()->user()->isSuperAdmin())

    <li class="nav-item">

    <a class="nav-link" data-toggle="tab" href="#panelCompetences" role="tab">Compétences</a>

    </li>

    @endif

    @if (auth()->user()->isSuperAdmin())

    <li class="nav-item">

    <a class="nav-link" data-toggle="tab" href="#panelCentreDeSecours" role="tab">Centre de secours</a>

    </li>

    @endif

    </ul>

    <!-- Tab panels -->

    <div class="tab-content">

    <!--Panel 1-->

    @if (auth()->user()->isAdmin() || auth()->user()->isSuperAdmin())

    <div class="tab-pane fade in show active" id="panelUser" role="tabpanel">

    <br>

    <style>

    /.dropdown.dropdown-lg .dropdown-menu {

    margin-top: -1px;

    padding: 6px 20px;

    }

    .input-group-btn .btn-group {

    display: flex !important;

    }

    .btn-group .btn {

    border-radius: 0;

    margin-left: -1px;

    }

    .btn-group .btn:last-child {

    border-top-right-radius: 4px;

    border-bottom-right-radius: 4px;

    }

    .btn-group .form-horizontal .btn[type="submit"] {

    border-top-left-radius: 4px;

    border-bottom-left-radius: 4px;

    }

    .form-horizontal .form-group {

    margin-left: 0;

    margin-right: 0;

    }

    .form-group .form-control:last-child {

    border-top-left-radius: 4px;

    border-bottom-left-radius: 4px;

    }

    @media screen and (min-width: 768px) {

    #adv-search {

    width: 500px;

    margin: 0 auto;

    }

    .dropdown.dropdown-lg {

    position: static !important;

    }

    .dropdown.dropdown-lg .dropdown-menu {

    min-width: 500px;

    }

    }
    /

    </style>

    <div class="input-group" id="adv-search" style="display: none;">

    <input type="text" class="form-control" placeholder="Search for snippets" />

    <div class="input-group-btn">

    <div class="btn-group" role="group">

    <div class="dropdown dropdown-lg">

    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">

    <span class="caret"></span>

    </button>

    <div class="dropdown-menu dropdown-menu-right" role="menu">

    </div>

    </div>

    </div>

    </div>

    </div>

    @if( auth()->user()->isSuperAdmin() )

    <form class="form-horizontal" action="/admin" id="searchForm" role="form" method="post">

    {{ csrf_field() }}

    <div class="form-group col-md-4" style="float: left;">

    <label for="filter">Compétences</label>

    <select multiple data-placeholder="{{trans("csp.vos_cp2")}}" name="cp[]" id="cp" class="form-control chosen-select" tabindex="6">

    {!! \App\Competence::getCompetence( false, '', true, $cp ) !!}

    </select>

    </div>

    <div class="form-group col-md-4" style="float: left;">

    <label for="filter">Centre de secours</label>

    <select name="cs" id="cs" class="form-control">

    {!! \App\CentreDeSecours::getCentredeSecours( false, '', true, $cs ) !!}

    </select>

    </div>

    <div class="form-group col-md-4" style="float: left;margin: 16px 0;">

    <button type="submit" class="submit_search btn btn-primary">Rechercher</button>

    </div>

    </form>

    @endif

    <style>

    ul.chosen-choices{ height: 37px !important; }

    </style>

    <div style="clear: both;"></div>

    <table class="table table-striped">

    <!--Table head-->

    <thead>

    <tr>

    <th style="display: none;">#</th>

    <th>Identifiants</th>

    <th>Compétences</th>

    <th>Centres de secours</th>

    <th>Statut</th>

    @if( auth()->user()->isSuperAdmin() )

    <th>Rôle</th>

    @endif

    <th>Validation</th>

    <th>Supprimer</th>

    <th>Modifier</th>

    </tr>

    </thead>

    <!--Table head-->

    <!--Table body-->

    <tbody>

    @if (auth()->user()->isAdmin() || auth()->user()->isSuperAdmin())

    @foreach ($users as $user)

    <tr id="user-{{$user->id}}">

    <th style="display: none;" scope="row">{{ $user->id }}</th>

    <td id="uname{{$user->id}}">{{ $user->name }}</td>

    <td id="cp_ad{{$user->id}}">{{ \App\Competence::getArrayCompetence(\App\Competence::getCompetence(true,$user->id) ) }}</td>

    <td id="cs_ad{{$user->id}}">{{ isset( \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name ) ? \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name : '' }}</td>

    <td id="compte-active-{{ $user->id }}">

    @if( $user->is_valid_mail )

    @if( $user->is_active )

    {!!trans("csp.compte_active")!!}

    @else

    {!!trans("csp.en_attente_validation")!!}

    @endif

    @else

    {!!trans("csp.attente_conf_mail")!!}

    @endif

    </td>

    @if( auth()->user()->isSuperAdmin() )

    <td id="role_ad{{$user->id}}">

    @if( $user->role == \App\User::SUPER_TYPE && ( $user->id == 29 ) )

    Super admin

    @else

    <select onchange="changerole( this, {{ $user->id }} )" name="roleUser" id="roleUser" class="form-control">

    <option value="{{ \App\User::SUPER_TYPE }}" {{ $user->role == \App\User::SUPER_TYPE ? 'selected' : '' }}>Super admin</option>

    <option value="{{ \App\User::ADMIN_TYPE }}" {{ $user->role == \App\User::ADMIN_TYPE ? 'selected' : '' }}>Admin</option>

    <option value="{{ \App\User::GESTIONNAIRE_TYPE }}" {{ $user->role == \App\User::GESTIONNAIRE_TYPE ? 'selected' : '' }}>Gestionnaire</option>

    <option value="{{ \App\User::DEFAULT_TYPE }}" {{ $user->role == \App\User::DEFAULT_TYPE ? 'selected' : '' }}>Utilisateur</option>

    </select>

    @endif

    </td>

    @endif

    <td id="compte-button-{{ $user->id }}">

    @if( $user->is_valid_mail )

    @if( $user->is_active )

    --

    @else

    @if( isset( \App\CentreDeSecours::getCentredeSecours( true )->name ) && isset( \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name ) )

    @if( \App\CentreDeSecours::getCentredeSecours( true )->name == \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name )

    <button type="button" class="btn btn-unique btn-sm my-0" data-toggle="modal" data-target="#modalAskValidateUser" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @else

    <button disabled="disabled" type="button" class="btn btn_validate btn-unique btn-sm my-0" data-toggle="modal" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @endif

    @else

    <button disabled="disabled" type="button" class="btn btn_validate btn-unique btn-sm my-0" data-toggle="modal" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @endif

    @endif

    @else

    --

    @endif

    </td>

    <td>

    @if( auth()->user()->isSuperAdmin() || $user->id == \Auth::id() || ( auth()->user()->isAdmin() && $user->role != "admin" ) )

    <button type="button" class="btn btn-unique btn-sm my-0" data-toggle="modal" data-target="#modalAskDeleteUser" style="padding: .175rem .75rem; margin: 0px;">Supprimer</button>

    @else

    <button disabled="disabled" type="button" class="btn_validate btn btn-unique btn-sm my-0" data-toggle="modal" style="padding: .175rem .75rem; margin: 0px;" onclick="javascript:void(0)">Supprimer</button>

    @endif

    </td>

    <td>

    @if( auth()->user()->isSuperAdmin() || $user->id == \Auth::id() || ( auth()->user()->isAdmin() && $user->role != "admin" ) )

    <button type="button" class="btn btn-unique btn-sm my-0" onclick="updateUser(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button>

    @else

    <button disabled="disabled" type="button" class="btn_validate btn btn-unique btn-sm my-0" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button>

    @endif

    </td>

    </tr>

    @endforeach

    @endif

    @if (auth()->user()->isGestionnaire())

    @foreach ($users as $user)

    <tr id="user-{{$user->id}}">

    <th style="display: none;" scope="row">{{ $user->id }}</th>

    <td>{{ $user->name }}</td>

    <td>{{ \App\Competence::getArrayCompetence(\App\Competence::getCompetence(true,$user->id) ) }}</td>

    <td>{{ isset( \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name ) ? \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name : '' }}</td>

    <td id="compte-active-{{ $user->id }}">

    @if( $user->is_valid_mail )

    @if( $user->is_active )

    {!!trans("Compte active")!!}

    @else

    {!!trans("En attende validation admin")!!}

    @endif

    @else

    {!!trans("En attende confirmation e-mail")!!}

    @endif

    </td>

    <td id="compte-button-{{ $user->id }}">

    @if( $user->is_valid_mail )

    @if( $user->is_active )

    --

    @else

    @if( isset( \App\CentreDeSecours::getCentredeSecours( true )->name ) && isset( \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name ) )

    @if( \App\CentreDeSecours::getCentredeSecours( true )->name == \App\CentreDeSecours::getCentredeSecours(true,$user->id)->name )

    <button type="button" class="btn btn-unique btn-sm my-0" data-toggle="modal" data-target="#modalAskValidateUser" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @else

    <button disabled="disabled" type="button" class="btn btn_validate btn-unique btn-sm my-0" data-toggle="modal" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @endif

    @else

    <button disabled="disabled" type="button" class="btn btn_validate btn-unique btn-sm my-0" data-toggle="modal" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;" >Valider</button>

    @endif

    @endif

    @else

    --

    @endif

    </td>

    <td>

    @if( auth()->user()->isSuperAdmin() || $user->id == \Auth::id() )

    <button type="button" class="btn btn-unique btn-sm my-0 disabled" data-toggle="modal" data-target="#modalAskDeleteUser" style="padding: .175rem .75rem; margin: 0px;">Supprimer</button>

    @else

    <button disabled="disabled" type="button" class="btn_validate btn btn-unique btn-sm my-0 disabled" data-toggle="modal" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;">Supprimer</button>

    @endif

    </td>

    <td>

    @if( auth()->user()->isSuperAdmin() || $user->id == \Auth::id() )

    <button type="button" class="btn btn-unique btn-sm my-0 disabled" onclick="updateUser(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button>

    @else

    <button disabled="disabled" type="button" class="btn_validate btn btn-unique btn-sm my-0 disabled" onclick="javascript:void(0)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button>

    @endif

    </td>

    </tr>

    @endforeach

    @endif

    </tbody>

    <!--Table body-->

    </table>

    <!--Table-->

    {{ $users->links() }}

    </div>

    <!--/.Panel 1-->

    @endif

    <!--Panel 2-->

    <div class="tab-pane fade" id="panelDispo" role="tabpanel">

    <br>

    <div class="form-group row">

    <label for="dateSearchDispo" class="col-md-2 col-form-label text-md-right">Date</label>

    <div class="col-md-6">

    <input type="text" id="dateSearchDispo" name="dateSearchDispo" class="datepicker-here form-control" data-language='fr' placeholder="Choisir une date" />

    </div>

    <button onclick="searchDispo(this)" class="btn btn-unique" style="margin: 0px;">Go</button>

    </div>

    <h3>Liste des disponibilités pour cette date :</h3>

    <table class="table table-striped">

    <!--Table head-->

    <thead>

    <tr>

    <th style="display: none;" scope="row">#</th>

    <th>Utilisateur</th>

    @if( auth()->user()->isSuperAdmin() )

    <th>Centre de secours</th>

    @endif

    <th>Statut</th>

    <th>Date de début</th>

    <th>Date de fin</th>

    <th>Compétences</th>

    <th>Supprimer</th>

    <th>Modifier</th>

    </tr>

    </thead>

    <!--Table head-->

    <!--Table body-->

    <tbody id="disponibilite_table">

    </tbody>

    <!--Table body-->

    </table>

    <!--Table-->

    </div>

    <!--/.Panel 2-->

    <div class="tab-pane fade" id="panelCompetences" role="tabpanel">

    <br>

    <h3>Ajouter une compétence :</h3>

    <div class="form-group row">

    <label for="name" class="col-md-4 col-form-label text-md-right">Nom de la compétence</label>

    <div class="col-md-5">

    <input id="nameCompetence" type="text" name="name" class="form-control" required>

    </div>

    <button class="btn btn-unique col-md-3" id="buttonAddCompetence" onclick="addCompetence()" style="margin: 0px;">Ajouter</button>

    </div>

    <h3>Liste des compétences :</h3>

    <table class="table table-striped">

    <!--Table head-->

    <thead>

    <tr>

    <th style="display: none;">#</th>

    <th>Nom</th>

    <th>Supprimer</th>

    <th>Modifier</th>

    </tr>

    </thead>

    <!--Table head-->

    <!--Table body-->

    <tbody id="competence_table">

    <?php $competences = \App\Competence::all(); ?>

    @foreach ($competences as $comp)

    <tr id="competence-{{ $comp->id }}">

    <th style="display: none;" scope="row">{{ $comp->id }}</th>

    <td class="name">{{ $comp->name }}</td>

    <td><button type="submit" class="btn btn-unique btn-sm my-0 buttonDeleteCompetence" data-toggle="modal" data-target="#modalAskDeleteCompetence" style="padding: .175rem .75rem; margin: 0px;">Supprimer</button></td>

    <td><button type="submit" class="btn btn-unique btn-sm my-0 buttonEditCompetence" onclick="updateCompetence(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button></td>

    </tr>

    @endforeach

    </tbody>

    <!--Table body-->

    </table>

    <!--Table-->

    </div>

    @if (auth()->user()->isSuperAdmin())

    <div class="tab-pane fade" id="panelCentreDeSecours" role="tabpanel">

    <br>

    <h3>Ajouter un centre de secours :</h3>

    <div class="form-group row">

    <label for="name" class="col-md-4 col-form-label text-md-right">Nom du centre de secours</label>

    <div class="col-md-5">

    <input id="nameCentreDeSecours" type="text" name="namecentredesecours" class="form-control" required>

    </div>

    <button class="btn btn-unique col-md-3" id="buttonAddCompetence" onclick="addCentreDeSecours()" style="margin: 0px;">Ajouter</button>

    </div>

    <h3>Liste des centres de secours :</h3>

    <table class="table table-striped">

    <!--Table head-->

    <thead>

    <tr>

    <th style="display: none;">#</th>

    <th>Nom</th>

    <th>Supprimer</th>

    <th>Modifier</th>

    </tr>

    </thead>

    <!--Table head-->

    <!--Table body-->

    <tbody id="centredesecours_table">

    <?php $CentreDeSecours = \App\CentreDeSecours::all(); ?>

    @foreach ($CentreDeSecours as $comp)

    <tr id="centredesecours-{{ $comp->id }}">

    <th style="display: none;" scope="row">{{ $comp->id }}</th>

    <td class="name">{{ $comp->name }}</td>

    <td><button type="submit" class="btn btn-unique btn-sm my-0 buttonDeleteCentreDeSecours" data-toggle="modal" data-target="#modalAskDeleteCentreDeSecours" style="padding: .175rem .75rem; margin: 0px;">Supprimer</button></td>

    <td><button type="submit" class="btn btn-unique btn-sm my-0 buttonEditCentreDeSecours" onclick="updateCentreDeSecours(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button></td>

    </tr>

    @endforeach

    </tbody>

    <!--Table body-->

    </table>

    <!--Table-->

    </div>

    @endif

    </div>

    </div>

    </div>

    </div>

    </div>

    </div>

    <!--Modal: modalConfirmDelete-->

    <div class="modal fade" id="modalConfirmDelete" tabindex="-1" role="dialog" aria-labelledby="modal_delete" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Supression effectué</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer">

    <a type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Ok</a>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div><!--Modal: modalConfirmDelete-->

    <!--Modal: modalConfirmDelete-->

    <div class="modal fade" id="modalConfirmChangeRole" tabindex="-1" role="dialog" aria-labelledby="modal_delete" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Rôle changé</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer">

    <a type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Ok</a>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <!--Modal: modalConfirmDeleteCentreDeSecours-->

    <div class="modal fade" id="modalConfirmDeleteCentreDeSecours" tabindex="-1" role="dialog" aria-labelledby="modal_delete" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Supression effectué</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer">

    <a type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Ok</a>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <!--Modal: modalConfirmDeleteCentreDeSecours-->

    <!--Modal: modalError-->

    <div class="modal fade" id="modalError" tabindex="-1" role="dialog" aria-labelledby="modal_error" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Erreur</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    <p> Une erreur est survenue, veuillez raffraichir la page. </p>

    </div>

    <!--Footer-->

    <div class="modal-footer">

    <a type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Ok</a>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <!--Modal: modalError-->

    <!--Modal: modalEdit-->

    <div class="modal fade" id="modalEdit" tabindex="-1" role="dialog" aria-labelledby="modalEdit" aria-hidden="true">

    <div class="modal-dialog" role="document">

    <div class="modal-content">

    <div class="modal-header text-center">

    <h4 class="modal-title w-100 font-weight-bold">Modifier le profil de l'utilisateur</h4>

    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

    <span aria-hidden="true">&times;</span>

    </button>

    </div>

    <div class="modal-body mx-3">

    <div class="md-form mb-4">

    <input type="email" id="modalEdit-email" class="form-control validate" placeholder="Email">

    <label class="active" for="modalEdit-email">Email</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-name" class="form-control validate" placeholder="Identifiant">

    <label class="active" for="modalEdit-name">Identifiant</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-matricule" class="form-control validate" placeholder="Matricule">

    <label class="active" for="modalEdit-matricule">Matricule</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-grade" class="form-control validate" placeholder="Grade">

    <label class="active" for="modalEdit-grade">Grade</label>

    <div class="container">
    <a href="#" title="Utiliser les grades sous la forme" data-toggle="popover" data-trigger="focus" data-content="Sapeur - Caporal - Caporal-chef - Sergent - Sergent-chef - Adjudant - Adjudant-chef - Lieutenant - Capitaine - Commandant - Lieutenant-colonel - Colonel
    "><span class="badge badge-pill badge-primary">Aide pour compléter les grades</span></a>
    </div>

    <script>
    $(document).ready(function(){
    $('[data-toggle="popover"]').popover();
    });
    </script></div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-adresse" class="form-control validate" placeholder="adresse">

    <label class="active" for="modalEdit-adresse">Adresse</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-ville" class="form-control validate" placeholder="ville">

    <label class="active" for="modalEdit-ville">CP & ville</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-telephone" class="form-control validate" placeholder="telephone">

    <label class="active" for="modalEdit-telephone">Téléphone</label>

    </div>

    <div class="md-form mb-4">

    <input type="text" id="modalEdit-incor" class="form-control validate" placeholder="incor">

    <label class="active" for="modalEdit-incor">Date d'inscription</label>

    </div>

    <div class="md-form mb-4">

    <select id="modalEdit-role" class="browser-default form-control" >

    <option value="" disabled selected>Rôle</option>

    <option value="default">Utilisateur</option>

    <option value="gestionnaire">Gestionnaire</option>

    <option value="admin">Administrateur</option>

    </select>

    <label class="active" for="modalEdit-role">Rôle</label>

    </div>

    <div class="md-form mb-4">

    <?php $competences = \App\Competence::all(); ?>

    <select data-placeholder="Vos compétences" name="competences" id="modalEdit-competence" multiple class="chosen-select form-control" style="margin:auto;" tabindex="8">

    <option value=""></option>

    @foreach ($competences as $competence)

    <option value="{{ $competence->id }}">{{ $competence->name }}</option>

    @endforeach

    </select>

    <label class="active" for="modalEdit-competences">Compétences</label>

    </div>

    <div class="md-form mb-4">

    <?php $CentreDeSecours = \App\CentreDeSecours::all(); ?>

    <select required data-placeholder="{!!trans('csp.voscs')!!}" name="modalEdit-centredesecours" id="modalEdit-centredesecours" class="chosen-select form-control">

    <option value=""></option>

    @foreach ($CentreDeSecours as $CentreDeSecours)

    <option value="{{ $CentreDeSecours->id }}">{{ $CentreDeSecours->name }}</option>

    @endforeach

    </select>

    <label class="active" for="modalEdit-centredesecours">Centre de secours</label>

    </div>

    <input type="hidden" id="modalEdit-id" class="form-control validate">

    </div>

    <div class="modal-footer d-flex justify-content-center">

    <button class="btn btn-default" id="modalEdit-save" onclick="saveUpdatedUser(this)">Sauvegarder</button>

    </div>

    </div>

    </div>

    </div>

    <!--Modal: modalEdit -->

    <!--Modal: modalEdit-->

    <div class="modal fade" id="modalEditCompetence" tabindex="-1" role="dialog" aria-labelledby="modalEditCompetence" aria-hidden="true">

    <div class="modal-dialog" role="document">

    <div class="modal-content">

    <div class="modal-header text-center">

    <h4 class="modal-title w-100 font-weight-bold">Modifier le compétence</h4>

    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

    <span aria-hidden="true">&times;</span>

    </button>

    </div>

    <div class="modal-body mx-3">

    <div class="md-form mb-4">

    <input type="text" id="modalEditCompetence-name" class="form-control validate" placeholder="Nom">

    <label class="active" for="modalEditCompetence-name">Nom</label>

    </div>

    <input type="hidden" id="modalEditCompetence-id" class="form-control validate">

    </div>

    <div class="modal-footer d-flex justify-content-center">

    <button class="btn btn-default" id="modalEditCompetence-save" onclick="saveUpdatedCompetence(this)">Sauvegarder</button>

    </div>

    </div>

    </div>

    </div>

    <!--Modal: modalEditCompetence -->

    <!--Modal: modalEdit-->

    <div class="modal fade" id="modalEditCentreDeSecours" tabindex="-1" role="dialog" aria-labelledby="modalEditCentreDeSecours" aria-hidden="true">

    <div class="modal-dialog" role="document">

    <div class="modal-content">

    <div class="modal-header text-center">

    <h4 class="modal-title w-100 font-weight-bold">Modifier le centre de secours</h4>

    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

    <span aria-hidden="true">&times;</span>

    </button>

    </div>

    <div class="modal-body mx-3">

    <div class="md-form mb-4">

    <input type="text" id="modalEditCentreDeSecours-name" class="form-control validate" placeholder="Nom">

    <label class="active" for="modalEditCentreDeSecours-name">Nom</label>

    </div>

    <input type="hidden" id="modalEditCentreDeSecours-id" class="form-control validate">

    </div>

    <div class="modal-footer d-flex justify-content-center">

    <button class="btn btn-default" id="modalEditCentreDeSecours-save" onclick="saveUpdatedCentreDeSecours(this)">Sauvegarder</button>

    </div>

    </div>

    </div>

    </div>

    <!--Modal: modalEditCentreDeSecours -->

    <div class="modal fade" id="modalEditDisponibilite" tabindex="-1" role="dialog" aria-labelledby="modalEditDisponibilite" aria-hidden="true">

    <div class="modal-dialog" role="document">

    <div class="modal-content">

    <div class="modal-header text-center">

    <h4 class="modal-title w-100 font-weight-bold">Modifier la disponibilité</h4>

    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

    <span aria-hidden="true">&times;</span>

    </button>

    </div>

    <div class="modal-body mx-3">

    <div class="md-form mb-4">

    <label class="active" for="modalEditDisponibilite-date_debut">Date et heure de début de disponibilité</label>

    <input id="modalEditDisponibilite-date_debut" type="text"name="date_debut" class="datepicker-here form-control" data-timepicker="true" data-language='fr' placeholder="Choisir une date" />

    </div>

    <div class="md-form mb-4">

    <label class="active" for="modalEditDisponibilite-date_fin">Date et heure de fin de disponibilité</label>

    <input id="modalEditDisponibilite-date_fin" type="text" name="date_debut" class="datepicker-here form-control" data-timepicker="true" data-language='fr' placeholder="Choisir une date" />

    </div>

    <input type="hidden" id="modalEditDisponibilite-id" class="form-control validate">

    </div>

    <div class="modal-footer d-flex justify-content-center">

    <button class="btn btn-default" id="modalEditCompetence-save" onclick="saveUpdatedDisponibilite(this)">Sauvegarder</button>

    </div>

    </div>

    </div>

    </div>

    <div class="modal fade" id="modalEditDisponibiliteError" tabindex="-1" role="dialog" aria-labelledby="modal_error" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <div class="modal-content">

    <div class="modal-header text-center">

    <p class="heading">{!! trans('csp.depot_error') !!}</p>

    <button type="button" class="close" data-dismiss="modal" aria-label="Close">

    <span aria-hidden="true">&times;</span>

    </button>

    </div>

    <div class="modal-body mx-3">

    <p class="error"></p>

    </div>

    <div class="modal-footer justify-content-center">

    <a type="button" class="btn btn-success waves-effect" data-dismiss="modal">{!! trans('csp.Ok') !!}</a>

    </div>

    </div>

    </div>

    </div>

    <!--Modal: modalConfirmDelete-->

    <div class="modal fade" id="modalAskDeleteCompetence" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment supprimer ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_delete_competence" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <!--Modal: modalConfirmDelete-->

    <!--Modal: modalConfirmDeleteCentreDeSecours-->

    <div class="modal fade" id="modalAskDeleteCentreDeSecours" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment supprimer ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_delete_centredesecours" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <!--Modal: modalConfirmDeleteCentreDeSecours-->

    <div class="modal fade" id="modalAskValidateUser" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment activer ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_validate_user" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <div class="modal fade" id="modalAskDeleteUser" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment supprimer ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_delete_user" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <div class="modal fade" id="modalAskchangeRoleUser" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment changer le role ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_role_user" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <div class="modal fade" id="modalAskDeleteDisponibilite" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-sm modal-notify modal-danger" role="document">

    <!--Content-->

    <div class="modal-content text-center">

    <!--Header-->

    <div class="modal-header d-flex justify-content-center">

    <p class="heading">Voulez vous vraiment supprimer ?</p>

    </div>

    <!--Body-->

    <div class="modal-body">

    <i class="fa fa-times fa-4x animated rotateIn"></i>

    </div>

    <!--Footer-->

    <div class="modal-footer flex-center">

    <button id="button_confirm_delete_dispo" class="btn btn-outline-danger">Oui</button>

    <button type="button" class="btn btn-danger waves-effect" data-dismiss="modal">Non</button>

    </div>

    </div>

    <!--/.Content-->

    </div>

    </div>

    <style>

    .btn_validate{

    border: 1px solid #999999 !important;

    background-color: #cccccc !important;

    color: #666666 !important;

    }

    .datepicker.-from-bottom- {

    z-index: 1100;

    }

    </style>

    <script>

    $('#modalEdit-competence').chosen({

    "disable_search": true

    });

    $('#modalAskDeleteCompetence').on('show.bs.modal', function(e) {

    var id = $(e.relatedTarget).parent().parent().children(":first").text();

    console.log(id);

    $('#button_confirm_delete_competence').attr('onclick', "deleteCompetence("+id+")");

    });

    $('#modalAskDeleteUser').on('show.bs.modal', function(e) {

    var id = $(e.relatedTarget).parent().parent().children(":first").text();

    $('#button_confirm_delete_user').attr('onclick', "deleteUser("+id+")");

    });

    $('#modalAskValidateUser').on('show.bs.modal', function(e) {

    var id = $(e.relatedTarget).parent().parent().children(":first").text();

    $('#button_confirm_validate_user').attr('onclick', "validateUser("+id+")");

    });

    $('#modalAskDeleteDisponibilite').on('show.bs.modal', function(e) {

    var id = $(e.relatedTarget).parent().parent().children(":first").text();

    $('#button_confirm_delete_dispo').attr('onclick', "deleteDisponibilite("+id+")");

    });

    function confirmDelete(element){

    var id = $(element).parent().parent().children(":first").text();

    $("#modalConfirmDelete").modal();

    }

    function addCompetence(){

    var name = $('#nameCompetence').val();

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: '{{ route('competence.store') }}',

    type: 'POST',

    dataType: "json",

    data: {

    "name": name

    },

    success: function (data) {

    var id = data.competence_id;

    var append = '<tr id="competence-'+id+'">' + '<th scope="row" style="display:none;">'+ id +'</th>' + '<td>' + name +'</td>' + '<td><button type="submit" class="btn btn-unique btn-sm my-0 buttonDeleteCompetence" data-toggle="modal" data-target="#modalAskDeleteCompetence" " style="padding: .175rem .75rem; margin: 0px;">Supprimer</button></td>' + '<td><button type="submit" class="btn btn-unique btn-sm my-0 buttonEditCompetence" onclick="updateCompetence(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button></td>';

    $("#competence_table").append(append);

    $("#nameCompetence").val("");

    },

    error: function (e) {

    $("#modalError").modal();

    }

    });

    }

    function deleteCompetence(id){

    // var id = $(element).parent().parent().children(":first").text();

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: '{{ route('competenceDelete') }}',

    type: 'POST',

    dataType: "json",

    data: {

    "id": id

    },

    success: function (data) {

    $('#modalAskDeleteCompetence').modal('toggle');

    var modalDelete = $('#modalConfirmDelete');

    modalDelete.find(".modal-body").empty();

    modalDelete.find(".modal-body").append("<p>La compétence d'id "+id+" à été supprimé.</p>");

    modalDelete.modal();

    competence_delete = "#competence-"+id;

    $(competence_delete).remove();

    },

    error: function (e) {

    $("#modalError").modal();

    }

    });

    };

    /*/

    $('#modalAskDeleteCentreDeSecours').on('show.bs.modal', function(e) {

    var id = $(e.relatedTarget).parent().parent().children(":first").text();

    console.log(id);

    $('#button_confirm_delete_centredesecours').attr('onclick', "deleteCentreDeSecours("+id+")");

    });

    function addCentreDeSecours(){

    var name = $('#nameCentreDeSecours').val();

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: '{{ route('centre-de-secours.store') }}',

    type: 'POST',

    dataType: "json",

    data: {

    "name": name

    },

    success: function (data) {

    var id = data.centredesecours_id;

    var append = '<tr id="centredesecours-'+id+'">' + '<th scope="row" style="display:none;">'+ id +'</th>' + '<td>' + name +'</td>' + '<td><button type="submit" class="btn btn-unique btn-sm my-0 buttonDeleteCentreDeSecours" data-toggle="modal" data-target="#modalAskDeleteCentreDeSecours" " style="padding: .175rem .75rem; margin: 0px;">Supprimer</button></td>' + '<td><button type="submit" class="btn btn-unique btn-sm my-0 buttonEditCentreDeSecours" onclick="updateCentreDeSecours(this)" style="padding: .175rem .75rem; margin: 0px;">Modifier</button></td>';

    $("#centredesecours_table").append(append);

    $("#nameCentreDeSecours").val("");

    },

    error: function (e) {

    $("#modalError").modal();

    }

    });

    }

    function deleteCentreDeSecours(id){

    // var id = $(element).parent().parent().children(":first").text();

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: '{{ route('centredesecoursDelete') }}',

    type: 'POST',

    dataType: "json",

    data: {

    "id": id

    },

    success: function (data) {

    $('#modalAskDeleteCentreDeSecours').modal('toggle');

    var modalDelete = $('#modalConfirmDeleteCentreDeSecours');

    modalDelete.find(".modal-body").empty();

    modalDelete.find(".modal-body").append("<p>Le centre de secours d'id "+id+" à été supprimé.</p>");

    modalDelete.modal();

    competence_delete = "#centredesecours-"+id;

    $(competence_delete).remove();

    },

    error: function (e) {

    $("#modalError").modal();

    }

    });

    };

    function updateCentreDeSecours(element){

    var id = $(element).parent().parent().children(":first").text();

    console.log(id);

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: 'centre-de-secours/'+id,

    type: 'GET',

    dataType: "json",

    data: {

    "id": id

    },

    success: function (data) {

    console.log(data);

    $("#modalEditCentreDeSecours-name").val(data.centredesecours.name);

    $("#modalEditCentreDeSecours-id").val(data.centredesecours.id);

    $("#modalEditCentreDeSecours").modal();

    },

    error: function (e) {

    $("#modalError").modal();

    }

    });

    }

    function saveUpdatedCentreDeSecours(element){

    let id = $("#modalEditCentreDeSecours-id").val();

    let name = $("#modalEditCentreDeSecours-name").val();

    console.log(name);

    $.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: 'centre-de-secours/'+id,

    type: 'PUT',

    dataType: "json",

    data: {

    "id": id,

    "name": name,

    },

    success: function (data) {

    $("#modalEditCentreDeSecours").modal('toggle');

    $("#centredesecours-"+data.centredesecours.id+' td.name').html(data.centredesecours.name);

    console.log(data);

    },

    error: function (e) {

    $("#modalEditCentreDeSecours").modal('toggle');

    console.log(e);

    }

    });

    }

    /*
    /

    function changerole( elt, id ){

    $('#modalAskchangeRoleUser').modal('toggle');

    $('#button_confirm_role_user').attr('onclick', "changerole2('"+$( elt ).val()+"',"+id+")");

    /*$.ajaxSetup({

    headers: {

    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

    }

    });

    $.ajax({

    url: '{{ route('updateRoleUser') }}',

    type: 'POST',

    dataType: "json",

    data: {

    "id": id,

    "role": $( elt ).val()

    },

    success: function (data) {

    $('#modalAskchangeRoleUser').modal('toggle');

    var modalDelete = $('#modalConfirmChangeRole');

    modalDelete.find(".modal-body").empty();
  • Avatar de MaitrePylos
    Membre depuis :
    27/05/2013
    Messages :
    264

    C'ets long....trèsssssssssssss long.
    Maintenant ceci me pertube un peu

    @if( auth()->user()->isSuperAdmin() || $user->id == \Auth::id() || ( auth()->user()->isAdmin() && $user->role != "admin" ) )

    Donc soit :

    il est SuperAdmin
    ou
    le $user et Auth sont identique
    ou
    auth est admin , mais user n'est pas admin ...cela vous semble pas illogique, si je fais le constats que Aut et $user sont la même personnes ?

  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    Certainement...
    4 profils avec droits différents
    utilisateur
    gestionnaire
    admin
    super admin

  • Avatar de MaitrePylos
    Membre depuis :
    27/05/2013
    Messages :
    264

    ok, mais je ne peut-être l'un et l'autre en même temps

    auth()->user()->isAdmin() && $user->role != "admin"
  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    Je ne sais pas, pour le moement elle fonctionne parfaitement avec un admin et ses rroits sont respectés.
    Si je place deux admin apparemment les fonctionnalités s'enlèvent

  • Avatar de DavidTisserand
    Membre depuis :
    10/11/2018
    Messages :
    37

    peut être parce qu'il récupère à chaque fois les fonctionnalités de l'user et en plus viennent se greffer celles de l'admin

Vous ne pouvez pas répondre à ce sujet.