<?php

require __dir__ . '/init.php';

template::get_header();
 
?>

	<?php template::title("User Details"); ?>
	
	<?php template::alert( $msg ); ?>
	  
	<div class='card'>
		<div class="card-body">
			<div class="table-responsive">
				<table class="display table"  data-table="simple">
					<thead>
						<tr>
							<th>ACCOUNT NAME</th>
							<th>EMAIL</th>
							<th>TRANSFER-STATUS</th>
							<th>REG-DATE </th>
							<th>ACTION</th>
						</tr>
					</thead>
					<tbody>
						<?php 
							$sql= "SELECT * FROM tbl_users";
							$result = mysqli_query($link,$sql);
							
							if(mysqli_num_rows($result) > 0){
								while($row = mysqli_fetch_assoc($result)):
								
									$msg = (empty($row['session'])) ? "online" : "offline";
									
									if(!empty($row['active'])){
										$acst = 'Activated &nbsp;<i class="fa fa-check text-success" ></i>';
									}else{
										$acst = 'Deactivated &nbsp;<i class="fa fa-times text-danger" ></i>';
									}
							
						?>
						<tr class="odd gradeX">
							<td><?php echo $row['fname'] .' '. $row['lname'];?></td>
							<td><?php echo $row['email'];?></td>
							<td><?php echo $acst;?></td>
							<td><?php echo $row['rdate'];?></td>
							<td>
								<a href="user-details.php?email=<?php echo $row['email']?>">
									<button  name="view" class="btn btn-info">
										<span class="fas fa-pencil-alt"></span> Manage
									</button>
								</a>
							</td>
						</tr>
						<?php    
								endwhile;
							}
						?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
    
<?php template::get_footer(); ?>  