<?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;
}
//+++++
	$IdU=vbval($_SESSION['SYS_USER_ID']);
	$PRO_ID_ALM=gn("pro_id_alm","usuarios","id_usuario=$IdU");
	//
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrEmp=V($_POST['CboEmp']);		
	$StrAlm=V($_POST['CboAlm']);				
	$StrCom=V($_POST['CboCom']);		
	$StrSer=V($_POST['TxtSer']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrPro=V($_POST['TxtPro']);
	$StrSN=V($_POST['CboSN']);	
	$StrGen=V($_POST['CboGen']);	
	$Pag=V($_POST['Pag']);	
	$StrPse=V($_POST['TxtPse']);			
	$StrPnu=V($_POST['TxtPnu']);
	$CobMod=V($_POST['CobMod']);
	$CobObs=V($_POST['CobObs']);
	//
	if(strlen($CobMod)==0)$CobMod="TODOS";
	if(strlen($CobObs)==0)$CobObs="TODOS";
	/*
	if(strlen($StrDex)==0)$StrDex=HACE_UN_MES();
	if(strlen($StrHax)==0)$StrHax=HOY();
	*/
	$CobMod_=LIKE($CobMod);
	$CobObs_=LIKE($CobObs);
	//
	if($PRO_ID_ALM==0){
		if(strlen($StrEmp)==0)$StrEmp=GE("S");
		if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"S");	
	}else{
		$StrEmp=gs("ENC","vis_almacenes","IDA=$PRO_ID_ALM");
		$StrAlm=gs("ANC","vis_almacenes","IDA=$PRO_ID_ALM");
	}
	$StrEmp_=LIKE($StrEmp);
	$StrAlm_=LIKE($StrAlm);
	//-------------------------
	if($StrCom=="TODOS" || strlen($StrCom)==0){
		$StrCom_="%";
	}else{
		$StrCom_=$StrCom;
	}
	$StrNum_=$StrNum."%";
	$StrSer_=$StrSer."%";
	if(strlen($StrDex)==0){
		$StrDex_="2000-01-01";
	}else{
		$StrDex_=ToDate($StrDex);
	}
	if(strlen($StrHax)==0){
		$StrHax_="2030-12-01";//
	}else{
		$StrHax_=ToDate($StrHax);
	}
	if(strlen($StrSN)==0 || $StrSN=="TODOS"){
		$StrSN_="%";
	}else{
		$StrSN_=substr($StrSN,0,1);
	}
	if(strlen($StrGen)==0 || $StrGen=="TODOS"){
		$StrGen_="%";
	}else{
		$StrGen_=substr($StrGen,0,1);
	}
	if(strlen($Pag)==0 || $Pag=="TODOS"){
		$Pag_="%";
	}else{
		$Pag_=$Pag;
	}
	
	$StrPro_=$StrPro."%";
	$StrPse_="%".$StrPse;
	$StrPnu_="%".$StrPnu;
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND ALM LIKE '$StrAlm_' AND COM LIKE '$StrCom_' AND
		 NUM LIKE '$StrNum_' AND SER LIKE '$StrSer_' AND 
		 FEC >= '$StrDex_' AND FEC <= '$StrHax_' AND 
		 CLI LIKE '$StrPro_' AND ANU LIKE '$StrSN_' AND 
		 COT_SER  LIKE '$StrPse_' AND COT_NUM LIKE '$StrPnu_' AND 
		 GEN LIKE '$StrGen_' AND COB_PAG LIKE '$Pag_' AND 
		 COB_MODA LIKE '$CobMod_' AND COB_OBS LIKE '$CobObs_' ";
	//-------------------------
$LStrTR=gn("count(*)","vventas",$FF);
$LStrPag=V($_POST['TxtPag']);
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=23;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
?>
<!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>Ventas - Buscar</title>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/funcionez.js"></script>
<script>
$(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();
});
});
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>
<style type="text/css">
<!--

body {
	background-color: #CCC;
}
#Layer1 {
	position:absolute;
	left:345px;
	top:115px;
	width:123px;
	height:35px;
	z-index:1;
}
.centrarFrm{
	width:1250px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-625px";?>;
}
#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; color: #FFFFFF; font-size: 12px; }
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.s4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="ventas_buscar.php">

  

   
        <input name="CmdV" type="button" id="CmdV" 
        style="position:absolute; left: 79px; top: 50px; width: 85px;"
		value="Volver" onclick="fVolver('ventas.php?TxtAc=X');" />
 
