<?php
$PageSecurity = 1;
include('includes/session.inc');
$title = _('Invoice');
//include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
	echo '<link href="'.$rootpath. '/css/'. $_SESSION['Theme'] .'/default.css" rel="stylesheet" type="text/css" />';
 

 if($_REQUEST['Items'])
 {
 if(isset($_SESSION['invoice_items']))
 $_SESSION['invoice_items']=array_unique(array_merge($_REQUEST['item_list'],$_SESSION['invoice_items']));
 else
 $_SESSION['invoice_items']=array_unique($_REQUEST['item_list'])	;
 
 
if($_REQUEST['action']=='addnew')
{
$s->pageLocation('invoice.php?action=addnew');

?><?php 
}
else{

$s->pageLocation('invoice.php?action=edit&id='.$_SESSION['editid'] );

 
} }
 
?>
<script type="text/javascript">
/*function display_table(str)
{
alert(str);
if (str=="")
  {
  document.getElementById("item_table").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
	xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   	//alert(xmlhttp.responseText);
    document.getElementById("item_table").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","get_items.php?q="+str,true);
xmlhttp.send();
}*/
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td ><div align="right"><A HREF="javascript:history.go(-1)"> [Go Back]</A> </div></td>
  </tr>
</table>
<center><h2>Search</h2>
<form action=" " method="post">
<table width="60%" border="0" cellspacing="0" cellpadding="0" class="maintable">
  <tr>
    <td> Shade Name : <input name="shade_name" type="text"></td>
    <td><input name="Go" type="submit" value="Go"></td>
  </tr>
</table>
</form></center><hr>

<form action="" method="post">
<input name="Items" type="submit" value="Select Items" >
<div style="overflow: auto; height:530px" > 
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="maintable">
  
  <tr bgcolor="#">  
	  <th>S No. </th>
    <th>Shade Name</th>
	 <th>Client Code</th>
    <th width="48%"> Description</th>
  </tr>
  <?php $i=0;$j=1;
  if($_REQUEST['Go'])
  $sql_stockmaster=DB_query("select * from stockmaster where  maincategoryid='FG' and shade_name like '%".$_REQUEST['shade_name']."%' and stockid !=''",$db);
  else
    $sql_stockmaster=DB_query("select * from stockmaster where maincategoryid='FG' and stockid !='' ",$db);
   while($row_stockmaster=DB_fetch_array($sql_stockmaster))  
   {
   if($i==0)
     $tabindex=13+$i;
	 else{
	 $tabindex+=$i;
	 }
	 if($i%2==0)
	  $bgcolor="#CCCCCC";
	  
   ?>
  <tr bgcolor="<?php echo $bgcolor;?>" > 
    <td><input name="item_list[]" type="checkbox" id="item_list_<?php echo $j;?>"  value="<?php echo $row_stockmaster['stockid']?>"><?php //echo $j; ?></td>
 <td><?php echo $row_stockmaster['shade_name'] ?></td>
    <td><?php echo $row_stockmaster['client_code'] ?></td>
    <td><?php echo $row_stockmaster['description'] ?></td>
    </tr>
  <?php  $i++;
   $j++;} 
   ?> 
 </table>
 </div>
<input name="Items" type="submit" value="Select Items" onclick="display_table()">
</form>