checks for dates on special award nominations

checks for maximum number of nominations
allow logins of users when registration is closed
This commit is contained in:
james 2005-05-12 15:47:21 +00:00
parent d9d82ce1f5
commit c3896013c1
3 changed files with 152 additions and 92 deletions

View File

@ -24,6 +24,9 @@
<?
require("common.inc.php");
$q=mysql_query("SELECT (NOW()>'".$config['dates']['regopen']."' AND NOW()<'".$config['dates']['regclose']."') AS datecheck");
$datecheck=mysql_fetch_object($q);
if($_POST['action']=="new")
{
$q=mysql_query("SELECT email,num,id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']);
@ -137,8 +140,18 @@
echo "<br />";
}
}
$showform=true;
if($allownew)
{
if($datecheck->datecheck==0)
{
echo error(i18n("Registration is closed. You can not create a new account"));
$showform=false;
echo "<A href=\"register_participants.php\">Back to Participant Registration Login Page</a>";
}
else
{
$regnum=0;
//now create the new registration record, and assign a random/unique registration number to then.
@ -171,8 +184,11 @@
echo i18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']));
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
}
}
if($showform)
{
echo "<br />";
echo i18n("Registration Number:");
echo "<input type=\"text\" size=\"10\" name=\"regnum\">";
@ -181,15 +197,22 @@
echo "<br />";
echo i18n("If you have lost or forgotten your <b>registration number</b>, please <a href=\"register_participants.php?action=resend\">click here to resend</a> it to your email address");
}
}
else
{
//Lets check the date - if we are AFTER 'regopen' and BEFORE 'regclose' then we can login
//otherwise, registration is closed - no logins!
$q=mysql_query("SELECT (NOW()>'".$config['dates']['regopen']."' AND NOW()<'".$config['dates']['regclose']."') AS datecheck");
$r=mysql_fetch_object($q);
//this will return 1 if its between the dates, 0 otherwise.
if($r->datecheck==1)
if($datecheck->datecheck==0)
{
echo notice(i18n("Registration for the %1 %2 is now closed. Existing registrants can login and view (read only) their information, as well as apply for special awards (if applicable).",array($config['FAIRYEAR'],$config['fairname'])));
echo i18n("Please enter your email address to login");
echo "<br />";
echo "<br />";
$buttontext=i18n("Login");
}
else
{
echo i18n("Please enter your email address to :");
@ -198,22 +221,19 @@
echo "<li>".i18n("Continue a previously started registration")."</li>";
echo "<li>".i18n("Modify an existing registration")."</li>";
echo "</ul>";
echo i18n("Please enter a valid email address. We will be emailing you information which you will need to complete the registration process!");
echo i18n("You must enter a valid email address. We will be emailing you information which you will need to complete the registration process!");
echo "<br />";
echo "<br />";
$buttontext=i18n("Begin");
}
?>
<form method="post" action="register_participants.php">
<input type="hidden" name="action" value="login" />
<?=i18n("Email")?>: <input type="text" name="email" size="30" />
<input type="submit" value="Begin" />
<input type="submit" value="<?=$buttontext?>" />
</form>
<?
}
else
{
echo i18n("Registration for the %1 %2 is now closed",array($config['FAIRYEAR'],$config['fairname']));
}
}
send_footer();
?>

View File

