First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
$moduleName = "ajax.userSearch.php";
|
||||
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog($moduleName);
|
||||
// startLog($moduleName);
|
||||
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
logExit("Session is not active",$moduleName);
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set userType
|
||||
$userType = "Parent";
|
||||
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'],$AllAdminUserTypes)) $userType = "Admin";
|
||||
if ($userType != 'Admin') return;
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
if ($userType != 'Admin') {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
logExit($error_message);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// CSRF token validation
|
||||
include "include/ajax.csrfToken.php";
|
||||
|
||||
|
||||
|
||||
// Get search text
|
||||
$text = trim(strtolower($_GET['term']));
|
||||
$words = explode(' ',$text);
|
||||
writeLog("text: $text\n");
|
||||
|
||||
|
||||
// Format where clause
|
||||
$swhere = "";
|
||||
$uwhere = "";
|
||||
for ($i = 0; $i < count($words); $i++) {
|
||||
$word = db_escape_string($words[$i]);
|
||||
$uwhere .= "AND (userid LIKE '$word%' " .
|
||||
"OR first_name LIKE '$word%' " .
|
||||
"OR last_name LIKE '$word%' " .
|
||||
"OR email LIKE '$word%' " .
|
||||
"OR schools.city LIKE '$word%' " .
|
||||
"OR schools.province LIKE '$word%' " .
|
||||
"OR phone LIKE '%$word%') ";
|
||||
}
|
||||
|
||||
// Get matching user records
|
||||
$query = "SELECT DISTINCT school_num,userid,first_name,last_name,school_name,schools.province,users.record_num FROM users,schools " .
|
||||
"WHERE users.school_num = schools.record_num " .
|
||||
"AND schools.status IN ('Active','Inactive','Special') " .
|
||||
$uwhere .
|
||||
"ORDER BY last_name,first_name";
|
||||
writeLog("query: $query\n");
|
||||
$results = db_query($query);
|
||||
|
||||
// Format data for return
|
||||
$return_data = array();
|
||||
$num_records = db_num_rows($results);
|
||||
if ($num_records > 0) {
|
||||
writeLog("records: $num_records\n");
|
||||
$return_data[] = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
extract($row);
|
||||
$query = "select sum(transaction_amount) as balance from user_account where school_num = $school_num and user_num = $record_num AND (deleted != 'Y' OR deleted IS NULL)";
|
||||
$user_balance = floatval(db_getVal($query));
|
||||
$user_balance = '$'.number_format($user_balance,2);
|
||||
$num = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $record_num");
|
||||
$return_data[] = array("value" => "$first_name $last_name ($num) $user_balance - $school_name ($province)",
|
||||
"school_num" => $school_num,
|
||||
"user_num" => $record_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
writeLog("completed\n");
|
||||
echo(json_encode($return_data));
|
||||
return false;
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user