<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../index.html'; </script>";
 return;
}
?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
	tr{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<center>

<form action='<?print $PHP_SELF?>' method='post'>
<input type=hidden name='itcode' value='<?print $itcode?>'>
<input type=hidden name='ordno' value='<?print $ordno?>'>
<table>
<tr><td>Reason </td><td><select name='reas'>
<option>Not available in Branch</option>
<option>Not available in Telcon</option>
<option>Not available in PSN</option>
<option>High Price</option>
<option>Err</option>
</select>
</td>
<td><input type=submit value='Short close now' name='cls'></td></tr>
</table>
</form>

<?
if(isset($_POST['cls']))
{
include("../opendb.php");
include("../test.php");
$cldate=date("Y-m-d");
$reas=$_REQUEST['reas'];
$cldate=$_REQUEST['cldate'];
$itcode=$_REQUEST['itcode'];
$ordno=$_REQUEST['ordno'];
$sql="update purorder_spare set closed='Y',reas='$reas',cldate='$cldate' where partcode='$itcode' and orderno='$ordno' and brcode='$brcode'";

mysqli_query($db,$sql) or die(mysqli_error($db));
print "<script> alert('Item has been closed'); document.location='pur_orderview.php' </script>";
}
?>