From f0bb80a86672e18139fa73b9572c359ed14fff1a Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 5 Mar 2007 04:27:44 +0000 Subject: [PATCH] - Fix the name of the generate project number function - Hardcode add a special award to the top of the list "I do not wish to nominate for any special awards". Allow the project_specialawards_link.award_awards_id field to become NULL, and set it to NULL if the student selects this award. - Fix the display of the award status based on whether the student has or has not specified that they do not wish to nominate for special awards. --- admin/project_editor.php | 2 +- admin/registration_receivedforms.php | 2 +- db/db.code.version.txt | 2 +- db/db.update.44.sql | 1 + projects.inc.php | 18 +++++++++++ register_participants.inc.php | 10 ++---- register_participants_main.php | 14 ++++----- register_participants_spawards.php | 46 +++++++++++++++++++--------- 8 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 db/db.update.44.sql diff --git a/admin/project_editor.php b/admin/project_editor.php index 67f8eeb..cc076ca 100644 --- a/admin/project_editor.php +++ b/admin/project_editor.php @@ -38,7 +38,7 @@ if($_POST['action']=="genprojnum") { mysql_query("UPDATE projects SET projectnumber=NULL WHERE id='{$_POST['id']}'"); - $pn = generate_project_number($registration_id); + $pn = generateProjectNumber($registration_id); // print("Generated Project Number [$pn]"); mysql_query("UPDATE projects SET projectnumber='$pn' WHERE id='{$_POST['id']}'"); } diff --git a/admin/registration_receivedforms.php b/admin/registration_receivedforms.php index bd2b0ab..4e2ae45 100644 --- a/admin/registration_receivedforms.php +++ b/admin/registration_receivedforms.php @@ -207,7 +207,7 @@ echo mysql_Error(); $r=mysql_fetch_object($q); $reg_id = $r->id; - $projectnumber = generate_project_number($reg_id); + $projectnumber = generateProjectNumber($reg_id); mysql_query("UPDATE projects SET projectnumber='$projectnumber' WHERE registrations_id='$reg_id' AND year='{$config['FAIRYEAR']}'"); echo happy(i18n("Assigned Project Number: %1",array($projectnumber))); diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 920a139..c739b42 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -43 +44 diff --git a/db/db.update.44.sql b/db/db.update.44.sql new file mode 100644 index 0000000..bc11902 --- /dev/null +++ b/db/db.update.44.sql @@ -0,0 +1 @@ +ALTER TABLE `project_specialawards_link` CHANGE `award_awards_id` `award_awards_id` INT( 10 ) UNSIGNED NULL DEFAULT '0' diff --git a/projects.inc.php b/projects.inc.php index b3f4a6b..1b3c019 100644 --- a/projects.inc.php +++ b/projects.inc.php @@ -165,6 +165,24 @@ function getSpecialAwardsNominatedForProject($projectid) return $awards; } +function getNominatedForNoSpecialAwardsForProject($projectid) +{ + global $config; + $awardsq=mysql_query("SELECT + projects.id AS projects_id + FROM + project_specialawards_link, + projects + WHERE + project_specialawards_link.projects_id='$projectid' + AND projects.year='".$config['FAIRYEAR']."' + AND projects.id='$projectid' + AND project_specialawards_link.award_awards_id IS NULL + "); + if(mysql_num_rows($awardsq) == 1) return true; + return false; +} + function getProjectsNominatedForSpecialAward($award_id) { global $config; diff --git a/register_participants.inc.php b/register_participants.inc.php index c62b374..227a104 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -213,21 +213,15 @@ function spawardStatus($reg_id="") $q=mysql_query("SELECT * FROM projects WHERE registrations_id='$rid'"); $project=mysql_fetch_object($q); + /* We want this query to get any awards with a NULL award_awards_id */ $awardsq=mysql_query("SELECT - award_awards.id, - award_awards.name, - award_awards.criteria, projects.id AS projects_id FROM - award_awards, project_specialawards_link, projects WHERE project_specialawards_link.projects_id='".$project->id."' - AND project_specialawards_link.award_awards_id=award_awards.id AND projects.year='".$config['FAIRYEAR']."' - ORDER BY - award_awards.name "); if(mysql_num_rows($awardsq)) @@ -264,7 +258,7 @@ function tourStatus($reg_id="") } -function generate_project_number($registration_id) +function generateProjectNumber($registration_id) { global $config; diff --git a/register_participants_main.php b/register_participants_main.php index 0f62cfe..6c66be1 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -272,9 +272,11 @@ echo ""; @@ -285,18 +287,16 @@ echo "
"; $project=mysql_fetch_object($q); $nominatedawards=getSpecialAwardsNominatedForProject($project->id); $num=count($nominatedawards); + $noawards=getNominatedForNoSpecialAwardsForProject($project->id); + + echo "
"; if($num) { - echo "
"; echo happy(i18n("You are nominated for %1 awards",array($num)),"inline"); echo "
"; - echo ""; } + else if($noawards == true) + { + echo happy(i18n("You are nominated for 0 awards"),"inline"); + } else { - echo ""; - } - echo ""; } else diff --git a/register_participants_spawards.php b/register_participants_spawards.php index f60f19a..2425253 100644 --- a/register_participants_spawards.php +++ b/register_participants_spawards.php @@ -109,7 +109,17 @@ function checkboxclicked(b) //this will return 1 if its between the dates, 0 otherwise. if(!$readonly) { - $num=count($_POST['spaward']); + $splist = array(); + $noawards = false; + if(is_array($_POST['spaward'])) $splist = $_POST['spaward']; + + /* If all they've selected is they don't want to self nominate, then erase all other selections */ + if(in_array(-1, $splist)) { + $splist = array(-1); + $noawards = true; + } + + $num=count($splist); if($num>$config['maxspecialawardsperproject']) { echo error(i18n("You can only apply to %1 special awards. You have selected %2",array($config['maxspecialawardsperproject'],$num))); @@ -118,16 +128,21 @@ function checkboxclicked(b) { mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='$project->id' AND year='".$config['FAIRYEAR']."'"); - foreach($_POST['spaward'] AS $spaward) + foreach($splist AS $spaward) { + $s = ($spaward == -1) ? "NULL" : "'$spaward'"; mysql_query("INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (". - "'$spaward', ". + "$s, ". "'$project->id', ". "'".$config['FAIRYEAR']."')"); echo mysql_error(); } - if($num) - echo happy(i18n("Successfully registered for %1 special awards",array($num))); + if($num) { + if($noawards == true) + echo happy(i18n("Successfully registered for no special awards")); + else + echo happy(i18n("Successfully registered for %1 special awards",array($num))); + } } } else @@ -137,8 +152,6 @@ function checkboxclicked(b) } } - - //output the current status $newstatus=spawardStatus(); if($newstatus!="complete") @@ -148,21 +161,24 @@ if($newstatus!="complete") else if($newstatus=="complete") { echo happy(i18n("Special Awards Self-Nomination Complete")); - } echo "\n"; echo "\n"; echo "
"; echo $c.". ".$na['name']."
"; $c++; } - echo "
"; echo error(i18n("You are nominated for 0 awards"),"inline"); - echo "
\n"; - $q=mysql_query("SELECT * FROM safety WHERE registrations_id='".$_SESSION['registration_id']."'"); - while($r=mysql_fetch_object($q)) - { - $safetyanswers[$r->safetyquestions_id]=$r->answer; - } - $eligibleawards=getSpecialAwardsEligibleForProject($project->id); $nominatedawards=getSpecialAwardsNominatedForProject($project->id); + + $eligibleawards = array_merge(array(array( 'id'=> -1, + 'name' => "I do not wish to self-nominate for any special awards", + 'criteria' => "Select this option if you do not wish to self-nominate you project for any special awards.
")), + $eligibleawards); + /* See if they have the -1 award selected */ + $noawards = getNominatedForNoSpecialAwardsForProject($project->id); + if($noawards == true) { + $nominatedawards = array_merge(array(array('id' => '-1')), $nominatedawards); + } /* echo "eligible awards
"; @@ -188,7 +204,7 @@ else if($newstatus=="complete") echo ""; echo ""; } echo "
"; echo $eaward['criteria']; - echo "

"; + if($eaward['id'] != -1) echo '

'; echo "
";