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 Administration").""; echo "   "; echo "<< ".i18n("Back to Registration").""; echo "
"; echo "
"; $showformatbottom=true; if($_POST['action']=="received" && $_POST['registration_number']) { $q=mysql_query("SELECT * FROM registrations WHERE num='".$_POST['registration_number']."' AND year='".$config['FAIRYEAR']."'"); if(mysql_num_rows($q)==1) { $r=mysql_fetch_object($q); $reg_id=$r->id; $reg_num=$r->num; $reg_status=$r->status; if($r->status=='new') { echo error(i18n("Invalid Registration Status (%1 is New). Cannot receive an empty form.",array($_POST['registration_number']))); } else { //make sure all of the statuses are correct $statusstudent=studentStatus($reg_id); $statusemergencycontact=emergencycontactStatus($reg_id); $statusproject=projectStatus($reg_id); $statusmentor=mentorStatus($reg_id); $statussafety=safetyStatus($reg_id); if( $statusstudent == "complete" && $statusemergencycontact == "complete" && $statusproject == "complete" && $statusmentor == "complete" && $statussafety == "complete" ) { $q=mysql_query("SELECT projects.title, projectcategories.category, projectdivisions.division FROM projects,projectcategories,projectdivisions WHERE projects.registrations_id='$reg_id' AND projects.projectcategories_id=projectcategories.id AND projects.projectdivisions_id=projectdivisions.id "); echo mysql_Error(); $projectinfo=mysql_fetch_object($q); echo ""; echo ""; switch($reg_status) { case "paymentpending": $status_text="Payment Pending"; break; case "complete": $status_text="Complete"; break; case "open": $status_text="Open"; break; } echo ""; echo ""; echo ""; echo ""; $q=mysql_query("SELECT students.firstname, students.lastname, schools.school FROM students,schools WHERE students.registrations_id='$reg_id' AND students.schools_id=schools.id "); $studnum=1; while($studentinfo=mysql_fetch_object($q)) { if($studnum==1) echo ""; echo ""; } echo "
".i18n("Registration Summary for %1",array($reg_num))."
".i18n("Registration Status")."$status_text
".i18n("Registration Number")."$reg_num
".i18n("Project Title")."$projectinfo->title
".i18n("Category / Division")."$projectinfo->category / $projectinfo->division
".i18n("School")."$studentinfo->school
".i18n("Student %1",array($studnum))."$studentinfo->firstname $studentinfo->lastname
\n"; echo "
"; if($r->status!='complete') { echo ""; echo ""; echo ""; echo "\n"; echo ""; echo "
"; echo i18n("Is this the correct form to register?"); echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; if($config['regfee']>0) { echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; } else { echo "
"; echo ""; echo ""; echo ""; echo "
"; } echo "
"; echo "
"; $showformatbottom=false; } else { echo i18n("This form has already been received. Registration is complete"); echo "
"; echo "
"; echo "
"; } } else { echo error(i18n("All registration sections are not complete. Cannot register incomplete form")); } } } else { echo error(i18n("Invalid Registration Number (%1)",array($_POST['registration_number']))); } } else if($_POST['action']=="receivedyes" && $_POST['registration_number']) { //actually set it to 'closed' mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'"); $q=mysql_query("SELECT id FROM registrations WHERE num='".$_POST['registration_number']."'"); $r=mysql_fetch_object($q); $reg_id=$r->id; $q=mysql_query("SELECT projects.projectcategories_id, projects.projectdivisions_id FROM projects WHERE registrations_id='$reg_id'"); $r=mysql_fetch_object($q); $projectnumber=$config['project_num_format']; //first replace the division and category $projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber); $projectnumber=str_replace('C',$r->projectcategories_id,$projectnumber); //now change the N to a % so we can use it as a wildcard $querynum=str_replace('N','%',$projectnumber); $searchq=mysql_query("SELECT projectnumber FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber LIKE '$querynum'"); if(mysql_num_rows($searchq)) { //first, put them all in an array $proj_nums=array(); while($searchr=mysql_fetch_object($searchq)) { $proj_nums[]=$r->projectnumber; } //we will eventually find a good number, so lets loop forever until we find a good one $testnum=1; $Nnum=1; $ok=false; do { $Nnum=sprintf("%02d",$testnum); $test_projectnumber=str_replace('N',$Nnum,$projectnumber); if(!in_array($test_projectnumber,$proj_nums)) $ok=true; $testnum++; }while(!$ok); } else { $Nnum="01"; } $projectnumber=str_replace('N',$Nnum,$projectnumber); mysql_query("UPDATE projects SET projectnumber='$projectnumber' WHERE registrations_id='$reg_id' AND year='".$config['FAIRYEAR']."'"); echo happy(i18n("Registration of form %1 successfully completed",array($registration_number))); echo happy(i18n("Assigned Project Number: %1",array($projectnumber))); } else if($_POST['action']=="receivedyesnocash" && $_POST['registration_number']) { //actually set it to 'closed' mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='".$_POST['registration_number']."'"); echo happy(i18n("Registration of form %1 marked as payment pending",array($registration_number))); } else if($_POST['action']=="receivedno" && $_POST['registration_number']) { echo notice(i18n("Registration of form %1 cancelled",array($registration_number))); } if($showformatbottom) { echo "

".i18n("Input Received Form")."

"; echo "
"; echo ""; echo i18n("Enter the registration number from the form: ")."
"; echo ""; echo ""; echo "
"; } send_footer(); ?>