<?
include_once('includes/top.php');
include_once('opendb.php');
include_once('test.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
if($_REQUEST['submit'])
{
$pono=$_REQUEST['pono'];
$amount=$_REQUEST['amount'];

	
 if(strlen($pono)<=0)
  {
     print "<script> alert('In sufficient entry'); history.back(1);  </script>";
     return;
  }
$re=mysqli_query($db,"select * from billtobillorder where pono='$pono' and brcode='$brcode'") or die(mysqli_error($db));
 if(mysqli_num_rows($re)>0)
    {
     print "<script> alert('Already exists'); history.back(1);  </script>";
     return;
   }



 $sql="insert into billtobillorder(pono,amount,brcode) values ('$pono','$amount','$brcode')";
 mysqli_query($db,$sql);
log_entry($brcode,$user,$REMOTE_ADDR,"stock upd cls:$clstock ops: $opstock month:$month ");



}
?>
<title>Khadi</title>
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link href="css/form.css" type="text/css" rel="stylesheet" media="screen" />
    <script type="text/javascript">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
    </script>

<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script
* This notice must stay intact for use
***********************************************/
                
function handleEnter (field, event) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 
		else
		return true;
	}      

</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;

}
</style>

<body background="back_ground.jpg">
<table class='container' style="background-color:#E0F8EC"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >> Stock</font>
<br>
<CENTER>

<FORM ACTION='<?print $PHP_SELF?>' METHOD='POST'>

<table cellspacing=1 cellpadding=1  class='form' >
<tr ><td align=center>
<table>
<tr><td colspan=2 align=center bgcolor='steelblue'><font color='ivory'>Purchase Order</font></TD></TR>


<tr ><td>Order No. </td><td><input type=text name='pono' size=40 onKeyPress='return handleEnter(this, event)'></td></tr>
<tr ><td>Amount</td><td><input type=text name='amount' size=40 onKeyPress='return handleEnter(this, event)'></td></tr>
</tr>


<TR ><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME= 'submit' VALUE='  SAVE  '></TD></TR>

</table>
</td></tr>
</table>

</FORM>

<?


$sql="select * from billtobillorder where brcode='$brcode'";
$result=mysqli_query($db,$sql)or die(mysqli_error($db));
$num=mysqli_num_rows($result);
if($num>0)
{
?>

<table cellspacing=1 cellpadding=1 border=1 class='report'>
<th>No.<th>Code<th>Purchase Order no.&nbsp;<th>Amount<th>Action
<?
$i=1;
while($row=mysqli_fetch_row($result))
{
?>
<form name='form1' id='form1' method='POST' Action='editpurchaseorder.php?cod=<? echo $row[0]; ?>'>
<tr bgColor='c1d7bb' onMouseOver=bgColor='lightsteelblue' onMouseOut=bgColor='c1d7bb' ><td><? echo $i++; ?></td><td align=center><? echo $row[0] ?></td><td align=center><? echo $row[1] ?></td><td align=center><? echo $row[2] ?></td>

<td align=center><input type=submit value='Edit' name='ed' ></td></tr>
</form>
<?
}
}
?>
</table>

</td></tr></table>
<br>
<script>
function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }

}
</script>
