  <div class="main-content">



   <div class="page-content">

     <div class="container-fluid">



       <div class="row">



         <div class="col-lg-12 table-responsive">

          <div class="card">

           <div class="card-body ">    

            <h4 class="mt-0 header-title m-b-30">All Users</h4>
<div class="alert alert-primary">
            <?php  if($this->session->flashdata('response')) {

             echo $this->session->flashdata('response');

           } ?>
</div>

<form action="<?= site_url('Admin/bulk_delete'); ?>" method="post">
   <button type="submit" class="btn btn-danger btn-sm">Delete Selected</button>
   <br><br>
          <table id="datatable" class="table table-striped table-bordered ">

             <thead class=" text-primary">
                  <th><input type="checkbox" id="select_all"></th>
                  <th>Sr No.</th>

                 <th>

            Register Date

          </th>

          

          <th>

            Email

          </th>

           <th>

            Username

          </th>

           <th>

            Balance

          </th>

          <th>

            Referral Id

          </th>

          <th>

            Name

          </th>

          <th>

            Phone Number

          </th>
          
          <th>

           IP Address

          </th>
          <th>Status</th>
          <th>Send Email</th>

          <th>Action</th> 

          

          

        </thead>
            <tbody>

          <?php

          if($data["users"]) {

          foreach ($data['users'] as $key => $user) { ?>

            <tr>
                <td><input type="checkbox" class="user_checkbox" name="user_ids[]" value="<?= $user['id']; ?>"></td>
                <td>

                    <?= $key+1;?>

                </td>

                <td>

                <?= Helpers::date($user["created_date"]); ?>


              </td>

               <td>

                <?= $user["email"]; ?>

              </td>

               <td>

                <?= $user["username"]; ?>

              </td>

               <td>

                <?= MemberHelper::user_wallet($user["id"]); ?>

              </td>

               <td>

                <?= $user["referral_id"]; ?>

                

              </td>

              <td><a href="<?= Helpers::adminLink('edit_user').'/'.$user["id"]; ?>">

                <?= $user["full_name"]; ?>

              </td>

             

              <td>

                <?= $user["phone_number"]; ?>

                

              </td>

               <td>

                <?= $user["ip"]; ?>

                

              </td>
          <td>
  <span class="badge <?= $user['status'] == 1 ? 'badge-success' : 'badge-danger'; ?>">
    <?= $user['status'] == 1 ? 'Verified' : 'Unverified'; ?>
  </span>
</td>
<td>
            <a href="<?= base_url('Admin/new_email/') . $user["id"]; ?>" class="btn btn-danger btn-sm" style="margin-bottom:10px;">Registered Users</a>
            <a href="<?= base_url('Admin/welcome_email/') . $user["id"]; ?>" class="btn btn-danger btn-sm">Unregistered Users</a>
          </td>

             <td>
            <a href="<?= base_url('Admin/delete_user/') . $user["id"]; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this user?');">Delete</a>
          </td>

              

            </tr>

          <?php } } ?>

            

          </tr>

        </tbody>
      

              </table> 

               </form>


            </div>

          </div>



        </div>



      </div>

    </div>

  </div>

  <script>
        document.getElementById('select_all').addEventListener('change', function() {
            let checkboxes = document.querySelectorAll('.user_checkbox');
            checkboxes.forEach(checkbox => checkbox.checked = this.checked);
        });
    </script>