<?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(); ?>

        

<?php echo Form::hidden('checklist','',['id'=>'checklist']); ?>

<div style="background-color:rgba(46,139,87,.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;">
               <?php echo Html::image("img/journal.png", "Mandatements", array( 'width'=>'100%',"style"=>"padding:4px" )); ?> 
            </div>
            <div class="col-xs-10" style="padding-left:0px;">
                <h1><i class="fa fa-plan"></i>Liste des Journaux
                <?php if($exercice_encours!=$exercice): ?>
                <small>Historique Non modififable</small>
                <?php endif; ?>
                </h1>
            </div>

            <div class="col-xs-2">
                <?php echo Form::select('exercice',$exercices,$exercice,
                    ['id' => 'exercice','class' => 'form-control selectpicker',
                        'data-width' => "50%",'style' => 'background-color:lightgrey;font-weight:bold;'
                    ]
                ); ?>

                <script>
                    $(document).ready(function() {
                        $('#exercice').on('change', function() {
                            location.href="<?php echo url('compta/journal_exercice/'); ?>"+"/"+$('#exercice').val();
                        });
                    });
                </script>
            </div>

        </div>

    </div>

 <div style="padding-left:0px" class="col-lg-max">
    <div class="row">&nbsp;
    </div>
</div>


    <div class=' col-lg-max' style="padding-top:5px">
        <div class="alert" style="padding-top:0px">
        <table id="_table" style="background-color:white" class="table table-condensed table-striped table-bordered">
            <thead>
                <tr>
                    <th nowrap width='1%'></th>
                    <th nowrap width='1%'>N°Journal</th>
                    <th width='1%' >Date</th>
                    <th nowrap width='1%'>N°Compte</th>
                    <th width='1%'>Référence</th>
                    <th>Libelle</th>
                    <th width='5%'>Débit</th>
                    <th width='5%'>Crédit</th>
                    <th width='1%'>Enc</th>
                    <th width='1%'>
                        <?php if($user->can("JOU_AJO") || $user->HasRole("ADMINISTRATEUR")): ?>
                         <div>
                            <a href="<?php echo url('/compta/journal/create'); ?>" class="btn btn-success">
                                Ajouter une écriture</a>
                            <a href="#" class="btn btn-success" id='bt_compenser' disabled onclick='compenser();return;'>
                                Compenser la sélection</a>
                        </div> 
                        <?php endif; ?>
                    </th>
                </tr>
            </thead>
 

            <tbody>
                <?php $total=["debit"=>0,"credit"=>0]; ?>
                <?php $__currentLoopData = $journaux; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $journal): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                    $total["debit"]+=$journal->debit;
                    $total["credit"]+=$journal->credit;
                ?>
                <tr>
                    <td align="center" style="color:grey;padding:0px;margin:0px">
                        <?php if($journal->IsCompensable): ?>
                        <?php echo Form::checkbox('box_'.$journal->id, '1',false
                        , ['id'=>'box_'.$journal->id,'onclick'=>"check($journal->id)"]); ?>

                        <?php endif; ?>
                    </td>
                    <td style="color:grey;font-style:italic"><?php echo $journal->id; ?></td>
                    <td align="center"><?php echo $journal->date; ?></td>
                    <td align="center"><?php echo $journal->numcpt; ?></td>
                    <td nowrap><?php echo $journal->ref; ?></td>
                    <td><?php echo $journal->libelle; ?></td>
                    <td nowrap align="right" style="color:darkred;font-weight:bold"><?php echo number_format($journal->debit,0,","," "); ?></td>
                    <td nowrap align="right" style="color:darkblue;font-weight:bold"><?php echo number_format($journal->credit,0,","," "); ?></td>
                    <td nowrap align="right"><?php echo $journal->enc; ?></td>
                    
                    <td nowrap>
                    
                    <!--
                        <?php if($user->can("JOU_MAJ") || $user->HasRole("ADMINISTRATEUR")): ?>
                            <a href="<?php echo url('/compta/journal').'/'.$journal->id.'/edit'; ?>" class="btn btn-info pull-left" style="margin-right: 3px;">Modifier</a>
                        <?php endif; ?> 
                        <?php if($user->can("JOU_SUP") || $user->HasRole("ADMINISTRATEUR")): ?>   
                            <?php echo Form::open(['url' => '/compta/journal/' . $journal->id, '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>
        </div>

  
    </div>


</div>


</body></html>



<script>
    //$("#bt_compenser").hide();

    //Complete la liste des boites cochées
    function check(id) {
        var list=$("#checklist").val();
        if($("#box_"+id).prop('checked')) {
            var value=id+"~";
            if(list.indexOf(id+"~")==-1) {
                $("#checklist").val(list+value);
            }
        } else {
            var pos=list.split("~");
            var new_list="";
            for(var i=0;i<pos.length;i++) {
                if((pos[i]!=id)&&(pos[i]!="")) new_list+=pos[i]+"~";
            }
            $("#checklist").val(new_list);
        }
        var list=$("#checklist").val();
        if(list=="") $("#bt_compenser").attr('disabled','disabled');   
        else $("#bt_compenser").removeAttr('disabled'); 
    }

     function compenser(id) {
        var list=$("#checklist").val();
        if(list=="") return;
        var url="<?php echo url('/compta/journal_compense'); ?>"+"/"+list;
        $.fancybox.open({ 
            'autoScale': true,
            'href': url, 
            'type': 'ajax',
            'width': '70%',
            'height': '70%',
            'autoSize': false,
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'elastic',
            'speedIn': 500,
            'speedOut': 300,
            'autoDimensions': false,
            'centerOnScroll': true,

           afterClose: function () { // USE THIS IT IS YOUR ANSWER THE KEY WORD IS "afterClose"
                parent.location.reload(true);
            }
        });
        //$.fancybox.open(paramsFancy);

        //window.open(url,'_blank');
        //box_versement fancybox.iframe
        return;
    }



</script>


<script>


$(document).ready(function() {

$.fn.dataTable.moment('D/M/YYYY');

    var table =$('#_table').dataTable( {
        bAutoWidth: false,
        bPaginate: false,
        bInfo: true,
        bFilter: true,
        deferRender:    true,
        scrollY:        500,
        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",
            "decimal": ",",
            "thousands": " ",

            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'
                }
            }

            },

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

            "aoColumnDefs": [
                { "sTypes": "numeric", "aTargets": [ 3 ] },
                { bSortable: false, aTargets: [9] },
            ],


            dom: "<'row'<'col-sm-4 text-left'f><'col-sm-4'><'col-sm-6 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'} },
                {extend: 'pdf',exportOptions: {columns: ':visible'} },
                {extend: 'print',exportOptions: {columns: ':visible'} },
                'colvis'
            ],

        } );

} );
</script><?php /**PATH C:\xampp\htdocs\SYSINFO\cpswf\sipre\resources\views/compta/journal/index.blade.php ENDPATH**/ ?>