<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
if(isset($_POST['submit']))
{
   	$supname=$_REQUEST['supname'];
	$code=$_REQUEST['code'];
 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 corp_master(code,corpname,branch) values('$code','$supname','$brcode')";
 mysqli_query($db,$sql)or die(mysqli_error($db));
}

?>
<title>PSN Telcon</title>
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link href="css/form.css" type="text/css" rel="stylesheet" media="screen" />
    <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>

<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;

}
</style>
<body background="back_ground.jpg">
<table class="container"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >> Corporate</font>
<br>

<CENTER>

<FORM ACTION='<?print $PHP_SELF?>' METHOD='POST'>
<table cellspacing=1 cellpadding=1 class='form'>
<tr ><td align=center>
<table>
<tr><td colspan=2 align=center bgcolor=green height=21><font color=white><b>CORPORATES  MASTER</TD></TR>
<tr><td>Name </td><td>
	<input type=text name='supname' size=40 onKeyDown=chkey(this)></td></tr>

<TR bgColor='lightsteelblue'><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 corp_master where branch='$brcode' order by corpname")or die(mysqli_error($db));
print "<table cellspacing=1 cellpadding=1 border=0 width=1200 class='report'>";
print "<th>No.<th>Name ";
print "<th>Edit";
$i=1;
while($row=mysqli_fetch_row($result))
{
 print "\n<tr bgColor='aliceblue' onMouseOver=bgColor='ivory' onMouseOut=bgColor='aliceblue'><td>".$i++."</td><td>$row[1]</td>";

 print "\n</tr>";
}
?>
</table>

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

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