<?php 
$PageSecurity = 4;
$PageName = 'Purchase Requisition';
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/DefineSuppTransClass.php');
 
 $title = _('Purchase Requisition');

 $modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;


if (isset($_GET['ModifyOrderNumber']) and $_SESSION[UserStockLocation]=='H001')  {
	$title = _('Modify Purchase Order') . ' ' . $_GET['ModifyOrderNumber'];
} else {
	$title = _('Purchase Requisition Entry');
}
if(isset($_POST['DeleteRow']))		 
{
 if(!empty($_REQUEST['delitem']))
 {	
 $ListItem=explode('#',$_SESSION['ACGRequisition-ItemList']);
  for($i=0;$i<count($_REQUEST['delitem']);$i++)
   {	  
		 $key=array_search($_REQUEST['delitem'][$i],$ListItem);
  		 if($key!==false)
		 unset($ListItem[$key]);
		 $itemlist1=implode("#",$ListItem);
		 $_SESSION['ACGRequisition-ItemList']=$itemlist1;
		  }
 }
 if(!empty($_REQUEST['deldate']))
 { 		
 for($i=0;$i<count($_REQUEST['deldate']);$i++)
 { 	
 $update=DB_query("update requisitionorderdetails set edit_status=1 where id='".$_REQUEST['deldate'][$i]."'",$db);	
 }		
 }
 }

?>
<link rel="stylesheet" href="css/jquery.ui.all.css">
 
<script>

function CalrequiredQty(val,i){
 

var a=	document.getElementById("stock_qty_"+i).value;
document.getElementById("req_quantity_"+i).value=val-a;

document.getElementById("required_qty_"+i).value=val-a;
 
}

$(function() {
		  $(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' ,changeMonth: true,
					changeYear: true,
					yearRange: '-80:+20'});
		  });
