<?php
session_start();
ob_start();

require("includes/config.php");
require("includes/dbcon.php");
if($_SESSION['uid']==""){	
	header("location:index.php");
	exit();
}
$enrollee_id=$_SESSION['uid'];

$activeQuery = mysql_query("select activFlag from enrollee where enrollee_id=".$enrollee_id);
$activeValue = mysql_fetch_array($activeQuery);

if( !empty($_POST) )
{	
	$father_name=trim($_REQUEST['father_name']);
	$mother_m_name=trim($_REQUEST['mother_m_name']);
	$ssn=trim($_REQUEST['ssn']);
	$countryBorn=trim($_REQUEST['countryBorn']);
	$gidCountry=trim($_REQUEST['gidCountry']);
	$education=trim($_REQUEST['education']);
	$passport=trim($_REQUEST['passport']);
	$governmentIdNumber=trim($_REQUEST['governmentIdNumber']);
	$bankName=trim($_REQUEST['bankName']);
	$drivingLicenceNumber=trim($_REQUEST['drivingLicenceNumber']);
	$gidIssueDate=trim($_REQUEST['gidIssueDate']);
	$gidExpiryDate=trim($_REQUEST['gidExpiryDate']);
	$gidIssuingAgency=trim($_REQUEST['gidIssuingAgency']);
	$cardType=trim($_REQUEST['cardType']);
	$cardNumber=trim($_REQUEST['cardNumber']);
	$expiresionDate=trim($_REQUEST['expiresionDate']);
	$nameOnCard=trim($_REQUEST['nameOnCard']);
	$issuingBank=trim($_REQUEST['issuingBank']);
	$securityCode=trim($_REQUEST['securityCode']);
	$cardNumber=($cardNumber) ? $cardNumber : "0";
	$insert_CreditCard_sql="insert into credit_card set 
	card_type ='".mysql_escape_string($cardType)."',
	card_number=".$cardNumber.",
	expiresion_date='".mysql_escape_string($expiresionDate)."',
	name_on_card='".mysql_escape_string($nameOnCard)."',
	issuing_bank='".mysql_escape_string($issuingBank)."',
	security_code='".mysql_escape_string($securityCode)."'";	
	mysql_query($insert_CreditCard_sql);
	$insrt_CreditCard_id= mysql_insert_id();	
	if($insrt_CreditCard_id)
	{
		$insert_foundationalInfo_sql="insert into foundational_info set 
		enrollee_id=".$enrollee_id.",
		country_born=".$countryBorn.", 
		credit_card_id=".$insrt_CreditCard_id.",
		gid_issuing_country=".$gidCountry.",
		ssn='".mysql_escape_string($ssn)."',
		education='".mysql_escape_string($education)."',
		mothers_m_name='".mysql_escape_string($mother_m_name)."',
		fathers_name='".mysql_escape_string($father_name)."',
		bank_name='".mysql_escape_string($bankName)."',
		driver_lic_number='".mysql_escape_string($drivingLicenceNumber)."',
		passport_number='".mysql_escape_string($passport)."',  
		gov_id_number='".mysql_escape_string($governmentIdNumber)."',
		gid_issue_date='".mysql_escape_string($gidIssueDate)."',
		gid_expiry_date='".mysql_escape_string($gidExpiryDate)."',			 
		gid_issuing_agency='".mysql_escape_string($gidIssuingAgency)."'";	
		mysql_query($insert_foundationalInfo_sql);			
		//header("location:selectOfficer2.php");	
		header("location:selectOfficerMap.php");	
	}
}
ob_end_flush();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="./style/design.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
.style1 {font-size: 0.8em}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>User Details Page</title>
<script language="JavaScript" src="includes/js/common.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="cal/calendar-win2k-cold-1.css" title="win2k-cold-1"><!-- main calendar program -->  
  <script type="text/javascript" src="cal/calendar.js"></script><!-- language for the calendar -->  
  <script type="text/javascript" src="cal/calendar-en.js"></script><!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->  
  <script type="text/javascript" src="cal/calendar-setup.js"></script>
