230 lines
8.8 KiB
PHP
230 lines
8.8 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
include "hotlunch_reports.menu.php";
|
|
}
|
|
|
|
|
|
|
|
// Get schedule information
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $schedule_num";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid lunch schedule id";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$schedule_record = db_fetch_array($results);
|
|
$schedule_name = $schedule_record['schedule_name'];
|
|
|
|
|
|
// 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) {
|
|
echo("<br>\n");
|
|
$error_message = "You are not allowed access to the requested hot lunch schedule";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<br>
|
|
<form method='post' action='/' name='orderform'>
|
|
<?php
|
|
|
|
$form_width = '90%';
|
|
$message_width = $form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($form_width) ?>' class='content-table'>
|
|
<tr>
|
|
<td align='center' class='heading'><?php displayLanguageText('TEXT-MENU-PRICE-UPDATE'); ?> - <?php echo($schedule_name) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<table width='820' cellpadding='1' cellspacing='1' border='0'>
|
|
<?php
|
|
// Get menu dates for this schedule
|
|
$query = "select * from hotlunch_menu_dates " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"order by sequence,menu_date";
|
|
$menu_dates = db_query($query);
|
|
|
|
while ($menu_date = db_fetch_array($menu_dates)) {
|
|
$menu_num = $menu_date['record_num'];
|
|
$menu_title = $menu_date['menu_title'];
|
|
$menu_link = $menu_date['menu_link'];
|
|
|
|
if ($menu_link != 'No') $menu_title .= " - Linked Menu: $menu_link";
|
|
|
|
// Get menu items for this menu date
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7' class='success'>
|
|
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
|
|
<tr>
|
|
<td align='left' class='success'><b><?php echo($menu_title) ?></td>
|
|
<td align='right' class='success'><?php echo(date("l F jS, Y",strtotime($menu_date['menu_date']))) ?></b></td>
|
|
</tr>
|
|
</td>
|
|
</table>
|
|
</tr>
|
|
<?php
|
|
if (db_num_rows($menu_items) > 0) {
|
|
?>
|
|
<tr>
|
|
<td align='left' width='380' class='oitem'><b><?php displayLanguageText('TEXT-ITEM'); ?></b></td>
|
|
<td width='80' align='right' class='oitem'><b><?php displayLanguageText('TEXT-ON-LINE'); ?></b></td>
|
|
<td width='80' align='right' class='oitem'><b><?php displayLanguageText('TEXT-PAPER'); ?></b></td>
|
|
<td width='80' align='right' class='oitem'><b><?php echo($Special1_Title) ?></b></td>
|
|
<td width='80' align='right' class='oitem'><b><?php echo($Special2_Title) ?></b></td>
|
|
<td width='80' align='right' class='oitem'><b><?php echo($Special3_Title) ?></b></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
|
|
while ($menu_item = db_fetch_array($menu_items)) {
|
|
extract($menu_item);
|
|
|
|
$menu_item_num = $record_num;
|
|
|
|
if ($item_type != 'Heading') {
|
|
$num_products = db_getVal("select count(*) from hotlunch_menu_products where school_num = $school_num and menu_item_num = $menu_item_num");
|
|
$item_cost = 0;
|
|
$item_cost = db_getVal("select sum((package_cost / package_qty) * supplier_product_qty) " .
|
|
"from hotlunch_menu_products,supplier_products " .
|
|
"where hotlunch_menu_products.school_num = $school_num " .
|
|
"and supplier_products.school_num = $supplier_school_num " .
|
|
"and menu_item_num = $menu_item_num " .
|
|
"and supplier_product_num = supplier_products.record_num");
|
|
|
|
// Setup field names
|
|
$field1 = "price1_$menu_item_num";
|
|
$field2 = "price2_$menu_item_num";
|
|
$field3 = "price3_$menu_item_num";
|
|
|
|
$fpm1 = " fname='special_price1' item_num='$menu_item_num' size='5' style='text-align: right; float: right;' class='special-price-field'";
|
|
$fpm2 = " fname='special_price2' item_num='$menu_item_num' size='5' style='text-align: right; float: right;' class='special-price-field'";
|
|
$fpm3 = " fname='special_price3' item_num='$menu_item_num' size='5' style='text-align: right; float: right;' class='special-price-field'";
|
|
|
|
?>
|
|
<tr>
|
|
<td align='left' class='oitem'><?php echo($item_title) ?> ::</td>
|
|
<?php if ($menu_link == 'No') { ?>
|
|
<td align='right' class='oitem'><?php echo($currencySymbol . number_format($online_price,2)) ?></td>
|
|
<td align='right' class='oitem'><?php echo($currencySymbol . number_format($offline_price,2)) ?></td>
|
|
<td align='right' class='oitem'><input type='text' name='<?php echo($field1) ?>' id='<?php echo($field1) ?>' value='<?php echo($currencySymbol . number_format($special_price1,2)) ?>'<?php echo($fpm1) ?>></td>
|
|
<td align='right' class='oitem'><input type='text' name='<?php echo($field2) ?>' id='<?php echo($field2) ?>' value='<?php echo($currencySymbol . number_format($special_price2,2)) ?>'<?php echo($fpm2) ?>></td>
|
|
<td align='right' class='oitem'><input type='text' name='<?php echo($field3) ?>' id='<?php echo($field3) ?>' value='<?php echo($currencySymbol . number_format($special_price3,2)) ?>'<?php echo($fpm3) ?>></td>
|
|
<?php } else { ?>
|
|
<td align='right' class='oitem'><?php echo(number_format($online_price,2)) ?></td>
|
|
<td align='right' class='oitem'><?php echo(number_format($offline_price,2)) ?></td>
|
|
<td align='right' class='oitem'><?php echo($currencySymbol) ?><span id='special_price1_<?php echo($menu_item_num) ?>'><?php echo(number_format($special_price1,2)) ?></span></td>
|
|
<td align='right' class='oitem'><?php echo($currencySymbol) ?><span id='special_price2_<?php echo($menu_item_num) ?>'><?php echo(number_format($special_price2,2)) ?></span></td>
|
|
<td align='right' class='oitem'><?php echo($currencySymbol) ?><span id='special_price3_<?php echo($menu_item_num) ?>'><?php echo(number_format($special_price3,2)) ?></span></td>
|
|
<?php } ?>
|
|
</tr>
|
|
<?php
|
|
}
|
|
else {
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7' class='menudate-subheader'><b> -- <?php echo($item_title) ?> -- </b></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
?>
|
|
<tr>
|
|
<td align='left' colspan='7'> </td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<input type='submit' id='refresh-screen' class='btn btn--primary' value="<?php displayLanguageText('TEXT-REFRESH-DATA'); ?>">
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
<?php include "hotlunch_orders.print_buttons.php"; ?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$(document).on('change', '.special-price-field', function() {
|
|
var item_num = $(this).attr('item_num');
|
|
var fname = $(this).attr('fname');
|
|
var price = $(this).val();
|
|
var fID = $(this).attr('id');
|
|
|
|
$.ajax({
|
|
url: 'ajax.UpdateDBField.php',
|
|
data: {
|
|
table_name: 'hotlunch_menu_items',
|
|
field_name: fname,
|
|
field_value: price,
|
|
field_type: 'decimal',
|
|
record_num: item_num
|
|
},
|
|
dataType: 'json'
|
|
}).done(function(results) {
|
|
var new_value = '<?php echo($currencySymbol) ?>'+results.new_value;
|
|
$('#'+fID).val(new_value);
|
|
if (results.linked.length > 0) {
|
|
$.each(results.linked, function(key, entry) {
|
|
var linkedField = fname+'_'+entry;
|
|
$("#"+linkedField).html(new_value);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#refresh-screen").click(function(e) {
|
|
e.preventDefault();
|
|
location.reload();
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|