science-ation/admin/user_list.php
dave 9c40cc91f8 A working user editor. It uses the same pages that the user actually sees (via
a $_SESSION['embed'] variable to change the behaviour).  It uses tabs to switch
between the various sections.  Converted committee, volunteer, and judge
editor.  Relies on using a popup window, don't know if that's a good idea or
not, but it sure looks cool.
2009-01-19 23:33:54 +00:00

226 lines
6.8 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
user_auth_required('committee', 'admin');
include "judges.inc.php";
send_header("User Editor",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php')
);
?>
<script language="javascript" type="text/javascript">
function openeditor(id)
{
if(id)
currentid=id;
/* else
currentid=document.forms.judges["judgelist[]"].options[document.forms.judges["judgelist[]"].selectedIndex].value;*/
window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes");
return false;
}
function toggleoptions()
{
if(document.getElementById('options').style.display == 'none') {
document.getElementById('options').style.display = 'block';
document.getElementById('optionstext').innerHTML = '- <?=i18n('Hide Display Options')?>';
} else {
document.getElementById('options').style.display = 'none';
document.getElementById('optionstext').innerHTML = '+ <?=i18n('Show Display Options')?>';
}
}
</script>
<?
$show_types = $_GET['show_types'];
if(user_valid_type($show_types) == false) {
$show_types = array('judge');
}
$show_complete = ($_GET['show_complete'] == 'yes') ? 'yes' : 'no';
$show_year = ($_GET['show_year'] == 'all') ? 'all' : 'current';
$uid = intval($_GET['uid']);
if($_GET['action']=='remove') {
if(!$uid) {
echo "Invalid uid for delete";
exit;
}
user_delete($uid);
}
echo "<div class=\"notice\">";
echo "<a id=\"optionstext\" href=\"javascript:toggleoptions()\">- ".i18n('Hide Display Options')."</a>";
echo "<form method=\"GET\" action=\"$PHP_SELF\">";
echo "<div id=\"options\" style=\"display: block;\" >";
echo "<table><tr><td>".i18n('Type').":</td>";
$x = 0;
foreach($user_what as $k=>$v ) {
$sel = (in_array($k, $show_types)) ? 'checked="checked"' : '';
echo "<td><input type=\"checkbox\" name=\"show_types[]\" value=\"$k\" $sel >".i18n($v)."</input></td>";
if($x) echo "</tr><tr><td></td>";
$x = ~$x;
}
echo "</tr>";
echo "<tr><td>".i18n('Complete').":</td><td>";
echo "<select name=\"show_complete\">";
$s = ($show_complete == 'yes') ? 'selected="selected"' : '';
echo "<option value=\"all\" $s>".i18n('Show only complete registrations')."</option>";
$s = ($show_complete == 'no') ? 'selected="selected"' : '';
echo "<option value=\"no\" $s>".i18n('Show ALL registrations')."</option>";
echo "</select>";
echo "</tr>";
echo "<tr><td>".i18n('Year').":</td><td>";
echo "<select name=\"show_year\">";
$s = ($show_year == 'current') ? 'selected="selected"' : '';
echo "<option value=\"current\" $s>".i18n('Show only registrations from %1', array($config['FAIRYEAR']))."</option>";
$s = ($show_year == 'all') ? 'selected="selected"' : '';
echo "<option value=\"all\" $s>".i18n('Show ALL years')."</option>";
echo "</select>";
echo "</td></tr></table>";
echo "<br />";
echo "<input type=submit value=\"".i18n('Filter')."\">";
echo "</div>";
echo "</form>";
echo "</div>";
echo "<br />";
/* Grab a list of users */
$w = array();
foreach($show_types as $t) {
$w [] = "users.types LIKE '%$t%'";
}
$where_types = "AND (".join(" OR ", $w).")";
$where_complete = "";
if($show_complete == 'yes') {
foreach($show_types as $t) {
$where_complete .= "AND ({$t}_complete='yes' OR {$t}_complete IS NULL) ";
}
}
if($show_year == 'current')
$where_year = "AND year={$config['FAIRYEAR']}";
echo "<table class=\"viewtable\">";
$querystr="SELECT
*
FROM
users
LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`users`.`id`
LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`users`.`id`
LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`users`.`id`
LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`users`.`id`
LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`users`.`id`
WHERE
users.deleted='no'
$where_year
$where_types
$where_complete
ORDER BY
lastname ASC,
firstname ASC,
year DESC";
$q=mysql_query($querystr);
echo mysql_error();
// echo $querystr;
$num=mysql_num_rows($q);
echo i18n("Listing %1 people total. See the bottom for breakdown of by complete status",array($num));
echo mysql_error();
echo "<tr>";
echo " <th>".i18n("Name")."</th>";
echo " <th>".i18n("Type(s)")."</th>";
echo " <th>".i18n("Email Address")."</th>";
echo " <th>".i18n("Year")."</th>";
echo " <th>".i18n("Complete")."</th>";
echo " <th>".i18n("Actions")."</th>";
echo "</tr>";
$completeyes=0;
$completeno=0;
while($r=mysql_fetch_assoc($q))
{
echo "<tr><td>";
echo "<a href=\"#\" onclick=\"return openeditor({$r['id']})\">{$r['firstname']} {$r['lastname']}</a>";
echo "</td><td>";
$types = split(',', $r['types']);
foreach($types as $t) {
echo $user_what[$t]."<br />";
}
echo "</td>";
echo "<td>{$r['email']}</td>";
echo "<td>{$r['year']}</td>";
echo "<td>";
foreach($types as $t) {
if($r["{$t}_complete"] == 'yes') {
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
$completeyes++;
} else {
echo "<div class=\"error\" align=\"center\">".i18n("no")."</div>";
$completeno++;
}
}
echo "</td>";
echo "<td align=\"center\">";
echo "<a onclick=\"return confirmClick('Are you sure you want to deactivate this judge from this years fair?')\" href=\"judges_judges.php?action=remove&remove=$r->id\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo i18n("Note: Deleting judges from this list only deactivates the judge for this year's fair. To completely delete a judge, use the 'Manage Judges' page");
echo "<br />";
echo "<br />";
echo "$num ".i18n("people listed.");
echo "<br />";
echo "$completeyes ".i18n('complete');
echo "<br />";
echo "$completeno ".i18n('incomplete');
echo "<br />";
echo "<br />";
echo "<br />";
send_footer();
?>