<?   
include('auth.php');
include('common.php');

$update_success=false;
$insert_success=false;

if (count($_POST) > 0) //form has been submitted by user
{
	$FIELDS[0]="birth"; 
	$FIELDS[1]="startdate";	
	$FIELDS[2]="criminalcheckdate"; 
	$FIELDS[3]="confirmationdate"; 
	
	//areas of interest
	$aosarray = $_POST['areaofinterest'];
	if (count($aosarray)>0)
	{
		foreach ($aosarray as $value)
		{
		    $AREAS_selected[$value]=true;
		}
	}
	
	//assemble all dates
	$startdate = $_POST['startyear']."-".$_POST['startmonth']."-".$_POST['startday'];
	$dob = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
	$crimdate = $_POST['crimyear']."-".$_POST['crimmonth']."-".$_POST['crimday'];
	$confdate = $_POST['confyear']."-".$_POST['confmonth']."-".$_POST['confday'];

	//assemble phone numbers
	$homephone = $_POST['phone1'].$_POST['phone2'].$_POST['phone3'];
	$altphone = $_POST['cell1'].$_POST['cell2'].$_POST['cell3'];
	$workphone = $_POST['work1'].$_POST['work2'].$_POST['work3'];
	
	//prep radio buttons
	$callhome= $_POST['callhome']; if ($callhome == 1) $callhomeyes = "checked"; if ($callhome == 0) $callhomeno = "checked"; 
	$callwork= $_POST['callwork']; if ($callwork == 1) $callworkyes = "checked"; if ($callwork == 0) $callworkno = "checked"; 
	$gender= $_POST['gender']; if ($gender == 1) $gendermale = "checked"; if ($gender == 0) $genderfemale = "checked"; 
	$mothertongue= $_POST['mothertongue'];  if ($mothertongue == 1) $langeng = "checked"; if ($mothertongue == 2) $langfr = "checked"; if ($mothertongue == 3) $langother = "checked"; 
	$crime= $_POST['crime']; if ($crime == 1) $crimeyes = "checked"; if ($crime == 0) $crimeno = "checked"; 
	$drinking= $_POST['drinking'];  if ($drinking == 1) $drinkingyes = "checked"; if ($drinking == 0) $drinkingno = "checked"; 
	$health= $_POST['health'];  if ($health == 1) $healthyes = "checked"; if ($health == 0) $healthno = "checked"; 
	$criminalcheck= $_POST['criminalcheck']; if ($criminalcheck == 1) $criminalcheck_yes = "checked"; if ($criminalcheck == 0) $criminalcheck_no = "checked"; 
	$confform= $_POST['confirmation']; if ($confform == 1) $confform_yes = "checked"; if ($confform == 0) $confform_no = "checked"; 
	$criminalissue= $_POST['criminalissue']; if ($criminalissue == 1) $criminalissueyes = "checked"; if ($criminalissue == 0) $criminalissueno = "checked"; 
	$specialskills= $_POST['specialskills']; if ($specialskills == 1) $specialskillsyes = "checked"; if ($specialskills == 0) $specialskillsno = "checked"; 



	//prep the data regardless
	$firstname= secure_user_input($_POST['firstname']);
	$lastname= secure_user_input($_POST['lastname']);
	$address= secure_user_input($_POST['address']);
	$apt= secure_user_input($_POST['apt']);
	$pobox= secure_user_input($_POST['pobox']);
	$city= secure_user_input($_POST['city']);
	$prov= secure_user_input($_POST['prov']);
	$postalcode= secure_user_input($_POST['postalcode']);
	$email= secure_user_input($_POST['email']);
	$password= secure_user_input($_POST['password']);
	$langother= secure_user_input($_POST['langother']);
	$crimeinfo= secure_user_input($_POST['crimeinfo']);
	$drinkinginfo= secure_user_input($_POST['drinkinginfo']);
	$healthinfo= secure_user_input($_POST['healthinfo']);
	$criminalinfo= secure_user_input($_POST['criminalinfo']);
	$how= secure_user_input($_POST['how']);
	$vtype= secure_user_input($_POST['vtype']);
	$council= secure_user_input($_POST['council']);
	$howmuchtime= secure_user_input($_POST['howmuchtime']);


	$specialskillsinfo= secure_user_input($_POST['specialskillsinfo']);


	if (!$firstname || !$lastname  )
	{
		$mssg= "*** REQUIRED FIELDS MISSING ***";
	
	}
	else
	{
		if ($_GET['mode'] == 'new' && !$_POST['vid'])
		{
		

			$SQL = "INSERT INTO volunteer
			(`email`, 
			`firstname`,		
			`lastname`, 		
			`startdate`,
			`active` ,
			`vtype_id` ,
			`council_id` ,
			`address` ,		
			`apt` ,		
			`pobox` 	,	
			`city` ,		
			`prov` 	,	
			`postalcode`, 		
			`gender` 	,	
			`birth` 	,	
			`homephone` ,		
			`altphone`, 		
			`workphone` ,		
			`callathome`,		
			`callatwork`,		
			`lang` 	,	
			`langother` ,		
			`health` 	,	
			`healthinfo` ,		
			`confirmation` ,		
			`confirmationdate`,		
			`crime`,
			`crimeinfo` ,
			`criminalcheck` ,		
			`criminalcheckdate`,
			`criminalissue`,
			`criminalinfo`,
			`drinking` ,		
			`drinkinginfo`,
			`how`,
			`howmuchtime`,			
			`specialskills`,
			`specialskillsinfo`			
			)			
			 VALUES 
			('".$email."',
			 '".$firstname."',
			 '".$lastname."',
			 '".$startdate."',
			 '1',
			 '".$vtype."',
			 '".$council."',
			 '".$address."',
			 '".$apt."',
			 '".$pobox."',
			 '".$city."',
			 '".$prov."',
			 '".$postalcode."',
			 '".$gender."',
			 '".$dob."',
			 '".$homephone."',
			 '".$altphone."',
			 '".$workphone."',
			 '".$callhome."',
			 '".$callwork."',
			 '".$mothertongue."',
			 '".$langother."',
			 '".$health."',
			 '".$healthinfo."',
			 '".$confform."',
			 '".$confdate."',
			 '".$crime."',
			 '".$crimeinfo."',
 			 '".$criminalcheck."',
 			 '".$crimdate."',
 			 '".$criminalissue."',
 			   '".$criminalinfo."',
			 '".$drinking."',
			 '".$drinkinginfo."',
			 '".$how."',
			 '".$howmuchtime."',
			'".$specialskills."',
			'".$specialskillsinfo."'			 
			 )";						
		
			if (!llnb_query($SQL))
				echo "ERROR on INSERT SQL";
				
			$currentid = mysql_insert_id();
			$currentVID= $currentid;
			
			//deal with 0000-00-00 fields and make them null
			setDateNullFields($FIELDS, $currentVID, "volunteer");				
			
			//add a status of active to status history
			//use start date if not empty
			if ($startdate == '--')
				$thedate = "CURDATE()";
			else
				$thedate = "'".$startdate."'";			
			
			$SQL="INSERT INTO status
			(user_id, thestatus,usertype,thedate )
						VALUES 
			('".$currentid."', 1, '3', ".$thedate." )";
			$results = llnb_query($SQL);
				
				
				
			//echo $SQL."<BR><BR>";
			$insert_success=true;

	
		}
		else if ($_POST['vid'] && $_GET['mode'] == 'edit' )
		{
			$SQL = "UPDATE volunteer SET
			`email`= 					'".$email."',
			`firstname`=				'".$firstname."',
			`lastname`= 				'".$lastname."',
			`startdate`=				'".$startdate."',
			`vtype_id`=				'".$vtype."',
			`council_id`=				'".$council."',
			`address`=				'".$address."',
			`apt`=					'".$apt."',
			`pobox`=				'".$pobox."',
			`city`=					'".$city."',
			`prov`=				'".$prov."',
			`postalcode`= 				'".$postalcode."',
			`gender`=				'".$gender."',
			`birth`=				'".$dob."',
			`homephone`=				'".$homephone."',
			`altphone`= 				'".$altphone."',
			`workphone`=				'".$workphone."',
			`callathome`=				'".$callhome."',
			`callatwork`=				'".$callwork."',
			`lang`=				'".$mothertongue."',
			`langother`=				'".$langother."',
			`health`=				'".$health."',
			`healthinfo`=				'".$healthinfo."',
			`confirmation`=				'".$confform."',
			`confirmationdate`=				'".$confdate."',
			`crime`=					'".$crime."',
			`crimeinfo`=				'".$crimeinfo."',
			`criminalcheck`=			'".$criminalcheck."',
			`criminalcheckdate`=		'".$crimdate."',
			`criminalissue`=			'".$criminalissue."',
			`criminalinfo`=			'".$criminalinfo."',
			`drinking`=				'".$drinking."',
			`drinkinginfo`=			'".$drinkinginfo."',
			`how`=					'".$how."',
			`howmuchtime`=					'".$howmuchtime."',
			`specialskills`=			'".$specialskills."',
			`specialskillsinfo`=		'".$specialskillsinfo."'	
				WHERE id=".$_POST['vid'];

			$results = llnb_query($SQL);
			
			//deal with 0000-00-00 fields and make them null
			setDateNullFields($FIELDS, $_POST['vid'], "volunteer");	
			
			$update_success = true;
			//echo $SQL;
			
		}
		
			if (!$currentVID)
				$currentVID = $_POST['vid'];
			
			//delete records for this user and update with new records
			$SQL = "DELETE FROM volunteer_areaofinterest WHERE volunteer_id=".$currentVID;
			$results = llnb_query($SQL);
			
			if (count($AREAS_selected)>0)
			{
				//insert the areas of interest
				foreach ($AREAS_selected as $thekey=>$value)
				{

				   if ($thekey == 7)	
					$otherinfo = $_POST['otherarea'];
				   else
					$otherinfo = '';

					$SQL = "INSERT INTO volunteer_areaofinterest 
					(volunteer_id, aoi_id, info) VALUES (".$currentVID.", ".$thekey.", '".$otherinfo."')";
					//echo $SQL."<BR><BR>";
					$results = llnb_query($SQL);
				}
			}
			header("Location: ./volunteer_overview.php?vid=".$currentVID);
		
		
		
		
	}

}
else if (isset($_GET['vid']))
{
	$SQL="SELECT * FROM volunteer WHERE id=".$_GET['vid'];
	$results = llnb_query($SQL);
	$row = llnb_fetch_assoc($results);

	//create date pieces from DB
	$datepieces = explode("-", $row['birth']);
	$bmonth = $datepieces[1];
	$bday = $datepieces[2];
	$byear = $datepieces[0];

	$datepieces = explode("-", $row['confirmationdate']);
	$confmonth = $datepieces[1];
	$confday = $datepieces[2];
	$confyear = $datepieces[0];
	
	$datepieces = explode("-", $row['criminalcheckdate']);
	$crimmonth = $datepieces[1];
	$crimday = $datepieces[2];
	$crimyear = $datepieces[0];

	$datepieces = explode("-", $row['startdate']);
	$startmonth = $datepieces[1];
	$startday = $datepieces[2];
	$startyear = $datepieces[0];

	//fetch areas of interest per volunteer
	$AREAS_selected = fetchAreasOfInterest($_GET['vid'], "v");

	//assemble phone numbers
	$phnums = phonenumberToPieces($row['homephone']);
	$ph1 = $phnums[0]; $ph2 = $phnums[1]; $ph3 = $phnums[2]; 
	$phnums = phonenumberToPieces($row['altphone']);
	$c1 = $phnums[0]; $c2 = $phnums[1]; $c3 = $phnums[2]; 
	$phnums = phonenumberToPieces($row['workphone']);
	$w1 = $phnums[0]; $w2 = $phnums[1]; $w3 = $phnums[2]; 


	//prep radio buttons
	$callhome= $row['callathome']; if ($callhome == 1) $callhomeyes = "checked"; if ($callhome == 0) $callhomeno = "checked"; 
	$callwork= $row['callatwork']; if ($callwork == 1) $callworkyes = "checked"; if ($callwork == 0) $callworkno = "checked"; 
	$gender= $row['gender']; if ($gender == 1) $gendermale = "checked"; if ($gender == 0) $genderfemale = "checked"; 
	$mothertongue= $row['lang'];  if ($mothertongue == 1) $langeng = "checked"; if ($mothertongue == 2) $langfr = "checked"; if ($mothertongue == 3) $langother = "checked"; 
	$crime= $row['crime']; if ($crime == 1) $crimeyes = "checked"; if ($crime == 0) $crimeno = "checked"; 
	$drinking= $row['drinking'];  if ($drinking == 1) $drinkingyes = "checked"; if ($drinking == 0) $drinkingno = "checked"; 
	$health= $row['health'];  if ($health == 1) $healthyes = "checked"; if ($health == 0) $healthno = "checked"; 
	$criminalcheck= $row['criminalcheck']; if ($criminalcheck == 1) $criminalcheck_yes = "checked"; if ($criminalcheck == 0) $criminalcheck_no = "checked"; 
	$confform= $row['confirmation']; if ($confform == 1) $confform_yes = "checked"; if ($confform == 0) $confform_no = "checked"; 
	$criminalissue= $row['criminalissue']; if ($criminalissue == 1) $criminalissueyes = "checked"; if ($criminalissue == 0) $criminalissueno = "checked"; 
	$specialskills= $row['specialskills']; if ($specialskills == 1) $specialskillsyes = "checked"; if ($specialskills == 0) $specialskillsno = "checked"; 
	
	$council= $row['council_id'];

	
	$SQL="SELECT ta.info as otherinfo 
		FROM volunteer_areaofinterest as ta WHERE volunteer_id=".$_GET['vid']." AND aoi_id= 7";
	$results = llnb_query($SQL);
	$therow = llnb_fetch_assoc($results);
	$otherarea= $therow['otherinfo'];
}
else //default values
{

	//assemble phone numbers
	$ph1= "506";
	$c1 =  "506";
	$w1 =  "506";
}

