<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}
include("../opendb.php");

//print $na.$code;
if($sv)
{
 $sq="update br_master set brname='$br' where brname='$na' and code='$code'";
 mysqli_query($db,$sq)or die(mysqli_error());
 $sq="update ledger set led='$br' where led='$na' and brcode='$brcode'";
 mysqli_query($db,$sq)or die(mysqli_error());
 $sq="update journal2 set partic='$br' where partic='$na'";
 mysqli_query($db,$sq)or die(mysqli_error());
 print "Data has been updated";
 print "<script> document.location='branch.php' </script>";
}

?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<script>
 function valid()
 {
   if(document.f1.br.value.length<=0)
   { alert('Invalid branch name'); return false;}
 }
</script>

<body bgcolor='ivory'>
<center>
<form  name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<?$na=str_replace('_',' ',$na);?>
<input type=hidden name='na' value='<?PRINT $na?>'>
<input type=hidden name='code' value='<?print $code?>'>

<table>
<th colspan=2>Edit Branch Name  <?print $na?>
<tr><td>Enter New Name </td><td><input type=text name='br' size=40></td></tr>
<tr><td colspan=2 align=center><input type=submit value='Save' name='sv'> <input type=button value='Cancel' onClick=history.go(-1)></td></tr>
</table>
</form>