<div id="layer3" style="position:absolute; left: 13px; top: 137px; width: 1218px; height: 415px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1204" height="19" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="14" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
</tr>
<tr>
<td width="104" bgcolor="#999999" style="color:#000">EMP / ALM</td>
<td width="92" nowrap="nowrap" style="color:#000"bgcolor="#999999">COMPROBANTE</td>
<td width="78" bgcolor="#999999" style="color:#000">NUMERO</td>
<td width="72" bgcolor="#999999" style="color:#000">FECHA</td>
<td width="306" bgcolor="#999999" style="color:#000">CLIENTE</td>            
<td width="72" bgcolor="#999999" style="color:#000" align="right">TOTAL</td>
<td width="96" bgcolor="#999999" style="color:#000">PROF../..CONTE..</td>
<td width="25" bgcolor="#999999"  style="color:#000">ANU</td>
<td width="26" bgcolor="#999999"  style="color:#000">GEN</td>
<td width="26" bgcolor="#999999"  style="color:#000">COB</td>
<td width="69" bgcolor="#999999"  style="color:#000">COB.ASI</td>
<td width="81" bgcolor="#999999"  style="color:#000">C.MODALIDAD</td>
<td width="96" bgcolor="#999999"  style="color:#000">COB.OBS</td>

<td width="31" bgcolor="#999999" align="center"  style="color:#000">#</td>
</tr>
<?php		  		
	$StrPRO="";
	$s="SELECT ID,ALM,COM,CONCAT(SER,'-',NUM),DATE_FORMAT(FEC,'%d-%m-%y'),
	    SUBSTRING(CLI,1,45),ROUND(TOT,2),
		ROUND(ACU,2),ANU,VEN_ID_VEN,EMPC,VEN_COM_REF,COT_SER,COT_NUM,GEN,COB_PAG,COB_FEC_ , COB_MODA,COB_OBS 
		FROM vventas WHERE ".$FF." ORDER BY ID ";

	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		if($row[16]=="01-01-00")$row[16]="";
		if($row[9]>0){
			$StrPRO=substr($row[11],0,1)." ".$row[12]."-".$row[13];
		}else{
			$StrPRO="";
		}
		echo "<tr ondblclick=\"location.href='ventas.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[10]." / ".$row[1].$X2;
		echo $X1.$row[2].$X2;
		//echo $X1.$row[3].$X2;
		echo "<td bgcolor=\"#FFFFFF\"><a target=\"_blank\" href=\"ventas.php?Id=$row[0]\">'$row[3]</a></td>";
		echo $X1.$row[4].$X2;
		echo $X1.$row[5].$X2;
		echo $X1B.NF3($row[6]).$X2;
		echo $X1.$StrPRO.$X2;
		echo $X1.$row[8].$X2;
		echo $X1.$row[14].$X2;
		echo $X1.$row[15].$X2;
		echo $X1.$row[16].$X2;
		echo $X1.$row[17].$X2;
		echo $X1.$row[18].$X2;
	?>    
		<td bgcolor="#FFFFFF"><input name="" type="button"  style="display:none" value="Ver" onclick="fVer('<?php echo $row[0]?>')" /></td>
    <?php
		echo "</tr>";
	}

?>		  

</table>
<script>
function fVer(id){
	alert(id);
}
</script>
    </div>
  </div>
    <div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">VENTAS - 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>	
    
<input name="CmdB" type="button" id="CmdB" style="position:absolute; left: 1122px; top: 109px; width: 57px;" value="Filtrar" onclick="fFiltrar();" />

<div class="s1" style="left:751px; top: 9px; width:473px"><b>COBRO OBSERVACION</b> : - = SIN OBSERVACION | CALCULADO = VERIFICADO POR EL SISTEMA | REPARAR = OBSERVACION GENERADA POR EL SISTEMA | REPARADO = CORREGIDO/EDITADO POR EL USUARIO</div> 
     
<div class="s1" style="left:13px; top: 89px;">EMPRESA</div>  
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:13px; top:109px; width: 66px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 
?>
</select>

<div class="s1" style="left: 91px; top: 89px;">ALMACEN</div>    
<select name="CboAlm" id="CboAlm" style="left: 88px; top: 109px; width: 83px;"  tabindex="2"
onkeydown="return SoloTextoEx(event,'CboCom');">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");
?>
</select>

<div class="s1" style="left: 184px; top: 76px;">COMPRO -<br>
BANTE</div>    
<select name="CboCom" id="CboCom"  tabindex="3"
style="left: 182px; top: 109px; width: 65px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');">
<?php
echo FCBO_("com_nombre","comprobantes",
"id_comprobante>0 AND com_nombre IN ('FACTURA','BOLETA','FACT. ELEC.','BOL. ELEC.') ",$StrCom,"S","N");
?>
</select>

<div id="layer15" style="position:absolute; left: 257px; top: 90px; width: 41px;">
<div align="left" class="f2">SERIE</div>
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="position:absolute; left: 257px; top: 109px; width: 36px;" 
value="<?php echo $StrSer;?>"  onblur="_S(this);" maxlength="4"
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="4" />

<div id="layer6" style="position:absolute; left: 311px; top: 90px; width: 65px;">
<div align="left" class="f2">NUMERO</div>
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 309px; top: 109px; width: 54px;" 
value="<?php echo $StrNum;?>"   maxlength="5"
onkeydown="return SoloTextoEx(event,'TxtDex');"  onblur="_N(this);"
tabindex="5" />

