<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($brcode)<=0)
{
 	print "<script> alert('Session timed out'); parent.document.location='../../index.php'; </script>";
 	return;
}
include("../../opendb.php");
?>
<head>
<title>ZF</title>
<script type="text/javascript" src="../../scripts/jquery-latest.js"></script>
<link type="text/css" href="../../includes/style1.css" rel="stylesheet" />
<link type="text/css" href="../../css/form.css" rel="stylesheet" />
<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>

    
  function chkno(val,id1)
    {
     if(isNaN(val))
       {
       alert('Invalid Number');
        document.getElementById(id1).value='';
       document.getElementById(id1).focus;
       }
    }
 

  function valid()
    {

   var chkno1=  document.getElementById('stno').value;
   var chkno2=  document.getElementById('endno').value;
   
  var bnk=document.f1.bank.value;
   if((chkno1='')||(chkno2==''))
   {
alert('Enter Cheque No');
return false;
  }
 if(bnk=='none')
  {
  alert('Select Bank/Account No');
  return false;
  }
 }

   
</script>

     

<body background="../../back_ground.jpg">
<?php include('logo1.php'); ?>
<?php include('top.php'); ?>
<br>
<body>
<center>
<table class="container"><tr><td>
<form name=f1 action='<?print $PHP_SELF;?>' method='post' onSubmit="return valid()">
<table class='form' align='center' width='40%'><tr><th colspan=2  bgcolor='grey'>New Cheque Book Registration</th></tr>

<td>Bank</td><td><select name='bank'><option value='none'>-Select-</option>

<?

$re=mysqli_query($db,"select * from ledger where (grp='Bank accounts' or grp='Bank O/d') and brcode='$brcode' order by led") or die(mysqli_error());

while($row=mysqli_fetch_row($re))
 {
 print "<option>$row[0]</option>";
 }
 ?>
</select>
</td></tr>
<tr bgcolor='grey'><th colspan=2>Cheque Number</th></tr>
<tr><td>Staring No.</td><td><input type=text name='stno' id='stno' onkeyup='chkno(this.value,this.id)'></td></tr>
<tr><td>Ending No.</td><td><input type=text name='endno' id='endno' onkeyup='chkno(this.value,this.id)'></td></tr>
<tr><th colspan=2  bgcolor='grey'>Remark</th></tr>
<tr><td >Remark.</td><td><textarea name='remark' ></textarea></td></tr>
<tr><td colspan='2' align='center'><input type='submit' name='save' value='Save'/></td></tr>
</table>
</td></tr></table>

<?
if(isset($_POST['save']))
 {
  $date=date('Y-m-d h:i:s');
  $stno=$_REQUEST['stno'];
  $bank=$_REQUEST['bank'];
  $remark=$_REQUEST['remark'];
  $endno=$_REQUEST['endno'];
  mysqli_query($db,"insert into chq_det (chq_no,chq_dt,brcode,bank,status,remarks,end_chq_no) values('$stno','$date','$brcode','$bank','NEW','$remark','$endno')");
   print"<script>alert('Your registration has been successfully completed');</script>";
   }
?>



