<?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='19' and usuario_usu_id='$usu_id'") or die(mysqli_error($con));
    $reg=mysqli_fetch_array($regis);
    if($reg['per_visualizar']=="Activo")
    {
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <?php include ('head.php'); ?>
</head>
<body>
<?php
$inicio="";
$M_inventario="";
$M_contactos="";
$M_compras="";
$M_ventas="active";
$M_pedidos="";
$M_pos="";
$R_reportes="";

$cotizacion="active";
$ventas="";
$periodica="";
$clientes="";
$cartera="";
$garantias="";
$abonos="";
$cotizacion_online="";


include ('menu.php');
?> 
<div class="main">
    <div class="col-md-2"> 
        <?php include ('include/menu_ventas.php');?>
    </div> <!-- /span6 -->
    <div class="col-md-10">
        <div class="widget stacked">
            <div class="widget-content">
                <?php //include ('php_cotizaciones/editar_cliente.php'); ?>
                <div class="widget stacked">
                    <div class="widget-content">
                        <section id="buttons">
                            <div class="col-md-6">
                                <a class="btn btn-danger" href="V_cotizaciones.php"> <i class="fas fa-angle-double-left"></i> Atras</a>
                            </div>
                            <div class="col-md-3">
                                <input id="q" type="text" class="form-control"  placeholder="Buscador" onkeyup='load(1);' autofocus>
                            </div>
                            <div class="col-md-3">
                                <section id="intro" >
                                    <select name="cliente" id="cliente" class="form-control name_list" onchange="load(1);" required>
                                    <option value='0'>TODOS</option>
                                        <?php
                                            $result_1 = mysqli_query($con,"SELECT * FROM  cliente WHERE  clie_cotizar='1'");  
                                            while ($row_1=mysqli_fetch_array($result_1)) 
                                            {   
                                                echo "<option value='".$row_1['clie_id']."' >".utf8_encode($row_1['clie_nombre'])."</option>"; 
                                            }  
                                            ?>
                                    </select>
                                </section>
                            </div>
                        </section>
                    </div> <!-- /widget-content -->
                </div> <!-- /widget --> 
                <div class="table-responsive">
                    <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> <!-- /widget-content -->
        </div> <!-- /span6 -->
    </div> <!-- /row -->
</div> 
<script >
$(document).ready(function(){
  load(1);
});

function load(page){
    var q= $("#q").val();
    var cliente= $("#cliente").val();
    $("#loader").fadeIn('slow');
    $.ajax({
        url:'php_cotizaciones/asesores_tabla_cotizaciones.php?action=ajax&page='+page+'&q='+q+'&cliente='+cliente,
         beforeSend: function(objeto){
         $('#loader').html('<img src="./img/ajax-loader.gif"> Cargando...');
        },
        success:function(data){
          $(".outer_div").html(data).fadeIn('slow');
          $('#loader').html('');
        }
    })
}
</script>   
<?php
    include ('php_caja/caja_abrir.php');
    include ('script.php');
?>
</body>
</html>
<?php
}
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>';
}
?>