- refactor duplicate code in main, create an ouputStatus function to do the work

- add participants project file
- add checks for project completeness
- add new status 'empty' for if the section has not been started yet
This commit is contained in:
james 2004-12-07 14:20:42 +00:00
parent 4e4df1e48d
commit 3a212ae5d5
4 changed files with 109 additions and 17 deletions

View File

@ -168,6 +168,7 @@ echo "<h1>".i18n($config['fairname'])."</h1>";
<div id="left">
<ul class="mainnav">
<li><a href="<?=$config['SFIABDIRECTORY']?>/index.php"><?=i18n("Home Page")?></a></li>
<li><a href="<?=$config['SFIABDIRECTORY']?>/register_participants.php"><?=i18n("Participant Registration")?></a></li>
<li><a href="<?=$config['SFIABDIRECTORY']?>/register_judges.php"><?=i18n("Judges Registration")?></a></li>
</ul>

View File

@ -1,4 +1,32 @@
<?
function outputStatus($status)
{
$ret="";
switch($status)
{
case 'incomplete':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Incomplete");
$ret.= "</div>";
break;
case 'complete':
$ret.= "<div class=\"complete\">";
$ret.= i18n("Complete");
$ret.= "</div>";
break;
case 'empty':
$ret.="<div class=\"incomplete\">";
$ret.= i18n("Empty");
$ret.= "</div>";
break;
default:
$ret.=i18n("Unknown");
break;
}
return $ret;
}
function studentStatus()
{
global $config;
@ -6,6 +34,36 @@ function studentStatus()
$q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
//if we dont have the minimum, return incomplete
if(mysql_num_rows($q)<$config['minstudentsperproject'])
return "incomplete";
while($r=mysql_fetch_object($q))
{
foreach ($required_fields AS $req)
{
if(!$r->$req)
{
return "incomplete";
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
}
function projectStatus()
{
global $config;
$required_fields=array("title","projectcategories_id","projectdivisions_id","summary","language");
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
//if we dont have a project entry yet, return empty
if(!mysql_num_rows($q))
return "empty";
while($r=mysql_fetch_object($q))
{
foreach ($required_fields AS $req)

View File

@ -48,28 +48,22 @@ echo "<a href=\"register_participants_students.php\">";
echo i18n("Student Information");
echo "</a>";
echo "</td><td>";
$status=studentStatus();
switch($status)
{
case 'incomplete':
echo "<div class=\"incomplete\">";
echo i18n("Incomplete");
echo "</div>";
break;
case 'complete':
echo "<div class=\"complete\">";
echo i18n("Complete");
echo "</div>";
break;
default:
break;
}
//check to see if its complete
$status=studentStatus();
echo outputStatus($status);
echo "</td></tr>";
//project information
echo "<tr><td>".i18n("Project Information")."</td><td>";
echo "<tr><td>";
echo "<a href=\"register_participants_project.php\">";
echo "".i18n("Project Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$status=projectStatus();
echo outputStatus($status);
echo "</td></tr>";
//safety information

View File

@ -0,0 +1,39 @@
<?
require("common.inc.php");
//authenticate based on email address and registration number from the SESSION
if(!$_SESSION['email'])
{
header("Location: register_participants.php");
exit;
}
if(!$_SESSION['registration_number'])
{
header("Location: register_participants.php");
exit;
}
$q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
"WHERE students.email='".$_SESSION['email']."' ".
"AND registrations.num='".$_SESSION['registration_number']."' ".
"AND registrations.id='".$_SESSION['registration_id']."' ".
"AND students.registrations_id=registrations.id ".
"AND registrations.year=".$config['FAIRYEAR']." ".
"AND students.year=".$config['FAIRYEAR']);
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_participants.php");
exit;
}
$r=mysql_fetch_object($q);
send_header("Participant Registration - Project Information");
echo "<a href=\"register_participants_main.php\">&lt;&lt; ".i18n("Back to Participant Registration Summary")."</a><br />";
echo "<br /><br />";
send_footer();
?>