<?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("guias_buscar_fun.php");
include("guias_pdf.php");
$LStrTR=gn("count(*)","vguias",$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=500;	
$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>Guias - Buscar</title>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<?php AddJs();?>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script>
$(document).ready(function(){  
   Inicializar();
});
//----------------------------
function fGenPDF(){
	var emp=gv("CboEmp");
	var alm=gv("CboAlm");
	if(jL(emp)==0){
		alert("Seleccione una empresa");
		jF("CboEmp");return;
	}
	if(jL(alm)==0){
		alert("Seleccione un almacen");
		jF("CboAlm");return;
	}
	document.getElementById("TxtAc").value="GEN_PDF_2";
	document.getElementById("Frm").submit();
}
//
function EM_OC(){	
	var Emp=gv("CboEmp");	
	var r=AX("03",Emp);
	if(r=="X"){
		CBO_CLS("CboAlm",1);
	}else{
		CBO_FILL("CboAlm",r,0);
	}
}

</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>
<script>
$(document).ready(function(){
$("#TxtDex").mask("99-99-99");
$("#TxtHax").mask("99-99-99");
});
</script>
<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 -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;
}
.f2 {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;
}
.x5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="guias_buscar.php" autocomplete="off">
<div id="layer5" style="position:absolute; left: 79px; top: 50px; width: 160px; height: 28px;">
<div align="left" class="f2">
<input name="CmdV" type="button" id="CmdV" 
value="Volver" onclick="fVolver('guias.php?TxtAc=X');" tabindex="<?php echo ++$TI;?>" />

<input name="CmdPDF" type="button" id="CmdPDF" 
value="Generar PDF" onclick="fGenPDF();"  
tabindex="<?php echo ++$TI;?>" />
</div>
</div>
<div id="layer3" 
style="position:absolute; left: 25px; top: 150px; width: 1051px; height: 398px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1018" height="19" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="18" colspan="10" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
           
</tr>
<tr>
<td width="111" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">EMP/ALM</span></td>
<td width="70" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">COMP.</span></td>
<td width="114" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">NUMERO</span></td>
<td width="42" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">FECHA</span></td>
<td width="279" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">DESTINATARIO</span></td>
<td width="127" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">RUC</span></td>
<td width="105" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">MOTIVO</span></td>
<td width="52" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">REF.</span></td>
<td width="46" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">R.SER</span></td>
<td width="50" bgcolor="#999999" style="white-space: nowrap;"><span class="x4">R.NUM</span></td>
</tr>
<?php		  			
	$s="SELECT ID,ALM,'GUIA' as COM,
		CONCAT(SER,'-',NUM) AS SER,
		DATE_FORMAT(FEC,'%d-%m-%y'),
		SUBSTRING(DES_RS,1,40),
		DES_RUC,EMPC,MOTIVO,COMR,SERR,NUMR
		FROM vguias 
		WHERE $FF ORDER BY ALM,SER,NUM,FEC,DES_RS ";
	
	$X1="<td bgcolor=\"#FFFFFF\" style=\"white-space: nowrap;\" ><span class=\"x5\" >";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><span class=\"x5\">";
	$X2="</span></td>";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		echo "<tr ondblclick=\"location.href='guias.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[7]." / ".$row[1].$X2;
		echo $X1.$row[2].$X2;
		//echo $X1.$row[3].$X2;
		echo "<td bgcolor=\"#FFFFFF\" style=\"white-space: nowrap;\"><a target=\"_blank\" href=\"guias.php?Id=$row[0]\">'$row[3]</a></td>";
		echo $X1.$row[4].$X2;
		echo $X1.$row[5].$X2;
		echo $X1.$row[6].$X2;
		echo $X1.$row[8].$X2;
		echo $X1.$row[9].$X2;
		echo $X1.$row[10].$X2;
		echo $X1.$row[11].$X2;
		echo "</tr>";
	}
?>		  
         
         
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">GUIAS - 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: 20px; top: 25px; width: 64px;">
    <div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
  </div>	

