<?php echo $__env->make('forms.fbncheader', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('forms.fdatatables', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>


<div style="background-color:rgba(30,144,255,.2);"  
    class="col-lg-max container-fluid">

<div style="padding-left:0px" class="col-lg-max">
     <div class="row" style="">   
        <div class="col-xs-1" style="padding-left:0px;">
           <?php echo Html::image("img/salaire.png", 
                "Salaires", 
                array( 'width'=>'100%',
                    "style"=>"padding:4px" )); ?> 
        </div>
        <div class="col-xs-10" style="padding-left:0px;">
            <h1 style="margin-top:2px;margin-bottom:0px">
                Salaires
            </h1>
            <h1 style="margin-top:0px;"><small><?php echo substr($employeur_nom,strpos($employeur_nom,' ')); ?></small><h1>
        </div>
    </div>
</div>

    <div class='form-group ' style="padding-bottom:20px">
        <div class="col-xs-4">    
            <?php echo Form::hidden('employeur_id2', $employeur_id, ['id'  => 'employeur_id2']); ?>

            <?php echo Form::label('employeur_nom', 'Employeur :' ); ?>

            <?php echo Form::text('employeur_nom', $employeur_nom, 
                ['placeholder' => 'Employeur', 'class' => 'form-control'
                    , 'id' => 'employeur_nom']); ?>

 
            <!-- source: "../autocomplete_employeur", -->
            <script>
                $(function() {        
                   $("#employeur_nom").autocomplete({
                        source: "<?php echo route('autocomplete_employeur'); ?>",
                        minLength: 1,
                        select: function(event, ui) {
                            var uid_=ui.item.id;
                            var value_=ui.item.value
                            if(value_=='TOUS') uid_="999999";
                            $('#employeur_nom').val(uid_+" "+(value_.trim()));
                            $('#employeur_id2').val(uid_);
                            location.href="<?php echo url('/recouvrement/salaire_annee/'); ?>/"
                                +$('#employeur_id2').val()+"/0"+"/0";
                        },
                        close: function(event, ui) {
                            
                        }
                    }); 

                });
            </script>
        </div>

        

            <div class="col-xs-2">
                <?php echo Form::label('annes', 'Année :' ); ?>

                <?php echo Form::select('exercice',$exercices,$exercice,
                    [
                        'id' => 'exercice_id','class' => 'form-control selectpicker',
                        'data-width' => "100%",'style' => 'font-weight:bold;'
                    ]
                ); ?>

                <script>
                    $(document).ready(function() {
                        $('#exercice_id').on('change', function() {
                            location.href="<?php echo url('/recouvrement/salaire_annee/'); ?>/"
                                +$('#employeur_id2').val()+"/"+$('#beneficiaire_id2').val()+"/"+$('#exercice_id').val();
                        });
                    });
                </script>
            </div>

            <?php if($employeur_id!=""): ?>
            <div class="col-xs-4">
                <?php echo Form::label('employe_nom', 'Employé :', []); ?>

                <?php echo Form::select('beneficiaire_id',$liste_employes,$beneficiaire_id,
                    [
                        'id' => 'beneficiaire_id2','class' => 'form-control selectpicker',
                        'data-width' => "100%",'style' => 'font-weight:bold;'
                    ]
                ); ?>

                <script>
                    $(document).ready(function() {
                        $('#beneficiaire_id2').on('change', function() {
                            location.href="<?php echo url('/recouvrement/salaire_annee/'); ?>/"
                                +$('#employeur_id2').val()+"/"+$('#beneficiaire_id2').val()+"/"+$('#exercice_id').val();;
                        });
                    });
                </script>
            </div>


        <?php endif; ?>


    </div>

 
    <br/><br/>


    <?php if($employeur_id!=""): ?>
        <div class="table-responsive">
            <table id="_table" style="background-color:white" class="table table-condensed table-striped table-bordered">
                <thead>
                    <tr>
                        <th width='1%'>N°</th>
                        <th >Employé</th>
                        <th width='1%'>DateNais.</th>
                        <th width='1%'>Année</th>
                        <th width='1%'>DateEnt.</th>
                        <th width='1%'>DateSor</th>
                        <?php if($employeur_nom=="TOUS"): ?>
                            <th >N°Emp.</th>
                            <th >Employeur</th>
                        <?php endif; ?>
                        
                        <th class="sum" width='5%'>Jan</th>
                        <th width='5%'>Fév</th>
                        <th width='5%'>Mar</th>
                        <th width='5%'>Avr</th>
                        <th width='5%'>Mai</th>
                        <th width='5%'>Jui</th>
                        <th width='5%'>Jui</th>
                        <th width='5%'>Aou</th>
                        <th width='5%'>Sep</th>
                        <th width='5%'>Oct</th>
                        <th width='5%'>Nov</th>
                        <th width='5%'>Déc</th>
                        <th width='5%'>Total</th>
                        <th width='1px'></th>
                    </tr>
                </thead>

                <tfoot>
                    <tr class='bg-danger'>
                        <th colspan="<?php echo ($employeur_nom=='TOUS')?'8':'6'; ?>">TOTAL</th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>
                        <th class="sum"></th>

                    </tr>
                </tfoot>
                <tfoot>
                    <tr class='bg-info'>
                        <td colspan="<?php echo ($employeur_nom=='TOUS')?'8':'6'; ?>"></td>
                        <?php $__currentLoopData = $nb_salaire; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mois=>$nb): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 
                            <td align="center" style="<?php echo ($mois=='total')?'font-weight:bold':''; ?>"><?php echo $nb; ?></td>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <td class=""></td>
                    </tr>
                </tfoot>

                <tbody>
                    <?php $__currentLoopData = $salaires; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $salaire): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo $salaire->benum; ?></td>
                        <td>
                            <a href="<?php echo url('tiers/beneficiaires/'.$salaire->benum); ?>" target='_blank'>
                                <?php echo $salaire->beneficiaire_Nom; ?>

                            </a>
                        </td>
                        <td nowrap><?php echo $salaire->BeneficiaireDateNaissance; ?></td>
                        <td nowrap align='center'><?php echo $salaire->annee; ?></td>
                        <td nowrap><?php echo $salaire->dat_ent; ?></td>
                        <td nowrap><?php echo $salaire->date_sor; ?></td>
                        <?php if($employeur_nom=="TOUS"): ?>
                            <td nowrap><?php echo str_pad($salaire->sonum, 6, "0", STR_PAD_LEFT); ?></td>
                            <td><?php echo $salaire->employeur_nom; ?></td>
                        <?php endif; ?>
                        <td nowrap align='right'><?php echo $salaire->jan; ?></td>
                        <td nowrap align='right'><?php echo $salaire->fev; ?></td>
                        <td nowrap align='right'><?php echo $salaire->mar; ?></td>
                        <td nowrap align='right'><?php echo $salaire->avr; ?></td>
                        <td nowrap align='right'><?php echo $salaire->mai; ?></td>
                        <td nowrap align='right'><?php echo $salaire->jun; ?></td>
                        <td nowrap align='right'><?php echo $salaire->jui; ?></td>
                        <td nowrap align='right'><?php echo $salaire->aou; ?></td>
                        <td nowrap align='right'><?php echo $salaire->sep; ?></td>
                        <td nowrap align='right'><?php echo $salaire->oct; ?></td>
                        <td nowrap align='right'><?php echo $salaire->nov; ?></td>
                        <td nowrap align='right'><?php echo $salaire->dec; ?></td>
                        <td nowrap align='right'><?php echo $salaire->TotalAnnee; ?></td>
                        <td nowrap>
                        <?php if($user->can("SAL_MAJ") || $user->HasRole("ADMINISTRATEUR")): ?>
                            <a href="<?php echo url('recouvrement/salaires/'.$salaire->id .'/edit'); ?>"
                                class="btn btn-info glyphicon glyphicon-pencil"></a>
                        <?php endif; ?> 
                        <?php if($user->can("SAL_AJO") || $user->HasRole("ADMINISTRATEUR")): ?>
                            <a href="<?php echo url('recouvrement/salaires/create/'.$salaire->benum.'/'.$employeur_id); ?>"
                                class="btn btn-success glyphicon glyphicon-plus"
                                ></a>
                        <?php endif; ?> 
                        <?php if( 
                            ($user->can("SAL_SUP") || $user->HasRole("ADMINISTRATEUR")) &&  
                                ( ($salaire->annee>date('Y')) 
                                    || ($salaire->annee<'1980') 
                                    ||($salaire->TotalAnnee==0))

                                ): ?>
                            <?php echo Form::open(['url' => '/recouvrement/salaires/' . $salaire->id.'/'.$employeur_id.'/'.$beneficiaire_id.'/'.$exercice, 'method' => 'DELETE']); ?>

                            <?php echo Form::submit('Supprimer', ['class' => 'btn btn-danger']); ?>

                            <?php echo Form::close(); ?>

                        <?php endif; ?> 
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                </tbody>
     
            </table>


            <table>

            </table>
        </div>

        <div class="col-lg-10" style="margin-bottom:10px"> 
            <?php if($beneficiaire_id>0): ?>       
            <div>  
                <?php if($user->can("SAL_AJO") || $user->HasRole("ADMINISTRATEUR")): ?>
                     <a href="<?php echo url('recouvrement/salaires/create/'.$beneficiaire_id.'/'.$employeur_id); ?>" 
                            class="btn btn-success">Ajouter un Salaire</a> 
                <?php endif; ?>
    

                <a href="<?php echo url('/attestation_edition/'.$beneficiaire_id.'/E/att_revenu'); ?>" 
                    class="btn btn-info" target="_blank">Attestation de déclaration</a>
                        
                <?php if($user->can("SAL_EDIT") || $user->HasRole("ADMINISTRATEUR")): ?>
                    <a href="<?php echo url('/salaire/liquidation/'.$beneficiaire_id); ?>" 
                        class="btn btn-info" target="_blank">Edition des liquidations</a>

                    <a href="<?php echo url('/salaire/liquidation_simulation/'.$beneficiaire_id); ?>" 
                        class="btn btn-warning" target="_blank">Edition d'une Simulation de liquidation</a>
                <?php endif; ?>



             </div> 
            <?php endif; ?>
        </div> 

    <?php endif; ?>
