<?
session_start();
include("../opendb.php");
$submit = $_REQUEST['submit'];
$code = $_REQUEST['code'];
if($submit)
{
$brname = $_REQUEST['$brname'];
$brman= $_REQUEST['brman'];
$braddr= $_REQUEST['braddr'];
$brcity= $_REQUEST['brcity'];
$brphone= $_REQUEST['brphone'];
$brpass1= $_REQUEST['brpass1'];
$btype= $_REQUEST['btype'];
$tin= $_REQUEST['tin'];
$cst= $_REQUEST['cst'];
$brstate= $_REQUEST['brstate'];
$pupass2= $_REQUEST['pupass2'];
$sapass2= $_REQUEST['sapass2'];
$jopass2= $_REQUEST['jopass2'];
$acpass2= $_REQUEST['acpass2'];
$otpass2= $_REQUEST['otpass2']; 

$vecvp= $_REQUEST['vecvp'];
$localp= $_REQUEST['localp'];   

    $sql="update branch set brman='$brman',braddr='$braddr',brcity='$brcity',brphone='$brphone',brpass='$brpass1',brtype='$btype',tin='$tin',cstno='$cst',brstate='$brstate',vecvpur='$vecvp',localpur='$localp' where brcode='$code'";
    mysqli_query($db,$sql) or die(mysqli_error($db));
    $sql="update branch set pupass2='$pupass2',sapass2='$sapass2',jopass2='$jopass2',acpass2='$acpass2',otpass2='$otpass2'";
   // mysqli_query($db,$sql) or die(mysqli_error($db));
    print("<script>window.close(); opener.document.location='createbr.php';</script>");
}
$result=mysqli_query($db,"select * from branch where brcode='$code'");
$row=mysqli_fetch_array($result)or die(mysqli_error($db));
?>
<script>
resizeTo(500,550);
</script>
<link rel="stylesheet" href="style.css" type="text/css" />
<script>
function validate()
{
   var p1=document.f1.brpass1.value
   var p2=document.f1.brpass2.value
   submit="true";
   if(document.f1.brname.value.length<3)
      {submit="false"; alert('Invalid branch name');}
   if(document.f1.brpass1.value.length<=0)
      {submit="false"; alert('Invalid Password');}
   if(document.f1.brpass2.value.length<=0)
      {submit="false"; alert('Invalid Password2');}
   if(p1!=p2)
      {submit="false"; alert('Passwords does not match');}
   if(submit=="false")
      return false;
}
</script>

<body bgcolor=fcfff1>
<font color=green>
<h3>Branch Updation</h3></font>
<hr bgcolor=red>
<center>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return validate()">
<input type=hidden name=code value='<?print $code?>'>
<table border=0  cellspacing=2 cellpadding=5>
<tr><td>Branch Name</td><td><input type=text name='brname' size=40 value='<?print $row['brname']?>'></td></tr>
<tr><td>Branch Type </td><td><select name='btype'>
<option><?print $row['brtype']?></option>
<option>Eicher</option>
<option>Telecon</option>
</select></td></tr>

<tr><td>Branch Manager</td><td><input type=text name='brman' size=40 value='<?print $row['brman']?>'></td></tr>
<tr><td>Address</td><td><input type=text name='braddr' size=40 value='<?print $row['braddr']?>'></td></tr>
<tr><td>City</td><td><input type=text name='brcity' size=40 value='<?print $row['brcity']?>'></td></tr>
<tr><td>State</td><td>
<select name='brstate'>
<option><?print $row['brstate']?></option>
<option>Kerala</option>
<option>Karnataka</option>
</select>
</td></tr>
<tr><td>Phone</td><td><input type=text name='brphone' size=40 value='<?print $row['brphone']?>'></td></tr>
<tr><td>Tin No.</td><td><input type=tex name='tin' size=40 value='<?print $row['tin']?>'></td></tr>
<tr><td>Cst No.</td><td><input type=text name='cst' size=40 value='<?print $row['cstno']?>'></td></tr>
<tr><td>Admin Password</td><td><input type=password name='brpass1' size=40 value='<?print $row['brpass']?>'></td></tr>
<tr><td>Confirm <br>Admin Password</td><td valign=bottom><input type=password name='brpass2' size=40 value='<?print $row['brpass']?>'></td></tr>



<tr><td>VECV Purchase <br>Days</td><td valign=bottom><input type=text name='vecvp' size=40 value='<?print $row['vecvpur']?>'></td></tr>
<tr><td>Local Purchase<br>Days</td><td valign=bottom><input type=text name='localp' size=40 value='<?print $row['localpur']?>'></td></tr>





<tr><td colspan=2 align=center><input type=submit name='submit' value='  S A V E  '> <input type=button value='   C A N C E L    ' onClick=window.close()></td></tr>
</table>
</form>


