forked from science-ation/science-ation
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:
parent
d9d82ce1f5
commit
c3896013c1
@ -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,59 +140,79 @@
|
||||
echo "<br />";
|
||||
}
|
||||
}
|
||||
$showform=true;
|
||||
|
||||
if($allownew)
|
||||
{
|
||||
$regnum=0;
|
||||
//now create the new registration record, and assign a random/unique registration number to then.
|
||||
do
|
||||
if($datecheck->datecheck==0)
|
||||
{
|
||||
//random number between
|
||||
//100000 and 999999 (six digit integer)
|
||||
$regnum=rand(100000,999999);
|
||||
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
|
||||
}while(mysql_num_rows($q)>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>";
|
||||
|
||||
//actually insert it
|
||||
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
|
||||
"'$regnum',".
|
||||
"'".$_SESSION['email']."',".
|
||||
"NOW(),".
|
||||
"'new',".
|
||||
$config['FAIRYEAR'].
|
||||
")");
|
||||
}
|
||||
else
|
||||
{
|
||||
$regnum=0;
|
||||
//now create the new registration record, and assign a random/unique registration number to then.
|
||||
do
|
||||
{
|
||||
//random number between
|
||||
//100000 and 999999 (six digit integer)
|
||||
$regnum=rand(100000,999999);
|
||||
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
|
||||
}while(mysql_num_rows($q)>0);
|
||||
|
||||
//actually insert it
|
||||
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
|
||||
"'$regnum',".
|
||||
"'".$_SESSION['email']."',".
|
||||
"NOW(),".
|
||||
"'new',".
|
||||
$config['FAIRYEAR'].
|
||||
")");
|
||||
|
||||
|
||||
$mailbody= "A new registration account has been created for you.\n".
|
||||
"To access your registration account, please enter\n".
|
||||
"enter the following registration number into the\n".
|
||||
"registration website:\n".
|
||||
"\n".
|
||||
"Registration Number: $regnum\n".
|
||||
"\n";
|
||||
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
|
||||
$mailbody= "A new registration account has been created for you.\n".
|
||||
"To access your registration account, please enter\n".
|
||||
"enter the following registration number into the\n".
|
||||
"registration website:\n".
|
||||
"\n".
|
||||
"Registration Number: $regnum\n".
|
||||
"\n";
|
||||
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
|
||||
|
||||
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\">";
|
||||
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\">";
|
||||
}
|
||||
|
||||
}
|
||||
echo "<br />";
|
||||
echo i18n("Registration Number:");
|
||||
echo "<input type=\"text\" size=\"10\" name=\"regnum\">";
|
||||
echo "<input type=\"submit\" value=\"Submit\">";
|
||||
echo "</form>";
|
||||
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");
|
||||
if($showform)
|
||||
{
|
||||
echo "<br />";
|
||||
echo i18n("Registration Number:");
|
||||
echo "<input type=\"text\" size=\"10\" name=\"regnum\">";
|
||||
echo "<input type=\"submit\" value=\"Submit\">";
|
||||
echo "</form>";
|
||||
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" />
|
||||
</form>
|
||||
<?
|
||||
}
|
||||
else
|
||||
{
|
||||
echo i18n("Registration for the %1 %2 is now closed",array($config['FAIRYEAR'],$config['fairname']));
|
||||
}
|
||||
?>
|
||||
<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="<?=$buttontext?>" />
|
||||
</form>
|
||||
<?
|
||||
}
|
||||
send_footer();
|
||||
?>
|
||||
|
@ -180,12 +180,26 @@ echo "<table><tr><td>";
|
||||
{
|
||||
echo "<table class=\"summarytable\">";
|
||||
echo "<tr><th>".i18n("Special Award Nominations")."</th></tr>";
|
||||
|
||||
if(registrationFormsReceived())
|
||||
{
|
||||
echo "<tr><td><a href=\"register_participants_spawards.php\">".i18n("Self-nominate for special awards")."</a></td></tr>";
|
||||
$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);
|
||||
$nominatedawards=getSpecialAwardsNominatedForProject($project->id);
|
||||
$num=count($nominatedawards);
|
||||
if($num)
|
||||
{
|
||||
@ -218,7 +232,7 @@ echo "<table><tr><td>";
|
||||
{
|
||||
echo "<tr><td>".error(i18n("We must receive your signature form before you can nominate yourself for special awards"),"inline")."</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
|
@ -60,33 +60,75 @@ 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\"><< ".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
|
||||
mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='$project->id' AND year='".$config['FAIRYEAR']."'");
|
||||
$count=0;
|
||||
foreach($_POST['spaward'] AS $spaward)
|
||||
//this will return 1 if its between the dates, 0 otherwise.
|
||||
if(!$readonly)
|
||||
{
|
||||
$num=count($_POST['spaward']);
|
||||
if($num>$config['maxspecialawardsperproject'])
|
||||
{
|
||||
mysql_query("INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (".
|
||||
"'$spaward', ".
|
||||
"'$project->id', ".
|
||||
"'".$config['FAIRYEAR']."')");
|
||||
echo mysql_error();
|
||||
$count++;
|
||||
echo error(i18n("You can only apply to %1 special awards. You have selected %2",array($config['maxspecialawardsperproject'],$num)));
|
||||
}
|
||||
echo happy(i18n("Successfully registered for %1 special awards",array($count)));
|
||||
// }
|
||||
else
|
||||
{
|
||||
mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='$project->id' AND year='".$config['FAIRYEAR']."'");
|
||||
|
||||
foreach($_POST['spaward'] AS $spaward)
|
||||
{
|
||||
mysql_query("INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (".
|
||||
"'$spaward', ".
|
||||
"'$project->id', ".
|
||||
"'".$config['FAIRYEAR']."')");
|
||||
echo mysql_error();
|
||||
}
|
||||
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>";
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user