<?php include "includes/header.php";?>

<?php include "includes/navbar.php";?>

  <div id="wrapper">

    <!-- Sidebar -->
   <?php include "includes/sidebar.php";?>

    <div id="content-wrapper">

      <div class="container-fluid">

        <!-- Breadcrumbs-->
        <ol class="breadcrumb">
          <li class="breadcrumb-item">
            <a href="#">Ola</a>
          </li>
          <li class="breadcrumb-item active"><?php echo $_SESSION['nome'];?></li>
        </ol>

        <!-- Icon Cards-->
        <div class="row">
       
	   <?php $loan->aproveLoan();?>
	   <div class="container">
	       <h3><font color="green">Validar creditos</font></h3>
	       <div class="col-sm-20">
	           <table class="table">
	               <thead>
	                   <tr>
	                       <th>Item</th>
	                       <th>Nome</th>
	                       <th>Valor</th>
	                       <th>Detalhes</th>
	                 
	                   </tr>
	               </thead>
	               <tbody>
	                  
	                       <?php 
	                       $item=1;
	                       $query = $database->query("SELECT cr.*, cli.* FROM creditos cr INNER JOIN clientes cli ON
                         cr.id_cliente = cli.id_cliente WHERE cr.status='aguardar'");
	                       while($sucessos = mysqli_fetch_assoc($query)){
	                       ?>
	                       
	                        <tr>
	                       <td><?php echo $item++;?></td>
	                       <td><?php echo $sucessos['nome_cliente'];?></td>
	                       <td><?php echo number_format($sucessos['valor'],2,",",".");?></td>
	                      
	                      
	  <?php if($_SESSION['nivel']==1){?> 
	  <td>
	                           <!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#exampleModal<?php echo $sucessos['id'];?>">
  <span><i class="fa fa-eye" aria-hidden="true"></i></span>
</button>
</td>
<!-- Modal -->
<div class="modal fade" id="exampleModal<?php echo $sucessos['id'];?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Validar <font color='red'><?php echo $sucessos['nome_cliente'];?>?</font></h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <div class="container">
            <div class="col-sm-8">
                <p>
                  Nome do cliente: <i><font color="red"><?php echo $sucessos['nome_cliente'];?></font></i><br> 
                  Tipo de credito: <i><font color="red"><?php echo $sucessos['tipo'];?></font></i><br> 
                  Prestacoes: <i><font color="red"><?php echo $sucessos['prestacoes'];?></font></i><br> 
                  Taxa de juros: <i><font color="red"><?php echo $sucessos['taxas'] * 100;?>%</font></i><br> 
                  Prestacao: <i><font color="red"><?php echo number_format($sucessos['v_prest'],2,",",".");?></font></i><br> 
                  Juros: <i><font color="red"><?php echo number_format($sucessos['juros'],2,",",".");?></font></i><br> 
                  Total: <i><font color="red"><?php echo number_format($sucessos['total'],2,",",".");?></font></i><br> 
                  Garantia: <i><font color="red"><?php echo $sucessos['garantias'];?></font></i><br>
                  Valor estimado: <i><font color="red"><?php echo number_format($sucessos['estimado'],2,",",".");?></font></i><br>
                  Finalidade: <i><font color="red"><?php echo $sucessos['finalidade'];?></font></i><br>
                  
                  </p>
                  <form action="" method="post">
                    <input type="hidden" name="id" value="<?php echo $sucessos['id'];?>"/>
                  <button type="submit" name="aprove" class="btn btn-info btn-sm"><span>Validar</span></button>
               </form>

               <button type="button" class="btn btn-danger btn-sm"><a href="includes/code.php?reject=<?php echo $sucessos['id'];?>"
                style="text-decoration:none;color:white"><span>Recusar</span></a></button>
            </div>
    
        </div>
      </div>
      
      
      <div class="modal-footer">
      </div>
    </div>
  </div>
</div>
<?php }else{

echo "<td><font color='red'>N/A</font>";
}?>

	         </tr>
	                                       
	                           
	                       
	                       <?php }?>
	                 
	               </tbody>
	           </table>
	           
	       </div>
	   </div>
        
        
        </div>

     
        

      </div>
      <!-- /.container-fluid -->

      <!-- Sticky Footer -->
      <?php include "includes/footer.php";?>

    </div>
    <!-- /.content-wrapper -->

  </div>
  <!-- /#wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
 <?php include "includes/logout_modal.php";?>

  <?php include "includes/sweatscripFooter.php";?>