<?php
session_start();
if (!isset($_SESSION['user_login_status']) AND $_SESSION['user_login_status'] != 1) 
{
	header("location: login.php");
	exit;
}
	require_once ("config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
	require_once ("config/conexion.php");//Contiene funcion que conecta a la base de datos
	include("modal/estado_cuenta_cli.php");
	
	
	$active_facturas="active";
	$active_productos="";
	$active_clientes="";
	$active_usuarios="";	
	$title="Facturas Anuladas | FONTUR";
?>
<!DOCTYPE html>
<html lang="en">

  <head>
	<?php include("head.php");?>
  </head>
  <body onLoad="redireccionar()">
	<?php
	include("navbar.php");
	?>  
    <div class="container" style="width:98%">
		<div class="panel panel-info">
			<div class="panel-heading">
		    	<div class="btn-group pull-right">
            		<a href="facturas.php" class="btn btn-info"><span class="glyphicon glyphicon--arrow-left" ></span> ATRAS</a>
				</div>
		    		
			
		<h4><i class='glyphicon glyphicon-search'></i> Buscar Facturas Anuladas <?php echo $_SESSION['estado']?></h4>
		</div>
		<div class="panel-body">
            	<form class="form-horizontal" role="form" id="datos_cotizacion">
				
						<div class="form-group row">
							<label for="q" class="col-md-1 control-label">Dato a buscar</label>
							<div class="col-md-3">
								<input type="text" class="form-control" id="q" placeholder="Factura, Cliente, Rif(Cedula)" onkeyup='load(1);'>
							</div>
							<?php if($_SESSION['rol']=="gerencia" || $_SESSION['estado']==""){?>
							<label for="q" class="col-md-1 control-label">Tienda</label>
							<div class="col-md-3">
								<select class="form-control" id="est" name="est" onChange="load(1), show()"/>
	 			          			<option value="">Consolidado</option>
									<?php 
              						$count_query= mysqli_query($con, "SELECT * FROM `tiendas`");
		     						while($dato= mysqli_fetch_array($count_query))
									{
			 							$tienda=$dato['nombre'];
										$id_tienda=$dato['id_tienda'];
			  							?>
                  						<option value="<?php echo $id_tienda; ?>"><?php echo $tienda; ?></option>
                  					<?php 
									}	 
						  			?>
                          		</select> 
							</div>
							<div id="lug" class="col-md-3" style="display:none;">
								<select class="form-control" id="lugar" name="lugar" onchange='load(1);'/>
	 			          			<option value="">---Seleccione un Lugar---</option>
									<?php 
              						$count_query2= mysqli_query($con, "SELECT * FROM `facturas` where `almacen`='Operativos' GROUP BY `lugar`");
		     						while($dato2= mysqli_fetch_array($count_query2))
									{
			 							$lugar=$dato2['lugar'];
			  							?>
                  						<option value="<?php echo $lugar; ?>"><?php echo $lugar; ?></option>
                  					<?php 
									}	 
						  			?>
                          		</select> 
							</div>
							<?php 
							}	 
						  	?>
							
						</div>
				
				
				
			</form>
			
            	<div id="resultados"></div><!-- Carga los datos ajax -->
				<div class='outer_div'></div><!-- Carga los datos ajax -->
			</div>
		</div>	
		
	</div>
	<hr>
	<?php
	include("footer.php");
	?>
	<script type="text/javascript" src="js/VentanaCentrada.js"></script>
	<script type="text/javascript" src="js/facturas_anuladas.js"></script>
   
  </body>
</html>

<script>

	
		function show()
				{
					getSelectValue = document.getElementById("est").value;
					
  					if(getSelectValue=="Operativos")
					{
						document.getElementById("lug").style.display = "inline-block";
						
					}
  					else
					{
    					document.getElementById("lug").style.display = "none";  
    					
   					}
  					
				}
	</script>