<?php $__env->startSection('listess'); ?>
    <style>
        .dtHorizontalVerticalExampleWrapper {
            max-width: 600px;
            margin: 0 auto;
        }

        #dtHorizontalVerticalExample th,
        td {
            white-space: nowrap;
        }

        table.dataTable thead .sorting:after,
        table.dataTable thead .sorting:before,
        table.dataTable thead .sorting_asc:after,
        table.dataTable thead .sorting_asc:before,
        table.dataTable thead .sorting_asc_disabled:after,
        table.dataTable thead .sorting_asc_disabled:before,
        table.dataTable thead .sorting_desc:after,
        table.dataTable thead .sorting_desc:before,
        table.dataTable thead .sorting_desc_disabled:after,
        table.dataTable thead .sorting_desc_disabled:before {
            bottom: .5em;
        }
    </style>
    <div class="pagetitle">
        <div class="row">
            <h1 class="col-5">Policiers dont les données à jour</h1>
            <div class="col ">

        <h1 class="col text-end">
                <a href="<?php echo e(route('admin.index')); ?>">
                    <button type="button" class="btn btn-success">Retour</button>
                </a>
            </h1>



            </div>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="<?php echo e(route('admin.index')); ?>">Listes des policiers enregistrées</a></li>
                    <li class="breadcrumb-item"><a href="#">Tableau des policiers dont les données à jour</a></li>
                </ol>
            </nav>
        </div><!-- End Page Title -->
 <div class="mb-5 mt-4 row">
            <div class="col ">
                    <div  class="text-start ">

                        <input type="checkbox" id="master"> <strong> Select All</strong>
                    </div>
            </div>
            <div class="col text-end">
               <div type="button" class=" btn bg-primary text-white  select_all " data-url=""> Télécharger toutes les cartes</div>

            </div>

        </div>

        <section class="section">
            <div class="row">
                <div class="col-lg">
                    <!--------->
                    <div class="card-body">

                        <div class="dataTable-wrapper dataTable-loading no-footer sortable searchable fixed-columns">
                            <div class="dataTable-top">
                                <div class="dataTable-dropdown"><label><select class="dataTable-selector">
                                            <option value="5">5</option>
                                            <option value="10" selected="">10</option>
                                            <option value="15">15</option>
                                            <option value="20">20</option>
                                            <option value="25">25</option>
                                           </select>Show entries</label></div>
                                                <div class="dataTable-search">
                                                <form action="#">
                                                    <div class="input-group">
                                                        <div id="search-autocomplete" class="form-outline">
                                                            <input type="search" name="search" id="form1"  class="form-control" placeholder="Search..." />
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                            </div>
                            <div class="dataTable-container">
                                <table id="dtHorizontalVerticalExample"  class="table table-striped table-bordered table-sm" cellspacing="0" width="100%">
                                    <thead>
                                        <tr>
                                            <th>select</th>
                                            <th>Matricule</th>
                                            <th>Nom</th>
                                            <th>Prenoms</th>
                                            <th>Actions</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php if(!empty($admins) && $admins->count()): ?>
                                            <?php $__currentLoopData = $admins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <tr>
                                                    <td class="text-center"> <input class="sub_chk" type="checkbox" name="" data-id="<?php echo e($admin->id); ?>"></td>
                                                    <td><?php echo e($admin->matricule); ?></td>
                                                    <td><?php echo e($admin->nom); ?></td>
                                                    <td><?php echo e($admin->prenoms); ?></td>
                                                    <td>

                                                        <div class=" d-flex grid ">
                                                            <div class="g-col-4">

                                                                    <a href="<?php echo e(route('pdfs.show', $admin->id)); ?>"
                                                                        data-tr="tr_<?php echo e($admin->id); ?>"
                                                                        data-toggle="confirmation"
                                                                        data-btn-ok-label="Delete" data-btn-ok-icon="fa fa-remove"
                                                                        data-btn-ok-class="btn btn-sm btn-danger"
                                                                        data-btn-cancel-label="Cancel"
                                                                        data-btn-cancel-icon="fa fa-chevron-circle-left"
                                                                        data-btn-cancel-class="btn btn-sm btn-default"
                                                                        data-title="Are you sure you want to delete ?"
                                                                        data-placement="left" data-singleton="true"

                                                                    >
                                                                    <button class="btn bg-success">
                                                                        <img class="pointer" src="<?php echo e(asset('assets/img/download.png')); ?>"
                                                                            alt="" srcset="">
                                                                      </button>
                                                                    </a>
                                                            </div>
                                                        </div>

                                                    </td>


                                                </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php else: ?>
                                            <tr></tr>
                                        <?php endif; ?>
                                    </tbody>
                                </table>
                            </div>
                            <div class="dataTable-bottom">
                                <div class="dataTable-info">
                                    <p class="small text-muted">
                                        <?php echo __('Showing'); ?>

                                        <span class="fw-semibold"><?php echo e($admins->firstItem()); ?></span>
                                        <?php echo __('to'); ?>

                                        <span class="fw-semibold"><?php echo e($admins->lastItem()); ?></span>
                                        <?php echo __('of'); ?>

                                        <span class="fw-semibold"><?php echo e($admins->total()); ?></span>
                                        <?php echo __('results'); ?>

                                    </p>
                                </div>
                                <nav class="dataTable-pagination">
                                    <ul class="dataTable-pagination-list">
                                        <?php echo e($admins->links()); ?>

                                    </ul>
                                </nav>
                            </div>
                        </div>
                    </div>
                    <!------->

                </div>
            </div>

            <script>
                $(document).ready(function() {
                    $('#dtHorizontalVerticalExample').DataTable({
                        "scrollX": true,
                        "scrollY":false,
                         "paging" : false,
                         "searching": false,
                         "filter": false,
                         "info":false,
                    });
                    $('.dataTables_length').addClass('bs-select');
                });

                $(document).ready(function() {
  $('#master').on('click', function(e) {
    if ($(this).is(':checked', true)) {
      $(".sub_chk").prop('checked', true);
    } else {
      $(".sub_chk").prop('checked', false);
    }
  });

  $('.select_all').on('click', function(e) {
    var allVals = [];
    $(".sub_chk:checked").each(function() {
      allVals.push($(this).attr('data-id'));
    });
    if (allVals.length <= 0) {
      alert("Please select row.");
    } else {
      var check = confirm("Are you sure you want to download these rows?");
      if (check == true) {
        // Télécharger les fichiers correspondants aux IDs cochés
        allVals.forEach(function(id) {
          fetch('<?php echo e(route('pdfs.show', '')); ?>/' + id)
            .then(function(response) {
              if (response.ok) {
                return response.blob();
              } else {
                throw new Error('Network response was not ok.');
              }
            })
            .then(function(blob) {
              // Créer un lien de téléchargement pour le fichier
              var a = document.createElement('a');
              a.href = URL.createObjectURL(blob);
              a.download = 'file-' + id + '.pdf';
              a.style.display = 'none';
              document.body.appendChild(a);
              // Télécharger le fichier
              a.click();
              // Supprimer le lien de téléchargement
              document.body.removeChild(a);
            })
            .catch(function(error) {
              console.error('Error:', error);
            });
        });
      }
    }
  });
});





            </script>

        </section>
    <?php $__env->stopSection(); ?>










<?php echo $__env->make('layouts.header-Admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /opt/lampp/htdocs/polrep/resources/views/admin/policiers_ajour.blade.php ENDPATH**/ ?>