<div class="col-6 menu">
       <table cellspacing="0" style="width: 100%;padding-top:0px;position: ;">
        <tr style="font-size: 7pt;">
            <td style="width: 55%; color: #444444;">
                <img style="width: 100%;" height="100%" src="img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
            <td style="width: 45%;text-align:center;">
                <br> Nit.: <?php echo $emp_nit;?>
                <br> Régimen <?php echo $emp_regimen;?>
                <br> <?php echo $emp_direccion;?>
                <br> <?php echo $emp_correo;?>
                <br> <?php echo $emp_telefono; echo'-'; echo $emp_cel;?>
            </td>
        </tr>
    </table>

     <table cellspacing="0" style="width: 100%;" class="table" bordercolor="#E1E1E1"  border="1" >
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">FECHA:</td>
            <td colspan="2" style="width:32%"><?php echo $ven['ven_fecha']; ?></td>
            <td style="width:18%">N° VENTA:</td>
            <td colspan="2" style="width:32%;color:#FF0000;"><?php echo $ceros; echo $ven['ven_n_venta']; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">CLIENTE:</td>
            <td colspan="4" style="width:32%"><?php echo $ven['ven_nombre']; ?></td>
            <td style="width:20%;color:#FF0000;"><?php echo $ven['ven_cc']; ?> </td>
        </tr>
       <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">DIRECCION:</td>
            <td colspan="5" style="width:84%"><?php echo $clie_direccion;?></td>           
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">NEGOCIO:</td>
            <td colspan="4" style="width:48%"><?php echo $clie_empresa;?></td>
            <td style="width:20%">CONTADO </td>
        </tr>
         <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">BARRIO:</td>
            <td colspan="3" style="width:66%"><?php echo $clie_barrio;?></td>
            <td  colspan="2" style="width:16%">TEL: <?php echo $clie_telefono; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">VENDEDOR:</td>
            <td  colspan="4" style="width:66%"><?php echo $usu_nombre;?></td>
            <td style="width:20%"><?php echo $usu_telefono;?> </td>
        </tr>
        <tr>
            <td style="width:14%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16% "></td>
            <td style="width:20%"> </td>
        </tr>
   </table>
<br>
    <table cellspacing="0" style="width:100%;" class="table" bordercolor="#E1E1E1"  border="1" >  
        <tr style="width: 100%; background: #E7E7E7; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;">CAN</td>
            <td style="width: 73%; color: #444444;">DETALLE</td>
            <td style="width: 10%;text-align:center;">V UNIT</td>
            <td style="width: 12%;text-align:center;">TOTAL</td>
        </tr>
    <?php
    $fact1=mysqli_query($con, "SELECT *,LEFT(vend_nombre,40) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='ven' LIMIT 0,18;");
    while ($row=mysqli_fetch_array($fact1))
    {
        $vend_id=$row['vend_id'];
        $vend_referencia=$row['vend_referencia'];
        $vend_cantidad=$row['vend_cantidad_dev'];
        $vend_nombre=$row['nombre'];
        $vend_iva=$row['vend_iva'];
        $vend_descuento=$row['vend_desc'];
        $vend_precio=$row['vend_precio'];

        $ivaf=$vend_iva/100;
        $precio_total=$vend_precio*$vend_cantidad;
        $descuento=($vend_descuento/100)*$precio_total;

        $iva=$vend_precio*$ivaf;
        $sin_iva=$vend_precio-$iva;
        $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?></strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?></strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?></strong></td>
        </tr>
    <?php } ?> 
        <tr style="width: 100%; border:  text-align: center; ">
            <td colspan="2" style="width: 76%;color: #444444;font-size: 5pt;padding:1mm;"> Esta factura se asimila en todos sus efectos legales a una letra de cambio según Art. 774 del código del comercio
            </td>
            <td style="width: 12%;text-align:center;font-size: 7pt;padding:1mm;">TOTAL</td>
            <td style="width: 12%;text-align:right;font-size: 7pt;padding:1mm;"></td>
        </tr>
    </table>
</div>








