<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
// ++
if(vbval($_SESSION['SYS_USER_GI'])!=USU_GET_GI($_SESSION['SYS_USER_ID'])){
	JsDir("cerrar.php");	
	return;
}
//	++
include("compras_buscar_.php");
include("compras_pdf.php");
//++
$LStrTR=gn("count(*)","vcompras",$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=100;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
$TI=0;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Compras - Buscar</title>
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script type="text/javascript" src="fe/compras_buscar.js"></script>
<script>
function fGenPDF(PDF){
	var emp=gv("CboEmp");
	var alm=gv("CboAlm");
	if(emp=="TODOS"){
		alert("Seleccione una empresa");
		jF("CboEmp");
		return;
	}
	if(alm=="TODOS"){
		alert("Seleccione un almacen");
		jF("CboAlm");
		return;
	}
	document.getElementById("TxtAc").value=PDF;
	document.getElementById("Frm").submit();
}


$(document).ready(function(){
   $("#TxtDex").mask("99-99-99");    
   $("#TxtHax").mask("99-99-99");    
});
</script>

<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<style type="text/css">
<!--
body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1100px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-550px";?>;
}
#Layer2 {
	position:absolute;
	left:409px;
	top:205px;
	width:82px;
	height:24px;
	z-index:1;
}
.Estilo1 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #FFFFFF;
}
.x2 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.x4 {
	color: #000099;
	text-align: right;
}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer3 .x2 table {
	font-weight: normal;
}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="compras_buscar.php">
 
<div class="s2" style="position:absolute; left: 30px; top: 159px; width: 1054px; height: 392px; overflow:auto">
<table id="Exportar_a_Excel" width="1035" height="19" border="1" cellpadding="0" cellspacing="0">

<tr>
<td height="18" colspan="8" bgcolor="#666666" align="center"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>           
</tr>

<tr>
<td width="72" bgcolor="#999999"><span class="x4"><b>EMPRESA</b></span></td>
<td width="75" bgcolor="#999999"><span class="x4"><b>ALMACEN</b></span></td>
<td width="97" bgcolor="#999999"><span class="x4"><b>COMPROBANTE</b></span></td>
<td width="119" bgcolor="#999999"><span class="x4"><b>SERIE-NUMERO</b></span></td>
<td width="111" bgcolor="#999999"><span class="x4"><b>DAM</b></span></td>
<td width="81" bgcolor="#999999"><span class="x4"><b>FECHA</b></span></td>
<td width="381" bgcolor="#999999"><span class="x4"><b>PROVEEDOR</b></span></td>
<td width="81" bgcolor="#999999" style="text-align:right"><span class="x4"><b>TOTAL</b></span></td>
</tr>
<?php		  		
$_TO=0;
$s="SELECT ID,ALMC,COM,NUM,DATE_FORMAT(FEC,'%d-%m-%y') as FECHA,SUBSTRING(PROV,1,34) AS PROV,
	TOT,EMPC,SER,DAM
	FROM vcompras WHERE $FF ORDER BY ALM,SER_,NUM_ ";
//echo $s;				
$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
$X2="</span></td>";	
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$result = grs($s);				
while ($row = $result->fetch_assoc()){
	echo "<tr 
	ondblclick=\"location.href='compras.php?Id=$row[ID]&Pag=0';\">";
	echo $X1.$row['EMPC'].$X2;
	echo $X1.$row['ALMC'].$X2;
	echo $X1.$row['COM'].$X2;
	echo "<td bgcolor=\"#FFFFFF\"><a target=\"_blank\" 
		  href=\"compras.php?Id=".$row['ID']."\">'".$row['SER']."-".$row['NUM']."</a></td>";
	echo $X1.$row['DAM'].$X2;
	echo $X1.$row['FECHA'].$X2;
	echo $X1.$row['PROV'].$X2;
	echo "<td bgcolor=\"#FFFFFF\"  style=\"text-align:right\">
	<span class=\"Estilo5\">".NF3($row['TOT']).$X2;
	echo "</tr>";
	$_TO=$_TO + $row['TOT'];
}
?>    
<tr>
<td width="72" bgcolor="#999999">&nbsp;</td>
<td width="75" bgcolor="#999999">&nbsp;</td>
<td width="97" bgcolor="#999999">&nbsp;</td>
<td width="119" bgcolor="#999999">&nbsp;</td>
<td width="111" bgcolor="#999999">&nbsp;</td>
<td width="81" bgcolor="#999999">&nbsp;</td>
<td width="381" bgcolor="#999999"><span class="x4"><b>TOTAL</b></span></td>
<td width="81" bgcolor="#999999" style="text-align:right"><span class="x4"><b><?php echo NF3($_TO);?></b></span></td>
</tr>     
</table>
</div>

<div class="s1" style="left: 29px; top: 557px; width: 706px;">
Doble Click sobre el registro para activar Actualizacion | <b> Los registros se muestran en forma descendente segun la fecha </b> </div>

<div style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
<div align="left" class="Estilo1">COMPRAS - BUSCAR
<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<input name="TxtAc" type="hidden" id="TxtAc" value="" />
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/> 
</div>
</div>