<script language="JavaScript">
function validate()
{
	var is_valid=true
	is_valid = blank_check( document.frm.father_name.value, "PLEASE INPUT FATHER NAME" )
		if( is_valid == false ) { document.frm.father_name.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.mother_m_name.value, "PLEASE INPUT MOTHER MAIDEN NAME" )
		if( is_valid == false ) { document.frm.mother_m_name.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.ssn.value, "PLEASE INPUT SSN" )
		if( is_valid == false ) { document.frm.ssn.focus(); return is_valid }
		
	is_valid = chosen_check( document.frm.countryBorn.value, "PLEASE SELECT COUNTRY BORN" )
		if( is_valid == false ) { document.frm.countryBorn.focus(); return is_valid }
		
	is_valid = chosen_check( document.frm.gidCountry.value, "PLEASE SELECT GID COUNTRY" )
		if( is_valid == false ) { document.frm.gidCountry.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.education.value, "PLEASE INPUT EDUCATION" )
		if( is_valid == false ) { document.frm.education.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.passport.value, "PLEASE INPUT PASSPORT NUMBER" )
		if( is_valid == false ) { document.frm.passport.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.governmentIdNumber.value, "PLEASE INPUT GOVERNMENT ID NUMBER" )
		if( is_valid == false ) { document.frm.governmentIdNumber.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.bankName.value, "PLEASE INPUT BANK NAME" )
		if( is_valid == false ) { document.frm.bankName.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.drivingLicenceNumber.value, "PLEASE INPUT DRIVING LICENCE NUMBER" )
		if( is_valid == false ) { document.frm.drivingLicenceNumber.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.gidIssueDate.value, "PLEASE INPUT GID ISSUE DATE" )
		if( is_valid == false ) { document.frm.gidIssueDate.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.gidExpiryDate.value, "PLEASE INPUT GID EXPIRY DATE" )
		if( is_valid == false ) { document.frm.gidExpiryDate.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.gidIssuingAgency.value, "PLEASE INPUT GID ISSUING AGENCY" )
		if( is_valid == false ) { document.frm.gidIssuingAgency.focus(); return is_valid }
		
	/*is_valid = blank_check( document.frm.cardType.value, "PLEASE INPUT CARD TYPE" )
		if( is_valid == false ) { document.frm.cardType.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.cardNumber.value, "PLEASE INPUT CARD NUMBER" )
		if( is_valid == false ) { document.frm.cardNumber.focus(); return is_valid }	
		
	is_valid = number_check( document.frm.cardNumber.value, "CARD NUMBER SHOULD BE INTEGER" )
		if( is_valid == false ) { document.frm.cardNumber.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.expiresionDate.value, "PLEASE INPUT CARD EXPIRY DATE" )
		if( is_valid == false ) { document.frm.expiresionDate.focus(); return is_valid }

	is_valid = blank_check( document.frm.nameOnCard.value, "PLEASE INPUT NAME ON CARD" )
		if( is_valid == false ) { document.frm.nameOnCard.focus(); return is_valid }
	
	is_valid = blank_check( document.frm.issuingBank.value, "PLEASE INPUT ISSUING BANK" )
		if( is_valid == false ) { document.frm.issuingBank.focus(); return is_valid }

	is_valid = blank_check( document.frm.securityCode.value, "PLEASE INPUT SECURITY CODE" )
		if( is_valid == false ) { document.frm.securityCode.focus(); return is_valid }	*/

	return is_valid
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" valign="top">

<?php
include_once("includes/header.php");
?>
<?php
if( $activeValue['activFlag']== 0 )
{
?>
<form name="frm" method="post" action="" enctype="multipart/form-data" onSubmit="return validate()">	
	<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">	 
	 <tr>
	   <td width="30%" valign="top">
		<div class="bodySubHeader">
		<span class="bsht03">Step 2: User Details</span>		
		</div>
		</td>
	 </tr> 
	</table>		
	<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="DarkLightBox">	 
	 <tr>
	   <td height="30" align="center" valign="top" colspan="8"><strong><?=$err_msg?></strong></td>	   
	 </tr> 	 	
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">Father's Name:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="father_name" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top" width="1%">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Mother's Maiden Name:<font color="red"><strong>*</strong></font></td>
	   <td height="30" align="left" valign="top"><input name="mother_m_name" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top" width="1%">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">SSN:<font color="red"><strong>*</strong></font></td>
	   <td height="30" align="left" valign="top"><input name="ssn" type="text" class="textField"/></td>
	 </tr>	 
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">Country Born:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top" colspan="7">
			<select name='countryBorn' id='countryBorn'>
			<option value='0' Selected >--- Select Country ---</option>
			<?php					
					$countryQuery = mysql_query("select country_id, country_name from country order by country_name asc");
					while($countryValue = mysql_fetch_array($countryQuery))
					{
						if($countryValue['country_id'] == $_REQUEST['country_id'])
						{
							echo"<option value='".$countryValue['country_id']."' Selected >".$countryValue['country_name']."</option>";
						}
						else
						{
							echo"<option value='".$countryValue['country_id']."' >".$countryValue['country_name']."</option>";
						}
					}
			?>
			</select>
	   </td>	   
	 </tr>
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">GID Issuing Country:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top" colspan="7">
			<select name='gidCountry' id='gidCountry'>
			<option value='0' Selected >--- Select Country ---</option>
			<?php	
					$countryQuery = mysql_query("select country_id, country_name from country order by country_name asc");
					while($countryValue = mysql_fetch_array($countryQuery))
					{
						if($countryValue['country_id'] == $_REQUEST['country_id'])
						{
							echo"<option value='".$countryValue['country_id']."' Selected >".$countryValue['country_name']."</option>";
						}
						else
						{
							echo"<option value='".$countryValue['country_id']."' >".$countryValue['country_name']."</option>";
						}
					}
			?>
			</select>
	   </td>	   
	 </tr>
	 <tr>	   
	   <td height="30" align="left" valign="top" class="browseEventContents">Education:<font color="red"><strong>*</strong></font></td>	 
	   <td height="30" align="left" valign="top"><input name="education" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Passport Number:<font color="red"><strong>*</strong></font></td>	  
	   <td height="30" align="left" valign="top"><input name="passport" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Government ID Number:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="governmentIdNumber" type="text" class="textField"/></td>	   
	 </tr>	
	 
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">Bank Name:<font color="red"><strong>*</strong></font></td>	  
	   <td height="30" align="left" valign="top"><input name="bankName" type="text" class="textField"/></td>   
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Driving Licence Number:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="drivingLicenceNumber" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">&nbsp;</td>	   
	   <td height="30" align="left" valign="top">&nbsp;</td>
	 </tr>
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">GID Issue Date:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="gidIssueDate" id="gidIssueDate" type="text" class="textField"/>&nbsp;<img src="cal/img.gif" id="f_trigger_c" style="border: 1px solid red; cursor: pointer;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''"></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">GID Expiry Date:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="gidExpiryDate" id="gidExpiryDate" type="text" class="textField"/>&nbsp;<img src="cal/img.gif" id="f_trigger_d" style="border: 1px solid red; cursor: pointer;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''"></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">GID Issuing Agency:<font color="red"><strong>*</strong></font></td>	   
	   <td height="30" align="left" valign="top"><input name="gidIssuingAgency" type="text" class="textField"/></td>
	 </tr>	
	 <tr>
	   <td height="30" align="left" valign="top" colspan="8">&nbsp;</td> 
	 </tr>		 
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">Card Type:</td>	   
	   <td height="30" align="left" valign="top"><input name="cardType" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Card Number:</td>	   
	   <td height="30" align="left" valign="top"><input name="cardNumber" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Name on Card.:</td>	   
	  <td height="30" align="left" valign="top"><input name="nameOnCard" type="text" class="textField"/></td>	   
	 </tr>
	 <tr>
	   <td height="30" align="left" valign="top" class="browseEventContents">Expiration Date:</td>	   
	   <td height="30" align="left" valign="top"><input name="expiresionDate" id="expiresionDate" type="text" class="textField"/>&nbsp;<img src="cal/img.gif" id="f_trigger_e" style="border: 1px solid red; cursor: pointer;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''"></td>	   
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Issuing Bank:</td>	   
	   <td height="30" align="left" valign="top"><input name="issuingBank" type="text" class="textField"/></td>
	   <td height="30" align="left" valign="top">&nbsp;</td>
	   <td height="30" align="left" valign="top" class="browseEventContents">Security Code:</td>	   
	   <td height="30" align="left" valign="top"><input name="securityCode" type="text" class="textField"/></td>
	 </tr>	 
	 <tr>
	   <td height="35" align="left" valign="bottom" colspan="7">&nbsp;</td>	   
	   <td height="35" align="left" valign="bottom"><input name="Submit" type="submit" value="Next" /></td>
	 </tr>
	</table>
</form>
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "gidIssueDate",     // id of the input field    
        ifFormat       :    "%Y-%m-%e",      // format of the input field
        button         :    "f_trigger_c",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
	
	Calendar.setup({
        inputField     :    "gidExpiryDate",     // id of the input field    
        ifFormat       :    "%Y-%m-%e",      // format of the input field
        button         :    "f_trigger_d",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });

	Calendar.setup({
        inputField     :    "expiresionDate",     // id of the input field    
        ifFormat       :    "%Y-%m-%e",      // format of the input field
        button         :    "f_trigger_e",  // trigger for the calendar (button ID)
        align          :    "Tl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
</script>
<?php
}
else
{
	$msg="You are already activated";
?>
	<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">		 
	 <tr>
	   <td height="30" align="center" valign="top"><strong><?=$msg?></strong></td>	   
	 </tr>
	</table>
<?php
}
?>
<?php
include_once("includes/footer.php");
?>
	   </td>
	 </tr> 	 
</table>
</body>
</html>