Files
HotLunches/multi-menu.supplier_orders.php
2026-10-19 15:22:52 -07:00

239 lines
7.8 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = "";
$headerArgs = "";
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team');
if (checkPermission($AllowedUserTypes) != 1) {
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
$action = '';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
$sdate = date("Y-m-d",time() + 60 * 60 * 24 * 20);
$ldate = date("Y-m-d",time() - 60 * 60 * 24 * 300);
$today = date("Y-m-d",time());
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
$ldate = '1969-01-01';
}
// Get set of schedules
$query = "SELECT hls.* " .
"FROM hotlunch_schedules AS hls,schools as s " .
"WHERE hls.school_num = $school_num " .
"AND hls.status IN ('Active','Pending','Closed','Completed') " .
"AND hls.school_num = s.record_num " .
"ORDER BY link_sequence,$scheduleSortOrder";
$schedules = db_query($query);
if (db_num_rows($schedules) == 0) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULES');
include "form.messages.php";
echo("<p>$query</p>\n");
return;
}
echo("<!-- NUM SCHEDULES: " . db_num_rows($schedules) . " -->\n");
$select_size = 10;
$templatePageTitle = getLanguageText('TEXT-MULTI-MENU-SUPPLIER-ORDERS');
$school_num = $school_record['record_num'];
include "form.messages.php";
//
// Display the menu selection
//
?>
<form method='post' action='/'>
<table width='90%' class='content-table'>
<tr class='heading'>
<td colspan='2' align='center'><?php displayLanguageText('TEXT-MULTI-MENU-SUPPLIER-ORDERS'); ?></td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='600' class='content-table'>
<tr class='heading'>
<td align='center'><?php displayLanguageText('TEXT-SELECTED-MENU-DATES'); ?></td>
</tr>
<tr>
<td align='center'>
<select name='selected_menus[]' multiple size='<?php echo($select_size) ?>' class='select-width500'>
<?php
// Process each schedule and list the menu dates
$today = date("Y-m-d",time());
$next_menu_date = "3000-01-01";
while ($schedule = db_fetch_array($schedules)) {
$schedule_num = $schedule['record_num'];
$schedule_name = $schedule['schedule_name'];
$query = "select * from hotlunch_menu_dates " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and menu_date >= '$ldate' " .
"order by $menuSortOrder,menu_date";
$results = db_query($query);
if (db_num_rows($results)) {
echo(" <optgroup label='$schedule_name'>\n");
while ($row = db_fetch_array($results)) {
$mtitle = $row['menu_title'];
$menu_date = $row['menu_date'];
$mdate = date("F jS, Y",strtotime($menu_date));
$record_num = $row['record_num'];
$mtitle .= " - $mdate";
echo(" <option value='$record_num'>$mtitle</option>\n");
if ($menu_date < $next_menu_date && $menu_date > $today) $next_menu_date = $menu_date;
}
echo(" </optgroup>\n");
}
}
?>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='600' class='content-table'>
<tr class='heading'>
<td align='center'><?php displayLanguageText('TEXT-SUPPLIERS'); ?></td>
</tr>
<tr>
<td align='center'>
<select name='supplier_num'>
<option value=''>All Suppliers</option>
<?php
$query = "select supplier_name,record_num from suppliers where school_num = $supplier_school_num AND status = 'Active' order by supplier_name";
$results = db_query($query);
while ($row = db_fetch_array($results)) {
echo(" <option value='$row[record_num]'>$row[supplier_name]</option>\n");
}
?>
</select>
</td>
</tr>
</table>
<br>
</td>
</tr>
<?php if ($_SESSION['UserInfo']['type'] == 'SuperUser') { ?>
<tr>
<td colspan='2' align='center'>
<br>
<table width='600' class='content-table'>
<tr class='heading'>
<td align='center'><?php displayLanguageText('TEXT-CLASSES'); ?></td>
</tr>
<tr>
<td align='center'>
<?php
$classes = db_query("SELECT * FROM classes WHERE school_num = $school_num AND entry_type = 'Class' ORDER BY sequence");
$nclasses = db_num_rows($classes);
?>
<select name='selected_classes[]' multiple size='<?php echo($nclasses) ?>' class='select-width400'>
<?php
while ($row = db_fetch_array($classes)) {
$cnum = $row['record_num'];
$class_info = getClassInfo($cnum);
echo(" <option value='$cnum' selected='selected'>$class_info</option>\n");
}
?>
</select>
</td>
</tr>
</table>
<br>
</td>
</tr>
<?php } ?>
</table>
<br>
<input type='hidden' name='action' value='supplier-orders-print'>
<input type='submit' name='button' class='btn btn--primary' value='Print Orders'>
</form>
<br>
<form method='post' action='/'>
<table width='90%' class='content-table'>
<tr class='heading'>
<td colspan='2' align='center'><?php displayLanguageText('TEXT-MULTI-MENU-SUPPLIER-ORDERS'); ?></td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='600' class='content-table'>
<tr class='heading'>
<td align='center'><?php displayLanguageText('TEXT-MENU-DATE'); ?></td>
</tr>
<tr>
<td align='center'>
<input type='text' name='selected_menu_date' id='selected_menu_date' class='date-field' value='<?php echo($next_menu_date) ?>'>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='600' class='content-table'>
<tr class='heading'>
<td align='center'><?php displayLanguageText('TEXT-SUPPLIERS'); ?></td>
</tr>
<tr>
<td align='center'>
<select name='supplier_num'>
<option value=''>All Suppliers</option>
<?php
$query = "select supplier_name,record_num from suppliers where school_num = $supplier_school_num AND status = 'Active' order by supplier_name";
$results = db_query($query);
while ($row = db_fetch_array($results)) {
echo(" <option value='$row[record_num]'>$row[supplier_name]</option>\n");
}
?>
</select>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
<br>
<input type='hidden' name='action' value='supplier-orders-print'>
<input type='submit' name='button' class='btn btn--primary' value='Print Orders'>
</form>
<br>
<?php
endTemplate();
?>