Copyright (C) 2005 James Grant 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. */ ?> << ".i18n("Back to Participant Registration Summary")."
"; echo "
"; $regfee_items = array(); $items_q = mysql_query("SELECT * FROM regfee_items WHERE year='{$config['FAIRYEAR']}'"); while($items_i = mysql_fetch_assoc($items_q)) { $regfee_items[] = $items_i; } //now do any data saves if($_POST['action']=="save") { if(registrationFormsReceived()) { echo error(i18n("Cannot make changes to forms once they have been received by the fair")); } else if(registrationDeadlinePassed()) { echo error(i18n("Cannot make changes to forms after registration deadline")); } else { $x=1; while($_POST["num"][$x]) { $students_id = intval($_POST['id'][$x]); if($students_id==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='".$_SESSION['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,pronunciation,sex,email,address,city,province,postalcode,phone,dateofbirth,grade,schools_id,tshirt,medicalalert,foodreq,teachername,teacheremail,year) VALUES (". "'".$_SESSION['registration_id']."', ". "'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['pronunciation'][$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']."')"); $students_id = mysql_insert_id(); 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]))."', ". "pronunciation='".mysql_escape_string(stripslashes($_POST['pronunciation'][$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='$students_id'"); echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x]))); } /* Update the regfee items link */ if($config['participant_regfee_items_enable'] == 'yes') { mysql_query("DELETE FROM regfee_items_link WHERE students_id='$students_id'"); if(is_array($_POST['regfee_item'][$x])) { foreach($_POST['regfee_item'][$x] as $id=>$enabled) { mysql_query("INSERT INTO regfee_items_link(`students_id`,`regfee_items_id`) VALUES ('$students_id','$id') "); } } } $x++; } } } if($_GET['action']=="removestudent") { if(registrationFormsReceived()) { echo error(i18n("Cannot make changes to forms once they have been received by the fair")); } else { $students_id = intval($_GET['removestudent']); //first make sure this is one belonging to this registration id $q=mysql_query("SELECT id FROM students WHERE id='$students_id' AND registrations_id='".$_SESSION['registration_id']."'"); if(mysql_num_rows($q)==1) { mysql_query("DELETE FROM students WHERE id='$students_id' AND registrations_id='".$_SESSION['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='$students_id' AND registrations_id='".$_SESSION['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='$students_id' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); mysql_query("DELETE FROM regfee_items_link WHERE students_id='$students_id'"); echo notice(i18n("Student successfully removed")); } else { echo error(i18n("Invalid student to remove")); } } } //output the current status $newstatus=studentStatus(); if($newstatus!="complete") { echo error(i18n("Student Information Incomplete")); } else if($newstatus=="complete") { echo happy(i18n("Student Information Complete")); } //now query and display $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); if(mysql_num_rows($q)==0) { //uhh oh, we didnt find any, this isnt possible! lets insert one using the logged in persons email address //although... this can never really happen, since the above queries only allow the page to view if the student //is found in the students table... soo... well, lets leave it here as a fallback anyways, just incase mysql_query("INSERT INTO students (registrations_id,email,year) VALUES ('".$_SESSION['registration_id']."','".mysql_escape_string($_SESSION['email'])."','".$config['FAIRYEAR']."')"); //if we just inserted it, then we will obviously find 1 $numfound=1; } else { $numfound=mysql_num_rows($q); } if($_GET['numstudents']) $numtoshow=$_GET['numstudents']; else $numtoshow=$numfound; echo "
"; echo i18n("Number of students that worked on the project: "); echo ""; echo "
"; if($numtoshow>$config['maxstudentsperproject']) $numtoshow=$config['maxstudentsperproject']; echo "
"; echo ""; for($x=1;$x<=$numtoshow;$x++) { $studentinfo=mysql_fetch_object($q); echo "

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

"; //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 ""; //save the ID, or 0 if it doesnt exist echo ""; echo ""; echo "\n"; echo " \n"; echo " \n"; echo "\n"; if($config['participant_student_pronunciation']=='yes') { echo "\n"; echo " \n"; echo " "; echo "\n"; } if($config['participant_student_personal']=="yes") { echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; if($config['participant_student_personal']=="yes") { echo " \n"; } else { echo ""; } echo "\n"; if($config['participant_student_personal']=="yes") { echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; } else echo ""; echo " "; echo ""; if($config['participant_student_tshirt']=="yes") { $tshirt_cost = floatval($config['participant_student_tshirt_cost']); echo "\n"; echo " \n"; echo ""; } if($config['participant_student_personal']=="yes") { echo "\n"; echo ""; echo "\n"; } if($config['participant_student_foodreq']=="yes") { echo "\n"; echo ""; echo "\n"; } echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; if($config['participant_regfee_items_enable'] == 'yes' ) { $sel_q = mysql_query("SELECT * FROM regfee_items_link WHERE students_id=$id"); $sel = array(); while($info_q = mysql_fetch_assoc($sel_q)) { $sel[$info_q['regfee_items_id']] = $info_q['id']; } foreach($regfee_items as $rfi) { echo "'; } } echo "
".i18n("First Name")."firstname\" />".REQUIREDFIELD."".i18n("Last Name")."lastname\" />".REQUIREDFIELD."
".i18n("Name Pronunciation Key")."pronunciation}\" />(for award ceremony, fill out this Pronunciation Key if your name is often mispronounced)
".i18n("Gender").""; echo "".REQUIREDFIELD; } echo "
".i18n("Email Address")."email\" />".REQUIREDFIELD."".i18n("City")."city\" />".REQUIREDFIELD."
".i18n("Address")."address\" />".REQUIREDFIELD."".i18n($config['provincestate']).""; emit_province_selector("province[$x]",$studentinfo->province); echo REQUIREDFIELD."
".i18n($config['postalzip'])."postalcode\" />".REQUIREDFIELD."".i18n("Phone")."phone\" />".REQUIREDFIELD."
".i18n("Date of Birth")."\n"; list($year,$month,$day)=split("-",$studentinfo->dateofbirth); echo "
"; emit_day_selector("day[$x]",$day); echo "\n"; emit_month_selector("month[$x]",$month); echo "\n"; //the year selector should be based on the min/max ages possible (as set in $config) $minyearselect=$config['FAIRYEAR'] - $config['maxage']; $maxyearselect=$config['FAIRYEAR'] - $config['minage']; emit_year_selector("year[$x]",$year,$minyearselect,$maxyearselect); echo "".REQUIREDFIELD."
\n"; echo "
".i18n("Grade")."\n"; echo "\n"; echo REQUIREDFIELD."
".i18n("T-Shirt Size").""; echo " "; if($tshirt_cost != 0.0) { printf(" The cost of each T-Shirt is $%.2f, sizes are Adult sizes.", $tshirt_cost); } echo "
".i18n("Medical Alert Info").""; echo "medicalalert\" />"; echo "
".i18n("Special Food Requirements").""; echo "foodreq\" />"; echo "
".i18n("School").""; if( $config['participant_registration_type']=="open" || $config['participant_registration_type']=="singlepassword" || $config['participant_registration_type']=="openorinvite" || ($studentinfo && !$studentinfo->schools_id) ) { $schoolq=mysql_query("SELECT id,school,city FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER by city,school"); echo "".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 "
".i18n("Teacher Name")."teachername\" />".i18n("Teacher Email")."teacheremail\" />
\n"; $checked = array_key_exists($rfi['id'], $sel) ? 'checked="checked"' : ''; echo ""; echo ''; echo i18n($rfi['description']); echo '
"; if($numfound>$config['minstudentsperproject'] && $studentinfo->id) { echo "
id\">".i18n("Remove this student from project")."
"; } echo "
"; echo "
"; } echo "\n"; echo "
"; echo "
"; echo notice(i18n("Note: if you change the email address that you are logged in with right now, you will be automatically logged out and will need to log back in again with your new email address")); send_footer(); ?>