<?php
session_start();
require_once('conexion.php');
require_once('include/sesiones.php');
if (isset($_SESSION['usu_nombre']))
{
    $regis=mysqli_query($con,"SELECT * from permiso where modulo_mod_id='24' and usuario_usu_id='$usu_id'") or die(mysqli_error($con));
    $reg=mysqli_fetch_array($regis);
    if($reg['per_visualizar']=="Activo")
    {
        if ($aper_num>'0')
        {
            if ($facturador=='si')
            {
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<?php include ('head.php');?>
</head>
<body >
<?php
$inicio="";
$M_inventario="";
$M_contactos="";
$M_compras="";
$M_ventas="";
$M_pedidos="";
$M_pos="active";
$R_reportes="";

$ventas="active";
$remisiones="";
$cajas="";
$apartadas="";
$orden="";
$movimientos="";
$periodica=""; 
$cocina="";
$mesas=""; 
include ('menu.php');
?> 
    
<div class="main">
    <div class="col-md-2">
        <?php include ('include/menu_pos.php');?>       
    </div> <!-- /span6 -->
    <div class="col-md-10">  
        <div class="widget stacked">
            <div class="widget-content">
                <div class="tabbable">
                    <ul class="nav nav-tabs">
                        <?php if ($facturador=='si') { ?>
                            <li class="active"><a href="P_pos.php">FACTURAS DE VENTA</a></li>
                            <?php if ($activar_remisiones=='Si') { ?>
                            <li class=""><a href="P_pos_remision.php">REMISIONES</a></li>
                            <?php } ?>
                         <?php } ?>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="widget stacked">
                                <div class="widget-content">
                                    <div class="col-md-6"><a class="btn btn-info"href="P_facturar.php" target="_blank" ><i class="icon-plus"></i> NUEVA VENTA</a></div>
                                    <div class="col-md-6">
                                        <div class="input-group">
                                            <input type="text" class="form-control" id="q" placeholder="Buscador" onKeyUp='load(1);' autofocus value="">
                                            <span class="input-group-addon">
                                                <a  href="#buscarfactura" data-toggle="modal" class=""  style="width:100%; color: red;" ><i class="fa-solid fa-magnifying-glass"></i><strong> Busqueda Avanzada</strong></a> 
                                            </span>
                                        </div>
                                        <?php include ('php_pos/forms_buscar.php');?> 
                                    </div>
                                </div> 
                            </div>
                            <center> <span id="loader"></span></center>
                            <div id="resultados"></div><!-- Carga los datos ajax -->
                            <div class='outer_div'></div><!-- Carga los datos ajax -->
                        </div>

                        <div class="tab-pane "></div>
                    </div>
                </div>
            </div>
        </div>
    </br></br></br>
    </div> <!-- /row -->
</div> <!-- /main --> 
<div class="modal fade" id="anular" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Anular</h4>
            </div>
            <div class="modal-body">
                <div id="form-anular"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
  
<div class="modal fade" id="abonar" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Abonar</h4>
            </div>
            <div class="modal-body">
                <div id="form-abonar"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
  
<div class="modal fade" id="cliente" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Modificar Cliente</h4>
            </div>
            <div class="modal-body">
                <div id="form-cliente"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
  
<div class="modal fade" id="modi-pago" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Modificar Metodo de Pago</h4>
            </div>
            <div class="modal-body">
                <div id="form-modificar_pago"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="detalle" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
    <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">&times;</button>
                <h4 class="modal-title">Detalle de Venta</h4>
            </div>
            <div class="modal-body">
                <div id="form-detalle"></div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<?php 
    include ('php_pos/forms_buscar.php');
	include ('php_caja/caja_abrir.php');
	include ('script.php');
?>
<script type="text/javascript" >
    
    $(document).ready(function(){
    load(1);
});

function load(page){
    var q= $("#q").val();
    var tipo='venta';

    $("#loader").fadeIn('slow');
    $.ajax({
        url:'php_pos/tabla.php?action=ajax&page='+page+'&q='+q+'&tipo='+tipo,
         beforeSend: function(objeto){
         $('#loader').html('<img src="./img/ajax-loader.gif"> Cargando...');
        },
        success:function(data){
          $(".outer_div").html(data).fadeIn('slow');
          $('#loader').html('');
        }
      })
    }
</script>
</body>
</html>
<?php
            }
            else
            {
                echo '<script>location.href = "P_pos_remision.php";</script>';
            }
        }
        else
        {
        echo '<script>alert("primero debes Abrir caja")</script>';
        echo '<script> setTimeout("history.back(1)", 0); </script>';
        }
    }
    else
    {
        echo '<script>alert("No tienes permiso para ver esta pagina")</script>';
        echo '<script> setTimeout("history.back(1)", 0); </script>';
    }
} 
else
{
    echo '<script>location.href = "index.php";</script>';
}
?>