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

 $code=substr($supname,0,3).substr(time(),7,3); 
 $code=str_replace(' ','-',$code);

 $sql="insert into pantype values('$code','$supname','$addr1','$addr2','$city','$dist', '$stat','$pin','$phone1','$phone2','$tin','$cst','$email','$web','$brcode')";
 mysqli_query($db,$sql)or die(mysqli_error());
}

?>
<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 ACTION='<?print $PHP_SELF?>' METHOD='POST'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr bgColor='c1d7bb'><td align=center>
<table>
<tr bgColor='c1d7bb'><td colspan=2 align=center>PAN TYPE MASTER</TD></TR>
<tr bgColor='c1d7bb'><td>Pan type</td><td>

<input type=text name='supname' size=40 onKeyDown=chkey(this)></td></tr>
<!--
<tr bgColor='c1d7bb'><td>Address1 </td><td><input type=text name='addr1' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Address2 </td><td><input type=text name='addr2' size=40></td></tr>
<tr bgColor='c1d7bb'><td>City </td><td><input type=text name='city' size=40></td></tr>
<tr bgColor='c1d7bb'><td>District </td><td><input type=text name='dist' size=40></td></tr>
<tr bgColor='c1d7bb'><td>State </td><td><input type=text name='stat' size=40 value='KERALA'></td></tr>
<tr bgColor='c1d7bb'><td>Pin No </td><td><input type=text name='pin' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Phone1 </td><td><input type=text name='phone1' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Phone2 </td><td><input type=text name='phone2' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Tin NO </td><td><input type=text name='tin' size=40></td></tr>
<tr bgColor='c1d7bb'><td>CST No & Date </td><td><input type=text name='cst' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Email_id </td><td><input type=text name='email' size=40></td></tr>
<tr bgColor='c1d7bb'><td>Web</td><td><input type=text name='web' size=40></td></tr>
-->
<TR bgColor='c1d7bb'><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME= 'submit' VALUE='  SAVE  '></TD></TR>

</table>
</td></tr>
</table>
</FORM>

<?
$result=mysqli_query($db,"select * from pantype where branch='$brcode' order by corpname")or die(mysqli_error());
print "<table cellspacing=1 cellpadding=1 border=1 >";
print "<th>No.<th>Name ";
print "<th>Edit";
$i=1;
while($row=mysqli_fetch_row($result))
{
 print "\n<tr bgColor='c1d7bb' onMouseOver=bgColor='lightsteelblue' onMouseOut=bgColor='c1d7bb'><td>".$i++."</td><td>$row[1]</td>";

 print "\n<td align=center><a href='editpantype_mast.php?code=$row[0]' title='Edit Entry' onMouseOver='window.status=''; return true'><img src='../img/edit.gif' border=0></a></td></tr>";
}
?>
</table>

<br>
<script>
function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
}
</script>
