<?php

require __dir__ . '/init.php';

template::get_header();  

?>

	<?php template::title( "Card Application" ); ?>
	
	<div class='card'>
		<div class="card-body">
			<div class="table-responsive">
				<table class="table " data-table='simple'>
					<thead>
						<tr>
							<th>ACCOUNT NAME</th>
							<th>EMAIL</th>
							<th>ACCOUNT</th>
							<th>REG-DATE </th>
							<th>CARD NUMBER </th>
							<th>CARD TYPE </th>
							<th>CARD STATUS</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)){  
							
							?>
						<tr class="odd gradeX">
							<td><?php echo $row['fname'] .' '. $row['lname'];?></td>
							<td><?php echo $row['email'];?></td>
							<td><?php echo $row['acctno'];?></td>
							<td><?php echo $row['carddate'];?></td>
							<td><?php echo empty($row['card']) ? "No assigned card" : $row['card']; ?></td>
							<td><?php echo $row['cardt'];?></td>
							<td><?php echo help::stdCheck(empty($row['sstatus'])); ?></td>
							<td>
								<a href="card-edit.php?email=<?php echo $row['email']?>">
									<button  name="view" class="btn btn-info">
										<span class="fas fa-pencil-alt"></span>
									</button>
								</a>
							</td>
						</tr>
						<?php    
								}
							}
							?>
					</tbody>
				</table>
			</div>
		</div>
	</div>

<?php template::get_footer(); ?>  