<div id="verdetalle<?php echo $reg['ven_id']; ?>" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog  modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">Detalle de Venta</h4>
            </div>
            <div class="modal-body">
                <div class="col-md-12">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover table-striped">
                            <thead>
                                <tr>
                                    <th width="10%">REFERENCIA</th>
                                    <th width="5%">CANTIDAD</th>
                                    <th width="45%"><span class="pull-center">DESCRIPCIÓN</span></th>
                                    <th width="15%"><span class="pull-right">PRECIO U</span></th>
                                    <th width="5%"><span class="pull-right">DESCUENTO</span></th>
                                    <th width="25%"><span class="pull-right">PRECIO T</span></th>
                                </tr>
                            </thead>
                            <tbody  class="buscar">
                            <?php
                                $sumador_combo=0;
                                $sumador_total=0;
                                $neto=0;
                                $descuento_global=0;
                                $iva_global=0;
                                $retencion_global=0;

                                $ret=mysqli_query($con, "SELECT * FROM retencion_venta where ventas_ven_id='$ven_id'") or die(mysqli_error($con)); 
                                $rets=mysqli_fetch_array($ret);

                                if(isset($rets['porcentaje']))
                                {
                                    $ret_porcentaje=$rets['porcentaje'];
                                }
                                else
                                {
                                    $ret_porcentaje=0;
                                }

                                $sql=mysqli_query($con, "SELECT * from venta_detalle where ventas_ven_id='$ven_id'");
                                while ($row=mysqli_fetch_array($sql))
                                {
                                    $vend_referencia=$row['vend_referencia'];
                                    $vend_nombre=$row['vend_nombre'];
                                    $vend_cantidad=$row['vend_cantidad'];
                                    //$vend_precio=$row['vend_precio']; //1.000.000
                                    $vend_precio1=$row['vend_precio']; //1.000.000
                                    $vend_iva=$row['vend_iva']; //19%
                                    $vend_descuento=$row['vend_desc']; //10%

                                    $suma_por_retencion=(($vend_precio1*$ret_porcentaje)/(100-$ret_porcentaje));
                                    $vend_precio=$vend_precio1+$suma_por_retencion; //1.000.000

                                    $iva0=$vend_iva/100; //0.19
                                    $iva1=1+$iva0; //1.19

                                    $precio_unitario_sin_iva=$vend_precio/$iva1;  //840.336
                                    $precio_total_sin_iva=$precio_unitario_sin_iva*$vend_cantidad;
                                    $descuento_unitario=($vend_descuento/100)*$precio_unitario_sin_iva;  //84033
                                    $descuento_item=$descuento_unitario*$vend_cantidad;  //84033
                                    $neto_item=$precio_total_sin_iva;
                                    $iva_item=($vend_precio-$precio_unitario_sin_iva)*$vend_cantidad;
                                    $neto+=$precio_total_sin_iva;
                                    $descuento_global+=$descuento_item;
                                    $iva_global+=$iva_item;

                                    $retencion_unitaria=(($precio_unitario_sin_iva)*($ret_porcentaje/100));
                                    $retencion_item=$retencion_unitaria*$vend_cantidad; 
                                    $retencion_global+=$retencion_item;
                                ?>
                            <tr>
                                <td ><?php echo $vend_referencia;?></td>
                                <td ><?php echo $vend_cantidad;?></td>
                                <td ><?php echo $vend_nombre;?></td>
                                <td ><span class="pull-right"><?php echo number_format($precio_unitario_sin_iva,0);?></span></td>
                                <td ><span class="pull-right"><?php echo number_format($vend_descuento,0);?></span></td>
                                <td style="text-align: right; "><span class="pull-right"><?php echo number_format($precio_total_sin_iva,0);?></span></td>
                            </tr>
                        <?php } 
                       $sumador_total=($neto+$iva_global)-$descuento_global;


                            $sql2=mysqli_query($con, "SELECT * from venta_detalle_combo where ven_id='$ven_id'");
                            while ($row2=mysqli_fetch_array($sql2))
                                {
                            $precio=($row2['combo_cantidad']*$row2['combo_precio']);
                            $sumador_combo+=$precio;
                        ?>
                            <tr class="receipt-item-row">
                                <td ><?php //echo $row2['combo_cantidad'];?></td>
                                <td ><?php echo $row2['combo_cantidad'];?></td>
                                <td ><?php echo $row2['combo_nombre'];?></td>
                                <td ><span class="pull-right"><?php echo number_format($row2['combo_precio'],0);?></span></td>
                                <td ><span class="pull-right"><?php //echo number_format($vend_descuento,0);?></span></td>
                                <td style="text-align: right;"><span class="pull-right"><?php echo number_format($precio,0);?></span></td>
                            </tr>   
                        <?php } ?>              
                            <tr>
                                <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: 15%; text-align: right;">SUBTOTAL  </td>
                                <td style="width: 25%; text-align: right;">&#36; <?php echo number_format($neto+$sumador_combo,0);?></td>
                            </tr>
                            <tr>
                                <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: 15%; text-align: right;">DESCUENTO  </td>
                                <td style="width: 25%; text-align: right;">&#36; <?php echo number_format($descuento_global,0);?></td>
                            </tr>
                            <tr>
                                <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: 15%; text-align: right;">IVA  </td>
                                <td style="width: 25%; text-align: right;">&#36; <?php echo number_format($iva_global,0);?></td>
                            </tr>
                             <tr>
                                <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: 15%; text-align: right;">RETENCION  </td>
                                <td style="width: 25%; text-align: right;">&#36; <?php echo number_format($retencion_global,0);?></td>
                            </tr>
                            <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 style="width: 15%; text-align: right;">TOTAL  </td>
                                <td style="width: 25%; text-align: right;">&#36; <?php echo number_format($sumador_total+$sumador_combo,0);?></td>
                            </tr>
                            </tbody> 
                        </table>
                    </div> <!-- /.form-group -->
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div> 
    </div>
</div>