<?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;
}
	$TI=0;
	//-------------------------
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrEmp=V($_POST['CboEmp']);
	$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']);
	$StrCod=V($_POST['TxtCod']);		
	$StrDes=V($_POST['TxtDes']);		
	$StrMar=V($_POST['TxtMar']);				
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("N");
	//
	if(strlen($StrCom)==0)$StrCom="PROFORMA";
	if(strlen($StrSN)==0) $StrSN="NO";	
	$StrSN_=substr($StrSN,0,1);
	$StrCod_=$StrCod."%";
	$StrDes_=$StrDes."%";
	$StrMar_=$StrMar."%";
	//-------------------------
	$StrNum_=$StrNum."%";
	$StrSer_=$StrSer."%";
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrPro_=$StrPro."%";
	//-------------------------

if($StrCom=="PROFORMA"){	
	$FF="ID>0 AND NUM LIKE '$StrNum_' AND 
         SER LIKE '$StrSer_' AND FEC >= '$StrDex_' AND 
         FEC <= '$StrHax_' AND 
		 CLI LIKE '$StrPro_' AND 
		 DES LIKE '$StrDes_' AND 
		 LINEA LIKE '$StrMar_' AND COD LIKE '$StrCod_' AND 
		 (CA_CONTROL - DEJA)>0 and ANU='N' AND PRI_='1' AND EMPC='$StrEmp'";
	$TAB="vcot_sal_pen";
}else{
	$FF="ID>0 AND NUM LIKE '$StrNum_' AND 
         SER LIKE '$StrSer_' AND FEC >= '$StrDex_' AND 
         FEC <= '$StrHax_' AND 
		 CLI LIKE '$StrPro_' AND 
		 DES LIKE '$StrDes_' AND 
		 LINEA LIKE '$StrMar_' AND COD LIKE '$StrCod_' AND 
		 (CA_CONTROL - DEJA)>0 and ANU='N' AND PRI_=1 
		 AND COM='$StrCom' AND EMPC='$StrEmp' ";
	$TAB="vven_sal_pen";
}

