First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
$moduleName = "hotlunch_order_list.parent.php";
|
||||
// if ($school_num == 20067) startLog($moduleName);
|
||||
|
||||
|
||||
// Determine the number of currently active schedules
|
||||
$today = date("Y-m-d",time());
|
||||
$now = date("Y-m-d H:i:s",time());
|
||||
$time = date("H",time());
|
||||
$cutoff = date("Y-m-d H:i:s",time() - 60 * 60 * 24 * 20);
|
||||
$num_active = db_getVal("SELECT count(*) FROM hotlunch_schedules WHERE school_num = $school_num AND status = 'Active' AND (schedule_end_date >= '$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("<p><b>There are no active schedules to view</b></p>\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("<br>\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("<br>\n");
|
||||
include "payment_form.php";
|
||||
}
|
||||
|
||||
// Start table regardless of whether there are schedules to display
|
||||
?>
|
||||
<table width='800' cellpadding='3' cellspacing='1' border='0'>
|
||||
<?php
|
||||
|
||||
$sched_count = 0;
|
||||
while ($row = db_fetch_array($schedules)) {
|
||||
$schedule_num = $row['record_num'];
|
||||
$title = $row['schedule_name'];
|
||||
$end_order_datetime = $row['end_order_datetime'];
|
||||
$schedule_start_date = $row['schedule_start_date'];
|
||||
$days_prior_to_order_date = $row['days_prior_to_order_date'];
|
||||
$schedule_type = $row['schedule_type'];
|
||||
$schedule_for = $row['schedule_for'];
|
||||
$order_button_text = $row['order_button_text'];
|
||||
$schedule_prices = $row['schedule_prices'];
|
||||
|
||||
writeLog("title: $title");
|
||||
|
||||
$schedule_total = 0;
|
||||
$schedule_paid = 0;
|
||||
|
||||
|
||||
// Check that the schedule has menu dates and items defined
|
||||
$numDates = db_getVal("SELECT count(*) FROM hotlunch_menu_dates WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
||||
if ($numDates == 0) continue;
|
||||
|
||||
$numItems = db_getVal("SELECT count(*) FROM hotlunch_menu_dates AS hlmd, hotlunch_menu_items AS hlmi " .
|
||||
"WHERE hlmd.school_num = $school_num " .
|
||||
"AND hlmi.school_num = $school_num " .
|
||||
"AND hlmd.schedule_num = $schedule_num " .
|
||||
"AND hlmi.menu_num = hlmd.record_num");
|
||||
if ($numItems == 0 && $schedule_type != 'Volunteer Only') continue;
|
||||
|
||||
|
||||
// Check if there are any of the students can access this schedule
|
||||
$class_entries = db_getVal("select count(*) from hotlunch_schedules_classes where school_num = $school_num and schedule_num = $schedule_num");
|
||||
$schedule_access = 1;
|
||||
|
||||
if ($class_entries > 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) {
|
||||
?>
|
||||
<tr>
|
||||
<td colspan='6'> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
$sched_count++;
|
||||
?>
|
||||
<tr>
|
||||
<td align='left' colspan='6' class='heading'> <?php echo($title) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='220' class='heading' align='left'> <?php displayLanguageText('TEXT-NAME'); ?></td>
|
||||
<td width='90' class='heading' align='center'><?php displayLanguageText('TEXT-DATE-MODIFIED'); ?></td>
|
||||
<td width='90' class='heading' align='right'><?php displayLanguageText('TEXT-ORDER-TOTAL'); ?></td>
|
||||
<td width='120' class='heading' align='center'><?php displayLanguageText('TEXT-STATUS'); ?></td>
|
||||
<td width='180' class='heading'> </td>
|
||||
</tr>
|
||||
<?php
|
||||
$total = 0;
|
||||
|
||||
$RowClasses = array("data-odd","data-even");
|
||||
$count = 0;
|
||||
|
||||
for ($sn = 0; $sn < count($students); $sn++) {
|
||||
$row = $students[$sn];
|
||||
$name = $row['last_name'] . ", " . $row['first_name'];
|
||||
$student_num = $row['record_num'];
|
||||
$class_num = intval($row['class_num']);
|
||||
|
||||
if ($row['people_type'] == 'Customer' && $schedule_for == 'Parents' && $class_num != 2) continue;
|
||||
if ($row['people_type'] == 'Customer') {
|
||||
if ($class_num == 2) $name .= " (" . getLanguageText('TEXT-PARENT') . ")";
|
||||
else $name .= " (" . getLanguageText('TEXT-CUSTOMER') . ")";
|
||||
}
|
||||
if ($row['people_type'] == 'Staff') $name .= " (" . getLanguageText('TEXT-STAFF') . ")";
|
||||
|
||||
// Check if this is a limited access schedule
|
||||
$class_entries = db_getVal("select count(*) from hotlunch_schedules_classes where school_num = $school_num and schedule_num = $schedule_num");
|
||||
|
||||
if ($class_entries > 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] = "<a href='?action=volunteer-signup&schedule_num=$schedule_num' class='btn btn--primary btn--xsmall'>" . getLanguageText('TEXT-VOLUNTEER-SIGNUP-TITLE') . "</a>";
|
||||
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] = "<a href='?action=orders&naction=$next_action&schedule_num=$schedule_num&student_num=$student_num' " .
|
||||
"class='btn btn--outline btn--xsmall'><span>$orderButtonText</span></a>";
|
||||
}
|
||||
else {
|
||||
$commands[0] = getLanguageText('TEXT-NOT-AVAILABLE');
|
||||
}
|
||||
|
||||
if ($next_action == "edit") {
|
||||
$commands[1] = "<a href='?action=orders-print&schedule_num=$schedule_num&order_num=$onum' " .
|
||||
"class='btn btn--outline btn--xsmall'><span>" . getLanguageText('TEXT-PRINT') . "</span></a>";
|
||||
}
|
||||
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] = "<a href='?action=orders&naction=$next_action&schedule_num=$schedule_num&student_num=$student_num&entered_order_num=$onum' " .
|
||||
"class='btn btn--outline btn--xsmall'><span>$orderButtonText</span></a>";
|
||||
}
|
||||
|
||||
if ($next_action == "edit") {
|
||||
$commands[1] = "<a href='?action=orders-print&schedule_num=$schedule_num&order_num=$onum' " .
|
||||
"class='btn btn--outline btn--xsmall'><span>" . getLanguageText('TEXT-PRINT') . "</span></a>";
|
||||
}
|
||||
|
||||
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);
|
||||
?>
|
||||
<tr height='30'>
|
||||
<td colspan='2' class='footer-row'> </td>
|
||||
<td class='footer-row' valign='middle' align='right'><?php echo($total) ?> </td>
|
||||
<td colspan='2' class='footer-row' align='right'><?php echo($balance_text) ?> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
$balance = floatval(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)"));
|
||||
if ($balance >= 0) $balance_text = $currencySymbol . number_format($balance,2);
|
||||
else $balance_text = "- $currencySymbol" . number_format(abs($balance),2);
|
||||
?>
|
||||
<tr height='30'>
|
||||
<td colspan='6' class='footer-row' align='right'><?php displayLanguageText('TEXT-CURRENT-ACCT-BALANCE'); ?> :: <?php echo($balance_text) ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
$user_num = intval($_SESSION['UserInfo']['record_num']);
|
||||
|
||||
if ($num_active > 2 && $balance > 0) {
|
||||
echo("<br>\n");
|
||||
include "payment_form.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user