<?php $__env->startSection('title','E-SHOP || All Leads'); ?>
<?php $__env->startSection('main-content'); ?>
 <!-- DataTales Example -->
 <div class="card shadow mb-4">
     <div class="row">
         <div class="col-md-12">
            <?php echo $__env->make('backend.layouts.notification', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
         </div>
     </div>
     <?php if(auth()->user()->role == 'admin'): ?>
     <div class="card-header row d-flex justify-content-end">
         <div class="col-lg-8">
             <form method="post" action="<?php echo e(route('leads.deleteAllTest')); ?>" class="leaForm d-flex">
                 <?php echo csrf_field(); ?>
                 <input type="text" name="delete_words" required class="form-control" placeholder="Enter comma separated words here to delete from all leads. eg: test,mailinator" >
                 <button type="submit" class="btn btn-primary btn-sm float-right mx-2" data-toggle="tooltip"
                     data-placement="bottom" title="delete test leads"><i class="fas fa-plus"></i> Deleta All Test Leads</a>
             </form>
         </div>
     </div>
     <?php endif; ?>
     
    <div class="card-header py-3">
      <h6 class="m-0 font-weight-bold text-primary float-left">Leads List</h6>
      <a href="<?php echo e(route('leads.create')); ?>" class="btn btn-primary btn-sm float-right" data-toggle="tooltip" data-placement="bottom" title="Add nft"><i class="fas fa-plus"></i> Add Lead</a>
    </div>
    <div class="card-body">
      <div class="table-responsive">
        <?php if(count($leads)>0): ?>
        <table class="table table-bordered" id="lead-dataTable" width="100%" cellspacing="0">
          <thead>
            <tr>
              <th>Action</th>
              <th>S.N.</th>
              <th>Name</th>
              <th>Email</th>
              <th>Phone</th>
              <th>IP</th>
              <th>City</th>
              <th>Region</th>
              <th>Country</th>
              <th>URL</th>
              <th>Created At</th>
            </tr>
          </thead>
          <tfoot>
            <tr>
              <th>Action</th>
              <th>S.N.</th>
              <th>Name</th>
              <th>Email</th>
              <th>Phone</th>
              <th>IP</th>
              <th>City</th>
              <th>Region</th>
              <th>Country</th>
              <th>URL</th>
              <th>Created At</th>
            </tr>
          </tfoot>
          <tbody>
            <?php $__currentLoopData = $leads; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lead): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>   
                <tr>
                    <td>
                        <a href="<?php echo e(route('leads.show',$lead->id)); ?>" class="btn btn-warning btn-sm float-left mr-1" style="height:30px; width:30px;border-radius:50%" data-toggle="tooltip" title="view" data-placement="bottom"><i class="fas fa-eye"></i></a>
                      <?php if(auth()->user()->role == 'admin'): ?>
                        <a href="<?php echo e(route('leads.edit',$lead->id)); ?>" class="btn btn-success btn-sm float-left mr-1" style="height:30px; width:30px;border-radius:50%" data-toggle="tooltip" title="edit" data-placement="bottom"><i class="fas fa-pen"></i></a>
                        <form method="POST" action="<?php echo e(route('leads.destroy',[$lead->id])); ?>">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('delete'); ?>
                            <button class="btn btn-danger btn-sm dltBtn" data-id=<?php echo e($lead->id); ?> style="height:30px; width:30px;border-radius:50%" data-toggle="tooltip" data-placement="bottom" title="Delete"><i class="fas fa-trash-alt"></i></button>
                        </form>
                      <?php endif; ?>
                    </td>
                    <td><?php echo e($lead->id); ?></td>
                    <td><?php echo e($lead->name); ?></td>
                    <td><?php echo e($lead->email); ?></td>
                    <td><?php echo e($lead->phone); ?></td>
                    <td><?php echo e($lead->ip); ?></td>
                    <td><?php echo e($lead->city); ?></td>
                    <td><?php echo e($lead->region); ?></td>
                    <td><?php echo e($lead->country); ?></td>
                    <td style="max-width: 250px">
                      <p style="-webkit-box-orient: vertical; display: -webkit-box !important; overflow: hidden; -webkit-line-clamp: 5;">
                        <?php echo e($lead->url); ?>

                      </p>
                    </td> 
                    <td><?php echo e(date('d M Y', strtotime($lead->created_at))); ?></td>
                    

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

        <div class="justify-content-center d-flex">
        <?php echo e($leads->links()); ?>

        </div>

        <?php else: ?>
          <h6 class="text-center">No leads found!!!</h6>
        <?php endif; ?>
      </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('styles'); ?>
  <link href="<?php echo e(asset('backend/vendor/datatables/dataTables.bootstrap4.min.css')); ?>" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css" />
<?php $__env->stopPush(); ?>

<?php $__env->startPush('scripts'); ?>

  <!-- Page level plugins -->
  <script src="<?php echo e(asset('backend/vendor/datatables/jquery.dataTables.min.js')); ?>"></script>
  <script src="<?php echo e(asset('backend/vendor/datatables/dataTables.bootstrap4.min.js')); ?>"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>

  <!-- Page level custom scripts -->
  <script src="<?php echo e(asset('backend/js/demo/datatables-demo.js')); ?>"></script>
  <script>
    $('#lead-dataTable').DataTable( {
      "paging": false,
      "columnDefs":[
          {
              "orderable":true,
              "orderBy":"desc",
              "targets":[0]
          },
      ],
      "order":[[0,"desc"]]
    });
  </script>
  <script>
      $(document).ready(function(){
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
          $('.dltBtn').click(function(e){
            var form=$(this).closest('form');
              var dataID=$(this).data('id');
              // alert(dataID);
              e.preventDefault();
              swal({
                    title: "Are you sure?",
                    text: "Once deleted, you will not be able to recover this data!",
                    icon: "warning",
                    buttons: true,
                    dangerMode: true,
                })
                .then((willDelete) => {
                    if (willDelete) {
                       form.submit();
                    } else {
                        swal("Your data is safe!");
                    }
                });
          })
      })
  </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/amzpubli/admin.amzpublicationwing.com/resources/views/backend/leads/index.blade.php ENDPATH**/ ?>