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. */ ?> prepare($query); $r->execute(); $tours = array(); while($i = $r->fetch(PDO::FETCH_OBJ)) { $tours[$i->id]['name'] = $i->name; $tours[$i->id]['num'] = $i->num; } if($_GET['action']=='info') { $sid = intval($_GET['id']); $query="SELECT * FROM students WHERE id='$sid' AND year='{$config['FAIRYEAR']}'"; $r = $pdo->prepare($query); $r->execute(); $i = $r->fetch(PDO::FETCH_OBJ); 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 = $pdo->prepare($query); $r->execute(); echo ''; $count = $r->rowwCount(); while($i = $r->fetch(PDO::FETCH_OBJ)) { 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 = $pdo->prepare("SELECT registrations_id FROM students WHERE id='$sid'"); $q->execute(); $i = $q->fetch(PDO::FETCH_OBJ); $rid = $i->registrations_id; /* Delete any old linking */ $stmt = $pdo->prepare("DELETE FROM tours_choice WHERE students_id='$sid' AND year='{$config['FAIRYEAR']}' AND rank='0'"); $stmt->execute(); /* Connect this student to this tour */ $stmt = $pdo->prepare("INSERT INTO tours_choice (`students_id`,`registrations_id`, `tour_id`,`year`,`rank`) VALUES ( '$sid', '$rid', '$tours_id', '{$config['FAIRYEAR']}','0')"); $stmt->execute(); $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[$tours_id]['num'],$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) { $stmt = $pdo->prepare("DELETE FROM tours_choice WHERE students_id='$students_id' AND year='{$config['FAIRYEAR']}' AND rank='0'"); $stmt->execute(); echo happy(i18n("Removed student from tour #%1 (%2)",array($tours[$tours_id]['num'],$tours[$tours_id]['name']))); } if($_GET['action']=="empty" && $tours_id>0) { $stmt=$po->prepare("DELETE FROM tours_choice WHERE tour_id='$tours_id' AND year='{$config['FAIRYEAR']}' AND rank='0'"); $stmt->execute(); echo happy(i18n("Emptied all students from tour #%1 (%2)",array($tours[$tours_id]['num'],$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=$pdo->prepare($querystr); $q->execute(); echo $pdo->errorInfo(); $student = array(); $last_student_id = -1; while($r=$q->fetch(PDO::FETCH_OBJ)) { $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(); ?>