First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
echo("Invalid Access");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Get parameters to script
|
||||
if (array_key_exists('action',$_GET)) $action = $_GET['action'];
|
||||
if (array_key_exists('show_modifier',$_GET)) $show_modifier = $_GET['show_modifier'];
|
||||
|
||||
$reportMode = "Standard";
|
||||
if (array_key_exists('mode',$_GET)) $reportMode = $_GET['mode'];
|
||||
|
||||
|
||||
|
||||
// Check permissions
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
header("Location: /?action=$action&show_modifier=$show_modifier&error_code=NOACCESS");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$column_headers = array(getLanguageText('TEXT-USER-ID'),
|
||||
getLanguageText('TEXT-TYPE'),
|
||||
getLanguageText('TEXT-NAME'),
|
||||
getLanguageText('TEXT-PHONE'),
|
||||
getLanguageText('TEXT-EMAIL'),
|
||||
getLanguageText('TEXT-BALANCE'),
|
||||
$GlobalText['Students']);
|
||||
|
||||
// Handle the modifier
|
||||
$stitle = getLanguageText('TEXT-USER-ACCOUNTS-REPORT');
|
||||
if ($show_modifier == 'balance-owing') {
|
||||
$shaving = "HAVING sum(transaction_amount) > 0.00 ";
|
||||
$stitle = getLanguageText('TEXT-BALANCE-OWING-ACCOUNTS-REPORT');
|
||||
}
|
||||
|
||||
$shaving = '';
|
||||
if ($show_modifier == 'balance-payable') {
|
||||
$shaving = "HAVING sum(transaction_amount) < 0.00 ";
|
||||
$stitle = getLanguageText('TEXT-BALANCE-PAYABLE-ACCOUNTS-REPORT');
|
||||
}
|
||||
|
||||
|
||||
$curr_school_num = $school_record['record_num'];
|
||||
$acctSchool = "ua.school_num = $curr_school_num AND ";
|
||||
$aview = "";
|
||||
if (array_key_exists('aview', $_GET) && $_GET['aview'] == 'consolidated') {
|
||||
$aview = 'consolidated';
|
||||
$acctSchool = "ua.school_num IN (" . $school_record['linked_sites'] . ") AND ";
|
||||
}
|
||||
|
||||
// Build the query statement
|
||||
$query = "SELECT userid,type,email,concat(u.first_name,' ',u.last_name) as name,u.home_phone,sum(transaction_amount) as balance," .
|
||||
"trx_status,u.record_num " .
|
||||
"FROM users AS u LEFT JOIN user_account as ua ON $acctSchool ua.user_num = u.record_num AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " .
|
||||
"WHERE u.school_num = $base_school_num " .
|
||||
"AND u.type in ('Parent','Staff') " .
|
||||
"GROUP BY 1,2,3,4,5,7,8 " .
|
||||
$shaving .
|
||||
"ORDER BY u.last_name";
|
||||
$accounts = db_query($query);
|
||||
|
||||
|
||||
$data = array();
|
||||
$total = 0;
|
||||
while ($row = db_fetch_array($accounts)) {
|
||||
extract($row);
|
||||
|
||||
if ($balance < 0) $balance = "-" . $currencySymbol . number_format(abs($balance),2);
|
||||
else $balance = $currencySymbol . number_format($balance,2);
|
||||
|
||||
$results = db_query("SELECT * FROM people WHERE school_num = $base_school_num AND user_num = $record_num ORDER BY people_type,last_name,first_name");
|
||||
$students = "";
|
||||
if (db_num_rows($results)) {
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
if (strlen($students)) $students .= "\n";
|
||||
$class_info = getClassInfo($row['class_num']);
|
||||
$students .= $row['first_name'] . ' ' . $row['last_name'] . ' (' . $class_info . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$data[] = array($userid,$type,$name,$home_phone,$email,$balance,$students);
|
||||
}
|
||||
|
||||
$fname = genFileName("account-balances.csv");
|
||||
xlsData($data,$column_headers,$fname);
|
||||
|
||||
return;
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user