1217 lines
50 KiB
Plaintext
1217 lines
50 KiB
Plaintext
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: {$FormTarget}");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$CurrentTable = "users";
|
|
$DeleteField = "userid,name";
|
|
$dSeparator = "<br>";
|
|
$FormFile = "users.form.php";
|
|
$OrderBy = "last_name,first_name";
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-USER-ADMINISTRATION');
|
|
if ($action == 'user-account-list') $templatePageTitle = getLanguageText('TEXT-USER-ACCOUNT-LIST');
|
|
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team','Communications Administrator');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
$naction = '';
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
$school_num = $school_record['record_num'];
|
|
$school_num = $base_school_num;
|
|
|
|
|
|
include "users.options.php";
|
|
|
|
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
|
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
|
|
|
switch (strtolower($naction)) {
|
|
case "add":
|
|
$next_naction = "insert";
|
|
|
|
include $FormFile;
|
|
break;
|
|
|
|
case "insert":
|
|
extract($_POST);
|
|
$error_message = "";
|
|
|
|
// Check if this user account is valid
|
|
if (strlen($userid) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-USER-ID-REQUIRED');
|
|
}
|
|
|
|
if (!isset($error_message) && strpos($userid, " ")) {
|
|
$error_message = getLanguageText('ERRORMSG-INVALID-USER-ID');
|
|
}
|
|
|
|
if (!isset($error_message) && ($userid == 'superuser' || $userid == 'admin')) {
|
|
$error_message = getLanguageText('ERRORMSG-RESTRICTED-USER-ID');
|
|
}
|
|
|
|
// Check if the user id is already in use
|
|
$query = "select * from users " .
|
|
"where school_num = $school_num " .
|
|
"and userid = '" . db_escape_string($userid) . "'";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) > 0) {
|
|
$error_message = getLanguageText('ERRORMSG-USER-ID-NOT-AVAILABLE');
|
|
}
|
|
|
|
if (isset($error_message) && strlen($error_message) > 0) {
|
|
$next_naction = "insert";
|
|
|
|
include $FormFile;
|
|
endTemplate();
|
|
exit();
|
|
}
|
|
|
|
$date_added = date("Y-m-d",time());
|
|
$password_crypt = encrypt_password($password);
|
|
|
|
$temp_phone = preg_replace("/[^0-9]/","",$home_phone);
|
|
if (strlen($temp_phone) == 10) $home_phone = "(" . substr($temp_phone,0,3) . ")" . substr($temp_phone,3,3) . "-" . substr($temp_phone,6);
|
|
|
|
$table = new Table("$CurrentTable");
|
|
$query = $table->BuildInsert();
|
|
db_query($query);
|
|
|
|
$user_num = db_insert_id();
|
|
$table = new Table("user_sites");
|
|
|
|
// Create any user_sites entries if required
|
|
for ($i = 0; $i < count($selected_user_sites); $i++) {
|
|
$site_num = $selected_user_sites[$i];
|
|
$query = $table->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
|
|
// Create people entry if this is a Guest account
|
|
if ($type == 'Guest') {
|
|
$people = new Table("people");
|
|
$people_type = 'Customer';
|
|
$class_num = 1;
|
|
$status = 'Verified';
|
|
$display = 'N';
|
|
$active = 'N';
|
|
$menu_price_category = 'Regular';
|
|
$cust_phone = $home_phone;
|
|
$cust_email = $email;
|
|
$added_date = date("Y-m-d",time());
|
|
|
|
$query = $people->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
|
|
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
|
$naction = "show-info&user_num=$user_num";
|
|
if (array_key_exists('donext',$_POST) && strlen($_POST['donext']) > 0) $naction = $_POST['donext'];
|
|
header("Location: {$FormTarget}?action=users&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "edit":
|
|
$next_naction = "update";
|
|
|
|
$record_num = intval($_GET['record_num']);
|
|
|
|
// Get current record
|
|
$query = "select * from $CurrentTable " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $record_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
}
|
|
else {
|
|
$error_message = getLanguageText('RECORD-NOT-FOUND-MSG');
|
|
header("Location: {$FormTarget}?action=users&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
include $FormFile;
|
|
break;
|
|
|
|
case "update":
|
|
extract($_POST);
|
|
$record_num = intval($record_num);
|
|
$error_message = "";
|
|
|
|
$args = "&lookup_where=" . urlencode($lookup_where) .
|
|
"&show_status=$show_status" .
|
|
"&show_type=$show_type" .
|
|
"&sortby=$sortby" .
|
|
"&show_modifier=$show_modifier" .
|
|
"&aview=$aview";
|
|
|
|
// Check if the user id is already in use
|
|
$query = "select * from users " .
|
|
"where school_num = $school_num " .
|
|
"and userid = '" . db_escape_string($userid) . "' " .
|
|
"and record_num != $record_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) > 0) {
|
|
$error_message = getLanguageText('ERRORMSG-USER-ID-NOT-AVAILABLE');
|
|
}
|
|
|
|
if (isset($error_message) && strlen($error_message) > 0) {
|
|
header("Location: {$FormTarget}?action=$action&naction=edit&record_num=$record_num&error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$temp_phone = preg_replace("/[^0-9]/","",$home_phone);
|
|
if (strlen($temp_phone) == 10) $home_phone = "(" . substr($temp_phone,0,3) . ")" . substr($temp_phone,3,3) . "-" . substr($temp_phone,6);
|
|
|
|
// Get existing record
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $school_num AND record_num = $record_num");
|
|
$user = db_fetch_assoc($results);
|
|
|
|
if ($status != $user['status']) {
|
|
// If setting an Active user to Suspended status
|
|
if ($user['status'] == 'Active' && ($status == 'Suspended' || $status == 'Inactive' || $status == 'Deleted')) {
|
|
$results = db_query("SELECT * FROM people WHERE school_num = $base_school_num AND people_type = 'Student' AND user_num = $record_num");
|
|
|
|
// Set student orders to 'Inactive'
|
|
if (db_num_rows($results)) {
|
|
while ($student = db_fetch_array($results)) {
|
|
$snum = $student['record_num'];
|
|
db_query("UPDATE hotlunch_order_header SET status = 'Inactive' WHERE school_num = $school_num AND ordered_by_num = $snum AND status = 'Unpaid'");
|
|
}
|
|
}
|
|
|
|
// Set students to Inactive as well
|
|
if ($status == 'Inactive' || $status == 'Deleted') db_query("UPDATE people SET status = 'Inactive', display = 'N' WHERE school_num = $base_school_num AND user_num = $record_num");
|
|
}
|
|
|
|
// If setting a Suspended user to Active status
|
|
if (($user['status'] == 'Suspended' || $user['status'] == 'Inactive') && $status == 'Active') {
|
|
$results = db_query("SELECT * FROM people WHERE school_num = $school_num AND people_type = 'Student' AND user_num = $record_num");
|
|
|
|
$default_order_status = $school_record['default_order_status'];
|
|
// Set student orders to 'Unpaid'
|
|
if (db_num_rows($results)) {
|
|
while ($student = db_fetch_array($results)) {
|
|
$snum = $student['record_num'];
|
|
db_query("UPDATE hotlunch_order_header SET status = '$default_order_status' WHERE school_num = $school_num AND ordered_by_num = $snum AND status = 'Inactive'");
|
|
}
|
|
}
|
|
|
|
// Set students to Verified as well
|
|
$display = 'Y';
|
|
if ($school_record['display_class_lists'] == 'N') $display = 'N';
|
|
if ($status == 'Inactive' || $status == 'Deleted') db_query("UPDATE people SET status = 'Verified', display = '$display' WHERE school_num = $base_school_num AND user_num = $record_num");
|
|
}
|
|
}
|
|
|
|
$password_crypt = encrypt_password($password);
|
|
|
|
$table = new Table("$CurrentTable");
|
|
$query = $table->BuildUpdate();
|
|
db_query($query);
|
|
|
|
// Update children if required
|
|
if ($type != $user['type']) {
|
|
if ($type == 'Staff') {
|
|
db_query("UPDATE people SET people_type = 'Staff', class_num = 0 WHERE school_num = $base_school_num AND user_num = $record_num");
|
|
db_query("UPDATE hotlunch_order_header SET ordered_by_type = 'Staff' WHERE school_num = $school_num AND ordered_by_num IN " .
|
|
"(SELECT record_num FROM people WHERE school_num = $base_school_num AND user_num = $record_num)");
|
|
}
|
|
|
|
if ($type == 'Parent') {
|
|
db_query("UPDATE people SET people_type = 'Student' WHERE school_num = $base_school_num AND user_num = $record_num");
|
|
db_query("UPDATE hotlunch_order_header SET ordered_by_type = 'Student' WHERE school_num = $school_num AND ordered_by_num IN " .
|
|
"(SELECT record_num FROM people WHERE school_num = $base_school_num AND user_num = $record_num)");
|
|
}
|
|
}
|
|
|
|
$user_num = $record_num;
|
|
$table = new Table("user_sites");
|
|
|
|
// Create any user_sites entries if required
|
|
db_query("DELETE FROM user_sites WHERE school_num = $base_school_num AND user_num = $record_num");
|
|
for ($i = 0; $i < count($selected_user_sites); $i++) {
|
|
$site_num = $selected_user_sites[$i];
|
|
$query = $table->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
|
|
// Set children to no display if the user is 'Inactive'
|
|
if ($status == 'Inactive' || $status == 'Suspended' || $status == 'Deleted') {
|
|
db_query("UPDATE people SET display = 'N' WHERE school_num = $school_num AND user_num = $record_num");
|
|
}
|
|
|
|
|
|
// Create people entry if this is a Guest account
|
|
if ($type == 'Guest') {
|
|
$cust = db_query("SELECT * FROM people WHERE school_num = $school_num AND user_num = $user_num");
|
|
if (db_num_rows($cust) == 0) {
|
|
$people = new Table("people");
|
|
$people_type = 'Customer';
|
|
$class_num = 1;
|
|
$status = 'Verified';
|
|
$display = 'N';
|
|
$active = 'N';
|
|
$menu_price_category = 'Regular';
|
|
$cust_phone = $home_phone;
|
|
$cust_email = $email;
|
|
$added_date = date("Y-m-d",time());
|
|
|
|
$query = $people->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
|
|
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
|
if (array_key_exists('donext',$_POST) && strlen($_POST['donext']) > 0) $naction = $_POST['donext'];
|
|
$naction = "show-info&user_num=$user_num";
|
|
header("Location: {$FormTarget}?action=users&naction=$naction$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "user-lookup":
|
|
include "users.lookup.php";
|
|
break;
|
|
|
|
case "user-lookup-search":
|
|
$search_text = db_escape_string($_POST['search_text']);
|
|
if (strlen($search_text) < 2) {
|
|
header("Location: {$FormTarget}?action=users&naction=search");
|
|
exit();
|
|
}
|
|
|
|
$sTextB = "'%25" . $search_text . "%25'";
|
|
$sText = "'" . $search_text . "%25'";
|
|
|
|
$lookup_where = "AND (u.first_name LIKE $sText " .
|
|
"OR u.last_name LIKE $sText " .
|
|
"OR u.userid LIKE $sTextB " .
|
|
"OR u.email LIKE $sTextB " .
|
|
"OR u.email2 LIKE $sTextB " .
|
|
"OR u.email3 LIKE $sTextB " .
|
|
"OR u.home_phone LIKE $sTextB)";
|
|
$naction = "list";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&lookup_where=" . urlencode($lookup_where));
|
|
break;
|
|
|
|
case "show-info":
|
|
include "users.info.php";
|
|
break;
|
|
|
|
case "merge-accounts":
|
|
$source = $_GET['source'];
|
|
$destination = $_GET['destination'];
|
|
$dname = db_getVal("SELECT concat(first_name,' ',last_name) FROM users WHERE school_num = $base_school_num AND record_num = $destination");
|
|
|
|
$entered = time();
|
|
$trx_datetime = date("Y-m-d H:i:s",$entered);
|
|
$unum = intval($_SESSION['UserInfo']['record_num']);
|
|
|
|
db_query("UPDATE people SET user_num = $destination WHERE school_num = $base_school_num AND user_num = $source");
|
|
db_query("UPDATE user_account SET user_num = $destination WHERE school_num = $school_num AND user_num = $source AND deleted != 'Y'");
|
|
db_query("INSERT INTO user_account (school_num,user_num,schedule_num,order_num,people_num,transaction_datetime,transaction_type,note,transaction_amount,transaction_fee,entered_by_user_num,entered_time,deleted) " .
|
|
"VALUES ($school_num,$source,0,0,0,'$trx_datetime','TRX Note','All Transactions Moved to Account $dname',0.00,0.00,$unum,$entered,'N')");
|
|
|
|
$selected_user_num = $destination;
|
|
header("Location: {$FormTarget}?action=users&naction=show-info&user_num=$destination");
|
|
exit();
|
|
|
|
case "delete-confirmed":
|
|
extract($_GET);
|
|
|
|
$record_num = intval($record_num);
|
|
|
|
$args = "&lookup_where=" . urlencode($lookup_where) .
|
|
"&show_status=$show_status" .
|
|
"&show_type=$show_type" .
|
|
"&sortby=$sortby" .
|
|
"&show_modifier=$show_modifier" .
|
|
"&aview=$aview";
|
|
|
|
// Get user account record
|
|
$query = "select * from $CurrentTable " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $record_num";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NOT-FOUND');
|
|
header("Location: {$FormTarget}?action=$action&naction=list$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$row = db_fetch_array($results);
|
|
extract($row,EXTR_PREFIX_ALL,'u');
|
|
$row['name'] = "$u_first_name $u_last_name";
|
|
|
|
if ($u_userid == 'admin') {
|
|
$error_message = getLanguageText('ERRORMSG-UNABLE-TO-DELETE-ADMIN');
|
|
header("Location: {$FormTarget}?action=$action&naction=list$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
// Check if this user has students linked to it
|
|
if ($u_type != 'Guest') {
|
|
$query = "select * from people " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $record_num";
|
|
$results = db_query($query);
|
|
|
|
// Unable to delete users with students
|
|
if (db_num_rows($results) > 0) {
|
|
$error_message = getLanguageText('ERRORMSG-UNABLE-TO-DELETE-USER-WITH-STUDENTS');
|
|
header("Location: {$FormTarget}?action=$action&naction=list$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
}
|
|
else {
|
|
// Check for Paid Orders
|
|
$paidOrders = db_getVal("SELECT count(*) FROM people AS p, hotlunch_order_header AS hloh " .
|
|
"WHERE p.school_num = $base_school_num " .
|
|
"AND hloh.school_num = $school_num " .
|
|
"AND p.user_num = $record_num " .
|
|
"AND p.active != 'N' " .
|
|
"AND p.record_num = hloh.ordered_by_num " .
|
|
"AND hloh.status = 'Paid'");
|
|
if ($paidOrders > 0) {
|
|
$error_message = getLanguageText('ERRORMSG-DELETE-WITH-PAID-ORDERS');
|
|
header("Location: {$FormTarget}?action=$action&naction=list$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
}
|
|
|
|
|
|
// If this is an admin user type then check if there are other admin types
|
|
if ($type == 'System Administrator') {
|
|
$num = db_getVal("select count(*) from users where school_num = $school_num and type = 'System Administrator'");
|
|
if ($num == 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ONLY-ADMIN-ACCOUNT');
|
|
header("Location: {$FormTarget}?action=$action&naction=list$args&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
}
|
|
|
|
// Delete the current record
|
|
$query = "delete from $CurrentTable " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $record_num";
|
|
db_query($query);
|
|
|
|
// Delete orders
|
|
$query = "delete from hotlunch_order_header " .
|
|
"where school_num = $school_num " .
|
|
"and status != 'Paid' " .
|
|
"and ordered_by_num IN (SELECT record_num FROM people WHERE school_num = $school_num AND user_num = $record_num)";
|
|
db_query($query);
|
|
|
|
// Delete Customer entries
|
|
$query = "delete from people " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $record_num " .
|
|
"and people_type IN ('Student','Customer')";
|
|
db_query($query);
|
|
|
|
// Delete contacts records
|
|
$query = "delete from contacts " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $record_num";
|
|
db_query($query);
|
|
|
|
// Delete account records
|
|
$query = "delete from user_account " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $record_num";
|
|
db_query($query);
|
|
|
|
// Delete any volunteer entries
|
|
$query = "delete from hotlunch_volunteers " .
|
|
"where school_num = $school_num " .
|
|
"and user_num = $record_num";
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-DELETED-MSG');
|
|
|
|
if (array_key_exists('show_modifier', $_GET) && strlen($_GET['show_modifier'])) {
|
|
$show_modifier = $_GET['show_modifier'];
|
|
header("Location: {$FormTarget}?action=users&naction=list&show_type=$show_type&show_modifier=$show_modifier&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
if (array_key_exists('show_type', $_GET) && strlen($_GET['show_type'])) {
|
|
$show_type = $_GET['show_type'];
|
|
header("Location: {$FormTarget}?action=users&naction=list&show_type=$show_type&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$naction = "search";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&show_type=$show_type&show_status=$show_status&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "search":
|
|
break;
|
|
|
|
case "lookup":
|
|
extract($_GET);
|
|
extract($_POST);
|
|
|
|
unset($user_ip);
|
|
unset($userid);
|
|
if (array_key_exists('userid',$_GET)) $userid = $_GET['userid'];
|
|
if (array_key_exists('userid',$_POST)) $userid = $_POST['userid'];
|
|
|
|
$table = new Table("$CurrentTable");
|
|
$lookup_query = $table->BuildQuery("","","u.");
|
|
$lookup_where = "";
|
|
if (stripos($lookup_query, "where ")) $lookup_where = preg_replace("/.* where/i","and",$lookup_query);
|
|
if (stripos($lookup_where, "order by ")) $lookup_where = preg_replace("/order by .*/i","",$lookup_where);
|
|
if (stripos($lookup_where, "u.school_num = $school_num AND ")) $lookup_where = preg_replace("/u.school_num = $school_num AND /i","",$lookup_where);
|
|
$naction = "list";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&lookup_where=" . urlencode($lookup_where));
|
|
exit();
|
|
|
|
case "fetch":
|
|
$lookup_where = "where u.record_num = $record_num";
|
|
$naction = "list";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&lookup_where=" . urlencode($lookup_where));
|
|
exit();
|
|
|
|
case "send-reminder":
|
|
// Get current record
|
|
$record_num = intval($_GET['record_num']);
|
|
if ($record_num == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
|
|
header("Location: {$FormTarget}?error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$query = "select * from $CurrentTable " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $record_num";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
|
|
if (strlen($row['email']) == 0) {
|
|
$error_message = getLanguageText('ERRORMSG-NO-EMAIL-ADDRESS') . " - '$row[userid]'";
|
|
$naction = "show-info&user_num=$user_num";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
if ($school_record['status'] == 'Special' && $_SESSION['UserInfo']['type'] != 'SuperUser') {
|
|
$error_message = "Unable to send emails from demo site";
|
|
header("Location: {$FormTarget}?form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
// Update user record
|
|
$time = time();
|
|
$change_datetime = date("Y-m-d H:i:s",$time);
|
|
db_query("UPDATE users SET change_datetime = '$change_datetime' WHERE record_num = $record_num");
|
|
|
|
// Format reset link
|
|
$at = strtotime($row['added_time']);
|
|
$userid = $row['userid'];
|
|
$ResetLink = $_SERVER['HTTP_HOST'] . "{$FormTarget}reset-password.php?id=$userid&rn=$record_num&tm=$time&at=$at";
|
|
|
|
if (array_key_exists('HTTPS',$_SERVER)) $ResetLink = "https://$ResetLink";
|
|
else $ResetLink = "http://$ResetLink";
|
|
// $ResetLink = "http://$ResetLink";
|
|
|
|
// Send reminder email to account
|
|
include_once("include/queuemail.php");
|
|
|
|
$emailRecipient = $row['userid'];
|
|
$emailTo = $row['email'];
|
|
$emailReply = $school_record['reply_description'];
|
|
$emailFrom = "notifications@easyschoolsoftware.net";
|
|
$emailFrom = setReplyAddress($school_record['support_email'],"notifications");
|
|
|
|
$emailSubject = $school_record['school_name'] . " " . getLanguageText('TEXT-SYSTEM-REMINDER');
|
|
|
|
// Setup user id edit message
|
|
$emailMessage = trim(db_getVal("SELECT text_data FROM text_data WHERE school_num = $school_num AND text_id = 'Parent Reminder'"));
|
|
$emailMessage .= "\n\n" .
|
|
"Web Address: http://$currentURL\n" .
|
|
"User ID: " . $row['userid'] . "\n" .
|
|
getLanguageText('TEXT-RESET-PASSWORD-LINK') . ": $ResetLink\n";
|
|
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
|
|
$naction = "search";
|
|
if (array_key_exists('next_naction',$_GET) && $_GET['next_naction'] == 'show-info') {
|
|
$naction = "show-info&user_num=$record_num";
|
|
}
|
|
|
|
$form_message = getLanguageText('MSG-REMINDER-EMAIL-SENT') . " - $emailTo";
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "weekly-reminder":
|
|
if ($school_record['status'] == 'Special') {
|
|
$error_message = "Unable to send emails from demo site";
|
|
header("Location: {$FormTarget}?form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$user_num = intval($record_num);
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $school_num AND record_num = $user_num");
|
|
$user = db_fetch_assoc($results);
|
|
|
|
$msg = getUserOrders($user_num,$school_num);
|
|
|
|
if (strlen($msg)) {
|
|
// Send reminder email to account
|
|
include_once("include/queuemail.php");
|
|
|
|
$emailRecipient = $user['userid'];
|
|
$emailTo = $user['email'];
|
|
$emailReply = $school_record['reply_description'];
|
|
$emailFrom = "notifications@easyschoolsoftware.net";
|
|
$emailFrom = setReplyAddress($school_record['support_email'],"notifications");
|
|
$emailMessage = $msg;
|
|
|
|
$emailSubject = $school_record['school_name'] . " " . getLanguageText('TEXT-ORDER-REMINDER');
|
|
QueueEmail($emailTo, $emailFrom, $emailSubject, $emailMessage, $emailReply, $emailRecipient);
|
|
}
|
|
|
|
$form_message = getLanguageText('MSG-REMINDER-EMAIL-SENT') . " - $emailTo";
|
|
header("Location: {$FormTarget}?action=users&naction=show-info&user_num=$user_num&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "update-balances":
|
|
// Post current account balance to the users table
|
|
$query = "select record_num from users where school_num = $school_num AND status in ('Active','Suspended')";
|
|
$results = db_query($query);
|
|
while ($row = db_fetch_array($results)) {
|
|
$unum = $row['record_num'];
|
|
updateUserBalance($unum,$school_num);
|
|
}
|
|
|
|
$naction = "search";
|
|
$form_message = getLanguageText('MSG-USER-BALANCES-UPDATED');
|
|
header("Location: {$FormTarget}?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case 'post-zero':
|
|
$user_num = intval($_GET['user_num']);
|
|
$selected_users = array($user_num);
|
|
|
|
case 'post-all-zero':
|
|
if (array_key_exists('selected_users',$_POST) && $naction == 'post-all-zero') {
|
|
if (array_key_exists('selected_users',$_POST)) $selected_users_string = $_POST['selected_users'];
|
|
$selected_users = explode(",",$selected_users_string);
|
|
}
|
|
|
|
// Create table object
|
|
$table = new Table("user_account");
|
|
$school_num = $school_record['record_num'];
|
|
|
|
// Setup defaults for insert
|
|
$transaction_type = 'Payment';
|
|
$payment_method = 'Posting';
|
|
$note = 'Account Posted to Zero';
|
|
$order_num = 0;
|
|
$ordered_by_num = 0;
|
|
$people_num = 0;
|
|
$transaction_status = 'Closed';
|
|
|
|
for ($i = 0; $i < count($selected_users); $i++) {
|
|
$user_num = $selected_users[$i];
|
|
|
|
// Get set of Unpaid and Inactive Orders
|
|
$query = "SELECT hloh.* FROM hotlunch_order_header as hloh, people as p " .
|
|
"WHERE hloh.school_num = $school_num " .
|
|
"AND ordered_by_num = p.record_num " .
|
|
"AND p.user_num = $user_num " .
|
|
"AND p.active != 'N' " .
|
|
"AND p.school_num = $base_school_num " .
|
|
"AND hloh.status NOT IN ('Paid','Complimentary','Concession')";
|
|
$orders = db_query($query);
|
|
|
|
$order_payments = "";
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
$onum = $row['record_num'];
|
|
$ototal = $row['order_total'];
|
|
$opaid = $row['amount_paid'];
|
|
$amt = str_replace(",","",number_format($ototal - $opaid));
|
|
if (strlen($order_payments) > 0) $order_payments .= "|";
|
|
$order_payments .= "{" . $onum . ":" . $amt . "}";
|
|
|
|
$query = "UPDATE hotlunch_order_header " .
|
|
"SET amount_paid = order_total, " .
|
|
"status = 'Paid', " .
|
|
"paid_date = '$today', " .
|
|
"payment_method = 'Posting' " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND record_num = $onum";
|
|
db_query($query);
|
|
}
|
|
|
|
// Get account balance
|
|
$transaction_amount = -1 * db_getVal("select sum(transaction_amount) from user_account where school_num = $school_num and user_num = $user_num AND (deleted != 'Y' OR deleted IS NULL)");
|
|
|
|
if ($transaction_amount != 0) {
|
|
// Get a schedule number
|
|
$end_date = date("Y-m-d",time() - 60 * 60 * 24 * 240);
|
|
$today = date("Y-m-d",time());
|
|
$now = date("Y-m-d H:i:s",time());
|
|
$schedule_num = db_getVal("SELECT record_num FROM hotlunch_schedules " .
|
|
"WHERE school_num = $school_num AND schedule_end_date >= '$end_date' AND start_order_datetime <= '$now' AND status NOT IN ('Closed','Deleted') " .
|
|
"ORDER BY start_order_datetime DESC LIMIT 0,1");
|
|
$entered_time = time();
|
|
$transaction_datetime = date("Y-m-d H:i:s",time());
|
|
$transaction_fee = 0.00;
|
|
$entered_by_user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
$deleted = 'N';
|
|
|
|
$query = $table->BuildInsert();
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
$naction = "list";
|
|
break;
|
|
|
|
default:
|
|
$naction = "list";
|
|
break;
|
|
}
|
|
|
|
|
|
//
|
|
// Display the search form if required
|
|
//
|
|
if ($naction == "search") {
|
|
$ChoosePagination = 'Y';
|
|
$next_naction = "lookup";
|
|
|
|
unset($userid);
|
|
unset($password);
|
|
unset($email);
|
|
unset($type);
|
|
unset($status);
|
|
unset($receive_emails);
|
|
unset($email_reminders);
|
|
$record_num = NULL;
|
|
|
|
include "users.lookup.php";
|
|
$displaySiteMessages = false;
|
|
// echo("<br>\n");
|
|
// include $FormFile;
|
|
}
|
|
|
|
|
|
//
|
|
// List all records if naction is "list"
|
|
//
|
|
if ($naction == "list") {
|
|
|
|
//
|
|
// Verify all user orders
|
|
//
|
|
if ($action == 'user-account-list' && in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator'))) {
|
|
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num");
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$uNum = $row['record_num'];
|
|
$orders = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $uNum AND transaction_type = 'Order'");
|
|
if (db_num_rows($orders) > 0) {
|
|
while ($row = db_fetch_assoc($orders)) {
|
|
$order_num = $row['order_num'];
|
|
$r = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND record_num = $order_num");
|
|
if (db_num_rows($r) == 0) {
|
|
db_query("DELETE FROM user_account WHERE school_num = $school_num AND user_num = $uNum AND transaction_type = 'Order' AND order_num = $order_num");
|
|
db_query("DELETE FROM hotlunch_order_items WHERE school_num = $school_num AND order_num = $order_num");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
include "form.messages.php";
|
|
|
|
// Manage sorting
|
|
$order_by_field = "last_name,first_name";
|
|
if (array_key_exists('sortby',$_GET) && strlen($_GET['sortby'])) {
|
|
$sortby = $_GET['sortby'];
|
|
$order_by_field = $sortby . ",last_name,first_name";
|
|
$action .= "&sortby=" . $_GET['sortby'];
|
|
}
|
|
|
|
// Manage subset selection
|
|
$swhere = "";
|
|
$show_status = "";
|
|
$show_type = "";
|
|
if (array_key_exists('show_status',$_REQUEST) && strlen($_REQUEST['show_status'])) {
|
|
$show_status = $_REQUEST['show_status'];
|
|
$swhere = "and u.status = '$show_status' ";
|
|
$action .= "&show_status=$show_status";
|
|
}
|
|
|
|
if (array_key_exists('show_type',$_REQUEST) && strlen($_REQUEST['show_type'])) {
|
|
$show_type = $_REQUEST['show_type'];
|
|
if ($show_type == 'Admin') {
|
|
$swhere = "and u.type not in ('Parent','Guest','Staff','Supplier') ";
|
|
}
|
|
else {
|
|
$swhere = "and u.type = '$show_type' ";
|
|
}
|
|
$action .= "&show_type=$show_type";
|
|
}
|
|
|
|
$post_all_to_zero = 'N';
|
|
$report_button = 'N';
|
|
$mwhere = "";
|
|
$mhaving = "";
|
|
if (array_key_exists('show_modifier',$_REQUEST) && strlen($_REQUEST['show_modifier'])) {
|
|
$show_modifier = $_REQUEST['show_modifier'];
|
|
if (array_key_exists('show_modifier', $_REQUEST) && $_REQUEST['show_modifier'] == 'noemail') {
|
|
$mwhere = "and (u.email = '' or u.email is null) ";
|
|
}
|
|
|
|
if (array_key_exists('show_modifier', $_REQUEST) && $_REQUEST['show_modifier'] == 'balance-owing') {
|
|
$mhaving = "having sum(ua.transaction_amount) > 0 ";
|
|
$report_button = 'Y';
|
|
$post_all_to_zero = 'Y';
|
|
}
|
|
|
|
if (array_key_exists('show_modifier', $_REQUEST) && $_REQUEST['show_modifier'] == 'balance-payable') {
|
|
$mhaving = "having sum(ua.transaction_amount) < 0 ";
|
|
$report_button = 'Y';
|
|
}
|
|
|
|
if (array_key_exists('show_modifier', $_REQUEST) && $_REQUEST['show_modifier'] == 'volunteers') {
|
|
$mwhere = "and u.available_to_volunteer = 'Y' ";
|
|
$report_button = 'Y';
|
|
}
|
|
|
|
$action .= "&show_modifier=" . $_REQUEST['show_modifier'];
|
|
}
|
|
|
|
|
|
$scriptName = str_replace("/m/data1/app.hotlunches.net{$FormTarget}","",__FILE__);
|
|
include "help.docs.php";
|
|
|
|
$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 ";
|
|
}
|
|
|
|
if (!isset($lookup_where)) $lookup_where = '';
|
|
$lookup_where = urldecode($lookup_where);
|
|
|
|
// Get set of user records
|
|
$columnHeaders = array(getLanguageText('TEXT-USER-ID'),
|
|
getLanguageText('TEXT-NAME'),
|
|
getLanguageText('TEXT-TYPE'),
|
|
getLanguageText('TEXT-STATUS'),
|
|
getLanguageText('TEXT-ORDER'),
|
|
getLanguageText('TEXT-EMAIL'),
|
|
getLanguageText('TEXT-BALANCE'),
|
|
$GlobalText['Students']);
|
|
$columnAlign = array('left','left','left','center','center','center','center','center');
|
|
$query = "SELECT email,userid,first_name,last_name,type,status,can_order,receive_emails,sum(ua.transaction_amount) as balance,trx_status,home_phone,date_added,email_flag,u.record_num " .
|
|
"FROM users AS u LEFT JOIN user_account AS ua ON $acctSchool user_num = u.record_num and (ua.deleted != 'Y' or ua.deleted is null) " .
|
|
"WHERE u.school_num = $base_school_num " .
|
|
$lookup_where .
|
|
$swhere .
|
|
$mwhere .
|
|
"GROUP BY 1,2,3,4,5,6,7,8,10,11,12,13,14 " .
|
|
$mhaving .
|
|
"ORDER BY $order_by_field";
|
|
echo("<!-- QUERY:: $query -->\n\n");
|
|
$results = db_query($query);
|
|
$numRecords = db_num_rows($results);
|
|
|
|
$otipSpans = "";
|
|
$otipSpanIDs = array();
|
|
|
|
$users = array();
|
|
$selected_users = "";
|
|
if ($numRecords > 0) {
|
|
$count = 0;
|
|
while ($row = db_fetch_array($results)) {
|
|
extract($row);
|
|
if (strlen($selected_users)) $selected_users .= ",";
|
|
$selected_users .= $record_num;
|
|
|
|
$query = "SELECT * FROM people " .
|
|
"WHERE school_num = $base_school_num " .
|
|
"AND user_num = $record_num " .
|
|
"AND active != 'N' " .
|
|
"AND people_type IN ('Student','Customer')";
|
|
$students = db_query($query);
|
|
$nstudents = db_num_rows($students);
|
|
if (array_key_exists('show_modifier', $_REQUEST) && $_REQUEST['show_modifier'] == 'nostudents' && $nstudents > 0) continue;
|
|
|
|
if ($nstudents > 0) {
|
|
$sclass = "";
|
|
$span_id = "students_$record_num";
|
|
$otipSpans .= "<span id='$span_id'>" . $otipTABLE;
|
|
$ototal = 0;
|
|
while ($student = db_fetch_array($students)) {
|
|
if ($student['class_num'] > 1) {
|
|
$otipSpans .= sprintf($otipROW2nb,'<nobr><b>' . $student['first_name'] . ' ' . $student['last_name'] . '</b> - </nobr>',
|
|
'<nobr>' . getClassInfo($student['class_num']) . '</nobr>');
|
|
}
|
|
else {
|
|
$otipSpans .= sprintf($otipROW2nb,'<nobr><b>' . $student['first_name'] . ' ' . $student['last_name'] . '</b> - </nobr>','Customer');
|
|
}
|
|
|
|
// Get list of Unpaid orders for this student
|
|
$orders = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $student[record_num] AND status NOT IN ('Paid','Complimentary','Deleted')");
|
|
if (db_num_rows($orders) > 0) {
|
|
$otable = "<table>";
|
|
while ($order = db_fetch_assoc($orders)) {
|
|
$stitle = db_getVal("SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $order[schedule_num]");
|
|
$otable .= "<tr><td align='left'>" . $order['status'] . " - </td>";
|
|
$otable .= "<td align='right'><b>$" . $order['order_total'] . "</b></td>";
|
|
$otable .= "<td align='left'> - $stitle</td>";
|
|
$otable .= "</tr>";
|
|
$ototal += round($order['order_total'],2);
|
|
if ($order['status'] == 'Inactive') $sclass = 'error';
|
|
}
|
|
$otable .= "</table>";
|
|
$otipSpans .= sprintf($otipROW2,' ',$otable);
|
|
}
|
|
}
|
|
|
|
if (round($ototal,2) != round($balance,2) && $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$nstudents = "<span class='warning'>$nstudents</span>";
|
|
$otipSpans .= sprintf($otipROW2,$ototal,$balance);
|
|
}
|
|
|
|
$otipSpans .= "</table></span>\n";
|
|
if (strlen($sclass)) $nstudents = "<span class='$sclass'> $nstudents </span>";
|
|
$nstudents = "<b><a href=\"?action=account-students&naction=display&uid=$record_num\" onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$nstudents</a></b>";
|
|
|
|
// $ncontacts = db_getVal("SELECT count(*) FROM contacts WHERE school_num = $school_num AND user_num = $record_num");
|
|
}
|
|
|
|
if ($balance < 0) $balance = "-" . $currencySymbol . number_format(abs($balance),2);
|
|
else $balance = $currencySymbol . number_format($balance,2);
|
|
|
|
$span_id = "user_$record_num";
|
|
$otipSpans .= "<span id='$span_id'>" . $otipTABLE .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-USER-ID') . ': </nobr>',$userid) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-USER-TYPE') . ': </nobr>',$type) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-NAME') . ': </nobr>',$first_name . ' ' . $last_name) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-EMAIL') . ': </nobr>',$email) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-PHONE') . ': </nobr>',$home_phone) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-DATE-ADDED') . ': </nobr>',$date_added) .
|
|
sprintf($otipROW2,'<nobr>' . getLanguageText('TEXT-CURRENT-BALANCE') . ': </nobr>',$balance) .
|
|
"</table></span>\n";
|
|
|
|
// Translate fields
|
|
if ($receive_emails == 'Y') $receive_emails_display = getLanguageText('TEXT-YES');
|
|
if ($receive_emails == 'N') $receive_emails_display = getLanguageText('TEXT-NO');
|
|
$receive_emails_display = "<span id='email$record_num' class='user-emails' val='$receive_emails' rnum='$record_num'>$receive_emails_display</span>";
|
|
if ($school_record['email_system'] == 'Y' && $type == 'Parent') $receive_emails_display .= "<br><span class='email-flag' val='$email_flag' rnum='$record_num'>($email_flag)</span>";
|
|
|
|
if ($can_order == 'Yes') $can_order_display = getLanguageText('TEXT-YES');
|
|
if ($can_order == 'No') $can_order_display = getLanguageText('TEXT-NO');
|
|
if ($can_order == 'Balance') $can_order_display = getLanguageText('TEXT-BALANCE');
|
|
|
|
if ($status == 'Active') $status_display = getLanguageText('TEXT-ACTIVE');
|
|
if ($status == 'Inactive') $status_display = getLanguageText('TEXT-INACTIVE');
|
|
if ($status == 'Deleted') $status_display = getLanguageText('TEXT-DELETED');
|
|
if ($status == 'Pending') $status_display = getLanguageText('TEXT-PENDING');
|
|
if ($status == 'Suspended') $status_display = getLanguageText('TEXT-SUSPENDED');
|
|
|
|
$ttype = getLanguageText(strtoupper('CODE-'.$type));
|
|
if (strlen($ttype)) $type = $ttype;
|
|
|
|
$status = getLanguageText(strtoupper('CODE-'.$status));
|
|
|
|
$users[$count] = array("<a href='mailto:$email' onmouseover=\"TagToTip('$span_id')\" onmouseout=\"UnTip()\">$userid</a>",
|
|
"$first_name $last_name",
|
|
$type,
|
|
"<span id='status$record_num' class='user-status' val='$status' rnum='$record_num'>$status_display</span>",
|
|
"<span id='order$record_num' class='user-can-order' val='$can_order' rnum='$record_num'>$can_order_display</span>",
|
|
$receive_emails_display,
|
|
$balance,
|
|
$nstudents);
|
|
$users[$count]['record_num'] = $record_num;
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
|
|
$students_icon = "<img src='images/icons/groupofusers24.png' alt='View Students' border='0'>";
|
|
$contacts_icon = "<img src='images/icons/userid24.png' alt='View Contact Information' border='0'>";
|
|
$reminder_icon = "<img src='images/icons/mailsend24.png' alt='Send Account Login Reminder Email' border='0'>";
|
|
$weekly_reminder_icon = "<img src='images/icons/mailsend24.png' alt='Send Weekly Menu Reminder Email' border='0'>";
|
|
$money_icon = "<img src='images/icons/money24.png' alt='Post to User Account' border='0'>";
|
|
$moneypost_icon = "<img src='images/icons/money-post24.png' alt='Post Account Balance to Zero' border='0'>";
|
|
|
|
$commands = array(
|
|
"<a href='?action=account-students&naction=display&show_status=$show_status&show_type=$show_type&uid=%d' title='View Students'>$students_icon</a>",
|
|
"<a href='?action=account-contacts&naction=list&show_status=$show_status&show_type=$show_type&uid=%d' title='View Contact Information'>$contacts_icon</a>",
|
|
"<a href='?action=$action&naction=send-reminder&record_num=%d' title='Send Account Login Reminder Email'>$reminder_icon</a>",
|
|
"<a href='?action=$action&naction=weekly-reminder&record_num=%d' title='Send Weekly Menu Reminder Email'>$weekly_reminder_icon</a>",
|
|
"<a href='?action=users&naction=show-info&user_num=%d' title='User Info'>$info_icon</a>",
|
|
"<a href='?action=user-account&naction=add&user_num=%d' title='Post to User Account'>$money_icon</a>"
|
|
);
|
|
|
|
$insert_new = 'Y';
|
|
if (strpos($action, 'user-account-list')) $insert_new = 'N';
|
|
|
|
if (!isset($lookup_where)) $lookup_where = '';
|
|
if (!isset($show_status)) $show_status = '';
|
|
if (!isset($show_type)) $show_type = '';
|
|
if (!isset($sortby)) $sortby = '';
|
|
if (!isset($show_modifier)) $show_modifier = '';
|
|
if (!isset($aview)) $aview = '';
|
|
|
|
$args = "&lookup_where=" . urlencode($lookup_where) .
|
|
"&show_status=$show_status" .
|
|
"&show_type=$show_type" .
|
|
"&sortby=$sortby" .
|
|
"&show_modifier=$show_modifier" .
|
|
"&aview=$aview";
|
|
$action .= "&donext=list";
|
|
|
|
if (in_array($_SESSION['UserInfo']['type'],array('Administration Team','Schedule Team','Financial','Financial Team')) || $school_record['status'] == 'Linked') {
|
|
if (in_array($_SESSION['UserInfo']['type'],array('Financial','Financial Team')) || $school_record['status'] == 'Linked') {
|
|
$commands = array("<a href='?action=user-account&naction=add&user_num=%d' title='Post to User Account'>$money_icon</a>");
|
|
listDataCustom($users,$columnHeaders,$action,$commands,$insert_new,$columnAlign);
|
|
}
|
|
else {
|
|
listDataCustom($users,$columnHeaders,$action,$commands,$insert_new,$columnAlign);
|
|
}
|
|
}
|
|
else {
|
|
listData($users,$columnHeaders,$action,$commands,$insert_new,$columnAlign,array(),"",$args);
|
|
}
|
|
|
|
if ($post_all_to_zero == 'Y' && strlen($selected_users) > 0 && count($users) > 0) {
|
|
if ($_SESSION['UserInfo']['type'] == 'System Administrator' || $_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$msg = getLanguageText('TEXT-CONFIRM-UPDATE');
|
|
?>
|
|
<br>
|
|
<form method='post' action='<?php echo($FormTarget) ?>' onClick='return confirm("<?php echo($msg) ?>")'>
|
|
<input type='submit' class='formButton' value="<?php displayLanguageText('TEXT-SET-ACCOUNTS-TO-ZERO'); ?>">
|
|
<input type='hidden' name='action' value='user-account-list'>
|
|
<input type='hidden' name='naction' value='post-all-zero'>
|
|
<input type='hidden' name='show_modifier' value='balance-owing'>
|
|
<input type='hidden' name='selected_users' value='<?php echo($selected_users) ?>'>
|
|
</form>
|
|
<?php
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#amount-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 200,
|
|
minHeight: 200,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#block-from-ordering").click(function(e) {
|
|
e.preventDefault();
|
|
var title = "<?php displayLanguageText('TEXT-BALANCE-GREATER-THAN'); ?>";
|
|
$("#amount-title").html(title);
|
|
|
|
$("#naction").val('Block');
|
|
$("#amount-dialog").dialog("open");
|
|
});
|
|
|
|
$("#clear-for-ordering").click(function(e) {
|
|
e.preventDefault();
|
|
var title = "<?php displayLanguageText('TEXT-BALANCE-LESS-THAN'); ?>";
|
|
$("#amount-title").html(title);
|
|
|
|
$("#naction").val('Clear');
|
|
$("#amount-dialog").dialog("open");
|
|
});
|
|
|
|
$("#post-amount").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var amount = $("#amount").val();
|
|
var naction = $("#naction").val();
|
|
$("#amount-dialog").dialog("close");
|
|
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: "ajax.UserUpdate.php",
|
|
data: { amount: amount, naction: naction }
|
|
}).done(function(){
|
|
location.reload();
|
|
});
|
|
});
|
|
|
|
$(document).on("click", ".user-status", function() {
|
|
var Status = $(this).attr('val');
|
|
var rnum = $(this).attr('rnum');
|
|
var spanID = $(this);
|
|
|
|
var data = "table_name=users"+
|
|
"&sequence_flag=N"+
|
|
"&record_num="+rnum+
|
|
"&Validation=N"+
|
|
"&status=";
|
|
|
|
switch (Status) {
|
|
case 'Active':
|
|
var newVal = "Inactive";
|
|
var newText = "<?php displayLanguageText('TEXT-INACTIVE'); ?>";
|
|
break;
|
|
|
|
case 'Inactive':
|
|
var newVal = "Active";
|
|
var newText = "<?php displayLanguageText('TEXT-ACTIVE'); ?>";
|
|
break;
|
|
}
|
|
|
|
data += newVal;
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$(spanID).html(newText);
|
|
$(spanID).attr('val',newVal);
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on("click", ".user-can-order", function() {
|
|
var Status = $(this).attr('val');
|
|
var rnum = $(this).attr('rnum');
|
|
var spanID = $(this);
|
|
|
|
var data = "table_name=users"+
|
|
"&sequence_flag=N"+
|
|
"&record_num="+rnum+
|
|
"&Validation=N"+
|
|
"&can_order=";
|
|
|
|
switch (Status) {
|
|
case 'Y':
|
|
var newVal = "No";
|
|
var newText = "<?php displayLanguageText('TEXT-NO'); ?>";
|
|
break;
|
|
|
|
case 'N':
|
|
var newVal = "Balance";
|
|
var newText = "<?php displayLanguageText('TEXT-BALANCE'); ?>";
|
|
break;
|
|
|
|
case 'B':
|
|
var newVal = "Yes";
|
|
var newText = "<?php displayLanguageText('TEXT-YES'); ?>";
|
|
break;
|
|
}
|
|
|
|
data += newVal;
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$(spanID).html(newText);
|
|
$(spanID).attr('val',newVal);
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on("click", ".user-emails", function() {
|
|
var Status = $(this).attr('val');
|
|
var rnum = $(this).attr('rnum');
|
|
var spanID = $(this);
|
|
|
|
var data = "table_name=users"+
|
|
"&sequence_flag=N"+
|
|
"&record_num="+rnum+
|
|
"&Validation=N"+
|
|
"&receive_emails=";
|
|
|
|
switch (Status) {
|
|
case 'Y':
|
|
var newVal = "N";
|
|
var newText = "<?php displayLanguageText('TEXT-NO'); ?>";
|
|
break;
|
|
|
|
case 'N':
|
|
var newVal = "Y";
|
|
var newText = "<?php displayLanguageText('TEXT-YES'); ?>";
|
|
break;
|
|
}
|
|
|
|
data += newVal;
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$(spanID).html(newText);
|
|
$(spanID).attr('val',newVal);
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on('click', '.email-flag', function(e) {
|
|
var Flag = $(this).attr('val');
|
|
var rnum = $(this).attr('rnum');
|
|
var spanID = $(this);
|
|
|
|
var data = "table_name=users"+
|
|
"&sequence_flag=N"+
|
|
"&record_num="+rnum+
|
|
"&Validation=N"+
|
|
"&email_flag=";
|
|
|
|
switch (Flag) {
|
|
case 'Y':
|
|
var newVal = "N";
|
|
var newText = '(N)';
|
|
break;
|
|
|
|
case 'N':
|
|
var newVal = "Y";
|
|
var newText = '(Y)';
|
|
break;
|
|
}
|
|
|
|
data += newVal;
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$(spanID).html(newText);
|
|
$(spanID).attr('val',newVal);
|
|
}
|
|
);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<div id='amount-dialog' title="<?php displayLanguageText('TEXT-AMOUNT'); ?>">
|
|
<p align='left'><b><label for='amount'><span id='amount-title'><?php displayLanguageText('TEXT-AMOUNT'); ?></span></label>:</b><br>
|
|
<input type='text' name='amount' id='amount' size='15'></p>
|
|
<p><button id='post-amount'> <?php displayLanguageText('TEXT-UPDATE'); ?> </button>
|
|
<input type='hidden' name='naction' id='naction'>
|
|
</div>
|
|
<?php
|
|
|
|
endTemplate();
|
|
?>
|