<?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']);
	$StrCod=V($_POST['TxtCod']);		
	$StrDes=V($_POST['TxtDes']);		
	$StrMar=V($_POST['TxtMar']);
	//
	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");
	}
	/*
	if(strlen($StrDex)==0) $StrDex=HACE_UNA_SEM();
	if(strlen($StrHax)==0) $StrHax=HOY();
	*/
	$StrEmp_=LIKE($StrEmp);
	$StrAlm_=LIKE($StrAlm);
	if(strlen($StrCom)==0) $StrCom="TODOS";	
	if(strlen($StrSN)==0) $StrSN="TODOS";	
	if($StrSN=="TODOS"){
		$StrSN_="%";
	}else{
		$StrSN_=substr($StrSN,0,1);
	}
	$StrCod_=$StrCod."%";
	$StrDes_=$StrDes."%";
	$StrMar_=$StrMar."%";
	//-------------------------
	if($StrCom=="TODOS"){
		$StrCom_="%";
	}else{
		$StrCom_=$StrCom;
	}
	$StrNum_=$StrNum."%";
	$StrSer_=$StrSer."%";
	$StrDex_=val_dex($StrDex);
	$StrHax_=val_hax($StrHax);
	$StrPro_=$StrPro."%";
	//-------------------------
	$FF="ID>0 AND FEC >= '$StrDex_' AND FEC <= '$StrHax_' AND EMPC LIKE '$StrEmp_' AND ALM LIKE '$StrAlm_' AND 
		COM LIKE '$StrCom_' AND 
		NUM LIKE '$StrNum_' AND SER LIKE '$StrSer_' AND 
		
		CLI LIKE '$StrPro_' AND ANU LIKE '$StrSN_' AND
		DES LIKE '$StrDes_' AND LINEA LIKE '$StrMar_' AND 
		COD LIKE '$StrCod_'";

$LStrTR=gn("count(*)","vcotizaciones_det",$FF);
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=200;	
$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>Proformas - Buscar- Detallado</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/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: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_buscar_det.php">

  
    <div id="layer6" style="position:absolute; left: 412px; top: 91px; width: 74px;">
      <div align="left" class="f2">NUMERO</div>
    </div>
    <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('cotizaciones.php?TxtAc=X');" />
      </div>
    </div>

<div id="layer3" 
style="position:absolute; left: 25px; top: 138px; width: 1158px; 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="10" bgcolor="#666666" align="center">
<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
            </td>
           
          </tr>
<tr>
<td width="155" bgcolor="#999999"><span class="eS4">EMPRESA / ALMACEN</span></td>
<td width="106" bgcolor="#999999"><span class="eS4">NUMERO</span></td>
<td width="51" bgcolor="#999999"><span class="eS4">FECHA</span></td>
<td width="204" bgcolor="#999999"><span class="eS4">CLIENTE</span></td>
<td width="80" bgcolor="#999999"><span class="eS4">CODIGO</span></td>
<td width="230" bgcolor="#999999"><span class="eS4">DESCRIPCION</span></td>
<td width="100" bgcolor="#999999"><span class="eS4">LINEA</span></td>
<td width="64" bgcolor="#999999"><span class="eS4">CANT</span></td>
<td width="46" bgcolor="#999999"><span class="eS4">PRECIO</span></td>
<td width="72" bgcolor="#999999" align="right"><span class="eS4">IMPORTE</span></td>
</tr>
<?php		  
	$_TP=0;		
	$ss="SELECT ID,ALM,COM,CONCAT(SER,'-',NUM),DATE_FORMAT(FEC,'%d-%m-%y'),
		 SUBSTRING(CLI,1,23) AS CLI,
		 SUBSTRING(DES,1,29) AS DES,
		 SUBSTRING(LINEA,1,12) AS LINEA,
		 KA,ROUND(PR - DT,2),IMP,COD,EMPC
		 FROM vcotizaciones_det 
		 WHERE $FF ORDER BY SER,NUM,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);
	//echo $s."<br>";
	$result = grs($s);				
	while ($row = $result->fetch_row()){
		echo "<tr ondblclick=\"location.href='cotizaciones.php?Id=$row[0]&Pag=0';\">";
		echo $X1.$row[12]." / ".$row[1].$X2;		
		//echo $X1.$row[3].$X2;
		echo "<td bgcolor=\"#FFFFFF\">
			  <a target=\"_blank\" href=\"cotizaciones.php?Id=$row[0]\">'$row[3]</a></td>";
		echo $X1.$row[4].$X2;		
		echo $X1.vbl($row[5],20).$X2;
		echo $X1.$row[11].$X2;
		echo $X1.$row[6].$X2;
		echo $X1.$row[7].$X2;
		echo $X1B.$row[8].$X2;
		echo $X1B.$row[9].$X2;
		echo $X1B.$row[10].$X2;
		echo "</tr>";
		$_TP=$_TP + $row[8];
	}

?>		  
<tr>
<td width="155" bgcolor="#999999">&nbsp;</td>
<td width="106" bgcolor="#999999">&nbsp;</td>
<td width="51" bgcolor="#999999">&nbsp;</td>
<td width="204" bgcolor="#999999">&nbsp;</td>
<td width="80" bgcolor="#999999">&nbsp;</td>
<td width="230" bgcolor="#999999">&nbsp;</td>
<td width="100" bgcolor="#999999"><span class="eS4">TOT.CAJ</span></td>
<td width="64" bgcolor="#999999"><span class="eS4"><?php echo NF4($_TP);?></span></td>
<td width="46" bgcolor="#999999">&nbsp;</td>
<td width="72" bgcolor="#999999" align="right">&nbsp;</td>
</tr>
        </table>
      </div>
    </div>
    <div id="layer" style="position:absolute; left: 79px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">PROFORMAS - 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");?>"/>  
      - Detallado</div>
    </div>
