- 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.
This commit is contained in:
dave 2007-03-05 04:27:44 +00:00
parent 5b84c70f69
commit f0bb80a866
8 changed files with 62 additions and 33 deletions

View File

@ -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']}'");
}

View File

@ -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)));

View File

@ -1 +1 @@
43
44

1
db/db.update.44.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE `project_specialawards_link` CHANGE `award_awards_id` `award_awards_id` INT( 10 ) UNSIGNED NULL DEFAULT '0'

View File

@ -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;

View File

@ -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;

View File

@ -272,9 +272,11 @@ echo "<table><tr><td>";
$project=mysql_fetch_object($q);
$nominatedawards=getSpecialAwardsNominatedForProject($project->id);
$num=count($nominatedawards);
$noawards=getNominatedForNoSpecialAwardsForProject($project->id);
echo "<tr><td>";
if($num)
{
echo "<tr><td>";
echo happy(i18n("You are nominated for %1 awards",array($num)),"inline");
echo "</td></tr>";
@ -285,18 +287,16 @@ echo "<table><tr><td>";
echo $c.". ".$na['name']."<br />";
$c++;
}
echo "</td>";
echo "</tr>";
}
else if($noawards == true)
{
echo happy(i18n("You are nominated for 0 awards"),"inline");
}
else
{
echo "<tr><td>";
echo error(i18n("You are nominated for 0 awards"),"inline");
echo "</td></tr>";
}
echo "</td></tr>";
}
else

View File

@ -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 "<form name=\"specialawards\" method=\"post\" action=\"register_participants_spawards.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\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.<hr>")),
$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 <br>";
@ -188,7 +204,7 @@ else if($newstatus=="complete")
echo "</td></tr>";
echo "<tr><td>";
echo $eaward['criteria'];
echo "<br /><br />";
if($eaward['id'] != -1) echo '<br /><br />';
echo "</td></tr>";
}
echo "</table>";