<?
session_start();
if(strlen($user)<=0)
{
 print "<script> alert('You are not logged in') </script>";
 include("logout.php");
 return;
}

include("opendb.php");
if($sv)
{
$code=substr($trname,0,3).date(ymds);
$code=str_replace(' ','-',$code);
$sql="insert into transpmaster values('$code','$brcode','$trname','$addr','$phone','$mob')";
mysqli_query($db,$sql) or die(mysqli_error($db));
}
if($del)
{
 mysqli_query($db,"delete from transpmaster where code='$code'");
}
?>
<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 rel="stylesheet" href="css/form.css" type="text/css" />
    <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>
<script>
 function valid()
 {
   if(document.f1.trname.value.length<=0)
   {
    alert('Invalid Transporter Name');
    document.f1.trname.focus();
    return false;
   }
}
</script>

<body background="back_ground.jpg">
<?php include('logo2.php'); ?>
<?php include('includes/top.php'); ?>
<br>
<table class="container"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Master >> Transport</font>
<br>
<center>
<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()">
<table cellspacing=1 cellpadding=3 class='form'>
<th colspan=2 bgcolor='green'><font color=white size=3>TRANSPORT MASTER</th>
<tr><td>Name </td><td><input type=text name='trname' size=50></td></tr>
<tr><td>Address </td><td><textarea name='addr' cols=48></textarea></td></tr>
<tr><td>Phone </td><td><input type=text name='phone' size=50></td></tr>
<tr><td>Mobile </td><td><input type=text name='mob' size=50></td></tr>
<th colspan=2><input type=submit value='Save' name='sv'></th>
</table>
</form>
<?
 $res=mysqli_query($db,"select * from transpmaster where brcode='$brcode' order by trname");
 if(mysqli_num_rows($res)>0)
  {
     $i=1;
   print "<table cellspacing=1 cellpadding=3 class='report'>";
   print "<th>No <th>Name <th>Address <th>Phone <th>Mobile <th>Del <th>Edit";
    while($row=mysqli_fetch_array($res))
    {
      print "\n<tr><form action='$PHP_SELF'><input type=hidden name='code' value='$row[0]'>";
      print "<td>".$i++."</td><td>$row[2]</td><td><pre>$row[3]</td><td>$row[4]</td>";
      print "\n<td>$row[5]</td><td><input type=submit value='Del' name='del'>";
      print "<td><input type=button value='Edit' name='edit' onClick=window.open('edittransp.php?code=$row[0]',menubar=false,resizable=false)></form></tr>";
    }
   print "</table>";
 }
?>
</td></tr></table>