<div class="col-6 menu">
       <table cellspacing="0" style="width: 100%;padding-top:0px;position: ;">
        <tr style="font-size: 7pt;">
            <td style="width: 55%; color: #444444;">
                <img style="width: 100%;" height="100%" src="img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
            <td style="width: 45%;text-align:center;">
                <br> Nit.: <?php echo $emp_nit;?>
                <br> Régimen <?php echo $emp_regimen;?>
                <br> <?php echo $emp_direccion;?>
                <br> <?php echo $emp_correo;?>
                <br> <?php echo $emp_telefono; echo'-'; echo $emp_cel;?>
            </td>
        </tr>
    </table>

     <table cellspacing="0" style="width: 100%;" class="table" bordercolor="#E1E1E1"  border="1" >
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">FECHA:</td>
            <td colspan="2" style="width:32%"><?php echo $ven['ven_fecha']; ?></td>
            <td style="width:18%">N° VENTA:</td>
            <td colspan="2" style="width:32%;color:#FF0000;"><?php echo $ceros; echo $ven['ven_n_venta']; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">CLIENTE:</td>
            <td colspan="4" style="width:32%"><?php echo $ven['ven_nombre']; ?></td>
            <td style="width:20%;color:#FF0000;"><?php echo $ven['ven_cc']; ?> </td>
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">DIRECCION:</td>
            <td colspan="5" style="width:84%"><?php echo $clie_direccion;?></td>           
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">NEGOCIO:</td>
            <td colspan="4" style="width:48%"><?php echo $clie_empresa;?></td>
            <td style="width:20%">CONTADO </td>
        </tr>
         <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">BARRIO:</td>
            <td colspan="3" style="width:66%"><?php echo $clie_barrio;?></td>
            <td  colspan="2" style="width:16%">TEL: <?php echo $clie_telefono; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">VENDEDOR:</td>
            <td  colspan="4" style="width:66%"><?php echo $usu_nombre;?></td>
            <td style="width:20%"><?php echo $usu_telefono;?> </td>
        </tr>
        <tr>
            <td style="width:14%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16% "></td>
            <td style="width:20%"> </td>
        </tr>
   </table>
<br>
     <table cellspacing="0" style="width:100%;" class="table" bordercolor="#E1E1E1"  border="1" >  
        <tr  style="width: 100%; background: #E7E7E7; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;">CAN</td>
            <td style="width: 73%; color: #444444;">DETALLE</td>
            <td style="width: 10%;text-align:center;">V UNIT</td>
            <td style="width: 12%;text-align:center;">TOTAL</td>
        </tr>
    <?php
    $fact2=mysqli_query($con, "SELECT *,LEFT(vend_nombre,40) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='ven' LIMIT 18,18; ");
    while ($row=mysqli_fetch_array($fact2))
    {
        $vend_id=$row['vend_id'];
        $vend_referencia=$row['vend_referencia'];
        $vend_cantidad=$row['vend_cantidad_dev'];
        $vend_nombre=$row['nombre'];
        $vend_iva=$row['vend_iva'];
        $vend_descuento=$row['vend_desc'];
        $vend_precio=$row['vend_precio'];

        $ivaf=$vend_iva/100;
        $precio_total=$vend_precio*$vend_cantidad;
        $descuento=($vend_descuento/100)*$precio_total;

        $iva=$vend_precio*$ivaf;
        $sin_iva=$vend_precio-$iva;
        $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?></strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?></strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?></strong></td>
        </tr>
    <?php } ?> 
        <tr style="width: 100%; border:  text-align: center; ">
            <td colspan="2" style="width: 76%;color: #444444;font-size: 5pt;padding:1mm;"> Esta factura se asimila en todos sus efectos legales a una letra de cambio según Art. 774 del código del comercio
            </td>
            <td style="width: 12%;text-align:center;font-size: 7pt;padding:1mm;">TOTAL</td>
            <td style="width: 12%;text-align:right;font-size: 7pt;padding:1mm;"></td>
        </tr>
    </table>
</div>







