First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
+789
@@ -0,0 +1,789 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$CurrentTable = "people";
|
||||
$DeleteField = "title,first_name,last_name";
|
||||
$dSeparator = " ";
|
||||
$FormFile = "staff.form.php";
|
||||
$TitleText = getLanguageText('TEXT-STAFF-PERSON');
|
||||
$OrderBy = "last_name,first_name";
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = "$TitleText " . getLanguageText('TEXT-ADMINISTRATION');
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
include "form.messages.php";
|
||||
endTemplate();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
if (isset($new_naction)) $naction = $new_naction;
|
||||
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
$school_num = $base_school_num;
|
||||
|
||||
|
||||
switch (strtolower($naction)) {
|
||||
case "add":
|
||||
$next_naction = "insert";
|
||||
$active = 'Y';
|
||||
|
||||
include $FormFile;
|
||||
break;
|
||||
|
||||
case "insert":
|
||||
extract($_POST);
|
||||
|
||||
// Validate the data entered
|
||||
if (strlen($last_name) == 0 && strlen($first_name) == 0) {
|
||||
$error_message = getLanguageText('MSG-MISSING-STAFF-NAME');
|
||||
$naction = "add";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Save the record
|
||||
$user_num = 0;
|
||||
$people_type = 'Staff';
|
||||
$can_order = 'Yes';
|
||||
$class_num = 0;
|
||||
if (!isset($active)) $active = 'Y';
|
||||
if (!isset($menu_price_category) || strlen($menu_price_category) == 0) $menu_price_category = 'Regular';
|
||||
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildInsert();
|
||||
db_query($query);
|
||||
$staff_num = db_insert_id();
|
||||
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
||||
|
||||
// Create a user account for this staff person
|
||||
if ($school_record['staff_userid'] == 'email' && strlen($email)) {
|
||||
$userid = $email;
|
||||
}
|
||||
else {
|
||||
if (strlen($first_name) > 0) {
|
||||
if (strlen($last_name) > 0) $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name) . "." . str_replace(".","",$last_name)));
|
||||
else $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name)));
|
||||
}
|
||||
else {
|
||||
$userid = str_replace(' ','',strtolower(str_replace(".","",$last_name)));
|
||||
}
|
||||
}
|
||||
|
||||
$userid = str_replace("'","",$userid);
|
||||
|
||||
// Check if this 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('MSG-ACCOUNT-EXISTS') . " ($userid)";
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$users_table = new Table("users");
|
||||
$password = $userid;
|
||||
$type = 'Staff';
|
||||
$status = 'Active';
|
||||
$receive_emails = 'Y';
|
||||
$email_reminders = 'Y';
|
||||
$date_added = date("Y-m-d",time());
|
||||
$language = $school_record['default_staff_language'];
|
||||
$query = $users_table->BuildInsert();
|
||||
db_query($query);
|
||||
$user_num = db_insert_id();
|
||||
|
||||
$query = "update people set user_num = $user_num where record_num = $staff_num";
|
||||
db_query($query);
|
||||
|
||||
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
|
||||
case "edit":
|
||||
$next_naction = "update";
|
||||
|
||||
// Get current record
|
||||
$record_num = intval($_GET['record_num']);
|
||||
$query = "select * from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results) == 1) {
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
$email = db_getVal("SELECT email FROM users WHERE record_num = $user_num");
|
||||
include $FormFile;
|
||||
}
|
||||
else {
|
||||
$error_message = getLanguageText('ERRORMSG-NOT-FOUND');
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
|
||||
case "update":
|
||||
extract($_POST);
|
||||
|
||||
// Validate the data entered
|
||||
if (strlen($last_name) == 0 && strlen($first_name) == 0) {
|
||||
$error_message = getLanguageText('MSG-MISSING-STAFF-NAME');
|
||||
$naction = "edit";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Check for an existing user id
|
||||
$curr_user_num = db_getVal("SELECT user_num FROM people WHERE school_num = $base_school_num AND record_num = $record_num");
|
||||
|
||||
|
||||
if (!isset($active)) $active = 'Y';
|
||||
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildUpdate();
|
||||
db_query($query);
|
||||
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
||||
$naction = "list";
|
||||
|
||||
// Create a user account for this staff person
|
||||
if (!isset($user_num) || strlen($user_num) == 0 || $user_num == 0) {
|
||||
if ($curr_user_num > 0) db_query("DELETE FROM users WHERE school_num = $base_school_num AND record_num = $curr_user_num");
|
||||
|
||||
if ($school_record['staff_userid'] == 'email' && strlen($email)) {
|
||||
$userid = $email;
|
||||
}
|
||||
else {
|
||||
if (strlen($first_name) > 0) {
|
||||
if (strlen($last_name) > 0) $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name) . "." . str_replace(".","",$last_name)));
|
||||
else $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name)));
|
||||
}
|
||||
else {
|
||||
$userid = str_replace(' ','',strtolower(str_replace(".","",$last_name)));
|
||||
}
|
||||
}
|
||||
|
||||
$userid = str_replace("'","",$userid);
|
||||
|
||||
$query = "select * from users " .
|
||||
"where school_num = $school_num " .
|
||||
"and userid = '" . db_escape_string($userid) . "'";
|
||||
$results = db_query($query);
|
||||
|
||||
// Create a new user if necessary
|
||||
if (db_num_rows($results) == 0) {
|
||||
$users_table = new Table("users");
|
||||
$password = $userid;
|
||||
$type = 'Staff';
|
||||
$status = 'Active';
|
||||
$receive_emails = 'Y';
|
||||
$date_added = date("Y-m-d",time());
|
||||
$query = $users_table->BuildInsert();
|
||||
db_query($query);
|
||||
$user_num = db_insert_id();
|
||||
|
||||
$query = "update people set user_num = $user_num where record_num = $record_num";
|
||||
db_query($query);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($first_name) > 0) {
|
||||
if (strlen($last_name) > 0) $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name) . "." . str_replace(".","",$last_name)));
|
||||
else $userid = str_replace(' ','',strtolower(str_replace(".","",$first_name)));
|
||||
}
|
||||
else {
|
||||
$userid = str_replace(' ','',strtolower(str_replace(".","",$last_name)));
|
||||
}
|
||||
|
||||
$userid = str_replace("'","",$userid);
|
||||
|
||||
// Check if this user id is already in use
|
||||
$query = "select * from users " .
|
||||
"where school_num = $school_num " .
|
||||
"and userid = '" . db_escape_string($userid) . "' " .
|
||||
"and record_num != $user_num";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) > 0) {
|
||||
$error_message .= getLanguageText('MSG-ACCOUNT-EXISTS') . " ($userid)";
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$set = "last_name = '" . db_escape_string($last_name) . "', first_name = '" . db_escape_string($first_name) . "'";
|
||||
$set .= ", userid = '$userid'";
|
||||
|
||||
// Get original user record
|
||||
$results = db_query("SELECT * FROM users WHERE school_num = $school_num AND record_num = $user_num");
|
||||
$ouser = db_fetch_assoc($results);
|
||||
|
||||
// Update user account with email if there is one
|
||||
if (strlen($email) > 0 || strlen($ouser['email'])) {
|
||||
$set .= ", email = '" . db_escape_string($email) . "'";
|
||||
}
|
||||
|
||||
db_query("update users set $set where record_num = $user_num");
|
||||
}
|
||||
|
||||
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
|
||||
case "delete-confirmed":
|
||||
$record_num = intval($_GET['record_num']);
|
||||
|
||||
// Check if this person has orders in the system
|
||||
$num = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $record_num AND status = 'Paid'");
|
||||
if ($num > 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-DELETE-WITH-PAID-ORDERS');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Delete the user account for this staff person
|
||||
$query = "select user_num from people " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$user_num = db_getVal($query);
|
||||
|
||||
if ($user_num) {
|
||||
$query = "delete from users " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $user_num";
|
||||
db_query($query);
|
||||
|
||||
$query = "delete from user_account " .
|
||||
"where school_num = $school_num " .
|
||||
"and user_num = $user_num";
|
||||
db_query($query);
|
||||
}
|
||||
|
||||
// Clear out and entries for this staff person in any classes
|
||||
db_query("UPDATE classes SET teacher1 = NULL WHERE school_num = $school_num AND teacher1 = $record_num");
|
||||
db_query("UPDATE classes SET teacher2 = NULL WHERE school_num = $school_num AND teacher2 = $record_num");
|
||||
db_query("UPDATE classes SET teacher3 = NULL WHERE school_num = $school_num AND teacher3 = $record_num");
|
||||
db_query("UPDATE classes SET teacher4 = NULL WHERE school_num = $school_num AND teacher4 = $record_num");
|
||||
db_query("UPDATE classes SET teacher5 = NULL WHERE school_num = $school_num AND teacher5 = $record_num");
|
||||
|
||||
// Delete the current record
|
||||
$query = "delete from people " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
db_query($query);
|
||||
|
||||
$form_message = getLanguageText('RECORD-DELETED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
|
||||
case "upload":
|
||||
$num_fields = $_POST['num_fields'];
|
||||
$fields = explode(",",$_POST['fields']);
|
||||
|
||||
// Get and process the data file
|
||||
$temp_name = $_FILES['filename']['tmp_name'];
|
||||
$file_name = str_replace(' ','_',$_FILES['filename']['name']);
|
||||
|
||||
if (strlen($file_name) == 0) {
|
||||
$error_message = getLanguageText('MSG-NO-SOURCE-DATA-FILE');
|
||||
$naction = "upload-form";
|
||||
header("Location: /?action=$action&naction=$naction&error_message=".urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Validate the file type
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$ftype = finfo_file($finfo,$temp_name);
|
||||
if ($ftype != "text/plain") {
|
||||
$error_message = getLanguageText('ERRORMSG-INVALID-FILE-FORMAT');
|
||||
$naction = "upload-form";
|
||||
header("Location: /?action=$action&naction=$naction&error_message=".urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Move file to temp folder
|
||||
if (!move_uploaded_file($temp_name,"temp/$school_num.staff.csv")) {
|
||||
$error_message = getLanguageText('MSG-ZERO-UPLOADED');
|
||||
$new_naction = "upload-form";
|
||||
break;
|
||||
}
|
||||
|
||||
// Open and process the data file
|
||||
$fp = fopen("temp/$school_num.staff.csv","r");
|
||||
$records = 0;
|
||||
|
||||
$userid_source = $_POST['userid_source'];
|
||||
$password_source = $_POST['password_source'];
|
||||
|
||||
$user_count = 0;
|
||||
$staff_count = 0;
|
||||
$error_count = 0;
|
||||
|
||||
// Delete existing entries
|
||||
db_query("DELETE FROM people WHERE school_num = $base_school_num AND people_type = 'Staff'");
|
||||
db_query("DELETE FROM users WHERE school_num = $base_school_num AND type = 'Staff'");
|
||||
|
||||
|
||||
// Setup defaults for staff insert
|
||||
$people = new Table("people");
|
||||
$added_date = date("Y-m-d",time());
|
||||
$date_added = $added_date;
|
||||
$people_type = "Staff";
|
||||
$class_num = 0;
|
||||
$status = "Verified";
|
||||
$display = 'N';
|
||||
$active = 'Y';
|
||||
$menu_price_category = "Regular";
|
||||
$staff_category = $school_record['default_staff_category'];
|
||||
|
||||
while (($data = fgetcsv($fp,10000,",")) !== FALSE) {
|
||||
$numDataFields = count($data);
|
||||
if ($numDataFields == 0) continue;
|
||||
|
||||
// Parse the data from the record
|
||||
for ($i = 0; $i < count($fields); $i++) {
|
||||
$fname = $fields[$i];
|
||||
unset($$fname);
|
||||
if (array_key_exists($fname, $_POST) && strlen($_POST[$fname]) > 0) {
|
||||
$col = $_POST[$fname] - 1;
|
||||
$$fname = str_replace('$','',trim($data[$col]));
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that there is at least a name
|
||||
if (strlen($first_name) == 0 || strlen($last_name) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Process data to create user account and get user_num
|
||||
$user_num = 0;
|
||||
|
||||
// Set userid
|
||||
switch ($userid_source) {
|
||||
case 'Email Address':
|
||||
$userid = $email;
|
||||
break;
|
||||
|
||||
case 'From File':
|
||||
if (!isset($userid) || strlen($userid) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-USERID-DATA-MISSING');
|
||||
$naction = "upload-form";
|
||||
header("Location: /?action=$action&naction=$naction&error_message=".urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'First Name and Last Name':
|
||||
$userid = str_replace(' ','.',str_replace("'","",str_replace(' ','',strtolower($first_name)))) . '.' . str_replace(' ','.',str_replace("'","",str_replace(' ','',strtolower($last_name))));
|
||||
break;
|
||||
}
|
||||
|
||||
// Set password
|
||||
switch ($password_source) {
|
||||
case 'Email Address':
|
||||
$password = $email;
|
||||
break;
|
||||
|
||||
case 'From File':
|
||||
if (!isset($password) || strlen($password) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-PASSWORD-DATA-MISSING');
|
||||
$naction = "upload-form";
|
||||
header("Location: /?action=$action&naction=$naction&error_message=".urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'First Name and Last Name':
|
||||
$password = str_replace(' ','.',str_replace("'","",str_replace(' ','',strtolower($first_name)))) . '.' . str_replace(' ','.',str_replace("'","",str_replace(' ','',strtolower($last_name))));
|
||||
break;
|
||||
}
|
||||
|
||||
// If category is set lookup the category number
|
||||
if (isset($category) && strlen($category)) {
|
||||
$num = db_getVal("SELECT record_num FROM staff_categories WHERE school_num = $school_num AND category_title = '" . db_escape_string($category) . "'");
|
||||
if ($num > 0) $category = $num;
|
||||
else $category = $default_staff_category;
|
||||
}
|
||||
else $category = $default_staff_category;
|
||||
|
||||
|
||||
// Check if the user id already exists
|
||||
$userid = db_escape_string($userid);
|
||||
$password = db_escape_string($password);
|
||||
$email = db_escape_string($email);
|
||||
$default_language = $school_record['default_language'];
|
||||
|
||||
$results = db_query("SELECT * FROM users WHERE school_num = $base_school_num AND userid = '" . db_escape_string($userid) . "'");
|
||||
if (db_num_rows($results) == 1) {
|
||||
$row = db_fetch_array($results);
|
||||
$user_num = $row['record_num'];
|
||||
}
|
||||
else {
|
||||
$fname = db_escape_string($first_name);
|
||||
$lname = db_escape_string($last_name);
|
||||
db_query("INSERT INTO users (school_num,userid,password,email,type,status,date_added,can_order,has_order,num_orders,balance_owing,account_balance,receive_emails,language,first_name,last_name) " .
|
||||
"VALUES ($base_school_num,'$userid','$password','$email','Staff','Active','$today','Yes','N',0,0.00,0.00,'Y','$default_language','$fname','$lname')");
|
||||
$user_num = db_insert_id();
|
||||
$user_count++;
|
||||
}
|
||||
|
||||
|
||||
// Check if this staff person is already in system
|
||||
$query = "SELECT * FROM people " .
|
||||
"WHERE school_num = $base_school_num " .
|
||||
"AND first_name = '" . db_escape_string($first_name) . "' " .
|
||||
"AND last_name = '" . db_escape_string($last_name) . "' " .
|
||||
"AND people_type = '$people_type'";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results) == 0) {
|
||||
// Create the staff people entry
|
||||
$school_num = $base_school_num;
|
||||
$query = $people->BuildInsert();
|
||||
db_query($query);
|
||||
$staff_count++;
|
||||
}
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data[] = array(getLanguageText('TEXT-STAFF'),$staff_count);
|
||||
$data[] = array(getLanguageText('TEXT-USER-ACCOUNTS'),$user_count);
|
||||
$data[] = array(getLanguageText('TEXT-ERRORS'),$error_count);
|
||||
|
||||
$columnHeaders = array(getLanguageText('TEXT-RESULT'),getLanguageText('TEXT-NUMBER'));
|
||||
$columnAlign = array('center','center');
|
||||
$TableWidth = 450;
|
||||
listDataCustom($data,$columnHeaders,'',array(),'N',$columnAlign);
|
||||
|
||||
break;
|
||||
|
||||
case "set-price-category":
|
||||
$category = $_POST['category'];
|
||||
|
||||
db_query("UPDATE people SET menu_price_category = '$category' WHERE school_num = $base_school_num AND people_type = 'Staff'");
|
||||
$form_message = getLanguageText('RECORDS-UPDATED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
|
||||
case "reset-passwords":
|
||||
db_query("UPDATE users SET password = userid WHERE school_num = $base_school_num AND type = 'Staff'");
|
||||
$form_message = getLanguageText('RECORDS-UPDATED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
|
||||
default:
|
||||
$naction = "list";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// List all records if naction is "list"
|
||||
//
|
||||
if ($naction == "list") {
|
||||
|
||||
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
|
||||
include "help.docs.php";
|
||||
|
||||
if ($school_record['special_item_prices'] == 'Y') {
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
<?php include "include/ajax.Setup.php" ?>
|
||||
|
||||
$(document).on("click", ".price-category", function() {
|
||||
var mcat = $(this).attr('mcat');
|
||||
var snum = $(this).attr('snum');
|
||||
var spanID = $(this);
|
||||
|
||||
var Regular = "Regular";
|
||||
var Special1 = "<span class='warning'>Special 1</span>";
|
||||
var Special2 = "<span class='warning'>Special 2</span>";
|
||||
var Special3 = "<span class='warning'>Special 3</span>";
|
||||
var newText;
|
||||
|
||||
var data = "table_name=people"+
|
||||
"&sequence_flag=N"+
|
||||
"&record_num="+snum+
|
||||
"&menu_price_category=";
|
||||
|
||||
switch (mcat) {
|
||||
case 'regular':
|
||||
var cat = "Special 1";
|
||||
var ncat = "special1";
|
||||
data = data+cat;
|
||||
newText = Special1;
|
||||
break;
|
||||
|
||||
case 'special1':
|
||||
var cat = "Special 2";
|
||||
var ncat = "special2";
|
||||
data = data+cat;
|
||||
newText = Special2;
|
||||
break;
|
||||
|
||||
case 'special2':
|
||||
var cat = "Special 3";
|
||||
var ncat = "special3";
|
||||
data = data+cat;
|
||||
newText = Special3;
|
||||
break;
|
||||
|
||||
case 'special3':
|
||||
var cat = "Regular";
|
||||
var ncat = "regular";
|
||||
data = data+cat;
|
||||
newText = Regular;
|
||||
break;
|
||||
}
|
||||
|
||||
$.getJSON("ajax.DataRecord.Update.php", data,
|
||||
function(results) {
|
||||
$(spanID).html(newText);
|
||||
$(spanID).attr('mcat',ncat);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
// Get records to display
|
||||
$columnHeaders = array(getLanguageText('TEXT-NAME'),
|
||||
getLanguageText('TEXT-CATEGORY'),
|
||||
getLanguageText('TEXT-USER-ID'),
|
||||
getLanguageText('TEXT-CLASS'));
|
||||
$columnAlign = array("left","center","left","left");
|
||||
|
||||
$description = 'N';
|
||||
// $num = db_getVal("SELECT count(*) FROM people WHERE school_num = $school_num AND people_type = 'Staff' AND (staff_description IS NOT NULL OR staff_description > '')");
|
||||
$num = 0;
|
||||
if ($num > 0) {
|
||||
$columnHeaders[] = getLanguageText('TEXT-DESCRIPTION');
|
||||
$columnAlign[] = "left";
|
||||
$description = 'Y';
|
||||
}
|
||||
|
||||
if ($school_record['special_item_prices'] != 'N') {
|
||||
$columnHeaders[] = getLanguageText('TEXT-MENU-PRICE-CATEGORY');
|
||||
$columnAlign[] = "center";
|
||||
}
|
||||
|
||||
$div_text = $school_record['division_class_num_text'];
|
||||
$query = "SELECT p.*,category_title " .
|
||||
"FROM people AS p LEFT JOIN staff_categories AS sc ON (sc.school_num = $school_num AND sc.record_num = p.staff_category) " .
|
||||
"WHERE p.school_num = $school_num " .
|
||||
"AND people_type = 'Staff' " .
|
||||
"ORDER BY last_name,first_name";
|
||||
$results = db_query($query);
|
||||
|
||||
$data = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
extract($row);
|
||||
|
||||
// Format the name
|
||||
if (strlen($title)) $name = "$title $first_name $last_name";
|
||||
else $name = "$first_name $last_name";
|
||||
|
||||
// Get and format userid
|
||||
$userid = '';
|
||||
|
||||
$ruser = db_query("SELECT * FROM users WHERE school_num = $school_num AND record_num = $user_num");
|
||||
if (db_num_rows($ruser)) {
|
||||
$user = db_fetch_assoc($ruser);
|
||||
$userid = $user['userid'];
|
||||
$userid = "<a href='/?action=users&naction=lookup&userid=$userid'>$userid</a>";
|
||||
|
||||
// If there is an email address create a link for the name field
|
||||
if (strlen($user['email']) && strstr($user['email'],'@')) {
|
||||
$name = "<a href='mailto:" . $user['email'] . "'>$name</a>";
|
||||
}
|
||||
}
|
||||
|
||||
// Check class number
|
||||
$nclasses = db_getVal("SELECT count(*) FROM classes WHERE school_num = $school_num AND record_num = $class_num");
|
||||
if ($nclasses > 0) {
|
||||
// Get class info
|
||||
$classinfo = getClassInfo($class_num,'internal',0);
|
||||
}
|
||||
else {
|
||||
$class_num = db_getVal("SELECT record_num FROM classes " .
|
||||
"WHERE school_num = $school_num " .
|
||||
"AND (teacher1 = $record_num OR teacher2 = $record_num OR teacher3 = $record_num OR teacher4 = $record_num OR teacher5 = $record_num) " .
|
||||
"LIMIT 0,1");
|
||||
if ($class_num) {
|
||||
db_query("UPDATE people SET class_num = $class_num WHERE school_num = $school_num AND record_num = $record_num");
|
||||
$classinfo = getClassInfo($class_num,'internal',0);
|
||||
}
|
||||
else {
|
||||
db_query("UPDATE people SET class_num = 0 WHERE school_num = $school_num AND record_num = $record_num");
|
||||
$classinfo = "";
|
||||
}
|
||||
}
|
||||
|
||||
if ($school_record['implement_meal_locations'] == 'Y') {
|
||||
$location = "";
|
||||
if ($meal_location > 0) {
|
||||
if ($meal_location != $class_num) $location = "<span class='small warning'>" . db_getVal("SELECT description FROM classes WHERE school_num = $base_school_num AND record_num = $meal_location") . "</span>";
|
||||
else $location = "<span class='small'>" . getLanguageText('TEXT-CLASSROOM') . "</span>";
|
||||
}
|
||||
if (strlen($location)) $name .= "<br>$location";
|
||||
}
|
||||
|
||||
$numOrders = 0;
|
||||
$numOrders = db_getVal("SELECT count(*) FROM hotlunch_order_header WHERE school_num = $school_num AND ordered_by_num = $record_num");
|
||||
if ($numOrders > 0) $name .= " ($numOrders)";
|
||||
|
||||
if ($school_record['special_item_prices'] == 'N') $data[] = array($name, $category_title, $userid, $classinfo, "record_num" => $record_num);
|
||||
else {
|
||||
$mcat = strtolower(str_replace(' ','',$menu_price_category));
|
||||
$mclass = '';
|
||||
if ($menu_price_category != 'Regular') $mclass = 'warning';
|
||||
$menu_price_category = "<span class='price-category' snum='$record_num' mcat='$mcat'><span class='$mclass'>" . $menu_price_category . "</span></span>";
|
||||
$data[] = array($name, $category_title, $userid, $classinfo, $menu_price_category, "record_num" => $record_num);
|
||||
}
|
||||
}
|
||||
|
||||
$message_width = $default_data_width;
|
||||
include "form.messages.php";
|
||||
|
||||
echo("<center>\n");
|
||||
echo("<p><b>$TitleText List</b></p>\n");
|
||||
echo("</center>\n");
|
||||
|
||||
listData($data,$columnHeaders,$action,array(),'Y',$columnAlign);
|
||||
echo("</center>\n");
|
||||
}
|
||||
|
||||
?>
|
||||
<table cellpadding='5'>
|
||||
<tr>
|
||||
<td><a href='?action=staff-report' class='largeButton'><?php displayLanguageText('TEXT-STAFF-REPORT'); ?></a></td>
|
||||
<td><a href='?action=staff-csv' class='largeButton'><?php displayLanguageText('TEXT-STAFF-CSV'); ?></a></td>
|
||||
<?php if ($school_record['implement_meal_locations'] == 'Y' && $_SESSION['UserInfo']['type'] == 'SuperUser') { ?>
|
||||
<td><a href='' id='set-locations' class='largeButton'><?php displayLanguageText('TEXT-DELIVERY-LOCATIONS'); ?></a></td>
|
||||
<?php } ?>
|
||||
<td><a href='?action=staff&naction=reset-passwords' onclick='return confirm("<?php displayLanguageText('TEXT-CONFIRM-UPDATE'); ?>");' class='largeButton'><?php displayLanguageText('TEXT-RESET-PASSWORDS'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
include "staff.set_price_category.form.php";
|
||||
|
||||
include "staff.upload.form.php";
|
||||
|
||||
?>
|
||||
<div id='locations-dialog' title="<?php displayLanguageText('TEXT-MANAGE-LOCATIONS'); ?>">
|
||||
<p align='left'><b><label for='selected_location'><?php displayLanguageText('TEXT-DELIVERY-LOCATIONS'); ?></label>:</b><br>
|
||||
<select name='selected_location' id='selected_location'>
|
||||
<?php
|
||||
$query = "SELECT * FROM classes WHERE school_num = $base_school_num AND entry_type = 'Location' ORDER BY description";
|
||||
$results = db_query($query);
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
echo("<option value='" . $row['record_num'] . "'>" . $row['description'] . "</option>\n");
|
||||
}
|
||||
?>
|
||||
</select></p>
|
||||
<button id='all-staff'> <?php displayLanguageText('TEXT-ALL-STAFF'); ?> </button>
|
||||
<button id='staff-without-location'> <?php displayLanguageText('TEXT-STAFF-WITHOUT-LOCATION'); ?> </button>
|
||||
<button id='classroom'> <?php displayLanguageText('TEXT-CLASSROOM'); ?> </button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
<?php include "include/ajax.Setup.php" ?>
|
||||
|
||||
$("#locations-dialog").dialog({
|
||||
autoOpen: false,
|
||||
minWidth: 400,
|
||||
modal: true,
|
||||
position: { my: 'center', at: 'center' }
|
||||
});
|
||||
|
||||
$("#set-locations").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#locations-dialog").dialog("open");
|
||||
});
|
||||
|
||||
$("#all-staff").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#locations-dialog").dialog("close");
|
||||
|
||||
var location = $("#selected_location").val();
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: "ajax.StaffLocationUpdate.php",
|
||||
data: { set: 'all', location: location }
|
||||
}).done(function(){
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
|
||||
$("#staff-without-location").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#locations-dialog").dialog("close");
|
||||
|
||||
var location = $("#selected_location").val();
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: "ajax.StaffLocationUpdate.php",
|
||||
data: { set: 'selected', location: location }
|
||||
}).done(function(){
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
|
||||
$("#classroom").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#locations-dialog").dialog("close");
|
||||
|
||||
var location = 'classroom';
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: "ajax.StaffLocationUpdate.php",
|
||||
data: { set: 'classroom', location: location }
|
||||
}).done(function(){
|
||||
window.location.reload(true);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user