<?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');?>

</head>
<body >
<?php
$inicio="";
$M_inventario="";
$M_contactos="";
$M_compras="";
$M_ventas="";
$M_pedidos="";
$M_pos="active";
$R_reportes="";

$ventas="";
$remisiones="";
$cajas="";
$apartadas="";
$orden="";
$movimientos="";
$periodica="";  
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">
                        <section id="buttons">
                            <div class="col-md-3">
                                <a href="#buscar" data-toggle="modal"   class="btn btn-primary"><i class="icon-search"></i> Buscar y Facturar</a>
                            </div>
                            <div class="col-md-3">
                                 <section id="intro" >
                                     <select name="estado" id="estado" class="form-control name_list input-sm" onchange='load(1);' >
                                        <option value="Pendiente">Pendiente</option>
                                        <option value="Confirmado">Confirmado</option>
                                        <option value="En Proceso">En proceso</option>
                                        <option value="Procesado">Procesado</option>
                                        <option value="Facturado">Facturado</option>
                                        <option value="Enviado">Enviado</option>
                                    </select>
                                </section>
                            </div>
                            <div class="col-md-3">
                                 <section id="intro" >
                                    <select  id="vende" class="form-control" onchange='load(1);'>
                                        <option value="0">VENDEDORES (TODOS)</option>
                                            <?php
                                                $datos=mysqli_query($con,"SELECT * FROM usuario WHERE  sucursal='$sucursal' and empresa_emp_id='$empresa' and usu_estado='Activo' and eliminado<>'si'") ;
                                                while( $fila = mysqli_fetch_array( $datos ) )
                                                {
                                                echo' <option value="'.$fila['usu_id'].'">'.$fila['usu_nombre'].'</option>';
                                                }
                                                ?>
                                    </select>
                                </section>
                            </div>
                            <div class="col-md-3">
                                <input type="text" class="form-control input-sm" id="q" placeholder="Buscador" onKeyUp='load(1);' autofocus value="">
                            </div>
                        </section>
                    </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></br></br></br>
    </div> <!-- /row -->
</div>


<div id="buscar" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <form method="get" action="P_facturar_lote2.php" >
                <div class="modal-body">
                    <div class="col-md-6" style="padding-left: 0px;">
                        <label class="pull-left">Fecha Desde</label>
                        <input type="date" class="form-control date-picker input-sm" value="<?php echo date('Y-m-d');?>" data-date-format="yyyy-mm-dd" name="fecha_desde">
                    </div>
                    <div class="col-md-6" style="padding-left: 0px;padding-right: 0px;">
                        <label class="pull-left">Hora Desde</label>
                        <input type="time" class="form-control input-sm" name="hora_desde" value="00:00:00">
                    </div>
                    <div class="col-md-6" style="padding-left: 0px;">
                        <label class="pull-left">Fecha Hasta</label>
                        <input type="date" class="form-control date-picker input-sm" value="<?php echo date('Y-m-d');?>" data-date-format="dd-mm-yyyy" name="fecha_hasta">
                    </div>
                    <div class="col-md-6" style="padding-left: 0px;padding-right: 0px;">
                        <label class="pull-left">Hora Hasta</label>
                        <input type="time" class="form-control input-sm" name="hora_hasta" value="23:59:59">
                    </div> 
                   
                    <label class="pull-left">Vendedor</label> 
                    <?php
                        $datos=mysqli_query($con,"SELECT * FROM usuario WHERE sucursal='$sucursal' and empresa_emp_id='$empresa' and eliminado<>'si' and usu_estado='Activo'") ;
                        while( $fila = mysqli_fetch_array($datos ))
                        { 
                    ?> 
                        <input name="vendedor[]" id="vendedor<?php echo $fila['usu_id']; ?>" type="checkbox" id="<?php echo $fila['usu_id']; ?>" class="" value="<?php echo $fila['usu_id']; ?>">
                        <label class="lab" for="vendedor<?php echo $fila['usu_id']; ?>" > <?php echo $fila['usu_nombre']; ?></label>
                    <?php } ?>

                    <label class="pull-left">Estado</label>
                    <select name="cot_estado" id="cot_estado" class="form-control name_list input-sm" required >
                        <option value="Pendiente">Pendiente</option>
                        <option value="Confirmado">Confirmado</option>
                        <option value="En Proceso">En proceso</option>
                        <option value="Procesado">Procesado</option>
                        <option value="Facturado">Facturado</option>
                        <option value="Enviado">Enviado</option>
                    </select>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
                        <button name="cot_buscar" value="cot_buscar" type="submit" class="btn btn-success"><i class="icon-search"></i> <strong>Buscar</strong></button>                            
                    </div>
                </div><!-- /.modal-content -->
            </form>
        </div><!-- /.modal-dialog -->
    </div>
</div>

<?php
    include ('php_caja/caja_abrir.php');
    include ('script.php');
?>
<script>
$(document).ready(function(){
  load(1);
});

function load(page)
{
var q= $("#q").val();
var vende= $("#vende").val();
var estado= $("#estado").val();
$("#loader").fadeIn('slow');
$.ajax({
    url:'./php_cotizaciones/tabla_cotizaciones_lote.php?action=ajax&page='+page+'&q='+q+'&vende='+vende+'&estado='+estado,
     beforeSend: function(objeto){
     $('#loader').html('<img src="./img/ajax-loader.gif"> Cargando...');
    },
    success:function(data){
      $(".outer_div").html(data).fadeIn('slow');
      $('#loader').html('');
    }
  })
}
</script>
<style>
.lab {
    font-weight: 600;
    color: #777777;
    margin-bottom: 8px;
    width: 100%;
    float: left;
    cursor: pointer;
    padding: 0 0.6em;
    box-sizing: border-box;
    background: #ccc;
    transition: all 0.5s ease 0s;
    float: right;
}

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"] + label {
    line-height: 3em;
}


input[type="checkbox"]:disabled + label {
    color: #ccc !important;
    cursor: not-allowed;
}
input[type="checkbox"]:checked:disabled + label:after {
    border-color: #ccc;
}

input[type="checkbox"] + label:before {
    content: "";
    width: 26px;
    height: 26px;
    float: left;
    margin-right: 0.5em;
    border: 2px solid red;
    background: #fff;
    margin-top: 0.5em;
}

input[type="checkbox"]:checked + label {
    background: #c1eec2;
}


input[type="checkbox"]:checked + label:after {
    content: "";
    width: 12px;
    height: 6px;
    border: 4px solid #0fbf12;
    float: left;
    margin-left: -1.95em;
    border-right: 0;
    border-top: 0;
    margin-top: 1em;
    transform: rotate(-55deg);
}

input[type="checkbox"]:checked + label:before {
    border-color: #0fbf12;
}

input[type="checkbox"]:checked:disabled + label {
    background: #ccc;
    color: #fff !important;
}

input[type="checkbox"]:checked:disabled + label:before {
    border-color: #bdbdbd;
}

@media (max-width: 650px) {
    .content {
        width: 100%;
    }
}
</style>
</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>';
}
?>