<?include_once("../../settings.php");?>
<script type="text/javascript" src="../js/livevalidation_standalone.compressed.js"></script>
<script>
</script>
<form method='post' name='replace'>
<?
	if (isset($_REQUEST['confirm'])){
		// Replace the selected person
		$SQL = "UPDATE tbl_registrant SET registrant_replaced='1' WHERE registrant_id='".$_REQUEST['registrant_id']."';";
		$qry->queryExecute($SQL);
		$SQL = "SELECT * FROM tbl_registrant WHERE registrant_id='".$_REQUEST['registrant_id']."';";
		$oldresults = $qry->querySelectSingle($SQL);

		$SQL = "INSERT INTO tbl_registrant(
		registrant_salutation,
		registrant_surname,
		registrant_givenname,
		registrant_designation,
		registrant_organisation,
		registrant_add1,
		registrant_add2,
		registrant_postal,
		registrant_tel,
		registrant_email,
		registrant_mobile,
		registrant_paname,
		registrant_pamail,
		registrant_attending,
		registrant_diet,
		registrant_dietremarks,
		registrant_confirmation,
		registrant_imported,
		registrant_lock,
		registrant_responsedatetime,
		registrant_replacing
		) VALUES (
		'".$_REQUEST['salutation']."',
		'".$_REQUEST['surname']."',
		'".$_REQUEST['givenname']."',
		'".$_REQUEST['designation']."',
		'".$_REQUEST['comname']."',
		'".$_REQUEST['address1']."',
		'".$_REQUEST['address2']."',
		'".$_REQUEST['postal']."',
		'".$_REQUEST['comtel']."',
		'".$_REQUEST['email']."',
		'".$_REQUEST['mobile']."',
		'".$_REQUEST['paname']."',
		'".$_REQUEST['paemail']."',
		'".$_REQUEST['attend']."',
		'".$_REQUEST['diet']."',
		'".$_REQUEST['dietremarks']."',
		'".$_REQUEST['confirmation']."','0','1',NOW(),
		'".$oldresults['registrant_id']."');";		
		
		$qry->queryExecute($SQL);
		// Insert new record of replacement
		$id = mysql_insert_id();
		echo "<script>alert('Delegate replaced.');parent.thickBoxDone();</script>";
	}
	$SQL = "SELECT * FROM tbl_registrant WHERE registrant_id='".$_REQUEST['registrant_id']."';";
	$result = $qry->querySelectSingle($SQL);
	echo "<center><font face='Arial' size='-1'>";
	echo "<table style='font-family:verdana;font-size:12px;width:550px;background:#CCCCFF;border:1px solid #000099;padding:3px;'>";
	echo "<tr><td colspan='2' bgcolor='white' align='center'><b>Delegate to be Replaced</b></td></tr>";
	echo "<tr><td width='30%'><b>Full Name: </b></td><td>".$result['registrant_surname']." ".$result['registrant_givenname']."</td></tr>";
	echo "<tr><td><b>Organisation: </b></td><td>".$result['registrant_organisation']."</td></tr>";
	echo "<tr><td><b>Email: </b></td><td>".$result['registrant_email']."</td></tr>";
	echo "<tr><td><b>Compynay Telephone: </b></td><td>".$result['registrant_tel']."</td></tr>";
	echo "</table>";
?>
			<table style='font-family:verdana;font-size:12px;width:550px;background:#CCCCFF;border:1px solid #000099;padding:3px;'>
			<tr>
				<td width='40%' align='left'><b>*Salutation: </b></td>
				<td width='60%' align='left'><select name='salutation' id='salutation'><option value='select'>Please Select</option><option value='Prof'>Prof</option><option value='A/Prof'>A/Prof</option><option value='Dr'>Dr</option><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Mrs'>Mrs</option></select></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Surname: </b></td>
				<td width='60%' align='left'><input type='text' name='surname' id='surname' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Given Name: </b></td>
				<td width='60%' align='left'><input type='text' name='givenname' id='givenname' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Designation: </b></td>
				<td width='60%' align='left'><input type='text' name='designation' id='designation' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Company Name: </b></td>
				<td width='60%' align='left'><input type='text' name='comname' id='comname' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Email: </b></td>
				<td width='60%' align='left'><input type='text' name='email' id='email' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Company Telephone: </b></td>
				<td width='60%' align='left'><input type='text' name='comtel' id='comtel' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Mobile: </b></td>
				<td width='60%' align='left'><input type='text' name='mobile' id='mobile' size='50'></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Address 1: </b></td>
				<td width='60%' align='left'><input type='text' name='address1' id='address1' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Address 2: </b></td>
				<td width='60%' align='left'><input type='text' name='address2' id='address2' size='50'></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Postal Code: </b></td>
				<td width='60%' align='left'><input type='text' name='postal' id='postal' size='50' required></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*PA Name: </b></td>
				<td width='60%' align='left'><input type='text' name='paname' id='paname' size='50'></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*PA Email: </b></td>
				<td width='60%' align='left'><input type='text' name='paemail' id='paemail' size='50'></td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Please let us know if you are: </b></td>
				<td width='60%' align='left'><select name="attend" id="attend"><option value="NOT ATTENDING">Not Attending</option><option value="ATTENDING">Attending</option></select></td>
			</tr>
			<tr>
				<td width='40%' align='left'><b>*Will you like to receive a confirmation and reminder through: </b></td>
				<td width='60%' align='left'><select name="confirmation" id="confirmation"><option value="0">Please select</option><option value="SMS">SMS</option><option value="Email">Email</option><option value="Both">Both</option></select></td>
			</tr>
			<tr>
				<td width='40%' align='left' valign="top"><b>*Kindly let us know your menu choice: </b></td>
				<td width='60%' align='left'><select name="diet" id="diet"><option value="0">Please Select</option><option value="Vegetarian">Vegetarian</option><option value="Fish">Fish</option></select></br>Other dietary restriction: <input type="text" name="dietremarks" size="20"></td>
			</tr>
			</table>
<?
	echo "<input type='hidden' name='registrant_id' value='".$_REQUEST['registrant_id']."'>";
	if ($result['registrant_replaced'] == 1){
		echo "Registrant has already been replaced";	
	}
	else {
		echo "<br><input type='submit' name='confirm' value='Confirm Replacment'>";
	}
	echo "</font>";
	echo "</center>";
?>
</form>