<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');
require_once('totales_facturar.php');
?>

<div class="col-md-12" style="padding-left:0px; padding-right: 0px;">
    <div class="btn-group btn-group-justified btn-group-sm" >
    <?php 
        $vap=mysqli_query($con,"SELECT count(*) AS numrows FROM ventas_espera where empresa='$empresa' and apertura='$apertura' and sucursal='$sucursal' and usuario='$usu_id' order by vene_n_venta desc") or die(mysqli_error($con));
        $venapar=mysqli_fetch_array($vap);
        $numrows = $venapar['numrows'];
        if ($numrows>0)
        {
    ?>
        <a href="#ventas_espera" class="btn btn-success" data-toggle="modal" type="button" accesskey="g" title="alt + g">VENTAS EN ESPERA</a>
    <?php } ?>
        <a href="#espera" class="btn btn-default" data-toggle="modal" type="button" accesskey="g" title="alt + g">ESPERA</a>
    </div>
</div>
<?php include('form_espera.php'); ?>
<div class="col-lg-12" style="padding: 0px; font-size: 15px; ">
    <strong>
        <div class="col-md-12"> &nbsp; </div>
        <?php  if($facturacion_directa<>'si') { ?>
        <div class="col-md-12" style="background-color:#F3F2F2;padding-top:3px; padding-bottom: 3px;">SUBTOTAL 1<span class="pull-right">$ <?php echo number_format($neto+$sumador_combo,0);?></span></div>
        <div class="col-md-12" style="padding-top:3px; padding-bottom: 3px;">DESCUENTO <span class="pull-right">$ <?php echo number_format($total_descuento+$descuento_combo_total,0);?></span></div>
         <div class="col-md-12" style="background-color:#F3F2F2;padding-top:3px; padding-bottom: 3px;">SUBTOTAL 2<span class="pull-right">$ <?php echo number_format(($neto+$sumador_combo-($total_descuento+$descuento_combo_total)),0);?></span></div>
        <div class="col-md-12" style="padding-top:3px; padding-bottom: 3px;">RETENCION
            <?php
            $total_retencion=0;
            $ret=mysqli_query($con,"SELECT * FROM retencion_temp where empresa='$empresa' and usuario='$usu_id'") or die(mysqli_error($con)); 
            while ($rets=mysqli_fetch_array($ret))
            {
                $rret_id=$rets['ret_id'];
                $retencion_ret_id=$rets['retencion_ret_id'];
                $rete=mysqli_query($con,"SELECT * FROM retencion where empresa='$empresa' and ret_id='$retencion_ret_id' ") or die(mysqli_error($con));
                $rete=mysqli_fetch_array($rete);
                $ret_nombre=$rete['ret_nombre'];
                $ret_porcentaje=$rete['ret_porcentaje'];
            ?>
            (<?php echo $ret_porcentaje;?>%)<a href="#" id="re-<?php echo $rets["ret_id"];?>"><i class="btn-icon-only icon-remove"></i></a>
            <script>
            $("#re-"+<?php echo $rets["ret_id"];?>).click(function(e){
            e.preventDefault();
            p = confirm("Estas seguro?");
            if(p){
                $.get("./php_facturar/eliminar_retencion.php","ret_id="+<?php echo $rets["ret_id"];?>,function(data){
                  loadTabla();
                  loadtotal();
                  loadbotones();
                });
              }
            });
            </script>
            <?php } ?>
            <span class="pull-right">$ <?php echo number_format($total_retencion,0);?></span>
        </div>
        <div class="col-md-12" style="background-color:#F3F2F2;padding-top:3px; padding-bottom: 3px;">IMPUESTO<span class="pull-right">$ <?php echo number_format($total_iva,0);?></span></div>
         <?php } ?>
        <div class="col-md-12" style="background-color:black; font-size: 22px;color: white;padding: 5px;">TOTAL<span class="pull-right">$ <?php echo number_format($sumador_total,0);?></span></div>
        <div class="col-md-12" > &nbsp; </div>
    </strong>
</div>

<?php include('form_ventas_espera.php');  ?>