Add a project editor and a student editor, accessible by

clicking on the project or student links from the 
  "Registration List and Statistics" page

Add the project number to the registration list
This commit is contained in:
james 2006-12-15 18:45:06 +00:00
parent 1e7d9fcad9
commit f36212f868
3 changed files with 657 additions and 2 deletions

280
admin/project_editor.php Normal file
View File

@ -0,0 +1,280 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
// include "register_participants.inc.php";
auth_required('admin');
//send the header
send_header("Project Editor");
echo "<a href=\"registration_list.php\">&lt;&lt; ".i18n("Back to Registration List")."</a><br />";
echo "<br />";
if($_POST['registration_id']) $registration_id=$_POST['registration_id'];
else if($_GET['registration_id']) $registration_id=$_GET['registration_id'];
if($_POST['action']=="save")
{
// {
//first, lets make sure this project really does belong to them
$q=mysql_query("SELECT * FROM projects WHERE id='".$_POST['id']."' AND registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
if($projectinfo=mysql_fetch_object($q))
{
$summarywords=preg_split("/[\s,]+/",$_POST['summary']);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
$summarycountok=0;
else
$summarycountok=1;
if($config['participant_project_title_charmax'] && strlen(stripslashes($_POST['title']))>$config['participant_project_title_charmax']) //0 for no limit, eg 255 database field limit
{
$title=substr(stripslashes($_POST['title']),0,$config['participant_project_title_charmax']);
echo error(i18n("Project title truncated to %1 characters",array($config['participant_project_title_charmax'])));
}
else
$title=stripslashes($_POST['title']);
mysql_query("UPDATE projects SET ".
"title='".mysql_escape_string($title)."', ".
"projectdivisions_id='".$_POST['projectdivisions_id']."', ".
"language='".mysql_escape_string(stripslashes($_POST['language']))."', ".
"req_table='".mysql_escape_string(stripslashes($_POST['req_table']))."', ".
"req_electricity='".mysql_escape_string(stripslashes($_POST['req_electricity']))."', ".
"req_special='".mysql_escape_string(stripslashes($_POST['req_special']))."', ".
"summary='".mysql_escape_string(stripslashes($_POST['summary']))."', ".
"summarycountok='$summarycountok'".
"WHERE id='".$_POST['id']."'");
echo mysql_error();
echo notice(i18n("Project information successfully updated"));
//check if they changed the project number
if($_POST['projectnumber']!=$projectinfo->projectnumber)
{
//check if hte new one is available
$q=mysql_query("SELECT * FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber='".$_POST['projectnumber']."'");
if(mysql_num_rows($q))
{
echo error(i18n("Could not change project number. %1 is already in use",array($_POST['projectnumber'])));
}
else
{
mysql_query("UPDATE projects SET
projectnumber='".$_POST['projectnumber']."'
WHERE id='".$_POST['id']."'");
echo happy(i18n("Project number successfully changed to %1",array($_POST['projectnumber'])));
}
}
}
else
{
echo error(i18n("Invalid project to update"));
}
//}
}
//now lets find out their MAX grade, so we can pre-set the Age Category
$q=mysql_query("SELECT MAX(grade) AS maxgrade FROM students WHERE registrations_id='".$registration_id."'");
$gradeinfo=mysql_fetch_object($q);
//now lets grab all the age categories, so we can choose one based on the max grade
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
{
//save these in an array, just incase we need them later (FIXME: remove this array if we dont need it)
$agecategories[$r->id]['category']=$r->category;
$agecategories[$r->id]['mingrade']=$r->mingrade;
$agecategories[$r->id]['maxgrade']=$r->maxgrade;
if($gradeinfo->maxgrade >= $r->mingrade && $gradeinfo->maxgrade <= $r->maxgrade)
{
$projectcategories_id=$r->id;
}
}
//now select their project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
//check if it exists, if we didnt find any record, lets insert one
$projectinfo=mysql_fetch_object($q);
//make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly
if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id)
{
echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category'])));
mysql_query("UPDATE projects SET projectcategories_id='$projectcategories_id' WHERE id='$projectinfo->id'");
}
//output the current status
?>
<script language="javascript" type="text/javascript">
function countwords()
{
var wordmax=<?=$config['participant_project_summary_wordmax'];?>;
var summaryobj=document.getElementById('summary');
var wordcountobj=document.getElementById('wordcount');
var wordcountmessageobj=document.getElementById('wordcountmessage');
var wordarray=summaryobj.value.replace(/\s+/g," ").split(" ");
var wordcount=wordarray.length;
if(wordcount>wordmax)
wordcountmessageobj.className="incomplete";
else
wordcountmessageobj.className="complete";
wordcountobj.innerHTML=wordcount;
}
</script>
<?
if($projectinfo)
{
echo "<form name=\"projectform\" method=\"post\" action=\"project_editor.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<input type=\"hidden\" name=\"id\" value=\"$projectinfo->id\">\n";
echo "<input type=\"hidden\" name=\"registration_id\" value=\"$registration_id\">\n";
echo "<table>\n";
echo "<tr><td>".i18n("Project Title").": </td><td><input type=\"text\" name=\"title\" size=\"50\" value=\"$projectinfo->title\" />".REQUIREDFIELD;
if($config['participant_project_title_charmax'])
echo i18n("(Max %1 characters)",array($config['participant_project_title_charmax']));
echo "</td></tr>\n";
echo "<tr><td>".i18n("Project Number").": </td><td><input type=\"text\" name=\"projectnumber\" size=\"10\" value=\"$projectinfo->projectnumber\" />";
echo "<tr><td>".i18n("Age Category").": </td><td>";
echo i18n($agecategories[$projectcategories_id]['category']);
echo " (".i18n("Grades %1-%2",array($agecategories[$projectcategories_id]['mingrade'],$agecategories[$projectcategories_id]['maxgrade'])).")";
echo "</td></tr>";
echo "<tr><td>".i18n("Division").": </td><td>";
//###### Feature Specific - filtering divisions by category
if($config['filterdivisionbycategory']=="yes"){
$q=mysql_query("SELECT projectdivisions.* FROM projectdivisions,projectcategoriesdivisions_link WHERE projectdivisions.id=projectdivisions_id AND projectcategories_id=".$projectcategories_id." AND projectdivisions.year='".$config['FAIRYEAR']."' AND projectcategoriesdivisions_link.year='".$config['FAIRYEAR']."' ORDER BY division");
echo mysql_error();
//###
}else
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
echo "<select name=\"projectdivisions_id\">";
echo "<option value=\"\">".i18n("Select a division")."</option>\n";
while($r=mysql_fetch_object($q))
{
if($r->id == $projectinfo->projectdivisions_id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars(i18n($r->division))."</option>\n";
}
echo "</select>".REQUIREDFIELD;
if($config['usedivisionselector']=="yes")
{
?>
<script language="javascript" type="text/javascript">
function openDivSelWindow()
{
divselwin=window.open('register_participants_project_divisionselector.php','divsel','width=500,height=220,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no')
if(divselwin.opener==null) divselwin.opener=self;
return false;
}
</script>
<?
}
echo "<br />";
echo i18n("WARNING! If you change the division you must manually change the project number too! It will NOT be assigned a new number automatically");
echo "</td></tr>";
echo "<tr><td>".i18n("Language").": </td><td>";
echo "<select name=\"language\">\n";
if($projectinfo->language)
$currentlang=$projectinfo->language;
else
$currentlang=$_SESSION['lang'];
foreach($config['languages'] AS $key=>$val)
{
if($currentlang==$key) $selected="selected=\"selected\""; else $selected="";
echo "<option $selected value=\"$key\">$val</option>";
}
echo "</select>".REQUIREDFIELD;
echo "</td></tr>";
echo "<tr><td>".i18n("Requirements").": </td><td>";
echo "<table>";
echo "<tr>";
echo " <td>".i18n("Table").REQUIREDFIELD."</td>";
if($projectinfo->req_table=="yes") $check="checked=\"checked\""; else $check="";
echo " <td><input $check type=\"radio\" name=\"req_table\" value=\"yes\" />Yes</td>";
echo " <td width=\"20\">&nbsp;</td>";
if($projectinfo->req_table=="no") $check="checked=\"checked\""; else $check="";
echo " <td><input $check type=\"radio\" name=\"req_table\" value=\"no\" />No</td>";
echo "</tr>";
echo "<tr>";
echo " <td>".i18n("Electricity").REQUIREDFIELD."</td>";
if($projectinfo->req_electricity=="yes") $check="checked=\"checked\""; else $check="";
echo " <td><input $check type=\"radio\" name=\"req_electricity\" value=\"yes\" />Yes</td>";
echo " <td width=\"20\">&nbsp;</td>";
if($projectinfo->req_electricity=="no") $check="checked=\"checked\""; else $check="";
echo " <td><input $check type=\"radio\" name=\"req_electricity\" value=\"no\" />No</td>";
echo "</tr>";
echo "<tr>";
echo " <td>".i18n("Special")."</td>";
echo " <td colspan=\"3\"><input type=\"text\" name=\"req_special\" value=\"$projectinfo->req_special\" /></td>";
echo "</tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td>".i18n("Summary").": </td><td><textarea onchange='countwords()' onkeypress='countwords()' cols=\"60\" rows=\"12\" id=\"summary\" name=\"summary\">".htmlspecialchars($projectinfo->summary)."</textarea>".REQUIREDFIELD."<br />";
$summarywords=preg_split("/[\s,]+/",$projectinfo->summary);
$summarywordcount=count($summarywords);
if($summarywordcount>$config['participant_project_summary_wordmax'])
echo "<div id=\"wordcountmessage\" class=\"incomplete\">";
else
echo "<div id=\"wordcountmessage\" class=\"complete\">";
echo "<span id=\"wordcount\">$summarywordcount</span>/";
echo i18n("%1 words maximum",array($config['participant_project_summary_wordmax']));
echo "</div>";
echo "</td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"".i18n("Save Project Information")."\" />\n";
echo "</form>";
}
else
{
echo error(i18n("Invalid project to edit"));
}
send_footer();
?>

View File

@ -30,6 +30,7 @@
?>
<script language="javascript" type="text/javascript">
function openstudentinfo(id)
{
window.open("students_info.php?id="+id,"StudentInfo","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
@ -85,6 +86,7 @@ else $wherestatus="";
{
case 'status': $ORDERBY="registrations.status DESC, projects.title"; break;
case 'num': $ORDERBY="registrations.num"; break;
case 'projnum': $ORDERBY="projects.projectnumber"; break;
case 'title': $ORDERBY="projects.title, registrations.status DESC"; break;
case 'cat': $ORDERBY="projects.projectcategories_id, projects.title"; break;
case 'div': $ORDERBY="projects.projectdivisions_id, projects.title"; break;
@ -96,6 +98,7 @@ else $wherestatus="";
registrations.num AS reg_num,
registrations.status,
projects.title,
projects.projectnumber,
projects.projectcategories_id,
projects.projectdivisions_id
FROM
@ -115,6 +118,7 @@ else $wherestatus="";
if($_GET['showstatus']) $stat="&showstatus=".$_GET['showstatus'];
echo "<th><a href=\"registration_list.php?sort=status$stat\">".i18n("Status")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=num$stat\">".i18n("Reg Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=projnum$stat\">".i18n("Proj Num")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=title$stat\">".i18n("Project Title")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=cat$stat\">".i18n("Age Category")."</a></th>";
echo "<th><a href=\"registration_list.php?sort=div$stat\">".i18n("Division")."</a></th>";
@ -145,7 +149,8 @@ else $wherestatus="";
echo "<tr>";
echo "<td>$status_text</td>";
echo "<td>$r->reg_num</td>";
echo "<td>$r->title</td>";
echo "<td>$r->projectnumber</td>";
echo "<td><a title=\"".i18n("Click to edit")."\" href=\"project_editor.php?registration_id=$r->reg_id\">$r->title</a></td>";
//now get thh category and division
@ -177,7 +182,8 @@ else $wherestatus="";
$students="";
while($studentinfo=mysql_fetch_object($sq))
{
$students.="<a href=\"\" onclick=\"return openstudentinfo($studentinfo->id)\">$studentinfo->firstname $studentinfo->lastname </a><br />";
// $students.="<a href=\"\" onclick=\"return openstudentinfo($studentinfo->id)\">$studentinfo->firstname $studentinfo->lastname </a><br />";
$students.="<a href=\"student_editor.php?registration_id=$r->reg_id\">$studentinfo->firstname $studentinfo->lastname </a><br />";
$schools.="$studentinfo->school <br />";
$stats_totalstudents++;
}

369
admin/student_editor.php Normal file
View File

@ -0,0 +1,369 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
auth_required("admin");
send_header("Student Editor");
echo "<a href=\"registration_list.php\">&lt;&lt; ".i18n("Back to Registration List")."</a><br />";
echo "<br />";
if($_POST['registration_id']) $registration_id=$_POST['registration_id'];
else if($_GET['registration_id']) $registration_id=$_GET['registration_id'];
//now do any data saves
if($_POST['action']=="save")
{
// {
$x=1;
while($_POST["num"][$x])
{
if($_POST['id'][$x]==0)
{
//if they use schoolpassword or singlepassword, then we need to set the school based on the school stored in the registration record. for anything else they can school the school on their own.
if($config['participant_registration_type']=="schoolpassword" || $config['participant_registration_type']=="invite")
{
$q=mysql_query("SELECT schools_id FROM registrations WHERE id='".$registration_id."' AND YEAR='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$schools_id=$r->schools_id;
$schoolvalue="'$schools_id', ";
}
else
{
$schoolvalue="'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ";
}
//INSERT new record
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x];
mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,email,address,city,province,postalcode,phone,dateofbirth,grade,schools_id,tshirt,medicalalert,foodreq,teachername,teacheremail,year) VALUES (".
"'".$registration_id."', ".
"'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['sex'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['address'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
"'$dob', ".
"'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
$schoolvalue.
"'".mysql_escape_string(stripslashes($_POST['tshirt'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['foodreq'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ".
"'".$config['FAIRYEAR']."')");
echo notice(i18n("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
}
else
{
//if they use schoolpassword or singlepassword, then we dont need to save teh schools_id because its already set when they inserted the record, and we dont allow them to change their school.
if(( $config['participant_registration_type']=="schoolpassword" || $config['participant_registration_type']=="invite") && !$_POST['schools_id'][$x])
{
$schoolquery="";
}
else
{
$schoolquery="schools_id='".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ";
}
//UPDATE existing record
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x];
mysql_query("UPDATE students SET ".
"firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
"lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
"sex='".mysql_escape_string(stripslashes($_POST['sex'][$x]))."', ".
"email='".mysql_escape_string(stripslashes($_POST['email'][$x]))."', ".
"address='".mysql_escape_string(stripslashes($_POST['address'][$x]))."', ".
"city='".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ".
"province='".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ".
"dateofbirth='$dob', ".
"grade='".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
$schoolquery.
"medicalalert='".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ".
"foodreq='".mysql_escape_string(stripslashes($_POST['foodreq'][$x]))."', ".
"teachername='".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
"teacheremail='".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ".
"tshirt='".mysql_escape_string(stripslashes($_POST['tshirt'][$x]))."' ".
"WHERE id='".$_POST['id'][$x]."'");
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x])));
}
$x++;
}
// }
}
if($_GET['action']=="removestudent")
{
// {
//first make sure this is one belonging to this registration id
$q=mysql_query("SELECT id FROM students WHERE id='".$_GET['removestudent']."' AND registrations_id='".$registration_id."'");
if(mysql_num_rows($q)==1)
{
mysql_query("DELETE FROM students WHERE id='".$_GET['removestudent']."' AND registrations_id='".$registration_id."'");
//now see if they have an emergency contact that also needs to be removed
$q=mysql_query("SELECT id FROM emergencycontact WHERE students_id='".$_GET['removestudent']."' AND registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
//no need to error message if this doesnt exist
if(mysql_num_rows($q)==1)
mysql_query("DELETE FROM emergencycontact WHERE students_id='".$_GET['removestudent']."' AND registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
echo notice(i18n("Student successfully removed"));
}
else
{
echo error(i18n("Invalid student to remove"));
}
// }
}
//now query and display
$q=mysql_query("SELECT * FROM students WHERE registrations_id='".$registration_id."' AND year='".$config['FAIRYEAR']."'");
$numfound=mysql_num_rows($q);
if($_GET['numstudents'])
$numtoshow=$_GET['numstudents'];
else
$numtoshow=$numfound;
echo "<form name=\"numstudentsform\" method=\"get\" action=\"student_editor.php\">";
echo "<input type=\"hidden\" name=\"registration_id\" value=\"$registration_id\">";
echo i18n("Number of students that worked on the project: ");
echo "<select name=\"numstudents\" onchange=\"document.forms.numstudentsform.submit()\">\n";
for($x=$config['minstudentsperproject'];$x<=$config['maxstudentsperproject'];$x++)
{
if($x<$numfound)
continue;
if($numtoshow==$x) $selected="selected=\"selected\""; else $selected="";
echo "<option $selected value=\"$x\">$x</option>\n";
}
echo "</select>";
echo "</form>";
echo "<form name=\"studentdata\" method=\"post\" action=\"student_editor.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />";
echo "<input type=\"hidden\" name=\"registration_id\" value=\"$registration_id\">";
for($x=1;$x<=$numtoshow;$x++)
{
$studentinfo=mysql_fetch_object($q);
echo "<h3>".i18n("Student %1 Details",array($x))."</h3>";
//if we have a valid student, set their ID, so we can UPDATE when we submit
//if there is no record for this student, then set the ID to 0, so we will INSERT when we submit
if($studentinfo->id) $id=$studentinfo->id; else $id=0;
//true should work here, it just has to be set to _something_ for it to work.
echo "<input type=\"hidden\" name=\"num[$x]\" value=\"true\" />";
//save the ID, or 0 if it doesnt exist
echo "<input type=\"hidden\" name=\"id[$x]\" value=\"$id\" />";
echo "<table>";
echo "<tr>\n";
echo " <td>".i18n("First Name")."</td><td><input type=\"text\" name=\"firstname[$x]\" value=\"$studentinfo->firstname\" />".REQUIREDFIELD."</td>\n";
echo " <td>".i18n("Last Name")."</td><td><input type=\"text\" name=\"lastname[$x]\" value=\"$studentinfo->lastname\" />".REQUIREDFIELD."</td>\n";
echo "</tr>\n";
if($config['participant_student_personal']=="yes")
{
echo "<tr>\n";
echo " <td>".i18n("Gender")."</td><td>";
echo "<select name=\"sex[$x]\">";
echo "<option value=\"\">".i18n("Select")."</option>\n";
if($studentinfo->sex=="male") $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"male\">".i18n("Male")."</option>\n";
if($studentinfo->sex=="female") $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"female\">".i18n("Female")."</option>\n";
echo "</select>".REQUIREDFIELD;
}
echo "</td>\n";
echo " <td></td><td></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Email Address")."</td><td><input type=\"text\" name=\"email[$x]\" value=\"$studentinfo->email\" />".REQUIREDFIELD."</td>\n";
if($config['participant_student_personal']=="yes")
{
echo " <td>".i18n("City")."</td><td><input type=\"text\" name=\"city[$x]\" value=\"$studentinfo->city\" />".REQUIREDFIELD."</td>\n";
}
else
{
echo "<td></td>";
}
echo "</tr>\n";
if($config['participant_student_personal']=="yes")
{
echo "<tr>\n";
echo " <td>".i18n("Address")."</td><td><input type=\"text\" name=\"address[$x]\" value=\"$studentinfo->address\" />".REQUIREDFIELD."</td>\n";
echo " <td>".i18n("Province")."</td><td>";
emit_province_selector("province[$x]",$studentinfo->province);
echo REQUIREDFIELD."</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Postal Code")."</td><td><input type=\"text\" name=\"postalcode[$x]\" value=\"$studentinfo->postalcode\" />".REQUIREDFIELD."</td>\n";
echo " <td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phone[$x]\" value=\"$studentinfo->phone\" />".REQUIREDFIELD."</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Date of Birth")."</td><td>\n";
list($year,$month,$day)=split("-",$studentinfo->dateofbirth);
echo "<table><tr><td>";
emit_day_selector("day[$x]",$day);
echo "</td><td>\n";
emit_month_selector("month[$x]",$month);
echo "</td><td>\n";
//the year selector should be based on the min/max grades possible
//assume min age of 3 for grade=0 (kindergarden)
//assume max age of 18 for grade=12
$minyearselect=$config['FAIRYEAR'] - 6 - $config['maxgrade'];
$maxyearselect=$config['FAIRYEAR'] - 3 - $config['mingrade'];
emit_year_selector("year[$x]",$year,$minyearselect,$maxyearselect);
echo "</td><td>".REQUIREDFIELD."</td></tr></table>\n";
echo "</td>\n";
}
else
echo "<tr>";
echo " <td>".i18n("Grade")."</td><td colspan=\"3\">\n";
echo "<select name=\"grade[$x]\">\n";
echo "<option value=\"\">".i18n("Grade")."</option>\n";
for($gr=$config['mingrade'];$gr<=$config['maxgrade'];$gr++)
{
if($studentinfo->grade==$gr) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$gr\">$gr</option>\n";
}
echo "</select>\n";
echo REQUIREDFIELD."</td>";
echo "</tr>";
if($config['participant_student_tshirt']=="yes")
{
echo "<tr>\n";
echo " <td>".i18n("T-Shirt Size")."</td><td>";
echo " <select name=\"tshirt[$x]\">\n";
if($studentinfo->tshirt=="small") $sel="selected=\"selected\""; else $sel="";
echo " <option $sel value=\"small\">".i18n("Small")."</option>";
if($studentinfo->tshirt=="medium") $sel="selected=\"selected\""; else $sel="";
echo " <option $sel value=\"medium\">".i18n("Medium")."</option>";
if($studentinfo->tshirt=="large") $sel="selected=\"selected\""; else $sel="";
echo " <option $sel value=\"large\">".i18n("Large")."</option>";
if($studentinfo->tshirt=="xlarge") $sel="selected=\"selected\""; else $sel="";
echo " <option $sel value=\"xlarge\">".i18n("X-Large")."</option>";
echo " </select>";
echo "</td>\n";
echo "</tr>";
}
if($config['participant_student_personal']=="yes")
{
echo "<tr>\n";
echo "<td>".i18n("Medical Alert Info")."</td><td colspan=\"3\">";
echo "<input name=\"medicalalert[$x]\" type=\"text\" size=\"50\" value=\"$studentinfo->medicalalert\" />";
echo "</td>";
echo "</tr>\n";
}
if($config['participant_student_foodreq']=="yes")
{
echo "<tr>\n";
echo "<td>".i18n("Special Food Requirements")."</td><td colspan=\"3\">";
echo "<input name=\"foodreq[$x]\" type=\"text\" size=\"50\" value=\"$studentinfo->foodreq\" />";
echo "</td>";
echo "</tr>\n";
}
echo "<tr>\n";
echo " <td>".i18n("School")."</td><td colspan=\"3\">";
if( $config['participant_registration_type']=="open" || $config['participant_registration_type']=="singlepassword" || ($studentinfo && !$studentinfo->schools_id) )
{
$schoolq=mysql_query("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER by school");
echo "<select name=\"schools_id[$x]\">\n";
echo "<option value=\"\">".i18n("Choose School")."</option>\n";
while($r=mysql_fetch_object($schoolq))
{
if($studentinfo->schools_id==$r->id) $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$r->id\">".htmlspecialchars($r->school)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
}
else
{
$schoolq=mysql_query("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."' AND id='$studentinfo->schools_id'");
$r=mysql_fetch_object($schoolq);
echo $r->school;
}
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>".i18n("Teacher Name")."</td><td><input type=\"text\" name=\"teachername[$x]\" value=\"$studentinfo->teachername\" /></td>\n";
echo " <td>".i18n("Teacher Email")."</td><td><input type=\"text\" name=\"teacheremail[$x]\" value=\"$studentinfo->teacheremail\" /></td>\n";
echo "</tr>\n";
echo "</table>";
if($numfound>$config['minstudentsperproject'] && $studentinfo->id)
{
echo "<div align=\"right\"><a onclick=\"return confirmClick('".i18n("Are you sure you want to remove this student from the project?")."');\" class=\"caution\" href=\"student_editor.php?registration_id=$registration_id&amp;action=removestudent&amp;removestudent=$studentinfo->id\">".i18n("Remove this student from project")."</a></div>";
}
echo "<br />";
echo "<br />";
}
echo "<br />";
echo i18n("WARNING! If you make a change to the grade that would affect the project number, you must update the project number manually, it will NOT be automatically updated");
echo "<input type=\"submit\" value=\"".i18n("Save Student Information")."\" />\n";
echo "</form>";
echo "<br />";
send_footer();
?>