<?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;
}
//	
	
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	$StrONE=trim(V($_GET['CmdB']));	
	//-------------------------
	$StrCod=V($_POST['TxtCod']);		
	$StrDes=V($_POST['TxtDes']);
	$StrMar=V($_POST['CboMar']);

	$StrCodT=$StrCod."%";	
	if(($StrLinT)=="TODOS") $StrLinT="%";
	$StrDesT=$StrDes."%";
	$StrMarT=$StrMar;
	if(($StrMarT)=="TODOS") $StrMarT="%";
	$LStrTR=gn("count(*)","vproductos",
				"COD LIKE '$StrCodT' AND 
				 DESCRIPCION LIKE '$StrDesT' AND LINEA LIKE '$StrMarT'");
$LStrPag=V($_POST['TxtPag']);	
if($StrCmd=="F"){$LStrPag="1";}
$VP_RegXPag=3000;	
$LStrPag=PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);
	//-------------------------
	if($StrCmd=="PDF"){	
		//
		$TI="REPORTE DE PRODUCTOS";
		$s="SELECT COD,DESCRIPCION,LINEA,ROUND(PC_SOL,1),ROUND(PV_MIN,1),ROUND(PV_MAX,1)
			FROM vproductos WHERE ID>0 AND 
			COD LIKE '$StrCodT' AND 
			DESCRIPCION LIKE '$StrDesT' AND LINEA LIKE '$StrMarT' 
			ORDER BY DESCRIPCION ";		
		$T="CODIGO,DESCRIPCION,LINEA,PC_SOL,PV_MIN,PV_MAX";
		$E="7,42,11,6,6,6";
		$A="0, 0, 0,2,2,2";		
		//
		$_ID=GenId("id","reportes");
		PDF_TIT($_ID,$TI);
		PDF_SQL($_ID,$s);
		PDF_CAM($_ID,$T);
		PDF_ESP($_ID,$E);
		PDF_ANC($_ID,$A);		
		$StrFilePDF=PDF_CREATE($_ID);	
		//
		//JsDirN($StrFilePDF);			
		//
		$StrMsg="onload=\"alert('Ahora puede descargar el reporte');\"";
	}
ob_end_clean();	
$LStrFoc="document.getElementById('TxtCod').focus();";
$LStrMsg="onload=\"$LStrFoc;\"";	
?>
<!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>Productos - Buscar</title>
<script type="text/javascript" src="fe/funciones.js"></script>
<script type="text/javascript" src="fe/ajf.js"></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:900px;
	height:600px;
	position:absolute;
    left:<?php echo "50%";?>;
    top:<?php echo "50%";?>;
	background-color:#006699;
	margin:<?php echo "-300px";?> 0 0 <?php echo "-450px";?>;
}
#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;}
.s4 {color: #000099}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer3 .f2 table tr td {
	color: #000;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?>>
<form id="Frm" name="Frm" method="post" action="productos_buscar.php">
<center> 
  <div Id="DivFRM"  class="centrarFrm" >
    <div id="layer6" style="position:absolute; left: 60px; top: 89px; width: 52px;">
      <div align="left" class="f2">CODIGO</div>
    </div>
    <div id="layer5" style="position:absolute; left: 116px; top: 50px; width: 210px; height: 28px;">
      <div align="left" class="f2">
        <input name="CmdV" type="button" id="CmdV" 
        value="Volver" onclick="fVolver('productos.php');" />
      </div>
    </div>

<div style="height:47px; width:871px; overflow-x:hidden; position:absolute; left: 27px; top: 146px; color: #0FF;">
      <div align="left" class="f2">
<table width="844"  border="1" cellpadding="0" cellspacing="0">
<tr height="10 px">
  <td colspan="8" bgcolor="#999999" align="center" height="25px"><?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?></td>
  </tr>
<tr height="10 px">
<td width="82" bgcolor="#999999"><span class="s4">CODIGO</span></td>
<td width="253" bgcolor="#999999"><span class="s4">DESCRIPCION</span></td>
<td width="124" bgcolor="#999999"><span class="s4">LINEA</span></td>
<td width="65" bgcolor="#999999"><span class="s4">PC DOL</span></td>
<td width="68" bgcolor="#999999"><span class="s4">PV MIN</span></td>
<td width="68" bgcolor="#999999"><span class="s4">PV MAX</span></td>
<td width="33" bgcolor="#999999">&nbsp;</td>
</tr>
</table>
</div>
</div>
<div id="layer3" style="height:392px; width:868px; overflow-x:hidden; position:absolute; left: 27px; top: 189px; overflow-y:scroll; color: #0FF; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;">
      <div align="left" class="f2">
 <div id="DivT">
<table width="845" height="17"  border="1" cellpadding="0" cellspacing="0">
<tr height="10 px">
<td width="82" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="252" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="125" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="64" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="70" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="67" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="34" bgcolor="#999999" align="center">&nbsp;</td>
</tr>	  
<?php		  		

$s="SELECT ID,COD,LINEA,DESCRIPCION,LINEA,PC_SOL,PV_MIN,PV_MAX
	FROM vproductos WHERE ID>0 AND 
	COD LIKE '$StrCodT' AND 
	DESCRIPCION LIKE '$StrDesT' AND LINEA LIKE '$StrMarT' 
	ORDER BY DESCRIPCION ";		
$i=0;  			
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);			
$result = grs($s);

