<?php $__env->startSection('title', 'List Data Value'); ?>

<?php $__env->startSection('content'); ?>
<style>
    /* Custom style for pagination links */
    .pagination {
        margin: 0; /* Remove default margin */
        padding: 0; /* Remove default padding */
        list-style: none; /* Remove list bullet points */
        display: flex; /* Use flex layout for horizontal alignment */
    }

    .pagination li a {
        padding:6px;
    }

    .pagination a {
        display: inline-block;
        padding: 0; /* Adjust the padding as needed */
        text-decoration: none;
        background-color: #f0f0f0;
        border: 1px solid #ccc;
        color: #333;
        transition: background-color 0.3s ease, color 0.3s ease;
    }

    .pagination a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .pagination .active a {
        background-color: #007bff;
        color: #fff;
    }
</style>
<!-- Main content -->
        <section class="content">

      <div class="row">

      <?php
        
        if (!empty($list_details->list_data)) {
      
          $url = request()->url(); 
        if($page == 1)
        {
            $currentPage = 1;
        }

        else
        {
            $currentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
        }

        $perPage = $show;
        $paginator = new Illuminate\Pagination\LengthAwarePaginator($list_details->list_data, $record_count, $perPage, $currentPage, ['path' => url($url)]);
    ?>

<?php if(session('error')): ?>
    <div class="alert alert-danger">
        <?php echo e(session('error')); ?>

    </div>
<?php endif; ?>

        <div class="col-12">
          <div class="box">
           <div class="box-body">   
         
      
                 
              <h4 class="box-title text-info mb-0"><i class="fa fa-user fa-sx"></i> List Data for <?php echo e($list_name); ?></h4>   
              <a href="/list" id="openListForm"  style="float:right" class="waves-effect waves-light btn btn-rounded btn-primary btn-bitbucket btn-sm mb-5"><i class="fa fa-eye"></i>View List</a>
              <form method="GET" action=" "style="display: inline;">
    <input type="hidden" name="submit_download" value="excel">
    <input type="hidden" name="search" value="<?php echo e($searchTerm); ?>">
    <input type="hidden" name="show" value="<?php echo e($show); ?>">
    <button type="submit" id="submit" style="float:right;margin-right:10px;" class="waves-effect waves-light btn btn-rounded btn-primary btn-bitbucket btn-sm mb-5">
        <i class="fa fa-download"></i> Download
    </button>
</form>

           <hr class="my-15">
           <div style="display:flex; justify-content:space-between; align-items:center;">
           <form action="<?php echo e(url()->current()); ?>" method="get" id="listForm">
    <input type="hidden" name="search" value="<?php echo e($searchTerm); ?>">
              <label class="label-class" for="show">Show:
              <select id="show" class="form-select form-control-sm" name="show"style="width:75px;display:inline-block;">
                  <option value="10" <?php echo e(request('show') == 10 ? 'selected' : ''); ?>>10</option>
                  <option value="25" <?php echo e(request('show') == 25 ? 'selected' : ''); ?>>25</option>
                  <option value="50" <?php echo e(request('show') == 50 ? 'selected' : ''); ?>>50</option>
                  <option value="100" <?php echo e(request('show') == 100 ? 'selected' : ''); ?>>100</option>
              </select>
              </label>
              <label for="show">entries</label>
          </form>
          
                    <form action="<?php echo e(url()->current()); ?>" method="get" style="margin:0; display:flex; align-items:center;">
                     <label class="form-label" style="margin:0 10px 0 0;">Search:</label>
                     <input type="text" value="<?php echo e($searchTerm); ?>" class="form-control form-control-sm" name="search" id="search" placeholder="" style="width:auto; padding:5px 30px 5px 15px;">
                    <input type="hidden" name="show" value="<?php echo e(request('show', 10)); ?>">
             
                    </form>
                    </div>
                
                    <b>Total Rows :<?= $record_count ?></b>

              <div class="table-responsive">
                <table  class="table mt-0 table-hover no-wrap">
                  <thead>
                    <tr>
                                    <th>#</th>
                                     <?php $__currentLoopData = $list_details->list_header; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $header): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <th><?php echo e($header); ?></th>
                                                                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                            </tr>
                  </thead>
                  <?php if(!empty($list_details)): ?>
                            <tbody>

                                <?php $__currentLoopData = $list_details->list_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $live): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td><?php echo e(($paginator->currentPage() - 1) * $paginator->perPage() + $key + 1); ?></td>
                                  <?php $__currentLoopData = $list_details->list_header; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $header): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php
                                        $fieldName = 'option_' . ($loop->index + 1); // Assuming headers start from 1
                                    ?>

                                    <td>
                                        <?php if(isset($live->$fieldName) && !empty($live->$fieldName)): ?>
                                            <?php echo e($live->$fieldName); ?>

                                        <?php else: ?>
                                            <!-- Show empty cell if no data is available -->
                                        <?php endif; ?>
                                    </td>
                                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                </tr>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                            <?php endif; ?>
                            <?php } ?>
                </table>
                <div style="float:right;">
                
                        <!-- <?php echo e($paginator->appends(Request::all())->links()); ?> -->

<!-- Pagination links with search parameter -->
<!-- <?php echo e($paginator->appends(['show' => $paginator->perPage(), 'search' => $searchTerm])->links()); ?> -->
 <?php echo e($paginator->appends(Request::all())->links('pagination::bootstrap-5')); ?>

 


                                                            </div>
              </div>
            </div>
          </div>
        </div>
 
      </div>
      <!-- /.row -->

    </section>
        <!-- /.content -->

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var selectElement = document.getElementById('show');
    var searchInput = document.getElementById('search');
    var listForm = document.getElementById('listForm');

    selectElement.addEventListener('change', function() {
        listForm.action = updateActionWithSearch(listForm.action, searchInput.value);
        listForm.submit();
    });

    function updateActionWithSearch(action, searchTerm) {
        var url = new URL(action);
        url.searchParams.set('search', searchTerm);
        return url.toString();
    }
});

  </script>

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var selectElement = document.getElementById('submit');

    selectElement.addEventListener('click', function() {
        this.form.submit();
    });
});

  </script>

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/leadmine/leadmine_pro/resources/views/lists/lists-view.blade.php ENDPATH**/ ?>