<?php defined('BASEPATH') OR exit('No direct script access allowed'); 
$pagehead   = "Admin Users";
?>
<!doctype html>
<html lang="en">
<head>
 <?php $this->load->view('admin/includes/header-script')?>
 <title><?=TITLE?></title>
 <style type="text/css">
 .active {
  pointer-events: none;
  cursor: default;
} 
</style>
</head>
<body class="pushmenu-push pushmenu-push-toright">
  <?php $this->load->view('admin/includes/left-menu')?> 
  <?php $this->load->view('admin/includes/header')?>
  <section class="admin-content">
   <div class="container">
    <h2><?=$pagehead?></h2>
    <?php
    $success_msg= $this->session->flashdata('success_msg');
    $error_msg= $this->session->flashdata('error_msg');
    if($success_msg) { ?>
     <div class="alert alert-success">
      <?php echo $success_msg; ?>
      <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
    </div>
  <?php } if($error_msg){ ?>
   <div class="alert alert-danger">
    <?php echo $error_msg; ?>
    <a href="#" class="close" data-dismiss="alert" aria-label="close" >×</a>
  </div>
<?php } ?>
<div class="col-md-12 col-lg-12 admin-setting">
 <div class="class-content d-flex">
  <div class="col-md-12 class-name col-lg-6">
    <?php echo form_open('admin/user/add_user'); ?>
    <div class="d-flex">
     <span>User Name</span>
     <input type="text" name="user_name" value="<?=isset($user_name)? $user_name : ''?>" class="form-control" required>
   </div>
   <div class="d-flex">
     <span>Password</span>
     <input type="password" name="user_password" value="<?=isset($user_password)? $user_password : ''?>" class="form-control" required>
   </div>
   <div class="submit-class d-flex justify-content-end">
    <?php if(isset($user_id)) { ?> 
      <input type="hidden" value="<?=isset($user_id)? $user_id : ''?>" name="user_id">
      <input type="submit" name="submit" value="Update" style="cursor: pointer;" class="submit">
      <a href="<?= base_url();?>admin/admin-user"><input type="button" value="Cancel" style="cursor: pointer;" class="reset"></a>
    <?php } else {?>
      <input type="submit" name="submit" value="Add" style="cursor: pointer;" class="submit">
      <input type="reset" value="Reset" style="cursor: pointer;" class="reset">
    <?php } ?>
  </div>
  <?php echo form_close(); ?>
</div>
<div class="col-md-12 col-lg-6">
 <h2>Admin Users</h2>
 <table class="table">
  <thead>
   <tr>
    <th>User Name</th>
    <th>Status</th>
    <th>Edit</th>
    <th>Delete</th>
  </tr>
</thead>
<tbody>
  <?php foreach($all_users as $val) { ?>
   <tr>
    <td><?=$val['user_name']?></td>
    <td class="text-center"><?php
    if($val['user_status'] == "active") { ?>
     <a class="<?php if($this->session->user_id == $val['user_id']){echo "active"; }?>" href="<?=site_url('admin/user/update_status/'.$val['user_id'])?>"><div class="active-swith">
      <?=$val['user_status']?>
    </div></a>
  <?php } if($val['user_status'] == "inactive"){ ?>
   <a href="<?=site_url('admin/user/update_status/'.$val['user_id'])?>"><div class="active-swith off">
    <?=$val['user_status']?>
  </div></a>
  <?php } ?></td>
  <td><a href="<?=site_url();?>admin/admin-user-edit/<?=$val['user_id']?>" title="Edit"><img src="<?=site_url();?>assets/admin/img/edit.png" alt=""><a></td>
    <td><?php if( $val['user_type']!='admin') { ?><a href="<?=site_url();?>admin/admin-user-delete/<?=$val['user_id']?>" onclick="return confirm('Are you sure want to Delete?')" title="Delete"><img src="<?=site_url();?>assets/admin/img/delete.png" alt=""><a><?php } else { echo "Can't Delete"; }?></td>
    </tr>
  <?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Optional JavaScript -->
<?php $this->load->view('admin/includes/footer-script')?> 
</body>
</html>