while ($row = $result->fetch_row()){
	$i++;
	echo "<tr height=\"10 px\"
		ondblclick=\"location.href='productos.php?Id=$row[0]&Pag=0';\">";
	echo "<td >".$row[1]."</td>";	
	echo "<td >".($row[3])."</td>";
	echo "<td >".($row[4])."</td>";						 
	echo "<td >".($row[5])."</td>";
	echo "<td >".($row[6])."</td>";
	echo "<td >".($row[7])."</td>";						 
	echo "<td >
		 <a href=\"productos.php?Id=$row[0]&Pag=0\" >
		 <img src=\"e.png\"  border=\"0\"/>
		 </a>
		 </td>";
	echo "</tr>";
}

?>
<tr height="10 px">
<td width="82" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="252" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="125" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="64" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="70" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="67" bgcolor="#999999"><span class="s4">&nbsp;</span></td>
<td width="34" bgcolor="#999999">&nbsp;</td>
</tr>	  
</table>
</div>
</div>
</div>
    
    <div id="layer" style="position:absolute; left: 116px; top: 30px; width: 412px; height: 24px;">
      <div align="left" class="Estilo1">PRODUCTOS - 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="" />
      </div>
    </div>
          <input name="TxtCod" type="text" id="TxtCod" 
          style="position:absolute; left: 60px; top: 109px; width: 99px;" value="<?php echo $StrCod;?>"  
          onkeydown="return SoloTextoEx(event,'TxtDes');"
          tabindex="1" />
    <div id="LblTit" style="position:absolute; left: 57px; top: 25px; width: 64px;">
    <div align="left" class="Estilo1"><img src="img/buscar.png" width="57" height="60" /></div>
  </div>
    <div id="layer8" style="position:absolute; left: 173px; top: 89px; width: 136px;">
      <div align="left" class="f2">DESCRIPCION</div>
</div>
        <input name="TxtDes" type="text" id="TxtDes" style="position:absolute; left: 170px; top: 109px; width: 367px;" 
        value="<?php echo $StrDes;?>"  
        onkeydown="return SoloTextoEx(event,'CboMar');""  tabindex="1" />

<select name="CboMar" id="CboMar" 
style="position:absolute; left: 550px; top: 109px; width: 142px;" 
onkeydown="return SoloTextoEx(event,'CmdB');">
<?php
echo FCBO_("lin_nombre","lineas","id_linea>0",$StrMar,"S","N");
?>
</select>

    <div id="layer12" style="position:absolute; left: 552px; top: 89px; width: 136px;">
      <div align="left" class="f2">LINEA</div>
    </div>
        <input name="CmdB2"
style="position:absolute; left: 714px; top: 108px; width: 54px;" type="button" id="CmdB2" 
value="Filtrar" 
onclick="fFiltrar();"
/>

    <div id="layer13" style="position:absolute; left: 769px; top: 108px; width: 68px; height: 26px;">
      <div align="left" class="f2">
        <input name="CmdB" type="button" id="CmdB" 
value="Imprimir" onclick="fPDF();" />
        <a href="<?php echo $StrFilePDF;?>" target="_blank" ></a> </div>
    </div>
    <div id="layer14" style="position:absolute; left: 840px; top: 109px; width: 30px; height: 23px;">
      <div align="left" class="f2"><a href="<?php echo $StrFilePDF;?>" target="_blank" ><img src="save.gif" width="16" height="16" /></a></div>
    </div>
  </div>
</center>	
</form>
</body>
</html>
