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

	include_once("../header.php");
        include_once("../php/config.php");
    $fecha1 = $_POST["fecha1"];    
    $fecha2 = $_POST["fecha2"];  
        $sql = mysql_query("select * from cobros_renta where fecha between '$fecha1' and '$fecha2'") or die(mysql_error());
	?>

    <div class="container">
       <?php include_once("../header.php")?>  
    
    <div class="row">
        	<div class="col-md-12">
        <a class="btn  btn-primary mt-2" href="rentas.php"><i class="fa fa-pencil"></i> Registrar un cobro</a>
        <a class="btn  btn-default mt-2" href="menu_renta.php"><i class="fa fa-pencil"></i> Salir</a>
				<hr>
	</div>
	<form method="POST" action="" name="frm">
        <div class="col-md-2 mb-2">
             <input type="Date" name="fecha1" class="form-control mt-2" value="<?php echo $hoy?>">
        </div>
	    <div class="col-md-2 mb-2">       
		<input type="Date" name="fecha2" class="form-control mt-2" value="<?php echo $hoy?>">
		
        </div>
        
        <div class="col-md-2 mb-2 mt-2">       
	        <button class="btn btn-default"> Consultar</button>
		
        </div>
    </div>
     
        
		<div class="row">
	  
			<div class="col-md-12">
			   
					
				<div class="table-responsive col-md-6">
					<table class="table table-sm table-borderred table-striped" data-page-length='8'>
						<thead>
							<th># Alquiler</th>
                             <th>Fecha</th>
							<th>Nombre/Apell.</th>
                            	<th>Monto</th>
                            	
						
                            <th>Accion</th>
						</thead>
						<tbody>
                           <?php while($r=mysql_fetch_array($sql)){
                                          $id_cobro=$r["idcobros_renta"]; 
										  $id_renta=$r["idrenta"]; 
                                          $c++;
                                          $monto+=$r["monto"];
                                
                                          
										  
                                          
                                                        ?>
							<tr>
								<td><?php echo $r["idcobros_renta"]?></td>
								<td><?php echo fecha($r["fecha"])?></td>
								<td><?php echo $r["cliente"]?></td>
							
								<td><?php echo decimal($r["monto"])?></td>
						
								<td><?php echo "<a href='datos_cobro_renta.php?idrenta=$id_renta&id_cobro=$id_cobro'> Ver</a>"?>
														<?php }?>
						</tbody>
						<tfoot>
						     <th>Cant. cobros </th>
						    <th>Total</th>
						    
						  
						    <tr>
						         <td><?php echo decimal($c)?></td>
						      
						        <td><?php echo "<b class='text-primary'>".decimal($monto)."</b>"?></td>
						       
						         
						       
						    </tr>
						</tfoot>
					</table>
				</div>
			</div>
		</div>
	</form>	
        </div>

      


          
</div>
    </div>



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