<div class="col-6 menu">
       <table cellspacing="0" style="width: 100%;padding-top:0px;position: ;">
        <tr style="font-size: 7pt;">
            <td style="width: 55%; color: #444444;">
                <img style="width: 100%;" height="100%" src="img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
            <td style="width: 45%;text-align:center;">
                 <br> Nit.: <?php echo $emp_nit;?>
                <br> Régimen <?php echo $emp_regimen;?>
                <br> <?php echo $emp_direccion;?>
                <br> <?php echo $emp_correo;?>
                <br> <?php echo $emp_telefono; echo'-'; echo $emp_cel;?>
            </td>
        </tr>
    </table>

     <table cellspacing="0" style="width: 100%;" class="table" bordercolor="#E1E1E1"  border="1" >
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">FECHA:</td>
            <td colspan="2" style="width:32%"><?php echo $ven['ven_fecha']; ?></td>
            <td style="width:18%">N° VENTA:</td>
            <td colspan="2" style="width:32%;color:#FF0000;"><?php echo $ceros; echo $ven['ven_n_venta']; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">CLIENTE:</td>
            <td colspan="4" style="width:32%"><?php echo $ven['ven_nombre']; ?></td>
            <td style="width:20%;color:#FF0000;"><?php echo $ven['ven_cc']; ?> </td>
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">DIRECCION:</td>
            <td colspan="5" style="width:84%"><?php echo $clie_direccion;?></td>           
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">NEGOCIO:</td>
            <td colspan="4" style="width:48%"><?php echo $clie_empresa;?></td>
            <td style="width:20%">CONTADO </td>
        </tr>
         <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">BARRIO:</td>
            <td colspan="3" style="width:66%"><?php echo $clie_barrio;?></td>
            <td  colspan="2" style="width:16%">TEL: <?php echo $clie_telefono; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">VENDEDOR:</td>
            <td  colspan="4" style="width:66%"><?php echo $usu_nombre;?></td>
            <td style="width:20%"><?php echo $usu_telefono;?> </td>
        </tr>
        <tr>
            <td style="width:14%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16% "></td>
            <td style="width:20%"> </td>
        </tr>
   </table>
<br>
     <table cellspacing="0" style="width:100%;" class="table" bordercolor="#E1E1E1"  border="1" >  
        <tr  style="width: 100%; background: #E7E7E7; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;">CAN</td>
            <td style="width: 73%; color: #444444;">DETALLE</td>
            <td style="width: 10%;text-align:center;">V UNIT</td>
            <td style="width: 12%;text-align:center;">TOTAL</td>
        </tr>
    <?php
    $fact3=mysqli_query($con, "SELECT *,LEFT(vend_nombre,40) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='ven' LIMIT 36,18;");
    while ($row=mysqli_fetch_array($fact3))
    {
        $vend_id=$row['vend_id'];
        $vend_referencia=$row['vend_referencia'];
        $vend_cantidad=$row['vend_cantidad_dev'];
        $vend_nombre=$row['nombre'];
        $vend_iva=$row['vend_iva'];
        $vend_descuento=$row['vend_desc'];
        $vend_precio=$row['vend_precio'];

        $ivaf=$vend_iva/100;
        $precio_total=$vend_precio*$vend_cantidad;
        $descuento=($vend_descuento/100)*$precio_total;

        $iva=$vend_precio*$ivaf;
        $sin_iva=$vend_precio-$iva;
        $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?></strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?></strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?></strong></td>
        </tr>
    <?php } ?> 
        <tr style="width: 100%; border:  text-align: center; ">
            <td colspan="2" style="width: 76%;color: #444444;font-size: 5pt;padding:1mm;"> Esta factura se asimila en todos sus efectos legales a una letra de cambio según Art. 774 del código del comercio
            </td>
            <td style="width: 12%;text-align:center;font-size: 7pt;padding:1mm;">TOTAL</td>
            <td style="width: 12%;text-align:right;font-size: 7pt;padding:1mm;"></td>
        </tr>
    </table>
</div>