<div class="s1" style="left:25px; top: 105px; width: 105px;">
EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:25px; top:121px; width: 75px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="<?php echo ++$TI;?>">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div class="s1" style="left: 109px; top: 105px; width: 82px;">
ALMACEN
</div>
<select name="CboAlm" id="CboAlm" 
style="left: 109px; top: 121px; width: 76px;" 
onkeydown="return SoloTextoEx(event,'CboCom');" tabindex="<?php echo ++$TI;?>">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div class="s1" style="left: 192px; top: 105px; width: 103px;">
COMPROBANTE
</div>
<select name="CboCom" id="CboCom"  tabindex="<?php echo ++$TI;?>"
style="left: 191px; top: 121px; width: 97px;" 
onkeydown="return SoloTextoEx(event,'Mot');">
<?php
echo FCBO("com_nombre","comprobantes","id_comprobante IN (7,8)",$StrCom,"S","N");
?>
</select>


<div class="s1" style="left:297px; top: 105px; width: 103px;">
MOTIVO
</div>
<select name="Mot" id="Mot" tabindex="<?php echo ++$TI;?>"
style="left: 297px; top: 121px; width: 62px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');">
<?php
echo FCBO("mot_des","gdr_motivos","id_mot>0 AND mot_lis=1 AND mot_des IN ('VENTA','OTROS','CONSIGNACION')",$Mot,"S","N");
?>
</select>




<div class="s1" style="left: 368px; top: 105px; width: 57px;">
SERIE
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="left: 369px; top: 121px; width: 48px;" 
value="<?php echo $StrSer;?>"  onblur="_S(this);"
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 427px; top: 105px; width: 65px;">
NUMERO</div>
<input name="TxtNum" type="text" id="TxtNum"
onblur="_N(this);"
style="left: 428px; top: 121px; width: 61px;" value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 501px; top: 89px; width: 68px;">
DESDE
</div>
<div class="EV" style="left: 501px; top: 104px; width: 75px; color:#FF0">
<u><a onclick="fFecServer('TxtDex')">(dd-mm-yy)</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="left: 500px; top: 121px; width: 67px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left:581px; top: 91px; width: 71px;">
HASTA
</div>
<div class="EV" style="left:581px; top: 104px; width: 82px; color:#FF0">
<u><a onclick="fFecServer('TxtHax')">(dd-mm-yy)</a></u></div>

<input name="TxtHax" type="text" id="TxtHax" 
style="left: 581px; top: 121px; width: 67px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 659px; top: 87px; width: 67px;">
DESTI- NATARIO
</div>
<input name="TxtPro" type="text" id="TxtPro" 
style="left: 659px; top: 121px; width: 68px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 739px; top: 105px; width: 69px;">
ANULADO
</div>
<select name="CboSN" id="CboSN" tabindex="<?php echo ++$TI;?>"
style="position:absolute; left: 739px; top: 121px; width: 60px;" 
onkeydown="return SoloTextoEx(event,'CboComR');">
<?php
	if($StrSN=="" || $StrSN=="NO"){
		AD("NO",1);	AD("SI",0);
	}else{
		AD("NO",0);	AD("SI",1);
	}
?>
</select>


<div class="s1" style="left: 808px; top: 87px; width: 70px;">
REFE- RENCIA
</div>
<select name="CboComR" id="CboComR" tabindex="<?php echo ++$TI;?>"
style="left: 809px; top: 121px; width: 70px;" 
onkeydown="return SoloTextoEx(event,'TxtSerR');">
<?php
echo FCBO("com_nombre","comprobantes","id_comprobante<>0",$ComR,"S","N");
?>
</select>


<div class="s1" style="left: 888px; top: 105px; width: 57px;">
SERIE
</div>
<input name="TxtSerR" type="text" id="TxtSerR" 
style="left: 887px; top: 121px; width: 42px;" 
value="<?php echo $SerR;?>"  
onkeydown="return SoloTextoEx(event,'TxtNumR');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 943px; top: 105px; width: 57px;">
NUMERO
</div>
<input name="TxtNumR" type="text" id="TxtNumR" 
style="left: 943px; top: 121px; width: 48px;" 
value="<?php echo $NumR;?>"  
onkeydown="return SoloTextoEx(event,'CmdB');"
tabindex="<?php echo ++$TI;?>" />



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

<div class="s1" style="left: 23px; top: 559px; width: 166px;">Doble Click sobre el registro para activar Actualizacion </div>

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

</form>

<form action="ficheroExcel.php" method="post" target="_blank" id="FormularioExportacion" >
<div style="position:absolute; left: 242px; 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>
