<div id="verdetalle<?php echo $reg['cot_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 Cotización</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%">CODIGO</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="20%"><span class="pull-right">PRECIO T</span></th>
                                </tr>
                            </thead>
                            <tbody  class="buscar">
                            <?php
                                $neto=0;
                                $total_descuento=0;
                                $total_iva=0;
                                $total_retencion=0;
                                $sumador_articulos=0;

                                $ret=mysqli_query($con, "SELECT * FROM retencion_cotizacion where cotizacion_cot_id='$cot_id' ") or die(mysqli_error($con)); 
                                $rets=mysqli_fetch_array($ret);
                                $ret_porcentaje=!empty($rets['porcentaje']);
                                $sql=mysqli_query($con, "SELECT * from cotizacion_detalle where cotizacion_cot_id='$cot_id'");
                                while ($row=mysqli_fetch_array($sql))
                                {
                                    $id=$row["cotd_id"];
                                    $cotd_id=$row["cotd_id"];
                                    $cotd_referencia=$row['cotd_referencia'];
                                    $cotd_nombre=$row['cotd_nombre'];
                                    $cotd_cantidad=$row['cotd_cantidad'];
                                    $cotd_precio=$row['cotd_precio'];
                                    $cotd_iva=$row['cotd_iva'];
                                    $cotd_descuento=$row['cotd_desc'];
                                 
                                    $iva0=$cotd_iva/100; //0.19
                                    $iva1=1+$iva0; //1.19

                                    $precio_total_item=$cotd_precio*$cotd_cantidad;//precio normal 1.000.000
                                    $precio_total_sin_iva_item=($cotd_precio/$iva1)*$cotd_cantidad; //precio sin iva  840.336
                                    $descuento_item=($cotd_descuento/100)*$precio_total_sin_iva_item; //descuento_item 84.033
                                    $total_iva_item=($precio_total_sin_iva_item-$descuento_item)*$iva0; // total iva  159.336

                                    $neto+=$precio_total_sin_iva_item;
                                    $total_descuento+=$descuento_item;
                                    $total_iva+=$total_iva_item;
                                    $sumador_articulos=($neto+$total_iva)-$total_descuento;
                                ?>
                            <tr>
                                <td ><?php echo $cotd_referencia;?></td>
                                <td ><?php echo $cotd_cantidad;?></td>
                                <td ><?php echo $cotd_nombre;
                                        $art=mysqli_query($con,"SELECT * FROM cotizacion_sabores_producto WHERE cotd_id='$cotd_id' ")or die(mysqli_error($con));
                                        while ($row1=mysqli_fetch_array($art))
                                        {
                                            echo ' ';  
                                            echo mb_strtoupper($row1['sab_nombre']);
                                            echo ' -'; 
                                        }
                                    ?></td>
                                <td ><span class="pull-right"><?php echo number_format($cotd_precio,0);?></span></td>
                                <td ><span class="pull-right"><?php echo number_format($cotd_descuento,0);?></span></td>
                                <td style="text-align: right; "><span class="pull-right"><?php echo number_format($precio_total_item,0);?></span></td>
                            </tr>
                        <?php } ?>


                        <?php 
                            $sumador_combo=0;
                            $sql=mysqli_query($con, "SELECT * from cotizacion_detalle_combo where cot_id='$cot_id'");
                            while ($row=mysqli_fetch_array($sql))
                            {
                                $cdc_id=$row["cdc_id"];
                                $combo_cantidad=$row["combo_cantidad"];
                                $combo_precio=$row["combo_precio"];
                                $subtotal=$combo_cantidad*$combo_precio;
                                $sumador_combo+=$subtotal;
                        ?>
                            <tr>
                                <td ><?php echo $row["combo_referencia"];?></td>
                                <td ><?php echo $combo_cantidad;?></td>
                                <td ><?php echo $row["combo_nombre"];
                                        $art=mysqli_query($con,"SELECT * FROM cotizacion_sabores_combo WHERE cdc_id='$cdc_id' ")or die(mysqli_error($con));
                                        while ($row1=mysqli_fetch_array($art))
                                        {
                                            echo ' ';
                                            echo mb_strtoupper($row1['sab_nombre']);
                                            echo ' -'; 
                                        }
                                   ?>
                                </td>
                                <td ><span class="pull-right"><?php echo number_format($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($subtotal,0);?></span></td>
                            </tr>
                        <?php }
                            $total_retencion+=($neto+$sumador_combo-$total_descuento)*($ret_porcentaje/100);
                            $sumador_total=$sumador_articulos+$sumador_combo-$total_retencion;
                         ?>

                            <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: 15%; text-align: right;">&#36; <?php echo number_format($neto,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: 15%; text-align: right;">&#36; <?php echo number_format($total_descuento,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;">SUBTOTAL  </td>
                                <td style="width: 15%; text-align: right;">&#36; <?php echo number_format($neto-$total_descuento,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;">IMPUESTO  </td>
                                <td style="width: 15%; text-align: right;">&#36; <?php echo number_format($total_iva,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: 15%; text-align: right;">&#36; <?php echo number_format($total_retencion,0);?></td>
                            </tr>
                            <tr style="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: 15%; text-align: right;">&#36; <?php echo number_format($sumador_total,0);?></td>
                            </tr>
                            <tr style="text-align: left; font-size: 10pt;padding:0mm;">
                                <td >Obs:</td>
                                <td colspan="5">  
                                    <strong><?php echo $observaciones=$reg['observaciones']; ?></strong>
                                </td>
                            </tr>
                            </tbody> 
                        </table>
                    </div> <!-- /.form-group -->
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div> 
    </div>
</div>