diff --git a/register_participants.inc.php b/register_participants.inc.php
index 9c93a490..9ce22813 100644
--- a/register_participants.inc.php
+++ b/register_participants.inc.php
@@ -80,4 +80,40 @@ function projectStatus()
}
+function mentorStatus()
+{
+ global $config;
+ $required_fields=array("firstname","lastname","phone","email","organization","description");
+
+
+ //first check the registrations table to see if 'nummentors' is set, or if its null
+ $q=mysql_query("SELECT nummentors FROM registrations WHERE id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+ $r=mysql_fetch_object($q);
+ if($r->nummentors==null)
+ return "incomplete";
+
+ $q=mysql_query("SELECT * FROM mentors WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+
+ //if we dont have the minimum, return incomplete
+ if(mysql_num_rows($q)<$config['minmentorserproject'])
+ 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";
+
+}
+
+
+
?>
diff --git a/register_participants_main.php b/register_participants_main.php
index a58b3fd2..3350df4d 100644
--- a/register_participants_main.php
+++ b/register_participants_main.php
@@ -68,8 +68,19 @@ echo "
";
//check to see if its complete
$status=projectStatus();
echo outputStatus($status);
+echo " | ";
-
+//mentor information
+echo "";
+if($status=="complete")
+ echo "";
+echo i18n("Mentor Information");
+if($status=="complete")
+ echo "";
+echo " | ";
+//check to see if its complete
+$status=mentorStatus();
+echo outputStatus($status);
echo " |
";
//safety information
diff --git a/register_participants_mentor.php b/register_participants_mentor.php
new file mode 100644
index 00000000..a0805e6f
--- /dev/null
+++ b/register_participants_mentor.php
@@ -0,0 +1,206 @@
+
+ require("common.inc.php");
+ include "register_participants.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'] && $_SESSION['registration_id']))
+ {
+ 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 - Mentor Information");
+ echo "<< ".i18n("Back to Participant Registration Summary")."
";
+ echo "
";
+
+
+//now do any data saves
+
+if($_POST['action']=="save")
+{
+ $x=1;
+ while($_POST["num"][$x])
+ {
+ if($_POST['id'][$x]==0)
+ {
+ //only insert if we have a name
+ if($_POST['firstname'][$x] && $_POST['lastname'][$x])
+ {
+ //INSERT new record
+ mysql_query("INSERT INTO mentors (registrations_id,firstname,lastname,email,phone,organization,position,description,year) VALUES (".
+ "'".$_SESSION['registration_id']."', ".
+ "'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['organization'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['position'][$x]))."', ".
+ "'".mysql_escape_string(stripslashes($_POST['description'][$x]))."', ".
+ "'".$config['FAIRYEAR']."')");
+ echo mysql_error();
+
+ echo notice(i18n("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
+ }
+
+ }
+ else
+ {
+ //UPDATE existing record
+ mysql_query("UPDATE mentors SET ".
+ "firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
+ "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
+ "email='".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ".
+ "phone='".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
+ "organization='".mysql_escape_string(stripslashes($_POST['organization'][$x]))."', ".
+ "position='".mysql_escape_string(stripslashes($_POST['position'][$x]))."', ".
+ "description='".mysql_escape_string(stripslashes($_POST['description'][$x]))."' ".
+ "WHERE id='".$_POST['id'][$x]."'");
+ echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
+
+ }
+ $x++;
+ }
+
+}
+
+if($_GET['action']=="removementor")
+{
+ //first make sure this is one belonging to this registration id
+ $q=mysql_query("SELECT id FROM mentors WHERE id='".$_GET['removementor']."' AND registrations_id='".$_SESSION['registration_id']."'");
+ if(mysql_num_rows($q)==1)
+ {
+ mysql_query("DELETE FROM mentors WHERE id='".$_GET['removementor']."' AND registrations_id='".$_SESSION['registration_id']."'");
+ echo notice(i18n("Mentor successfully removed"));
+ }
+ else
+ {
+ echo error(i18n("Invalid mentor to remove"));
+ }
+}
+
+
+
+//now query and display
+
+ $q=mysql_query("SELECT nummentors FROM registrations WHERE id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+ $r=mysql_fetch_object($q);
+ $registrations_nummentors=$r->nummentors;
+
+ $q=mysql_query("SELECT * FROM mentors WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+
+ $numfound=mysql_num_rows($q);
+
+ if(isset($_GET['nummentors']))
+ {
+ mysql_query("UPDATE registrations SET nummentors='".$_GET['nummentors']."' WHERE id='".$_SESSION['registration_id']."'");
+ $registrations_nummentors=$_GET['nummentors'];
+ $numtoshow=$_GET['nummentors'];
+ }
+ else
+ $numtoshow=$numfound;
+
+
+//output the current status
+$newstatus=mentorStatus();
+if($newstatus!="complete")
+{
+ echo error(i18n("Mentor Information Incomplete"));
+}
+else if($newstatus=="complete")
+{
+ echo happy(i18n("Mentor Information Complete"));
+
+}
+
+
+ echo "";
+
+ echo "";
+
+ send_footer();
+?>
diff --git a/sfiab.css b/sfiab.css
index 4dd233f1..5b862ac8 100644
--- a/sfiab.css
+++ b/sfiab.css
@@ -25,7 +25,7 @@ body
position: absolute;
top: 80px;
left: 10px;
- width: 175px;
+ width: 165px;
background: #EEEEFF;
border: 2px solid Silver;
padding: 5px;
@@ -34,7 +34,7 @@ body
#main {
background: #EEEEFF;
- margin-left: 210px;
+ margin-left: 200px;
margin-top: 10px;
margin-right: 10px;
padding: 5px;