|
0) echo(" $discount_msg \n");
$tabindex = 1;
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier');
if (checkPermission($AllowedUserTypes) == 1) {
?>
0) echo("$name \n");
// Set name title for Concession Order
$display_current_totals = 'N';
$concessionOrder = 'N';
if ($ordered_by_type == 'Concession') {
echo("Concession Order \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("\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 = " ";
$otipSpans .= "" . sprintf($otipNUTRITION,nl2br($nutritional_info)) . "\n";
$nutrition_image = " $nutrition_icon ";
}
// Process the BC Food Guidelines icons
$rating_image = "";
$rating_icon = " ";
if ($school_record['display_bc_food_guidelines'] == 'Y') {
if ($bc_guideline_rating == 'Sometimes') $rating_image = " $rating_icon ";
if ($bc_guideline_rating == 'Most') $rating_image = " " . $rating_icon . $rating_icon . "";
}
// Handle item image
$image_link = "";
echo("\n");
if (strlen($image) > 0 && is_file("$imagedir/$image")) {
$image_icon = " ";
$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 = " ";
}
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 .= "" . sprintf($otipIMG,"$imageurl/$image",$image_height,$image_width,$item_title) . "\n";
$image_link = "$image_icon";
}
}
// 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 = " - $item_title";
if ($display_price != 'N') $iTitle .= " - $currencySymbol$item_price ";
$iTitle .= " \n";
if (strlen($item_description)) $iTitle .= " -- $item_description \n";
if ($taxable_item == 'Y') $iTitle .= " -- " . getLanguageText('TEXT-TAXABLE') . " \n";
// Format nutritional info
if (strlen(trim($nutritional_info))) $nutritional_info = " \n" . nl2br(trim($nutritional_info));
// Include image if there is one
$iImage = "
";
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 = " \n" . sprintf($otipIMG,"$imageurl/$image",$image_height,$image_width,$item_title) . "";
}
$mtitle = "";
if (strlen($menu_title)) $mtitle = " $menu_title \n";
// Process the BC Food Guidelines icons
$rating_image = "";
$rating_icon = " ";
if ($school_record['display_bc_food_guidelines'] == 'Y') {
if ($bc_guideline_rating == 'Sometimes') $rating_image = " $rating_icon ";
if ($bc_guideline_rating == 'Most') $rating_image = " " . $rating_icon . $rating_icon . "";
}
$span_id = "info_span$curr_item_num";
if ($menu_available != 'N') {
$otipSpans .= "" .
sprintf($otipNUTRITION,$mtitle . $iTitle . $nutritional_info) .
$iImage .
"\n";
}
else {
$msg = "" . getLanguageText('TEXT-NOT-AVAILABLE') . " ";
$otipSpans .= "" .
sprintf($otipNUTRITION,$msg . $mtitle . $iTitle . $nutritional_info) .
$iImage .
"\n";
}
$label_title = "$label_title";
}
$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 .= " \n";
if (strlen($optionsTitle)) $options_code .= "$optionsTitle: ";
$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("\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 .= " \n";
}
else {
// $fname = $sname . "_visible";
$options_code .= " \n";
if (strlen($checked)) $options_code .= "";
}
$optionsText .= "$option ";
if ($menu_display_mode == 'Form' && strlen($optionsText) > 70 && $i < ($num_options - 1)) {
$optionsText = "";
$options_code .= " \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 = "$options_code";
$view_icon_small = " ";
$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 = " ";
$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("\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("\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("\n");
$rstyle = " style='color: #ff0000; background-color: #cccccc;'";
}
$qfield = "$groupText$total_ordered";
if (strlen($readonly) == 0) {
$qfield = "$groupText$total_ordered" .
" " .
"" .
" " .
"";
}
if (1 == 2 && strlen($readonly) == 0) {
$qfield = "$groupText$total_ordered";
}
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 = "$groupText$total_ordered" .
" ";
}
}
$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 = " \n - $item_description";
// 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 = " \n $item_description";
$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 .= "";
}
else {
$vField = "";
$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) {
?>
\n");
for ($dow = 0; $dow < 7; $dow++) {
$dayOfWeek = $dayNames[$dow];
if ($menu_display_mode == 'Calendar No Weekends' && ($dow == 0 || $dow == 6)) continue;
?>
\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(" \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(" $currCalendarDate \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 = "";
$espan = "";
}
echo("$sspan" . $row['title'] . "$espan ");
}
}
}
$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("\n");
if (strlen($menu_instructions) > 0) {
echo("\n");
}
echo(" \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 = " -- $currencySymbol".number_format($item_price,2)."";
$display_title = $label_title;
$ItemTitle = str_replace('"',""",$item_title);
?>
class=''>
|
|
>
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;'";
?>
>
| >
>
|
> |
0) {
extract($MenuTotals);
?>
| :
|
\n");
}
else {
echo(" \n");
echo(" \n");
echo(" \n");
// echo(" \n");
}
}
}
echo(" \n");
$currCalendarDateTime = strtotime(date("Y-m-d",$currCalendarDateTime + 60 * 60 * 25));
}
echo(" \n");
if (date("n",$currCalendarDateTime) > date("n",$currMonthTime)) {
if ($monthBreak) break;
else $monthSpanned = true;
}
if (date("Y",$currCalendarDateTime) > date("Y",$currMonthTime)) break;
}
if ($monthBreak) {
?>
|
0) {
$displayFooterMenus = true;
}
//
// Display menu form
//
if ($menu_display_mode == 'Form' || $displayFooterMenus) {
?>
$val) {
extract($MenuDates[$menu_num]);
// If displaying Footer menus do not display regular menus
if ($menu_display_mode != 'Form' && $displayFooterMenus && $menu_type == 'Regular') continue;
?>
>
|
0) { ?>
|
$item_title";
if ($item_price != 0.00) $priceVal = true;
$priceSpan = "";
$qcolSpan = 1;
if ($schedule_prices == 'N') {
$priceSpan = "";
$qcolSpan = 3;
}
$readonlyflag = "";
if (strlen($readonly)) $readonlyflag = "readonly";
?>
class=''>
| $item_title$item_availability$rating_image") ?> |
|
> |
");
}
?>
|
[hide]";
if ($heading_visibility == 'hidden') {
$control = "";
}
?>
class='menu-subheading'>
0) {
extract($MenuTotals);
$currRowStyle = $rowStyle;
if ($priceVal == false) $currRowStyle = " class='invisible'";
?>
>
| |
|
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;'";
?>
>
|
|
>
| |
0) $ordertotal = $ordertotal - $discount_amount;
// Table for footer fields and buttons
?>
|