3590 lines
152 KiB
PHP
3590 lines
152 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
// startLog("hotlunch_orders.form.php");
|
|
writeLog("School Num: $school_num");
|
|
|
|
|
|
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";
|
|
echo("<br>\n");
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// Setup defaults for the form
|
|
//
|
|
$form_width = '98%';
|
|
$source = "On-Line";
|
|
if (array_key_exists('source',$_GET) && strlen($_GET['source']) > 0) $source = $_GET['source'];
|
|
|
|
unset($defaultOrder);
|
|
if (array_key_exists('defaultOrder', $_GET) && strlen($_GET['defaultOrder']) > 0) $defaultOrder = $_GET['defaultOrder'];
|
|
|
|
|
|
// Get schedule information
|
|
$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) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$schedule_record = db_fetch_array($results);
|
|
|
|
$schedule_name = $schedule_record['schedule_name'];
|
|
$schedule_type = $schedule_record['schedule_type'];
|
|
$allow_multiple_orders = $schedule_record['allow_multiple_orders'];
|
|
$discount_offered = $schedule_record['discount_offered'];
|
|
$discount_type = $schedule_record['discount_type'];
|
|
$discount_order_minimum = $schedule_record['discount_order_minimum'];
|
|
$discount_expiry_date = $schedule_record['discount_expiry_date'];
|
|
$display_menu_date = $schedule_record['display_menu_date'];
|
|
$late_charge = $schedule_record['late_charge'];
|
|
$late_charge_date = $schedule_record['late_charge_date'];
|
|
$last_link_update = $schedule_record['last_link_update'];
|
|
$check_for_missed_menus = $schedule_record['check_for_missed_menus'];
|
|
$implement_order_notes = $schedule_record['implement_order_notes'];
|
|
$order_notes_message = $schedule_record['order_notes_message'];
|
|
$implement_order_notes2 = $schedule_record['implement_order_notes2'];
|
|
$order_notes_message2 = $schedule_record['order_notes_message2'];
|
|
$hide_unavailable_dates = $schedule_record['hide_unavailable_dates'];
|
|
$menu_display_mode = $schedule_record['menu_display_mode'];
|
|
$calendar_month_breaks = $schedule_record['calendar_month_breaks'];
|
|
$display_title_or_label = $schedule_record['display_title_or_label'];
|
|
$schedule_prices = $schedule_record['schedule_prices'];
|
|
|
|
if ($schedule_type == 'Date Sensitive') $display_menu_date = 'Y';
|
|
|
|
// Determine if there are any discounts defined for this schedule
|
|
$today = date("Y-m-d",time());
|
|
$numDiscounts = db_getVal("SELECT count(*) FROM hotlunch_schedules_discounts " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND (expiry_date IS NULL OR expiry_date >= '$today') " .
|
|
"ORDER BY menu_group,order_quantity");
|
|
|
|
$discountGroups = array();
|
|
if ($numDiscounts > 0) {
|
|
$results = db_query("SELECT distinct menu_group " .
|
|
"FROM hotlunch_schedules_discounts " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND (expiry_date IS NULL OR expiry_date >= '$today') " .
|
|
"ORDER BY menu_group");
|
|
while ($row = db_fetch_array($results)) {
|
|
$discountGroups[$row['menu_group']] = TRUE;
|
|
}
|
|
}
|
|
|
|
|
|
// Check if order has already been paid for
|
|
$form_edit_mode = "edit";
|
|
$form_edit_message = "";
|
|
if (array_key_exists('ordered_by_num',$_GET)) $ordered_by_num = intval($_GET['ordered_by_num']);
|
|
if (array_key_exists('order_num',$_GET) && $_GET['order_num'] > 0) $order_num = intval($_GET['order_num']);
|
|
if (!isset($order_num) && array_key_exists('entered_order_num',$_GET) && $_GET['entered_order_num'] > 0) $order_num = intval($_GET['entered_order_num']);
|
|
if (array_key_exists('user_num',$_GET)) {
|
|
$user_num = intval($_GET['user_num']);
|
|
$userNum = intval($_GET['user_num']);
|
|
}
|
|
|
|
// Setup for parent/student orders
|
|
if ($_SESSION['UserInfo']['type'] == 'Parent') {
|
|
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$ordered_by_num = intval($_GET['student_num']);
|
|
$ordered_by_type = "Student";
|
|
}
|
|
|
|
// Setup for staff orders
|
|
if ($_SESSION['UserInfo']['type'] == 'Staff') {
|
|
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$ordered_by_type = "Staff";
|
|
}
|
|
|
|
// Setup for Guest orders
|
|
if ($_SESSION['UserInfo']['type'] == 'Guest') {
|
|
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$ordered_by_num = intval($_GET['user_num']);
|
|
$ordered_by_type = "Customer";
|
|
}
|
|
|
|
// Get name of person ordering
|
|
$menu_price_category = 'Regular';
|
|
if (isset($ordered_by_num) && $ordered_by_num > 0) {
|
|
$results = db_query("SELECT * FROM people WHERE record_num = $ordered_by_num");
|
|
$person = db_fetch_assoc($results);
|
|
$name = db_getVal("SELECT concat(first_name,' ',last_name) FROM people WHERE record_num = $ordered_by_num");
|
|
$name = $person['first_name'].' '.$person['last_name'];
|
|
$people_type = $person['people_type'];
|
|
|
|
$menu_price_category = db_getVal("SELECT menu_price_category FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
if (strlen($menu_price_category) == 0) $menu_price_category = 'Regular';
|
|
if ($menu_price_category != 'Regular') $PageTitle = "$menu_price_category " . getLanguageText('TEXT-ORDER');
|
|
|
|
if ($ordered_by_type != $people_type) $ordered_by_type = $people_type;
|
|
}
|
|
|
|
// Get current user's class_num
|
|
$ccnum = 0;
|
|
if (isset($ordered_by_num) && $ordered_by_num > 0) $ccnum = db_getVal("SELECT class_num FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
|
|
|
|
|
unset($query);
|
|
$newOrder = 'Y';
|
|
$owhere = "";
|
|
|
|
// If order_num is set then get existing order
|
|
if (isset($order_num) && $order_num > 0) {
|
|
$owhere = "and order_num = $order_num ";
|
|
$query = "select * from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $order_num";
|
|
|
|
$item_query = "UPDATE hotlunch_order_items SET order_num = $order_num " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND ordered_by_num = $ordered_by_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND order_num = 0";
|
|
db_query($item_query);
|
|
}
|
|
else {
|
|
// Otherwise check for an existing order if multiples are not allowed
|
|
if ($allow_multiple_orders != 'Y' || $naction != 'add') {
|
|
if (isset($ordered_by_num) && $ordered_by_num > 0) {
|
|
$order_num = db_getVal("SELECT record_num FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $ordered_by_num AND schedule_num = $schedule_num AND status != 'Deleted'");
|
|
|
|
if (! $order_num) {
|
|
$query = "select * from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and status != 'Deleted'";
|
|
}
|
|
else {
|
|
$owhere = "and order_num = $order_num ";
|
|
$query = "select * from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $order_num";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (isset($query)) {
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) > 0) {
|
|
$newOrder = 'N';
|
|
$header = db_fetch_array($results);
|
|
$source = $header['source'];
|
|
$status = $header['status'];
|
|
$order_num = $header['record_num'];
|
|
$ordered_by_num = $header['ordered_by_num'];
|
|
$ordered_by_type = $header['ordered_by_type'];
|
|
$order_notes = $header['order_notes'];
|
|
$order_notes2 = $header['order_notes2'];
|
|
$discount_amount = $header['discount_amount'];
|
|
$price_category = $header['price_category'];
|
|
|
|
if ($_SESSION['UserInfo']['type'] == 'System Administrator' || $_SESSION['UserInfo']['type'] == 'SuperUser') echo("<p>Order Number: $order_num</p>\n");
|
|
|
|
// Get the user_num associated with this person
|
|
$user_num = db_getVal("SELECT user_num FROM people WHERE record_num = $ordered_by_num");
|
|
|
|
|
|
// Do not allow editing of Paid orders by default
|
|
if ($status == 'Paid' && $school_record['allow_edit_of_paid_orders'] == 'N' && ($schedule_record['edit_paid_orders'] == 'D' || $schedule_record['edit_paid_orders'] == 'N')) {
|
|
$form_edit_mode = "review";
|
|
$form_edit_message = getLanguageText('MSG-ORDER-PAID');
|
|
if (strlen($PageTitle)) $PageTitle .= " - ";
|
|
$PageTitle .= getLanguageText('TEXT-REVIEW-ORDER');
|
|
}
|
|
|
|
// Do not allow editing of compimentary orders
|
|
if ($status == 'Complimentary' && $school_record['allow_edit_of_complimentary_orders'] != 'Y' && ($schedule_record['edit_complimentary_orders'] == 'D' || $schedule_record['edit_complimentary_orders'] == 'N')) {
|
|
$form_edit_mode = "review";
|
|
$form_edit_message = getLanguageText('MSG-ORDER-NO-EDIT');
|
|
if (strlen($PageTitle)) $PageTitle .= " - ";
|
|
$PageTitle .= getLanguageText('TEXT-REVIEW-ORDER');
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// If we are past the last date for ordering
|
|
$today = date("Y-m-d",time());
|
|
$first_menu_date = db_getVal("SELECT min(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_type = 'Regular'");
|
|
|
|
$days_prior = $schedule_record['days_prior_to_order_date'];
|
|
if ($days_prior == 0 && date("H",time()) >= $schedule_record['order_until_hour']) $days_prior = 1;
|
|
$menu_date_cutoff = date("Y-m-d",time() + $days_prior * 60 * 60 * 24 - 60);
|
|
if ($schedule_record['end_order_datetime'] < $first_menu_date) $menu_date_cutoff = $today;
|
|
if ($schedule_record['menu_cutoff_date'] > $today) $menu_date_cutoff = $schedule_record['menu_cutoff_date'];
|
|
|
|
|
|
$customDateWhere = "";
|
|
$dateNow = date("Y-m-d H:i:00",time());
|
|
if ($schedule_record['custom_menu_end_dates'] == 'Y') {
|
|
$customDateWhere = "AND menu_end_order_datetime > '$dateNow' ";
|
|
}
|
|
|
|
|
|
// Ordering ended prior to today
|
|
if ($form_edit_mode == "edit" && $schedule_record['end_order_datetime'] < $today) {
|
|
$form_edit_mode = "review";
|
|
$form_edit_message = "$schedule_name - " . getLanguageText('MSG-ORDER-CUTOFF-DATE') . ' ' . date("l F jS, Y",strtotime($schedule_record['end_order_datetime'])) . ".";
|
|
}
|
|
|
|
$now = date("Y-m-d H:i:s",time());
|
|
if ($form_edit_mode == "edit" && $schedule_record['end_order_datetime'] < $now) {
|
|
$form_edit_mode = "review";
|
|
$form_edit_message = "$schedule_name - " . getLanguageText('MSG-ORDER-CUTOFF-DATE') . ' ' . date("l F jS, Y",strtotime($schedule_record['end_order_datetime'])) . ".";
|
|
}
|
|
|
|
// Unless we are logged in as Admin or HotLunchTeam user
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
$form_edit_mode = "edit";
|
|
$form_edit_message = "";
|
|
}
|
|
else {
|
|
if ($form_edit_mode == "edit") {
|
|
$form_edit_message = "$schedule_name - " . getLanguageText('MSG-ORDER-DATES') . "<br>\n" .
|
|
date("l F jS, Y",strtotime($schedule_record['start_order_datetime'])) . " & " .
|
|
date("l F jS, Y",strtotime($schedule_record['end_order_datetime'])) . ".";
|
|
}
|
|
}
|
|
|
|
db_query("UPDATE hotlunch_menu_dates SET current_menu_link = menu_link WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
|
|
|
|
|
//
|
|
// Determine if there are any linked menu dates for this order source
|
|
//
|
|
$menu_link_code = "('None')";
|
|
$linked_items = 'N';
|
|
if ($source == 'Paper') {
|
|
$num = db_getVal("select count(*) from hotlunch_menu_dates where school_num = $school_num and schedule_num = $schedule_num and menu_link in ('Paper','All') and active != 'N'");
|
|
if ($num > 0) {
|
|
$linked_items = 'Y';
|
|
$menu_link_code = "('Paper','All')";
|
|
}
|
|
}
|
|
|
|
if ($source == 'On-Line') {
|
|
$num = db_getVal("select count(*) from hotlunch_menu_dates where school_num = $school_num and schedule_num = $schedule_num and menu_link = 'All' and active != 'N'");
|
|
if ($num > 0) {
|
|
$linked_items = 'Y';
|
|
$menu_link_code = "('All')";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// Get volunteer message if required
|
|
//
|
|
$school_volunteer_signup = $school_record['enable_volunteer_signup'];
|
|
$schedule_volunteer_signup = $schedule_record['volunteer_signup'];
|
|
|
|
|
|
|
|
// Setup readonly for text fields based on current user type
|
|
$readonly_flag = " readonly";
|
|
$disabled_flag = " disabled";
|
|
|
|
if ($linked_items == 'Y') {
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
$readonly_flag = "";
|
|
$disabled_flag = "";
|
|
}
|
|
|
|
// Update the hotlunch_menu_items table
|
|
if ($today > $last_link_update) {
|
|
|
|
$query = "SELECT menu_date,source_menu,record_num " .
|
|
"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 ($row = db_fetch_array($menu_dates)) {
|
|
$mnum = $row['record_num'];
|
|
db_query("UPDATE hotlunch_menu_items SET current_source_item = source_item WHERE school_num = $school_num AND menu_num = $mnum");
|
|
db_query("UPDATE hotlunch_menu_dates SET current_menu_link = menu_link WHERE school_num = $school_num AND record_num = $mnum");
|
|
}
|
|
|
|
|
|
// Now get the set of source menu dates that are prior to the cut off date
|
|
$query = "SELECT menu_date,source_menu,record_num " .
|
|
"FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND (source_menu = 0 OR source_menu IS NULL) " .
|
|
"AND menu_date < '$menu_date_cutoff' " .
|
|
$customDateWhere .
|
|
"ORDER BY sequence,menu_date";
|
|
$menu_dates = db_query($query);
|
|
if (db_num_rows($menu_dates) > 0) {
|
|
while ($row = db_fetch_array($menu_dates)) {
|
|
$mnum = $row['record_num'];
|
|
$mdate = $row['menu_date'];
|
|
|
|
$results = db_query("SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND source_menu = $mnum AND menu_date >= '$menu_date_cutoff' $customDateWhere ORDER BY sequence,menu_date");
|
|
$num_menus = db_num_rows($results);
|
|
if ($num_menus == 0) continue;
|
|
$new_source_menu = db_fetch_array($results);
|
|
$new_mnum = $new_source_menu['record_num'];
|
|
db_query("UPDATE hotlunch_menu_dates SET current_menu_link = 'No' WHERE school_num = $school_num AND record_num = $new_mnum");
|
|
|
|
// Get other linked menus if there are any
|
|
$other_menus = "";
|
|
if ($num_menus > 1) {
|
|
while ($row = db_fetch_array($results)) {
|
|
if (strlen($other_menus)) $other_menus .= ",";
|
|
$other_menus .= $row['record_num'];
|
|
}
|
|
}
|
|
|
|
// Get all the menu items for this menu date
|
|
$results = db_query("SELECT * FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $new_mnum ORDER BY sequence");
|
|
while ($row = db_fetch_array($results)) {
|
|
$inum = $row['record_num'];
|
|
$snum = $row['source_item'];
|
|
|
|
// Update other linked menus
|
|
if (strlen($other_menus) > 0) {
|
|
db_query("UPDATE hotlunch_menu_items SET current_source_item = $inum WHERE school_num = $school_num AND source_item = $snum");
|
|
}
|
|
|
|
// Update the items to be the new source items
|
|
db_query("UPDATE hotlunch_menu_items SET current_source_item = 0 WHERE school_num = $school_num AND record_num = $inum");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Create a message about the discount
|
|
$discount_msg = "";
|
|
if (isset($discount_offered) && $discount_offered != 0 && $discount_expiry_date >= $today) {
|
|
$order_total = $ordertotal;
|
|
$discount_msg = getLanguageText('MSG-DISCOUNT-AMOUNT') . ' ';
|
|
|
|
if ($discount_type == 'Amount') {
|
|
$discount_msg .= $currencySymbol . number_format($discount_offered,2);
|
|
}
|
|
else {
|
|
$discount_msg .= number_format($discount_offered,1) . "%";
|
|
}
|
|
|
|
$discount_msg .= " " . getLanguageText('MSG-DISCOUNT-DATE') . ' ' . date("F jS, Y",strtotime($discount_expiry_date));
|
|
|
|
if (isset($discount_order_minimum) && $discount_order_minimum > 0) {
|
|
$discount_msg .= ' ' . getLanguageText('TEXT-OVER') . " $currencySymbol" . number_format($discount_order_minimum,2);
|
|
}
|
|
}
|
|
|
|
|
|
// Create message about late charges
|
|
if (isset($late_charge) && $late_charge > 0) {
|
|
if (strlen($discount_msg) > 0) $discount_msg .= "<br>\n";
|
|
|
|
$discount_msg .= getLanguageText('MSG-LATE-CHARGE') . " $currencySymbol" . number_format($late_charge,2) . " " . getLanguageText('MSG-LATE-CHARGE-DATE') . " " .
|
|
date("F jS, Y",strtotime($late_charge_date)) . ".";
|
|
$apply_late_charge = 'N';
|
|
if ($late_charge_date <= $today) $apply_late_charge = 'Y';
|
|
}
|
|
|
|
|
|
// Set flag for concession orders
|
|
$concessionOrder = 'N';
|
|
if ($ordered_by_type == 'Concession') {
|
|
$concessionOrder = 'Y';
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<script language="JavaScript">
|
|
|
|
// Function to update the form for checkboxes
|
|
function updateCheckboxLine(code, mcode, gcheck, qtest) {
|
|
var cbcode = 'cb_'+code+'';
|
|
var qtycode = 'qty_' +code+'';
|
|
|
|
if (document.getElementById(cbcode).checked == true) document.getElementById(qtycode).value = 1;
|
|
else document.getElementById(qtycode).value = 0;
|
|
|
|
updateLine(code, mcode, gcheck, qtest);
|
|
}
|
|
|
|
// Function to update the form totals
|
|
function updateLine(code, mcode, gcheck, qtest) {
|
|
var qtycode = 'qty_' +code+'';
|
|
var qtyfield = 'document.orderform.qty_'+code+'';
|
|
var cbfield = 'cb_'+code+'';
|
|
var pricefield = 'document.orderform.price_'+code+'';
|
|
var minqtyfield = 'document.orderform.minqty_'+code+'';
|
|
var warnqtyfield = 'document.orderform.warnqty_'+code+'';
|
|
var maxqtyfield = 'document.orderform.maxqty_'+code+'';
|
|
var maxqtybyfield = 'document.orderform.maxqty_by_'+code+'';
|
|
var familyqtyfield = 'document.orderform.family_qty_'+code+'';
|
|
var linetotal = 'document.orderform.ltotal_'+code+'';
|
|
var linecount = 'document.orderform.lcount_'+code+'';
|
|
var menutotal = 'document.orderform.mtotal_'+mcode+'';
|
|
var menucount = 'document.orderform.mcount_'+mcode+'';
|
|
var lcodeid = 'ltotal_'+code+'';
|
|
var mcodeid = 'mtotal_'+mcode+'';
|
|
var lcountid = 'lcount_'+code+'';
|
|
var mcountid = 'mcount_'+mcode+'';
|
|
var stotal = document.orderform.ordersubtotal.value;
|
|
var ototal = document.orderform.ordertotal.value;
|
|
|
|
if (document.orderform.discount_amount) var discount = document.orderform.discount_amount.value;
|
|
|
|
var linespan = 'span_' +code+'';
|
|
var menuspan = 'span_' +mcode+'';
|
|
|
|
ltotal = eval(''+linetotal+'.value');
|
|
lcount = eval(''+linecount+'.value');
|
|
|
|
mtotal = eval(''+menutotal+'.value');
|
|
mcount = eval(''+menucount+'.value');
|
|
|
|
qty = eval(''+qtyfield+'.value');
|
|
|
|
if (qty.length > 0 && !isInteger(qty)) {
|
|
document.getElementById(qtycode).value = '';
|
|
alert("<?php displayLanguageText('JAVA-INTEGERS-ONLY'); ?>");
|
|
return false;
|
|
}
|
|
|
|
if (gcheck == 'Y') {
|
|
groupCheck(code, mcode);
|
|
}
|
|
qty = eval(''+qtyfield+'.value');
|
|
|
|
var atest = 'N';
|
|
<?php
|
|
if ($concessionOrder == 'N') {
|
|
?>
|
|
|
|
maxqty = eval(''+maxqtyfield+'.value');
|
|
if (Math.abs(maxqty) > 0 && Math.abs(qty) > Math.abs(maxqty)) {
|
|
document.getElementById(qtycode).value = '';
|
|
qty = maxqty;
|
|
document.getElementById(qtycode).value = qty;
|
|
alert("<?php displayLanguageText('JAVA-ORDER-LIMIT') ?> "+maxqty);
|
|
}
|
|
|
|
maxqtyby = eval(''+maxqtybyfield+'.value');
|
|
if (Math.abs(maxqty) > 0 && maxqtyby == 'Family') {
|
|
familyqty = eval(''+familyqtyfield+'.value');
|
|
totalqty = Math.abs(familyqty) + Math.abs(qty);
|
|
if (Math.abs(totalqty) > Math.abs(maxqty)) {
|
|
document.getElementById(qtycode).value = '';
|
|
qty = 0;
|
|
document.getElementById(qtycode).value = qty;
|
|
alert("++<?php displayLanguageText('JAVA-ORDER-LIMIT') ?> "+maxqty);
|
|
}
|
|
}
|
|
|
|
minqty = eval(''+minqtyfield+'.value');
|
|
if (Math.abs(minqty) > 0 && Math.abs(qty) < Math.abs(minqty)) {
|
|
document.getElementById(qtycode).value = '';
|
|
qty = minqty;
|
|
document.getElementById(qtycode).value = qty;
|
|
document.getElementById(cbfield).checked = true;
|
|
alert("<?php displayLanguageText('JAVA-MIN-ORDER-LIMIT') ?> "+minqty);
|
|
}
|
|
|
|
<?php
|
|
if ($schedule_record['qty_absolute_limit'] > 0) {
|
|
$alimit = $schedule_record['qty_absolute_limit'];
|
|
?>
|
|
var schedule_limit = <?php echo($alimit) ?>;
|
|
var qty_max = schedule_limit;
|
|
if (Math.abs(maxqty) > 0) qty_max = maxqty;
|
|
if (qtest == 'Y' && Math.abs(qty) > Math.abs(qty_max)) {
|
|
document.getElementById(qtycode).value = '';
|
|
qty = <?php echo($alimit) ?>;
|
|
document.getElementById(qtycode).value = qty;
|
|
atest = 'Y';
|
|
alert("<?php displayLanguageText('JAVA-ORDER-LIMIT') ?> <?php echo($alimit) ?>");
|
|
}
|
|
<?php
|
|
}
|
|
|
|
if ($schedule_record['qty_warning_limit'] > 0) {
|
|
$wlimit = $schedule_record['qty_warning_limit'];
|
|
?>
|
|
var schedule_warning_limit = <?php echo($wlimit) ?>;
|
|
var qty_warn = schedule_warning_limit;
|
|
var item_warning_limit = eval(''+warnqtyfield+'.value');
|
|
if (Math.abs(item_warning_limit) > 0) qty_warn = item_warning_limit;
|
|
if (qtest == 'Y' && atest == 'N' && Math.abs(qty) >= Math.abs(qty_warn)) {
|
|
r = confirm("<?php displayLanguageText('JAVA-ORDER-CONFIRMATION') ?> "+qty+'');
|
|
if (r != true) {
|
|
document.getElementById(qtycode).value = '';
|
|
qty = 0;
|
|
}
|
|
}
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
price = eval(''+pricefield+'.value');
|
|
// if (price == '0.00') return;
|
|
|
|
linetotal = qty * price;
|
|
menutotal = Math.abs(mtotal - ltotal + linetotal);
|
|
menucount = mcount - lcount + qty;
|
|
ordersubtotal = stotal - mtotal + menutotal;
|
|
ordertotal = ototal - mtotal + menutotal;
|
|
|
|
if (document.getElementById(linespan)) {
|
|
document.getElementById(linespan).innerHTML = '';
|
|
if (linetotal > 0 || qty > 0) {
|
|
document.getElementById(linespan).innerHTML = formatCurrency(linetotal);
|
|
}
|
|
}
|
|
|
|
<?php if ($numDiscounts > 0) { ?>
|
|
// Calculate the discount amount
|
|
calculateDiscount(ordersubtotal);
|
|
if (document.getElementById('discount_amount').value) ordertotal = ordersubtotal - document.getElementById('discount_amount').value;
|
|
<?php } ?>
|
|
|
|
if (document.getElementById(menuspan)) document.getElementById(menuspan).innerHTML = formatCurrency(menutotal);
|
|
document.getElementById(lcodeid).value = linetotal.toString().replace(/\$|\,/g,'');
|
|
document.getElementById(mcodeid).value = menutotal.toString().replace(/\$|\,/g,'');
|
|
document.getElementById('orderspan').innerHTML = formatCurrency(ordertotal);
|
|
|
|
ordersubtotal = formatDecimal(ordersubtotal);
|
|
document.getElementById('ordersubtotal').value = ordersubtotal.toString().replace(/\$|\,/g,'');
|
|
|
|
ordertotal = formatDecimal(ordertotal);
|
|
document.getElementById('ordertotal').value = ordertotal.toString().replace(/\$|\,/g,'');
|
|
|
|
document.getElementById(lcountid).value = qty;
|
|
document.getElementById(mcountid).value = menucount;
|
|
<?php
|
|
//
|
|
// Menu items are linked and updated based on source and menu definitions
|
|
// - See above for the setting of this value
|
|
//
|
|
if ($linked_items == 'Y') {
|
|
?>
|
|
updateLinkedItems(code);
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
return;
|
|
}
|
|
|
|
//Define function to format a value as currency:
|
|
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));
|
|
return (((sign)?'':'-') + '<?php echo($currencySymbol) ?>' + num + '.' + cents);
|
|
}
|
|
|
|
//Define function to format a value as decimal
|
|
function formatDecimal(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));
|
|
return (((sign)?'':'-') + num + '.' + cents);
|
|
}
|
|
|
|
// Function to check if a value is an integer
|
|
function isInteger(n) {
|
|
return (n.toString().search(/^-?[0-9]+$/) == 0);
|
|
}
|
|
|
|
function infoWindow(item) {
|
|
var infowin=dhtmlwindow.open("infobox","iframe","info.view.php?item="+item+"","<?php displayLanguageText('TEXT-ADDITIONAL-INFORMATION'); ?>","width=400px,height=300px,resize=1,scrolling=1,center=1");
|
|
}
|
|
|
|
</script>
|
|
<noscript>
|
|
<p style='background-color: red; color: white;'><br>
|
|
<b><?php displayLanguageText('TEXT-JAVASCRIPT-NOT-ENABLED'); ?></b><br>
|
|
</p>
|
|
<br>
|
|
</noscript>
|
|
|
|
<form method='post' action='/' name='orderform' id='orderform' onSubmit="return checkForm()">
|
|
<?php
|
|
|
|
// Display form_edit_message if there is one
|
|
if (strlen($form_edit_message)) {
|
|
?>
|
|
<table width='<?php echo($form_width) ?>' cellpadding='1' cellspacing='1' border='0' class='big-content-table'>
|
|
<tr>
|
|
<td align='center' bgcolor='#ffffff'><b><?php echo($form_edit_message) ?></b></td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
|
|
// If there is a desription for this schedule the display it
|
|
if (strlen(trim($schedule_record['description'])) > 0 || $schedule_record['display_instructions'] == 'Y') {
|
|
?>
|
|
<table width='<?php echo($form_width) ?>' cellpadding='1' cellspacing='1' border='0' class='content-table'>
|
|
<tr>
|
|
<td align='center'>
|
|
<table>
|
|
<tr>
|
|
<td bgcolor='#ffffff'>
|
|
<?php
|
|
if (strlen(trim($schedule_record['description'])) > 0) {
|
|
if (strip_tags($schedule_record['description']) == $schedule_record['description']) {
|
|
echo("<p>" . htmlspecialchars_decode($schedule_record['description']) . "</p>\n");
|
|
echo(htmlspecialchars_decode($row['content'],ENT_QUOTES));
|
|
}
|
|
else {
|
|
echo(nl2br($schedule_record['description']));
|
|
}
|
|
}
|
|
|
|
if ($schedule_record['display_instructions'] == 'Y') echo("<p>" . getLanguageText('TEXT-ORDER-INSTRUCTIONS') . "</p>\n");
|
|
?>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
if (isset($defaultOrder) && $defaultOrder == 'Y') $PageTitle .= " (" . getLanguageText('TEXT-GENERATE-ORDERS') . ")";
|
|
|
|
|
|
if ($linked_items == 'Y' && $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
echo("<span class='yellow'><b>[<a href='#' onclick='updateAllLinkedItems(); document.getElementById(\"orderform\").submit();'>Update Linked and Submit</a>]</b></span><br><br>");
|
|
}
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
echo("<span class='yellow'><b>[<a href='#' onclick='document.getElementById(\"orderform\").submit();'>Submit and Update</a>]</b></span><br><br>");
|
|
}
|
|
|
|
$message_width = $form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($form_width) ?>' class='content-table'>
|
|
<tr>
|
|
<td align='center' class='heading'><?php echo($PageTitle) ?><br><?php echo($schedule_name) ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<?php
|
|
// If there is a discount offered for this schedule then display it
|
|
if (isset($discount_msg) && strlen($discount_msg) > 0) echo("<p><b>$discount_msg</b></p>\n");
|
|
|
|
$tabindex = 1;
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
?>
|
|
<center>
|
|
<table cellpadding='1' cellspacing='1' border='0' align='center'>
|
|
<?php
|
|
if (!isset($ordered_by_num) && (!isset($defaultOrder) || $defaultOrder != 'Y')) {
|
|
?>
|
|
<tr>
|
|
<td align='left'><b><?php displayLanguageText('TEXT-ORDER-FORM'); ?></b></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'><?php echo(getLanguageText('TEXT-LAST-NAME')) ?>:<br>
|
|
<input type='text' name='new_last_name' id='new_last_name' tabindex=1 value="<?php echo($new_last_name) ?>" size='40'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'>
|
|
<div id=studentResultsRow>
|
|
<div style="width: 525px; border: 1px solid #000; border-bottom: none; background:#eee;">
|
|
<table id=studentResultsHead border=0 cellspacing=0 cellpadding=2>
|
|
<tr>
|
|
<th align=left><?php echo(getLanguageText('TEXT-NAME')) ?></th>
|
|
<th align=left><?php echo(getLanguageText('TEXT-PARENT')) ?></th>
|
|
<th align=left><?php echo(getLanguageText('TEXT-PHONE')) ?></th>
|
|
<th align=center><?php echo(getLanguageText('TEXT-ORDERED')) ?>?</th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div id=studentResultsScroll style="height:100px; width:525px; overflow:auto; border: 1px solid #000; border-top: none; background:#fff;">
|
|
<table id=studentResultsTable border=0 cellspacing=0 cellpadding=2><tr><td></td></tr></table>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'><?php echo(getLanguageText('TEXT-FIRST-NAME')) ?>:<br>
|
|
<input type='text' name='new_first_name' id='new_first_name' tabindex=2 value="<?php echo($new_first_name) ?>" size='40'></td>
|
|
</tr>
|
|
<?php if ($school_record['collect_student_birthdate'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-BIRTH-DATE'); ?>: <br>
|
|
<select name='birth_year'>
|
|
<?php
|
|
$birth_year = date("Y",time()) - 10;
|
|
|
|
$yr = date("Y",time());
|
|
for ($i = 0; $i < 100; $i++) {
|
|
$selected = "";
|
|
if ($yr == $birth_year) $selected = " selected='selected'";
|
|
echo(" <option value='$yr'$selected>$yr</option>\n");
|
|
$yr--;
|
|
}
|
|
?>
|
|
</select>
|
|
<select name='birth_month'>
|
|
<?php
|
|
if (isset($birthdate)) $birth_month = substr($birthdate,5,2);
|
|
|
|
$months = array(getLanguageText('MONTH-JANUARY'),
|
|
getLanguageText('MONTH-FEBRUARY'),
|
|
getLanguageText('MONTH-MARCH'),
|
|
getLanguageText('MONTH-APRIL'),
|
|
getLanguageText('MONTH-MAY'),
|
|
getLanguageText('MONTH-JUNE'),
|
|
getLanguageText('MONTH-JULY'),
|
|
getLanguageText('MONTH-AUGUST'),
|
|
getLanguageText('MONTH-SEPTEMBER'),
|
|
getLanguageText('MONTH-OCTOBER'),
|
|
getLanguageText('MONTH-NOVEMBER'),
|
|
getLanguageText('MONTH-DECEMBER'));
|
|
|
|
|
|
for ($i = 0; $i < count($months); $i++) {
|
|
$num = sprintf("%02d",$i + 1);
|
|
$month = $months[$i];
|
|
$selected = "";
|
|
if ($num == $birth_month) $selected = " selected='selected'";
|
|
echo(" <option value='$num'$selected>$month</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
<select name='birth_day'>
|
|
<?php
|
|
if (isset($birthdate)) $birth_day = substr($birthdate,8,2);
|
|
|
|
for ($i = 1; $i <= 31; $i++) {
|
|
$selected = "";
|
|
if ($i == $birth_day) $selected = " selected='selected'";
|
|
echo(" <option value='$i'$selected>$i</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php
|
|
if ($school_record['participant_grouping'] != 'None') {
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
if ($numClasses > 0 || $school_record['orders_for'] != 'Registrant') {
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php echo($school_record['student_class_text']) ?>:<br>
|
|
<select name='new_class_num' id='new_class_num' tabindex=3 class='select-width300'>
|
|
<?php
|
|
// Get class and teacher information
|
|
if ($school_record['i_display_program'] == 'Y') {
|
|
$query = "select c.*,program_name,cp.sequence " .
|
|
"from classes as c left join class_programs as cp on cp.record_num = class_program " .
|
|
"where c.school_num = $base_school_num " .
|
|
"order by cp.sequence,c.sequence";
|
|
$cresults = db_query($query);
|
|
}
|
|
else {
|
|
$query = "select * from classes " .
|
|
"where school_num = $base_school_num " .
|
|
"order by sequence";
|
|
$cresults = db_query($query);
|
|
}
|
|
|
|
$prev_program = "none";
|
|
while ($crow = db_fetch_array($cresults)) {
|
|
if (strlen($crow['program_name']) > 0 && $prev_program != $crow['program_name']) {
|
|
if ($prev_program != "none") echo(" </optgroup>\n");
|
|
$title = $crow['program_name'];
|
|
$prev_program = $title;
|
|
echo(" <optgroup label='$title'>\n");
|
|
}
|
|
|
|
$cnum = $crow['record_num'];
|
|
$class_info = getClassInfo($cnum);
|
|
|
|
$selected = "";
|
|
if ($cnum == $class_num) $selected = " selected='selected'";
|
|
echo(" <option value='$cnum'$selected>$class_info</option>\n");
|
|
}
|
|
|
|
// Handle staff people
|
|
if ($school_record['registrations_permitted'] == 'Parent' || $school_record['registrations_permitted'] == 'Both') {
|
|
$selected = "";
|
|
if ($class_num == 0) $selected = " selected='selected'";
|
|
echo(" <option value='0'$selected>" . $GlobalText['Staff'] . "</option>\n");
|
|
}
|
|
|
|
// Handle customers
|
|
if ($school_record['registrations_permitted'] == 'Both') {
|
|
$selected = "";
|
|
if ($class_num == 1) $selected = " selected='selected'";
|
|
echo(" <option value='1'$selected>" . getLanguageText('TEXT-CUSTOMER') . "</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<?php if ($school_record['collect_student_number'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-STUDENT-NUMBER'); ?>: <br>
|
|
<input type='text' name='student_number' id='grade' value="<?php echo($student_number) ?>" size='15'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['collect_student_birthdate'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-BIRTH-DATE'); ?>: <br>
|
|
<input type='text' name='birthdate' id='birthdate' value='<?php echo($birthdate) ?>' size='20'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['collect_student_age'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-AGE'); ?>: <br>
|
|
<td align='left' valign='top'><input type='text' name='age' id='age' value='<?php echo($age) ?>' size='5'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['collect_student_sex'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-SEX'); ?>: <br>
|
|
<select name='sex' id='sex'>
|
|
<?php BuildFileList("sex.txt",$sex); ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['collect_student_grade'] == 'Y') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-GRADE'); ?>: <br>
|
|
<input type='text' name='school_grade' id='grade' value="<?php echo($school_grade) ?>" size='5'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['collect_permission'] == 'Y' || $school_record['collect_permission'] == 'W') { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><br>
|
|
<?php echo($school_record['permission_prompt']); ?>: <br>
|
|
<?php BuildFileRadio("yn.txt","additional_permission",'N') ?><br>
|
|
<?php if ($school_record['collect_permission'] == 'W') { ?>
|
|
<input type='text' name='additional_permission_note' value="<?php echo($additional_permission_note) ?>" size='30'><br>
|
|
<?php } ?>
|
|
<?php if (strlen(trim($school_record['permission_description']))) echo("<span class='small'>" . nl2br(trim($school_record['permission_description'])) . "</span>") ?>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($school_record['user_defined_values'] == 'Y' && strlen($school_record['user_defined_title']) > 0) { ?>
|
|
<tr>
|
|
<td align='left' valign='top'><?php echo($school_record['user_defined_title']); ?>: <br>
|
|
<input type='text' name='user_defined_value' id='user_defined_value' value="<?php echo($user_defined_value) ?>" size='20'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<tr>
|
|
<td align='left'><?php displayLanguageText('TEXT-PARENT-NAME'); ?>:<br>
|
|
<input type='text' name='new_parent_last_name' id='new_parent_last_name' tabindex=4 value="<?php echo($new_parent_last_name) ?>" size='40'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'>
|
|
<div id=parentResultsRow>
|
|
<div style="width: 525px; border: 1px solid #000; border-bottom: none; background:#eee;">
|
|
<table id=parentResultsHead border=0 cellspacing=0 cellpadding=2>
|
|
<tr>
|
|
<th align=left><?php displayLanguageText('TEXT-ACCOUNT'); ?></th>
|
|
<th align=left><?php displayLanguageText('TEXT-NAME'); ?></th>
|
|
<th align=left><?php displayLanguageText('TEXT-EMAIL'); ?></th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div id=parentResultsScroll style="height:100px; width:525px; overflow:auto; border: 1px solid #000; border-top: none; background:#fff;">
|
|
<table id=parentResultsTable border=0 cellspacing=0 cellpadding=2><tr><td></td></tr></table>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'><?php displayLanguageText('TEXT-PARENT-FIRST-NAME'); ?>:<br>
|
|
<input type='text' name='new_parent_first_name' id='new_parent_first_name' tabindex=5 value="<?php echo($new_parent_first_name) ?>" size='40'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-EMAIL'); ?>:<br>
|
|
<input type='text' name='new_email' id='new_email' tabindex=6 value="<?php echo($new_email) ?>" size='50'><br>
|
|
<span class='small'><?php displayLanguageText('MSG-LEAVE-EMAIL-BLANK'); ?></span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'><?php displayLanguageText('TEXT-HOME-PHONE'); ?>:<br>
|
|
<input type='text' name='new_phone' id='new_phone' tabindex=7 value='<?php echo($new_phone) ?>' size='15'></td>
|
|
</tr>
|
|
<tr id=contactInfoRow>
|
|
<td align='left'><?php displayLanguageText('TEXT-CONTACT-INFORMATION'); ?>:<br>
|
|
<input type='radio' name='display_contact_info' tabindex=8 value='Y' checked='checked'> <?php displayLanguageText('TEXT-YES'); ?>
|
|
<input type='radio' name='display_contact_info' tabindex=9 value='N'> <?php displayLanguageText('TEXT-NO'); ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
</center>
|
|
<br>
|
|
<?php
|
|
$tabindex = 10;
|
|
}
|
|
|
|
|
|
if (isset($name) && strlen($name) > 0) echo("<p><b>$name</b></p>\n");
|
|
|
|
// Set name title for Concession Order
|
|
$display_current_totals = 'N';
|
|
$concessionOrder = 'N';
|
|
if ($ordered_by_type == 'Concession') {
|
|
echo("<p><b>Concession Order</b></p>\n");
|
|
$display_current_totals = 'Y';
|
|
$concessionOrder = 'Y';
|
|
}
|
|
|
|
|
|
//
|
|
// Menu Dates Array
|
|
//
|
|
$MenuDates = array();
|
|
$CurrentDates = array();
|
|
|
|
|
|
// Get menu dates for this schedule
|
|
$query = "select * from hotlunch_menu_dates " .
|
|
"where school_num = $school_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
"and active != 'N' " .
|
|
"order by sequence,menu_date";
|
|
writeLog($query);
|
|
$menu_dates = db_query($query);
|
|
|
|
$ordertotal = '0';
|
|
$global_code = "";
|
|
$menu_items_code = "";
|
|
$all_menu_items_code = "";
|
|
$menu_options_code = "";
|
|
$group_check_code = "";
|
|
$group_complete_code = "";
|
|
$form_check_code = "";
|
|
$discount_code = "";
|
|
$groupQtyFields = array();
|
|
$groupCodes = array('A','B','C','D','E','F','G','H','I','J','K','L','M');
|
|
|
|
$otipSpans = "";
|
|
$nutrition_spans = "";
|
|
$image_spans = "";
|
|
|
|
writeLog("SELECT min(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND active != 'N' AND menu_type = 'Regular'");
|
|
$firstMenuDate = db_getVal("SELECT min(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND active != 'N' AND menu_type = 'Regular' AND menu_date IS NOT NULL");
|
|
writeLog("firstMenuDate: $firstMenuDate");
|
|
|
|
writeLog("SELECT max(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND active != 'N' AND menu_type = 'Regular'");
|
|
$lastMenuDate = db_getVal("SELECT max(menu_date) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND active != 'N' AND menu_type = 'Regular'");
|
|
writeLog("lastMenuDate: $lastMenuDate");
|
|
|
|
|
|
while ($mdate = db_fetch_array($menu_dates)) {
|
|
$menu_num = $mdate['record_num'];
|
|
$menu_code = $schedule_num . "_" . $menu_num;
|
|
$menu_title = $mdate['menu_title'];
|
|
$menu_link = $mdate['menu_link'];
|
|
$menu_link = $mdate['current_menu_link'];
|
|
$menu_date = $mdate['menu_date'];
|
|
$menu_type = $mdate['menu_type'];
|
|
$menu_instructions = $mdate['menu_instructions'];
|
|
$volunteer_msg = $mdate['volunteer_msg'];
|
|
$menu_available = $mdate['available'];
|
|
|
|
writeLog("menu_num: $menu_num\n");
|
|
writeLog("menu_date: $menu_date\n");
|
|
|
|
|
|
// Check if this student can order in this menu
|
|
if ($ccnum > 0 && $ordered_by_type == 'Student' && isset($ordered_by_num) && $ordered_by_num > 0) {
|
|
$sclasses = db_getVal("SELECT count(*) FROM hotlunch_menu_dates_classes WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num");
|
|
if ($sclasses > 0) {
|
|
$access = db_getVal("SELECT count(*) FROM hotlunch_menu_dates_classes WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND class_num = $ccnum");
|
|
if (($_SESSION['UserInfo']['type'] == 'Parent' || $_SESSION['UserInfo']['type'] == 'Staff') && $access == 0) continue;
|
|
}
|
|
}
|
|
|
|
|
|
// if ($menu_type != 'Footer') {
|
|
// if ($firstMenuDate == 0) $firstMenuDate = $menu_date;
|
|
// $lastMenuDate = $menu_date;
|
|
// }
|
|
// else {
|
|
// $menu_date = $lastMenuDate;
|
|
// }
|
|
|
|
if ($menu_type == 'Footer') $menu_date = $lastMenuDate;
|
|
|
|
$menuDateActive = 'Y';
|
|
$rowStyle = "";
|
|
|
|
$volunteer_signup = 'N';
|
|
|
|
if ($school_volunteer_signup == 'Y') {
|
|
$maxVolunteers = $school_record['max_volunteers'];
|
|
$volunteerMessage = $school_record['default_volunteer_message'];
|
|
if (strlen($schedule_record['schedule_volunteer_message']) > 0) $volunteerMessage = $schedule_record['schedule_volunteer_message'];
|
|
$volunteer_signup = 'Y';
|
|
}
|
|
|
|
if ($schedule_volunteer_signup == 'Y') {
|
|
$maxVolunteers = $schedule_record['max_volunteers'];
|
|
$volunteer_signup = 'Y';
|
|
}
|
|
if (strlen($schedule_record['schedule_volunteer_message']) > 0) $volunteerMessage = $schedule_record['schedule_volunteer_message'];
|
|
|
|
if ($schedule_volunteer_signup == 'N') {
|
|
$volunteer_signup = 'N';
|
|
}
|
|
|
|
if ($mdate['num_volunteer_override'] == 'Y') {
|
|
$maxVolunteers = $mdate['max_volunteers'];
|
|
$volunteer_signup = 'Y';
|
|
}
|
|
if (strlen($mdate['volunteer_msg']) > 0) $volunteerMessage = $mdate['volunteer_msg'];
|
|
|
|
if ($mdate['num_volunteer_override'] == 'N') {
|
|
$volunteer_signup = 'N';
|
|
}
|
|
|
|
|
|
// Handle linked child items if the field needs to be readonly based on the menu_link
|
|
$readonly = "";
|
|
$disabled = "";
|
|
$linkedMenu = false;
|
|
if (($menu_link == 'Paper' && $source == 'Paper') || $menu_link == 'All') {
|
|
if ($schedule_record['edit_linked_menus'] == 'N') {
|
|
$readonly = $readonly_flag;
|
|
$disabled = $disabled_flag;
|
|
$linkedMenu = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Set class for menu header
|
|
$tclass = 'menudate-header';
|
|
|
|
// Get menu items for this menu date
|
|
$active_menu_items = array();
|
|
$currentMenuItems = array();
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"AND active != 'N' " .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
while ($menu_item = db_fetch_array($menu_items)) {
|
|
extract($menu_item);
|
|
|
|
// Check if this student can order in this menu item
|
|
if ($ccnum > 0 && $ordered_by_type == 'Student' && isset($ordered_by_num) && $ordered_by_num > 0) {
|
|
$sclasses = db_getVal("SELECT count(*) FROM hotlunch_menu_items_classes WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND menu_item_num = $record_num");
|
|
if ($sclasses > 0) {
|
|
$access = db_getVal("SELECT count(*) FROM hotlunch_menu_items_classes WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND menu_item_num = $record_num AND class_num = $ccnum");
|
|
if (($_SESSION['UserInfo']['type'] == 'Parent' || $_SESSION['UserInfo']['type'] == 'Staff') && $access == 0) continue;
|
|
}
|
|
}
|
|
|
|
$active_menu_items[] = $record_num;
|
|
$currentMenuItems[] = $menu_item;
|
|
}
|
|
|
|
$iwhere = "";
|
|
if (count($active_menu_items)) {
|
|
$activeMenuItems = implode(",",$active_menu_items);
|
|
$iwhere = "AND record_num IN ($activeMenuItems) ";
|
|
}
|
|
|
|
$numItems = count($active_menu_items);
|
|
if ($numItems == 0) $tclass = 'menudate-noitems';
|
|
|
|
|
|
// Adjust title if date is in the past
|
|
if ($schedule_type == 'Hot Lunch' || $schedule_type == 'Date Sensitive') {
|
|
if ($form_edit_mode == 'edit') {
|
|
if ($menu_date < $menu_date_cutoff) $menuDateActive = 'N';
|
|
if ($schedule_record['custom_menu_end_dates'] == 'Y' && $mdate['menu_end_order_datetime'] < $dateNow) $menuDateActive = 'N';
|
|
|
|
if ($menuDateActive == 'N' || $menu_available == 'N') {
|
|
$tclass = 'menudate-past';
|
|
if ($_SESSION['UserInfo']['type'] == 'Parent' || $_SESSION['UserInfo']['type'] == 'Staff' || $_SESSION['UserInfo']['type'] == 'Guest') {
|
|
$menu_title .= " - " . getLanguageText('TEXT-NOT-AVAILABLE-AT-THIS-TIME');
|
|
if ($hide_unavailable_dates == 'Y') $rowStyle = " style='display: none;'";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
// Save menu date information
|
|
//
|
|
if (in_array($siteType,array('hotlunch','fundraising'))) $menuDate = $mdate['menu_date'];
|
|
else $menuDate = $mdate['menu_date'] . "." . $menu_num;
|
|
|
|
$MenuDates[$menu_num]['menu_date'] = $mdate['menu_date'];
|
|
$MenuDates[$menu_num]['menu_type'] = $mdate['menu_type'];
|
|
$MenuDates[$menu_num]['rowStyle'] = $rowStyle;
|
|
$MenuDates[$menu_num]['tclass'] = $tclass;
|
|
$MenuDates[$menu_num]['menu_title'] = $menu_title;
|
|
$MenuDates[$menu_num]['display_menu_date'] = $display_menu_date;
|
|
$MenuDates[$menu_num]['menu_instructions'] = $menu_instructions;
|
|
$MenuDates[$menu_num]['menu_active'] = $menuDateActive;
|
|
|
|
|
|
// Get menu items for this menu date
|
|
$query = "select * from hotlunch_menu_items " .
|
|
"where school_num = $school_num " .
|
|
"and menu_num = $menu_num " .
|
|
"AND active != 'N' " .
|
|
$iwhere .
|
|
"order by sequence";
|
|
$menu_items = db_query($query);
|
|
|
|
// Determine if groups are in use in this menu
|
|
$groupCount = db_getVal("SELECT count(*) FROM hotlunch_menu_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND menu_num = $menu_num " .
|
|
"AND active != 'N' " .
|
|
"AND menu_group IN ('A','B','C','D','E','F','G','H','I','J','K','L','M')");
|
|
$group_items = array();
|
|
|
|
$groupLimits = array();
|
|
|
|
$menu_total = '0';
|
|
$menu_count = 0;
|
|
$item_count = 0;
|
|
|
|
unset($MenuItems);
|
|
$MenuItems = array();
|
|
$MenuItemCount = 0;
|
|
|
|
$LastHeadingClass = '';
|
|
|
|
while ($menu_item = db_fetch_array($menu_items)) {
|
|
extract($menu_item);
|
|
echo("<!-- image: $image -->\n");
|
|
|
|
$readonly = "";
|
|
|
|
if ($item_type == 'Heading') {
|
|
$LastHeadingClass = "header-$record_num";
|
|
if ($heading_visibility == 'hidden') $LastHeadingClass .= " hidden-item";
|
|
$heading_class = "";
|
|
}
|
|
else {
|
|
$heading_class = $LastHeadingClass;
|
|
}
|
|
|
|
$curr_item_num = $record_num;
|
|
$curr_code = $schedule_num . "_" . $menu_num . "_" . $curr_item_num;
|
|
$qtyfield = "qty_$curr_code";
|
|
$cbfield = "cb_$curr_code";
|
|
$pricefield = "price_$curr_code";
|
|
$linespan = "span_$curr_code";
|
|
$linetotal = "ltotal_$curr_code";
|
|
$linecount = "lcount_$curr_code";
|
|
$minqty = "minqty_$curr_code";
|
|
$warnqty = "warnqty_$curr_code";
|
|
$maxqty = "maxqty_$curr_code";
|
|
$maxqty_by = "maxqty_by_$curr_code";
|
|
$family_qty = "family_qty_$curr_code";
|
|
|
|
|
|
// Save qty field to groupQtyFields array for later processing
|
|
if ($item_type != 'Heading' && array_key_exists('Any',$discountGroups)) $groupQtyFields['Any'] .= " $qtyfield";
|
|
for ($i = 0; $i < count($groupCodes); $i++) {
|
|
$gCode = $groupCodes[$i];
|
|
if ($item_type != 'Heading' && array_key_exists($gCode,$discountGroups)) $groupQtyFields[$gCode] .= " $qtyfield";
|
|
}
|
|
|
|
|
|
if (strlen(trim($label_title)) == 0) $label_title = $item_title;
|
|
if ($display_title_or_label == 'Title') $label_title = $item_title;
|
|
|
|
$MenuItems[$MenuItemCount]['item_type'] = $item_type;
|
|
|
|
|
|
if ($item_type != 'Heading') {
|
|
// Format tips for "Form" display mode
|
|
if ($menu_display_mode == 'Form') {
|
|
// Display nutritional information icon if data exists
|
|
$nutrition_image = "";
|
|
if (strlen(trim($nutritional_info)) > 0) {
|
|
$span_id = "nut_span$curr_item_num";
|
|
$nutrition_icon = "<img src='images/icons/infoabout16.png' alt='" . getLanguageText('TEXT-ADDITIONAL-INFORMATION') . "' title='" . getLanguageText('TEXT-ADDITIONAL-INFORMATION') . "' hspace='0' border='0'>";
|
|
$otipSpans .= "<span id='$span_id'>" . sprintf($otipNUTRITION,nl2br($nutritional_info)) . "</span>\n";
|
|
$nutrition_image = " <a href=\"javascript:TagToTip('$span_id',BGCOLOR,'#FFFFFF')\" onmouseover=\"TagToTip('$span_id',BGCOLOR,'#FFFFFF')\" onmouseout=\"UnTip()\">$nutrition_icon</a> ";
|
|
}
|
|
|
|
// Process the BC Food Guidelines icons
|
|
$rating_image = "";
|
|
$rating_icon = "<img src='images/icons/accept16.png' alt='Choose $bc_guideline_rating' title='Choose $bc_guideline_rating' hspace='0'>";
|
|
if ($school_record['display_bc_food_guidelines'] == 'Y') {
|
|
if ($bc_guideline_rating == 'Sometimes') $rating_image = " $rating_icon ";
|
|
if ($bc_guideline_rating == 'Most') $rating_image = " <nobr>" . $rating_icon . $rating_icon . "</nobr>";
|
|
}
|
|
|
|
// Handle item image
|
|
$image_link = "";
|
|
echo("<!-- image: $image -->\n");
|
|
if (strlen($image) > 0 && is_file("$imagedir/$image")) {
|
|
$image_icon = "<img src='images/icons/pictures16.png' alt='Item Image' title='Item Image' hspace='5' border='0' align='right'>";
|
|
|
|
$ic = explode('.',$image);
|
|
$iname = "";
|
|
$ext = $ic[count($ic) - 1];
|
|
for ($i = 0; $i < count($ic) - 1; $i++) {
|
|
if (strlen($iname)) $iname .= ".";
|
|
$iname .= $ic[$i];
|
|
}
|
|
|
|
$image_size = GetImageSize("$imagedir/$image");
|
|
$image_width = $image_size[0];
|
|
$image_height = $image_size[1];
|
|
|
|
$thumbnail = $iname."-tn.".$ext;
|
|
if ($schedule_record['display_product_thumbnail'] == 'Y') {
|
|
if (!is_file("$imagedir/$thumbnail")) {
|
|
$img = createThumbnail($image, $imagedir);
|
|
}
|
|
$image_size = GetImageSize("$imagedir/$thumbnail");
|
|
$image_width = $image_size[0];
|
|
$image_height = $image_size[1];
|
|
$image_icon = "<img src='$imageurl/$thumbnail' alt='Item Image' title='Item Image' hspace='5' border='0' width='$image_width' height='$image_height' align='right'>";
|
|
}
|
|
|
|
if ($image_width >= $image_height) {
|
|
if ($image_width > $maxImageDimension) {
|
|
$image_height = intval($image_height * $maxImageDimension / $image_width);
|
|
$image_width = $maxImageDimension;
|
|
}
|
|
}
|
|
else {
|
|
if ($image_height > $maxImageDimension) {
|
|
$image_width = intval($image_width * $maxImageDimension / $image_height);
|
|
$image_height = $maxImageDimension;
|
|
}
|
|
}
|
|
|
|
$span_id = "img_span$curr_item_num";
|
|
$otipSpans .= "<span id='$span_id'>" . sprintf($otipIMG,"$imageurl/$image",$image_height,$image_width,$item_title) . "</span>\n";
|
|
$image_link = "<a href=\"javascript:TagToTip('$span_id')\" onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$image_icon</a>";
|
|
}
|
|
}
|
|
|
|
// Setup prices
|
|
$item_price = $offline_price;
|
|
if ($source == 'On-Line') $item_price = $online_price;
|
|
|
|
// Use Special Prices if required
|
|
if ($school_record['special_item_prices'] == 'Y') {
|
|
if ($menu_price_category == 'Special 1') $item_price = $special_price1;
|
|
if ($menu_price_category == 'Special 2') $item_price = $special_price2;
|
|
if ($menu_price_category == 'Special 3') $item_price = $special_price3;
|
|
}
|
|
|
|
if (strlen($item_price) == 0) $item_price = "0.00";
|
|
|
|
|
|
// Format tips for "Calendar" display mode
|
|
if ($menu_display_mode == 'Calendar' || $menu_display_mode == 'Calendar No Weekends') {
|
|
$iTitle = "<b> - $item_title</b>";
|
|
if ($display_price != 'N') $iTitle .= " - <span class='price-tip'> $currencySymbol$item_price </span>";
|
|
$iTitle .= "<br>\n";
|
|
|
|
if (strlen($item_description)) $iTitle .= " -- $item_description<br>\n";
|
|
if ($taxable_item == 'Y') $iTitle .= " -- " . getLanguageText('TEXT-TAXABLE') . "<br>\n";
|
|
|
|
// Format nutritional info
|
|
if (strlen(trim($nutritional_info))) $nutritional_info = "<br>\n" . nl2br(trim($nutritional_info));
|
|
|
|
// Include image if there is one
|
|
$iImage = "<br><br>";
|
|
if (strlen($image) > 0 && is_file("$imagedir/$image")) {
|
|
|
|
$image_size = GetImageSize("$imagedir/$image");
|
|
$image_width = $image_size[0];
|
|
$image_height = $image_size[1];
|
|
|
|
if ($image_width >= $image_height) {
|
|
if ($image_width > $maxImageDimension) {
|
|
$image_height = intval($image_height * $maxImageDimension / $image_width);
|
|
$image_width = $maxImageDimension;
|
|
}
|
|
}
|
|
else {
|
|
if ($image_height > $maxImageDimension) {
|
|
$image_width = intval($image_width * $maxImageDimension / $image_height);
|
|
$image_height = $maxImageDimension;
|
|
}
|
|
}
|
|
|
|
$image = urlencode($image);
|
|
$iImage = "<br>\n<center>" . sprintf($otipIMG,"$imageurl/$image",$image_height,$image_width,$item_title) . "</center>";
|
|
}
|
|
|
|
$mtitle = "";
|
|
if (strlen($menu_title)) $mtitle = "<span class='title-tip'> $menu_title </span><br>\n";
|
|
|
|
// Process the BC Food Guidelines icons
|
|
$rating_image = "";
|
|
$rating_icon = "<img src='images/icons/accept16.png' alt='Choose $bc_guideline_rating' title='Choose $bc_guideline_rating' hspace='0'>";
|
|
if ($school_record['display_bc_food_guidelines'] == 'Y') {
|
|
if ($bc_guideline_rating == 'Sometimes') $rating_image = " $rating_icon ";
|
|
if ($bc_guideline_rating == 'Most') $rating_image = " <nobr>" . $rating_icon . $rating_icon . "</nobr>";
|
|
}
|
|
|
|
|
|
$span_id = "info_span$curr_item_num";
|
|
if ($menu_available != 'N') {
|
|
$otipSpans .= "<span id='$span_id' class='info-span'>" .
|
|
sprintf($otipNUTRITION,$mtitle . $iTitle . $nutritional_info) .
|
|
$iImage .
|
|
"</span>\n";
|
|
}
|
|
else {
|
|
$msg = "<span class='error'>" . getLanguageText('TEXT-NOT-AVAILABLE') . "</span><br>";
|
|
$otipSpans .= "<span id='$span_id'>" .
|
|
sprintf($otipNUTRITION,$msg . $mtitle . $iTitle . $nutritional_info) .
|
|
$iImage .
|
|
"</span>\n";
|
|
}
|
|
$label_title = "<a href=\"javascript:TagToTip('$span_id',BGCOLOR,'#FFFFFF')\" onmouseover=\"TagToTip('$span_id',BGCOLOR,'#FFFFFF')\" onmouseout=\"UnTip()\" " .
|
|
"class='menu-item-title' menu-num='$menu_num' item-num='$curr_item_num'>$label_title</a>";
|
|
}
|
|
|
|
|
|
$qtyvalue = '';
|
|
$line_total = '0';
|
|
$item_options_ordered = array();
|
|
$item_options2_ordered = array();
|
|
$item_options3_ordered = array();
|
|
|
|
// Check if there is an order for this item for this person
|
|
if (isset($ordered_by_num) && $newOrder != 'Y') {
|
|
$query = "select * from hotlunch_order_items " .
|
|
"where school_num = $school_num " .
|
|
"and ordered_by_num = $ordered_by_num " .
|
|
"and schedule_num = $schedule_num " .
|
|
$owhere .
|
|
"and menu_num = $menu_num " .
|
|
"and menu_item_num = $curr_item_num " .
|
|
"and active != 'N'";
|
|
$orders = db_query($query);
|
|
|
|
if (db_num_rows($orders) > 0) {
|
|
$order = db_fetch_array($orders);
|
|
$qtyvalue = $order['qty'];
|
|
$options_ordered = $order['options_ordered'];
|
|
$options2_ordered = $order['options2_ordered'];
|
|
$options3_ordered = $order['options3_ordered'];
|
|
if (strlen($options_ordered) > 0) $item_options_ordered = explode("\n",trim($options_ordered));
|
|
if (strlen($options2_ordered) > 0) $item_options2_ordered = explode("\n",trim($options2_ordered));
|
|
if (strlen($options3_ordered) > 0) $item_options3_ordered = explode("\n",trim($options3_ordered));
|
|
|
|
$ltotal = $qtyvalue * $item_price;
|
|
$line_total = number_format($ltotal,2);
|
|
$menu_total += $ltotal;
|
|
$menu_count += $qtyvalue;
|
|
$ordertotal += $ltotal;
|
|
}
|
|
}
|
|
else {
|
|
if (isset($_POST["qty_$curr_code"])) $qtyvalue = $_POST["qty_$curr_code"];
|
|
if ($min_quantity > 0 && $qtyvalue == 0) $qtyvalue = $min_quantity;
|
|
|
|
$ltotal = $qtyvalue * $item_price;
|
|
$line_total = number_format($ltotal,2);
|
|
$menu_total += $ltotal;
|
|
$menu_count += $qtyvalue;
|
|
$ordertotal += $ltotal;
|
|
}
|
|
|
|
|
|
// Handle dates that have passed for parents
|
|
if ($_SESSION['UserInfo']['type'] == 'Parent' || $_SESSION['UserInfo']['type'] == 'Staff') {
|
|
if ($form_edit_mode == 'edit' && $menuDateActive == 'N') {
|
|
$readonly = $readonly_flag;
|
|
$disabled = $disabled_flag;
|
|
}
|
|
}
|
|
|
|
|
|
// Handle item options
|
|
$options_count_code = "";
|
|
$options_code = "";
|
|
$optionsArray = array();
|
|
|
|
for ($set = 0; $set <= 2; $set++) {
|
|
switch ($set) {
|
|
case 0:
|
|
$optionsTitle = $options_title;
|
|
$itemOptions = $options;
|
|
$defaultOptions = $default_options;
|
|
$orderedOptions = $item_options_ordered;
|
|
$minOptions = $min_options;
|
|
$maxOptions = $max_options;
|
|
$ext = "";
|
|
break;
|
|
|
|
case 1:
|
|
$optionsTitle = $options2_title;
|
|
$itemOptions = $options2;
|
|
$defaultOptions = $default_options2;
|
|
$orderedOptions = $item_options2_ordered;
|
|
$minOptions = $min_options2;
|
|
$maxOptions = $max_options2;
|
|
$ext = "2";
|
|
break;
|
|
|
|
case 2:
|
|
$optionsTitle = $options3_title;
|
|
$itemOptions = $options3;
|
|
$defaultOptions = $default_options3;
|
|
$orderedOptions = $item_options3_ordered;
|
|
$minOptions = $min_options3;
|
|
$maxOptions = $max_options3;
|
|
$ext = "3";
|
|
break;
|
|
}
|
|
|
|
|
|
$itemOptions = trim($itemOptions);
|
|
if (strlen($itemOptions) > 0) {
|
|
$item_options = explode("\n",$itemOptions);
|
|
$default_options_array = array();
|
|
if (strlen(trim($defaultOptions))) $default_options_array = explode("\n",trim($defaultOptions));
|
|
for ($o = 0; $o < count($default_options_array); $o++) { $default_options_array[$o] = trim($default_options_array[$o]); }
|
|
if ($menu_display_mode == 'Form' || $set > 0) $options_code .= "<br>\n";
|
|
if (strlen($optionsTitle)) $options_code .= "<span class='options$ext'><b>$optionsTitle</b>:</span> ";
|
|
$optionsText = "$optionsTitle: ";
|
|
|
|
if ($form_edit_mode != 'review') {
|
|
// Build menu options code string
|
|
$menu_options_code .= " if (code == '$curr_code') {\n";
|
|
$menu_options_code .= " var qtyfield = 'qty_'+code+'';\n";
|
|
$menu_options_code .= " var cbfield = 'cb_'+code+'';\n";
|
|
|
|
if ($menuDateActive == 'Y') {
|
|
$menu_options_code .= " if (document.getElementById(sname).checked && ! document.getElementById(qtyfield).value) {\n";
|
|
$menu_options_code .= " document.getElementById(qtyfield).value = 1;\n";
|
|
$menu_options_code .= " if (document.getElementById(cbfield)) document.getElementById(cbfield).checked = true;\n";
|
|
$menu_options_code .= " }\n\n";
|
|
}
|
|
|
|
// Handle limits on the number of options selected
|
|
if ($maxOptions > 0 || $minOptions > 0) {
|
|
$numOptions = count($orderedOptions);
|
|
$global_code .= " var ocount$ext" . "_$curr_code = $numOptions;\n";
|
|
$menu_options_code .= " ocount$ext" . "_$curr_code = 0;\n";
|
|
$options_count_code .= " ocount$ext" . "_$curr_code = 0;\n";
|
|
}
|
|
|
|
$num_options = count($item_options);
|
|
for ($i = 0; $i < count($item_options); $i++) {
|
|
$option = trim($item_options[$i]);
|
|
$optionsArray[] = array($option,$ext);
|
|
// echo("<!-- option: $option ext: $ext -->\n");
|
|
if (strlen($option) > 0) $checked = "";
|
|
if (in_array($option,$orderedOptions)) $checked = " checked='checked'";
|
|
if ($newOrder == 'Y' && in_array($option,$default_options_array)) $checked = " checked='checked'";
|
|
$option_f = str_replace(" ","_",substr($option,0,30));
|
|
$option_f = str_replace("&","and",$option_f);
|
|
$option_f = preg_replace("/[^a-zA-Z0-9_]/","",$option_f);
|
|
$sname = "option{$ext}_$curr_code" . "_$option_f";
|
|
if ($disabled != $disabled_flag || strlen($disabled_flag) == 0) {
|
|
$options_code .= "<span class='menu-item-option options$ext'><input type='checkbox' name='$sname' id='$sname' inum='$curr_item_num' optionf='$option_f' class='item-option $current_source_item $option_f' value='Y' " .
|
|
"curr-code='$curr_code' menu-code='$menu_code' " .
|
|
"onChange=\"checkOptions('$curr_code','$menu_code','$sname');\"$checked> " .
|
|
"$option</span> \n";
|
|
}
|
|
else {
|
|
// $fname = $sname . "_visible";
|
|
$options_code .= "<span class='menu-item-option options$ext'><input type='checkbox' name='$sname' id='$sname' class='item-option $current_source_item $option_f' value='Y' " .
|
|
"$checked$disabled> " .
|
|
"$option</span> \n";
|
|
if (strlen($checked)) $options_code .= "<input type='hidden' name='$sname' id='$sname' value='Y'>";
|
|
}
|
|
$optionsText .= "$option ";
|
|
if ($menu_display_mode == 'Form' && strlen($optionsText) > 70 && $i < ($num_options - 1)) {
|
|
$optionsText = "";
|
|
$options_code .= "<br>\n";
|
|
}
|
|
|
|
if ($maxOptions > 0 || $minOptions > 0) {
|
|
$menu_options_code .= " if (document.orderform.$sname.checked) ocount$ext" . "_$curr_code" . "++;\n";
|
|
$options_count_code .= " if (document.orderform.$sname.checked) ocount$ext" . "_$curr_code" . "++;\n";
|
|
}
|
|
}
|
|
|
|
// Ensure that too many options are not selected
|
|
if ($menuDateActive == 'Y' && $maxOptions > 0) {
|
|
$menu_options_code .= " if (ocount$ext" . "_$curr_code > $maxOptions) {\n";
|
|
$menu_options_code .= " document.getElementById(sname).checked = false;\n";
|
|
$menu_options_code .= " alert(\"" . getLanguageText('TEXT-YOU-MAY-NOT-SELECT-MORE-THAN') . " $maxOptions $optionsTitle\");\n";
|
|
$menu_options_code .= " return false;\n";
|
|
$menu_options_code .= " }\n";
|
|
}
|
|
$menu_options_code .= " }\n\n";
|
|
|
|
// Ensure that the minimum number of options have been selected
|
|
if ($menuDateActive == 'Y' && $minOptions > 0) {
|
|
$ititle = str_replace("'",""",$item_title);
|
|
if ($display_menu_date == 'Y') $ititle .= " - " . date("l F jS, Y",strtotime($mdate['menu_date']));
|
|
if ($linkedMenu != true) {
|
|
$form_check_code .= $options_count_code;
|
|
$form_check_code .= " if (document.getElementById('qty_$curr_code').value > 0 && ocount$ext" . "_$curr_code < $minOptions) {\n";
|
|
$form_check_code .= " checkFormMissedOptionsMessage += '" . getLanguageText('TEXT-YOU-MUST-SELECT-AT-LEAST') . " $minOptions $optionsTitle: $ititle\\n';\n";
|
|
$form_check_code .= " }\n";
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$noptions = 0;
|
|
for ($i = 0; $i < count($item_options); $i++) {
|
|
$option = trim($item_options[$i]);
|
|
if (strlen($option) > 0) {
|
|
if (in_array($option,$orderedOptions)) {
|
|
if ($noptions == 0) $options_code .= " - ";
|
|
if ($noptions > 0) $options_code .= ", ";
|
|
$options_code .= $option;
|
|
$noptions++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Complete the span
|
|
if ($menu_display_mode != 'Form' && strlen($options_code)) {
|
|
$options_code = "<span class='item-options-span' id='$curr_code'>$options_code</span>";
|
|
$view_icon_small = "<img src='images/icons/find16.png' alt='Edit Options' menu-num='$menu_num' item-num='$curr_item_num' class='qty-checkbox' border='0'>";
|
|
$label_title .= " " . $view_icon_small;
|
|
}
|
|
|
|
|
|
// Get total items ordered if required
|
|
$total_ordered = "";
|
|
if ($display_current_totals == 'Y') {
|
|
$query = "select sum(qty) from hotlunch_order_items AS hloi, hotlunch_order_header AS hloh, people AS p " .
|
|
"where hloi.school_num = $school_num " .
|
|
"and hloh.school_num = $school_num " .
|
|
"and p.school_num = $base_school_num " .
|
|
"and hloh.record_num = hloi.order_num " .
|
|
"and hloh.status NOT IN ('Inactive','Deleted') " .
|
|
"and hloi.ordered_by_type != 'Concession' " .
|
|
"and hloi.ordered_by_num = p.record_num " .
|
|
"and hloh.schedule_num = $schedule_num " .
|
|
"and hloi.schedule_num = $schedule_num " .
|
|
"and hloi.menu_num = $menu_num " .
|
|
"and hloi.menu_item_num = $curr_item_num " .
|
|
"and hloi.active != 'N'";
|
|
$total_ordered = db_getVal($query);
|
|
$total_ordered = number_format($total_ordered,0) . " ";
|
|
}
|
|
|
|
|
|
// Set the border color of the quantity field
|
|
$borderColor = "808080";
|
|
$groupText = "";
|
|
|
|
$group_available = 0;
|
|
if (isset($menu_group) && strlen($menu_group) == 1) {
|
|
$mgcode = strtolower("group_$menu_group" . "_color");
|
|
$borderColor = $school_record[$mgcode];
|
|
$groupText = "($menu_group) ";
|
|
$group_available = $mdate['group_' . strtolower($menu_group) . '_available'];
|
|
$groupLimits[$menu_group] = $group_available;
|
|
|
|
$group_sold = 0;
|
|
if ($group_available > 0) {
|
|
$query = "SELECT sum(qty) FROM hotlunch_order_items AS hloi, hotlunch_menu_items AS hlmi " .
|
|
"WHERE hloi.school_num = $school_num " .
|
|
"AND hlmi.school_num = $school_num " .
|
|
"AND hloi.schedule_num = $schedule_num " .
|
|
"AND hloi.menu_num = $menu_num " .
|
|
"AND hlmi.menu_num = $menu_num " .
|
|
"AND hloi.menu_item_num = hlmi.record_num " .
|
|
"AND hlmi.menu_group = '$menu_group' " .
|
|
"AND hloi.active != 'N' " .
|
|
"AND hlmi.active != 'N'";
|
|
$group_sold = db_getVal($query);
|
|
$group_qty_available = $group_available - intval($group_sold);
|
|
$groupLimits[$menu_group] = $group_qty_available;
|
|
}
|
|
}
|
|
|
|
|
|
// Clear the group color if the school profile specifies to
|
|
if ($school_record['display_group_colors'] == 'N' && $display_group_colors != 'Y') $borderColor = "808080";
|
|
if (!isset($display_group_colors) || $display_group_colors == 'N') $borderColor = "808080";
|
|
|
|
// Clear the group text if this is a concession order or if the school profile specifies to
|
|
if ($concessionOrder == 'Y') $groupText = "";
|
|
if ($school_record['display_group_letters'] == 'N' || !isset($display_group_letters) || $display_group_letters == 'N') $groupText = "";
|
|
if (!isset($display_group_letters) || $display_group_letters == 'N') $groupText = "";
|
|
|
|
// If group processing is required save this item number to the correct group
|
|
if ($groupCount > 0 && $concessionOrder == 'N') $group_items[$menu_group][] = $curr_item_num;
|
|
|
|
$item_count++;
|
|
$item_price_d = "x $currencySymbol$item_price";
|
|
if ($display_price == 'N') $item_price_d = "";
|
|
|
|
|
|
// Handle limited quantity items
|
|
$item_availability = "";
|
|
$qty_remaining = 9999;
|
|
if ($quantity_available > 0) {
|
|
$qty_sold = db_getVal("SELECT sum(qty) FROM hotlunch_order_items " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_num = $menu_num " .
|
|
"AND menu_item_num = $curr_item_num " .
|
|
"AND active != 'N'");
|
|
$qty_remaining = $quantity_available - $qty_sold;
|
|
|
|
$availablityText = getLanguageText('TEXT-AVAILABLE');
|
|
}
|
|
if ($group_available > 0) {
|
|
if ($group_qty_available < $qty_remaining) {
|
|
$qty_remaining = $group_qty_available;
|
|
$availablityText = getLanguageText('TEXT-AVAILABLE-IN-GROUP') . " $menu_group";
|
|
}
|
|
}
|
|
if ($quantity_available > 0 || $group_available > 0) {
|
|
$item_availability = " ";
|
|
if ($menu_display_mode != 'Form') $item_availability = "<br>";
|
|
$item_availability .= "($qty_remaining " . $availablityText . ")";
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') $item_availability .= " $group_sold / $group_available";
|
|
}
|
|
|
|
|
|
// Setup the order form field
|
|
if ((($mdate['order_format'] != 'Checkbox' || $menu_item_format == 'Q') && $menu_item_format != 'C') || $concessionOrder == 'Y') {
|
|
$rstyle = "";
|
|
$onclick = "";
|
|
if ($linkedMenu) {
|
|
$rstyle = " background: #E0C0C0";
|
|
$onclick = " onclick='alert(\"" . getLanguageText('MSG-LINKED-MENU') . "\")'";
|
|
$readonly = " readonly";
|
|
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) == 1) $onclick = "";
|
|
}
|
|
|
|
if (!in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team'))) {
|
|
if ($menu_available == 'N' || $menuDateActive == 'N') {
|
|
$readonly = " readonly onClick='alert(\"" . getLanguageText('TEXT-NOT-AVAILABLE') . "\");'";
|
|
$onclick = "";
|
|
}
|
|
}
|
|
|
|
echo("<!-- READONLY: $readonly -->\n");
|
|
if (strlen($readonly) == 0) {
|
|
if ($qty_remaining <= 0) {
|
|
$readonly = " readonly onClick='alert(\"" . getLanguageText('TEXT-NOT-AVAILABLE') . "\");'";
|
|
$onclick = "";
|
|
}
|
|
}
|
|
|
|
$itemTitle = "";
|
|
if (strlen(trim($item_message))) $itemTitle = "title=\"$item_message\" ";
|
|
|
|
|
|
$today = date("Y-m-d",time());
|
|
echo("<!-- active_until_date: $active_until_date -- today: $today -- readonly: $readonly -->\n");
|
|
if (strlen($active_until_date) && $active_until_date != '' && $active_until_date != '0000-00-00' && $active_until_date < $today) $readonly = " readonly";
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator');
|
|
if (checkPermission($AllowedUserTypes) == 1) {
|
|
$readonly = "";
|
|
}
|
|
|
|
$rstyle = "";
|
|
if (strlen($readonly)) {
|
|
echo("<!-- $item_title readonly: $readonly -->\n");
|
|
$rstyle = " style='color: #ff0000; background-color: #cccccc;'";
|
|
}
|
|
|
|
$qfield = "<nobr>$groupText$total_ordered<input type='text' name='$qtyfield' id='$qtyfield' size='2' value='$qtyvalue' tabindex=$tabindex " .
|
|
"menu-num='$menu_num' item-num='$curr_item_num' class='qty-field' $rstyle " .
|
|
$itemTitle .
|
|
"style='width: 20px; text-align: center; border-color: #$borderColor;$rstyle'$onclick " .
|
|
"onChange=\"updateLine('$curr_code','$menu_code','Y','Y');\"$readonly></nobr>";
|
|
|
|
if (strlen($readonly) == 0) {
|
|
$qfield = "<nobr>$groupText$total_ordered" .
|
|
"<span class='item-title' rflag='$readonlyflag' code='$curr_code' mcode='$menu_code' menu-num='$menu_num' item-num='$curr_item_num'><img src='images/icons/add24.png' hspace='5'></span>" .
|
|
"<input type='text' name='$qtyfield' id='$qtyfield' size='2' value='$qtyvalue' tabindex=$tabindex " .
|
|
"menu-num='$menu_num' item-num='$curr_item_num' class='qty-field' $rstyle " .
|
|
$itemTitle .
|
|
"style='width: 20px; text-align: center; border-color: #$borderColor;$rstyle'$onclick " .
|
|
"onChange=\"updateLine('$curr_code','$menu_code','Y','Y');\"$readonly>" .
|
|
"<span class='item-price' rflag='$readonlyflag' code='$curr_code' mcode='$menu_code'><img src='images/icons/subtract24.png' hspace='5'></span>" .
|
|
"</nobr>";
|
|
}
|
|
|
|
if (1 == 2 && strlen($readonly) == 0) {
|
|
$qfield = "<nobr>$groupText$total_ordered<select name='$qtyfield' id='$qtyfield' onChange=\"updateLine('$curr_code','$menu_code','Y','Y');\">";
|
|
$qfield .= "<option value=''></option>";
|
|
for ($i = 1; $i <= 100; $i++) {
|
|
$selected = "";
|
|
if (strlen($qtyvalue) && $qtyvalue == $i) $selected = " selected='selected'";
|
|
$qfield .= "<option value='$i'$selected>$i</option>";
|
|
}
|
|
$qfield .= "</select></nobr>";
|
|
}
|
|
|
|
if ($form_edit_mode == "review") {
|
|
$qfield = $qtyvalue . " ";
|
|
}
|
|
}
|
|
else {
|
|
$rstyle = "";
|
|
|
|
if ($qtyvalue == 0 && $quantity_available > 0 && $qty_remaining <= 0) {
|
|
$qfield = "";
|
|
$item_price_d = "";
|
|
}
|
|
else {
|
|
$checked = "";
|
|
if ($qtyvalue == 1) $checked = " checked='checked'";
|
|
if ($min_quantity > 0) {
|
|
$checked = " checked='checked'";
|
|
if ($qtyvalue == 0) $qtyvalue = 1;
|
|
}
|
|
|
|
if ($form_edit_mode == "review") {
|
|
$disabled = $disabled_flag;
|
|
}
|
|
|
|
if (!in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team'))) {
|
|
if ($menu_available == 'N' || $menuDateActive == 'N') {
|
|
$disabled = " disabled onClick='alert(\"" . getLanguageText('TEXT-NOT-AVAILABLE') . "\");'";
|
|
$onclick = "";
|
|
$rstyle = " style='background-color: #FF8080'";
|
|
}
|
|
}
|
|
|
|
$itemTitle = "";
|
|
if (strlen(trim($item_message))) $itemTitle = "title=\"$item_message\" ";
|
|
|
|
$qfield = "<nobr>$groupText$total_ordered<input type='hidden' name='$qtyfield' id='$qtyfield' value='$qtyvalue'>" .
|
|
"<input type='checkbox' name='$cbfield' id='$cbfield'$rstyle qtyfield='$qtyfield' " .
|
|
"menu-num='$menu_num' item-num='$curr_item_num' class='qty-checkbox' tabindex=$tabindex " .
|
|
$itemTitle .
|
|
"onClick=\"updateCheckboxLine('$curr_code','$menu_code','Y','N');\"$checked$disabled> </nobr>";
|
|
}
|
|
}
|
|
|
|
$tabindex++;
|
|
|
|
//
|
|
// Handle item links based on the $menu_link_code value set previously
|
|
// - $menu_link_code is set when evaluating order source and linking
|
|
//
|
|
if ($menuDateActive == 'Y') {
|
|
$query = "select hlmi.* " .
|
|
"from hotlunch_menu_items as hlmi, hotlunch_menu_dates as hlmd " .
|
|
"where hlmi.school_num = $school_num " .
|
|
"AND hlmi.active != 'N' " .
|
|
"and hlmi.current_source_item = $curr_item_num " .
|
|
"and hlmi.menu_num = hlmd.record_num " .
|
|
"and menu_link in $menu_link_code " .
|
|
"and hlmd.school_num = $school_num " .
|
|
"and hlmd.schedule_num = $schedule_num " .
|
|
"and hlmd.menu_date >= '$menu_date_cutoff'";
|
|
$results = db_query($query);
|
|
$nrows = db_num_rows($results);
|
|
if (db_num_rows($results) > 0) {
|
|
$menu_items_code .= " if (code == '$curr_code') {\n";
|
|
$all_menu_items_code .= " updateLinkedItems('$curr_code');\n";
|
|
|
|
while ($row = db_fetch_array($results)) {
|
|
$linked_menu_code = $schedule_num . "_" . $row['menu_num'];
|
|
$linked_code = $linked_menu_code . "_" . $row['record_num'];
|
|
$linked_qty_field = "qty_$linked_code";
|
|
$linked_cb_field = "cb_$linked_code";
|
|
$menu_items_code .= " document.orderform.$linked_qty_field.value = document.orderform.qty_$curr_code.value;\n";
|
|
|
|
// Set checkboxes if required
|
|
if ($mdate['order_format'] == 'Checkbox' || $row['menu_item_format'] == 'C') {
|
|
$menu_items_code .= " if (document.orderform.$linked_cb_field) document.orderform.$linked_cb_field.checked = document.orderform.cb_$curr_code.checked;\n";
|
|
}
|
|
|
|
$menu_items_code .= " updateLine('$linked_code','$linked_menu_code','Y','N');\n";
|
|
}
|
|
|
|
$menu_items_code .= " }\n\n";
|
|
}
|
|
}
|
|
|
|
// Handle item description text
|
|
$item_description = trim($item_description);
|
|
if (strlen($item_description)) $item_description = "<br>\n<span class='small'> - $item_description</span>";
|
|
|
|
// Handle supplier product code
|
|
if ($mdate['display_supplier_code'] == 'Y') {
|
|
$product_num = db_getVal("SELECT supplier_product_num FROM hotlunch_menu_products WHERE school_num = $school_num AND menu_item_num = $curr_item_num AND product_sequence = 1");
|
|
$supplier_code = "";
|
|
if ($product_num > 0) {
|
|
$supplier_code = db_getVal("SELECT supplier_code FROM supplier_products WHERE school_num = $supplier_school_num AND record_num = $product_num");
|
|
}
|
|
if (strlen($supplier_code) > 1) $item_title = "$supplier_code: $item_title";
|
|
}
|
|
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') $item_title = "$curr_item_num: $item_title";
|
|
|
|
if (strlen($qtyvalue) == 0) $qtyvalue = '0';
|
|
|
|
$itemStyle = "";
|
|
if (strlen($rowStyle)) $itemStyle = $rowStyle;
|
|
if ($active == 'N') {
|
|
$itemStyle = " style='display: none;'";
|
|
$heading_class = "";
|
|
}
|
|
|
|
|
|
// Save menu item data
|
|
$MenuItems[$MenuItemCount]['itemStyle'] = $itemStyle;
|
|
$MenuItems[$MenuItemCount]['item_title'] = $item_title;
|
|
$MenuItems[$MenuItemCount]['label_title'] = $label_title;
|
|
$MenuItems[$MenuItemCount]['item_availability'] = $item_availability;
|
|
$MenuItems[$MenuItemCount]['rating_image'] = $rating_image;
|
|
$MenuItems[$MenuItemCount]['nutrition_image'] = $nutrition_image;
|
|
$MenuItems[$MenuItemCount]['image_link'] = $image_link;
|
|
$MenuItems[$MenuItemCount]['item_description'] = $item_description;
|
|
$MenuItems[$MenuItemCount]['options_code'] = $options_code;
|
|
$MenuItems[$MenuItemCount]['qfield'] = $qfield;
|
|
$MenuItems[$MenuItemCount]['item_price_d'] = $item_price_d;
|
|
$MenuItems[$MenuItemCount]['linespan'] = $linespan;
|
|
$MenuItems[$MenuItemCount]['line_total'] = $line_total;
|
|
$MenuItems[$MenuItemCount]['pricefield'] = $pricefield;
|
|
$MenuItems[$MenuItemCount]['item_price'] = $item_price;
|
|
$MenuItems[$MenuItemCount]['linetotal'] = $linetotal;
|
|
$MenuItems[$MenuItemCount]['line_total'] = $line_total;
|
|
$MenuItems[$MenuItemCount]['linecount'] = $linecount;
|
|
$MenuItems[$MenuItemCount]['qtyvalue'] = $qtyvalue;
|
|
$MenuItems[$MenuItemCount]['min_quantity'] = $min_quantity;
|
|
$MenuItems[$MenuItemCount]['warn_quantity'] = $warn_quantity;
|
|
$MenuItems[$MenuItemCount]['max_quantity'] = $max_quantity;
|
|
$MenuItems[$MenuItemCount]['max_quantity_by'] = $max_quantity_by;
|
|
$MenuItems[$MenuItemCount]['minqty'] = $minqty;
|
|
$MenuItems[$MenuItemCount]['warnqty'] = $warnqty;
|
|
$MenuItems[$MenuItemCount]['maxqty'] = $maxqty;
|
|
$MenuItems[$MenuItemCount]['maxqty_by'] = $maxqty_by;
|
|
$MenuItems[$MenuItemCount]['family_qty'] = $family_qty;
|
|
$MenuItems[$MenuItemCount]['item_format'] = $menu_item_format;
|
|
$MenuItems[$MenuItemCount]['item_num'] = $curr_item_num;
|
|
$MenuItems[$MenuItemCount]['source_item_num'] = $current_source_num;
|
|
$MenuItems[$MenuItemCount]['heading_class'] = $heading_class;
|
|
$MenuItems[$MenuItemCount]['curr_code'] = $curr_code;
|
|
$MenuItems[$MenuItemCount]['menu_code'] = $menu_code;
|
|
$MenuItems[$MenuItemCount]['readonly'] = $readonly;
|
|
|
|
if (isset($ordered_by_num) && $ordered_by_num > 0) $user_num = db_getVal("SELECT user_num FROM people WHERE record_num = $ordered_by_num");
|
|
if (isset($user_num) && $user_num > 0) {
|
|
$query = "SELECT sum(qty) FROM hotlunch_order_items AS hloi, people AS p " .
|
|
"WHERE p.school_num = $base_school_num " .
|
|
"AND hloi.school_num = $school_num " .
|
|
"AND p.user_num = $user_num " .
|
|
"AND p.record_num = hloi.ordered_by_num " .
|
|
"AND hloi.menu_item_num = $curr_item_num";
|
|
$fqty = intval(db_getVal($query));
|
|
$MenuItems[$MenuItemCount]['family_quantity'] = $fqty - intval($qtyvalue);
|
|
}
|
|
else {
|
|
$MenuItems[$MenuItemCount]['family_quantity'] = 0;
|
|
}
|
|
$MenuItems[$MenuItemCount]['display_price'] = $display_price;
|
|
|
|
$MenuItemCount++;
|
|
}
|
|
else {
|
|
$description = $item_description;
|
|
if (strlen($item_description) > 0) $item_description = "<br>\n <span class='small'>$item_description</span>";
|
|
|
|
$MenuItems[$MenuItemCount]['rowStyle'] = $rowStyle;
|
|
$MenuItems[$MenuItemCount]['item_title'] = $item_title;
|
|
$MenuItems[$MenuItemCount]['item_description'] = $item_description;
|
|
$MenuItems[$MenuItemCount]['description'] = $description;
|
|
$MenuItems[$MenuItemCount]['item_num'] = $curr_item_num;
|
|
$MenuItems[$MenuItemCount]['heading_visibility'] = $heading_visibility;
|
|
|
|
$MenuItemCount++;
|
|
}
|
|
}
|
|
|
|
$MenuDates[$menu_num]['MenuItems'] = $MenuItems;
|
|
$MenuDates[$menu_num]['item_count'] = $item_count;
|
|
|
|
unset($MenuTotals);
|
|
$MenuTotals = array();
|
|
|
|
|
|
// Show a totals box if there are menu items
|
|
if ($item_count > 0) {
|
|
$menuspan = "span_$menu_code";
|
|
$menutotal = "mtotal_$menu_code";
|
|
$menucount = "mcount_$menu_code";
|
|
$menu_total = number_format($menu_total,2);
|
|
|
|
if ($menuDateActive == 'Y' && ($schedule_type == 'Hot Lunch' || $schedule_type == 'Date Sensitive') && $check_for_missed_menus == 'Y') {
|
|
$mtitle = str_replace('"',""",$menu_title);
|
|
if ($display_menu_date == 'Y') $mtitle .= " - " . date("l F jS, Y",strtotime($mdate['menu_date']));
|
|
$form_check_code .= " if (document.orderform.$menucount.value == 0) {\n";
|
|
$form_check_code .= " missedMenuCount++;\n";
|
|
$form_check_code .= " if (missedMenuCount <= maxMenuCount) {\n";
|
|
$form_check_code .= " checkFormMissedDatesMessage += \" - $mtitle\\n\";\n";
|
|
$form_check_code .= " }\n";
|
|
$form_check_code .= " }\n";
|
|
}
|
|
|
|
$MenuTotals['rowStyle'] = $rowStyle;
|
|
$MenuTotals['menuspan'] = $menuspan;
|
|
$MenuTotals['menu_total'] = $menu_total;
|
|
$MenuTotals['menutotal'] = $menutotal;
|
|
$MenuTotals['menucount'] = $menucount;
|
|
$MenuTotals['menu_count'] = $menu_count;
|
|
}
|
|
|
|
$MenuDates[$menu_num]['MenuTotals'] = $MenuTotals;
|
|
|
|
unset($MenuVolunteers);
|
|
$MenuVolunteers = array();
|
|
$MenuDates[$menu_num]['MenuVolunteers'] = $MenuVolunteers;
|
|
|
|
|
|
if ($concessionOrder == 'N') {
|
|
if ($volunteer_signup == 'Y') {
|
|
$vBox = "volunteer_$menu_code";
|
|
$vChecked = "";
|
|
$vnum = 0;
|
|
if (isset($user_num) && $user_num > 0) {
|
|
$vnum = db_getVal("SELECT count(*) FROM hotlunch_volunteers WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND user_num = $user_num AND deleted != 'Y'");
|
|
if ($vnum == 1) $vChecked = " checked='checked'";
|
|
}
|
|
|
|
// Determine the number of volunteers currently registered
|
|
$numRegistered = db_getVal("SELECT count(*) FROM hotlunch_volunteers WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_num = $menu_num AND deleted != 'Y'");
|
|
|
|
if ($form_edit_mode == 'review' || $menuDateActive == 'N' || $numRegistered >= $maxVolunteers) {
|
|
$vField = 'N';
|
|
if ($vnum == 1) $vField = 'Y';
|
|
$vField .= "<input type='hidden' name='$vBox' value='$vField'>";
|
|
}
|
|
else {
|
|
$vField = "<input type='checkbox' name='$vBox' value='Y'$vChecked tabindex=$tabindex>";
|
|
$tabindex++;
|
|
}
|
|
|
|
if (strlen($volunteerMessage) == 0) $volunteerMessage = getLanguageText('TEXT-DEFAULT-VOLUNTEER-MESSAGE');
|
|
|
|
$MenuVolunteers['rowStyle'] = $rowStyle;
|
|
$MenuVolunteers['volunteerMessage'] = $volunteerMessage;
|
|
$MenuVolunteers['volunteer_msg'] = $volunteer_msg;
|
|
$MenuVolunteers['numRegistered'] = $numRegistered;
|
|
$MenuVolunteers['maxVolunteers'] = $maxVolunteers;
|
|
$MenuVolunteers['vnum'] = $vnum;
|
|
$MenuVolunteers['vField'] = $vField;
|
|
|
|
$MenuDates[$menu_num]['MenuVolunteers'] = $MenuVolunteers;
|
|
}
|
|
}
|
|
|
|
// Generate the group processing code if required
|
|
if ($groupCount > 0 && $concessionOrder == 'N') {
|
|
|
|
$group_check_code .= " if (mcode == '$menu_code') {\n";
|
|
$group_check_code .= " var Atotal = Number(0);\n";
|
|
$group_menu_code = "";
|
|
|
|
// Process each group
|
|
for ($i = 0; $i < count($groupCodes); $i++) {
|
|
$gCode = $groupCodes[$i];
|
|
$groupItems = $group_items[$gCode];
|
|
$groupTotal = $gCode . "total";
|
|
$groupSum = "var $groupTotal = ";
|
|
$currGroup = "group_" . strtolower($gCode);
|
|
$groupLimit = $mdate[$currGroup];
|
|
$Lword = "item";
|
|
if ($groupLimit > 1) $Lword = "items";
|
|
|
|
if (isset($groupLimits[$gCode]) && $groupLimits[$gCode] > 0 && $groupLimits[$gCode] < $groupLimit) $groupLimit = $groupLimits[$gCode];
|
|
|
|
// If this is group B - E check if A required
|
|
if ($i > 0) {
|
|
$aRequiredField = $currGroup . "_a_required";
|
|
$aCustomMessage = $currGroup . "_message";
|
|
}
|
|
|
|
if (count($groupItems) > 0) {
|
|
for ($j = 0; $j < count($groupItems); $j++) {
|
|
$item = $groupItems[$j];
|
|
$curr_code = $schedule_num . "_" . $menu_num . "_" . $item;
|
|
|
|
// Code to check the quantities of menu groups
|
|
$group_check_code .= " var $gCode$j = 0;\n";
|
|
$group_check_code .= " if (document.orderform.qty_$curr_code) $gCode$j = Number(document.orderform.qty_$curr_code.value);\n";
|
|
$group_complete_code .= " var $gCode$j = 0;\n";
|
|
$group_complete_code .= " if (document.orderform.qty_$curr_code) $gCode$j = Number(document.orderform.qty_$curr_code.value);\n";
|
|
|
|
if ($j > 0) $groupSum .= " + ";
|
|
$groupSum .= "$gCode$j";
|
|
|
|
$group_menu_code .= " if (code == '$curr_code') {\n";
|
|
|
|
if ($gCode == 'A') {
|
|
$group_menu_code .= " if (Atotal == 0) {\n";
|
|
for ($m = 1; $m < count($groupCodes); $m++) {
|
|
$codeTemp = $groupCodes[$m];
|
|
$groupTemp = $group_items[$codeTemp];
|
|
$requiredTemp = "group_" . strtolower($codeTemp) . "_a_required";
|
|
|
|
if ($mdate[$requiredTemp] == 'Y' && count($groupTemp) > 0) {
|
|
for ($n = 0; $n < count($groupTemp); $n++) {
|
|
$item_temp = $groupTemp[$n];
|
|
$temp_code = $schedule_num . "_" . $menu_num . "_" . $item_temp;
|
|
$group_menu_code .= " document.orderform.qty_$temp_code.value = 0;\n";
|
|
// $group_menu_code .= " document.orderform.ltotal_$temp_code.value = 0;\n";
|
|
// $group_menu_code .= " document.orderform.lcount_$temp_code.value = 0;\n";
|
|
$group_menu_code .= " updateLine('$temp_code','$menu_code','N','Y');\n";
|
|
}
|
|
}
|
|
}
|
|
$group_menu_code .= " updateLine('$curr_code','$menu_code','N','Y');\n";
|
|
$group_menu_code .= " }\n\n";
|
|
}
|
|
|
|
// Code to prevent someone from ordering unless at least one group A has been ordered
|
|
if ($mdate[$aRequiredField] == 'Y') {
|
|
$g_message = getLanguageText('TEXT-GROUP-A-FIRST') . " $gCode";
|
|
if (strlen($mdate[$aCustomMessage])) $g_message = $mdate[$aCustomMessage];
|
|
$group_menu_code .= " if (Atotal == 0 && document.orderform.qty_$curr_code.value > 0) {\n";
|
|
$group_menu_code .= " document.orderform.qty_$curr_code.value = '';\n";
|
|
|
|
if ($mdate['order_format'] == 'Checkbox') {
|
|
$group_menu_code .= " document.orderform.cb_$curr_code.checked = false;\n";
|
|
}
|
|
|
|
$g_message = str_replace('"','\"',$g_message);
|
|
$group_menu_code .= " alert(\"$g_message\");\n";
|
|
$group_menu_code .= " return;\n";
|
|
$group_menu_code .= " }\n\n";
|
|
}
|
|
|
|
// Ensure that group B,C,D... items are not more than group A items
|
|
for ($n = 0; $n < count($groupCodes); $n++) {
|
|
$gCode2 = $groupCodes[$n];
|
|
if ($gCode2 == 'A') continue;
|
|
|
|
$groupArrayCode = "group_" . strtolower($gCode2);
|
|
$aRequiredField2 = $groupArrayCode . "_a_required";
|
|
$numGroupItems = db_getVal("SELECT count(*) FROM hotlunch_menu_items WHERE school_num = $school_num AND menu_num = $menu_num AND active != 'N' AND menu_group = '$gCode2'");
|
|
|
|
if ($numGroupItems > 0 && $mdate[$aRequiredField2] == 'Y' && $mdate[$groupArrayCode] == 0) {
|
|
$g_quantity = sprintf(getLanguageText('TEXT-GROUP-QTY-ERROR'),$gCode2);
|
|
$group_menu_code .= " if (Atotal > 0 && " . $gCode2 . "total > Atotal) {\n";
|
|
$group_menu_code .= " document.orderform.qty_$curr_code.value = '';\n";
|
|
|
|
$group_menu_code .= " if (document.orderform.cb_$curr_code.checked) {\n";
|
|
$group_menu_code .= " document.orderform.cb_$curr_code.checked = false;\n";
|
|
$group_menu_code .= " }\n";
|
|
|
|
$group_menu_code .= " alert(\"$g_quantity\");\n";
|
|
$group_menu_code .= " return;\n";
|
|
$group_menu_code .= " }\n\n";
|
|
}
|
|
}
|
|
|
|
// Code to manage group quantity limits
|
|
if ($groupLimit > 0) {
|
|
$g_limit = sprintf(getLanguageText('TEXT-GROUP-LIMIT'),$groupLimit) . " $gCode";
|
|
$customMsgField = "group_" . strtolower($gCode) . "_max_message";
|
|
if (strlen($mdate[$customMsgField])) $g_limit = $mdate[$customMsgField];
|
|
|
|
$group_menu_code .= " if ($groupTotal > $groupLimit) {\n";
|
|
$group_menu_code .= " document.orderform.qty_$curr_code.value = '';\n";
|
|
|
|
if ($mdate['order_format'] == 'Checkbox') {
|
|
$group_menu_code .= " document.orderform.cb_$curr_code.checked = false;\n";
|
|
}
|
|
$group_menu_code .= " alert(\"$g_limit\");\n";
|
|
|
|
$group_menu_code .= " }\n";
|
|
}
|
|
$group_menu_code .= " }\n";
|
|
}
|
|
$group_check_code .= " $groupSum;\n";
|
|
$group_complete_code .= " $groupSum;\n";
|
|
|
|
if ($gCode == 'A') {
|
|
if ($mdate['group_a_min'] > 0) {
|
|
$min = $mdate['group_a_min'];
|
|
$msg = getLanguageText('ERRORMSG-NO-ITEMS-SELECTED') . "\\n-- " . $mdate['menu_title'] . " --";
|
|
$group_complete_code .= " if ($groupTotal < $min) {\n";
|
|
$group_complete_code .= " alert(\"$msg\");\n";
|
|
$group_complete_code .= " return(false);\n";
|
|
$group_complete_code .= " }\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$group_check_code .= "\n$group_menu_code";
|
|
$group_check_code .= " }\n\n";
|
|
|
|
// Setup code to check if the mandatory groups have been entered
|
|
$groupMandatory = false;
|
|
|
|
// Process each group
|
|
for ($i = 1; $i < count($groupCodes); $i++) {
|
|
$mandatoryCode = "group_" . strtolower($groupCodes[$i]) . "_mandatory";
|
|
if ($mdate[$mandatoryCode] == 'Y') $groupMandatory = true;
|
|
}
|
|
|
|
// If there is a mandatory group in this menu
|
|
if ($groupMandatory == true) {
|
|
$mtitle = str_replace("'","\'",$menu_title);
|
|
if ($display_menu_date == 'Y') $mtitle .= " - " . date("l F jS, Y",strtotime($mdate['menu_date']));
|
|
|
|
$group_complete_code .= " if (Atotal > 0) {\n";
|
|
for ($i = 1; $i < count($groupCodes); $i++) {
|
|
$mandatoryCode = "group_" . strtolower($groupCodes[$i]) . "_mandatory";
|
|
$groupLimit = $mdate["group_" . strtolower($groupCodes[$i])];
|
|
if ($mdate[$mandatoryCode] == 'Y') {
|
|
// if ($groupLimit == 0) $group_complete_code .= " if (" . $groupCodes[$i] . "total < Atotal) {\n";
|
|
// else $group_complete_code .= " if (" . $groupCodes[$i] . "total < $groupLimit) {\n";
|
|
|
|
if ($groupLimit == 0) {
|
|
$group_complete_code .= " if (" . $groupCodes[$i] . "total < Atotal) {\n";
|
|
$group_complete_code .= " msg = '" . getLanguageText('MESSAGE-INCOMPLETE-ORDER-GROUPS') . "'+'\\n - '+'$mtitle';\n";
|
|
$group_complete_code .= " alert(msg);\n";
|
|
$group_complete_code .= " return false;\n";
|
|
$group_complete_code .= " }\n";
|
|
}
|
|
else {
|
|
$group_complete_code .= " if (" . $groupCodes[$i] . "total < 1) {\n";
|
|
$group_complete_code .= " msg = '" . getLanguageText('MESSAGE-INCOMPLETE-ORDER-GROUPS') . "'+'\\n - '+'$mtitle';\n";
|
|
$group_complete_code .= " alert(msg);\n";
|
|
$group_complete_code .= " return false;\n";
|
|
$group_complete_code .= " }\n";
|
|
}
|
|
}
|
|
}
|
|
$group_complete_code .= " }\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//
|
|
// Display calendar form menus
|
|
//
|
|
if ($menu_display_mode == 'Calendar' || $menu_display_mode == 'Calendar No Weekends') {
|
|
$dayNames = array(
|
|
getLanguageText('TEXT-SUNDAY'),
|
|
getLanguageText('TEXT-MONDAY'),
|
|
getLanguageText('TEXT-TUESDAY'),
|
|
getLanguageText('TEXT-WEDNESDAY'),
|
|
getLanguageText('TEXT-THURSDAY'),
|
|
getLanguageText('TEXT-FRIDAY'),
|
|
getLanguageText('TEXT-SATURDAY')
|
|
);
|
|
|
|
writeLog("firstMenuDate: $firstMenuDate");
|
|
writeLog("lastMenuDate: $lastMenuDate");
|
|
|
|
$firstDateTime = strtotime($firstMenuDate);
|
|
$lastDateTime = strtotime($lastMenuDate);
|
|
|
|
$firstCalendarMonth = date("n",$firstDateTime);
|
|
$lastCalendarMonth = date("n",$lastDateTime);
|
|
|
|
$currYear = date("Y",$firstMenuDate);
|
|
$currMonth = $firstCalendarMonth;
|
|
$currMonthDate = date("Y-m-01",$firstDateTime);
|
|
$currDateTime = $firstDateTime;
|
|
|
|
$currMonthYear = date("Y-m",$firstDateTime);
|
|
$lastMonthYear = date("Y-m",$lastDateTime);
|
|
|
|
$monthBreak = true;
|
|
if ($calendar_month_breaks != 'Y') $monthBreak = false;
|
|
if ($school_num == 18493 || $school_num == 18494) $monthBreak = false;
|
|
|
|
$monthNum = 1;
|
|
$monthSpanned = false;
|
|
|
|
$EventCount = 0;
|
|
$query = "select count(*) " .
|
|
"from event_calendar " .
|
|
"where school_num = $school_num " .
|
|
"and status = 'Approved' " .
|
|
"and display = 'Active' " .
|
|
"and start_date <= '$firstMenuDate' and '$lastMenuDate' <= end_date";
|
|
$EventCount = db_getVal($query);
|
|
|
|
$RegularMenus = array();
|
|
$query = "SELECT menu_date,record_num FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_type = 'Regular' " .
|
|
"ORDER BY sequence,menu_date";
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$RegularMenus[$row['menu_date']][] = $row['record_num'];
|
|
}
|
|
|
|
while ($currMonthYear <= $lastMonthYear) {
|
|
$currMonthTime = strtotime("$currMonthYear-01");
|
|
$currMenuDate = date("Y-m-d",$currMonthTime);
|
|
$futureMenuDates = db_getVal("SELECT count(*) FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_date >= '$currMenuDate' " .
|
|
"AND menu_type = 'Regular'");
|
|
|
|
if ($futureMenuDates == 0 && $monthBreak == false) break;
|
|
|
|
$monthTitle = date("F Y",$currMonthTime);
|
|
|
|
$cols = 7;
|
|
$colwidth = '14%';
|
|
if ($menu_display_mode == 'Calendar No Weekends') {
|
|
$cols = 5;
|
|
$colwidth = '20%';
|
|
}
|
|
|
|
if ($monthBreak == false) $monthTitle = $schedule_name;
|
|
|
|
if ($monthBreak || $monthNum == 1) {
|
|
?>
|
|
<table width='99%' cellpadding='1' cellspacing='1' border='0' class='content-table'>
|
|
<tr>
|
|
<td colspan='<?php echo($cols) ?>' align='center' class='menudate-header'><?php echo($monthTitle) ?></td>
|
|
</tr>
|
|
<?php
|
|
|
|
// Display day of week heading
|
|
echo(" <tr>\n");
|
|
for ($dow = 0; $dow < 7; $dow++) {
|
|
$dayOfWeek = $dayNames[$dow];
|
|
|
|
if ($menu_display_mode == 'Calendar No Weekends' && ($dow == 0 || $dow == 6)) continue;
|
|
?>
|
|
<td width='<?php echo($colwidth) ?>' align='center' class='menudate-header'><?php echo($dayOfWeek) ?></td>
|
|
<?php
|
|
}
|
|
echo(" </tr>\n");
|
|
}
|
|
|
|
$monthNum++;
|
|
|
|
// Display calendar dates
|
|
$startDOW = date("w",$currMonthTime);
|
|
$currCalendarDateTime = $currMonthTime - $startDOW * 60 * 60 * 24 + 60 * 60 * 2;
|
|
|
|
$startWeek = 0;
|
|
if ($monthSpanned) {
|
|
$startWeek = 1;
|
|
$currCalendarDateTime += 60 * 60 * 24 * 7;
|
|
if (date("d",$currCalendarDateTime) > '07') $currCalendarDateTime = $currMonthTime - 7 * 60 * 60 * 24 + 60 * 60 * 2;
|
|
}
|
|
$monthSpanned = false;
|
|
|
|
|
|
for ($Week = $startWeek; $Week <= 6; $Week++) {
|
|
if ($currCalendarDateTime >= $lastDateTime) {
|
|
$Week = 7;
|
|
$currMonthYear = $lastMonthYear + 1;
|
|
$currMonthTime = $lastDateTime;
|
|
break;
|
|
}
|
|
|
|
// Check if there are any menus this week
|
|
if ($menu_display_mode == 'Calendar No Weekends') {
|
|
$menusThisWeek = false;
|
|
$wtime = $currCalendarDateTime;
|
|
for ($dow = 0; $dow < 7; $dow++) {
|
|
$menu_date = date("Y-m-d",$wtime);
|
|
if (date("n",$wtime) != date("n",$currMonthTime)) {
|
|
$wtime = strtotime(date("Y-m-d",$wtime + 60 * 60 * 25));
|
|
continue;
|
|
}
|
|
|
|
$query = "SELECT record_num FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_date = '$menu_date' " .
|
|
"AND menu_type = 'Regular' " .
|
|
"ORDER BY sequence,menu_date LIMIT 0,1";
|
|
$menu_num = db_getVal($query);
|
|
if (isset($menu_num)) {
|
|
writeLog("menu_num: $menu_num");
|
|
writeLog("MenuDates[$menu_num]['menu_date']: " .$MenuDates[$menu_num]['menu_date']);
|
|
if ($MenuDates[$menu_num]['menu_date'] == $menu_date) $menusThisWeek = true;
|
|
}
|
|
$wtime = strtotime(date("Y-m-d",$wtime + 60 * 60 * 25));
|
|
}
|
|
if (!$menusThisWeek) {
|
|
$currCalendarDateTime = $wtime;
|
|
if (date("n",$currCalendarDateTime) > date("n",$currMonthTime)) break;
|
|
if (date("Y",$currCalendarDateTime) > date("Y",$currMonthTime)) break;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
echo(" <tr height='100'>\n");
|
|
for ($dow = 0; $dow < 7; $dow++) {
|
|
if ($menu_display_mode == 'Calendar No Weekends' && ($dow == 0 || $dow == 6)) {
|
|
$currCalendarDateTime = strtotime(date("Y-m-d",$currCalendarDateTime + 60 * 60 * 25));
|
|
continue;
|
|
}
|
|
|
|
$currCalendarDate = dateString('shortdate',$currCalendarDateTime);
|
|
$menu_date = date("Y-m-d",$currCalendarDateTime);
|
|
|
|
$tdclass = "calendar-date";
|
|
$dtclass = "caldate";
|
|
$currMonthFlag = true;
|
|
if (date("n",$currCalendarDateTime) != date("n",$currMonthTime)) {
|
|
if ($monthBreak) {
|
|
$tdclass = "non-current-date";
|
|
$dtclass = "noncaldate";
|
|
$currMonthFlag = false;
|
|
}
|
|
else {
|
|
$monthSpanned = true;
|
|
if ($menu_display_mode == 'Calendar') $Week = 0;
|
|
}
|
|
}
|
|
else {
|
|
if (date("Y-m-d",$currCalendarDateTime) < date("Y-m-d",time())) {
|
|
$tdclass .= " calendar-date-past";
|
|
}
|
|
}
|
|
|
|
// Display calendar cell
|
|
echo(" <td width='$colwidth' align='left' valign='top' class='$tdclass'><span class='$dtclass'>$currCalendarDate</span><br>\n");
|
|
|
|
// Check event calendar for events on this date
|
|
if ($school_record['system_configuration'] == 'Full' && $EventCount > 0) {
|
|
$query = "select ec.* " .
|
|
"from event_calendar as ec, event_types as et " .
|
|
"where ec.school_num = $school_num " .
|
|
"and et.school_num = $school_num " .
|
|
"and ec.event_type = et.event_type_title " .
|
|
"and et.display_on_order_form = 'Y' " .
|
|
"and ec.status = 'Approved' " .
|
|
"and ec.display = 'Active' " .
|
|
"and start_date <= '$menu_date' and '$menu_date' <= end_date " .
|
|
"order by start_date,end_date,title";
|
|
$events = db_query($query);
|
|
|
|
if (db_num_rows($events)) {
|
|
while ($row = db_fetch_array($events)) {
|
|
// Handle event type colors
|
|
$sspan = "";
|
|
$espan = "";
|
|
|
|
$event_type = $row['event_type'];
|
|
$results = db_query("SELECT * FROM event_types WHERE school_num = $school_num AND event_type_title = '" . db_escape_string($event_type) . "'");
|
|
if (db_num_rows($results) > 0) {
|
|
$erow = db_fetch_array($results);
|
|
$sspan = "<span style='color: #" . $erow['text_color'] . "; background-color: #" . $erow['bg_color'] . ";'>";
|
|
$espan = "</span>";
|
|
}
|
|
echo("<span class='calitem'>$sspan" . $row['title'] . "$espan</span><br>");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$menuDate = $menu_date;
|
|
$query = "SELECT record_num,menu_link,current_menu_link FROM hotlunch_menu_dates " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_date = '$menu_date' " .
|
|
"AND menu_type = 'Regular' " .
|
|
"ORDER BY sequence,menu_date";
|
|
writeLog($query);
|
|
$menu_dates = db_query($query);
|
|
while ($row = db_fetch_assoc($menu_dates)) {
|
|
$menu_num = $row['record_num'];
|
|
$mLink = $row['menu_link'];
|
|
$mLink = $row['current_menu_link'];
|
|
if ($currMonthFlag && $MenuDates[$menu_num]['menu_date'] == $menu_date) {
|
|
extract($MenuDates[$menu_num]);
|
|
|
|
// Display menu items for current date
|
|
if (count($MenuItems)) {
|
|
|
|
$qclass = "";
|
|
$tclass = "";
|
|
if ($menu_active == 'N') {
|
|
$qclass = " calitem-past";
|
|
$tclass = 'menudate-past';
|
|
}
|
|
|
|
$ext = "";
|
|
if (($mLink == 'Paper' && $source == 'Paper') || $mLink == 'All') $tclass = 'menudate-linked';
|
|
if (strlen($menu_title) && $schedule_record['display_menu_title'] == 'Y') echo("<span class='caltext menu-title $tclass'><b>$menu_title</b> $ext</span>\n");
|
|
if (strlen($menu_instructions) > 0) {
|
|
echo("<span class='caltext menu-instructions warning'>" . nl2br($menu_instructions) . "</span>\n");
|
|
}
|
|
|
|
echo(" <table width='100%' cellpadding='0' cellspacing='1'>\n");
|
|
for ($i = 0; $i < count($MenuItems); $i++) {
|
|
extract($MenuItems[$i]);
|
|
|
|
if ($item_type != 'Heading') {
|
|
$item_price_info = "";
|
|
if ($schedule_record['display_item_price'] == 'Y' && $display_price != 'N') $item_price_info = "<br> -- <span class='cal-item-price'>$currencySymbol".number_format($item_price,2)."</span>";
|
|
|
|
$display_title = $label_title;
|
|
|
|
$ItemTitle = str_replace('"',""",$item_title);
|
|
|
|
?>
|
|
<tr<?php echo($itemStyle) ?> class='<?php echo($heading_class) ?>'>
|
|
<td width='90%' align='left' valign='top' class='oitem calitem<?php echo($qclass) ?>'><?php echo("$display_title$item_availability$item_price_info") ?></td>
|
|
<td width='10%' align='center' valign='top' class='oitem calitem<?php echo($qclass) ?>'><?php echo($qfield) ?>
|
|
<input type='hidden' name='<?php echo($pricefield) ?>' value='<?php echo($item_price) ?>'>
|
|
<input type='hidden' name='<?php echo($linetotal) ?>' id='<?php echo($linetotal) ?>' value='<?php echo($line_total) ?>'>
|
|
<input type='hidden' name='<?php echo($linecount) ?>' id='<?php echo($linecount) ?>' value='<?php echo($qtyvalue) ?>'>
|
|
<input type='hidden' name='<?php echo($minqty) ?>' id='<?php echo($minqty) ?>' value='<?php echo($min_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($warnqty) ?>' id='<?php echo($warnqty) ?>' value='<?php echo($warn_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($maxqty) ?>' id='<?php echo($maxqty) ?>' value='<?php echo($max_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($maxqty_by) ?>' id='<?php echo($maxqty_by) ?>' value='<?php echo($max_quantity_by) ?>'>
|
|
<input type='hidden' name='<?php echo($family_qty) ?>' id='<?php echo($family_qty) ?>' value='<?php echo($family_quantity) ?>'>
|
|
<input type='hidden' name='item_title_<?php echo($item_num) ?>' id='item_title_<?php echo($item_num) ?>' value="<?php echo($ItemTitle) ?>">
|
|
<?php echo($options_code) ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
else {
|
|
if ($schedule_record['display_menu_headings'] == 'Y') {
|
|
?>
|
|
<tr<?php echo($itemStyle) ?>>
|
|
<td colspan='2' align='left' valign='middle' class='menudate-subheader caltext'>
|
|
<?php
|
|
if (strlen($item_title)) {
|
|
echo("$item_title");
|
|
if (strlen($description)) echo("<br>\n");
|
|
}
|
|
?>
|
|
<?php if (strlen($description)) echo("<span class='item-description'>$description</span>"); ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
}
|
|
|
|
if (count($MenuVolunteers) > 0) {
|
|
extract($MenuVolunteers);
|
|
|
|
if (strlen($volunteerMessage) > 0) {
|
|
if ($numRegistered < $maxVolunteers || $vnum > 0) {
|
|
$vfont = $school_record['volunteer_msg_font'];
|
|
$vcolor = $school_record['volunteer_msg_color'];
|
|
if (strlen($vfont)) $vfont = " style='font: $vfont;'";
|
|
if (strlen($vcolor)) $vcolor = " style='background: #$vcolor;'";
|
|
?>
|
|
<tr<?php echo($rowStyle) ?>>
|
|
<td align='left' valign='top' class='signup'<?php echo($vcolor) ?>>
|
|
<span class='signup-text caltext'<?php echo($vfont) ?>><b><?php echo(nl2br($volunteerMessage)) ?></b></span>
|
|
</td>
|
|
<td align='center' valign='top' class='signup'<?php echo($vcolor) ?>><?php echo($vField) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($item_count > 0) {
|
|
extract($MenuTotals);
|
|
?>
|
|
<tr>
|
|
<td align='right' colspan='2' class='oitem calitem'><b><?php displayLanguageText('TEXT-SUBTOTAL'); ?>: </b> <b> <span id='<?php echo($menuspan) ?>'><?php echo($school_record['currency_symbol'] . $menu_total) ?></span></b>
|
|
<input type='hidden' name='<?php echo($menutotal) ?>' id='<?php echo($menutotal) ?>' value='<?php echo(trimNumber($menu_total)) ?>'>
|
|
<input type='hidden' name='<?php echo($menucount) ?>' id='<?php echo($menucount) ?>' value='<?php echo(trimNumber($menu_count)) ?>'>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
echo(" </table>\n");
|
|
}
|
|
else {
|
|
echo(" <table width='100%' cellpadding='0' cellspacing='1'>\n");
|
|
echo(" <tr><td class='caltext menudate-noitems'>$menu_title</td></tr>\n");
|
|
echo(" </table>\n");
|
|
// echo("<span class='caltext menudate-noitems'><b>$menu_title</b></span><br>\n");
|
|
}
|
|
}
|
|
}
|
|
|
|
echo(" </td>\n");
|
|
$currCalendarDateTime = strtotime(date("Y-m-d",$currCalendarDateTime + 60 * 60 * 25));
|
|
}
|
|
echo(" </tr>\n");
|
|
|
|
if (date("n",$currCalendarDateTime) > date("n",$currMonthTime)) {
|
|
if ($monthBreak) break;
|
|
else $monthSpanned = true;
|
|
}
|
|
if (date("Y",$currCalendarDateTime) > date("Y",$currMonthTime)) break;
|
|
}
|
|
|
|
|
|
if ($monthBreak) {
|
|
?>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
$prevMonthYear = $currMonthYear;
|
|
|
|
$currMonthTime += 32 * 24 * 60 * 60;
|
|
$currMonthYear = date("Y-m",$currMonthTime);
|
|
$currMonthTime = strtotime("$currMonthYear-01");
|
|
}
|
|
|
|
if (!$monthBreak) {
|
|
?>
|
|
</table>
|
|
<br>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
|
|
// Check for Footer menu dates
|
|
$FooterMenus = db_query("SELECT * FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num AND menu_type != 'Regular' ORDER BY sequence");
|
|
$displayFooterMenus = false;
|
|
if (db_num_rows($FooterMenus) > 0) {
|
|
$displayFooterMenus = true;
|
|
}
|
|
|
|
|
|
//
|
|
// Display menu form
|
|
//
|
|
if ($menu_display_mode == 'Form' || $displayFooterMenus) {
|
|
?>
|
|
<table width='90%' cellpadding='1' cellspacing='1' border='0'>
|
|
<?php
|
|
|
|
foreach ($MenuDates as $menu_num => $val) {
|
|
extract($MenuDates[$menu_num]);
|
|
|
|
// If displaying Footer menus do not display regular menus
|
|
if ($menu_display_mode != 'Form' && $displayFooterMenus && $menu_type == 'Regular') continue;
|
|
|
|
?>
|
|
<tr<?php echo($rowStyle) ?>>
|
|
<td align='center' colspan='4' class='<?php echo($tclass) ?>'>
|
|
<table width='100%' cellspacing='0' cellpadding='0' border='0'>
|
|
<tr>
|
|
<td align='left' class='<?php echo($tclass) ?> menu-heading'><?php echo(str_replace('\\','',$menu_title)) ?></td>
|
|
<?php if ($display_menu_date == 'Y' && $menu_type != 'Footer') { ?>
|
|
<td align='right' class='<?php echo($tclass) ?> menu-heading'><nobr><?php echo(date("l F jS, Y",strtotime($menu_date))) ?></nobr></td>
|
|
<?php } ?>
|
|
</tr>
|
|
</table>
|
|
<?php if (strlen($menu_instructions) > 0) { ?>
|
|
<table width='100%' cellspacing='0' cellpadding='3' border='0'>
|
|
<tr>
|
|
<td align='center' class='instructions'><span class='instructions-text'><?php echo(nl2br($menu_instructions)) ?></span></td>
|
|
</tr>
|
|
</table>
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
|
|
//
|
|
// Display menu items for current date
|
|
//
|
|
$priceVal = false;
|
|
for ($i = 0; $i < count($MenuItems); $i++) {
|
|
extract($MenuItems[$i]);
|
|
|
|
if ($item_type != 'Heading') {
|
|
$item_title = "<b>$item_title</b>";
|
|
if ($item_price != 0.00) $priceVal = true;
|
|
|
|
$priceSpan = "<span>";
|
|
$qcolSpan = 1;
|
|
if ($schedule_prices == 'N') {
|
|
$priceSpan = "<span style='visibility: hidden'>";
|
|
$qcolSpan = 3;
|
|
}
|
|
|
|
$readonlyflag = "";
|
|
if (strlen($readonly)) $readonlyflag = "readonly";
|
|
|
|
?>
|
|
<tr<?php echo($itemStyle) ?> class='<?php echo($heading_class) ?>'>
|
|
<td width='80%' align='left' valign='top' class='oitem'><?php echo("<span class='item-title' rflag='$readonlyflag' code='$curr_code' mcode='$menu_code'>$item_title</span>$item_availability$rating_image") ?><?php echo($nutrition_image) ?><?php echo("$image_link$item_description$options_code") ?></td>
|
|
<td width='4%' colspan='<?php echo($qcolSpan) ?>' align='right' valign='top' class='oitem'><?php echo($qfield) ?></td>
|
|
<?php if ($schedule_prices != 'N') { ?>
|
|
<td width='8%' align='right' valign='top' class='oitem'><nobr><span class='item-price' <?php echo("rflag='$readonlyflag' code='$curr_code' mcode='$menu_code'"); ?>><?php echo($priceSpan) ?><?php echo($item_price_d) ?></span></span></nobr></td>
|
|
<td width='12%' align='right' valign='top' class='oitem'><?php echo($priceSpan) ?><span id='<?php echo($linespan) ?>'>
|
|
<?php
|
|
if ($line_total != '0') {
|
|
echo($school_record['currency_symbol'] . $line_total);
|
|
}
|
|
else {
|
|
echo("<img src='images/spacer.gif' width='35' height='1'>");
|
|
}
|
|
?></span></span>
|
|
<?php } else { ?>
|
|
<span style='visibility: hidden' id='<?php echo($linespan) ?>'></span>
|
|
<?php } ?>
|
|
<input type='hidden' name='<?php echo($pricefield) ?>' value='<?php echo($item_price) ?>'>
|
|
<input type='hidden' name='<?php echo($linetotal) ?>' id='<?php echo($linetotal) ?>' value='<?php echo($line_total) ?>'>
|
|
<input type='hidden' name='<?php echo($linecount) ?>' id='<?php echo($linecount) ?>' value='<?php echo($qtyvalue) ?>'>
|
|
<input type='hidden' name='<?php echo($minqty) ?>' id='<?php echo($minqty) ?>' value='<?php echo($min_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($warnqty) ?>' id='<?php echo($warnqty) ?>' value='<?php echo($warn_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($maxqty) ?>' id='<?php echo($maxqty) ?>' value='<?php echo($max_quantity) ?>'>
|
|
<input type='hidden' name='<?php echo($maxqty_by) ?>' id='<?php echo($maxqty_by) ?>' value='<?php echo($max_quantity_by) ?>'>
|
|
<input type='hidden' name='<?php echo($family_qty) ?>' id='<?php echo($family_qty) ?>' value='<?php echo($family_quantity) ?>'>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
else {
|
|
$control = "<span hnum='$item_num' mode='visible' id='header-$item_num' class='header-controls'>[hide]</span>";
|
|
if ($heading_visibility == 'hidden') {
|
|
$control = "<span hnum='$item_num' mode='hidden' id='header-$item_num' class='header-controls'>[show]</span>";
|
|
}
|
|
?>
|
|
<tr height='25'<?php echo($rowStyle) ?> class='menu-subheading'>
|
|
<td colspan='4' width='100%' align='left' valign='middle' class='menudate-subheader'>
|
|
<?php
|
|
if (strlen($item_title)) echo("-- $item_title -- $control");
|
|
echo($item_description);
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
if ($item_count > 0) {
|
|
extract($MenuTotals);
|
|
|
|
$currRowStyle = $rowStyle;
|
|
if ($priceVal == false) $currRowStyle = " class='invisible'";
|
|
|
|
?>
|
|
<tr<?php echo($currRowStyle) ?>>
|
|
<td colspan='3'> </td>
|
|
<td align='right' class='oitem'><span id='<?php echo($menuspan) ?>'><?php if ($menu_total > 0.00) echo($school_record['currency_symbol'] . $menu_total) ?></span>
|
|
<input type='hidden' name='<?php echo($menutotal) ?>' id='<?php echo($menutotal) ?>' value='<?php echo(trimNumber($menu_total)) ?>'>
|
|
<input type='hidden' name='<?php echo($menucount) ?>' id='<?php echo($menucount) ?>' value='<?php echo(trimNumber($menu_count)) ?>'>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
if (count($MenuVolunteers) > 0) {
|
|
extract($MenuVolunteers);
|
|
|
|
if (strlen($volunteerMessage) > 0) {
|
|
if ($numRegistered < $maxVolunteers || $vnum > 0) {
|
|
$vfont = $school_record['volunteer_msg_font'];
|
|
$vcolor = $school_record['volunteer_msg_color'];
|
|
if (strlen($vfont)) $vfont = " style='font: $vfont;'";
|
|
if (strlen($vcolor)) $vcolor = " style='background: #$vcolor;'";
|
|
?>
|
|
<tr<?php echo($rowStyle) ?>>
|
|
<td align='center' colspan='4'>
|
|
<table width='100%' cellspacing='0' cellpadding='3' border='0'>
|
|
<tr>
|
|
<td align='left' valign='top' class='signup'<?php echo($vcolor) ?>>
|
|
<span class='signup-text'<?php echo($vfont) ?>><b><?php echo(nl2br($volunteerMessage)) ?></b></span>
|
|
</td>
|
|
<td align='center' valign='top' class='signup'<?php echo($vcolor) ?>><?php echo($vField) ?></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<tr<?php echo($rowStyle) ?>>
|
|
<td colspan='4'> </td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
|
|
$ordersubtotal = $ordertotal;
|
|
if ($discount_amount > 0) $ordertotal = $ordertotal - $discount_amount;
|
|
|
|
|
|
// Table for footer fields and buttons
|
|
?>
|
|
<table width='90%' cellpadding='1' cellspacing='1' border='0'>
|
|
<?php
|
|
|
|
if ($implement_order_notes == 'Y') {
|
|
?>
|
|
<tr>
|
|
<td colspan='2' align='left' class='oitem'>
|
|
<b><?php echo($order_notes_message) ?>::</b><br>
|
|
<?php
|
|
if ($form_edit_mode == "edit") {
|
|
?>
|
|
<textarea name='order_notes' rows='2' cols='100'><?php echo($order_notes) ?></textarea>
|
|
<?php
|
|
}
|
|
else {
|
|
echo(nl2br($order_notes));
|
|
}
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2'> </td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
if ($implement_order_notes2 == 'Y') {
|
|
?>
|
|
<tr>
|
|
<td colspan='2' align='left' class='oitem'>
|
|
<b><?php echo($order_notes_message2) ?>::</b><br>
|
|
<?php
|
|
if ($form_edit_mode == "edit") {
|
|
?>
|
|
<textarea name='order_notes2' rows='2' cols='100'><?php echo($order_notes2) ?></textarea>
|
|
<?php
|
|
}
|
|
else {
|
|
echo(nl2br($order_notes2));
|
|
}
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan='2'> </td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
<?php if ($apply_late_charge == 'Y' && $_SESSION['UserInfo']['type'] != 'Parent' && $_SESSION['UserInfo']['type'] != 'Staff') { ?>
|
|
<tr>
|
|
<td align='right' class='oitem'><b><?php displayLanguageText('TEXT-APPLY-LATE-CHARGE'); ?> $<?php echo($late_charge) ?>:: </b></td>
|
|
<td align='center' class='oitem'><input type='checkbox' name='apply_late_charge' value='Y' checked='checked'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($numDiscounts > 0) { ?>
|
|
<tr>
|
|
<td align='right' class='oitem'><b><?php displayLanguageText('TEXT-DISCOUNT'); ?>: </b></td>
|
|
<td align='right' class='oitem'><span id='discountspan'><?php if ($discount_amount > 0) echo($school_record['currency_symbol'] . number_format($discount_amount,2)) ?></span></td>
|
|
<input type='hidden' name='discount_amount' id='discount_amount' value='<?php echo(trimNumber($discount_amount)) ?>'></td>
|
|
</tr>
|
|
<?php } ?>
|
|
<?php if ($schedule_prices != 'N') { ?>
|
|
<tr>
|
|
<td width='92%' align='right' class='oitem'><b><?php displayLanguageText('TEXT-ORDER-TOTAL'); ?>: </b></td>
|
|
<td width='8%' align='right' class='oitem'><span id='orderspan'><?php if ($ordertotal > 0.00) echo($school_record['currency_symbol'] . number_format($ordertotal,2)) ?></span></td>
|
|
</tr>
|
|
<?php } ?>
|
|
</table>
|
|
<span id='orderspan' style='visibility: hidden'></span>
|
|
<input type='hidden' name='ordersubtotal' id='ordersubtotal' value='<?php echo(trimNumber($ordersubtotal)) ?>'>
|
|
<input type='hidden' name='ordertotal' id='ordertotal' value='<?php echo(trimNumber($ordertotal)) ?>'>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<?php
|
|
// Display schedule documents
|
|
$schedule_docs = db_query("SELECT d.* FROM hotlunch_schedules_documents AS hlsd, documents AS d " .
|
|
"WHERE hlsd.school_num = $school_num " .
|
|
"AND hlsd.schedule_num = $schedule_num " .
|
|
"AND hlsd.document_num = d.record_num " .
|
|
"ORDER BY sequence");
|
|
if (db_num_rows($schedule_docs)) {
|
|
$view_icon = "<img src='images/icons/filesearch24.png' alt='View Document' border='0'>";
|
|
$startTable = " <table width='50%' cellpadding='0' cellspacing='1' class='content-table'>\n";
|
|
$numDocs = 0;
|
|
|
|
while ($row = db_fetch_array($schedule_docs)) {
|
|
$doc_num = $row['record_num'];
|
|
|
|
$query = "select * from documents " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $doc_num";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results)) {
|
|
$r = db_fetch_array($results);
|
|
$fname = $r['file_name'];
|
|
|
|
$doc_title = "<b>" . $row['title'] . "</b>";
|
|
if (strlen($row['description'])) $doc_title .= "<br>\n" . $row['description'];
|
|
|
|
$link = "<a href='view-doc.php?dnum=$doc_num'>$view_icon</a>";
|
|
echo($startTable);
|
|
echo(" <tr>\n");
|
|
echo(" <td width='90%' class='oitem' align='left' valign='top'>$doc_title</td>\n");
|
|
echo(" <td class='oitem' align='center' valign='top'>$link</td>\n");
|
|
echo(" </tr>\n");
|
|
|
|
$startTable = "";
|
|
$numDocs++;
|
|
}
|
|
}
|
|
|
|
if ($numDocs > 0) {
|
|
echo(" </table>\n");
|
|
echo(" <br>\n");
|
|
}
|
|
}
|
|
|
|
|
|
if ($form_edit_mode == "edit") {
|
|
if (isset($defaultOrder)) {
|
|
$classes = db_query("SELECT * FROM classes WHERE school_num = $base_school_num ORDER BY sequence");
|
|
$numRows = db_num_rows($classes);
|
|
if ($numRows > 10) $numRows = 10;
|
|
?>
|
|
<select name='selected_classes[]' multiple size='<?php echo($numRows) ?>'>
|
|
<?php
|
|
while ($row = db_fetch_assoc($classes)) {
|
|
$classInfo = getClassInfo($row['record_num']);
|
|
echo("<option value='".$row['record_num']."'>$classInfo</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
<br>
|
|
<br>
|
|
<?php
|
|
}
|
|
?>
|
|
<table cellpadding='5' cellspacing='2' border='0'>
|
|
<tr>
|
|
<td align='center'><input type='submit' id='submit_button' class='btn btn--primary' tabindex=<?php echo($tabindex) ?> value="<?php echo($ButtonText) ?>"></td>
|
|
<?php if (isset($ordered_by_num)) { ?>
|
|
<td align='center'><a href='/' class='btn btn--primary>'><?php displayLanguageText('TEXT-CANCEL-CHANGES'); ?></a></td>
|
|
<?php } else { ?>
|
|
<td align='center'><a href='/' class='btn btn--primary>'><?php displayLanguageText('TEXT-CANCEL-ORDER'); ?></a></td>
|
|
<?php } ?>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='<?php echo($action) ?>'>
|
|
<input type='hidden' name='naction' value='<?php echo($next_naction) ?>'>
|
|
<input type='hidden' name='paction' value='<?php echo($paction) ?>'>
|
|
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
|
<input type='hidden' name='student_num' id='student_num' value=''>
|
|
<input type='hidden' name='people_type' id='people_type' value=''>
|
|
<input type='hidden' name='existing_user_num' id='user_num' value=''>
|
|
<?php if ($_SESSION['UserInfo']['type'] == 'Parent' || $_SESSION['UserInfo']['type'] == 'Staff') { ?>
|
|
<input type='hidden' name='apply_late_charge' id='apply_late_charge' value='<?php echo($apply_late_charge) ?>'>
|
|
<?php } ?>
|
|
<?php if (isset($source)) { ?>
|
|
<input type='hidden' name='source' id='source' value='<?php echo($source) ?>'>
|
|
<?php } ?>
|
|
<?php if (isset($defaultOrder)) { ?>
|
|
<input type='hidden' name='defaultOrder' id='defaultOrder' value='<?php echo($defaultOrder) ?>'>
|
|
<?php } ?>
|
|
<?php if (isset($ordered_by_num)) { ?>
|
|
<input type='hidden' name='ordered_by_num' value='<?php echo($ordered_by_num) ?>'>
|
|
<input type='hidden' name='ordered_by_name' value='<?php echo($name) ?>'>
|
|
<input type='hidden' name='ordered_by_type' value='<?php echo($ordered_by_type) ?>'>
|
|
<input type='hidden' name='order_num' value='<?php echo($order_num) ?>'>
|
|
<input type='hidden' name='source' value='<?php echo($source) ?>'>
|
|
<input type='hidden' name='price_category' value='<?php echo($menu_price_category) ?>'>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
<br>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
</form>
|
|
|
|
<?php
|
|
// Include search and lookup code
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team');
|
|
if (checkPermission($AllowedUserTypes) == 1) include "hotlunch_orders.print_buttons.php";
|
|
?>
|
|
|
|
<script language="JavaScript">
|
|
|
|
<?php echo($global_code) ?>
|
|
|
|
<?php
|
|
if ($linked_items == 'Y') {
|
|
?>
|
|
// Function to update the linked menu dates
|
|
function updateLinkedItems(code) {
|
|
<?php echo($menu_items_code) ?>
|
|
}
|
|
|
|
// Function to update all linked items
|
|
function updateAllLinkedItems() {
|
|
<?php echo($all_menu_items_code) ?>
|
|
}
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
// Function to validate the quantities based on the group rules
|
|
function groupCheck(code, mcode) {
|
|
|
|
<?php echo($group_check_code) ?>
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
// Function to validate the menu options
|
|
function checkOptions(code, mcode, sname) {
|
|
<?php // if ($_SESSION['UserInfo']['type'] == 'SuperUser' || $user_ip == "23.16.142.243") echo("alert('checkOptions');"); ?>
|
|
|
|
<?php echo($menu_options_code) ?>
|
|
|
|
updateLine(code, mcode,'Y','Y');
|
|
return true;
|
|
}
|
|
|
|
<?php if ($numDiscounts > 0) { ?>
|
|
|
|
// Function to calculate form discounts
|
|
function calculateDiscount(ordersubtotal) {
|
|
|
|
var groupQtyTotal = 0;
|
|
var discountRate = 0;
|
|
var discountAmt = 0;
|
|
|
|
<?php
|
|
foreach ($groupQtyFields as $groupCode => $val) {
|
|
echo(" // Calculate the discount amount for group '$groupCode'\n");
|
|
echo(" groupQtyTotal = 0;\n");
|
|
$fields = explode(" ",trim($val));
|
|
for ($i = 0; $i < count($fields); $i++) {
|
|
$field = $fields[$i];
|
|
echo(" if (document.getElementById('$field').value) groupQtyTotal = groupQtyTotal + parseInt(document.getElementById('$field').value);\n");
|
|
}
|
|
echo("\n");
|
|
|
|
$results = db_query("SELECT * FROM hotlunch_schedules_discounts " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_num = $schedule_num " .
|
|
"AND menu_group = '$groupCode' " .
|
|
"AND (expiry_date IS NULL OR expiry_date >= '$today') " .
|
|
"ORDER BY order_quantity");
|
|
while ($row = db_fetch_array($results)) {
|
|
extract($row);;
|
|
if ($discount_percentage > 0 && $discount_amount == 0) echo(" if (groupQtyTotal >= $order_quantity) discountRate = $discount_percentage;\n");
|
|
if ($discount_amount > 0 && $discount_percentage == 0) echo(" if (groupQtyTotal >= $order_quantity) discountAmt = $discount_amount;\n");
|
|
}
|
|
}
|
|
?>
|
|
|
|
document.getElementById('discount_amount').value = 0;
|
|
document.getElementById('discountspan').innerHTML = formatCurrency(0);
|
|
if (discountRate > 0) {
|
|
discountAmount = ordersubtotal * discountRate / 100;
|
|
document.getElementById('discount_amount').value = discountAmount;
|
|
document.getElementById('discountspan').innerHTML = formatCurrency(discountAmount);
|
|
}
|
|
|
|
if (discountAmt > 0) {
|
|
document.getElementById('discount_amount').value = discountAmt;
|
|
document.getElementById('discountspan').innerHTML = formatCurrency(discountAmt);
|
|
}
|
|
}
|
|
|
|
<?php } ?>
|
|
|
|
// Function to validate the form data
|
|
function checkForm() {
|
|
var checkFormMissedDatesMessage = '';
|
|
var checkFormMissedOptionsMessage = '';
|
|
var actionMessage = "<?php displayLanguageText('MESSAGE-CONFIRM-ACTION'); ?>";
|
|
var noItemsMessage = "<?php displayLanguageText('MESSAGE-NO-ITEMS-SELECTED'); ?>";
|
|
var textMenus = "<?php displayLanguageText('TEXT-MENUS'); ?>";
|
|
var missedMenuCount = 0;
|
|
var maxMenuCount = 5;
|
|
|
|
// Check that any groups have been completed
|
|
<?php echo($group_complete_code) ?>
|
|
|
|
// Check that all menu dates have been entered
|
|
<?php echo($form_check_code) ?>
|
|
|
|
if (checkFormMissedDatesMessage.length > 0) {
|
|
var additionalMenus = missedMenuCount - maxMenuCount;
|
|
|
|
checkFormMissedDatesMessage = noItemsMessage+' '+missedMenuCount+' '+textMenus+':\n---------------------------------------------\n'+checkFormMissedDatesMessage;
|
|
if (additionalMenus > 0) {
|
|
checkFormMissedDatesMessage = checkFormMissedDatesMessage+'------ <?php displayLanguageText('TEXT-AND') ?> '+additionalMenus+' <?php displayLanguageText('TEXT-OTHER-MENUS') ?> ------\n';
|
|
}
|
|
checkFormMissedDatesMessage = checkFormMissedDatesMessage+'---------------------------------------------\n'+actionMessage;
|
|
var r1 = confirm(checkFormMissedDatesMessage);
|
|
if (r1 == false) return false;
|
|
}
|
|
|
|
if (checkFormMissedOptionsMessage.length > 0) {
|
|
// var r2 = confirm(checkFormMissedOptionsMessage);
|
|
// if (r2 == false) return false;
|
|
alert(checkFormMissedOptionsMessage);
|
|
return false;
|
|
}
|
|
|
|
document.getElementById('submit_button').disabled = true;
|
|
return true;
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function($) {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
var studentCellWidths = [150, 150, 105, 70];
|
|
for (i=0; i<studentCellWidths.length; i++) $('#studentResultsHead th').eq(i).css('width', studentCellWidths[i]);
|
|
|
|
var parentCellWidths = [110, 150, 215];
|
|
for (i=0; i<parentCellWidths.length; i++) $('#parentResultsHead th').eq(i).css('width', parentCellWidths[i]);
|
|
|
|
// Hide everything by default
|
|
var studentSearch = $('#new_last_name');
|
|
var studentResultsRow = $('#studentResultsRow').hide();
|
|
var studentResultsTable = $('#studentResultsTable');
|
|
var studentResultsScroll = $('#studentResultsScroll');
|
|
|
|
var selectedStudent = null;
|
|
var selectedParent = null;
|
|
|
|
var parentSearch = $('#new_parent_last_name');
|
|
var parentResultsRow = $('#parentResultsRow').hide();
|
|
var parentResultsTable = $('#parentResultsTable');
|
|
var parentResultsScroll = $('#parentResultsScroll');
|
|
|
|
// Handle typing in the student search box
|
|
studentSearch.keyup(function() {
|
|
var searchName = $(this).val();
|
|
if (searchName.length < 2) {
|
|
doStudentClick(null);
|
|
return;
|
|
}
|
|
var d = new Date();
|
|
searchName = escape(searchName);
|
|
$.getJSON('/ajaxSearchStudents.php',
|
|
{s:searchName, sn:<?php echo($school_num) ?>, bn:<?php echo($base_school_num) ?>, sch:<?php echo($schedule_num) ?>, d:d.getTime()},
|
|
updateStudentResults
|
|
);
|
|
});
|
|
|
|
function updateStudentResults(data) {
|
|
var row;
|
|
var radio;
|
|
|
|
if (data.length == 0) {
|
|
doStudentClick(null);
|
|
return;
|
|
}
|
|
|
|
// empty the results table, and rebuild it
|
|
studentResultsTable.empty();
|
|
|
|
// add the 'new student' row
|
|
row = $('<tr>');
|
|
row.append($('<td align=left colspan=4>').html('<b><i> - <?php displayLanguageText('TEXT-ENTER-A-NEW-STUDENT'); ?> - </i></b>')).addClass('newStudent');
|
|
studentResultsTable.append(row);
|
|
|
|
for (var i=0; i<data.length; i++) {
|
|
data[i]['name'] = unescape(data[i]['name']);
|
|
row = $('<tr>');
|
|
row.append($('<td align=left>').css('width', studentCellWidths[0]).html(decodeURIComponent( escape( data[i]['name'] ) )));
|
|
row.append($('<td align=left>').css('width', studentCellWidths[1]).html(data[i]['parent']==''?' ':unescape(decodeURIComponent( data[i]['parent'] ))));
|
|
row.append($('<td align=left>').css('width', studentCellWidths[2]).html(data[i]['phone']==''?' ':data[i]['phone']));
|
|
row.append($('<td align=center>').css('width', studentCellWidths[3]).html(data[i]['hasOrder']?'Yes':'No'));
|
|
if (data[i]['hasOrder']) {
|
|
row.addClass('hasOrder');
|
|
row.find('td').css('fontStyle','italic');
|
|
}
|
|
row.data('info', data[i]);
|
|
studentResultsTable.append(row);
|
|
}
|
|
|
|
// treat a click anywhere on the row as a click on the radio button
|
|
$('#studentResultsTable tr *').css('cursor','pointer').click(function() {
|
|
doStudentClick($(this).closest('tr'));
|
|
});
|
|
|
|
// display results, if the height > 150px, setup autoscroll
|
|
studentResultsScroll.css('overflow','visible').css('height', 'auto');
|
|
studentResultsRow.show();
|
|
if (studentResultsScroll.height() > 150) studentResultsScroll.css('overflow','auto').css('height', 150);
|
|
updateStudentValues(null, false);
|
|
$('#new_first_name').removeAttr('disabled').removeClass('disabled');
|
|
}
|
|
|
|
function doStudentClick(row) {
|
|
if (row == null) {
|
|
selectedStudent = null;
|
|
updateStudentValues(null, false);
|
|
doParentClick(null);
|
|
if (studentSearch.val() != '') $('#new_first_name').removeAttr('disabled').removeClass('disabled');
|
|
}
|
|
else if (row == 0 || row.hasClass('newStudent')) {
|
|
// entering a new student
|
|
selectedStudent = 0;
|
|
updateStudentValues(null, true);
|
|
$('#new_first_name')[0].focus();
|
|
$('#student_num').val(0);
|
|
parentSearch.val(studentSearch.val()).keyup();
|
|
}
|
|
else if (row.hasClass('hasOrder')) {
|
|
data = row.data('info');
|
|
if (confirm("<?php displayLanguageText('TEXT-EDIT-EXISTING-ORDER'); ?>")) {
|
|
location.href= '?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&student_num=' + data['record_num'];
|
|
}
|
|
}
|
|
else {
|
|
// clicked on a student
|
|
data = row.data('info');
|
|
if (data['price_category'] != 'Regular') location.href= '?action=orders&naction=edit&schedule_num=<?php echo($schedule_num) ?>&student_num=' + data['record_num'];
|
|
selectedStudent = data['record_num'];
|
|
updateStudentValues(data, false);
|
|
$('#student_num').val(data['record_num']);
|
|
$('#user_num').val(data['user']['record_num']);
|
|
$('#people_type').val(data['people_type']);
|
|
$('#new_last_name').val(data==null?'':unescape(decodeURIComponent( data['last_name'] )));
|
|
}
|
|
studentResultsRow.hide();
|
|
studentResultsTable.empty();
|
|
}
|
|
|
|
function updateStudentValues(data, enabled) {
|
|
if (data != null) studentSearch.val(data['last_name']);
|
|
$('#new_first_name').val(data==null?'':unescape(decodeURIComponent( data['first_name'] )));
|
|
$('#new_class_num').val(data==null?'':data['class_num']);
|
|
$('#age').val(data==null?'':unescape(data['age']));
|
|
$('#grade').val(data==null?'':unescape(data['grade']));
|
|
$('#sex').val(data==null?'':unescape(data['sex']));
|
|
$('#user_defined_value').val(data==null?'':unescape(data['user_defined_value']));
|
|
$('#new_parent_last_name').val(data==null?'':unescape(decodeURIComponent( data['user']['last_name'] )));
|
|
$('#new_parent_first_name').val(data==null?'':unescape(decodeURIComponent( data['user']['first_name'] )));
|
|
$('#new_email').val(data==null?'':data['user']['email']);
|
|
$('#new_phone').val(data==null?'':data['user']['home_phone']);
|
|
if (enabled) {
|
|
$('#new_first_name').removeAttr('disabled').removeClass('disabled');
|
|
$('#new_class_num').removeAttr('disabled').removeClass('disabled');
|
|
$('#new_parent_last_name').removeAttr('disabled').removeClass('disabled');
|
|
parentSearch.keyup();
|
|
}
|
|
else {
|
|
$('#contactInfoRow').hide();
|
|
parentResultsRow.hide();
|
|
parentResultsTable.empty();
|
|
}
|
|
}
|
|
|
|
$('#new_first_name').focus(function() {
|
|
if (selectedStudent == null) doStudentClick(0);
|
|
studentResultsRow.hide();
|
|
studentResultsTable.empty();
|
|
});
|
|
|
|
doStudentClick(null);
|
|
|
|
// Handle typing in the student search box
|
|
parentSearch.keyup(function() {
|
|
var searchName = $(this).val();
|
|
|
|
if (searchName.length < 2) {
|
|
doParentClick(null);
|
|
return;
|
|
}
|
|
var d = new Date();
|
|
searchName = escape(searchName);
|
|
$.getJSON('/ajaxSearchParents.php', {s:searchName, sn:<?php echo($base_school_num) ?>, sch:<?php echo($schedule_num) ?>, d:d.getTime()}, updateParentResults);
|
|
});
|
|
|
|
function updateParentResults(data) {
|
|
var row;
|
|
var radio;
|
|
|
|
if (data.length == 0) {
|
|
doParentClick(null);
|
|
return;
|
|
}
|
|
|
|
// empty the results table, and rebuild it
|
|
parentResultsTable.empty();
|
|
|
|
// add the 'new user' row
|
|
row = $('<tr>');
|
|
row.append($('<td align=left colspan=4>').html('<b><i> - Enter A New Parent - </i></b>')).addClass('newParent');
|
|
parentResultsTable.append(row);
|
|
|
|
for (var i=0; i<data.length; i++) {
|
|
row = $('<tr>');
|
|
row.append($('<td align=left>').css('width', parentCellWidths[0]).html(unescape(data[i]['account'])));
|
|
row.append($('<td align=left>').css('width', parentCellWidths[1]).html(data[i]['name']==''?' ':unescape(decodeURIComponent( data[i]['name'] ))));
|
|
row.append($('<td align=left>').css('width', parentCellWidths[2]).html(data[i]['email']==''?' ':data[i]['email']));
|
|
row.data('info', data[i]);
|
|
parentResultsTable.append(row);
|
|
}
|
|
// treat a click anywhere on the row as a click on the radio button
|
|
$('#parentResultsTable tr *').css('cursor','pointer').click(function() {
|
|
doParentClick($(this).closest('tr'));
|
|
});
|
|
|
|
// display results, if the height > 150px, setup autoscroll
|
|
parentResultsScroll.css('overflow','visible').css('height', 'auto');
|
|
parentResultsRow.show();
|
|
if (parentResultsScroll.height() > 150) parentResultsScroll.css('overflow','auto').css('height', 150);
|
|
updateParentValues(null, false);
|
|
$('#new_parent_first_name').removeAttr('disabled').removeClass('disabled');
|
|
}
|
|
|
|
function doParentClick(row) {
|
|
if (row == null) {
|
|
selectedParent = null;
|
|
updateParentValues(null, false);
|
|
if (parentSearch.val() != '') $('#new_parent_first_name').removeAttr('disabled').removeClass('disabled');
|
|
}
|
|
else if (row == 0 || row.hasClass('newParent')) {
|
|
// entering a new parent/user
|
|
selectedParent = 0;
|
|
updateParentValues(null, true);
|
|
$('#new_parent_first_name')[0].focus();
|
|
$('#user_num').val(0);
|
|
} else {
|
|
// clicked on a user
|
|
data = row.data('info');
|
|
selectedParent = data['record_num'];
|
|
updateParentValues(data, false);
|
|
$('#user_num').val(data['record_num']);
|
|
$('#new_parent_last_name').val(data==null?'':unescape(data['last_name']));
|
|
}
|
|
parentResultsRow.hide();
|
|
parentResultsTable.empty();
|
|
}
|
|
|
|
function updateParentValues(data, enabled) {
|
|
if (data != null) parentSearch.val(data['last_name']);
|
|
$('#new_parent_first_name').val(data==null?'':unescape(data['first_name']));
|
|
$('#new_email').val(data==null?'':data['email']);
|
|
$('#new_phone').val(data==null?'':data['home_phone']);
|
|
if (enabled) {
|
|
$('#new_parent_first_name').removeAttr('disabled').removeClass('disabled');
|
|
$('#new_email').removeAttr('disabled').removeClass('disabled');
|
|
$('#new_phone').removeAttr('disabled').removeClass('disabled');
|
|
$('#contactInfoRow').show();
|
|
}
|
|
else {
|
|
// $('#new_parent_first_name').attr('disabled','disabled').addClass('disabled');
|
|
// $('#new_phone').attr('disabled','disabled').addClass('disabled');
|
|
// $('#new_email').attr('disabled','disabled').addClass('disabled');
|
|
$('#contactInfoRow').hide();
|
|
}
|
|
}
|
|
|
|
$('#new_parent_first_name').focus(function() {
|
|
if (selectedParent == null) doParentClick(0);
|
|
});
|
|
|
|
$(document).on('click', '.header-controls', function(e) {
|
|
e.preventDefault();
|
|
|
|
var hnum = $(this).attr('hnum');
|
|
var mode = $(this).attr('mode');
|
|
|
|
if (mode == 'visible') {
|
|
$(".header-"+hnum).hide();
|
|
$(this).attr('mode','hidden');
|
|
$(this).html("[show]");
|
|
}
|
|
|
|
if (mode == 'hidden') {
|
|
// $(".header-"+hnum).show();
|
|
$(".header-"+hnum).each(function() {
|
|
$(this).show();
|
|
$(this).removeClass('hidden-item');
|
|
});
|
|
|
|
$(this).attr('mode','visible');
|
|
$(this).html("[hide]");
|
|
}
|
|
});
|
|
|
|
$(document).on('click','.item-title',function(e) {
|
|
var code = $(this).attr('code');
|
|
var mcode = $(this).attr('mcode');
|
|
var rflag = $(this).attr('rflag');
|
|
var qty = $("#qty_"+code).val();
|
|
var nqty = Math.abs(qty) + 1;
|
|
var menu_num = $(this).attr('menu-num');
|
|
var item_num = $(this).attr('item-num');
|
|
var item_title = $("#item_title_"+item_num).val();
|
|
|
|
if (rflag == 'readonly') return;
|
|
|
|
$("#qty_"+code).val(nqty);
|
|
if (nqty > 0) showOptions(menu_num, item_num, item_title);
|
|
updateLine(code,mcode,'Y','Y');
|
|
});
|
|
|
|
$(document).on('click','.item-price',function(e) {
|
|
var code = $(this).attr('code');
|
|
var mcode = $(this).attr('mcode');
|
|
var rflag = $(this).attr('rflag');
|
|
var qty = $("#qty_"+code).val();
|
|
var nqty = Math.abs(qty) - 1;
|
|
|
|
if (rflag == 'readonly') return;
|
|
|
|
if (nqty >= 0) {
|
|
$("#qty_"+code).val(nqty);
|
|
updateLine(code,mcode,'Y','Y');
|
|
if (nqty == 0) $("#qty_"+code).val('');
|
|
}
|
|
});
|
|
|
|
//
|
|
// JQuery code to manage forms
|
|
//
|
|
|
|
var schedule_num = <?php echo($schedule_num) ?>;
|
|
|
|
$(".info-span").hide();
|
|
|
|
$("#new_last_name").focus();
|
|
|
|
$("#options-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 800,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
// Hide item options in calendar display mode
|
|
$(".item-options-span").hide();
|
|
|
|
// Checkbox click
|
|
$(document).on("click", ".qty-checkbox", function(e) {
|
|
var menu_num = $(this).attr('menu-num');
|
|
var item_num = $(this).attr('item-num');
|
|
var item_title = $("#item_title_"+item_num).val();
|
|
|
|
var qtyfield = $(this).attr('qtyfield');
|
|
var qty = $("#"+qtyfield).val();
|
|
|
|
if (qty > 0) showOptions(menu_num, item_num, item_title);
|
|
});
|
|
|
|
// Quantity field change
|
|
$(document).on("change", ".qty-field", function(e) {
|
|
var menu_num = $(this).attr('menu-num');
|
|
var item_num = $(this).attr('item-num');
|
|
var item_title = $("#item_title_"+item_num).val();
|
|
var qty = $(this).val();
|
|
|
|
if (qty > 0) showOptions(menu_num, item_num, item_title);
|
|
});
|
|
|
|
$(document).on("click", ".menu-item-title", function(e) {
|
|
e.preventDefault();
|
|
|
|
var menu_num = $(this).attr('menu-num');
|
|
var item_num = $(this).attr('item-num');
|
|
var item_title = $(this).html();
|
|
showOptions(menu_num, item_num, item_title);
|
|
});
|
|
|
|
function showOptions(menu_num, item_num, item_title) {
|
|
|
|
var menu_code = schedule_num+'_'+menu_num;
|
|
var options_span = schedule_num+'_'+menu_num+'_'+item_num;
|
|
if ($("#"+options_span).length == 0) return;
|
|
|
|
var options_code = $("#"+options_span).html();
|
|
|
|
// If the options span exists then display the options
|
|
if (options_code.length) {
|
|
var html_code = "<h2>"+item_title+"</h2>"+options_code;
|
|
$("#options-code-div").html(html_code);
|
|
|
|
// Rename checkbox elements in span
|
|
$("#options-code-div :input").each(function() {
|
|
var id = $(this).attr('id');
|
|
var new_id = 'p'+id;
|
|
$(this).attr('id',new_id);
|
|
$("#"+new_id).prop('checked',false);
|
|
if ($("#"+id).prop('checked')) $("#"+new_id).prop('checked',true);
|
|
});
|
|
|
|
$("#options_saved").val('N');
|
|
$("#options_selected").val(0);
|
|
$("#options-dialog").dialog("open");
|
|
}
|
|
}
|
|
|
|
$(document).on("change", ".item-option", function(e) {
|
|
var id = $(this).attr('id');
|
|
var save_id = id.substring(1);
|
|
var num_options = $("#options_selected").val();
|
|
var inum = $(this).attr('inum');
|
|
var optionf = $(this).attr('optionf');
|
|
|
|
if ($(this).is(':checked')) {
|
|
if ($("#"+save_id)) $("#"+save_id).prop('checked', true);
|
|
$("."+inum+"."+optionf).prop('checked', true);
|
|
num_options = Math.abs(num_options) + 1;
|
|
}
|
|
else {
|
|
if ($("#"+save_id)) $("#"+save_id).prop('checked', false);
|
|
$("."+inum+"."+optionf).prop('checked', false);
|
|
num_options = Math.abs(num_options) - 1;
|
|
}
|
|
|
|
$("#options_selected").val(num_options);
|
|
|
|
var curr_code = $(this).attr('curr-code');
|
|
var menu_code = $(this).attr('menu-code');
|
|
var name_code = $(this).attr('name');
|
|
|
|
if (!checkOptions(curr_code,menu_code,name_code)) {
|
|
$("#"+id).prop('checked', false);
|
|
$("."+inum+"."+optionf).prop('checked', false);
|
|
// $("#"+save_id).prop('checked', false);
|
|
}
|
|
});
|
|
|
|
$("#closeOptions").click(function(e) {
|
|
e.preventDefault();
|
|
$("#options-dialog").dialog("close");
|
|
});
|
|
|
|
$(".qty-field").tooltip({
|
|
position: { my: "left+5 top+5", at: "left bottom", collision: "flipfit" },
|
|
show: { effect: "fade", delay: 200 },
|
|
hide: false,
|
|
content: function() { return $(this).prop('title'); }
|
|
});
|
|
|
|
$(".qty-checkbox").tooltip({
|
|
position: { my: "left+5 top+5", at: "left bottom", collision: "flipfit" },
|
|
show: { effect: "fade", delay: 200 },
|
|
hide: false,
|
|
content: function() { return $(this).prop('title'); }
|
|
});
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
<div id='options-dialog' title="<?php displayLanguageText('TEXT-AVAILABLE-OPTIONS'); ?>">
|
|
<table cellpadding='0' cellspacing='0'>
|
|
<tr>
|
|
<td align='left'>
|
|
<div id='options-code-div' class='align-left'></div>
|
|
<p><button id='closeOptions' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-SAVE'); ?> </button></p>
|
|
<input type='hidden' name='options_saved' id='options_saved'>
|
|
<input type='hidden' name='options_selected' id='options_selected'>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|