@ -180,9 +180,23 @@ echo "<table><tr><td>";
{
echo "<table class=\"summarytable\">";
echo "<tr><th>".i18n("Special Award Nominations")."</th></tr>";
if(registrationFormsReceived())
{
$q=mysql_query("SELECT (NOW()>'".$config['dates']['specawardregopen']."' AND NOW()<'".$config['dates']['specawardregclose']."') AS datecheck");
$r=mysql_fetch_object($q);
//this will return 1 if its between the dates, 0 otherwise.
if($r->datecheck==1)
{
echo "<tr><td><a href=\"register_participants_spawards.php\">".i18n("Self-nominate for special awards")."</a></td></tr>";
}
else
{
echo "<tr><td>".error(i18n("Special award self-nomination is only available from %1 to %2",array($config['dates']['specawardregopen'],$config['dates']['specawardregclose'])),"inline")."</td></tr>";
}
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."'");
$project=mysql_fetch_object($q);
$nominatedawards=getSpecialAwardsNominatedForProject($project->id);

View File

@ -60,22 +60,58 @@ echo mysql_error();
//send the header
send_header("Participant Registration - Self-Nomination for Special Awards");
?>
<script language="javascript" type="text/javascript">
function checkboxclicked(b)
{
max=<?=$config['maxspecialawardsperproject'];?>;
num=0;
df=document.forms["specialawards"];
for (i=0; i<df.elements.length; i++) {
if (df[i].type=="checkbox" && df[i].name=="spaward[]") {
if (df[i].checked==true) {
num++;
}
}
}
if(num>max)
{
b.checked=false;
alert('<?=i18n("You can only self-nominate for up to %1 special awards",array($config['maxspecialawardsperproject']))?>');
}
}
</script>
<?
echo "<a href=\"register_participants_main.php\">&lt;&lt; ".i18n("Back to Participant Registration Summary")."</a><br />";
echo "<br />";
echo notice(i18n("Special award self-nomination is only available from %1 to %2. Please make sure you complete your nominations between these dates. You may apply to a maximum of %3 special awards.",array($config['dates']['specawardregopen'],$config['dates']['specawardregclose'],$config['maxspecialawardsperproject'])));
$q=mysql_query("SELECT (NOW()>'".$config['dates']['specawardregopen']."' AND NOW()<'".$config['dates']['specawardregclose']."') AS datecheck");
$r=mysql_fetch_object($q);
//this will return 1 if its between the dates, 0 otherwise.
if($r->datecheck==1)
$readonly=false;
else
$readonly=true;
if($_POST['action']=="save")
{
//FIXME: check the date when they have to have this in by and dont let them submit after that date
// if(registrationFormsReceived())
// {
// echo error(i18n("Cannot make changes to forms once they have been received by the fair"));
// }
// else
// {
//first we will delete all their old answer, its easier to delete and re-insert in this case then it would be to find the corresponding answers and update them
//this will return 1 if its between the dates, 0 otherwise.
if(!$readonly)
{
$num=count($_POST['spaward']);
if($num>$config['maxspecialawardsperproject'])
{
echo error(i18n("You can only apply to %1 special awards. You have selected %2",array($config['maxspecialawardsperproject'],$num)));
}
else
{
mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='$project->id' AND year='".$config['FAIRYEAR']."'");
$count=0;
foreach($_POST['spaward'] AS $spaward)
{
mysql_query("INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (".
@ -83,10 +119,16 @@ echo mysql_error();
"'$project->id', ".
"'".$config['FAIRYEAR']."')");
echo mysql_error();
$count++;
}
echo happy(i18n("Successfully registered for %1 special awards",array($count)));
// }
if($num)
echo happy(i18n("Successfully registered for %1 special awards",array($num)));
}
}
else
{
echo error(i18n("Special award self-nomination is only available from %1 to %2",array($config['dates']['specawardregopen'],$config['dates']['specawardregclose'])));
}
}
@ -99,11 +141,11 @@ if($newstatus!="complete")
}
else if($newstatus=="complete")
{
echo happy(i18n("Safety Awards Self-Nomination Complete"));
echo happy(i18n("Special Awards Self-Nomination Complete"));
}
echo "<form method=\"post\" action=\"register_participants_spawards.php\">\n";
echo "<form name=\"specialawards\" method=\"post\" action=\"register_participants_spawards.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\n";
@ -134,7 +176,7 @@ else if($newstatus=="complete")
{
echo "<tr><td rowspan=\"2\">";
if(in_array($eaward['id'],$nominatedawards_list)) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"spaward[]\" value=\"".$eaward['id']."\" />";
echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"spaward[]\" value=\"".$eaward['id']."\" />";
echo "</td><td>";
echo "<b>".$eaward['name']."</b>";
echo "</td></tr>";
@ -144,24 +186,8 @@ else if($newstatus=="complete")
echo "</td></tr>";
}
echo "</table>";
/*
$num=1;
while($r=mysql_fetch_object($q))
{
echo "<tr><td><b>$num</b>. </td><td>".i18n($r->question)."</td>";
echo "<td>";
if($r->type=="check")
{
if($safetyanswers[$r->id]=="checked") $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"safety[$r->id]\" value=\"checked\" />";
}
echo "</td>";
echo "</tr>";
$num++;
}
echo "</table>";
*/
echo "<input type=\"submit\" value=\"".i18n("Save Safety Information")."\" />\n";
if(!$readonly)
echo "<input type=\"submit\" value=\"".i18n("Save Special Award Nominations")."\" />\n";
echo "</form>";