<?php //print_r($usertype);exit; ?>
    <section class="content-header">
      <h1>
        <?php if($this->uri->segment(3)=='expiredusers'){ echo 'Expired';} ?> Members
      </h1>
      <ol class="breadcrumb">
        <li><a href="<?php echo base_url().'admin';?>"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">List</li>
      </ol>
    </section>

    <section class="content">
      <div class="row">
        <?php echo $this->utility->showMsg();?>
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">Management</h3>
              <?php if(chkWritePermission('All_Members',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' ){ ?>
              <?php if($this->uri->segment(3)!='expiredusers'){ ?>
                <a class="btn btn-primary margin-right pull-right" href="<?php echo base_url()?>admin/users/add">Add</a>
			        <?php } ?>
              <?php } ?>
              </div>
               
              <div></div>
            <!-- /.box-header -->
            <div class="box-body">
            <form action="" id="search_frm" method="post" style="margin-bottom: 5%;">
              <input type="text" name="search" class="form-control" placeholder="Search by email" value="<?php if($this->input->post('search')) { echo $this->input->post('search'); }?>" style="width: 25%; float: right;">
              <input type="text" name="search_name" class="form-control" placeholder="Search by pseudonym" value="<?php if($this->input->post('search_name')) { echo $this->input->post('search_name'); }?>" style="width: 25%; float: right;">
              <input type="text" name="search_id" class="form-control" placeholder="Search by ID" value="<?php if($this->input->post('search_id')) { echo $this->input->post('search_id'); }?>" style="width: 25%; float: right;">
              <input type="submit" class="btn btn-primary" value="Search" style="float: right;">
            </form>
            <div class="table-responsive">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>#</th>
                  <?php if(chkWritePermission('All_Members',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' || $this->session->userdata('admin_id')=='25267'){ ?>
                  <th>Action</th>
                  <?php } ?>
                  <?php if($this->session->userdata('admin_id')=='19624'  || $this->session->userdata('admin_id')=='25267'){ ?>
                  <th>Email</th>
                  <?php } ?>
                  <th>Pseudonym</th>
                  <th>Registered</th>
                  <th>Last Login</th>
                  <th>Account Type</th>
                  <th>User Status</th>
                  <th>Email Status</th>
                  <th>Other Status</th>
                  <th>Came from</th>
                  <th>Campaign ID</th>
                  <th>IP Address</th>
                  <th>Delete Date</th>
                  <!--<th>Reject Reason</th>-->
                  
                </tr>
                </thead>
                 <?php if(count($users)>0)
                {?>
                <tbody>
               <?php
                $i=1;
                foreach ($users as $data) 
                {
                ?>
                <tr>
                    <td><?php echo $i; ?></td>
                    <?php if(chkWritePermission('All_Members',$this->session->userdata('admin_id'))!=0 || $this->session->userdata('admin_id')=='19624' || $this->session->userdata('admin_id')=='25267'){ ?>
                    <td>
                      <a href="<?php echo base_url();?>admin/users/edit/<?php echo base64_encode($data['id']);?>" title="Edit"><span class="fa fa-pencil-square"></span></a>
                      <a href="<?php echo base_url();?>admin/users/direct_message/<?php echo base64_encode($data['id']);?>" title="Instant Message"><span class="fa fa-envelope"></span></a>
                      </td> 
                    <?php } ?>
                    <?php if($this->session->userdata('admin_id')=='19624'  || $this->session->userdata('admin_id')=='25267'){ ?>
                    <td><?php echo $data['email']; ?></td>
                    <?php } ?>
                    <td><?php echo $data['username']; ?> 
                      &nbsp; &nbsp; 
                      <?php if($data['reality_authenticated'] == 1 && $data['accounttype']=='lady') { ?>
                      <span class="fa fa-street-view" style="color:#b3975b"></span>
                      <?php } ?>
                    </td>
                    <td><?php echo date('d-m-Y h:i:s',$data['created']);?></td>
                    <td><?php if($data['last_login'] > 0) { echo date('d-m-Y h:i:s',$data['last_login']);} ?></td>
                    <td><?php echo $data['accounttype'];?></td>
                    <td><?php if($data['email_confirmed'] == 1) { echo 'Active'; } elseif($data['email_confirmed'] ==0 ) { echo 'Email not confirmed'; } else { echo 'Inactive'; }?></td>
                    <td><?php echo $data['email_status']; ?></td>
                    <td><?php if($data['free_member']==1) { echo 'Free membership'; } else { echo $data['membership']; } ?></td>
                    <td><?php if($data['came_from'] == 1) { echo 'Google Adwords'; } elseif($data['came_from'] ==2 ) { echo 'Facebook Adwords'; } else { echo 'Normal'; }?></td>
                    <td><?php echo $data['campaign_id']; ?></td>
                    <td><?php echo $data['ip_address']; ?></td>
                    <td><?php if($data['delete_date'] != '') { echo date('d-m-Y',strtotime($data['delete_date'])); } ?></td>
                    <!--<td><?php echo $data['reject_reason']; ?></td>-->
                    
                </tr>

               <?php $i++; } ?>

                </tbody>
                <?php } ?>
                <tfoot>
               
                </tfoot>
              </table>
            </div>
              <?php if($this->uri->segment(3)!='expiredusers'){ ?>
                <div class="custom_pagination"><?php echo $link; ?></div>
              <?php } ?>  
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update Number</h4>
      </div>
      <div class="modal-body">
        <form action="<?php echo base_url().'admin/users/update_number'; ?>" method="post">
            <div class="box-body">
              <div class="form-group">
                <label class="col-sm-2 control-label">Mobile Number</label>
                <div class="col-sm-6">
                <input type="tel" id="mobile_number" name="mobile_number" class="form-control" placeholder="Enter Mobile" value="">
                <input name="user_id" id="user_id" class="form-control" placeholder="Enter Mobile" value="" style="" type="hidden">
                </div>
              </div>
          </div>
          <div class="text-center">
            <input type="submit" class="btn btn-info " value="Update" id="add">
          </div>
            
        </form>
      </div>
      
    </div>

  </div>
</div>


<div id="myModal1" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Enter Delete Date</h4>
      </div>
      <div class="modal-body">
        <form action="<?php echo base_url().'admin/users/add_delete_date'; ?>" method="post">
            <div class="box-body">
              <div class="form-group">
                <label class="col-sm-2 control-label">Delete Date</label>
                <div class="col-sm-6">
                <input type="text" id="delete_date" name="delete_date" class="form-control" placeholder="Enter Delete Date" value="">
                <input name="delete_user_id" id="delete_user_id" class="form-control" type="hidden">
                <input name="uri" id="" class="form-control" type="hidden" value="<?php echo str_replace('/','-',uri_string()); ?>">
                </div>
              </div>
          </div>
          <div class="text-center">
            <input type="submit" class="btn btn-info " value="Add" id="add">
          </div>
            
        </form>
      </div>
      
    </div>

  </div>
</div>

    <style type="text/css">
      .dataTables_info, .dataTables_paginate {   
      display: none;
      }
    </style>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.6/css/intlTelInput.css">
<script src="<?php echo base_url(); ?>assets/js/intlTelInput.js"></script>    
<script>
  $(function () {
    $("#example1").DataTable();
    $("#delete_date").datetimepicker({
      minDate: new Date()
    });
    /*******************Mobile Verification*******************/
    $("#mobile_number").intlTelInput();
    $('body').on('click','ul.country-list li',function(){
      $('#mobile_number').val($(this).children('.dial-code').html());
    })
    $('.custom_pagination a').click(function(e){
      e.preventDefault();
      $('#search_frm').attr('action',$(this).attr('href'));
      $('#search_frm').submit();
    })

    $('.update_number').click(function(){
      $('#user_id').val($(this).data('id'));
    })
    $('.delete_date').click(function(){
      $('#delete_user_id').val($(this).data('id'));
    })
  });
</script>
<style type="text/css">
  .dataTables_length, .dataTables_filter{ display: none; }
</style>