127 lines
3.4 KiB
PHP
127 lines
3.4 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
|
|
require_once("include/globals.php");
|
|
include "hotlunch.orderform.php";
|
|
|
|
// startLog("hlform.php");
|
|
writeLog("School Num: $school_num");
|
|
|
|
$schedule_num = 70184;
|
|
$schedule_num = 70182;
|
|
$schedule_num = 70185;
|
|
|
|
startTemplate();
|
|
|
|
buildOrderForm($schedule_num, 'On-Line', 0, 0);
|
|
echo($CurrentScheduleRecord['schedule_name']."\n");
|
|
|
|
?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$('.menu-div-active-N').each(function() {
|
|
$(this).hide();
|
|
});
|
|
|
|
$('.menu-title-table').click(function() {
|
|
var menu_num = $(this).attr('menu_num');
|
|
var menu_div = '#menu-div-'+menu_num;
|
|
var visibility = $(this).attr('visible');
|
|
|
|
if (visibility == 'N') {
|
|
$(menu_div).show();
|
|
$(this).attr('visible','Y');
|
|
}
|
|
else {
|
|
$(menu_div).hide();
|
|
$(this).attr('visible','N');
|
|
}
|
|
});
|
|
|
|
$(document).on('click touch', '.item-qty-increase', function(e) {
|
|
e.preventDefault();
|
|
|
|
var item_num = $(this).attr('menu_item');
|
|
var item_qty = $("#qty-"+item_num).val();
|
|
|
|
if (item_qty == '') item_qty = 0;
|
|
item_qty = Math.abs(item_qty) + 1;
|
|
|
|
$("#qty-"+item_num).val(item_qty);
|
|
calcLinePrice(item_num);
|
|
});
|
|
|
|
$(document).on('click touch', '.item-qty-decrease', function(e) {
|
|
e.preventDefault();
|
|
|
|
var item_num = $(this).attr('menu_item');
|
|
var item_qty = $("#qty-"+item_num).val();
|
|
|
|
if (item_qty == '') return;
|
|
if (item_qty == 0) return;
|
|
|
|
item_qty = Math.abs(item_qty) - 1;
|
|
|
|
if (item_qty == 0) $("#qty-"+item_num).val('');
|
|
else $("#qty-"+item_num).val(item_qty);
|
|
|
|
calcLinePrice(item_num);
|
|
});
|
|
|
|
$(document).on('change', '.item-qty', function() {
|
|
var item_num = $(this).attr('menu_item');
|
|
calcLinePrice(item_num);
|
|
});
|
|
|
|
$(document).on('change', '.alternate-prices', function() {
|
|
var item_num = $(this).attr('menu_item');
|
|
calcLinePrice(item_num);
|
|
});
|
|
|
|
function calcLinePrice(item_num) {
|
|
|
|
var qtyfield = "#qty-"+item_num;
|
|
var pricefield = "#price-"+item_num;
|
|
var altprice = "#alt_prices_"+item_num;
|
|
var extendedprice = "#extended-price-"+item_num;
|
|
|
|
var qty = $(qtyfield).val();
|
|
var price = $(pricefield).val();
|
|
var alt_flag = $(pricefield).attr('alt-prices');
|
|
var sign = Math.sign(price);
|
|
|
|
if (alt_flag == 'Y') price = $(altprice).val();
|
|
|
|
if (Math.abs(qty) == 0) $(qtyfield).val('');
|
|
|
|
var eprice = Math.abs(qty) * Math.abs(price) * sign;
|
|
$(extendedprice).html(formatCurrency(eprice));
|
|
}
|
|
|
|
function formatCurrency(num) {
|
|
num = num.toString().replace(/\$|\,/g,'');
|
|
if(isNaN(num)) num = "0";
|
|
sign = (num == (num = Math.abs(num)));
|
|
num = Math.floor(num*100+0.50000000001);
|
|
cents = num%100;
|
|
num = Math.floor(num/100).toString();
|
|
if(cents<10) cents = "0" + cents;
|
|
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
|
|
num = num.substring(0,num.length-(4*i+3))+','+
|
|
num.substring(num.length-(4*i+3));
|
|
if (num == 0 && cents == '00') return('');
|
|
return (((sign)?'':'-') + '$' + num + '.' + cents);
|
|
}
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|