<?php
session_name("AUTHENUSER");
session_start();
$USERNAME = $_SESSION['SES_USERNAME'];
if(!session_name("AUTHENUSER"))
	{
?>
						<script language="javascript">
						 alert("Waktu Login telah habis.Silahkan Login Kembali");
						document.location="index.php";
						</script>
<?php
	}
if(!$USERNAME)
	{
?>
						<script language="javascript">
						 alert("Harap Login Dahulu.");
						document.location="index.php";
						</script>
<?php
	}
	?>
	<?php include "common/config.php";
	include "include/head.php"; ?>?>
    
<body>
<?php include "include/head2.php"; ?>
<?php include "include/leftmenu.php"; ?>
<?php include "include/top.php"; ?>
  <h1><i class="icon-user"></i> Master User</h1>
</div>

<ol class="breadcrumb">
  <li><a href="add_user.php">Add User</a></li>
<!--  <li><a href="#">Bread</a></li>
  <li><a href="#">Crumbs</a></li>
  <li class="active">Example</li>-->
</ol>
   <div class="main-content">
            <div class="widget">
              <h3 class="section-title first-title"><i class="icon-table"></i> Listing User</h3>
              <div class="widget-content-white glossed">
                <div class="padded">
                <table class="table table-striped table-bordered table-hover">
                  <thead>
                    <tr>
                      <th>Username</th>
                      <th>Branch Name</th>
                      <th>Status User</th>
                      <th>Last Login</th>
                      <th>Details</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php
						$sql = mysql_query("select * from tbl_admin");
						while($fetch = mysql_fetch_array($sql))
						{
								$user_id = $fetch['user_id'];
								$status = $fetch['status'];
								$id_branch = $fetch['id_branch'];
								if($status == 1)
								{
									$status1 = "No Active";
								}
								elseif($status == 2)
								{
									$status1 = "Active";
								}
								$fetch2 = mysql_fetch_array(mysql_query("select * from tbl_branch where id_branch = '$id_branch'"));
								$nama_branch = $fetch2['nama_branch'];
					?>
                    <tr>
                      <td><?php echo $fetch['user_id']; ?></td>
                            <td><?php echo $fetch2['nama_branch']; ?></td>
                            <td><?php echo $status1; ?></td>
                            <td><?php echo $fetch['lastlogin']; ?></td>
                      <td class="text-right">
                        <a href="edit_user.php?user_id=<?php echo $user_id; ?>&status=<?php echo $status; ?>&id_branch=<?php echo $id_branch; ?>" class="btn btn-default btn-xs"><i class="icon-pencil"></i> edit</a>
                      <!--  <a href="#" class="btn btn-danger btn-xs"><i class="icon-remove"></i></a>-->
                      </td>
                    </tr>
                     <?php
						}
						?>
                  </tbody>
                </table>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>       

<?php include "include/foot.php"; ?>
<script src='assets/js/for_pages/dashboard.js'></script>
</body>

</html>