From 953e95ac3e57d8ccda36217c067f67b85f0eee10 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 4 Mar 2011 21:52:37 +0000 Subject: [PATCH] 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 --- admin/project_editor.php | 31 +++++-------- admin/registration_list.php | 86 +++++++++++++++++++++-------------- admin/student_editor.php | 86 ++++++++++++++++++----------------- projects.inc.php | 10 ++-- register_participants.inc.php | 7 +++ 5 files changed, 119 insertions(+), 101 deletions(-) diff --git a/admin/project_editor.php b/admin/project_editor.php index 9e7aced..03bd527 100644 --- a/admin/project_editor.php +++ b/admin/project_editor.php @@ -55,7 +55,7 @@ if($auth_type == 'fair') { switch($action) { case 'project_load': - project_load(); + project_load2(); break; case 'project_regenerate_number': /* Save first */ @@ -123,7 +123,7 @@ function project_save() "projectsort='".mysql_escape_string(stripslashes($_POST['projectsort']))."'". "WHERE id='".intval($_POST['id'])."'"); echo mysql_error(); - happy_("Project information successfully updated"); + happy_('Project Information Saved'); //check if they changed the project number if($_POST['projectnumber']!=$projectinfo->projectnumber) { @@ -141,31 +141,24 @@ function project_save() } -function project_load() +function project_load2() { global $registrations_id, $config, $conference; - //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='".$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; - } - + $projectcategories_id=getProjectCategory($registrations_id); //now select their project info $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 $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 if($projectcategories_id && $projectinfo->projectcategories_id!=$projectcategories_id) { echo notice(i18n("Age category changed, updating to %1",array($agecategories[$projectcategories_id]['category']))); diff --git a/admin/registration_list.php b/admin/registration_list.php index f8975c8..b17ac44 100644 --- a/admin/registration_list.php +++ b/admin/registration_list.php @@ -57,7 +57,7 @@ case 'delete': 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 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 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']."'"); @@ -300,18 +300,15 @@ $(document).ready(function() { selected: -1 }); +/* $("#newproject").click(function() { popup_editor(-1); } ); + */ }); -THIS PAGE IS NOT YET UPDATED TO THE NEW SYSTEM. PLEASE DO NOT USE IT -
- + \n"; + ?>
@@ -335,7 +332,9 @@ exit; } ?>
"; echo ""; if($showstatus) $stat="&showstatus=".$showstatus; echo "".i18n("Status").""; -echo "".i18n("Email Address").""; echo "".i18n("Reg Num").""; echo "".i18n("Proj Num").""; echo "".i18n("Project Title").""; echo "".i18n("Age Category").""; echo "".i18n("Division").""; -echo "".i18n("School(s)").""; -echo "".i18n("Student(s)").""; +echo "".i18n("Participant Details").""; echo "".i18n("Action").""; echo ""; echo ""; @@ -399,7 +396,6 @@ function list_query($conference_id, $wherestatus, $reg_id) $q=mysql_query("SELECT registrations.id AS reg_id, registrations.num AS reg_num, registrations.status, - registrations.email, projects.title, projects.projectnumber, projects.projectcategories_id, @@ -437,7 +433,7 @@ function print_row($r) $pcl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','project');\""; echo "{$status_text}"; - echo "{$r->email}"; +// echo "{$r->email}"; echo "{$r->reg_num}"; $pn = str_replace(' ', ' ', $r->projectnumber); echo "$pn"; @@ -446,44 +442,66 @@ function print_row($r) echo "".i18n($cats[$r->projectcategories_id]).""; echo "".i18n($divs[$r->projectdivisions_id]).""; - $sq=mysql_query("SELECT students.firstname, - students.lastname, - students.id, + echo ""; + + $sq=mysql_query("SELECT users.firstname, + users.lastname, + users.id, schools.school, schools.board, - schools.id AS schools_id + schools.id AS schools_id, + accounts.username, + accounts.email, + accounts.pendingemail FROM - students,schools + users + JOIN accounts ON users.accounts_id=accounts.id + LEFT JOIN schools ON users.schools_id=schools.id WHERE - students.registrations_id='$r->reg_id' - AND - students.schools_id=schools.id + users.registrations_id='$r->reg_id' "); echo mysql_error(); $studnum=1; $schools=""; $students=""; - while($studentinfo=mysql_fetch_object($sq)) - { - $students.="$studentinfo->firstname $studentinfo->lastname
"; - $schools.="$studentinfo->school
"; - } + $scl = "style=\"cursor:pointer;\" onclick=\"popup_editor('{$r->reg_id}','');\""; + //if theres more than 1, we should show some headings between the tables + if(mysql_num_rows($sq)>1) $showheadings=true; + + while($studentinfo=mysql_fetch_object($sq)) { + if($studentinfo->email) $e=$studentinfo->email; + else if($studentinfo->pendingemail) $e=$studentinfo->pendingemail; + else $e=""; + if($showheadings) + echo "Participant #$studnum
"; + + echo "reg_id}','');\">"; + echo "\n"; + echo "\n"; + if($e && $studentinfo->username!=$e) { + echo "\n"; + } + echo "\n"; + echo "
Name$studentinfo->firstname $studentinfo->lastname
Username$studentinfo->username
Email$e
School$studentinfo->school
\n"; + $studnum++; + } + echo ""; + - echo "$schools"; - echo "$students"; echo ""; if($conference_id==$conference['id']) { echo "reg_id});return false\" >"; echo ""; echo ""; - - echo "
"; - echo ""; - echo "email\">"; - echo "reg_num\">"; - echo ""; - echo "
"; + /* + echo "
"; + echo ""; + echo "email\">"; + echo "reg_num\">"; + echo ""; + echo "
"; + */ } diff --git a/admin/student_editor.php b/admin/student_editor.php index 1fe962f..39aa3c5 100644 --- a/admin/student_editor.php +++ b/admin/student_editor.php @@ -113,8 +113,10 @@ function students_save() $schoolvalue="'".mysql_escape_string(stripslashes($_POST['schools_id'][$x]))."', "; } //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]; - 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."', ". "'".mysql_escape_string(stripslashes($_POST['firstname'][$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['province'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['postalcode'][$x]))."', ". - "'".mysql_escape_string(stripslashes($_POST['phone'][$x]))."', ". + "'".mysql_escape_string(stripslashes($_POST['phonehome'][$x]))."', ". "'$dob', ". "'".mysql_escape_string(stripslashes($_POST['grade'][$x]))."', ". $schoolvalue. @@ -134,6 +136,7 @@ function students_save() "'".mysql_escape_string(stripslashes($_POST['teachername'][$x]))."', ". "'".mysql_escape_string(stripslashes($_POST['teacheremail'][$x]))."', ". "'".$conference['id']."')"); + */ happy_("%1 %2 successfully added",array($_POST['firstname'][$x],$_POST['lastname'][$x])); @@ -150,7 +153,7 @@ function students_save() //UPDATE existing record $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]))."', ". "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$x]))."', ". "sex='".mysql_escape_string(stripslashes($_POST['sex'][$x]))."', ". @@ -159,17 +162,20 @@ function students_save() "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', ". + "phonehome='".mysql_escape_string(stripslashes($_POST['phonehome'][$x]))."', ". + "birthdate='$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]."'"); + if(mysql_error()) { + error_("error: %1",array(mysql_error())); + } + else { happy_("%1 %2 successfully updated",array($_POST['firstname'][$x],$_POST['lastname'][$x])); + } } $x++; } @@ -181,7 +187,7 @@ function students_load() global $registrations_id, $config, $conference; //now query and display - $q=mysql_query("SELECT * FROM students WHERE + $q=mysql_query("SELECT * FROM users WHERE registrations_id='$registrations_id' AND conferences_id='{$conference['id']}'"); echo mysql_error(); @@ -192,12 +198,13 @@ function students_load() if($numtoshow == 0) $numtoshow=$numfound; + /* echo "
"; echo i18n("Number of students that worked on the project: "); echo ""; echo "
"; + */ echo "
"; for($x=1;$x<=$numtoshow;$x++) { @@ -240,15 +248,15 @@ function students_load() echo " \n"; echo "\n"; +/* echo "\n"; echo " ".i18n("Email Address")."email\" />".REQUIREDFIELD."\n"; + */ - if($config['participant_student_personal']=="yes") - { + if($config['participant_student_personal']=="yes") { echo " ".i18n("City")."city\" />".REQUIREDFIELD."\n"; } - else - { + else { echo ""; } @@ -264,12 +272,12 @@ function students_load() echo "\n"; echo "\n"; echo " ".i18n($config['postalzip'])."postalcode\" />".REQUIREDFIELD."\n"; - echo " ".i18n("Phone")."phone\" />".REQUIREDFIELD."\n"; + echo " ".i18n("Phone")."phonehome\" />".REQUIREDFIELD."\n"; echo "\n"; echo "\n"; echo " ".i18n("Date of Birth")."\n"; - list($year,$month,$day)=explode("-",$studentinfo->dateofbirth); + list($year,$month,$day)=explode("-",$studentinfo->birthdate); echo "\n"; echo " \n"; echo "\n"; +/* echo "\n"; echo " \n"; echo " \n"; echo "\n"; + */ @@ -453,10 +456,8 @@ function registration_load() - - - - + +
"; emit_day_selector("day[$x]",$day); echo "\n"; @@ -345,33 +353,28 @@ function students_load() echo "
".i18n("School").""; - if( $config['participant_registration_type']=="open" || $config['participant_registration_type']=="singlepassword" || ($studentinfo && !$studentinfo->schools_id) ) - { - $schoolq=mysql_query("SELECT id,school,city FROM schools WHERE conferences_id='".$conference['id']."' ORDER by city,school"); - echo "".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 FROM schools WHERE conferences_id='".$conference['id']."' AND id='$studentinfo->schools_id'"); + $validschool=mysql_fetch_object($schoolq); + //you know what, fuck it, in this editor we should always be able to chagne the school + $schoolq=mysql_query("SELECT id,school,city FROM schools WHERE conferences_id='".$conference['id']."' ORDER by city,school"); + echo "".REQUIREDFIELD; echo "
".i18n("Teacher Name")."teachername\" />".i18n("Teacher Email")."teacheremail\" />
:
:
: