<?php
##This is where we gather the credentials in batches of up to three.  So far, we do not ask for scans of them.
##For the first goround, we try to steer the subject toward a birth certificate.
##The process continues to collect credentials until No more is selected as a credential type
##or the subject clicks the That's all button.
require("includes/.htconfig.php");
$msg="";

if( !empty($_POST) )
{
    $credtype=trim($_REQUEST["credential_type_code"]);
    $credential_name=trim($_REQUEST["credential_name"]);
    $issuing_agency=trim($_REQUEST["issuing_agency"]);
    $issue_date=trim($_REQUEST["issue_date"]);
    $valid_until=trim($_REQUEST["valid_until"]);
    $query="insert into credential set
      enrollee_id=$enrollee_id,
      issuing_agency='".mysql_escape_string($issuing_agency)."',
      credential_type_code='$credtype',
      credential_name='".mysql_escape_string($credential_name)."',
      issue_date='".mysql_escape_string($issue_date)."'";
    if (strlen($valid_until)>0) $query.=",valid_until='".mysql_escape_string($valid_until)."'";
    if (mysql_query($query,$link))
      advancePage($enrollee_id,$newby);
    else
    {
      baderror(__LINE__,"adding driver's license",$query);
      $errmsgs.="<BR>We failed to record your driver's license.";
    }
}

######################################################################################################

?>
<!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>Your Credentials</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

	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");
          $typequery="select * from credential_type_code";
          $credsquery="select c.*,ct.credential_type from credential c,credential_type_code ct where ct.credential_type_code=c.credential_type_code and enrollee_id=$enrollee_id order by issue_date";
          $creds=mysql_query($credsquery);
          $nCreds=mysql_num_rows($creds);
        ?>
        <?php
        if( 1 )
        {
        ?>
          <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="30%" valign="top">
                <div class="bodySubHeader">
                  <span class="bsht03">Step 3: Identity Documentation</span>
                </div>
              </td>
            </tr>
            <tr>
              <td colspan="4">
                Please give us the information on your driver's license.
                <br/>
              </td>
            </tr>
          </table>
        <form name="frm" method="post" action="
<?PHP
	echo $script;
?>" enctype="multipart/form-data" onSubmit="return validate()">
        <INPUT type="hidden" name='credential_type_code' value='dl'>
          <table>
            <tr>
              <td>
                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="DarkLightBox">
                  <tr>
                    <?PHP
                    echo inputCells("Name on your driver's license$redstar","credential_name");
                    echo "</tr><tr>".inputCells("License number","number");
                    echo "</tr><tr>".inputCells("Issuing Agency (state)$redstar","issuing_agency");
                    ?>
                  </tr>
                  <tr>
                    <td height="30" align="left" valign="top" class="browseEventContents">
                      Date of issue:
                    </td>
                    <td height="30" align="left" valign="top">
                      <input name="issue_date" id="issue_date" type="text" class="textField"/>&nbsp;<img src="cal/img.gif" id="f_trigger_"
<?PHP
	echo $j;
?>" style="border: 1px solid red; cursor: pointer;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''">
                    </td>
                  </tr>
                  <tr>
                    <td height="30" align="left" valign="top" class="browseEventContents">
                      Expiration date:</td>
                    <td height="30" align="left" valign="top">
                      <input name="valid_until"" id="valid_until" type="text" class="textField"/>&nbsp;<img src="cal/img.gif" id="f_trigger_e"
<?PHP
	echo $j;
?>" style="border: 1px solid red; cursor: pointer;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''">
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td height="35" align="left" valign="bottom" colspan="2">&nbsp;</td>
              <td height="35" align="left" valign="bottom">
                <input name="Submit" type="submit" value="Next" />
              </td>
            </tr>
          </table>
        </td>
    </tr>
  </table>
</form>
<script type="text/javascript">
  Calendar.setup({
  inputField     :    "issue_date",     // id of the input field
  ifFormat       :    "%Y-%m-%e",      // format of the input field
  button         :    "f_trigger_",  // trigger for the calendar (button ID)
  align          :    "Tl",           // alignment (defaults to "Bl")
  singleClick    :    true
  });
  Calendar.setup({
  inputField     :    "valid_until",     // 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>
<?PHP
	echo $msg;
?>
</strong></td>	   
	 </tr>
	</table>
<?php
}
?>
<?php
include_once("includes/footer.php");
?>
	   </td>
	 </tr> 	 
</table>
</body>
</html>