<div class="col-6 menu">
    <table cellspacing="0" style="width: 100%;padding-top:0px;position: ;">
        <tr style="font-size: 7pt;">
            <td style="width: 55%; color: #444444;">
                <img style="width: 100%;" height="100%" src="img/<?php echo $empresa;?>.png" alt="Logo"><br>
            </td>
            <td style="width: 45%;text-align:center;">
                <br> Nit.: <?php echo $emp_nit;?>
                <br> Régimen <?php echo $emp_regimen;?>
                <br> <?php echo $emp_direccion;?>
                <br> <?php echo $emp_correo;?>
                <br> <?php echo $emp_telefono; echo'-'; echo $emp_cel;?>
            </td>
        </tr>
    </table>

    <table cellspacing="0" style="width: 100%;" class="table" bordercolor="#E1E1E1"  border="1" >
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">FECHA:</td>
            <td colspan="2" style="width:32%"><?php echo $ven['ven_fecha']; ?></td>
            <td style="width:18%">N° VENTA:</td>
            <td colspan="2" style="width:32%;color:#FF0000;"><?php echo $ceros; echo $ven['ven_n_venta']; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">CLIENTE:</td>
            <td colspan="4" style="width:32%"><?php echo $ven['ven_nombre']; ?></td>
            <td style="width:20%;color:#FF0000;"><?php echo $ven['ven_cc']; ?> </td>
        </tr>
       <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">DIRECCION:</td>
            <td colspan="5" style="width:84%"><?php echo $clie_direccion;?></td>           
        </tr>
        <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">NEGOCIO:</td>
            <td colspan="4" style="width:48%"><?php echo $clie_empresa;?></td>
            <td style="width:20%">CONTADO </td>
        </tr>
         <tr style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width:10%;">BARRIO:</td>
            <td colspan="3" style="width:66%"><?php echo $clie_barrio;?></td>
            <td  colspan="2" style="width:16%">TEL: <?php echo $clie_telefono; ?> </td>
        </tr>
        <tr  style="width: 100%; text-align: center; font-size: 7pt;padding:1mm;">
            <td  style="width:10%;">VENDEDOR:</td>
            <td  colspan="4" style="width:66%"><?php echo $usu_nombre;?></td>
            <td style="width:20%"><?php echo $usu_telefono;?> </td>
        </tr>
        <tr>
            <td style="width:14%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16%"></td>
            <td style="width:16% "></td>
            <td style="width:20%"> </td>
        </tr>
   </table>
