
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js"></script>
            <!-- TOP Nav Bar END -->
            <div class="container-fluid">
               <div class="row">
                  <div class="col-sm-12">
                     <div class="iq-card">
                        <div class="iq-card-header d-flex justify-content-between">
                           <div class="iq-header-title">
                              <h4 class="card-title">Users List</h4>
                           </div>
                              <span class="table-add float-right mb-3 mr-2">
                             
                              <a href="<?php echo base_url(); ?>users/add" class="btn btn-sm iq-bg-success"><i
                                 class="ri-add-fill"><span class="pl-1">Add New</span></i>
                              </a>
                              </span>
                        </div>
                        <div class="iq-card-body">
                           <div id="table" class="table-editable">
                              
                               <table id="myTable" class="display table" style="width:100%">
              <thead>
                <tr>
                  <th>SL. No.</th>
                  <th>User Name</th>
                  <th>Email ID</th> 
                  <th>Mobile Number</th>     
                  <th>Role</th>               
                  <th>Status</th>                
                  <th>Action</th>
                </tr>
              </thead>
              <tbody>
                <?php  
                $start=0;
                for($i=0;$i<count($recordSet);$i++)
                   { $start++;
                ?>
                <tr class="trBack">
                  <td scope="row"><?php echo $start; ?></td>
                  <td><?php echo $recordSet[$i]['fullname']; ?></td>
                  <td><?php echo $recordSet[$i]['email']; ?></td>
                  <td><?php echo $recordSet[$i]['mobile_no']; ?></td>
                  <td><?php if($recordSet[$i]['role_id']==1){ echo 'Super Admin'; } else if($recordSet[$i]['role_id']==2){ echo 'Reservation Admin'; } else{ echo 'None'; } ?></td>
                  <td><?php if($recordSet[$i]['role_id']!=1){ ?><button type="button" class="btn <?php if($recordSet[$i]['login_status']=='1'){ ?> btn-success <?php } else { ?> btn-danger <?php } ?> btn-xs" onclick="status_change(<?php echo  $recordSet[$i]['admin_id']; ?>,<?php echo  $recordSet[$i]['login_status']; ?>);"><?php if($recordSet[$i]['login_status']=='1'){ ?> Active <?php } else { ?> Inactive <?php } ?></button><?php } ?></td>


                  <td><?php if($recordSet[$i]['role_id']!=1){ ?><a href="javascript:void(0)" onclick="delete_function(<?php echo $recordSet[$i]['admin_id']; ?>);" class="delete remScnt" title="Delete"><i class="fa fa-trash" style="color:red;" aria-hidden="true" title="Delete"></i> </a><?php } ?></td>
                </tr>

              <?php } ?>
              </tbody>
            </table>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
            <!-- Footer -->
      

<style type="text/css">
  table.dataTable thead .sorting, 
table.dataTable thead .sorting_asc, 
table.dataTable thead .sorting_desc {
    background : none;
}
</style>
<script type="text/javascript">
  function delete_function(id) {

$.confirm({
    title: 'Delete!',
    content: 'Are you want to delete this data?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>users/Delete/",
          data: {id : id }, 
          success: function(html) {
            $.alert("Your data has been successfully deleted");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}

function status_change(id,status){
if (status=='1') {
  var new_status='0';
$.confirm({
    title: 'Change Status!',
    content: 'Are you want to inactive?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>users/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });



}
else {
  var new_status='1';

$.confirm({
    title: 'Change Status!',
    content: 'Are you want to active?',
    type: 'green',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-green',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>users/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}
}
</script>
