<?include_once("../../settings.php");?>
<form method='post' name='resend_confirmation_email'>
<?
	if (isset($_REQUEST['action']) && $_REQUEST['action']!=""){
		// Email sending
		$SQL = "SELECT * FROM tbl_registrant WHERE registrant_id='".$_REQUEST['registrant_id']."';";
			$result = $qry->querySelectSingle($SQL);
			$SQL = "SELECT * FROM tbl_email WHERE email_key='confirmation';";
			$emailresult=$qry->querySelectSingle($SQL);
			$subject = $emailresult['email_subject'];
			$message = $emailresult['email_content'];
			
			$datetime = date("F j, Y");	
			$registrant_salutation = $result['registrant_salutation'];
			$registrant_last_name = $result['registrant_family_name'];
			$registrant_sn = $result['registrant_sn'];
			$email = $result['registrant_email'];

			$message = str_replace("@registrant_salutation@",$registrant_salutation,$message);
			$message = str_replace("@registrant_last_name@",$registrant_last_name,$message);
			$message = str_replace("@registrant_sn@",$registrant_sn,$message);
			$message = str_replace("@datetime@",$datetime,$message);
								
			$mail->IsHTML(true);
			$mail->SetFrom("secretariat@get-up.com.sg ","A*STAR GET-Up 2013 Secretariat");
			$mail->AddAddress($email);
			$mail->Subject = $subject;
			$mail->Body = $message;
			$mail->Send(); // send message
			
			$SQL = "UPDATE tbl_registrant SET registrant_email_sent='1' WHERE registrant_id='".$_REQUEST['registrant_id']."';";
			$qry->queryExecute($SQL);
			echo "<script>alert('Email Sent');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:300px;background:#CCCCFF;border:1px solid #000099;padding:3px;'>";
	echo "<tr><td width='30%'><b>Delegate No.: </b></td><td>".$result['registrant_sn']."</td></tr>";
	echo "<tr><td width='30%'><b>Salutation: </b></td><td>".$result['registrant_salutation']."</td></tr>";
	echo "<tr><td width='30%'><b>Family Name: </b></td><td>".$result['registrant_family_name']."</td></tr>";
	echo "<tr><td width='30%'><b>First Name: </b></td><td>".$result['registrant_first_name']."</td></tr>";
	
	echo "</table><br><br>";
	echo "<input type='hidden' name='registrant_id' value='".$_REQUEST['registrant_id']."'>";
	echo "</font>";
	echo "<input type='submit' name='action' value='Resend Email' onclick=\"return confirm('Do you really want to resend');\">";
	echo "</center>";

?>
</form>