<?php

/* $Revision: 1.20 $ */

$PageSecurity = 2;

include('includes/session.inc');

$title = _('Indent');

//include('includes/header.inc');
?>
<SCRIPT LANGUAGE="JavaScript">
<!--

function pick(symbol,val,units) {
  if (window.opener && !window.opener.closed)
    window.opener.document.IntentItemForm.item_code<?=$_GET['id'];?>.value = symbol;
	window.opener.document.getElementById('itmcode<?=$_GET['id'];?>').innerHTML = symbol;
	 window.opener.document.IntentItemForm.item_desc<?=$_GET['id'];?>.value = val;
	 window.opener.document.getElementById('itmdesc<?=$_GET['id'];?>').innerHTML = val;
	  window.opener.document.IntentItemForm.base_unit<?=$_GET['id'];?>.value = units;
	window.opener.document.getElementById('baseunit<?=$_GET['id'];?>').innerHTML = units;
	window.opener.document.getElementById('delitem<?=$_GET['id'];?>').style.display = 'block';
  window.close();
}

// -->
</SCRIPT>
<style>
*{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
}
a{
	text-decoration:none;
}
.EvenTableRows {
	background-color: #CCCCCC;
}

.OddTableRows {
	background-color: #EEEEEE;
}

th {
	font-weight: normal;
	background-color: #800000;
	color: white;
}
</style>
<?php
$condition = '';
if(!empty($_POST['keywords'])){
	$keyword = addslashes(trim($_POST['keywords']));
	$condition .= " where description like '$keyword%'";
}

$sql="SELECT * FROM stockmaster $condition";
//echo $sql;
$result=DB_query($sql, $db);

?>
<form method="post" action="" name="ItemSearchForm">	
	<table width="80%" border="0" align="center" cellpadding="3">
	  <tr>
		<td class="number">Enter the Keyword</td>
		<td width="30%"><input type="text" name="keywords" /></td>
		<td><input type="submit" name="submit" value="Search Item" /></td>
	  </tr>
	</table>	
</form><br />
<table width="100%" border="0">
  <tr>
    <th align="left">Code</th>
    <th align="left">Description</th>
  </tr>
<?
$i=1;
while($myrow=DB_fetch_array($result)){
	if(($i%2)==0){
		$class = 'class="EvenTableRows"';
	}else{
		$class = 'class="OddTableRows"';
	}
?>
  <tr <?=$class;?>>
    <td><A HREF="javascript:pick('<?=$myrow['stockid'];?>','<?=$myrow['description'];?>','<?=$myrow['units'];?>')"><?=$myrow['stockid'];?></A></td>
    <td><A HREF="javascript:pick('<?=$myrow['stockid'];?>','<?=$myrow['description'];?>','<?=$myrow['units'];?>')"><?=$myrow['description'];?></A></td>
  </tr>


<? 
	$i++;
} ?>
</table>