diff --git a/register_participants_tours.php b/register_participants_tours.php index 72f9b74..dbe9967 100644 --- a/register_participants_tours.php +++ b/register_participants_tours.php @@ -80,9 +80,19 @@ echo mysql_error(); { foreach($_POST['toursel'] AS $students_id=>$ts) { + $selarray = array(); + foreach($ts AS $rank=>$tid) { if($tid == -1) continue; + $x = intval($tid); + + /* If this choice has already been selected, don't record it */ + if(in_array($x, $selarray)) continue; + + /* Remember this choice in a format that is easily searchable */ + $selarray[] = $x; + mysql_query("INSERT INTO tours_choice (registrations_id,students_id,tour_id,year,rank) VALUES (". "'".$_SESSION['registration_id']."', ". "'".intval($students_id)."', ". @@ -151,27 +161,22 @@ else if($newstatus=="complete") $min = $config['tours_choices_min']; $max = $config['tours_choices_max']; -/* - if($min == $max) { - $t = i18n("Please select %1 tour(s)", array($min)); - } else if($min == 1) { - $t = i18n("Please select up to %1 tours", array($max)); - } else { - $t = i18n("Please select between %1 and %2 tours", array($min, $max)); - } - echo $t." "; - echo i18n("by placing a number from 1 (highest preference) to %1 (lowest preference) beside the tours you select", array($config['tours_choices_max']) ); -*/ - echo "
\n"; echo "\n"; - echo "\n"; $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); $num_found = mysql_num_rows($q); while($r=mysql_fetch_object($q)) { + if($r->grade <= 0) { + echo error(i18n("You must select your grade on the Student Information page before selecting tours")); + echo i18n("Go to the"). " "; + echo i18n("Student Information"); + echo "". i18n(" page now."). "

"; + continue; + } + echo "
\n"; echo ""; @@ -186,6 +191,10 @@ else if($newstatus=="complete") echo ""; foreach($tours as $id=>$t) { $sel = ""; + + /* Don't show this tour as an option if the student is outside the grade range */ + if($r->grade < $t['grade_min'] || $r->grade > $t['grade_max']) continue; + if($tour_choice[$r->id][$rank] == $id) $sel = "selected=selected"; echo ""; @@ -195,8 +204,8 @@ else if($newstatus=="complete") echo ""; } echo ""; + echo ("
"; echo i18n("Tour Selection for")." ".$r->firstname." ".$r->lastname; echo "
 
"); } - echo (""); /* $rank = $tour_choice[$r->id]; @@ -216,8 +225,9 @@ else if($newstatus=="complete") /* Dump the tours */ foreach($tours as $id=>$t) { echo i18n("Tour Name").": ".i18n($t['name'])."
"; - echo i18n("Grade").": ".$t['grade_min']." - ".$t['grade_max'].", "; - echo i18n("Capacity").": ".$t['capacity']." ".i18n("students")."
"; + echo i18n("Grade").": ".$t['grade_min']." - ".$t['grade_max'].""; + // echo i18n(", Capacity").": ".$t['capacity']." ".i18n("students"); + echo "
"; echo i18n($t['description'])."

"; }