$LStrTR=gn("count(*)",$TAB,$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=1000;	
$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>Salidas - Pendientes</title>
<!--CSS_NEW------------------------------------->
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<!--CSS_NEW------------------------------------->
<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/funciones.js"></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:1200px;
	height:600px;
	position:absolute;
	left:<?php echo "50%";?>;
	top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-600px";?>;
}
#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;}
.eS4 {color: #000099}
.Estilo5 {color: #000000}

-->
</style>

</head>
<body  <?php echo $StrMsg;?>>
<div Id="DivFRM"  class="centrarFrm" >
<form id="Frm" name="Frm" method="post" action="cotizaciones_pendientes.php">
<input name="TxtAc" type="hidden" value="" id="TxtAc" />
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>
<div id="layer5" style="position:absolute; left: 79px; top: 50px; width: 85px; height: 28px;">
<div align="left" class="f2">
<input name="CmdV" type="button" id="CmdV" 
value="Volver" onclick="fVolver('menu.php');" />
</div>
</div>

<div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
<div align="left" class="Estilo1">SALIDAS - PENDIENTES</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: 107px;">
EMPRESA
</div>
<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:23px; top:123px; width: 111px;" 
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"N","N"); 
?>
</select>

<div class="s1" style="left:147px; top: 105px; width: 103px;">
COMPROBANTE
</div>
<select name="CboCom" id="CboCom" style="position:absolute; left: 144px; top: 123px; width: 107px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');" 
tabindex="<?php echo ++$TI;?>">
<?php 
echo FCBOOD_("com_nombre","comprobantes",
"com_nombre IN ('FACTURA','BOLETA','PROFORMA','FACT. ELEC.','BOL. ELEC.')",$StrCom,"N","N","com_nombre");
?>
</select> 

<div class="s1" style="left: 266px; top: 105px; width: 46px;">
SERIE
</div>
<input name="TxtSer" type="text" id="TxtSer" 
style="position:absolute; left: 263px; top: 123px; width: 49px;" 
onblur="_S(this);" maxlength="4"
value="<?php echo $StrSer;?>"  
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 327px; top: 105px; width: 69px;">
NUMERO
</div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 324px; top: 123px; width: 68px;" 
onblur="_N(this);" maxlength="6"
value="<?php echo $StrNum;?>"  
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 405px; top: 91px; width: 86px;">
DESDE
</div>
<div class="EV" style="left: 404px; top: 105px; width: 86px; color:#FF0"><u><a onclick="fFecServer('TxtDex')">(dd-mm-yy) +</a></u></div>
<input name="TxtDex" type="text" id="TxtDex" 
style="position:absolute; left: 403px; top: 123px; width: 75px;" value="<?php echo $StrDex;?>"  
onkeydown="return SoloFec(this,event,'TxtHax');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 491px; top: 91px; width: 78px;">
HASTA
</div>
<div class="EV" style="left: 489px; top: 105px; width: 115px; color:#FF0"><u><a onclick="fFecServer('TxtHax')">(dd-mm-yy) +</a></u></div>
<input name="TxtHax" type="text" id="TxtHax" 
style="position:absolute; left: 487px; top: 123px; width: 78px;" 
value="<?php echo $StrHax;?>"  
onkeydown="return SoloFec(this,event,'TxtPro');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 576px; top: 105px; width: 71px;">
CLIENTE
</div>
<input name="TxtPro" type="text" id="TxtPro" 
style="position:absolute; left: 576px; top: 123px; width: 168px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'TxtCod');" 
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 757px; top: 105px; width: 87px;">
CODIGO
</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="position:absolute; left: 753px; top:123px; width: 90px;" 
value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 855px; top:105px; width: 131px;">
DESCRIPCION
</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="position:absolute; left: 852px; top: 123px; width: 154px;" value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMar');"
tabindex="<?php echo ++$TI;?>" />

<div class="s1" style="left: 1021px; top:105px; width: 67px;">
LINEA
</div>
<input name="TxtMar" type="text" id="TxtMar" 
style="position:absolute; left: 1019px; top: 123px; width: 65px;" value="<?php echo $StrMar;?>"  
onkeydown="return SoloTextoEx(event,'CmdB');"
tabindex="<?php echo ++$TI;?>" />

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


<div id="layer3" style="position:absolute; left: 25px; top: 151px; width: 1146px; height: 400px; overflow:auto">
<div align="left" class="f2">
<table id="Exportar_a_Excel" width="1130" height="19" border="1" cellpadding="0" cellspacing="0">

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

<tr>
<td width="80" bgcolor="#999999"><span class="eS4">NUMERO</span></td>
<td width="80" bgcolor="#999999"><span class="eS4">FECHA</span></td>
<td width="209" bgcolor="#999999"><span class="eS4">CLIENTE</span></td>
<td width="97" bgcolor="#999999"><span class="eS4">CODIGO</span></td>
<td width="314" bgcolor="#999999"><span class="eS4">DESCRIPCION</span></td>
<td width="159" bgcolor="#999999"><span class="eS4">LINEA</span></td>
<td width="42" bgcolor="#999999"><span class="eS4">CANT.</span></td>
<td width="55" bgcolor="#999999"><span class="eS4">PIEZAS</span></td>
<td width="74" bgcolor="#999999"><span class="eS4">CANT.PEND</span></td>
</tr>

<?php
	$TP=0;	 
	$_TP=0; 		
	$ss="SELECT CONCAT(SER,'-',NUM) as SN,DATE_FORMAT(FEC,'%d-%m-%y') as FE,
         SUBSTRING(CLI,1,20) as CL,COD,SUBSTRING(DES,1,20) as DE,
         LINEA,KA,UNI,(CA_CONTROL - DEJA) as PEN, ((CA_CONTROL - DEJA) * UNI) as TP FROM 
		 $TAB WHERE $FF ORDER BY ID,COD ";
	$X1="<td bgcolor=\"#FFFFFF\"><span class=\"Estilo5\">";
	$X1B="<td bgcolor=\"#FFFFFF\" align=\"right\"><span class=\"Estilo5\">";
	$X2="</span></td>";
	$s=PagSql($ss,$LStrPag,$VP_RegXPag,$LStrTR);
	$result = grs($s);				
	while ($row = $result->fetch_assoc()){
		echo "<tr >";
		echo $X1.$row['SN'].$X2;		
		echo $X1.$row['FE'].$X2;		
		echo $X1.$row['CL'].$X2;		
		echo $X1.$row['COD'].$X2;
		echo $X1.$row['DE'].$X2;
		echo $X1.$row['LINEA'].$X2;
		echo $X1.$row['KA'].$X2;
		echo $X1B.$row['UNI'].$X2;
		echo $X1B.$row['PEN'].$X2;
		echo "</tr>";
		$TP=$TP + $row['TP'];
		$_TP=$_TP + $row['PEN'];
	}

?>
<tr>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td colspan="2" bgcolor="#999999"><span class="eS4">TOT. PIEZAS</span></td>
  <td bgcolor="#999999" align="right"><span class="eS4"><?php echo NF4($TP);?></span></td>
</tr>
<tr>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td bgcolor="#999999">&nbsp;</td>
  <td colspan="2" bgcolor="#999999"><span class="eS4">TOT. CAJAS</span></td>
  <td bgcolor="#999999" align="right"><span class="eS4"><?php echo NF4($_TP);?></span></td>
</tr>	           
</table>
</div>
</div>
<div class="s1" style="left: 23px; top: 559px; width: 166px;">Doble Click sobre el registro para activar Actualizacion </div>

</form>

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