108 lines
4.1 KiB
PHP
108 lines
4.1 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only valid user types access this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Get set of locations
|
|
$locations = array();
|
|
$r = db_query("SELECT * FROM classes WHERE school_num = $base_school_num ORDER BY entry_type,sequence");
|
|
while ($row = db_fetch_assoc($r)) {
|
|
$entry_type == $row['entry_type'];
|
|
if ($entry_type == 'Class') $row['class_info'] = getClassInfo($row['record_num']);
|
|
else $row['class_info'] = $row['description'];
|
|
$locations[] = $row;
|
|
}
|
|
|
|
if (count($locations) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-LOCATIONS-FOUND');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND entry_type = 'Class'");
|
|
$numLocations = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND entry_type = 'Location'");
|
|
|
|
|
|
?>
|
|
<p><b><?php echo($title) ?></b></p>
|
|
<p><b>Editing <?php echo($num) ?> Entries</b></p>
|
|
<form method='post' action='/'>
|
|
<table width='900' id='data-table' class='content-table'>
|
|
<tr>
|
|
<td align='left' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-NAME'); ?></b></td>
|
|
<td align='center' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-ALTERNATE-LOCATION'); ?></b></td>
|
|
</tr>
|
|
<?php
|
|
$count = 0;
|
|
while ($row = db_fetch_array($results)) {
|
|
$rnum = $row['record_num'];
|
|
$name = $row['first_name'] . ' ' . $row['last_name'];
|
|
|
|
$bgclass = 'data-even';
|
|
if ($count % 2) $bgclass = 'data-odd';
|
|
$count++;
|
|
|
|
$class_num = intval($row['class_num']);
|
|
$meal_location = intval($row['meal_location']);
|
|
if ($meal_location == 0) $meal_location = $class_num;
|
|
|
|
if ($meal_location != $class_num) $bgclass = "warning";
|
|
?>
|
|
<tr>
|
|
<td class='<?php echo($bgclass) ?>' align='left'><?php echo($name) ?></td>
|
|
<td class='<?php echo($bgclass) ?>' align='center'>
|
|
<select name='meal_location_<?php echo($rnum) ?>' class='class-select'>
|
|
<?php
|
|
$prev_type = "";
|
|
for ($i = 0; $i < count($locations); $i++) {
|
|
$lrow = $locations[$i];
|
|
$entry_type = $lrow['entry_type'];
|
|
if ($numClasses > 0 && $numLocations > 0) {
|
|
if ($entry_type != $prev_type) {
|
|
if (strlen($prev_type)) echo(" </optgroup>\n");
|
|
if ($entry_type == 'Class') $t = $GlobalText['Classes'];
|
|
if ($entry_type == 'Location') $t = getLanguageText('TEXT-ALTERNATE-LOCATIONS');
|
|
echo(" <optgroup label='$t'>\n");
|
|
$prev_type = $entry_type;
|
|
}
|
|
}
|
|
|
|
$v = $lrow['record_num'];
|
|
if ($entry_type == 'Class') $l = getClassInfo($v);
|
|
else $l = $lrow['description'];
|
|
$selected = "";
|
|
if ($v == $meal_location) $selected = " selected='selected'";
|
|
echo(" <option value='$v'$selected>$l</option>\n");
|
|
}
|
|
if ($numClasses > 0 && $numLocations > 0) echo(" </optgroup>\n");
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value='Update Students'>
|
|
<input type='hidden' name='action' value='students'>
|
|
<input type='hidden' name='naction' value='update-meal-locations'>
|
|
</form>
|
|
<?php if ($school_record['implement_meal_locations'] == 'Y') { ?>
|
|
<?php $msg = getLanguageText('TEXT-CONFIRM-UPDATE'); ?>
|
|
<br>
|
|
<p><a href='?action=students&naction=reset-meal-locations' onClick='return confirm("<?php echo($msg) ?>")' class='btn btn--primary>'><?php displayLanguageText('TEXT-RESET-LOCATIONS'); ?></a></p>
|
|
<?php } ?>
|