</script>
<script language="javascript">
var xmlHttp
function LocationDetailChange(str)
 { 
    xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		    alert ("Your browser does not support AJAX!");
		    return;
		  } 
	var url="Locationchange.php";
	url=url+"?location_code="+str;
	xmlHttp.onreadystatechange=NumberChanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function NumberChanged1() 
{ 
	if (xmlHttp.readyState==4)
	{ 
	   document.getElementById("txtid").innerHTML=xmlHttp.responseText;
	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}
function approve(str)
{
	var req_quantity = document.getElementById("req_quantity_"+str).value;
	var app_quantity = document.getElementById("AppQut_"+str).value;
	if(app_quantity > req_quantity)
	{
		alert("Approved Quantity cannot Be Greater Than Requisition Quantity");
		return false;
	}
}
function validateapprove()
{
	var count;
	var record_count = document.getElementById("record_count").value;
	for(var i=1; i<record_count; i++)
	{	
		var qval = document.getElementById("AppQut_"+i).value;
		if(qval == '')
		{
			alert("Please Enter Quantity To Be Approved");
			return false;
		}
	}
}
function open_items()
{
	
	var reqno=document.getElementById("reqno").value;
	
	window.open("ADD_Items.php?id="+reqno+"&action=add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>RequisitionNo=<?php echo $_REQUEST['RequisitionNo'];?>&update=1","item_popup_window","height=500,width=500,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}


</script>
<script language="javascript" src="js/function-ajax.js"></script>
 
<h2 align="center">Purchase Requisition </h2>
<?php 
if($_REQUEST['Cancel'])
{
	 unset($_SESSION['itemlist']);
	 unset($_SESSION['ACGRequisition-ItemList']);

}
if($_REQUEST['submit'])
{
 $sqldata=DB_query("delete  from requisitionorderdetails where edit_status=1 and requsitionno='".$_GET['RequisitionNo']."'",$db);
 
 
 	  $materialrequisitions_sql="Update   materialrequisitions set
									 
									comments='".$_REQUEST['remarks']."',
									prdate='".FormatDateForSQL($_REQUEST['date'])."',
									initiator='".$_SESSION['UserID']."',
									sitecode='".$_REQUEST['site']."',
									Reqno='".$_REQUEST['requisition_no']."'  
									WHERE requisitionno='".$_GET['RequisitionNo']."'  ";
					
						$update_materialrequisitions_sql=DB_query($materialrequisitions_sql,$db);			
									
	for($CR=0;$CR<count($_REQUEST['product_id']);$CR++)
	{
		$get_sql="Select * from requisitionorderdetails where requsitionno='".$_GET['RequisitionNo']."' and 
		product_id='".$_SESSION['requsition_itemcode'][$CR]."'";
			$get_result=DB_query($get_sql,$db);
			 
			if(DB_num_rows($get_result)>0)
			{
			  $update_sql="Update requisitionorderdetails set 
								req_quantity='".$_REQUEST['req_quantity'][$CR]."',
								make='".$_REQUEST['make'][$CR]."',
								color='".$_REQUEST['color'][$CR]."',
								grade='".$_REQUEST['grade'][$CR]."' ,
								size='".$_REQUEST['size'][$CR]."',  	
								status='".$_REQUEST['MRstatus'][$CR]."' ,						
 								req_quantity='".$_REQUEST['req_quantity'][$CR]."',
								required_qty='".$_REQUEST['req_quantity'][$CR]."',
								requisition_qty='".$_REQUEST['requisition_qty'][$CR]."',
								material_required_by='".FormatDateForSQL($_REQUEST['material_required_by'][$CR])."',
								Remarks='".$_REQUEST['remark'][$CR]."',
								stock_qty='".$_REQUEST['stock_qty'][$CR]."'
								WHERE requsitionno='".$_GET['RequisitionNo']."' and
								 id='".$_REQUEST['iddata'][$CR]."'";
								  
				$update_result=DB_query($update_sql,$db);
				
			}
			else
			{
				$insert_sql="Insert into requisitionorderdetails set 
									id='',
									requsitionno='".$_GET['RequisitionNo']."',
									product_id='".$_REQUEST['product_id'][$CR]."',
									product_description='".$_REQUEST['product_description'][$CR]."',
									make='".$_REQUEST['make'][$CR]."',    
									color='".$_REQUEST['color'][$CR]."',
									size='".$_REQUEST['size'][$CR]."',     
									grade='".$_REQUEST['grade'][$CR]."',    
									status='".$_REQUEST['MRstatus'][$CR]."' ,	
									req_quantity='".$_REQUEST['req_quantity'][$CR]."',
									required_qty='".$_REQUEST['req_quantity'][$CR]."',
									requisition_qty='".$_REQUEST['requisition_qty'][$CR]."',
									material_required_by='".FormatDateForSQL($_REQUEST['material_required_by'][$CR])."',
									Remarks='".$_REQUEST['remark'][$CR]."',
									stock_qty='".$_REQUEST['stock_qty'][$CR]."'"; 
									 

$insert_result=DB_query($insert_sql,$db);
}
}
$_SESSION['success_msg']="Update Successfully";	
echo "<script>location.href='index.php?route=POModule/MR_SelectOSMaterialRequi$rurl&RequisitionNo=".$_GET['RequisitionNo']."'</script>";
unset($_SESSION['manvi']);
unset($_SESSION['itemlist']);
unset($_SESSION['ACGRequisition-ItemList']);
}
  $date1=date('M-Y');
  $date2=date('Y-m-d');
		if (empty($_GET['identifier'])) {
			 $identifier=date('U');
		} else {
			$identifier=$_GET['identifier'];
		}
		$msg='';
		    $reqno = $_GET['RequisitionNo'];
			$sql="SELECT * FROM materialrequisitions WHERE requisitionno='".$reqno."'";
			$result=DB_query($sql,$db);
			$myrow=DB_fetch_array($result);
			$site=$myrow['sitecode'];
			$Reqno=$myrow['Reqno'];
			$prdate =$myrow['prdate'];
			$version=$myrow['version'];
			$revised=$myrow['revised'];
			$initiator=$myrow['initiator'];
			$requisition_site=$myrow['requisition_site'];
			$sitecode=$myrow['sitecode'];
			$dateprinted=$myrow['dateprinted'];
			$requisition_nature=$myrow['requisition_nature'];
			$month_year=$myrow['month_year'];
			$purchase_category =$myrow['purchase_category'];
			$intostocklocationcode=$myrow['intostocklocationcode'];
			$intostocklocation=$myrow['intostocklocation'];
			$status=$myrow['status'];
			$stat_comment=$myrow['stat_comment'];
			$comments=$myrow['comments'];
			
			?>
	<form action="" method="post">
	<input type="hidden" name="reqno" id="reqno" value="<?php echo $reqno;?>" />
	<fieldset style="width:650px"><legend><h3 align="center"><strong>Requisition Details</strong></h3></legend>
	<table width="100%" border="0" cellspacing="1" cellpadding="5" align="center">
  <tr>
    <th><strong>REQUISITION DATE</strong></th>
    <td><input type="text" name="date" id="date" class="datepicker" readonly="true" value=" <?php if(isset($_SESSION['date']))echo $_SESSION['date']; else echo ConvertSqlDate($prdate);?>"></td>
    <th rowspan="3"><strong>REMARKS</strong></th>
    <td rowspan="3"><textarea name="remarks" style="width:100%" rows="3"><?php if($_SESSION['remarks']!=''){ echo $_SESSION['remarks'];} else { echo $comments; }?></textarea></td>
  </tr>
  <tr>
    <th><strong>SITE</strong></th>
    <td>
	<?php 
	if($_SESSION['AssignedSites']!='0')
	  {
	  	 $ss="Select loccode,locationname from locations where loccode in (".$_SESSION['AssignedSites'].")";
	  	 $site_sql=DB_query($ss,$db);
	  }
	  else
	  {
		$ss="Select loccode,locationname from locations";
		$site_sql=DB_query($ss,$db);
	  }
	?>
	<select name="site" id="site" style="width:120px" onchange="generate_reqno(this.value)">
      <option value="000">---Select---</option>
      <?php
	while($site_row=DB_fetch_array($site_sql)){
		$p='';
		if($site_row['loccode']==$site ||$site_row['loccode']==$_SESSION['site'])
		{
		$p="selected";	
		}
	?>
      <option value="<?php echo $site_row['loccode'];?>"<?php  echo $p;?>><?php echo $site_row['locationname'];?></option>
      <?php } ?>
    </select></td>
  </tr>
  <tr>
    <th><strong>REQUISITION NUMBER </strong></th>
    <td><div id="reqno">
        <input name="requisition_no" type="text" id="requisition_no" value="<?php if($_SESSION['requisition_no']!=''){ echo $_SESSION['requisition_no'];} else { echo $Reqno; }?>" size="30" readonly="true" />
      </div></td>
  </tr>
</table></fieldset>

    <br />
	<h2 align="center">Item Details</h2>
	<p align="left"><input type="button" name="item_popup" value="Add More Items" id="item_popup"  onclick="open_items();" />
		<input type="submit"   name="DeleteRow" value="Delete" onclick="return confirm('Are you sure you want to delete?')"/>
	</p>
	<div align="center">
	<div style="overflow:auto; width:800px; height:250px">
    <table  width="100%;" border="0" cellspacing="1" cellpadding="2">
      <tr>
		<th width="9%">ITEM CODE </th>
		<th width="9%">ITEM NAME </th>
		<th width="5%">MAKE</th>
		<th width="6%">GRADE</th>
		<th width="6%">COLOR</th>
		<th width="6%">SIZE</th>
		<th width="4%">Unit</th>
		<th width="4%">ITEM NO.</th>
		<th width="11%">TOTAL STOCK </th>
		<th width="11%">REQUISITION QTY </th>
		<th width="16%">REQUIRED QTY </th>
		<th width="8%">MATERIAL REQUIRED DATE </th>
		<th width="11%">REMARK </th>
		<th width="6%">Status </th>
		<th width="15%">Action</th>
      </tr>
     <?php
	   $sql2 = "select * from requisitionorderdetails where requsitionno='".$reqno."' and edit_status=0";
	 $res = DB_query($sql2,$db);
	$i=0;
	
	$_SESSION['requsition_itemcode']=array();
	 while($row = DB_fetch_array($res)) 
	 {	
		$product_id=$row['product_id'];
		$_SESSION['requsition_itemcode'][]=$product_id;
        $product_description=$row['product_description'];
		 $make=$row['make'];
		 $grade=$row['grade'];
         $color=$row['color'];
		 $size=$row['size'];
        $uom=$row['uom'];
	  	$MRstatus=$row['status'];
		$totalreceivetilldate=$row['totalreceivetilldate'];
        $req_quantity=$row['req_quantity'];
        $requisition_qty=$row['requisition_qty'];
        $required_qty=$row['required_qty'];
		$material_required_by=$row['material_required_by'];
        $stock_qty=$row['stock_qty'];
	    $Remarks=$row['Remarks'];
	 ?>
	  <tr>
        <td><?php echo $product_id;?><input type="hidden" name="product_id[]" value="<?php echo $product_id;?>" id="product_id_<?php echo $i;?>" />
        	<input type="hidden" name="iddata[]" value="<?php echo $row['id']; ?>" />
        </td>
        
		<td><?php echo $product_description;?><input type="hidden" name="product_description[<?php echo $i;?>]" value="<?php echo $product_description;?>" id="product_description_<?php echo $i;?>" /></td>
		<td>
		<select name="make[]" id="make" style="width:100%">
			<option value="0">Select Make</option>
      <?php
			 $querymake=DB_query("select * from product_manufacture where 1=1" ,$db);
			while($que_row=DB_fetch_array($querymake))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($make==$que_row['id'] ?'selected':'')?>><?php echo $que_row['manufacturer'];?></option>
      <?php  }?>
	  </select>
		 </td>
	  <td>
	  <select name="grade[]" id="grade[<?php echo $i; ?>]"  style="width:100%">
	  	<option value="0">Select Grade</option>
		<?php
			 $querygrade=DB_query("select * from product_grade where 1=1" ,$db);
			while($que_row=DB_fetch_array($querygrade))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($grade==$que_row['id']?'selected':'')?>><?php echo  $que_row['grade'];?></option>
      <?php  }?>
	  </select>
		 </td>
		<td><select name="color[]" id="color[<?php echo $i; ?>]" style="width:100%">
			<option value="0">Select Color</option>
		<?php
			 $querycolor=DB_query("select * from product_color where 1=1" ,$db);
			while($que_row=DB_fetch_array($querycolor))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($color==$que_row['id'] ?'selected':'')?>><?php echo  $que_row['color'];?></option>
      <?php  }?></select>
		 </td>
       <td>
	 
		  <select name="size[]" id="size_<?php echo $i;?>" style="width:100%">
		  	<option value="0">Select Size</option>
		    <?php 
		
			$sizeId=DB_query("Select * from size_master",$db);
			while($sizeRow=DB_fetch_array($sizeId))
			{
		?>
		    <option value="<?php echo $sizeRow['id'];?>"<?php echo ($size==$sizeRow['id'] ?'selected':'')?>><?php echo $sizeRow['name'];?></option>
		    <?php } ?>
		    </select>	
	   
	    </td>
		 
	    <td><?php 
		$unit=$s->getField('item_master','StockID',$product_id,'unit');
		$unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
		echo $unitname;?><input type="hidden" name="uom[<?php echo $i;?>]" value="<?php echo $unit;?>" id="uom_<?php echo $i;?>" />  </td> 
	     <td><?php echo $item_row['item_no']; ?></td>
		 <td><?php echo  $stock_qty;?>
		 <input type="hidden" name="stock_qty[]" id="stock_qty_<?php echo $i;?>" value="<?php  echo $stock_qty?>" />
		  </td> 
		 <td> <input type="text" name="requisition_qty[<?php echo $i;?>]" value="<?php echo $requisition_qty;?>" id="requisition_qty_<?php echo $i;?>" onblur="CalrequiredQty(this.value,<?php echo $i;?>)" size="5" /></td>
    
		<td>
		<input name="required_qty[]" type="hidden" id="required_qty_<?php echo $i;?>"  alue="<?php echo $req_quantity;?>" /> 
		
		<input name="req_quantity[]" type="text" id="req_quantity_<?php echo $i;?>" value="<?php echo $req_quantity;?>" size="5" /></td>
		 <td align="center"><input name="material_required_by[<?php echo $i;?>]" type="text" id="material_required_by_<?php echo $i;?>" style="width:100%" value="<?php echo $new_date= date('d-m-Y', strtotime($material_required_by)); ?>"  class="datepicker"/></td>
		 <td align="center"><input name="remark[]" type="text" id="remark_<?php echo $i;?>" size="10" value="<?php echo $Remarks?>" /></td>
		 
		 <td>
		 	
		 <select  name="MRstatus[]" id="MRstatus_<?php echo $i;?>"  style="width:50px">
		 <option value="Active" <?php echo $MRstatus=='Active'?'selected':''?>>Active</option>
 		 <option value="Inactive" <?php echo $MRstatus=='Inactive'?'selected':''?> >Inactive</option>
		  <option value="Declined" <?php echo $MRstatus=='Declined'?'selected':''?> >Declined</option>
		   <option value="Davation" <?php echo $MRstatus=='Davation'?'selected':''?> >Davation</option>
		   
		 </select>
		 </td>
		 <td><input name="deldate[]" type="checkbox" value="<?php echo $row['id'];?>" /><img src="images/Icon_Delete.png" height="15" width="15"></td>
      </tr>
	  <?php $i++;} ?>
	  
	  
	
	  <?php if($_SESSION['ACGRequisition-ItemList']!='')
	   {
	// print_r($_SESSION['ACGRequisition-ItemList']);
	  $itemcode_list=explode('#',$_SESSION['ACGRequisition-ItemList']);
	 //echo"<pre>";
	 // print_r($itemcode_list);
	 
	 	for($j=0,$k=$i;$j<count($itemcode_list);$j++,$k++)
		{
				
			$yy=explode(",",$itemcode_list[$j]);
			//print_r($yy);
			if($j%2==0)
			{$bg="#CCCCCC";}
			else
			$bg="#C8BECB";
				
			$_SESSION['requsition_itemcode'][]=$yy[0];
			$item=DB_query("select item_name,unit,StockID from item_master where StockID='".$yy[0]."'",$db);
			$item_name=DB_fetch_array($item);
		?>
		<tr bgcolor="<?php echo $bg;?>">
        <td><?php echo $yy[0];?><input type="hidden" name="product_id[<?php echo $k;?>]" value="<?php echo $yy[0];?>" id="product_id_<?php echo $k;?>" /></td>
        
		<td><?php echo $item_name['item_name'];?><input type="hidden" name="product_description[<?php echo $k;?>]" value="<?php echo $item_name['item_name'];?>" id="product_description_<?php echo $k;?>" /></td>
        
		<td>
		<select name="make[<?php echo $k;?>]" id="make" style="width:100%">
			<option value="0">Select Make</option>
      <?php
			 $querymake=DB_query("select * from product_manufacture where 1=1" ,$db);
			while($que_row=DB_fetch_array($querymake))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($_REQUEST['make']==$que_row['id'] ?'selected':'')?>><?php echo $que_row['manufacturer'];?></option>
      <?php  }?>
	  </select>
		 </td>
	  <td>
	  <select name="grade[<?php echo $k;?>]" id="grade[<?php echo $k; ?>]"  style="width:100%">
	  	<option value="0">Select Grade</option>
		<?php
			 $querygrade=DB_query("select * from product_grade where 1=1" ,$db);
			while($que_row=DB_fetch_array($querygrade))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($_REQUEST['grade']==$que_row['id']?'selected':'')?>><?php echo  $que_row['grade'];?></option>
      <?php  }?>
	  </select>
		 </td>
		<td><select name="color[<?php echo $k;?>]" id="color[<?php echo $k; ?>]" style="width:100%">
			<option value="0">Select Color</option>
		<?php
			 $querycolor=DB_query("select * from product_color where 1=1" ,$db);
			while($que_row=DB_fetch_array($querycolor))
			{ 
 		 ?>
      <option value="<?php echo $que_row['id'];?>" <?php echo ($_REQUEST['color']==$que_row['id'] ?'selected':'')?>><?php echo  $que_row['color'];?></option>
      <?php  }?></select>
		 </td>
       <td>
	   <?php 
		$sizesql="Select * from size_master  where 1=1";
		$size_result=DB_query($sizesql,$db);?>
		  <select name="size[<?php echo $k;?>]" id="size_<?php echo $k;?>" style="width:100%">
		  	<option value="0">Select Size</option>
		    <?php 
		while($size_row=DB_fetch_array($size_result))
		{
			$sizeId=DB_query("Select name from size_master where id='".$size_row['size']."'",$db);
			$sizeRow=DB_fetch_array($sizeId);
			
		?>
		    <option value="<?php echo $size_row['size'];?>"<?php echo ($_REQUEST['size']==$size_row['id'] ?'selected':'')?>><?php echo $size_row['name'];?></option>
		    <?php } ?>
		    </select>	</td>
		 
	    <td><?php 
		$unit=$s->getField('item_master','StockID',$yy[0],'unit');
		$unitname=$s->getField('unitsofmeasure','unitid',$unit,'unitname');
		echo $unitname;?><input type="hidden" name="uom[<?php echo $k;?>]" value="<?php echo $unit;?>" id="uom_<?php echo $k;?>" /></td>
    
		 <td><?php echo $items_row['quality'];?></td> 
		 
		<td><?php echo  $stock_qty;?>
		 <input type="hidden" name="stock_qty[]" id="stock_qty_<?php echo $i;?>" value="<?php  echo $stock_qty?>" />
		  </td> 
		<td>
		<input type="text" name="requisition_qty[<?php echo $k;?>]" value="<?php echo $items_row['req_quantity'];?>" id="requisition_qty_<?php echo $k;?>" onblur="CalrequiredQty(this.value,<?php echo $k;?>)" size="5" />
		</td>
		<td>
		
		<?php echo $totalreceivetilldate;?><input type="hidden" name="totalreceivetilldate[<?php echo $k;?>]" value="<?php echo $totalreceivetilldate;?>" id="totalreceivetilldate_<?php echo $j;?>" />
		<input name="req_quantity[<?php echo $k;?>]" type="text" id="req_quantity_<?php echo $k;?>" value="<?php echo $items_row['req_quantity']?>" size="5" />
		<input name="required_qty[<?php echo $i;?>]" type="hidden" id="required_qty_<?php echo $k;?>"  alue="<?php echo $items_row['req_quantity']?>" /> 
		</td> 
		<td align="center"><input name="material_required_by[<?php echo $i;?>]" type="text" id="material_required_by_<?php echo $i;?>" style="width:100%" value="<?php echo $material_required_by; ?>"/></td>
		 <td align="center"><input name="remark[<?php echo $k;?>]" type="text" id="remark_<?php echo $k;?>" size="10" value="" /></td>
 <td>
		 <select name="MRstatus[<?php echo $k;?>]" id="MRstatus_<?php echo $k;?>"  style="width:50px">
		  
		  		 <option value="Active" <?php echo $MRstatus=='Active'?'selected':''?>  >Active</option>
 		 <option value="Inactive" <?php echo $MRstatus=='Inactive'?'selected':''?> >Inactive</option>
		  <option value="Declined" <?php echo $MRstatus=='Declined'?'selected':''?> >Declined</option>
		   <option value="Davation" <?php echo $MRstatus=='Davation'?'selected':''?> >Davation</option>
		 </select>
		 </td>
		 <td>
		 	
		 	<input name="delitem[]" type="checkbox" value="<?php echo $item_name['StockID'];?>" /><img src="images/Icon_Delete.png" height="15" width="15"></td>
      </tr>
		<?php 
		}
	  }
	  ?>
    <input type="hidden" name="counter" value="<?php echo ($i+$j);?>" id="counter" />
	</table> 
	</div>
	</div>

	<p align="center"><input type="submit" name="submit" value="Update" />
	<input type="submit" name="Cancel" value="Cancel" /></p>
</form>
<?
include('includes/footer.inc');
?>