<?php
//
	$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']);		
	$Mot=V($_POST['Mot']);	
	$StrSer=V($_POST['TxtSer']);		
	$StrNum=V($_POST['TxtNum']);		
	$StrDex=V($_POST['TxtDex']);		
	$StrHax=V($_POST['TxtHax']);			
	$StrPro=V($_POST['TxtPro']);			
	$StrSN=V($_POST['CboSN']);
	//
	$ComR=V($_POST['CboComR']);
	$SerR=V($_POST['TxtSerR']);
	$NumR=V($_POST['TxtNumR']);
	//
	if(strlen($ComR)==0)$ComR="TODOS";
	//
	if(strlen($StrCom)==0)$StrCom="GUIA DE REMISION ELECTRONICA";	
	if(strlen($Mot)==0)$Mot="TODOS";		
	//++
	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(strlen($StrSN)==0)$StrSN="NO";
	$StrSN_=substr($StrSN,0,1);
	$StrNum_=$StrNum."%";
	$StrSer_=$StrSer."%";
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrPro_=$StrPro."%";
	//------------------------
	$StrCom_=LIKE($StrCom);
	$Mot_=LIKE($Mot);
	//-------------------------
	$FF="ID>0 AND EMPC LIKE '$StrEmp_' AND ALM LIKE '$StrAlm_' AND 
		 SER LIKE '$StrSer_' AND 
		 NUM LIKE '$StrNum_' AND FEC >= '$StrDex_' AND 
		 FEC <= '$StrHax_' AND DES_RS LIKE '$StrPro_' AND 
		 ANU LIKE '$StrSN_' AND TIP_GIA LIKE '$StrCom_' AND MOTIVO LIKE '$Mot_' ";
	if($ComR!="TODOS"){
		$FF=$FF." AND COMR='$ComR' ";
	}
	if(vbval($SerR)>0){
		$FF=$FF." AND SERR_=".vbval($SerR);
	}
	if(vbval($NumR)>0){
		$FF=$FF." AND NUMR_=".vbval($NumR);
	}
?>