161 lines
9.0 KiB
PHP
161 lines
9.0 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
// header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
if (!in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Financial Team'))) {
|
|
return;
|
|
}
|
|
|
|
|
|
// Ensure that schedule_num is set
|
|
if (!isset($schedule_num)) {
|
|
return;
|
|
}
|
|
|
|
// Check if this is a valid schedule
|
|
$swhere = "";
|
|
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $schedule_num $swhere";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
return;
|
|
}
|
|
|
|
|
|
// If this is a ScheduleTeam user check if they have permission to access this schedule
|
|
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
|
|
$userNum = $_SESSION['UserInfo']['record_num'];
|
|
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
|
|
|
|
if (!$access || $access == 0) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
$query = "SELECT * FROM supplier_products WHERE school_num = $supplier_school_num AND (package_qty = 0 OR package_qty IS NULL)";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$rnum = $row['record_num'];
|
|
$query = "UPDATE supplier_products SET package_qty = 1 WHERE school_num = $supplier_school_num AND record_num = $rnum";
|
|
db_query($query);
|
|
}
|
|
|
|
|
|
// Check that this schedule date has lunch dates specified
|
|
$query = "select count(*) num from hotlunch_menu_dates " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num";
|
|
$menuDates = db_getVal($query);
|
|
|
|
|
|
// Check that this schedule has lunch items specified
|
|
$query = "select count(hotlunch_menu_items.record_num) num from hotlunch_menu_items,hotlunch_menu_dates " .
|
|
"WHERE hotlunch_menu_items.school_num = $school_num " .
|
|
"AND hotlunch_menu_dates.school_num = $school_num " .
|
|
"AND hotlunch_menu_dates.record_num = hotlunch_menu_items.menu_num " .
|
|
"AND hotlunch_menu_dates.schedule_num = $schedule_num";
|
|
$menuItems = db_getVal($query);
|
|
|
|
|
|
// Check if there is concession order
|
|
$concession_num = 0;
|
|
if ($siteType != 'schoolfees' && $siteType != 'registration') {
|
|
$query = "select record_num from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and ordered_by_type = 'Concession' " .
|
|
"order by record_num asc " .
|
|
"limit 0,1";
|
|
$concession_num = db_getVal($query);
|
|
if (!isset($concession_num) || !$concession_num) {
|
|
$today = date("Y-m-d",time());
|
|
$query = "insert into hotlunch_order_header (school_num,ordered_by_num,ordered_by_type,schedule_num,added_date,status,order_total,source) " .
|
|
"values ($school_num,$school_num,'Concession',$schedule_num,'$today','Concession',0,'On-Line')";
|
|
db_query($query);
|
|
$concession_num = db_insert_id();
|
|
}
|
|
}
|
|
|
|
// echo($siteType);
|
|
|
|
?>
|
|
<?php if ($school_record['navigation_mode'] == 'Select') { ?>
|
|
<center>
|
|
<table width='90%' cellpadding='1' cellspacing='1' border='0'>
|
|
<tr>
|
|
<td align='left'>
|
|
<select name='selected_next_action' id='selected_next_action' class='navigation-select select-width200'>
|
|
<option value=''><?php displayLanguageText('TEXT-NAVIGATION-SELECTION'); ?></option>
|
|
<option value='?action=schedule-reports&schedule_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-SUMMARY-PAGE'); ?></option>
|
|
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator'))) { ?>
|
|
<option value='?action=schedules&naction=edit&next_action=summary&record_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-EDIT-SCHEDULE'); ?></option>
|
|
<?php if ($siteType == 'hotlunch') { ?>
|
|
<option value='?action=menu-dates&naction=list&schedule_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-MENUS'); ?></option>
|
|
<?php } else { ?>
|
|
<option value='?action=menu-dates&naction=list&schedule_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-MANAGE-FORM'); ?></option>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
<?php if ($menuDates > 0) { ?>
|
|
<?php if ($siteType == 'schoolfees') { ?>
|
|
<option value='?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&defaultOrder=Y'><?php displayLanguageText('TEXT-GENERATE-ORDERS'); ?></option>
|
|
<?php } ?>
|
|
<option value='?action=orders&naction=add&schedule_num=<?php echo($schedule_num) ?>&source=Paper'><?php displayLanguageText('TEXT-PAPER-ORDER'); ?></option>
|
|
<option value='?action=orders&naction=add&schedule_num=<?php echo($schedule_num) ?>&source=On-Line'><?php displayLanguageText('TEXT-ON-LINE-ORDER'); ?></option>
|
|
<?php if ($concession_num > 0) { ?>
|
|
<option value='?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&order_num=<?php echo($concession_num) ?>&ordered_by_type=Concession'><?php displayLanguageText('TEXT-CONCESSION'); ?></option>
|
|
<?php if ($school_record['cafeteria_ordering'] == 'Y') { ?>
|
|
<option value='?action=schedule-cafeteria&schedule_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-CAFETERIA'); ?></option>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team'))) { ?>
|
|
<option value='?action=orders&schedule_num=<?php echo($schedule_num) ?>'><?php displayLanguageText('TEXT-VIEW-ORDERS'); ?></option>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<center>
|
|
<?php } else { ?>
|
|
<table cellpadding='1' cellspacing='1' border='0'>
|
|
<tr>
|
|
<td align='center'><a href='?action=schedule-reports&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-SUMMARY-PAGE'); ?></a></td>
|
|
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator'))) { ?>
|
|
<td align='center'><a href='?action=schedules&naction=edit&next_action=summary&record_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-EDIT-SCHEDULE'); ?></a></td>
|
|
<?php if ($siteType == 'hotlunch') { ?>
|
|
<td align='center'><a href='?action=menu-dates&naction=list&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-MENUS'); ?></a></td>
|
|
<?php } else { ?>
|
|
<td align='center'><a href='?action=menu-dates&naction=list&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-MANAGE-FORM'); ?></a></td>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
<?php if ($menuDates > 0) { ?>
|
|
<?php if ($siteType == 'schoolfees') { ?>
|
|
<td align='center'><a href='?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&defaultOrder=Y' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-GENERATE-ORDERS'); ?></a></td>
|
|
<?php } ?>
|
|
<td align='center'><a href='?action=orders&naction=add&schedule_num=<?php echo($schedule_num) ?>&source=Paper' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-PAPER-ORDER'); ?></a></td>
|
|
<td align='center'><a href='?action=orders&naction=add&schedule_num=<?php echo($schedule_num) ?>&source=On-Line' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-ON-LINE-ORDER'); ?></a></td>
|
|
<?php if ($concession_num > 0) { ?>
|
|
<td align='center'><a href='?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&order_num=<?php echo($concession_num) ?>&ordered_by_type=Concession' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-CONCESSION'); ?></a></td>
|
|
<?php if ($school_record['cafeteria_ordering'] == 'Y') { ?>
|
|
<td align='center'><a href='?action=schedule-cafeteria&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-CAFETERIA'); ?></a></td>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team'))) { ?>
|
|
<td align='center'><a href='?action=orders&schedule_num=<?php echo($schedule_num) ?>' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-VIEW-ORDERS'); ?></a></td>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</tr>
|
|
</table>
|
|
<?php } ?>
|
|
|