<?
session_start();
if ($_SESSION['estado'] != "ON")
		{
		?>
		<script>
			parent.location.href = 'index.php';
		</script>
		<? 
		exit();
		}
$id_empresa = $_SESSION['ss_empresa'];
$id_user = $_SESSION['ss_user'];
?>
<title>Busqueda Producto</title>
<style type="text/css">
<!--
.Estilo15 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; }
.Estilo17 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #00ff00; }
-->
</style>
<?

$cant = $_GET["id"];
$enviar = $_GET["b"];
if ($enviar=="")
	{
	$enviar="1";
	}
include "../conex.php";
?>
<table width="100%"align="center" border="0">
  <tr>
    <td width="25%"><div align="center"><img src="../Images/logo.gif" width="120" height="120"></div></td>
	<td width="50%"><div align="center"><strong><font size="6">Buscar Producto</font></strong></div></td>
    <td width="25%">&nbsp;</td>
  </tr>
</table>


<form name="form1" method="post" action="busqueda.php?id=<?=$cant?>&b=<? echo "2";?>">
  <table width="100%"align="center" border="0">

    <tr>
      <td width="20%">Ingrese parte de la descripci&oacute;n :</td>
      <td width="65%"><label>
        <input name="textcodigo" type="text" size="65">
      </label></td>
      <td width="15%"><label>
        <input name="enviar" type="submit" id="enviar" value="Buscar">
      </label></td>
    </tr>
  </table>
</form>
	<?
	$cont=0;
	if ( $textcodigo!="" )
		{
		$bsql = "SELECT saldo, codigo, descripcion, precio FROM productos WHERE descripcion LIKE '%$textcodigo%' AND empresa=$id_empresa";
		$resultado =mysql_query($bsql,$enlace);
		}
	else
		{
		$bsql = "SELECT saldo, codigo, descripcion, precio FROM productos WHERE descripcion LIKE '%' AND empresa=$id_empresa";
		$resultado =mysql_query($bsql,$enlace);
		}
	while (mysql_fetch_object ($resultado))
		{
		$saldo=mysql_result($resultado, $cont, "saldo");
		$cp=mysql_result($resultado, $cont, "codigo");
		$des=mysql_result($resultado, $cont, "descripcion");
		$pre=mysql_result($resultado, $cont, "precio");
	
		if ($cont==0)
			{
		?>
		<table width="95%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="8%" align="center">Saldo</td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="12%" align="center">Precio ($)</td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="20%" align="center">Código</td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="50%" align="center">Descripción</td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="10%" align="center">Enviar</td>
		</tr>
		<? 
			}
		?>
		<tr>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="8%" align="right"><?=$saldo;?></td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="12%" align="right"><?=$pre;?></td>
			<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="20%" align="left"><?=$cp;?></td>
		<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="50%" align="left"><?=$des?></td>
		<td class="Estilo15" style="border:double; border-width:3px; border-color:#0F0F0F" width="10%" align="center"><a onClick="JavaScript:enviar('<? echo "$cp";?>','<? echo "$des";?>','<? echo "$pre";?>')"><IMG align=top  border=0 src="../Images/ir.gif" style="cursor:pointer" title="Presione aqui para enviar este código"></a></td>
	</tr>
	
	<?
	$cont=$cont+1;
	}
	?>
</table>



	<script languaje="javascript">
	function enviar(cod,des,pre)
		{

		window.opener.document.getElementById("codigo[<? echo "$cant";?>]").value = cod;
		window.opener.document.getElementById("precio[<? echo "$cant";?>]").value = pre;
		//window.opener.document.getElementById("precio1[<? echo "$cant";?>]").value = pre;
		window.opener.document.getElementById("detalle[<? echo "$cant";?>]").value = des;	
		//window.opener.document.getElementById("detalle1[<? echo "$cant";?>]").value = des;	
		window.close();
		window.opener.document.getElementById("codigo[<? echo "$cant";?>]").focus();
		window.opener.document.getElementById("cantidad[<? echo "$cant";?>]").focus();
		}
	</script>
