<?php
#This is where we capture the payment method.  Currently, we accept only credit cards but we don't process them.
require("includes/.htconfig.php");

if( !empty($_POST) )
{	
	$card_type_code=trim($_REQUEST['card_type_code']);
	$cardNumber=trim($_REQUEST['cardNumber']);
	$expiresionDate=trim($_REQUEST['expiresionDate']);
	$nameOnCard=trim($_REQUEST['nameOnCard']);
	$securityCode=trim($_REQUEST['securityCode']);
	$insert_CreditCard_sql="insert into credit_card set "
    ." enrollee_id=$enrollee_id"
	  .",card_type_code ='".mysql_escape_string($card_type_code)."',
	  card_number='".mysql_escape_string($cardNumber)."',
	  expiration_date='".mysql_escape_string($expiresionDate)."',
	  name_on_card='".mysql_escape_string($nameOnCard)."',
	  security_code='".mysql_escape_string($securityCode)."'";	
	  if(!mysql_query($insert_CreditCard_sql))
    {
      reporterror("inserting the new credit card",$insert_CreditCard_sql);
      $errmsgs.="We couldn't record your credit card information.  We'll look at this soon but go ahead.";
    }
  advancePage($enrollee_id,$newby);
}
?>
<!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>Payment 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.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 A WHOLE UMBER" )
		if( is_valid == false ) { document.frm.cardNumber.focus(); return is_valid }
		
	is_valid = blank_check( document.frm.expiresionDate.value, "PLEASE INPUT CARD EXPIRATION 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.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");
?>
<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 4: Payment Method</span>		
		</div>
		</td>
	 </tr> 
	</table>		
	<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="DarkLightBox">
	 <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">
       <select name="card_type_code">
         <?PHP
         echo spew_options($link,"select * from credit_card_type_code","credit_card_type_code","credit_card_type",$_REQUEST["card_type_code"]);
         ?>
       </select>
     </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">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     :    "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>
	<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
include_once("includes/footer.php");
?>
	   </td>
	 </tr> 	 
</table>
</body>
</html>