<?php

require __dir__ . '/init.php';

require _SDIR . '/for-bcm.php';

template::get_header(); 

?>  

	<?php template::title( 'Digital Deposits' ); ?>
	
	<?php template::alert( $msg, $status ); ?>
	
	<div class='card'>
		<div class="card-body">

			<div class="table-responsive text-break">
				<table class="table" data-table="simple">
					<thead>
						<tr>
							<th>TNX</th>
							<th>NETWORK</th>
							<th>USD</th>
							<th>DATE</th>
							<th>RATE</th>
							<th>BTC TXN</th>
							<th>STATUS</th>
							<th>ACTION</th>
						</tr>
					</thead>
					<tbody>
						<?php 
						
							$sql= "SELECT * FROM deposits ORDER BY id DESC";
							$result = mysqli_query($link,$sql);
							
							if(mysqli_num_rows($result) > 0){
								while($row = mysqli_fetch_assoc($result)){  
									
									$approved = !empty($row['status']);
									
							?>
						<tr class="odd gradeX">
							<td><?php echo $row['tnxid'];?></td>
							<td><strong><?php echo $row['network'];?></strong></td>
							<td><?php echo '$' . $row['usd'];?></td>
							<td><?php echo $row['date'];?></td>
							<td><?php echo $row['rate'];?></td>
							<td><?php echo $row['btctnx'];?></td>
							<td><?php echo help::stdCheck($row['status'], 'Approved', 'Unapproved'); ?></td>
							<td>	
								<form action="bcm.php" method="post" onsubmit="return confirm('Click OK to proceed');">
									<input type='hidden' name='tnxid' value='<?php echo $row['tnxid']; ?>'>
									<div class='btn-group'>
										<button type="submit" name="delete" class="btn btn-danger">
											<span class="fas fa-trash"></span>
										</button>
										<button  type="submit" name="approve" class="btn btn-success" <?php if( $approved ) echo 'disabled'; ?>>
											<span class="fas fa-<?php echo $approved ? 'ban' : 'check'; ?>"></span>
										</button>
									</div>
								</form>
							</td>
						</tr>
						<?php    
								};
							};
						?>
					</tbody>
				</table>
			</div>
		</div>
	</div>


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