@include('forms.fbncheader')
@include('forms.fdatatables')



<div style="background-color:rgba(34,139,34,.2);"  
    class="col-lg-max col-lg-offset-1 container-fluid">

<div style="padding-left:0px" class="col-lg-max">
     <div class="row" style="">   
        <div class="col-xs-1" style="padding-left:0px;">
           {!! Html::image("img/entreprise.png", 
                "Employeurs", 
                array( 'width'=>'100%',
                    "style"=>"padding:4px" ))
            !!} 
        </div>
        <div class="col-xs-11" style="padding-left:0px;">
            <h1 style="margin-top:2px;">
                Employeurs<small>{!! $titre2 !!}</small>
            </h1>
        </div>


        <div class="form-inline">
            <div class='col-md-6'>
                {!! Form::label('select_statut', 'Statut ') !!}
                {!! Form::select('select_statut',
                        $statuts,isset($statut)?$statut:"",
                            ['placeholder'=>'Choisir un statut','class' => 'form-control','onchange' => 'valide()']) !!} 
            </div>
            <script>
                function valide() {
                    var select_statut = [...document.getElementById('select_statut').selectedOptions].map(option => option.value);
                    if(select_statut=="") select_statut=0;

                    var url="{!! url('tiers/employeurs_statut') !!}/"+select_statut  ; 
                    location.href=url;
                }
            </script>
        </div>

    </div>
</div>

<div class='col-lg-max' style="padding-top:5px">
    <div class="table-responsive" >
        <table id="_table" style="background-color:white"  
            class="table table-condensed table-striped table-hover table-bordered">
            <thead>
                <tr>
                    <th width='1%'>N°</th>
                    <th>Nom</th>
                    <th>IBAN</th>
                    <th width='1%'>NbSalariés</th>
                    <th width='1%'>ile</th>
                    <th width='30%'>Responsable</th>
                    <th width='30%'>Email</th>
                    <th width='30%'>Tél</th>
                    <th width='30%'>Contact2</th>
                    <th width='30%'>Email2</th>
                    <th width='30%'>Tél2</th>
                    <th width='10%'>Adresse</th>
                    <th width='1%'>Secteur</th>
                    <th width='5%'>Statut</th>
                    <th width='1%'></th>
                </tr>
            </thead>
 
            <tbody>
                @foreach ($employeurs as $employeur)
                <tr>
                    <td>
                        {!! str_pad($employeur->id,4,'0',STR_PAD_LEFT) !!}
                    </td>
                    <td>
                        @if($user->can("EMP_VISU") || $user->HasRole("ADMINISTRATEUR"))
                            <a href="{!! url('/tiers/employeurs/'.$employeur->id) !!}" 
                                class="" style="margin-right: 3px;">
                        @endif

                        {!! $employeur->NomReduit !!}

                        @if($user->can("EMP_VISU") || $user->HasRole("ADMINISTRATEUR"))
                            </a>
                        @endif 
                    </td>
                    <td>{!! $employeur->iban !!}</td>
                    <td>{!! $employeur->Nbemployes !!}</td>
                    <td>{!! $employeur->ile !!}</td>
                    <td>{!! (strlen($employeur->responsable)>20)?substr($employeur->responsable,0,20):$employeur->responsable !!}</td>
                    <td>{!! $employeur->tel !!}</td>
                    <td>{!! $employeur->email !!}</td>
                    <td>{!! (strlen($employeur->contact_nom)>20)?substr($employeur->contact_nom,0,20):$employeur->contact_nom !!}</td>
                    <td>{!! $employeur->tel !!}</td>
                    <td>{!! $employeur->email !!}</td>
                    <td>{!! $employeur->AdresseComplete !!}</td>
                    <td>{!! $employeur->secteur !!}</td>
                    <td>{!! $employeur->statut !!}</td>
                    <td>
                    @if($user->can("EMP_SUP")&&($employeur->Nbemployes==0)&&($employeur->statut=="TER"))      
                            {!! Form::open(['url' => '/tiers/employeurs/' . $employeur->id, 'method' => 'DELETE']) !!}
                    @endif 
                    @if($user->can("EMP_MAJ") || $user->HasRole("ADMINISTRATEUR"))
                        <a href="{!! url('tiers/employeurs/'.$employeur->id) !!}/edit" class="btn btn-info pull-left" style="margin-right: 3px;">Modifier</a>
                    @endif 
                    @if($user->can("EMP_SUP")&&($employeur->Nbemployes==0)&&($employeur->statut=="TER"))      
                            {!! Form::submit('Supprimer', ['class' => 'btn btn-danger'])!!}
                            {!! Form::close() !!}
                    @endif 
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
        @if($user->can("EMP_VISU") || $user->HasRole("ADMINISTRATEUR"))
            <script>
            jQuery(document).ready(function($) {
                $(".clickable-row").click(function() {
                    window.document.location = $(this).data("href");
                });
            });
            </script>
        @endif
    </div>
@if($user->can("EMP_AJO") || $user->HasRole("ADMINISTRATEUR"))
     <div>
        <h4><a href="./employeurs/create" class="btn btn-success">Ajouter un Employeur</a></h4>
    </div> 
@endif
</div>
</div>

</body></html>



<script>
$(document).ready(function() {
   $.fn.dataTable.moment('D/M/YYYY');

    var table =$('#_table').dataTable( {
        bAutoWidth: false,
        bPaginate: true,
        bInfo: true,
        bFilter: true,

        deferRender:    true,
        scrollCollapse: false,
        scroller:       false,

        iDisplayLength:10,
        oLanguage: {
            "sZeroRecords": "Aucune ligne",
            "sInfo": "Affichage de _START_ &agrave; _END_ sur _TOTAL_ lignes",
            "sInfoEmpty": "Showing 0 to 0 of 0 records",
            "sInfoFiltered": "(sur un total de _MAX_ lignes)",
            "oPaginate": {"sPrevious": "Pr&eacute;c&eacute;dente","sNext": "Suivante"
                ,"sFirst": "Premi&egrave;re","sLast": "Derni&egrave;re"},
                "sSearch":"Chercher ",
            buttons: {
                colvis: 'Colonnes à afficher',
                copy: 'Copier',
                print: 'Imprimer',
                copyTitle: 'Ajouté au presse-papiers',
                copyKeys: 'Appuyez sur <i>ctrl</i> ou <i>\u2318</i> + <i>C</i> pour copier les données du tableau à votre presse-papiers. <br><br>Pour annuler, cliquez sur ce message ou appuyez sur Echap.',
                copySuccess: {
                    _: '%d lignes copiées',
                    1: '1 ligne copiée'
                }
            }

            },
            dom: "<'row'<'col-sm-8 text-left'f><'col-sm-4 text-right'B>>" +
            "<'row'<'col-sm-12'tr>>" +
            "<'row'<'col-sm-5'i><'col-sm-7'p>>",

            buttons: [ 
                {extend: 'copy',exportOptions: {columns: ':visible'} },
                {extend: 'excel',exportOptions: {columns: ':visible'} },
                'colvis'
            ],
            


            "aoColumnDefs": [
                { visible: false, targets: [6,7,8,9,10,11] },
            ],



        } );


     yadcf.init(table, [
        {column_number : 1, filter_default_label: "Tous"},
        {column_number : 5, filter_default_label: "Tous"},  
    ]);



} );
</script>

@section('sort')

@stop


