105 lines
4.1 KiB
PHP
105 lines
4.1 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
$mode = "";
|
|
if (array_key_exists('mode',$_GET) && $_GET['mode'] == 'detail') $mode = 'detail';
|
|
|
|
|
|
$numClasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $base_school_num");
|
|
|
|
$column_headers = array();
|
|
|
|
// Get set of records
|
|
$query = "SELECT p.first_name,p.last_name,p.class_num,student_number,p.birthdate,p.age,p.sex,p.school_grade," .
|
|
"u.first_name AS parent_first_name,u.last_name AS parent_last_name,u.home_phone,u.cell_phone,u.email,c.sequence,p.record_num AS snum,u.record_num AS unum " .
|
|
"FROM classes AS c, people AS p, users AS u " .
|
|
"WHERE p.school_num = $school_num " .
|
|
"AND u.school_num = $school_num " .
|
|
"AND c.school_num = $base_school_num " .
|
|
"AND u.record_num = p.user_num " .
|
|
"AND c.record_num = p.class_num " .
|
|
"AND u.type NOT IN ('System Administrator','Application Administrator','Volunteer Administrator') " .
|
|
"ORDER BY sequence,p.last_name,p.first_name";
|
|
|
|
$results = db_query($query);
|
|
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
$entry = array();
|
|
|
|
if ($numClasses > 0) {
|
|
$class_info = getClassInfo($class_num);
|
|
$entry[] = $class_info;
|
|
}
|
|
|
|
if ($school_record['collect_student_number'] == 'Y') $entry[] = $student_number;
|
|
$entry[] = $first_name;
|
|
$entry[] = $last_name;
|
|
if ($school_record['collect_student_birthdate'] == 'Y') $entry[] = $birthdate;
|
|
if ($school_record['collect_student_age'] == 'Y') $entry[] = $age;
|
|
if ($school_record['collect_student_sex'] == 'Y') $entry[] = $sex;
|
|
if ($school_record['collect_student_grade'] == 'Y') $entry[] = $school_grade;
|
|
$entry[] = $parent_first_name;
|
|
$entry[] = $parent_last_name;
|
|
$entry[] = $home_phone;
|
|
$entry[] = $cell_phone;
|
|
$entry[] = $email;
|
|
|
|
if ($mode == 'detail') {
|
|
$student_balance = db_getVal("SELECT sum(order_total - amount_paid) FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $snum AND status != 'Deleted'");
|
|
$student_balance = '$' . sprintf("%0.2f",$student_balance);
|
|
|
|
$account_balance = db_getVal("SELECT sum(transaction_amount) FROM user_account WHERE school_num = $school_num AND user_num = $unum AND (deleted != 'Y' OR deleted IS NULL)");;
|
|
$account_balance = '$' . sprintf("%0.2f",$account_balance);
|
|
|
|
$entry[] = $student_balance;
|
|
$entry[] = $account_balance;
|
|
}
|
|
|
|
$data[] = $entry;
|
|
}
|
|
|
|
if ($numClasses > 0) $column_headers[] = $GlobalText['Class'];
|
|
if ($school_record['collect_student_number'] == 'Y') $column_headers[] = getLanguageText('TEXT-STUDENT-NUMBER');
|
|
$column_headers[] = getLanguageText('TEXT-FIRST-NAME');
|
|
$column_headers[] = getLanguageText('TEXT-LAST-NAME');
|
|
if ($school_record['collect_student_birthdate'] == 'Y') $column_headers[] = getLanguageText('TEXT-BIRTH-DATE');
|
|
if ($school_record['collect_student_age'] == 'Y') $column_headers[] = getLanguageText('TEXT-AGE');
|
|
if ($school_record['collect_student_sex'] == 'Y') $column_headers[] = getLanguageText('TEXT-GENDER');
|
|
if ($school_record['collect_student_grade'] == 'Y') $column_headers[] = getLanguageText('TEXT-GRADE');
|
|
$column_headers[] = getLanguageText('TEXT-FIRST-NAME');
|
|
$column_headers[] = getLanguageText('TEXT-LAST-NAME');
|
|
$column_headers[] = getLanguageText('TEXT-PHONE');
|
|
$column_headers[] = getLanguageText('TEXT-CELL');
|
|
$column_headers[] = getLanguageText('TEXT-EMAIL');
|
|
|
|
if ($mode == 'detail') {
|
|
$column_headers[] = getLanguageText('TEXT-BALANCE');
|
|
$column_headers[] = getLanguageText('TEXT-ACCOUNT-BALANCE');
|
|
}
|
|
|
|
|
|
$file_name = strtolower($GlobalText['StudentLink'] . ".csv");
|
|
$fname = genFileName($file_name);
|
|
xlsData($data,$column_headers,$fname);
|
|
|
|
exit();
|
|
?>
|