Update student/project editor for admin

Fix the registration_list.php to work again - temporarily disable "create new project" and the ability to ADD students to an existing project
This commit is contained in:
james 2011-03-04 21:52:37 +00:00
parent 9caa5b0a17
commit 953e95ac3e
5 changed files with 119 additions and 101 deletions

View File

@ -55,7 +55,7 @@ if($auth_type == 'fair') {
switch($action) { switch($action) {
case 'project_load': case 'project_load':
project_load(); project_load2();
break; break;
case 'project_regenerate_number': case 'project_regenerate_number':
/* Save first */ /* Save first */
@ -123,7 +123,7 @@ function project_save()
"projectsort='".mysql_escape_string(stripslashes($_POST['projectsort']))."'". "projectsort='".mysql_escape_string(stripslashes($_POST['projectsort']))."'".
"WHERE id='".intval($_POST['id'])."'"); "WHERE id='".intval($_POST['id'])."'");
echo mysql_error(); echo mysql_error();
happy_("Project information successfully updated"); happy_('Project Information Saved');
//check if they changed the project number //check if they changed the project number
if($_POST['projectnumber']!=$projectinfo->projectnumber) { if($_POST['projectnumber']!=$projectinfo->projectnumber) {
@ -141,31 +141,24 @@ function project_save()
} }
function project_load() function project_load2()
{ {
global $registrations_id, $config, $conference; global $registrations_id, $config, $conference;
//now lets find out their MAX grade, so we can pre-set the Age Category $projectcategories_id=getProjectCategory($registrations_id);
$q=mysql_query("SELECT MAX(grade) AS maxgrade FROM students WHERE registrations_id='".$registrations_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 conferences_id='".$conference['id']."' 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 //now select their project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_id."' AND conferences_id='".$conference['id']."'"); $q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$registrations_id."' AND conferences_id='".$conference['id']."'");
//check if it exists, if we didnt find any record, lets insert one //check if it exists, if we didnt find any record, lets insert one
$projectinfo=mysql_fetch_object($q); $projectinfo=mysql_fetch_object($q);
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
while($r=mysql_fetch_object($q)) {
//save these in an array, so we can use them below
$agecategories[$r->id]['category']=$r->category;
$agecategories[$r->id]['mingrade']=$r->mingrade;
$agecategories[$r->id]['maxgrade']=$r->maxgrade;
}
//make sure that if they changed their grade on the student page, we update their projectcategories_id accordingly //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) { if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id) {
echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category']))); echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category'])));

View File

