<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");
if($edit)
{
 $sql="update br_master set brname='$brname',addr1='$addr1',addr2='$addr2',city='$city', dist='$dist',stat='$stat', pin='$pin',phone1='$phone1',phone2='$phone2', email='$email', web='$web',brpass='$brpass',tin='$tin',cstno='$cst',secbrpass='$secbrpass' where code='$code' and brcode='$brcode'";
 mysqli_query($db,$sql)or die(mysqli_error());
include("branch.php");
return;
}

$result=mysqli_query($db,"select * from br_master where code='$code' and brcode='$brcode'");
$row=mysqli_fetch_array($result);
?>
<script>
function valid()
{
  submitOK="true";

 if(document.f1.brname.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Branch name');
 }

  if(submitOK=="true")
   return true;
  else
   return false;
}
function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
}
</script>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>

<CENTER>
<BR>
<form name='f1' action='<? print $PHP_SELF?>' method='Post' onSubmit="return valid()">
<input  type=hidden name='code' value='<?print $code?>'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr><td align=center>
<table>
<tr><td colspan=2 align=center>EDIT BRANCH MASTER</TD></TR>
<tr><td><font color=red>Branch Name </td><td>
<input type=text name='brname' readonly size=30 value='<?print $row[brname]?>' onKeyDown=chkey(this)>
<input type=button value='Edit' onClick=fn('<? print str_replace(' ','_',$row[brname])?>','<?print $code?>');></td></tr>
<tr><td>Address1 </td><td><input type=text name='addr1' size=40 value='<?print $row[addr1]?>'></td></tr>
<tr><td>Address2 </td><td><input type=text name='addr2' size=40 value='<?print $row[addr2]?>'></td></tr>
<tr><td>City </td><td><input type=text name='city' size=40 value='<?print $row[city]?>'></td></tr>
<tr><td>District </td><td><input type=text name='dist' size=40 value='<?print $row[dist]?>'></td></tr>
<tr><td>State </td><td><input type=text name='stat' size=40 value='<?print $row[stat]?>'></td></tr>
<tr><td>PinCODE </td><td><input type=text name='pin' size=40 value='<?print $row[pin]?>'></td></tr>
<tr><td>TIN </td><td><input type=text name='tin' size=40 value='<?print $row[tin]?>'></td></tr>
<tr><td>CST </td><td><input type=text name='cst' size=40 value='<?print $row[cst]?>'></td></tr>

<tr><td>Phone1 </td><td><input type=text name='phone1' size=40 value='<?print $row[phone1]?>'></td></tr>
<tr><td>Phone2 </td><td><input type=text name='phone2' size=40 value='<?print $row[phone2]?>'></td></tr>
<tr><td>Email_id </td><td><input type=text name='email' size=40 value='<?print $row[email]?>'></td></tr>
<tr><td>Web</td><td><input type=text name='web' size=40 value='<?print $row[web]?>'></td></tr>
<tr><td>Password</td><td><input type=password name='brpass' size=10 value='<?print $row[brpass]?>'></td></tr>
<tr><td>Sec.Password</td><td><input type=password name='secbrpass' size=10 value='<?print $row[secbrpass]?>'></td></tr>

<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT name='edit' VALUE='  SAVE  '>
<input type=button value='Cancel' onClick=history.go(-1)></TD></TR>

</table>
</td></tr>
</table>
</form>
<br>
<script>
 function fn(x,y)
 {
  if(confirm('Do you want to edit branch '+x+ ' ?'))
   document.location='editbrname.php?na='+x+'&code='+y;
 }
</script>

