<?
session_start();
if(strlen($brcode)<=0)
{
  print "<script> alert('Invalid User'); parent.document.location='ind.php' </script>";
  return;
}
?>
<style>
 td{font-family:verdana;font-size:12;color:black;}
 th{font-family:verdana;font-size:12;color:white;background-color:#5b5858}
 body{background-color:silver;}
 select
  {border-style:ridge;
   border-color:black;
   height:25px;
   border-size=1;
   font-family:verdana;
   color:black;
  }
 input
  {border-style:ridge;
   border-color:#22437f;
   background-color:white;
   height:25px;
   font-weight:bold;
   border-size=1;
   font-family:sans-serif;
   color:BLACK;
  }
</style>
<?
 include("opendb.php");
$result=mysqli_query($db,"select * from ledger where brcode='$brcode' and(grp='Sundry Creditors' or grp='Sundry Debtors')") or die(mysqli_error());
$re=mysqli_query($db,"select max(dt) from actrans");
$rw=mysqli_fetch_row($re);
$date=explode('-',$rw[0]);

?>

<body onload=document.f1.vouch.focus()>
<center>
<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;

<form name=f1 action="svpurch.php">
<table border=0 width=80%>
<TR bgcolor=5b5858><TD colspan=4 align=center><font color=white><B>PURCHASE ENTRY</B></td></tr>
<tr><td> Receipt No.</td><td><input type=text name=vouch size=5></td>
<td>Date</td><td>DD<input type=text maxlength='2' name=d size=1 value='<?print $date[2]?>'>
MM<input type=text name=m size=1 maxlength='2' value='<?print $date[1]?>'>
YYYY<input type=text name=y maxlength='4' size=3 value='<?print $date[0]?>'>
<tr>
  <td>By</td>
  <td> 
<select name=dr>
<?
//$result=mysqli_query($db,"select * from ledger where  grp='purchase accounts'") or die(mysqli_error());
$sql="select a.led from ledger a,acgroups b where a.grp=b.gname and b.headgroup='purchase' and a.brcode='$brcode'";
$result=mysqli_query($db,$sql) or die(mysqli_error());
//$result=mysqli_query($db,"select a.led from ledger a,acgroups b where a.grp=b.gname and b.headgroup='purchase'") or die(mysqli_error());
while($row=mysqli_fetch_row($result))
{
 print "<option>$row[0]</option>";
}
?>
</select>

</td>
  <td>(Rs.) </td><td><input type=text name=amt style={text-align:right}></td>
</tr>
<tr><td>To</td><td>
<select name=cr>
<option>Cash</option>
<?
$result=mysqli_query($db,"select * from ledger where brcode='$brcode' and (grp='Sundry Creditors' or grp='Sundry Debtors' or grp='Bank accounts')") or die(mysqli_error());
while($row=mysqli_fetch_row($result))
{
 print "<option>$row[0]</option>";
}
?>
</select>
<td>Narration</td><td><textarea name=narr cols=23></textarea></tr>
<TR bgcolor=5b5858><TD colspan=4 align=center><input type=submit value="Save">
<input type=reset value='Cancel'> </td></tr>
</table>
<!-- <input type=hidden name=dr value='Purchase'>-->
</form>
