143 lines
4.7 KiB
PHP
143 lines
4.7 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Setup defaults for the lookup
|
|
//
|
|
?>
|
|
|
|
<br>
|
|
<?php
|
|
$message_width = $default_form_width;
|
|
include "form.messages.php";
|
|
?>
|
|
<table width='<?php echo($default_form_width) ?>' class='content-table'>
|
|
<tr>
|
|
<td colspan='2' align='center' class='heading'><?php displayLanguageText('TEXT-LOOKUP-FORM'); ?></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<form method='post'>
|
|
<table width='100%' cellpadding='1' cellspacing='1' border='0' align='center'>
|
|
<tr>
|
|
<td align='left' valign='top' >
|
|
<?php echo(getLanguageText('TEXT-SEARCH')) ?>:<br>
|
|
<input type='text' name='search_text' id='search_text' tabindex=1 size='40'><br>
|
|
<span class='small'><?php displayLanguageText('MESSAGE-USER-LOOKUP'); ?></span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<div id=dataResultsRow>
|
|
<div style="width: 700px; border: 1px solid #000; border-bottom: none; background:#eee;">
|
|
<table id=dataResultsHead border=0 cellspacing=0 cellpadding=2>
|
|
<tr>
|
|
<th align=left><?php echo(getLanguageText('TEXT-NAME')) ?></th>
|
|
<th align=left><?php echo(getLanguageText('TEXT-USER-ID')) ?></th>
|
|
<th align=left><?php echo(getLanguageText('TEXT-TYPE')) ?></th>
|
|
<th align=left><?php echo(getLanguageText('TEXT-PHONE')) ?></th>
|
|
<th align=center><?php echo(getLanguageText('TEXT-NUMBER')) ?></th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div id=dataResultsScroll style="height:100px; width:700px; overflow:auto; border: 1px solid #000; border-top: none; background:#fff;">
|
|
<table id=dataResultsTable border=0 cellspacing=0 cellpadding=2><tr><td></td></tr></table>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='users'>
|
|
<input type='hidden' name='naction' value='user-lookup-search'>
|
|
</form>
|
|
<br>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function($) {
|
|
|
|
$("#search_text").focus();
|
|
|
|
var dataCellWidths = [150, 150, 250, 120, 80];
|
|
for (i=0; i<dataCellWidths.length; i++) $('#dataResultsHead th').eq(i).css('width', dataCellWidths[i]);
|
|
|
|
// Hide everything by default
|
|
var dataSearch = $('#search_text');
|
|
var dataResultsRow = $('#dataResultsRow').hide();
|
|
var dataResultsTable = $('#dataResultsTable');
|
|
var dataResultsScroll = $('#dataResultsScroll');
|
|
|
|
|
|
// Handle typing in the search box
|
|
dataSearch.keyup(function() {
|
|
var searchName = $(this).val();
|
|
if (searchName.length < 2) {
|
|
doClick(null);
|
|
return;
|
|
}
|
|
var d = new Date();
|
|
searchName = escape(searchName);
|
|
$.getJSON('ajaxSearchUsers.php', {s:searchName, sn:<?php echo($school_num) ?>, bn:<?php echo($base_school_num) ?>, d:d.getTime()}, updateResults);
|
|
});
|
|
|
|
function updateResults(data) {
|
|
var row;
|
|
var radio;
|
|
|
|
if (data.length == 0) {
|
|
doClick(null);
|
|
return;
|
|
}
|
|
|
|
// empty the results table, and rebuild it
|
|
dataResultsTable.empty();
|
|
|
|
for (var i=0; i<data.length; i++) {
|
|
row = $('<tr>');
|
|
row.append($('<td align=left>').css('width', dataCellWidths[0]).html(unescape(decodeURIComponent( data[i]['name'] ))));
|
|
row.append($('<td align=left>').css('width', dataCellWidths[1]).html(data[i]['userid']==''?' ':unescape(data[i]['userid'])));
|
|
row.append($('<td align=left>').css('width', dataCellWidths[2]).html(data[i]['type']));
|
|
row.append($('<td align=left>').css('width', dataCellWidths[3]).html(data[i]['phone']==''?' ':data[i]['phone']));
|
|
row.append($('<td align=center>').css('width', dataCellWidths[4]).html(data[i]['students']));
|
|
row.data('info', data[i]);
|
|
dataResultsTable.append(row);
|
|
}
|
|
|
|
// treat a click anywhere on the row as a click on the radio button
|
|
$('#dataResultsTable tr *').css('cursor','pointer').click(function() {
|
|
doClick($(this).closest('tr'));
|
|
});
|
|
|
|
// display results, if the height > 150px, setup autoscroll
|
|
dataResultsScroll.css('overflow','visible').css('height', 'auto');
|
|
dataResultsRow.show();
|
|
if (dataResultsScroll.height() > 150) dataResultsScroll.css('overflow','auto').css('height', 150);
|
|
}
|
|
function doClick(row) {
|
|
if (row != null) {
|
|
// clicked on a selection
|
|
data = row.data('info');
|
|
location.href= '?action=users&naction=show-info&user_num=' + data['record_num'];
|
|
}
|
|
dataResultsRow.hide();
|
|
dataResultsTable.empty();
|
|
}
|
|
$('#search_text').focus(function() {
|
|
dataResultsRow.hide();
|
|
dataResultsTable.empty();
|
|
});
|
|
doClick(null);
|
|
|
|
});
|
|
</script>
|
|
|