Files
HotLunches/hotlunch_orders.select.php
T
2026-10-19 15:22:52 -07:00

170 lines
6.9 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
$form_width = '80%';
$message_width = $form_width;
include "form.messages.php";
?>
<br>
<table width='<?php echo($form_width) ?>' class='content-table'>
<tr>
<td align='center' class='heading'><?php displayLanguageText('TEXT-SELECT-PERSON-TO-VIEW-ORDERS'); ?></td>
</tr>
<form method='post'>
<tr>
<td align='center'>
<br>
<table>
<tr>
<td align='left'>
<?php displayLanguageText('TEXT-ORDERED-BY'); ?><br>
<select name='ordered_by_view' class='select-width600'>
<option value=''><?php displayLanguageText('TEXT-SELECT-PERSON'); ?></option>
<option value='Concession'><?php displayLanguageText('TEXT-CONCESSION-ORDER'); ?></option>
<?php
// Get list of students with orders
$curr_school_num = $school_record['record_num'];
$query = "select st.first_name,st.last_name,st.record_num,division,grade,class_program,classes.record_num as class_num,source,hloh.status " .
"from people as st,classes,hotlunch_order_header as hloh " .
"where st.school_num = $base_school_num " .
"and st.people_type NOT IN ('Staff') " .
"and st.class_num = classes.record_num " .
"and st.record_num = hloh.ordered_by_num " .
"and hloh.school_num = $curr_school_num " .
"and hloh.schedule_num = $schedule_num " .
"order by st.last_name,st.first_name";
$results = db_query($query);
if (db_num_rows($results)) {
echo(" <optgroup label='" . $GlobalText['Student'] . "'>\n");
while ($row = db_fetch_array($results)) {
$snum = $row['record_num'];
$class_num = $row['class_num'];
$source = $row['source'];
$status = $row['status'];
$name = "$row[last_name], $row[first_name]";
$class_info = getClassInfo($class_num);
echo(" <option value='Student.$snum'>$name &nbsp;&nbsp;&nbsp;($class_info - $status)</option>\n");
}
echo(" </optgroup>\n");
}
// Get list of staff with orders
$query = "select first_name,last_name,people.record_num,class_num,hloh.status " .
"from people,staff_categories,hotlunch_order_header as hloh " .
"where people.school_num = $base_school_num " .
"and hloh.school_num = $curr_school_num " .
"and staff_categories.school_num = $curr_school_num " .
"and people.people_type = 'Staff' " .
"and people.record_num = hloh.ordered_by_num " .
"and people.staff_category = staff_categories.record_num " .
"and hloh.schedule_num = $schedule_num " .
"order by last_name,first_name";
$results = db_query($query);
if (db_num_rows($results)) {
echo(" <optgroup label='" . $GlobalText['Staff'] . "'>\n");
while ($row = db_fetch_array($results)) {
$snum = $row['record_num'];
$name = "$row[last_name], $row[first_name]";
if (array_key_exists('category_title', $row)) $name .= " - $row[category_title]";
$status = $row['status'];
$info = "";
if (array_key_exists('category_title', $row) && strlen($row['category_title']) > 0) $info .= $row['category_title'];
if (array_key_exists('grade', $row) && $school_record['i_display_grade'] && strlen($row['grade']) > 0) $info .= " - Gr. $row[grade]";
if (array_key_exists('division', $row) && $school_record['i_display_division'] == 'Y' && $row['division'] > 0) $info .= " $school_record[division_class_num_text]: $row[division]";
if (array_key_exists('description', $row) && $school_record['i_display_description'] == 'Y' && strlen($row['description']) > 0) $info .= " $row[description]";
if (strlen($info)) $info .= " - ";
$info .= $status;
echo(" <option value='Staff.$snum'>$name &nbsp;&nbsp;&nbsp;($info)</option>\n");
}
echo(" </optgroup>\n");
}
// Get list of customers with orders
$query = "select first_name,last_name,people.record_num,class_num,hloh.status " .
"from people,hotlunch_order_header as hloh " .
"where people.school_num = $base_school_num " .
"and hloh.school_num = $curr_school_num " .
"and people.record_num = hloh.ordered_by_num " .
"and people.people_type = 'Customer' " .
"and hloh.schedule_num = $schedule_num " .
"order by last_name,first_name";
$results = db_query($query);
if (db_num_rows($results)) {
echo(" <optgroup label='" . getLanguageText('TEXT-CUSTOMER') . "'>\n");
while ($row = db_fetch_array($results)) {
$snum = $row['record_num'];
$name = "$row[last_name], $row[first_name]";
$status = $row['status'];
echo(" <option value='Staff.$snum'>$name &nbsp;&nbsp;&nbsp;($status)</option>\n");
}
echo(" </optgroup>\n");
}
?>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align='center'><input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-VIEW-SELECTED'); ?>"></td>
</tr>
<input type='hidden' name='action' value='orders'>
<input type='hidden' name='naction' value='view'>
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
</form>
</table>
<br>
<table width='<?php echo($form_width) ?>' class='content-table'>
<tr>
<td colspan='2' align='center' class='heading'><?php displayLanguageText('TEXT-ORDERS-BY-DATE'); ?></td>
</tr>
<tr>
<td colspan='2'>&nbsp;</td>
</tr>
<form method='post'>
<tr>
<td width='45%' align='right'><?php displayLanguageText('TEXT-START-DATE'); ?>: </td>
<td align='left'><input type='text' name='selected_date' value='<?php echo(date("Y-m-d",time())) ?>' size='15' class='date-field'></td>
</tr>
<tr>
<td width='45%' align='right'><?php displayLanguageText('TEXT-END-DATE'); ?>: </td>
<td align='left'><input type='text' name='selected_end_date' value='<?php echo(date("Y-m-d",time())) ?>' size='15' class='date-field'></td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-VIEW-SELECTED'); ?>">
</td>
</tr>
<input type='hidden' name='action' value='orders'>
<input type='hidden' name='naction' value='view'>
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
</form>
</table>
<br>