<input name="TxtNum" type="text" id="TxtNum" 
style="position:absolute; left: 413px; top: 109px; width: 60px;" 
value="<?php echo $StrNum;?>"  onblur="_N(this);" maxlength="6"
onkeydown="return SoloTextoEx(event,'TxtDex');"
tabindex="1" />

    <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: 1096px; top: 108px; width: 57px;"
        value="Filtrar" onclick="fFiltrar();" />

    <div id="layer7" style="position:absolute; left: 484px; top: 76px; width: 45px;">
      <div align="left" class="f2">DESDE</div>
    </div>
<div class="EV" style="left: 480px; top: 91px; 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: 484px; top: 109px; width: 66px;" value="<?php echo $StrDex;?>"  
        onkeydown="return SoloFec(this,event,'TxtHax');"
        tabindex="1" />

<input name="TxtPro" type="text" id="TxtPro" 
style="position:absolute; left: 629px; top: 109px; width: 98px;" value="<?php echo $StrPro;?>"  
onkeydown="return SoloTextoEx(event,'CboSN');" 
tabindex="1" />

    <div id="layer10" style="position:absolute; left: 631px; top: 91px; width: 100px;">
      <div align="left" class="f2">CLIENTE</div>
    </div>
    <div id="layer11" style="position:absolute; left: 559px; top: 76px; width: 60px;">
      <div align="left" class="f2">HASTA</div>
    </div>
<div class="EV" style="left: 555px; top: 91px; 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: 558px; top: 109px; width: 64px;" 
        value="<?php echo $StrHax;?>"  
        onkeydown="return SoloFec(this,event,'TxtPro');"
        tabindex="1" />

        <select name="CboCom" id="CboCom" 
        style="position:absolute; left: 249px; top: 109px; width: 92px;" 
onkeydown="return SoloTextoEx(event,'TxtSer');">
          <option value="PROFORMA" selected="selected">PROFORMA</option>

        </select>

<div id="layer13" style="position:absolute; left: 250px; top: 91px; width: 102px;">
<div align="left" class="f2">COMPROBANTE</div>
</div>

<div style="position:absolute; left:25px; top: 91px; width: 102px;">
<div align="left" class="f2">EMPRESA</div>
</div>

<select name="CboEmp" id="CboEmp" 
style="position:absolute; left:25px; top:109px; width: 114px;" 
onchange="EM_OC();"
onkeydown="return SoloTextoEx(event,'CboAlm');" tabindex="1">
<?php 
	echo LE($StrEmp,"S","N"); 	
?>
</select>

<select name="CboAlm" id="CboAlm" style="position:absolute; left: 148px; top: 109px; width: 95px" 
onkeydown="return SoloTextoEx(event,'CboCom');">
<?php
	echo LA($StrEmp,$StrAlm,"S","N");	
?>
</select>

<div style="position:absolute; left: 150px; top: 91px; width: 102px;">
<div align="left" class="f2">ALMACEN</div>
</div>
    <div id="layer15" style="position:absolute; left: 354px; top: 91px; width: 46px;">
      <div align="left" class="f2">SERIE</div>
    </div>
<input name="TxtSer" type="text" id="TxtSer" 
style="position:absolute; left: 353px; top: 109px; width: 50px;" 
value="<?php echo $StrSer;?>"  onblur="_S(this);" maxlength="4"
onkeydown="return SoloTextoEx(event,'TxtNum');"
tabindex="1" />

    <div id="layer17" style="position:absolute; left: 736px; top: 91px; width: 75px;">
      <div align="left" class="f2">ANULADO</div>
    </div>
        <select name="CboSN" id="CboSN" 
style="position:absolute; left: 734px; top: 109px; width: 59px;" 
onkeydown="return SoloTextoEx(event,'TxtCod');">
<?php
	echo FCBO_("au_item","auxiliar","au_tab='SI_NO'",$StrSN,"S","N");
?>
        </select>

<div id="layer19" style="position:absolute; left: 800px; top: 92px; width: 74px;">
<div align="left" class="f2">CODIGO</div>
</div>
<input name="TxtCod" type="text" id="TxtCod" 
style="position:absolute; left: 800px; top: 109px; width: 66px;" 
value="<?php echo $StrCod;?>"  
onkeydown="return SoloTextoEx(event,'TxtDes');"
tabindex="1" />

<div id="layer19" style="position:absolute; left: 878px; top: 92px; width: 74px;">
<div align="left" class="f2">DESCRIPCION</div>
</div>
<input name="TxtDes" type="text" id="TxtDes" 
style="position:absolute; left: 876px; top: 109px; width: 124px;" value="<?php echo $StrDes;?>"  
onkeydown="return SoloTextoEx(event,'TxtMar');"
tabindex="1" />

<div id="layer21" style="position:absolute; left: 1010px; top: 92px; width: 74px;">
<div align="left" class="f2">LINEA</div>
</div>
<input name="TxtMar" type="text" id="TxtMar" 
style="position:absolute; left: 1007px; top: 109px; width: 75px;" value="<?php echo $StrMar;?>"  
onkeydown="return SoloTextoEx(event,'CmdB');"
tabindex="1" />

  

<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: 149px; 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>
