<?php
	$usuario = $_COOKIE["usuario"];
$nivel = $_COOKIE["nivel"];
if($nivel=="administrador"){$usuario="";}
    $id = $_GET["id_prestamo"];

        include_once("../../php/config.php");
        $sql = mysql_query("select * from cobros where id_prestamo='$id'") or die(mysql_error());
	?>
<meta name="viewport" content="width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<link rel="icon" sizes="192x192" href="../../img/cloud3.png">
  <meta name="theme-color" content="#563d7c">
  <title>SantanaSoft - NUBEPOS</title>

  <link rel="icon" sizes="192x192" href="../../imagenes/mon.png">
  <script src="jquery.js"></script>
    <style>
    	*{
font-family:"Arial";
}
 a{
  text-decoration: none;
}
a:hover{
  background: green;
  color: yellow;
}
</style>
    <div class="container">
       
        
		<div class="row">
			<div class="col-md-12">
			  
				<a class="btn  btn-primary mt-2" href="prestamos.php"><i class="fa fa-plus"></i> Registrar un  cobro</a>
				 <a class="btn  btn-default mt-2" href="prestamos.php?id_prestamo=<?php echo $id?>"><i class="fa fa-pencil"></i> Salir</a>
				<hr>
				<div class="table-responsive col-md-7">
					<table class="table table-sm table-borderred table-striped" data-page-length='8'>
						<theads>
							<th># Prestamo</th>
                             <th>Fecha</th>
							
                            
							<th>Total pagado</th>
                           
							<th>Accion</th>
						</thead>
						<tbody>
                                 <?php while($r=mysql_fetch_array($sql)){
                                          $id_prestamo=$r["id_prestamo"]; 
										  $id_cobro=$r["id_cobro"]; 
                                          $c++;
                                          $monto+=$r["total"];
                                          $capital+=$r["capital"];
                                          $interes+=$r["interes"];

                                                        ?>
							<tr>
								<td><?php echo $r["id_prestamo"]?></td>
								<td><?php echo fecha($r["fecha"])?></td>
							
							
								<td><?php echo decimal($r["total"])?></td>
                               
								<td><?php echo "<a href='datos_pago_prestamo.php?id_prestamo=$id_prestamo&id_cobro=$id_cobro'> Ver</a>"?>

                                
	
								
							</tr>
                                                        <?php }?>
						</tbody>
						<tfoot>
						     <th>Cant. cobros </th>
						    <th>Total cobrado</th>
                            <th>Capital cobrado</th>
                            <th>Interes cobrado</th>
						    
						    
						    <tr>
							
						         <td><?php echo decimal($c)?></td>
						        <td><?php echo decimal($monto)?></td>
                                <td><?php echo decimal($capital)?></td>
                                <td><?php echo decimal($interes)?></td>

						    </tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
		
        </div>

      


          
</div>
    </div>