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

204 lines
6.7 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-MULTI-MENU-SUPPLIER-PRODUCT-CSV');
$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);
$today = date("Y-m-d",time());
// 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') " .
"AND hls.school_num = s.record_num " .
"ORDER BY link_sequence,$scheduleSortOrder";
$schedules = db_query($query);
if (db_num_rows($schedules) == 0) {
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE');
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
$select_size = 10;
echo("<br>\n");
$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-PRODUCT-CSV'); ?></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 " .
"order by sequence,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' selected='selected'>$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>
</table>
<br>
<input type='hidden' name='action' value='multi-menu-supplier-csv-generate'>
<input type='hidden' name='format' value='order'>
<input type='submit' name='button' class='btn btn--primary' value="<?php displayLanguageText('BUTTON-GENERATE-CSV'); ?>">
</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-PRODUCT-CSV'); ?></td>
</tr>
<tr>
<td colspan='2' align='center'>
<br>
<table width='300' class='content-table'>
<tr>
<td align='left'>
<b><?php displayLanguageText('TEXT-MENU-DATE'); ?>:</b><br>
<input type='text' name='selected_menu_date' id='selected_menu_date' class='date-field' value='<?php echo($next_menu_date) ?>'>
</td>
</tr>
<tr>
<td align='left'>
<b><?php displayLanguageText('TEXT-SUPPLIERS'); ?>:</b><br>
<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>
<tr>
<td align='left'>
<b><?php displayLanguageText('TEXT-DOCUMENT-FORMAT'); ?>:</b><br>
<?php BuildFileRadio("multi-menu.supplier.csv.format.txt","format","order") ?>
</td>
</tr>
<tr>
<td align='left'>
<b><?php echo($GlobalText['Staff']); ?>:</b><br>
<?php BuildFileRadio("staff.included.txt","staff","included") ?>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
<br>
<input type='hidden' name='action' value='multi-menu-supplier-csv-generate'>
<input type='submit' name='button' class='btn btn--primary' value="<?php displayLanguageText('BUTTON-GENERATE-CSV'); ?>">
</form>
<br>
<?php
endTemplate();
?>