= '$cutoff' OR end_order_datetime >= '$cutoff')");
writeLog("num_active: $num_active");
// Get records to display
$max_schedules = $school_record['max_schedules'] + $num_active;
$query = "select * from hotlunch_schedules " .
"where school_num = $school_num " .
"and status = 'Active' " .
"and start_order_datetime <= '$now' " .
"order by $scheduleSortOrder";
writeLog($query);
$schedules = db_query($query);
$num = db_num_rows($schedules);
$num_classes = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
if ($num == 0) {
echo("
There are no active schedules to view
\n");
}
else {
// Determine if the student list is to be displayed
$displayStudents = true;
if ($_SESSION['UserInfo']['type'] == 'HotLunchTeam') {
$unum = intval($_SESSION['UserInfo']['record_num']);
$stnum = intval($_GET['ordered_by_num']);
if (isset($stnum) && $stnum > 0) {
$num = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $unum AND record_num = $stnum");
if ($num == 0) $displayStudents = false;
}
else {
if ($action != "order-list") $displayStudents = false;
}
}
// Get set of students for this parent
if ($displayStudents) {
$uid = $_SESSION['UserInfo']['record_num'];
$students = array();
$query = "select * from people " .
"where school_num = $base_school_num " .
"and user_num = $uid " .
"and active != 'N' " .
"order by last_name,first_name";
$results = db_query($query);
if (db_num_rows($results) == 0) {
echo("
\n");
$error_message = "Error: You have no students defined in the system";
include "form.messages.php";
return;
}
$classes = "";
$student_nums = "";
while ($row = db_fetch_array($results)) {
$students[] = $row;
$class_num = intval($row['class_num']);
if ($num_classes == 0) $class_num = 3;
if (strlen($classes) > 0) $classes .= ",";
$classes .= $class_num;
$student_num = $row['record_num'];
if (strlen($student_nums) > 0) $student_nums .= ",";
$student_nums .= $student_num;
}
// Get account balance
$balance = db_getVal("select sum(transaction_amount) from user_account where school_num = $school_num and user_num = $uid AND (deleted != 'Y' OR deleted IS NULL)");
$user_num = intval($_SESSION['UserInfo']['record_num']);
if ($balance > 0) {
echo("
\n");
include "payment_form.php";
}
// Start table regardless of whether there are schedules to display
?>
0 && $_SESSION['UserInfo']['type'] != 'Staff') {
$query = "select count(*) from hotlunch_schedules_classes " .
"where school_num = $school_num " .
"and schedule_num = $schedule_num " .
"and class_num in ($classes)";
writeLog($query);
$schedule_access = db_getVal($query);
writeLog("schedule_access: $schedule_access");
if ($schedule_access == 0) continue;
}
// Check if this is a limited access schedule by category
$category_entries = db_getVal("select count(*) from hotlunch_schedules_categories where school_num = $school_num and schedule_num = $schedule_num");
if ($category_entries > 0) {
$query = "SELECT count(*) FROM hotlunch_schedules_categories AS hlsc, people_categories AS pc " .
"WHERE hlsc.school_num = $school_num " .
"AND pc.school_num = $school_num " .
"AND schedule_num = $schedule_num " .
"AND hlsc.category_num = pc.category_num " .
"AND pc.people_num IN ($student_nums)";
$schedule_access = db_getVal($query);
if ($schedule_access == 0) continue;
}
// Spacer between schedules if there are multiple schedules
if ($sched_count > 0) {
?>
| |
| |
| |
|
|
|
|
0 && $_SESSION['UserInfo']['type'] != 'Staff') {
if ($_SESSION['UserInfo']['type'] == 'Staff') {
if ($class_num > 0) $class_num .= ",1";
else $class_num = 1;
}
if (strlen($class_num) || $class_num > 0) {
$query = "select count(*) from hotlunch_schedules_classes where school_num = $school_num and schedule_num = $schedule_num and class_num IN ($class_num)";
$schedule_access = db_getVal($query);
if ($schedule_access == 0) continue;
}
}
// Check if this is a limited access schedule by category
$category_entries = db_getVal("select count(*) from hotlunch_schedules_categories where school_num = $school_num and schedule_num = $schedule_num");
if ($category_entries > 0) {
$query = "SELECT count(*) FROM hotlunch_schedules_categories AS hlsc, people_categories AS pc " .
"WHERE hlsc.school_num = $school_num " .
"AND pc.school_num = $school_num " .
"AND schedule_num = $schedule_num " .
"AND hlsc.category_num = pc.category_num " .
"AND pc.people_num = $student_num";
$schedule_access = db_getVal($query);
if ($schedule_access == 0) continue;
}
$next_action = "add";
// if ($row['people_type'] == 'Staff') $next_action = "edit";
$status = getLanguageText('TEXT-NO-ORDER');
$added_date = " -- ";
$order_total = "";
$amount_paid = "";
// Update paid amounts for this student's orders
$query = "SELECT record_num FROM hotlunch_order_header " .
"WHERE school_num = $school_num " .
"AND ordered_by_num = $student_num " .
"AND amount_paid >= order_total";
$results = db_query($query);
while ($row = db_fetch_assoc($results)) {
extract($row);
db_query("UPDATE hotlunch_order_header SET status = 'Paid' " .
"WHERE school_num = $school_num " .
"AND ordered_by_num = $student_num " .
"AND record_num = $record_num");
}
db_query("UPDATE hotlunch_order_header SET amount_paid = order_total " .
"WHERE school_num = $school_num " .
"AND ordered_by_num = $student_num " .
"AND status = 'Paid'");
// Get the orders for this student
$query = "select * from hotlunch_order_header " .
"where school_num = $school_num " .
"and ordered_by_num = $student_num " .
"AND status NOT IN ('Deleted') " .
"and schedule_num = $schedule_num";
$results = db_query($query);
// Setup order commands
$commands = array();
$commands[0] = "";
$commands[1] = "";
switch ($schedule_type) {
case 'Volunteer Only':
$commands[0] = "" . getLanguageText('TEXT-VOLUNTEER-SIGNUP-TITLE') . "";
break;
default:
$now = date("Y-m-d H:i:s",time());
if ($next_action == 'edit' || $end_order_datetime > $now) {
$orderButtonText = getLanguageText('TEXT-ORDER');
if (isset($order_button_text) && strlen($order_button_text)) $orderButtonText = $order_button_text;
$commands[0] = "$orderButtonText";
}
else {
$commands[0] = getLanguageText('TEXT-NOT-AVAILABLE');
}
if ($next_action == "edit") {
$commands[1] = "" . getLanguageText('TEXT-PRINT') . "";
}
break;
}
if (db_num_rows($results) == 0) {
$bgclass = $RowClasses[$count % 2];
$count++;
include "hotlunch_order_list.parent.row.php";
}
else {
// $total = 0;
$total_paid = 0;
while ($row = db_fetch_array($results)) {
$status = getLanguageText('TEXT-'.strtoupper($row['status']));
if (array_key_exists('display_order_payment_status', $school_record) && $school_record['display_order_payment_status'] == 'N') {
if ($row['status'] == 'Paid' || $row['status'] == 'Unpaid') $status = '-';
}
$added_date = $row['added_date'];
$onum = $row['record_num'];
$order_total = $currencySymbol . number_format($row['order_total'],2);
$amount_paid = $currencySymbol . number_format($row['amount_paid'],2);
$total += $row['order_total'];
$total_paid += $row['amount_paid'];
$next_action = "edit";
$schedule_total += $row['order_total'];
$schedule_paid += $row['amount_paid'];
$bgclass = $RowClasses[$count % 2];
$count++;
// Setup order commands
$commands = array();
$commands[0] = "";
$commands[1] = "";
$now = date("Y-m-d H:i:s",time());
if ($next_action == 'edit' || $end_order_datetime > $now) {
$orderButtonText = getLanguageText('TEXT-ORDER');
if (isset($order_button_text) && strlen($order_button_text)) $orderButtonText = $order_button_text;
$orderButtonText = str_replace(' ',' ',$orderButtonText);
$commands[0] = "$orderButtonText";
}
if ($next_action == "edit") {
$commands[1] = "" . getLanguageText('TEXT-PRINT') . "";
}
include "hotlunch_order_list.parent.row.php";
}
}
}
if (!isset($total_paid)) $total_paid = 0;
if (!isset($schedule_paid)) $schedule_paid = 0;
$balance = $total - floatval($total_paid);
$balance = $schedule_total - floatval($schedule_paid);
$balance_text = "";
if ($balance >= 0) $balance_text = getLanguageText('Order Balance')." :: $currencySymbol" . number_format($balance,2);
else $balance_text = "Order Balance :: - $currencySymbol" . number_format(abs($balance),2);
$total = $currencySymbol . number_format($total,2);
$total_paid = $currencySymbol . number_format(floatval($total_paid),2);
?>
= 0) $balance_text = $currencySymbol . number_format($balance,2);
else $balance_text = "- $currencySymbol" . number_format(abs($balance),2);
?>
2 && $balance > 0) {
echo("
\n");
include "payment_form.php";
}
}
}
?>