<?php
session_start();
require_once ("../conexion.php");
require_once('../include/sesiones.php');
$vene_id=$_GET['id'];
?>

<table class="table table-bordered table-hover table-striped">
    <thead>
        <tr>
            <th width="10%">REFERENCIA</th>
            <th width="5%">CANTIDAD</th>
            <th width="5%">UM</th>
            <th width=""><span class="pull-center">DESCRIPCIÓN</span></th>
            <th width="12%"><span class="pull-right">PRECIO U</span></th>
            <th width="5%"><span class="pull-right">IMP</span></th>
            <th width="5%"><span class="pull-right">DESC</span></th>
            <th width="12%"><span class="pull-right">PRECIO T</span></th>
        </tr>
    </thead>
    <tbody  class="buscar">
    <?php
       	$descuento=0;
		$sumador_total=0;
		$sql15=mysqli_query($con,"SELECT * from venta_espera_detalle where ventas_espera_vene_id='$vene_id' and empresa='$empresa'");
		while ($row15=mysqli_fetch_array($sql15))
		{
		    $vened_id=$row15["vened_id"];
		    $vened_referencia=$row15['vened_referencia'];
            $vened_cantidad=$row15['vened_cantidad'];
            $vened_unidad=$row15['vened_unidad'];
		    $vened_nombre=$row15['vened_nombre'];
		    $vened_precio=$row15['vened_precio'];
		    $vened_iva=$row15['vened_iva'];
		    $vened_descuento=$row15['vened_desc'];
		    $ivaf=$vened_iva/100;
		    $precio_total=$vened_precio*$vened_cantidad;
		    $descuento=($vened_descuento/100)*$precio_total;
		    $iva=$vened_precio*$ivaf;
		    $sin_iva=$vened_precio-$iva;
		    $sumador_total+=$precio_total-$descuento;//Sumador
	?>
	
	 <tr>
        <td ><?php echo $vened_referencia;?></td>
        <td ><?php echo $vened_cantidad;?></td>
        <td ><?php echo $vened_unidad;?></td>
        <td ><?php echo $vened_nombre;?></td>
        <td ><span class="pull-right"><?php echo number_format($vened_precio,0);?></span></td>
        <td ><span class="pull-right"><?php echo number_format($vened_iva,0);?></span></td>
        <td ><span class="pull-right"><?php echo number_format($vened_descuento,0);?></span></td>
        <td style="text-align: right; "><span class="pull-right"><?php echo number_format($precio_total,0);?></span></td>
    </tr>

	<?php	}
		$sumador_total1=0;
		$sql=mysqli_query($con,"SELECT * from venta_espera_combo where ventas_espera_vene_id='$vene_id' ");
		while ($row=mysqli_fetch_array($sql))
		{
		    $combo_cantidad=$row["combo_cantidad"];
		    $combo_precio=$row['combo_precio'];
		    $combo_nombre=$row['combo_nombre'];
		    $precio_total1=$combo_cantidad*$combo_precio;
		    $sumador_total1+=$precio_total1;//Sumador
        ?>
   
	 <tr>
        <td ><?php// echo $vened_referencia; ?></td>
        <td ><?php echo $combo_cantidad;?></td>
        <td ><?php echo $combo_nombre;?></td>
        <td ><span class="pull-right"><?php echo number_format($combo_precio,0);?></span></td>
        <td ><span class="pull-right"><?php //echo number_format($vened_iva,0);?></span></td>
        <td ><span class="pull-right"><?php //echo number_format($vened_descuento,0);?></span></td>
        <td style="text-align: right; "><span class="pull-right"><?php echo number_format($precio_total1,0);?></span></td>
    </tr>
            
   <?php } ?>
    <tr  style=" border: solid 01px black;  text-align: center; font-size: 10pt;padding:0mm;">
        <td border="1" style=" text-align: right;">  </td>
        <td border="1" style=" text-align: right;">  </td>
        <td border="1" style=" text-align: right;">  </td>
        <td border="1" style=" text-align: right;">  </td>
        <td border="1" style=" text-align: right;">  </td>
        <td border="1" style=" text-align: right;">  </td>
        <td style="width: 5%; text-align: right;">TOTAL  </td>
        <td style="width: 12%; text-align: right;"> <?php echo number_format($sumador_total+$sumador_total1,0);?></td>
    </tr>
    </tbody> 
</table>