@ -57,7 +57,7 @@ case 'delete':
mysql_query("DELETE FROM winners WHERE projects_id='{$p['id']}'"); mysql_query("DELETE FROM winners WHERE projects_id='{$p['id']}'");
} }
mysql_query("DELETE FROM registrations WHERE id='$regid' AND conferences_id='".$conference['id']."'"); mysql_query("DELETE FROM registrations WHERE id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM students WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'"); mysql_query("DELETE FROM users WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM projects WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'"); mysql_query("DELETE FROM projects WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
mysql_query("DELETE FROM safety WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'"); mysql_query("DELETE FROM safety WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
// mysql_query("DELETE FROM questions_answers WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'"); // mysql_query("DELETE FROM questions_answers WHERE registrations_id='$regid' AND conferences_id='".$conference['id']."'");
@ -300,18 +300,15 @@ $(document).ready(function() {
selected: -1 selected: -1
}); });
/*
$("#newproject").click(function() { $("#newproject").click(function() {
popup_editor(-1); popup_editor(-1);
} }
); );
*/
}); });
</script> </script>
<b>THIS PAGE IS NOT YET UPDATED TO THE NEW SYSTEM. PLEASE DO NOT USE IT</b>
<?
send_footer();
exit;
?>
<br /> <br />
<table style="width: 500px;"> <table style="width: 500px;">
<tr><td> <tr><td>
@ -335,7 +332,9 @@ exit;
} }
?> ?>
</select></form></td> </select></form></td>
<td align="right"><button id="newproject"><?=i18n("Create New Project")?></button></td> <?
// echo <td align=\"right\"><button id=\"newproject\">".i18n("Create New Project")."</button></td>\n";
?>
</tr></table> </tr></table>
<? <?
@ -357,14 +356,12 @@ echo "<table id=\"registration_list\" class=\"tableview\">";
echo "<thead><tr>"; echo "<thead><tr>";
if($showstatus) $stat="&showstatus=".$showstatus; if($showstatus) $stat="&showstatus=".$showstatus;
echo "<th>".i18n("Status")."</th>"; echo "<th>".i18n("Status")."</th>";
echo "<th>".i18n("Email Address")."</th>";
echo "<th>".i18n("Reg Num")."</th>"; echo "<th>".i18n("Reg Num")."</th>";
echo "<th>".i18n("Proj Num")."</th>"; echo "<th>".i18n("Proj Num")."</th>";
echo "<th>".i18n("Project Title")."</th>"; echo "<th>".i18n("Project Title")."</th>";
echo "<th>".i18n("Age Category")."</th>"; echo "<th>".i18n("Age Category")."</th>";
echo "<th>".i18n("Division")."</th>"; echo "<th>".i18n("Division")."</th>";
echo "<th>".i18n("School(s)")."</th>"; echo "<th>".i18n("Participant Details")."</th>";
echo "<th>".i18n("Student(s)")."</th>";
echo "<th>".i18n("Action")."</th>"; echo "<th>".i18n("Action")."</th>";
echo "</tr></thead>"; echo "</tr></thead>";
echo "<tbody>"; echo "<tbody>";
@ -399,7 +396,6 @@ function list_query($conference_id, $wherestatus, $reg_id)
$q=mysql_query("SELECT registrations.id AS reg_id, $q=mysql_query("SELECT registrations.id AS reg_id,
registrations.num AS reg_num, registrations.num AS reg_num,
registrations.status, registrations.status,
registrations.email,
projects.title, projects.title,
projects.projectnumber, projects.projectnumber,
projects.projectcategories_id, projects.projectcategories_id,
@ -437,7 +433,7 @@ function print_row($r)
$pcl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','project');\""; $pcl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','project');\"";
echo "<td $scl>{$status_text}</td>"; echo "<td $scl>{$status_text}</td>";
echo "<td $scl>{$r->email}</td>"; // echo "<td $scl>{$r->email}</td>";
echo "<td $scl>{$r->reg_num}</td>"; echo "<td $scl>{$r->reg_num}</td>";
$pn = str_replace(' ', '&nbsp;', $r->projectnumber); $pn = str_replace(' ', '&nbsp;', $r->projectnumber);
echo "<td $scl>$pn</td>"; echo "<td $scl>$pn</td>";
@ -446,44 +442,66 @@ function print_row($r)
echo "<td $scl>".i18n($cats[$r->projectcategories_id])."</td>"; echo "<td $scl>".i18n($cats[$r->projectcategories_id])."</td>";
echo "<td $scl>".i18n($divs[$r->projectdivisions_id])."</td>"; echo "<td $scl>".i18n($divs[$r->projectdivisions_id])."</td>";
$sq=mysql_query("SELECT students.firstname, echo "<td>";
students.lastname,
students.id, $sq=mysql_query("SELECT users.firstname,
users.lastname,
users.id,
schools.school, schools.school,
schools.board, schools.board,
schools.id AS schools_id schools.id AS schools_id,
accounts.username,
accounts.email,
accounts.pendingemail
FROM FROM
students,schools users
JOIN accounts ON users.accounts_id=accounts.id
LEFT JOIN schools ON users.schools_id=schools.id
WHERE WHERE
students.registrations_id='$r->reg_id' users.registrations_id='$r->reg_id'
AND
students.schools_id=schools.id
"); ");
echo mysql_error(); echo mysql_error();
$studnum=1; $studnum=1;
$schools=""; $schools="";
$students=""; $students="";
while($studentinfo=mysql_fetch_object($sq)) $scl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','');\"";
{ //if theres more than 1, we should show some headings between the tables
$students.="$studentinfo->firstname $studentinfo->lastname<br />"; if(mysql_num_rows($sq)>1) $showheadings=true;
$schools.="$studentinfo->school <br />";
} while($studentinfo=mysql_fetch_object($sq)) {
if($studentinfo->email) $e=$studentinfo->email;
else if($studentinfo->pendingemail) $e=$studentinfo->pendingemail;
else $e="";
if($showheadings)
echo "<b>Participant #$studnum</b><br />";
echo "<table style=\"cursor:pointer; border-collapse: collapse;\" onclick=\"popup_editor('{$r->reg_id}','');\">";
echo "<tr><th>Name</th><td>$studentinfo->firstname $studentinfo->lastname</td></tr>\n";
echo "<tr><th>Username</th><td>$studentinfo->username</td></tr>\n";
if($e && $studentinfo->username!=$e) {
echo "<tr><th>Email</th><td>$e</td></tr>\n";
}
echo "<tr><th>School</th><td>$studentinfo->school</td></tr>\n";
echo "</table>\n";
$studnum++;
}
echo "</td>";
echo "<td $scl>$schools</td>";
echo "<td $scl>$students</td>";
echo "<td align=\"center\" >"; echo "<td align=\"center\" >";
if($conference_id==$conference['id']) { if($conference_id==$conference['id']) {
echo "<a title=\"".i18n("Delete this registration")."\" href=\"#\" onClick=\"delete_registration({$r->reg_id});return false\" >"; echo "<a title=\"".i18n("Delete this registration")."\" href=\"#\" onClick=\"delete_registration({$r->reg_id});return false\" >";
echo "<img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=0>"; echo "<img src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\" border=0>";
echo "</a>"; echo "</a>";
/*
echo "<form target=\"_blank\" method=\"post\" action=\"../register_participants.php\">"; echo "<form target=\"_blank\" method=\"post\" action=\"../register_participants.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">"; echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
echo "<input type=\"hidden\" name=\"email\" value=\"$r->email\">"; echo "<input type=\"hidden\" name=\"email\" value=\"$r->email\">";
echo "<input type=\"hidden\" name=\"regnum\" value=\"$r->reg_num\">"; echo "<input type=\"hidden\" name=\"regnum\" value=\"$r->reg_num\">";
echo "<input type=\"submit\" value=\"".i18n("Login")."\">"; echo "<input type=\"submit\" value=\"".i18n("Login")."\">";
echo "</form>"; echo "</form>";
*/
} }

View File

@ -113,8 +113,10 @@ function students_save()
$schoolvalue="'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', "; $schoolvalue="'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', ";
} }
//INSERT new record //INSERT new record
//FIXME: we don't do this yet, rather, we need to check if the account exists, add it if not, then account_add_role()
/*
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x]; $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,conferences_id) VALUES (". mysql_query("INSERT INTO students (registrations_id,firstname,lastname,sex,email,address,city,province,postalcode,phonehome,birthdate,grade,schools_id,tshirt,medicalalert,foodreq,teachername,teacheremail,conferences_id) VALUES (".
"'".$registrations_id."', ". "'".$registrations_id."', ".
"'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
@ -124,7 +126,7 @@ function students_save()
"'".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['phonehome'][$x]))."', ".
"'$dob', ". "'$dob', ".
"'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
$schoolvalue. $schoolvalue.
@ -134,6 +136,7 @@ function students_save()
"'".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ".
"'".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ".
"'".$conference['id']."')"); "'".$conference['id']."')");
*/
happy_("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x])); happy_("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x]));
@ -150,7 +153,7 @@ function students_save()
//UPDATE existing record //UPDATE existing record
$dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x]; $dob=$_POST['year'][$x]."-".$_POST['month'][$x]."-".$_POST['day'][$x];
mysql_query("UPDATE students SET ". mysql_query("UPDATE users SET ".
"firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ". "firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$x]))."', ".
"lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ".
"sex='".mysql_escape_string(stripslashes($_POST['sex'][$x]))."', ". "sex='".mysql_escape_string(stripslashes($_POST['sex'][$x]))."', ".
@ -159,17 +162,20 @@ function students_save()
"city='".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ". "city='".mysql_escape_string(stripslashes($_POST['city'][$x]))."', ".
"province='".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ". "province='".mysql_escape_string(stripslashes($_POST['province'][$x]))."', ".
"postalcode='".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ". "postalcode='".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ".
"phone='".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ". "phonehome='".mysql_escape_string(stripslashes($_POST['phonehome'][$x]))."', ".
"dateofbirth='$dob', ". "birthdate='$dob', ".
"grade='".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ". "grade='".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ".
$schoolquery. $schoolquery.
"medicalalert='".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ". "medicalalert='".mysql_escape_string(stripslashes($_POST['medicalalert'][$x]))."', ".
"foodreq='".mysql_escape_string(stripslashes($_POST['foodreq'][$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]))."' ". "tshirt='".mysql_escape_string(stripslashes($_POST['tshirt'][$x]))."' ".
"WHERE id='".$_POST['id'][$x]."'"); "WHERE id='".$_POST['id'][$x]."'");
if(mysql_error()) {
error_("error: %1",array(mysql_error()));
}
else {
happy_("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x])); happy_("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x]));
}
} }
$x++; $x++;
} }
@ -181,7 +187,7 @@ function students_load()
global $registrations_id, $config, $conference; global $registrations_id, $config, $conference;
//now query and display //now query and display
$q=mysql_query("SELECT * FROM students WHERE $q=mysql_query("SELECT * FROM users WHERE
registrations_id='$registrations_id' registrations_id='$registrations_id'
AND conferences_id='{$conference['id']}'"); AND conferences_id='{$conference['id']}'");
echo mysql_error(); echo mysql_error();
@ -192,12 +198,13 @@ function students_load()
if($numtoshow == 0) $numtoshow=$numfound; if($numtoshow == 0) $numtoshow=$numfound;
/*
echo "<form>"; echo "<form>";
echo i18n("Number of students that worked on the project: "); echo i18n("Number of students that worked on the project: ");
echo "<select id=\"students_num\">\n"; echo "<select id=\"students_num\">\n";
for($x=$config['minstudentsperproject'];$x<=$config['maxstudentsperproject'];$x++) { for($x=$config['minstudentsperproject'];$x<=$config['maxstudentsperproject'];$x++) {
/* Don't let them go back to fewer student by selection, // Don't let them go back to fewer student by selection,
* force them to delete one */ // force them to delete one
if($x<$numfound) continue; if($x<$numfound) continue;
$sel = ($numtoshow==$x) ? 'selected="selected"' : ''; $sel = ($numtoshow==$x) ? 'selected="selected"' : '';
@ -205,6 +212,7 @@ function students_load()
} }
echo "</select>"; echo "</select>";
echo "</form>"; echo "</form>";
*/
echo "<form id=\"students_form\" >"; echo "<form id=\"students_form\" >";
for($x=1;$x<=$numtoshow;$x++) { for($x=1;$x<=$numtoshow;$x++) {
@ -240,15 +248,15 @@ function students_load()
echo " <td></td><td></td>\n"; echo " <td></td><td></td>\n";
echo "</tr>\n"; echo "</tr>\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"; 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") if($config['participant_student_personal']=="yes") {
{
echo " <td>".i18n("City")."</td><td><input type=\"text\" name=\"city[$x]\" value=\"$studentinfo->city\" />".REQUIREDFIELD."</td>\n"; echo " <td>".i18n("City")."</td><td><input type=\"text\" name=\"city[$x]\" value=\"$studentinfo->city\" />".REQUIREDFIELD."</td>\n";
} }
else else {
{
echo "<td></td>"; echo "<td></td>";
} }
@ -264,12 +272,12 @@ function students_load()
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo " <td>".i18n($config['postalzip'])."</td><td><input type=\"text\" name=\"postalcode[$x]\" value=\"$studentinfo->postalcode\" />".REQUIREDFIELD."</td>\n"; echo " <td>".i18n($config['postalzip'])."</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 " <td>".i18n("Phone")."</td><td><input type=\"text\" name=\"phonehome[$x]\" value=\"$studentinfo->phonehome\" />".REQUIREDFIELD."</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo " <td>".i18n("Date of Birth")."</td><td>\n"; echo " <td>".i18n("Date of Birth")."</td><td>\n";
list($year,$month,$day)=explode("-",$studentinfo->dateofbirth); list($year,$month,$day)=explode("-",$studentinfo->birthdate);
echo "<table><tr><td>"; echo "<table><tr><td>";
emit_day_selector("day[$x]",$day); emit_day_selector("day[$x]",$day);
echo "</td><td>\n"; echo "</td><td>\n";
@ -345,33 +353,28 @@ function students_load()
echo "<tr>\n"; echo "<tr>\n";
echo " <td>".i18n("School")."</td><td colspan=\"3\">"; 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 conferences_id='".$conference['id']."' AND id='$studentinfo->schools_id'");
{ $validschool=mysql_fetch_object($schoolq);
$schoolq=mysql_query("SELECT id,school,city FROM schools WHERE conferences_id='".$conference['id']."' ORDER by city,school"); //you know what, fuck it, in this editor we should always be able to chagne the 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->city).' - '.htmlspecialchars($r->school)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
}
else
{
$schoolq=mysql_query("SELECT id,school FROM schools WHERE conferences_id='".$conference['id']."' AND id='$studentinfo->schools_id'");
$r=mysql_fetch_object($schoolq);
echo $r->school;
}
$schoolq=mysql_query("SELECT id,school,city FROM schools WHERE conferences_id='".$conference['id']."' ORDER by city,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->city).' - '.htmlspecialchars($r->school)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\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 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 " <td>".i18n("Teacher Email")."</td><td><input type=\"text\" name=\"teacheremail[$x]\" value=\"$studentinfo->teacheremail\" /></td>\n";
echo "</tr>\n"; echo "</tr>\n";
*/
@ -453,10 +456,8 @@ function registration_load()
<tr> <tr>
<td><?=i18n("Registration Number")?>:</td> <td><?=i18n("Registration Number")?>:</td>
<td><input type="text" name="registration_num" value="<?=$r['num']?>"></td> <td><input type="text" name="registration_num" value="<?=$r['num']?>"></td>
</tr><tr> </tr>
<td><?=i18n("Registration Email")?>:</td> <tr>
<td><input type="text" name="registration_email" value="<?=$r['email']?>"></td>
</tr><tr>
<td><?=i18n("Status")?>:</td> <td><?=i18n("Status")?>:</td>
<td><select name="registration_status"> <td><select name="registration_status">
<? foreach($status as $k=>$v) { <? foreach($status as $k=>$v) {
@ -511,8 +512,10 @@ function registration_save()
$registrations_id = mysql_insert_id(); $registrations_id = mysql_insert_id();
/* Create one student and a project */ /* Create one student and a project */
/*
mysql_query("INSERT INTO students (registrations_id,email,conferences_id) VALUES ( mysql_query("INSERT INTO students (registrations_id,email,conferences_id) VALUES (
$registrations_id, '$registration_email', '{$conference['id']}')"); $registrations_id, '$registration_email', '{$conference['id']}')");
*/
mysql_query("INSERT INTO projects (registrations_id,conferences_id) VALUES ( mysql_query("INSERT INTO projects (registrations_id,conferences_id) VALUES (
$registrations_id, '{$conference['id']}')"); $registrations_id, '{$conference['id']}')");
happy_('Created student and project record'); happy_('Created student and project record');
@ -521,8 +524,7 @@ function registration_save()
/* Update registration */ /* Update registration */
mysql_query("UPDATE registrations SET mysql_query("UPDATE registrations SET
num='$registration_num', num='$registration_num',
status='$registration_status', status='$registration_status'
email='$registration_email'
WHERE WHERE
id='$registrations_id'"); id='$registrations_id'");
echo mysql_error(); echo mysql_error();
@ -535,7 +537,7 @@ function registration_save()
WHERE WHERE
registrations_id='$registrations_id'"); registrations_id='$registrations_id'");
echo mysql_error(); echo mysql_error();
happy_('Information Saved'); happy_('Registration Information Saved');
echo "<script language=\"javascript\" type=\"text/javascript\">"; echo "<script language=\"javascript\" type=\"text/javascript\">";
echo "registrations_id=$registrations_id;"; echo "registrations_id=$registrations_id;";
echo "</script>"; echo "</script>";

View File

@ -279,9 +279,9 @@ function project_load($pid)
$proj = mysql_fetch_array($q); $proj = mysql_fetch_array($q);
/* Load the students */ /* Load the students */
$q = mysql_query("SELECT students.*,schools.school FROM students $q = mysql_query("SELECT users.*,schools.school FROM users
LEFT JOIN schools ON schools.id=students.schools_id LEFT JOIN schools ON schools.id=students.schools_id
WHERE registrations_id='{$proj['registrations_id']}' AND students.conferences_id='{$proj['conferences_id']}' ORDER BY students.id"); WHERE registrations_id='{$proj['registrations_id']}' AND users.conferences_id='{$proj['conferences_id']}' ORDER BY users.id");
$proj['num_students'] = 0; $proj['num_students'] = 0;
while($s = mysql_fetch_assoc($q)) { while($s = mysql_fetch_assoc($q)) {
$proj['num_students']++; $proj['num_students']++;
@ -297,10 +297,8 @@ function getProjectCategory($registrations_id){
$projectcategories_id = null; $projectcategories_id = null;
//now lets grab all the age categories, so we can choose one based on the max grade //now lets grab all the age categories, so we can choose one based on the max grade
$q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id"); $q=mysql_query("SELECT * FROM projectcategories WHERE conferences_id='".$conference['id']."' ORDER BY id");
while(($r=mysql_fetch_object($q)) && $projectcategories_id === null) while(($r=mysql_fetch_object($q)) && $projectcategories_id === null) {
{ if($gradeinfo->maxgrade >= $r->mingrade && $gradeinfo->maxgrade <= $r->maxgrade) {
if($gradeinfo->maxgrade >= $r->mingrade && $gradeinfo->maxgrade <= $r->maxgrade)
{
$projectcategories_id = $r->id; $projectcategories_id = $r->id;
} }
} }

View File

@ -382,6 +382,13 @@ function saveProjectData($data,$registrations_id=null){
} }
} }
//if the status is 'new', change it to 'open' but we dont change any other statuses to 'open'
//becuase if tis already complete, or paymentpending, we dont want to reset that
//though, they shouldnt be submitting this is its complete or paymentpending, EXCEPT
//if they are saving the special award nominations.... crap... ummmm
//FIXME: read above comment, and figure out a solution
mysql_query("UPDATE registrations SET status='open' WHERE status='new' AND id='{$rid}'");
//and update nummentors in registrations, yea, i know its not in the projects table //and update nummentors in registrations, yea, i know its not in the projects table
if(isset($data['nummentors'])) { if(isset($data['nummentors'])) {
if($data['nummentors']==null) { if($data['nummentors']==null) {