<?php
	$usuario = $_COOKIE["usuario"];
$nivel = $_COOKIE["nivel"];
if($nivel=="administrador"){$usuario="";}
    $id = $_GET["idrenta"];
	include_once("../header.php");
        include_once("../php/config.php");
        $sql = mysql_query("select * from cobros_renta where idrenta='$id'") 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-plus"></i> Registrar un  cobro</a>
				 <a class="btn  btn-default mt-2" href="datos_renta.php?idrentas=<?php echo $id?>"><i class="fa fa-pencil"></i> Salir</a>
				<hr>
				<div class="table-responsive col-md-6">
					<table class="table table-sm table-borderred table-striped" data-page-length='8'>
						<theads>
							<th># Alquiler</th>
                             <th>Fecha</th>
							<th>Nombre/Apell.</th>
                            
							<th>Monto cobrado</th>
							<th>Accion</th>
                           
						</thead>
						<tbody>
                                 <?php while($r=mysql_fetch_array($sql)){
                                          $idrenta=$r["idrenta"]; 
										  $idcobro=$r["idcobros_renta"]; 
                                          $c++;
                                          $monto+=$r["monto"];

                                                        ?>
							<tr>
								<td><?php echo $r["idrenta"]?></td>
								<td><?php echo ($r["hora"])?></td>
								<td><?php echo $r["cliente"]?></td>
							
								<td><?php echo decimal($r["monto"])?></td>
								<td><?php echo "<a href='datos_cobro_renta.php?id_cobro=$idcobro&idrenta=$idrenta'> Ver</a>"?>

	
								
							</tr>
                                                        <?php }?>
						</tbody>
						<tfoot>
						     <th>Cant. cobros </th>
						    <th>Total cobrado</th>
						    
						    
						    <tr>
						         <td><?php echo decimal($c)?></td>
						        <td><?php echo decimal($monto)?></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>