</div>

</body></html>


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

    var table =$('#_table').dataTable( {
        bAutoWidth: false,
        bPaginate: false,
        bInfo: true,
        bFilter: true,
                scrollY:        400,
                scrollX:        '100%',
                scrollCollapse: true,
                scroller:       true,

        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": '<"top"fBl>rt<"bottom"ip><"clear">',
            dom: "<'row'<'col-sm-3 text-left'f><'col-sm-4'><'col-sm-5 text-center'B>>" +
            "<'row'<'col-sm-12'tir>>" +
            "<'row'<'col-sm-5'><'col-sm-7'p>>",

            "aaSorting": [
                [1,'asc']
            ],

            buttons: [ 
                {extend: 'copy',exportOptions: {columns: ':visible'} },
                {extend: 'excel',exportOptions: {columns: ':visible'} },
                {extend: 'pdf',orientation: 'landscape',pageSize: 'A3',exportOptions: {columns: ':visible'} },
                {extend: 'print',exportOptions: {columns: ':visible'} },
                'colvis'
            ],
            

            "footerCallback": function(row, data, start, end, display) {
              var api = this.api();
                <?php if($employeur_nom=="TOUS"): ?>
                    api.columns([8,9,10,11,12,13,14,15,16,17,18,19,20], { //
                <?php else: ?>
                    api.columns([6,7,8,9,10,11,12,13,14,15,16,17,18], { //
                <?php endif; ?>
                page: 'current'
              }).every(function() {

                var sum = this
                  .data()
                  .reduce(function(a, b) {
                    var x = parseFloat(a) || 0;
                    var y = parseFloat(b) || 0;
                    return x + y;
                  }, 0);
                $(this.footer()).html(sum);
              });
            },



        } );

        $('#_table').DataTable().draw();

        $(window).resize(function () {
                    $('#_table').DataTable().draw();
        });
} );
</script>

<?php /**PATH C:\xampp7422\htdocs\sysinfo\cpswf\sipre9\resources\views/recouvrement/salaires/index.blade.php ENDPATH**/ ?>