<?php 
use App\Models\UserModel;
$user = new UserModel();
?>
<div class="content-wrapper">
  <div class="content-header">
     <div class="container-fluid">
        <div class="row mb-2">
           <div class="col-sm-6">
              <h1 class="m-0 text-dark">All Member</h1>
           </div>
           <div class="col-sm-6">
              <ol class="breadcrumb float-sm-right">
                 <li class="breadcrumb-item"><a href="<?php echo base_url() ?>admin/admin/dashboard">Dashboard</a></li>
                 <li class="breadcrumb-item"><a href="#">Member</a></li>
                 <li class="breadcrumb-item active">All Member</li>
              </ol>
           </div>
        </div>
     </div>
  </div>

  <section class="content">
    <div class="container-fluid">
      <div class="card card-default">
        <div class="card-header">
          <h3 class="card-title">View All Member</h3>
          <div class="card-tools">
             <a href="<?php echo base_url()?>/admin/member/add_new_member" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Member</a>
          </div>
        </div>
        <div class="card-body">
           <table id="example1" class="table table-bordered table-striped">
             <thead>
                <tr>
                   <th>id</th>
                   <th>Image</th>
                   <th>Name</th>
                   <th>Contact & Address Details</th>
                   <th>Extra Details</th>
                   <?php if(check_user_permission('delete') || check_user_permission('edit')): ?>
                     <th></th>
                  <?php endif;?>
                </tr>
             </thead>
             <tbody>
                <?php $i=1; foreach ($all_members as $key => $memeber):
                $added_by = $user->get_user_by_id($memeber->user_added_by);
                ?>
                <tr>
                   <td><?php echo $i ?></td>
                   <td><img src="<?php echo base_url() ?><?php echo $memeber->user_image ?>" width="70px"></td>
                   <td><?php echo $memeber->user_name ?>
                      <br/>
                      <span class="badge badge-success"><?php echo $memeber->user_designation ?></span>
                   </td>
                   <td>
                      Mob. : <b><?php echo $memeber->user_mobile ?></b>
                      <br/>
                      Email : <b><?php echo $memeber->user_email ?></b>
                      <br/>
                      Address : <b><?php echo $memeber->user_address ?>, <?php echo $memeber->user_post ?>, <br/><?php echo $memeber->user_dist ?>, <?php echo $memeber->user_state ?> - <?php echo $memeber->user_pin_code ?></b>
                   </td>
                   <td>
                     DOB : <b><?php echo date('d-m-Y', strtotime($memeber->user_dob)) ?></b>
                     <br/>
                     Gender : <b><?php echo $memeber->user_gender ?></b>
                     <br/>
                     Education : <b><?php echo $memeber->user_education ?></b>
                     <br/>
                     Employment : <b><?php echo $memeber->user_employment ?></b>
                     <br/>
                     Added Date : <b><?php echo date('d-m-Y', strtotime($memeber->created_at)) ?></b>
                     <br/>
                     <?php if($memeber->user_added_by == 2): ?>
                        Added By : <b>Admin</b>
                     <?php else: ?>
                        Added By : <b><?php echo $added_by->user_name; ?></b>
                     <?php endif;?>
                     <br/>
                     <?php if($memeber->user_is_teacher == 1): ?>
                        Teacher : <b>Yes</b>
                     <?php else: ?>
                        Teacher : <b>No</b>
                     <?php endif;?>
                   </td>
                   <?php if(check_user_permission('delete') || check_user_permission('edit')): ?>
                      <td>
                        <?php if(check_user_permission('edit')): ?>
                           <a href="<?php echo base_url()?>/admin/member/edit_memeber/<?php echo $memeber->user_rand_code; ?>" class="btn btn-info btn-sm"><i class="fa fa-edit" aria-hidden="true"></i></a>
                        <?php endif; ?>
                        <?php if(check_user_permission('delete')): ?>
                           <a class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this member?')" href="<?php echo base_url() ?>/admin/member/delete_member/<?php echo $memeber->user_rand_code ?>"><i class="fa fa-trash" aria-hidden="true"></i></a>
                        <?php endif; ?>
                      </td>
                  <?php endif;?>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
             </tbody>
          </table>
        </div>
      </div>
    </div>
  </section>
</div>
