<?php
include "header.php";

$act = $_POST["act"];
if ($act == "del")
{
	$eventid = $_POST["id"];
	$regid = $_POST["regid"];
	
	mysql_query("delete from reg where regid='$regid'") or die (mysql_error());
	
	redirect ("reg.php?id=$eventid");
}

$eventid = $_GET["id"];
$query = "select regid, memid, title, name, designation, organisation, address, postcode, country, officephone, homephone, mobilephone, fax, email, wish, pmid, entry from reg where eventid='$eventid'";
$res = mysql_query($query) or die (mysql_error());
echo "<table border=\"1\" width=\"80%\" align=\"center\">";
if (mysql_num_rows($res) > 0)
{
	echo "<tr><th>Entry</th><th>Name</th><th>Member</th><th>Designation</th><th>Organisation</th><th>Address</th><th>Phone</th><th>Fax</th><th>Email</th><th>Pay</th><th>Option</th></tr>";
}
while ($row = mysql_fetch_array($res))
{
	$member = "N";
	if ($row[1] > 0)
	{
		$member = "Y";
	}
	$pm = getpmname($row[15]);
	
	echo "<tr><td valign=top>$row[16]</td><td valign=top>$row[2], $row[3]</td><td valign=top>$member</td><td valign=top>$row[4]</td><td valign=top>$row[5]</td><td valign=top>$row[6]<br>$row[8]<br>$row[7]</td><td valign=top>$row[9]<br>$row[10]<br>$row[11]</td><td valign=top>$row[12]</td><td valign=top>$row[13]</td><td valign=top>$pm</td>";
	echo "<td valign=top><form onSubmit=\"return confirmSubmit()\" action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"post\"><input type=hidden name=id value=$eventid><input type=hidden name=act value=del><input type=hidden name=regid value=$row[0]><input type=submit value=Delete></td></form></tr>";
}

echo "</table>";
?>


<?php
include "footer.php";

function getpmname($pmid)
{
	$q = "select pmname from paymode where pmid='$pmid'";
	$res = mysql_query($q) or die (mysql_error());
	while ($r = mysql_fetch_array($res))
	{
		return $r[0];
	}
	return '';
}
?>

<script language="javascript">
function confirmSubmit()
{
	var agree=confirm("Are you sure you want to delete this registration?");
	if (agree)
	{
		return true ;
	}
	else
	{
		return false ;
	}
}
</script>