<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
include("opendb.php");
//'#B0C4DE'
if(isset($_POST['save']))
{
$pname=$_REQUEST['pname'];
$sex=$_REQUEST['sex'];
$age=$_REQUEST['age'];
$addr1=$_REQUEST['addr1'];
$city=$_REQUEST['city'];
$ph1=$_REQUEST['ph1'];
$pin=$_REQUEST['pin'];
$ph2=$_REQUEST['ph2'];
$mob=$_REQUEST['mob'];
$exec=$_REQUEST['exec'];
$district=$_REQUEST['district'];
$addr2=$_REQUEST['addr2'];
$addr3=$_REQUEST['addr3'];
$addr4=$_REQUEST['addr4'];
$std=$_REQUEST['std'];
$location=$_REQUEST['location'];

 $code=substr($pname,0,4).substr(time(),5);
 $sql="insert into prospmaster values('$code','$brcode','$pname','$sex','$age','$addr1', '$city', '$pin','$ph1','$ph2', '$mob','$exec', '$district','$addr2','$addr3','$addr4','$std','$location')";
  mysqli_query($db,$sql) or die(mysqli_error($db));
}
?>
<head>
<title>Amplc</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>

<body background="back_ground.jpg">
<?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 >> Propspect Master</font>
<br>
<script>
 function valid()
 {
   if(document.f1.pname.value.length<=0)
   {
     alert('Invalid Prospect');
	document.f1.pname.focus();
     return false;
   }
   if(document.f1.addr1.value.length<=0)
   {
     alert('Invalid Address');
	document.f1.addr1.focus();
     return false;
   }

   if(document.f1.pin.value.length<6 || document.f1.pin.value.length>6 )
   {
     alert('Invalid PIN Code');
	document.f1.pin.focus();
     return false;
   }
 if(document.f1.std.length<=0)
 {
     alert('Invalid STD Code');
	document.f1.std.focus();
     return false;
   }

  var phone1=document.f1.ph1.value;
  var phone2=document.f1.ph2.value;
  var mobile=document.f1.mob.value;
 if(phone1.length<=0 && phone2.length<=0 && mobile.length<=0)
   {
     alert('Invalid Contact Numbers');
	document.f1.ph1.focus();
     return false;
   }
 if(mobile.length>0 && mobile.length!=10)
 {
     alert('Invalid Mobile Number');
	document.f1.mob.focus();
     return false;
   }
    
if(document.f1.location.selectedIndex<=0)
{
  alert('Invalid Location');
  document.f1.location.focus();
  return false;
}
   return true;
 }

</script>



</head>

<center>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onsubmit="return valid()">
  <table border="1" cellpadding="5" cellspacing="1" class='form'>
    <tr>
      <td colspan="9" align="center" height="17" bgcolor="green">
<font color=white><b>P R O S P E C T &nbsp;&nbsp; M A S T E R </td>
    </tr>
<TR><TD>Name </td><td><input type=text name='pname' size=40></td>
	<td>
	Sex <select name='sex'><option>Male</option><option>Female</option> </select></td>
	<td>Age</td><td><input type=text name='age' size=3 maxlength=2></td>
</tr>
<tr><td>Address 1</td><td colspan=6><input type=text name='addr1' size=70></td></tr>
<tr><td>Address 2</td><td colspan=6><input type=text name='addr2' size=70></td></tr>
<tr><td>Address 3</td><td colspan=6><input type=text name='addr3' size=70></td></tr>
<tr><td>Address 4</td><td colspan=6><input type=text name='addr4' size=70></td></tr>
<tr><td>Location</td><td colspan=6><select name='location'>
<option>Select</option>
<?
$locres=mysqli_query($db,"select * from locmaster order by loc");
while($locrow=mysqli_fetch_array($locres))
{
 print "<option>$locrow[loc]</option>";
}
?>
</select></td></tr>
<tr><td>City</td><td colspan=2><input type=text name='city' size=20>
District <select name='district'>
<option>Alappuzha</option>
<option>Ernakulam</option>
<option>Idukki</option>
<option>Kollam</option>
<option>Kannur</option>
<option>Kasaragod</option>
<option>Kottayam</option>
<option>Kozhikode</option>
<option>Malappuram</option>
<option>Palakkad</option>
<option>Pathanamthitta</option>
<option>Thrissur</option>
<option>Thiruvananthapuram</option>
<option>Wayanad</option>

   <option>   Bangalore Urban  </option>
   <option>   Bangalore Rural  </option>
   <option>   Bagalakot  </option>
   <option>   Belgaum  </option>
   <option>   Bellary  </option>
   <option>   Bidar  </option>
   <option>   Bijapur  </option>
   <option>   Chamarajanagar  </option>
   <option>   Chikballapur  </option>
   <option>   Chikkamaglur  </option>
   <option>   Chitiradurga  </option>
   <option>   Coorg  </option>
   <option>   Davanagere  </option>
   <option>   Dharwad  </option>
   <option>   Gulbarga  </option>
   <option>   Gadag  </option>
   <option>   Hassan  </option>
   <option>   Haveri  </option>
   <option>   Kolar  </option>
   <option>   Koppal  </option>
   <option>   Mandya  </option>
   <option>   Dakshina Kannada  </option>
   <option>   Mysore  </option>
   <option>   Raichur  </option>
   <option>   Ramanagra  </option>
   <option>   Shimoga  </option>
   <option>   Tumkur  </option>
   <option>   Udupi  </option>
   <option>   Uttara Kannada  </option> 

</td>
	<td><font color=red>*</font>Pin</td><td><input type=text name='pin' maxlength=6></td>
</tr>

<tr><td colspan=8>Std Code <input type=text name='std' size=4 maxlength=4> Phone 1 <input type=text name='ph1'>
	Phone 2 <input type=text name='ph2'>
</tr>
<tr><td>Mobile </td><td colspan=4><input type=text name='mob' size=23 maxlength=10></td></tr>

<tr><td> Executive </td><td colspan=10><select name='exec'>
<option><?print $user?></option>

</select>


<tr>
      <td colspan="9" align="center" height="17" >
	<input type=submit value='Save' name='save'> <input type=reset value='Cancel'>
</td></tr>
</table>
</form>
<style>
th{color:white;background-color:steelblue}
</style>

<table border="0" cellpadding="3" cellspacing="1" class='report'>
<th>No <th>Name <th>Address <th>City <th>Pin<th>STD<th>Phone1 <th>Phone2 <th>Mobile<th>District
<?
$i=1;
$pres=mysqli_query($db,"select * from prospmaster where brcode='$brcode' and exec='$user' order by pname");
while($prow=mysqli_fetch_array($pres))
{
 print "\n<tr><td>".$i++."</td><td>$prow[2]</td><td>$prow[addr1]</td><td>$prow[city]</td>";
 print "<td>$prow[pin]</td><td>$prow[std]</td><td>$prow[ph1]</td><td>$prow[ph2]</td><td>$prow[mob]</td>";
 print "<td>$prow[district]</td></tr>";
}
?>
</table>
</td></tr></table>
