<div class="row">
		
	       
		    <section class="content">  
	        <div class="box box-success">
            <div class="box-body">
              <div class="table-responsive">
             <div class="box-body">
<form method="post">
	<a href="newloans.php?id=<?php echo $_SESSION['tid']; ?>&&mid=<?php echo base64_encode("405"); ?>"><button type="button" class="btn btn-flat btn-success"><i class="fa fa-plus"></i>&nbsp;Adicionar Emprestimo</button></a>
<?php
$dia = date("d");
$mes = date("m");
$ano = date("Y");
$date = $ano."-".$mes."-".$dia;
?>
	<hr>		
			  
			 <table id="example1" class="table table-responsive table-bordered table-striped">
                <thead>
                <tr>
                  <th><input type="checkbox" id="select_all"/></th>
                  <th>ID</th>
				  <th>Nº Conta</th>
                  <th>Descrição</th>
                  <th>Valor</th>
                  <th>Saldo</th>
                  <th>Cliente</th>
				  <th>Agente</th>
                  <th>Aprovado por</th>
                  <th>Data de Aprov</th>
                  <th>Dia de Pagamento</th>
                  <th>Estado</th>
                 </tr>
                </thead>
                <tbody> 
<?php
$select = mysqli_query($link, "SELECT * FROM loan_info WHERE pay_date < '$date' AND amount_topay > 0") or die (mysqli_error($link));
if(mysqli_num_rows($select)==0)
{
echo "<div class='alert alert-info'>Nenhum dado encontrado!!</div>";
}
else{
while($row = mysqli_fetch_array($select))
{
$id = $row['id'];
$borrower = $row['borrower'];
$status = $row['status'];
$upstatus = $row['upstatus'];
$selectin = mysqli_query($link, "SELECT fname, lname FROM borrowers WHERE id = '$borrower'") or die (mysqli_error($link));
$geth = mysqli_fetch_array($selectin);
$name = $geth['fname'];
?> 
<?php
if($upstatus == "Pending")
{
?>  
                <tr>
				<td><input id="optionsCheckbox" class="checkbox" name="selector[]" type="checkbox" value="<?php echo $row['id']; ?>"></td>
                <td><?php echo $row['id']; ?></td>
				<td><?php echo $row['baccount']; ?></td>
				<td><?php echo $row['desci']; ?></td>
                <td><?php echo $row['amount']; ?></td>
				<td><?php echo $row['amount_topay']; ?></td>
				<td><?php echo $geth['fname']; ?></td>
				<td><?php echo $row['agent']; ?></td>
			    <td><?php echo $row['teller']; ?></td>
				<td><?php echo $row['date_release']; ?></td>
				<td><?php echo $row['pay_date']; ?></td>
                <td>
<span class="label label-<?php if($status =='Approved')echo 'success'; elseif($status =='Disapproved')echo 'danger'; else echo 'warning';?>"><?php echo $status; ?></span>				</td>
			
						    
			    </tr>
<?php
}
else{
?>
				<tr>
				<td><input id="optionsCheckbox" class="checkbox" name="selector[]" type="checkbox" value="<?php echo $row['id']; ?>"></td>
                <td><?php echo $row['id']; ?></td>
				<td><?php echo $row['baccount']; ?></td>
				<td><?php echo $row['desci']; ?></td>
                <td><?php echo $row['amount']; ?></td>
				<td><?php echo $row['amount_topay']; ?></td>
				<td><?php echo $geth['fname']; ?></td>
				<td><?php echo $row['agent']; ?></td>
			    <td><?php echo $row['teller']; ?></td>
				<td><?php echo $row['date_release']; ?></td>
				<td><?php echo $row['pay_date']; ?></td>
                <td>
				<span class="label label-<?php if($status =='Approved')echo 'success'; elseif($status =='Disapproved')echo 'danger'; else echo 'warning';?>"><?php echo $status; ?></span>
				</td>
				    
			    </tr>
<?php } } } ?>
             </tbody>
                </table>  

</form>				

              </div>


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