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

	include_once("../header.php");
        include_once("../php/config.php");
       
        
 $sql2 = mysql_query("select DISTINCT idrentas, cliente, monto, vence  from rentas where vence<='$hoy' and estado!='Cerrada'") or die(mysql_error());

	?>
<style>

</style>
    <div class="container">
       <?php include_once("../header.php")?>  
        
		<div class="row">
			<div class="col-md-12">
			  
				<a class="btn  btn-danger mt-2" href="nueva_renta.php"><i class="fa fa-plus"></i> Registrar un nuevo alquiler</a>
				 <a class="btn  btn-default mt-2" href="menu_renta.php"><i class="fa fa-pencil"></i> Salir</a>
				<hr>
				<div class="table-responsive col-md-8">
					<table class="table table-sm table-borderred table-striped" data-page-length='8'>
						<thead>
							<th># Alquiler</th>
                             
							<th width="200">Nombre/Apell.</th>
  
								<th>Monto</th>
								<th>Vence</th>
                            <th>Accion</th>
						</thead>
						<tbody>
                                                        <?php while($r=mysql_fetch_array($sql2)){
                                          $idrentas=$r["idrentas"]; 
                                          $c++;
                                          
                                         
                                          $monto+=$r["monto"];
                                          
                                          
                                          
                                                        ?>
							<tr>
								<td><?php echo $r["idrentas"]?></td>
							
								<td><?php echo $r["cliente"]?></td>
					
								<td><?php echo decimal($r["monto"])?></td>
								<td><?php echo fecha($r["vence"])?></td>
								
								<td>|
								 <?php echo "<a href='datos_renta.php?idrentas=$idrentas'>Cobrar</a>"?></td>
							</tr>
                                                        <?php }?>
						</tbody>
						<tfoot>
						     <th>Cant. prestamos </th>
						    <th>Total prestado</th>
						    
						    <th>Total cuota</th>
						    <tr>
						         <td><?php echo decimal($c)?></td>
						        <td><?php echo decimal($prestado)?></td>
						       
						         
						        <td><?php echo decimal($balance)?></td>
						    </tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
		
        </div>

      


          
</div>
    </div>



	<?php
	include_once("../footer.php");
	?>
	
	<script>
$(".table").DataTable({
	 "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
        }
});
</script>

