diff --git a/admin/index.php b/admin/index.php index 8e0ebc8..10c110e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -46,7 +46,7 @@ if($config['volunteer_enable'] == 'yes') { echo "".i18n("Volunteer Management")."
"; } if($config['tours_enable'] == 'yes') { - echo "".i18n("Tour Management")."
"; + echo "".i18n("Tour Management")."
"; } echo "".i18n("Internal Document Management")."
"; echo "
"; diff --git a/admin/tours.php b/admin/tours.php new file mode 100644 index 0000000..d13ab1b --- /dev/null +++ b/admin/tours.php @@ -0,0 +1,40 @@ + + 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. +*/ +?> + 'committee_main.php', + 'Administration' => 'admin/index.php') + ); + echo "".i18n("Manage Tours")." ".i18n("- Add, Delete, Edit, and List tours")."
"; + echo "".i18n("Edit Student-Tour Assignments")."
"; + echo "
"; + echo "".i18n("Automatic Tour Assignments")."
"; + + send_footer(); + +?> diff --git a/admin/tours_assignments.php b/admin/tours_assignments.php new file mode 100644 index 0000000..194343e --- /dev/null +++ b/admin/tours_assignments.php @@ -0,0 +1,325 @@ + + Copyright (C) 2005 James Grant + Copyright (C) 2008 David 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. +*/ +?> +id]['name'] = $i->name; + $tours[$i->id]['num'] = $x; + $x++; + } + + if($_GET['action']=='info') { + $sid = intval($_GET['id']); + + $query="SELECT * FROM students WHERE id='$sid' + AND year='{$config['FAIRYEAR']}'"; + $r = mysql_query($query); + $i = mysql_fetch_object($r); + + send_popup_header(i18n('Student Tour Rank Information - %1 %2', + array($i->firstname, $i->lastname))); + $query="SELECT * FROM tours_choice + WHERE students_id='$sid' + AND year='{$config['FAIRYEAR']}' + ORDER BY rank"; + $r = mysql_query($query); + echo ''; + $count = mysql_num_rows($r); + while($i = mysql_fetch_object($r)) { + echo ''; + } + echo '
'; + if($i->rank == 0) { + echo ''.i18n('Current Assigned Tour').':'; + echo ''; + echo "#{$tours[$i->tour_id]['num']}: {$tours[$i->tour_id]['name']}"; + echo '

'; + $count--; + } else { + echo ''.i18n('Tour Preference %1', + array($i->rank)).':'; + echo '
'; + echo "#{$tours[$i->tour_id]['num']}: {$tours[$i->tour_id]['name']}"; + echo ''; + if($i->rank == 1) + echo i18n('(Most Preferred)'); + if($i->rank == $count) + echo i18n('(Least Preferred)'); + } + echo '
'; + + send_popup_footer(); + exit; + } + + send_header("Tour Assignments", + array('Committee Main' => 'committee_main.php', + 'Administration' => 'admin/index.php', + 'Tours' => 'admin/tours.php') + ); +?> + + +0) { + // make sure the tour is valid + if(!array_key_exists($tours_id, $tours)) { + /* Someone is hacking the POST */ + echo "HALT: Tour list changed between the form and the POST."; + exit; + } + + $added=0; + foreach($student_list AS $sid) { + /* Make sure the student exists */ + $sid = intval($sid); + + $q = mysql_query("SELECT registrations_id FROM students + WHERE id='$sid'"); + $i = mysql_fetch_object($q); + $rid = $i->registrations_id; + + /* Delete any old linking */ + mysql_query("DELETE FROM tours_choice WHERE + students_id='$sid' AND + year='{$config['FAIRYEAR']}' AND + rank='0'"); + /* Connect this student to this tour */ + mysql_query("INSERT INTO tours_choice + (`students_id`,`registrations_id`, + `tour_id`,`year`,`rank`) + VALUES ( + '$sid', '$rid', '$tours_id', + '{$config['FAIRYEAR']}','0')"); + $added++; + } + if($added==1) $j=i18n("student"); + else $j=i18n("students"); + + echo happy(i18n("%1 %2 added to tour #%3 (%4)",array( + $added,$j,$tours_id,$tours[$tours_id]['name']))); + } + + $tours_id = intval($_GET['tours_id']); + $students_id = intval($_GET['students_id']); + + if($_GET['action']=='del' && $tours_id>0 && $students_id>0) { + mysql_query("DELETE FROM tours_choice + WHERE students_id='$students_id' + AND year='{$config['FAIRYEAR']}' + AND rank='0'"); + + echo happy(i18n("Removed student from tour #%1 (%2)",array($tours_id,$tours[$tours_id]['name']))); + + } + + if($_GET['action']=="empty" && $tours_id>0) + { + mysql_query("DELETE FROM tours_choice WHERE + tour_id='$tours_id' + AND year='{$config['FAIRYEAR']}' + AND rank='0'"); + echo happy(i18n("Emptied all students from tour #%1 (%2)",array($tours_id,$tours[$tours_id]['name']))); + } + + + if(!$_SESSION['viewstate']['students_teams_list_show']) + $_SESSION['viewstate']['students_teams_list_show']='unassigned'; + //now update the students_teams_list_show viewstate + if($_GET['students_teams_list_show']) + $_SESSION['viewstate']['students_teams_list_show']=$_GET['students_teams_list_show']; + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
".i18n("Student List"); + echo "
"; + echo ""; + echo "
".i18n("Tours")."
"; + + /* Load students with the current tour selections + * (rank=0), or if there is no selection, make + * rank NULL, and tours_id NULL */ + $querystr="SELECT students.firstname, students.lastname, + students.id, + tours_choice.tour_id, tours_choice.rank + FROM + students + LEFT JOIN tours_choice ON (tours_choice.students_id=students.id AND tours_choice.rank=0) + LEFT JOIN registrations ON registrations.id=students.registrations_id + WHERE + students.year='{$config['FAIRYEAR']}' AND + (tours_choice.year='{$config['FAIRYEAR']}' OR + tours_choice.year IS NULL) AND + registrations.status='complete' + ORDER BY + students.lastname, + students.firstname, + tours_choice.rank"; + + $q=mysql_query($querystr); + + echo mysql_error(); + + $student = array(); + $last_student_id = -1; + while($r=mysql_fetch_object($q)) + { + $id = $r->id; + $tours_id = $r->tour_id; + $rank = $r->rank; + + if($id != $last_student_id) { + $last_student_id = $id; + + $student[$id]['name'] = $r->firstname.' '.$r->lastname; + } + if($tours_id != NULL) { + $tours[$tours_id]['students'][] = $id; + $student[$id]['tours_id'] = $tours_id; + } + } + +//rint_r($student); + echo ""; + echo ""; + + echo ""; + foreach($tours as $tid=>$t) { + echo ''; + $x = 0; + if(is_array($t['students']) ) { + foreach($t['students'] AS $sid) { + $s = $student[$sid]; + if($x == 0) echo ''; + echo '"; + if($x==2) { + echo ''; + $x = 0; + } else + $x++; + } + if($x != 0) echo ''; + echo ""; + } + else + { + echo ""; + } + + } + + echo "

'; + + echo ""; + echo " #{$t['num']}: {$t['name']} "; + echo '
'; + echo ""; + echo ' '; + echo ""; + echo "{$s['name']}"; + echo "
"; + echo ""; + echo " ".i18n("Empty All Members")." "; + echo ""; + echo ""; + echo "
"; + echo error(i18n("Tour has no members"),"inline"); + echo "
"; + + echo "
"; + + echo "
"; + echo "
"; + + send_footer(); + +?> diff --git a/admin/tours_manager.php b/admin/tours_manager.php index e07490e..086bdf8 100644 --- a/admin/tours_manager.php +++ b/admin/tours_manager.php @@ -30,7 +30,8 @@ send_header("Tour Management", array('Committee Main' => 'committee_main.php', - 'Administration' => 'admin/index.php') + 'Administration' => 'admin/index.php', + 'Tours' => 'admin/tours.php') ); ?>