First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
$action = "menu-details";
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Check permissions
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sortby = "School";
|
||||
|
||||
// Get parameters to script
|
||||
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
||||
if (array_key_exists('sortby',$_GET)) $sortby = db_escape_string($_GET['sortby']);
|
||||
if (array_key_exists('show_status',$_GET)) $show_status = db_escape_string($_GET['show_status']);
|
||||
|
||||
if (!isset($schedule_num)) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Verify the schedule_num is a valid and active schedule
|
||||
$swhere = "";
|
||||
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
|
||||
$today = date("Y-m-d",time());
|
||||
$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) {
|
||||
header("Location: /?action=$action&error_code=INVALIDSCHED");
|
||||
exit();
|
||||
}
|
||||
|
||||
$schedule = db_fetch_array($results);
|
||||
$schedule_name = $schedule['schedule_name'];
|
||||
|
||||
|
||||
// If this is a ScheduleTeam user check if they have permission to access this schedule
|
||||
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
|
||||
$userNum = intval($_SESSION['UserInfo']['record_num']);
|
||||
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
|
||||
|
||||
if (!$access || $access == 0) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
$school_name = $school_record['school_name'];
|
||||
$document_name = getLanguageText('TEXT-ORDERS-SUMMARY');
|
||||
|
||||
|
||||
// Set the status condition if required
|
||||
$ReportTitle = getLanguageText('TEXT-ORDERS-SUMMARY') . " - (" . $GlobalText['Student'] . ") - $schedule_name";
|
||||
$orderby = "ORDER BY last_name, first_name";
|
||||
if ($sortby == 'Class') $orderby = "ORDER BY c.sequence, last_name, first_name";
|
||||
|
||||
|
||||
unset($delivered);
|
||||
if (array_key_exists('delivered',$_GET) && strlen($_GET['delivered'])) $delivered = $_GET['delivered'];
|
||||
if (array_key_exists('delivered',$_POST) && strlen($_POST['delivered'])) $delivered = $_POST['delivered'];
|
||||
$dwhere = "";
|
||||
if (isset($delivered)) {
|
||||
$dwhere = "AND delivered = '$delivered' ";
|
||||
if ($delivered == 'Y') $ReportTitle .= " - " . getLanguageText('TEXT-DELIVERED');
|
||||
else $ReportTitle .= " - " . getLanguageText('TEXT-NOT-DELIVERED');
|
||||
}
|
||||
|
||||
|
||||
$status_where = "";
|
||||
if (isset($show_status) && strlen($show_status)) {
|
||||
$status_where = "AND hloh.status = '$show_status' ";
|
||||
}
|
||||
|
||||
|
||||
// Get orders for this schedule
|
||||
$query = "SELECT p.last_name,p.first_name,class_num,sequence,people_type,hloh.source,hloh.order_total,hloh.price_category,hloh.status,p.user_num,hloh.record_num,userid," .
|
||||
"hloh.payment_method,hloh.added_date,sum(ua.transaction_amount) as balance,delivered " .
|
||||
"FROM people AS p LEFT JOIN classes AS c ON p.class_num = c.record_num, hotlunch_order_header AS hloh, " .
|
||||
"users AS u LEFT JOIN user_account AS ua ON ua.school_num = $school_num AND ua.user_num = u.record_num AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " .
|
||||
"WHERE p.school_num = $base_school_num " .
|
||||
"AND hloh.school_num = $school_num " .
|
||||
"AND hloh.status NOT IN ('Inactive','Deleted') " .
|
||||
"AND p.record_num = hloh.ordered_by_num " .
|
||||
$dwhere .
|
||||
$status_where .
|
||||
"AND hloh.schedule_num = $schedule_num " .
|
||||
"AND p.user_num = u.record_num " .
|
||||
"GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,16 " .
|
||||
$orderby;
|
||||
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
header("Location: /?error_code=NOORDERS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if ($sortby == 'Class') {
|
||||
$column_headers = array(getLanguageText('TEXT-NAME'),
|
||||
getLanguageText('TEXT-TYPE'),
|
||||
getLanguageText('TEXT-CLASS'),
|
||||
getLanguageText('TEXT-ORDER'),
|
||||
getLanguageText('TEXT-ORDER-DATE'),
|
||||
getLanguageText('TEXT-SOURCE'),
|
||||
getLanguageText('TEXT-CATEGORY'),
|
||||
getLanguageText('TEXT-STATUS'),
|
||||
getLanguageText('TEXT-ACCOUNT'),
|
||||
getLanguageText('TEXT-PHONE'),
|
||||
getLanguageText('TEXT-EMAIL'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$column_headers = array(getLanguageText('TEXT-NAME'),
|
||||
getLanguageText('TEXT-TYPE'),
|
||||
getLanguageText('TEXT-ORDER'),
|
||||
getLanguageText('TEXT-ORDER-DATE'),
|
||||
getLanguageText('TEXT-SOURCE'),
|
||||
getLanguageText('TEXT-CATEGORY'),
|
||||
getLanguageText('TEXT-STATUS'),
|
||||
getLanguageText('TEXT-ACCOUNT'),
|
||||
getLanguageText('TEXT-PHONE'),
|
||||
getLanguageText('TEXT-EMAIL'),
|
||||
);
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$prev_class = 0;
|
||||
$total = 0;
|
||||
|
||||
// Process all the orders found for this page
|
||||
while ($row = db_fetch_array($results)) {
|
||||
|
||||
$entry = array();
|
||||
|
||||
$name = $row['last_name'] . ', ' . $row['first_name'];
|
||||
$entry[] = $name;
|
||||
$entry[] = $row['people_type'];
|
||||
|
||||
if ($sortby == 'Class') {
|
||||
$class_num = $row['class_num'];
|
||||
$class = '';
|
||||
if ($class_num != $prev_class) {
|
||||
$prev_class = $class_num;
|
||||
$class = getClassInfo($class_num);
|
||||
}
|
||||
$entry[] = $class;
|
||||
}
|
||||
|
||||
$entry[] = $school_record['currency_symbol'] . number_format($row['order_total'],2);
|
||||
$total += $row['order_total'];
|
||||
|
||||
$entry[] = dateString('date',strtotime($row['added_date']));
|
||||
$entry[] = $row['source'];
|
||||
$entry[] = $row['price_category'];
|
||||
|
||||
$dtext = "";
|
||||
if ($schedule['schedule_type'] != 'Hot Lunch' && in_array($siteType,array('hotlunch','yearbook','tickets','fundraising'))) $dtext = " (" . $row['delivered'] . ")";
|
||||
|
||||
$entry[] = $row['status'].' - '.$row['payment_method'] . $dtext;
|
||||
|
||||
// Get the name on this account
|
||||
$unum = $row['user_num'];
|
||||
$r = db_query("select concat(first_name,' ',last_name) AS account, email, home_phone from users where school_num = $base_school_num and record_num = $unum");
|
||||
$ur = db_fetch_assoc($r);
|
||||
$entry[] = $ur['account'];
|
||||
$entry[] = $ur['home_phone'];
|
||||
$entry[] = $ur['email'];
|
||||
|
||||
$data[] = $entry;
|
||||
}
|
||||
|
||||
$data[] = array('','',$school_record['currency_symbol'] . number_format($total,2));
|
||||
|
||||
// Output the XLS data
|
||||
$fname = genFileName("all-orders.csv");
|
||||
xlsData($data,$column_headers,$fname);
|
||||
return;
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user