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

	include_once("../header.php");
        include_once("../php/config.php");
        $sql = mysql_query("select * from catalogo_renta order by nombre asc") or die(mysql_error());
	?>

    <div class="container">
        
        
		<div class="row">
			<div class="col-md-12">
			  
				<a class="btn  btn-primary mt-2" href="datos_producto_renta.php"><i class="fa fa-plus"></i> Registrar un nuevo producto</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">
					<table class="table table-sm table-borderred table-striped" data-page-length='8'>
						<thead1>
							<th>Codigo</th>
                             <th>Nombre</th>
							<th>Costo inventario</th>
                            
							<th>Precio renta</th>
								
                                <th>En almacen</th>
                            <th>Accion</th>
						</thead>
						<tbody>
                                                        <?php while($r=mysql_fetch_array($sql)){
                                          $idcatalogo_renta = $r["idcatalogo_renta"]; 
                                          $c++;
                                          
                                          $costo+=$r["costo"] * $r["stock"];
                                          
                                                        
                                          
                                          
                                                        ?>
							<tr>
								<td><?php echo $r["idcatalogo_renta"]?></td>
								<td><?php echo $r["nombre"]?></td>
								<td><?php echo decimal($r["costo"])?></td>
							
								<td><?php echo decimal($r["precio"])?></td>
								<td><?php echo decimal($r["stock"])?></td>
								
								
								<td><?php echo "<a class='btn btn-default' href='datos_producto_renta.php?idcatalogo=$idcatalogo_renta'><i class='fa fa-edit'></i> Seleccionar</a>"?>
							    	
							</tr>
                                                        <?php }?>
						</tbody>
						<tfoot>
						     <th>Cant. productos </th>
						    <th>Total valorizado</th>
						    
						    <th></th>
						    <tr>
						         <td><?php echo decimal($c)?></td>
						        <td><?php echo decimal($costo)?></td>
						       
						         
						        <td></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>

