<?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')
           {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include ('head.php');?>
<script>
function miFuncion() {
    load(1);
}
 </script>
</head>
<body onload="miFuncion();">
<?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="widget stacked">
                    <div class="widget-content">
                        <div class="col-md-6"></div>
                        <div class="col-md-6">
                            <div class="input-group">
                                <input type="text" class="form-control" id="busc" placeholder="Buscador" onKeyUp='load(1);' value="" disabled>
                                <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> 
                    <?php 
                        if (isset($_GET['ven_id'])){ $ven_id=$_GET['ven_id'];} else  {  $ven_id=''; }
                        if (isset($_GET['desde'])){ $desde=$_GET['desde'];} else  {  $desde=''; }
                        if (isset($_GET['hasta'])){ $hasta=$_GET['hasta'];} else  {  $hasta=''; }
                        if (isset($_GET['factura'])){ $factura=$_GET['factura'];} else  {  $factura=''; }
                        if (isset($_GET['serial'])){ $serial=$_GET['serial'];} else  {  $serial=''; }
                        if (isset($_GET['clie_id'])){ $clie_id=$_GET['clie_id'];} else  {  $clie_id=''; }
                        if (isset($_GET['Cliente_clie_id'])){ $Cliente_clie_id=$_GET['Cliente_clie_id'];} else  {  $Cliente_clie_id=''; }
                    ?>
                    <input type="hidden" id="ven_id" value="<?php echo $ven_id;?>">
                    <input type="hidden" id="desde" value="<?php echo $desde;?>">
                    <input type="hidden" id="hasta" value="<?php echo $hasta;?>">
                    <input type="hidden" id="factura" value="<?php echo $factura;?>">
                    <input type="hidden" id="serial" value="<?php echo $serial;?>">
                    <input type="hidden" id="cliente" value="<?php echo $clie_id;?>">
                    <input type="hidden" id="Cliente_clie_id" value="<?php echo $Cliente_clie_id;?>">
                </div>  
                <center> <span id="loader"></span></center>
                <div id="resultados"></div>
                <div class='outer_div'></div>
            </div>
        </div>     </br></br></br>
    </div> <!-- /span6 -->        
</div> <!-- /main -->
<?php 
    include ('php_pos/forms_buscar.php');
    include ('php_caja/caja_abrir.php');
    include ('script.php');
?>
<script>
$(document).ready(function(){
  load(1);
});

function load(page){
var clie_id=$("#cliente").val();
var desde=$("#desde").val();
var hasta=$("#hasta").val();
var factura=$("#factura").val();
var serial=$("#serial").val();
var ven_id=$("#ven_id").val();
var Cliente_clie_id=$("#Cliente_clie_id").val();
$("#loader").fadeIn('slow');
$.ajax({
url:'./php_pos/tabla2.php?action=ajax&page='+page+'&clie_id='+clie_id+'&desde='+desde+'&hasta='+hasta+'&factura='+factura+'&serial='+serial+'&ven_id='+ven_id+'&Cliente_clie_id='+Cliente_clie_id,
 beforeSend: function(objeto){
 $('#loader').html('<img src="./img/ajax-loader.gif"> Cargando...');
},
success:function(data){
  $(".outer_div").html(data).fadeIn('slow');
  $('#loader').html('');
}
})
}
</script>

<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_modal" 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="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 -->

  </body>
</html>

<?php
      }
      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>';
  }
?>