<div id="layer7" style="position:absolute; left: 378px; top: 74px; width: 73px;">
<div align="left" class="f2">DESDE</div>
</div>
<div class="EV" style="left: 377px; top: 89px; width: 76px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy)</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="position:absolute; left: 377px; top: 109px; width:66px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="6" />

<div id="layer11" style="position:absolute; left: 453px; top: 71px; width: 89px;">
<div align="left" class="f2">HASTA</div>
</div>
<div class="EV" style="left: 456px; top: 89px; width: 70px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy)</a></u></div> 
<input name="TxtHax" type="text" id="TxtHax" 
style="position:absolute; left: 456px; top: 110px; width:66px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="7" />


<div id="layer10" style="position:absolute; left: 536px; top: 90px; width: 66px;">
<div align="left" class="f2">CLIENTE</div>
</div>
<input name="TxtPro" type="text" id="TxtPro" 
style="position:absolute; left: 535px; top: 110px; width: 72px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboGen');" 
tabindex="8" />


<div id="layer20" style="position:absolute; left:623px; top: 77px; width: 52px; height: 25px;">
<div align="left" class="f2">GENE-<br>RADO</div>
</div>
<select name="CboGen" id="CboGen" 
style="position:absolute; left:623px; top: 110px; width: 55px;" 
onkeydown="return SoloTextoEx(event,'CboSN');" tabindex="9">
<?php
if($StrGen=="" || $StrGen=="TODOS"){
	AD("TODOS",1);AD("NO",0);AD("SI",0);
}
if($StrGen=="NO"){
	AD("TODOS",0);AD("NO",1);AD("SI",0);
}
if($StrGen=="SI"){
	AD("TODOS",0);AD("NO",0);AD("SI",1);
}

?>
</select>


<div id="layer20" style="position:absolute; left: 691px; top: 77px; width: 44px;">
<div align="left" class="f2">ANU-<br>LADO</div>
</div>
<select name="CboSN" id="CboSN" 
style="position:absolute; left: 690px; top: 110px; width: 51px;" 
onkeydown="return SoloTextoEx(event,'Pag');" tabindex="10">
<?php
if($StrSN=="" || $StrSN=="TODOS"){
AD("TODOS",1);AD("NO",0);AD("SI",0);
}
if($StrSN=="NO"){
AD("TODOS",0);AD("NO",1);AD("SI",0);
}
if($StrSN=="SI"){
AD("TODOS",0);AD("NO",0);AD("SI",1);
}

?>
</select>

<div id="layer20" style="position:absolute; left: 754px; top: 77px; width: 50px;">
<div align="left" class="f2">COBRA<br>DO</div>
</div>
<select name="Pag" id="Pag" style="position:absolute; left:753px; top: 110px; width: 58px;" 
onkeydown="return SoloTextoEx(event,'CobMod');"  tabindex="11">
<?php
if($Pag=="" || $Pag=="TODOS"){
	AD("TODOS",1);AD("NO",0);AD("SI",0);
}
if($Pag=="NO"){
	AD("TODOS",0);AD("NO",1);AD("SI",0);
}
if($Pag=="SI"){
	AD("TODOS",0);AD("NO",0);AD("SI",1);
}

?>
</select>

<div class="s1" style="left: 821px; top: 78px;">COBRO<br>
MODALIDAD</div>    
<select name="CobMod" id="CobMod" 
style="left: 822px; top: 111px; width: 68px;" 
onkeydown="return SoloTextoEx(event,'CobObs');" tabindex="12">
<?php
echo FCBO("au_item","auxiliar","au_tab='COB_MODA'",$CobMod,"S","N");
?>
</select>

<div class="s1" style="left:901px; top: 78px;">*COBRO<br>
OBSERVACION</div>    
<select name="CobObs" id="CobObs" 
style="left: 904px; top: 111px; width: 74px;" 
onkeydown="return SoloTextoEx(event,'TxtPse');"  tabindex="13">
<?php
echo FCBO("au_item","auxiliar","au_tab='COB_OBS'",$CobObs,"S","N");
?>
</select>



<div class="s1" style="left: 994px; top: 70px; width:188px">PROFORMA / CONTENEDOR</div>    
<div class="s1" style="left: 994px; top: 88px;">SERIE</div>    
<input name="TxtPse" type="text" id="TxtPse" 
style="left: 994px; top: 109px; width: 47px;" value="<?php echo $StrPse;?>"  
onkeydown="return SoloTextoEx(event,'TxtPnu');" onblur="_S(this);"
tabindex="14" />

<div class="s1" style="left: 1052px; top: 88px;">NUMERO</div>    
<input name="TxtPnu" type="text" id="TxtPnu" 
style="left: 1051px; top: 109px; width: 62px;" value="<?php echo $StrPnu;?>"  
onkeydown="return SoloTextoEx(event,'CmdB');"  onblur="_N(this);"
tabindex="15" />


  
</form>

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