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 @@ +<< ".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 i18n("Number of mentors that helped with the project: "); + echo ""; + echo "
"; + + echo "
"; + echo ""; + for($x=1;$x<=$numtoshow;$x++) + { + $mentorinfo=mysql_fetch_object($q); + echo "

".i18n("Mentor %1 Details",array($x))."

"; + //if we have a valid mentor, set their ID, so we can UPDATE when we submit + //if there is no record for this mentor, then set the ID to 0, so we will INSERT when we submit + if($mentorinfo->id) $id=$mentorinfo->id; else $id=0; + + //true should work here, it just has to be set to _something_ for it to work. + echo ""; + + //save the ID, or 0 if it doesnt exist + echo ""; + echo ""; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " "; + echo "\n"; + echo "\n"; + + echo "
".i18n("First Name")."firstname\" />".i18n("Last Name")."lastname\" />
".i18n("Email Address")."email\" />".i18n("Phone")."phone\" />
".i18n("Organization")."organization\" />".i18n("Position")."position\" />
".i18n("Description of help")."
"; + + if($mentorinfo->id) + { + echo "
id\">".i18n("Remove this Mentor from project")."
"; + } + + echo "
"; + echo "
"; + } + if($numtoshow) + { + echo "\n"; + } + 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;