<div id="LblTit" style="position:absolute; left: 57px; top: 25px; width: 64px;">
<div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
</div>	

<div style="position:absolute; left: 32px; top: 113px; width: 76px;">
<div align="left" class="x2">EMPRESA</div>
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:29px; top:131px; width:90px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="<?php echo ++$TI;?>">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div style="position:absolute; left: 130px; top: 113px; width: 68px;">
<div align="left" class="x2">ALMACEN</div>
</div>
<select name="CboAlm" id="CboAlm" 
style="position:absolute; left: 130px; top: 130px; width:90px;" 
onkeydown="return SoloTextoEx(event,'CboCom');" tabindex="<?php echo ++$TI;?>">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div style="position:absolute; left: 231px; top: 113px; width: 102px;">
<div align="left" class="x2">COMPROBANTE</div>
</div>
<select name="CboCom" id="CboCom" 
style="position:absolute; left: 230px; top: 130px; width: 104px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');" tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO_("com_nombre","comprobantes","com_nombre IN ('FACTURA','BOLETA','CONTENEDOR')",$StrCom,"S","N");
?>
</select>


<div style="position:absolute; left: 344px; top: 113px; width: 74px;">
<div align="left" class="x2">SERIE</div>
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="position:absolute; left:344px; top: 130px; width: 54px;" 
value="<?php echo $StrSer;?>"  
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="<?php echo ++$TI;?>" />


<div style="position:absolute; left: 412px; top: 113px; width: 74px;">
<div align="left" class="x2">NUMERO</div>
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 410px; top: 130px; width: 64px;" value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDam');"
tabindex="<?php echo ++$TI;?>" />

<div style="position:absolute; left:483px; top: 113px; width: 74px;">
<div align="left" class="x2">DAM</div>
</div>
<input name="TxtDam" type="text" id="TxtDam" 
style="position:absolute; left: 482px; top: 130px; width: 66px;" value="<?php echo $StrDam;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="<?php echo ++$TI;?>" />

<div style="position:absolute; left: 563px; top: 96px; width: 45px;">
<div align="left" class="x2">DESDE</div>
</div>
<div class="EV" style="left: 556px; top: 114px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="position:absolute; left: 558px; top: 130px; width: 75px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$TI;?>" />


<div style="position:absolute; left: 640px; top: 96px; width: 60px;">
<div align="left" class="x2">HASTA</div>
</div>
<div class="EV" style="left: 639px; top: 114px; width: 88px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="position:absolute; left: 641px; top: 130px; width:68px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="<?php echo ++$TI;?>" />

<div style="position:absolute; left: 719px; top: 113px; width: 100px;">
<div align="left" class="x2">PROVEEDOR</div>
</div>
<input name="TxtPro" type="text" id="TxtPro" 
style="position:absolute; left: 719px; top: 130px; width: 123px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" 
tabindex="<?php echo ++$TI;?>" />


<div style="position:absolute; left: 849px; top: 113px; width: 75px;">
<div align="left" class="x2">ANULADO</div>
</div>
<select name="CboSN" id="CboSN" 
style="position:absolute; left: 850px; top: 130px; width: 62px;" 
onkeydown="return SoloTextoEx(event,'CboET');" tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$StrSN,"N","N");
?>
</select>

<div style="position:absolute; left: 924px; top: 98px; width: 67px; height: 30px;">
<div align="left" class="x2">EN TRANSITO</div>
</div>
<select name="CboET" id="CboET" 
style="position:absolute; left: 920px; top: 130px; width: 75px;" 
onkeydown="return SoloTextoEx(event,'CmdB');" tabindex="<?php echo ++$TI;?>">
<?php
echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$StrET,"N","N");
?>
</select>

<input name="CmdB" type="button"
style="position:absolute; left: 1003px; top: 130px; width: 57px;"
id="CmdB" value="Filtrar" onclick="fFiltrar();"  tabindex="<?php echo ++$TI;?>"/>


<div class="ps" style="left: 116px; top: 50px; width: 543px;">
<input name="CmdB" type="button" id="CmdB" class="bt"
value="Volver" onclick="fVolver('compras.php?TxtAc=X');"
tabindex="<?php echo ++$TI;?>" />

<input name="CmdPDF" type="button" id="CmdPDF" 
value="Generar PDF" onclick="fGenPDF('PDF_E');" 
tabindex="<?php echo ++$TI;?>" />
</div>



<?php
if(strlen($StrPDF1)>0){
echo "<div id=\"layer51\" 
	  style=\"position:absolute; left: 212px; top: 82px; 
	  width: 90px; background-color: #FFCC00; layer-background-color: #FFCC00; 
	  border: 1px none #000000; height: 17px;\">";
echo "<div align=\"center\" class=\"x2\"> ";
echo " <a href=\"$StrPDF1\" download>Descarga.PDF</a> ";
echo "</div>";
echo "</div>";
}
?>
</form>

<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 317px; top: 50px; width: 45px; height: 15px;">  
<input name="" type="button" class="botonExcel" value="Exportar" />
<input type="hidden" id="datos_a_enviar" name="datos_a_enviar" />
</div>
</form>

</div>
</body>
</html>
