245 lines
8.9 KiB
PHP
245 lines
8.9 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
// if ($_SESSION['UserInfo']['type'] == 'SuperUser') startLog("users");
|
|
// writeLog("school_num: $school_num base_school_num: $base_school_num");
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$CurrentTable = "users";
|
|
$FormFile = "users.dialog.php";
|
|
$JQueryFile = "users.js.php";
|
|
$CustomLoadData = "Y";
|
|
$DialogWidth = 600;
|
|
$TitleText = getLanguageText('TEXT-USERS');
|
|
$SequenceFlag = 'N';
|
|
$tableAction = "users-list";
|
|
$RequiredFields = array('userid','first_name','last_name');
|
|
$RequiredFields = array('userid');
|
|
$LoadInitialData = 'N';
|
|
|
|
$today = date("Y-m-d", time());
|
|
$FieldDefaultValues = array(
|
|
'type' => 'Parent',
|
|
'status' => 'Active',
|
|
'date_added' => $today,
|
|
'can_order' => 'Yes',
|
|
'has_order' => 'N',
|
|
'language' => $school_record['default_language'],
|
|
);
|
|
|
|
$CustomDialogFields = array(
|
|
array('field_name' => 'selected_user_sites', 'default' => '', 'ftype' => 'form-data'),
|
|
);
|
|
|
|
$JSinitForm = "
|
|
$('#delete-icon').show();
|
|
";
|
|
|
|
$JSeditData = "
|
|
var delete_flag = results.delete_flag;
|
|
if (delete_flag == 'N') $('#delete-icon').hide();
|
|
";
|
|
|
|
$CustomValidation = "
|
|
var user_type = $('#dialog_type').val();
|
|
|
|
if (user_type == 'Parent' || user_type == 'Guest') {
|
|
var first_name = $('#dialog_first_name').val();
|
|
first_name = first_name.trim();
|
|
if (first_name == null || first_name.length == 0) {
|
|
var mtext = $('label[for=dialog_first_name]').text();
|
|
form_error_message += 'Error: missing data in form: '+mtext+'\\n';
|
|
form_error = true;
|
|
$('#dialog_first_name').addClass('missing-data');
|
|
}
|
|
|
|
var last_name = $('#dialog_last_name').val();
|
|
last_name = last_name.trim();
|
|
if (last_name == null || last_name.length == 0) {
|
|
var mtext = $('label[for=dialog_last_name]').text();
|
|
form_error_message += 'Error: missing data in form: '+mtext+'\\n';
|
|
form_error = true;
|
|
$('#dialog_last_name').addClass('missing-data');
|
|
}
|
|
}
|
|
";
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = getLanguageText('TEXT-USER-ADMINISTRATION');
|
|
if ($action == 'user-account-list') $templatePageTitle = getLanguageText('TEXT-USER-ACCOUNT-LIST');
|
|
|
|
$naction = '';
|
|
if (array_key_exists('naction', $_GET)) $naction = db_escape_string($_GET['naction']);
|
|
|
|
|
|
// 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');
|
|
header("Location: /?action=$action&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Verify all user orders
|
|
//
|
|
if (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");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
include "users.options.php";
|
|
include "form.js.php";
|
|
|
|
?>
|
|
<input type='hidden' id='sortby'>
|
|
<input type='hidden' id='show_status'>
|
|
<input type='hidden' id='show_type'>
|
|
<input type='hidden' id='show_modifier'>
|
|
<input type='hidden' id='show_custom'>
|
|
|
|
|
|
<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' class="form-field text ui-widget-content ui-corner-all"></p>
|
|
|
|
<table width='100%'>
|
|
<tr>
|
|
<td align='center' style='background-color: #e0e0e0; height: 25px;'>
|
|
<button id='post-amount' class='btn btn--outline btn--small'> <?php displayLanguageText('TEXT-UPDATE'); ?> </button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='naction' id='naction'>
|
|
</div>
|
|
|
|
<div id='info-dialog' title="<?php displayLanguageText('TEXT-INFORMATION'); ?>">
|
|
<center>
|
|
<div id='dynamic-info-div'></div>
|
|
<br>
|
|
<table width='100%'>
|
|
<tr>
|
|
<td align='center' style='background-color: #e0e0e0; height: 25px;'>
|
|
<button id='closeInfoDialogBtn' class='btn btn--outline btn--small'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
|
|
<div id='orders-dialog' title="<?php displayLanguageText('TEXT-ORDERS'); ?>">
|
|
<center>
|
|
<div id='orders-div'></div>
|
|
<br>
|
|
<table width='100%'>
|
|
<tr>
|
|
<td align='center' style='background-color: #e0e0e0; height: 25px;'>
|
|
<button id='closeOrdersDialogBtn' class='btn btn--outline btn--small'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
$Users = array();
|
|
$query = "SELECT * FROM users WHERE school_num = $base_school_num AND type IN ('Parent','Guest','Staff') ORDER BY type,last_name, first_name";
|
|
$users = db_query($query);
|
|
while ($row = db_fetch_assoc($users)) {
|
|
$unum = $row['record_num'];
|
|
$num = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $unum");
|
|
$row['num'] = $num;
|
|
$Users[] = $row;
|
|
}
|
|
?>
|
|
<div id='merge-dialog' title="<?php displayLanguageText('TEXT-MERGE-USER-ACCOUNTS'); ?>">
|
|
<center>
|
|
<p align='left'><b><label for='source_user_account'><?php displayLanguageText('TEXT-SOURCE-USER-ACCOUNT'); ?></label>:</b><br>
|
|
<select name='source_user_account' id='source_user_account' class="form-field select-width400 text ui-widget-content ui-corner-all">
|
|
<option value='0'><?php displayLanguageText('TEXT-SELECT-USER'); ?></option>
|
|
<?php
|
|
$ptype = '';
|
|
for ($i = 0; $i < count($Users); $i++) {
|
|
extract($Users[$i]);
|
|
$school_num = $school_record['record_num'];
|
|
|
|
if ($type != $ptype) {
|
|
if (strlen($ptype)) echo(" </optgroup>\n");
|
|
echo(" <optgroup label='$type'>\n");
|
|
}
|
|
$ptype = $type;
|
|
|
|
echo(" <option value='$record_num'>$last_name, $first_name - $userid ($num)</option>\n");
|
|
}
|
|
echo(" </optgroup>\n");
|
|
?>
|
|
</select></p>
|
|
<p align='left'><b><label for='destination_user_account'><?php displayLanguageText('TEXT-DESTINATION-USER-ACCOUNT'); ?></label>:</b><br>
|
|
<select name='destination_user_account' id='destination_user_account' class="form-field select-width400 text ui-widget-content ui-corner-all">
|
|
<option value='0'><?php displayLanguageText('TEXT-SELECT-USER'); ?></option>
|
|
<?php
|
|
$ptype = '';
|
|
for ($i = 0; $i < count($Users); $i++) {
|
|
extract($Users[$i]);
|
|
$school_num = $school_record['record_num'];
|
|
|
|
if ($type != $ptype) {
|
|
if (strlen($ptype)) echo(" </optgroup>\n");
|
|
echo(" <optgroup label='$type'>\n");
|
|
}
|
|
$ptype = $type;
|
|
|
|
echo(" <option value='$record_num'>$last_name, $first_name - $userid ($num)</option>\n");
|
|
}
|
|
echo(" </optgroup>\n");
|
|
?>
|
|
</select></p>
|
|
<p><b><?php displayLanguageText('TEXT-MERGE-ACCOUNTS-MESSAGE'); ?></b></p>
|
|
<br>
|
|
<table width='100%'>
|
|
<tr>
|
|
<td align='center' style='background-color: #e0e0e0; height: 25px;'>
|
|
<button id='closeMergeDialogBtn' class='btn btn--outline btn--small'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button>
|
|
<button id='MergeAccountsBtn' class='btn btn--primary btn--small'> <?php displayLanguageText('TEXT-MERGE-ACCOUNTS'); ?> </button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
|
|
<div id='trx-dialog' title="<?php displayLanguageText('TEXT-USER-ACCOUNT'); ?>">
|
|
<div id='user-account-div'></div>
|
|
<p><button class='trx-close-window-btn btn btn--outline btn--small'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button></p>
|
|
</div>
|
|
|
|
<?php
|
|
endTemplate();
|
|
?>
|