?>


<!doctype html>
<html class="no-js" lang="en"> <!--<![endif]-->

<head>
<meta charset="utf-8">

<!-- Use the .htaccess and remove these lines to avoid edge case issues.
       More info: h5bp.com/i/378 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LLNB System</title>
<meta name="description" content="">

<!-- Mobile viewport optimized: h5bp.com/viewport -->
<meta name="viewport" content="width=device-width, maximum-scale=1.0">

<!-- Place favicon.ico and apple-touch-icon.png in the root directory: mathiasbynens.be/notes/touch-icons -->
  <LINK REL="SHORTCUT ICON" HREF="favicon.ico">

<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/llnb-style.css">

<!-- More ideas for your <head> here: h5bp.com/d/head-Tips -->

<script src="js/libs/modernizr-2.5.3.min.js"></script>
</head>
<body onLoad="document.forms.personalinfo.username.focus()">
<div id="wrap"> 
  <!-- Prompt IE 6 users to install Chrome Frame. Remove this if you support IE 6.
       chromium.org/developers/how-tos/chrome-frame-getting-started --> 
  <!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
  <header><a href="index.php" class="btn lfr" style="position:relative; top: 15px; right: 0;">Logout</a>
    <h1>Laubach Literacy</h1>
    <nav id="menu" class="clearfix navmenu">
    <a href="home.php" class="btn lfl">Home</a>
        <?
        	if ($_SESSION['ulevel'] == $_COORD || $_SESSION['ulevel'] == $_TUTOR)
    			$force_council= "?council=".$_SESSION['council_id'];
        ?>
        <a href="volunteer_list.php<?=$force_council;?>" class="btn lfl">Volunteer List</a>
    
    
    
       <?
        if ($_GET['mode'] != "new")
        {
        	 echo "<a href=\"volunteer_overview.php?vid=".$_GET['vid']."\" class=\"btn lfl\">Volunteer Overview</a></nav>";
        }
    ?>
  </header>
  <div role="main" id="main" class="clearfix">
    <?
    
    if ($_GET['mode'] != "new")
    {
		echo "
		    <div id=\"location\">
			 <H2><span>Volunteer:</span> ".$row['firstname']." ".$row['lastname']."</H2>
		    </div>";
    }
    ?>
    <!-- end of location -->
    <div>
      <H2>Personal Information</H2>
         <div style="color: red;"><?=$mssg;?></div>

      <form name="personalinfo" class="midform" action="volunteer_personalinfo.php?mode=<?=$_GET['mode']; ?>&vid=<?= $_GET['vid'];?>" method="post">
              <div style="border-bottom: 2px solid #666; padding-bottom: 10px;">
        </div> 
   <label style="display:block;">Type of Volunteer</label>
       <select name="vtype" class="volunteertype" title="Select volunteer type">
		<?
		$myvtype = ($_POST['vtype']) ? $_POST['vtype'] : $row['vtype_id'];
			echo buildVtypeDropdown($myvtype); 
		?>

    </select>
    <div style="clear:both;"></div>


        <div class="input">
          <div class="input">
            <label style="display:block;">Start Date:</label>
            <select name="startmonth" title="month">
			<?
			$mymon = ($_POST['startmonth']) ? stripslashes($_POST['startmonth']) : $startmonth;
			echo buildMonthDropdown($mymon, $_MONTHS_abbr); 
			?>

            </select>
            <select name="startday" title="date">
				<?
				$myday = ($_POST['startday']) ? stripslashes($_POST['startday']) : $startday;
				echo buildDayDropdown($myday); 
				?>

            </select>
            <select name="startyear" title="Year">
				<?
				$myyear = ($_POST['startyear']) ? stripslashes($_POST['startyear']) : $startyear;
				echo buildYearDropdown($myyear, "2012"); 
				?>

            </select>
          </div>
          <div class="input plusleft">
            <label style="display:block;">Council Select:</label>
	  <?
		if ($_SESSION['ulevel'] == $_COORD || $_SESSION['ulevel'] == $_TUTOR)
		{
			$council = $_SESSION['council_id'];
			
			echo 
				"<strong>".fetchCouncilName($council)."</strong>
				<input type=\"hidden\" name=\"council\" readonly value=\"".$council."\">";
		}
		else
		{
			echo "<select name=\"council\">".buildCouncilDropdownALLoption($council)."</select>";
		}
	  ?>
        </div >
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label  class="mandatory">First Name:</label>
        <input name="firstname" type="text"   value="<?= ($_POST['firstname']) ? stripslashes($_POST['firstname']) : $row['firstname'];?>">
        </div>
        <div class="input">
          <label  class="mandatory">Last Name:</label>
              <input name="lastname" type="text"   value="<?= ($_POST['lastname']) ? stripslashes($_POST['lastname']) : $row['lastname'];?>">
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>Street Address:</label>
        <input name="address" type="text"   value="<?= ($_POST['address']) ? stripslashes($_POST['address']) : $row['address'];?>" class="midinp">
        </div>
        <div class="input">
          <label>Apt.#:</label>
        <input name="apt" type="text"   value="<?= ($_POST['apt']) ? stripslashes($_POST['apt']) : $row['apt'];?>" class="ssminp">
        </div>
        <div class="input">
          <label>PO Box:</label>
        <input name="pobox" type="text"   value="<?= ($_POST['pobox']) ? stripslashes($_POST['pobox']) : $row['pobox'];?>" class="sminp">
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>City/Town:</label>
        <input name="city" type="text" value="<?= ($_POST['city']) ? stripslashes($_POST['city']) : $row['city'];?>" >
        </div>
        <div class="input">
          <label>Province:</label>
          <select name="prov" class="typevolunteer" title="prov">

			<?
			echo  buildProvDropdown($prov);
			?>
          </select>
                </div>
        <div class="input">
          <label>Postal Code:</label>
        <input name="postalcode" type="text" value="<?= ($_POST['postalcode']) ? stripslashes($_POST['postalcode']) : $row['postalcode'];?>" class="sminp">
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>Home Phone:</label>
        <input name="phone1" MAXLENGTH="3" type="text" value="<?= ($_POST['phone1']) ? stripslashes($_POST['phone1']) : $ph1;?>" class="ssminp">
        <input name="phone2" MAXLENGTH="3" type="text" value="<?= ($_POST['phone2']) ? stripslashes($_POST['phone2']) : $ph2;?>"  class="ssminp">
        <input name="phone3" MAXLENGTH="4" type="text" value="<?= ($_POST['phone3']) ? stripslashes($_POST['phone3']) : $ph3;?>" class="smminp">

        </div>
        <div class="input" style="margin-left:30px; display:none;">
          <label>May we call you at home?</label>
          <label class="radio" style="margin-right:15px;">
	        <input name="callhome" type="radio" value="1" <?= $callhomeyes;?>>Yes</label>
	        <label class="radio">
	        <input name="callhome" type="radio" value="0" <?= $callhomeno; ?> >No</label>

        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>Alternate Phone:</label>
        <input name="cell1" MAXLENGTH="3" type="text"  value="<?= ($_POST['cell1']) ? stripslashes($_POST['cell1']) : $c1;?>" class="ssminp">
        <input name="cell2" MAXLENGTH="3" type="text" value="<?= ($_POST['cell2']) ? stripslashes($_POST['cell2']) : $c2;?>"  class="ssminp">
        <input name="cell3" MAXLENGTH="4" type="text" value="<?= ($_POST['cell3']) ? stripslashes($_POST['cell3']) : $c3;?>"  class="smminp">
       </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>Work Phone:</label>
        <input name="work1" MAXLENGTH="3" type="text" value="<?= ($_POST['work1']) ? stripslashes($_POST['work1']) : $w1;?>" class="ssminp">
        <input name="work2" MAXLENGTH="3" type="text"  value="<?= ($_POST['work2']) ? stripslashes($_POST['work2']) : $w2;?>" class="ssminp">
        <input name="work3" MAXLENGTH="4" type="text" value="<?= ($_POST['work3']) ? stripslashes($_POST['work3']) : $w3;?>"  class="smminp">
        </div>
        <div class="input" style="margin-left:30px">
	        <label>May we call you at work?</label>
	        <label class="radio" style="margin-right:15px;">
	        <input name="callwork" type="radio" value="1" <?= $callworkyes;?>>Yes</label>
	        <label class="radio">
	        <input name="callwork" type="radio" value="0"  <?= $callworkno;?>>No</label>
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label>Email Address: *</label>
        <input name="email" type="text"  value="<?= ($_POST['email']) ? stripslashes($_POST['email']) : $row['email'];?>" class="lrginp">
        </div>

        <div style="clear:both;"></div>
        <div class="input">
          <label style="display:block;">Date of Birth:</label>
          <select name="month" title="month">
          <?
		       	$mymon = ($_POST['month']) ? stripslashes($_POST['month']) : $bmonth;
		       	echo buildMonthDropdown($mymon, $_MONTHS_abbr); 
       	?>
          </select>
          <select name="day" title="date">
           	<?
		        	$myday = ($_POST['day']) ? stripslashes($_POST['day']) : $bday;
		        	echo buildDayDropdown($myday); 
       	?>
          </select>
          <select name="year" title="Year">
                	<?
	           	$myyear = ($_POST['year']) ? stripslashes($_POST['year']) : $byear;
	           	echo buildYearDropdown($myyear, "1965"); 
       	?>
          </select>
        </div>
        <div class="input" style="margin-left:30px">
         	        <label>Gender</label>
	    		<label class="radio" style="margin-right:15px;">
	    		<input name="gender" type="radio" value="0" <?= $genderfemale;?> >Female</label>
	    		<label class="radio">
		<input name="gender" type="radio" value="1"  <?= $gendermale;?>>Male</label>
        </div>
        <div style="clear:both;"></div>
        <div class="input" style="margin-right: 10px;">
	        <label>Mother Tongue:</label>
	<label class="radio"><input name="mothertongue" type="radio" value="1" <?= $langeng;?>>English</label>
	<label class="radio"><input name="mothertongue" type="radio" value="2" <?= $langfr;?>>French</label>
	<label class="radio"><input name="mothertongue" type="radio" value="3" <?= $langother;?>>Other</label>
        </div>
        <div class="input">
          <label>Other:</label>
        <input name="langother" type="text"  value="<?= ($_POST['langother']) ? stripslashes($_POST['langother']) : $row['langother'];?>"  class="midinp">
        </div>
        <div style="clear:both;"></div>
        
        <div class="input" style="margin-right: 10px;">
     
       <label>Do you have any physical or mental health conditions you think we should be aware of?</label>
          <label class="radio">
            <input name="health" type="radio" value="1"  <?= $healthyes;?> >
            Yes</label>
          <label class="radio">
            <input name="health" type="radio" value="0"  <?= $healthno;?>>
            No</label>
          <label class="radio">If yes, then please provide details:</label>
        </div>
        <div class="input">
                  <input name="healthinfo" type="text" value="<?= ($_POST['healthinfo']) ? stripslashes($_POST['healthinfo']) : $row['healthinfo'];?>" class="lrginp">
        </div>
        
        <div style="clear:both;"></div>
       
       <div class="input" style="margin-right: 10px;">
          <label>Have you been convicted of a criminal offense for which you have not received a pardon?</label>
          
		<label class="radio">
	<input name="crime" type="radio" value="1" <?= $crimeyes;?> >Yes</label>
	<label class="radio">
	<input name="crime" type="radio" value="0" <?= $crimeno;?> >No</label> 
	<label class="radio">If Yes, Please specify (failing a Breathalyzer is a criminal offense)</label></div>
      <div class="input">
        <input name="crimeinfo" type="text" value="<?= ($_POST['crimeinfo']) ? stripslashes($_POST['crimeinfo']) : $row['crimeinfo'];?>"  class="lrginp">
          
        </div>
        <div style="clear:both;"></div>
        <div class="input" style="margin-right: 10px;">
          <label>Will you submit to a police records check?</label>
          <label class="radio">
            <input name="criminalcheck" type="radio" value="1"  <?= $criminalcheck_yes;?> >
            Yes</label>
          <label class="radio">
            <input name="criminalcheck" type="radio" value="0"  <?= $criminalcheck_no;?>>
            No</label>
        </div>
        <div style="clear:both;"></div>
        <div class="input">
          <label style="display:block;">Criminal record check received.</label>
          <select name="crimmonth" title="month">
		<?
		$mymon = ($_POST['crimmonth']) ? stripslashes($_POST['crimmonth']) : $crimmonth;
		echo buildMonthDropdown($mymon, $_MONTHS_abbr); 
       	?>
        
          </select>
          <select name="crimday" title="date">
       	<?
       	$myday = ($_POST['crimday']) ? stripslashes($_POST['crimday']) : $crimday;
       	echo buildDayDropdown($myday); 
       	?>
         
          </select>
          <select name="crimyear" title="Year">
       	<?
       	$myyear = ($_POST['crimyear']) ? stripslashes($_POST['crimyear']) : $crimyear;
       	echo buildYearDropdown($myyear, "2009"); 
       	?>
          </select>
        </div>
        <div class="input plusleft" >
          <label>Issues:</label>
          <label class="radio">
            <input name="criminalissue" type="radio" value="0"   <?= $criminalissueno;?>>
            Clear</label>
          <label class="radio">
            <input name="criminalissue" type="radio" value="1"  <?= $criminalissueyes;?> >
            Issues</label>
        </div>
        <div class="input plusleft">
          <label>Details:</label>

        <input name="criminalinfo" type="text" value="<?= ($_POST['criminalinfo']) ? stripslashes($_POST['criminalinfo']) : $row['criminalinfo'];?>"    class="smlinp">

        </div>
         
		<div style="clear:both;"></div>
        <div class="input">
          <label>Do you, at the present time, have a drinking or drug problem?</label>
          <label class="radio">
            <input name="drinking" type="radio" value="1" <?= $drinkingyes;?>>
            Yes</label>
          <label class="radio">
            <input name="drinking" type="radio" value="0" <?= $drinkingno;?>>
            No</label>
          <label class="radio">If Yes, Please explain.</label>
        </div>
        <div class="input">
           <input name="drinkinginfo" type="text" value="<?= ($_POST['drinkinginfo']) ? stripslashes($_POST['drinkinginfo']) : $row['drinkinginfo'];?>"    class="lrginp">
        </div>
        <div style="clear:both;"></div>

        <div style="clear:both;"></div>
        <div class="input" style="margin-right: 15px;">
          <label>Is Confirmation signed.</label>
          <label class="radio">
            <input name="confform" type="radio" value="1" <?= $confform_yes;?> >
            Yes</label>
          <label class="radio">
            <input name="confform" type="radio" value="0" <?= $confform_no;?>>
            No</label>
        </div>
        <div class="input">
          <label style="display:block;">Date on form:</label>
          <select name="confmonth" title="month">
       	<?
       	$mymon = ($_POST['confmonth']) ? stripslashes($_POST['confmonth']) : $confmonth;
       	echo buildMonthDropdown($mymon, $_MONTHS_abbr); 
       	?>
          </select>
          <select name="confday" title="date">
  		<?
       	$myday = ($_POST['confday']) ? stripslashes($_POST['confday']) : $confday;
       	echo buildDayDropdown($myday); 
       	?>

          </select>
          <select name="confyear" title="Year">
       	<?
       	$myyear = ($_POST['confyear']) ? stripslashes($_POST['confyear']) : $confyear;
       	echo buildYearDropdown($myyear, "2009"); 
       	?>
          </select>
        </div>
        <div class="input btn btndownload plusleft">
        <?php    	$number = rand(); ?>
        	<a href="forms/volunteer_intake.pdf?=<?php echo $number ?>" target="_blank" class="smalllink"><img src="img/pdficon_large.png" alt="PDF file" width="32" height="32" align="left">Volunteer Intake<br>form Download.</a>
        </div>
        <div style="clear:both;"></div>
        
      <div class="input">
        <label>How did you hear about Laubach Literacy?</label>
        <textarea name="how" cols="" rows="3" class="talrg"><? echo ($_POST['how']) ? stripslashes($_POST['how']) : stripslashes($row['how']); ?></textarea>
      </div>
      <div style="clear:both;"></div>

      <div class="input">
        <label>How much time do you have to dedicate to a volunteer position?</label>
        <input name="howmuchtime" type="text" value="<?= ($_POST['howmuchtime']) ? stripslashes($_POST['howmuchtime']) : $row['howmuchtime'];?>"  class="lrginp"></input>
      </div>
      <div style="clear:both;"></div>
        
         <label>Please indicate which areas you would like to volunteer with the regional board or Laubach Literacy New Brunswick.</label>
            
            <div  class="input moveright" >
		<?
			echo buildAreasOfInterest($AREAS_selected, "v");
		?>
    		</div>
           
      <div style="clear:both;"></div>
          <div class="input" style="margin-top:0;">
        <label>If other, please specify:</label>
           <input name="otherarea" type="text" value="<?= ($_POST['otherarea']) ? stripslashes($_POST['otherarea']) : $otherarea; ?>"    class="lrginp">
      </div>
      <div style="clear:both;"></div>

      <div class="input" >
          <label>Do you possess any special skills or interests that you feel would be an asset with Laubach?</label>
          <label class="radio">
            <input name="specialskills" type="radio" value="1"  <?= $specialskillsyes;?>>
            Yes</label>
          <label class="radio">
            <input name="specialskills" type="radio" value="0"  <?= $specialskillsno;?> >
            No</label>
          <label class="radio">If yes, then please provide details:</label>
        </div>
        <div class="input">
                <input name="specialskillsinfo" type="text" value="<?= ($_POST['specialskillsinfo']) ? stripslashes($_POST['specialskillsinfo']) : stripslashes($row['specialskillsinfo']);?>"  class="lrginp">
        </div>
      <div style="clear:both;"></div>
      <input type="hidden" name="vid" value="<?=$_GET['vid']; ?>">

        

        <p class="clearfix">
        <input type="submit"  class="btn lfr" value="Save &amp; Close"> 
      
     <?
	     if ($_GET['mode'] != "new")
	         	 $cancel= "<a href=\"volunteer_overview.php?vid=".$_GET['vid']."\" class=\"btn lfr\">Cancel</a>";
	     else
	        	 $cancel= "<a href=\"volunteer_list.php\" class=\"btn lfr\">Cancel</a>";
     ?>        
        <?=$cancel;?></p>    
        
        </form>
    </div>
  </div>
  <!-- end of main -->
  <aside> </aside>
  <div style="clear:both;"></div>
  <footer>
    <?php include('footer.php'); ?>
  </footer>
</div>

</body>
</html>