<br>
    <table cellspacing="0" style="width:100%;" class="table" bordercolor="#E1E1E1"  border="1" >  
        <tr  style="width: 100%; background: #E7E7E7; text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;">CAN</td>
            <td style="width: 73%; color: #444444;">DETALLE</td>
            <td style="width: 10%;text-align:center;">V UNIT</td>
            <td style="width: 12%;text-align:center;">TOTAL</td>
        </tr>
    <?php
    $fact4=mysqli_query($con, "SELECT *,LEFT(vend_nombre,36) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='ven' LIMIT 54,18; ");
    $resultado4=mysqli_num_rows($fact4);
    while ($row=mysqli_fetch_array($fact4))
    {
    $vend_id=$row['vend_id'];
    $vend_referencia=$row['vend_referencia'];
    $vend_cantidad=$row['vend_cantidad_dev'];
    $vend_nombre=$row['nombre'];
    $vend_iva=$row['vend_iva'];
    $vend_descuento=$row['vend_desc'];
    $vend_precio=$row['vend_precio'];

    $ivaf=$vend_iva/100;
    $precio_total=$vend_precio*$vend_cantidad;
    $descuento=($vend_descuento/100)*$precio_total;

    $iva=$vend_precio*$ivaf;
    $sin_iva=$vend_precio-$iva;
    $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?></strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?></strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?></strong></td>
        </tr>
    <?php } ?>


     <?php if($cambio>0) { ?>
        <tr style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;color: #444444;"> </td>
            <td style="width: 73%;color: #444444;"> CAMBIO</td>
            <td style="width: 10%;text-align:right;"></td>
            <td style="width: 12%;text-align:right;"></td>
        </tr>
    <?php
        $fact1c=mysqli_query($con,"SELECT *,LEFT(vend_nombre,40) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='cam'");
    while ($row=mysqli_fetch_array($fact1c))
    {
        $vend_id=$row['vend_id'];
        $vend_referencia=$row['vend_referencia'];
        $vend_cantidad=$row['vend_cantidad_dev'];
        $vend_nombre=$row['nombre'];
        $vend_iva=$row['vend_iva'];
        $vend_descuento=$row['vend_desc'];
        $vend_precio=$row['vend_precio'];

        $ivaf=$vend_iva/100;
        $precio_total=$vend_precio*$vend_cantidad;
        $descuento=($vend_descuento/100)*$precio_total;

        $iva=$vend_precio*$ivaf;
        $sin_iva=$vend_precio-$iva;
        $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?><strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?><strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?><strong></td>
        </tr>
    <?php } } ?>


    <?php
    if($bonificacion>0) { ?>
        <tr style="width: 100%; border: text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;color: #444444;"> </td>
            <td style="width: 73%;color: #444444;"> BONIFICACIÓN</td>
            <td style="width: 10%;text-align:right;"></td>
            <td style="width: 12%;text-align:right;"></td>
        </tr>
    <?php
    $fact1b=mysqli_query($con,"SELECT *,LEFT(vend_nombre,40) as nombre from venta_detalle where ventas_ven_id='$ven_id' and cambio='com'");
    while ($row=mysqli_fetch_array($fact1b))
    {
        $vend_id=$row['vend_id'];
        $vend_referencia=$row['vend_referencia'];
        $vend_cantidad=$row['vend_cantidad_dev'];
        $vend_nombre=$row['nombre'];
        $vend_iva=$row['vend_iva'];
        $vend_descuento=$row['vend_desc'];
        $vend_precio=$row['vend_precio'];

        $ivaf=$vend_iva/100;
        $precio_total=$vend_precio*$vend_cantidad;
        $descuento=($vend_descuento/100)*$precio_total;

        $iva=$vend_precio*$ivaf;
        $sin_iva=$vend_precio-$iva;
        $sumador_total+=$precio_total;//Sumador
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;text-align:center;"><strong><?php echo $vend_cantidad;?></strong></td>
            <td style="width: 73%;color: #444444;">
                <strong>
                    <?php 
                        echo $vend_nombre;
                        $art0=mysqli_query($con,"SELECT  count(*) AS numrows FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                        $row0=mysqli_fetch_array($art0);
                        $numrows = $row0['numrows'];
                        if($numrows>0)  
                        {
                            echo' '; $art=mysqli_query($con,"SELECT * FROM venta_detalle_sabores_productos WHERE vend_id='$vend_id'")or die(mysqli_error($con));
                                while ($row1=mysqli_fetch_array($art))
                                {
                                    echo $row1['sab_nombre'];
                                    echo' ';
                                }
                        }
                    ?>
                </strong>
            </td>
            <td style="width: 10%;text-align:right;"><strong><?php echo number_format($vend_precio,0);?></strong></td>
            <td style="width: 12%;text-align:right;"><strong><?php echo number_format($precio_total,0);?></strong></td>
        </tr>
    <?php } } ?>

  <?php if($observaciones<>null) { ?>
        <tr style="width: 100%; border: text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 5%;color: #444444;"> </td>
            <td colspan="3" style="width: 7%;color: #444444;">OBSERVACIONES</td>
        </tr>
         <tr style="width: 100%; border: text-align: center; font-size: 7pt;padding:1mm;">
            <td colspan="4" style="width: 7%;color: #444444;"><strong><?php echo $observaciones; ?></strong></td>
        </tr>
    <?php } ?>


    <?php
    $linea=$linea1hasta-$resultado4-$resul_linea_cambios;
    $number=$linea;  
        if($number > 0)  
          {  
            for($i=0; $i<$number; $i++)  
          {  
    ?>
        <tr  style="width: 100%; border:  text-align: center; font-size: 7pt;padding:1mm;">
            <td style="width: 7%;color: #444444;"> <br></td>
            <td style="width: 69%;color: #444444;"> </td>
            <td style="width: 12%;text-align:center;"></td>
            <td style="width: 12%;text-align:center;"></td>
        </tr>
    <?php } } ?>



   
        <tr style="width: 100%; border: text-align: center; ">
            <td colspan="2" style="width: 76%;color: #444444;font-size: 5pt;padding:1mm;"> Esta factura se asimila en todos sus efectos legales a una letra de cambio según Art. 774 del código del comercio
            </td>
            <td style="width: 12%;text-align:center;font-size: 7pt;padding:1mm;">TOTAL</td>
            <td style="width: 12%;text-align:right;font-size: 7pt;padding:1mm;"><?php echo number_format($sumador_total,0);?></td>
        </tr>
    </table>
</div>


