forked from science-ation/science-ation
Udated user_list to work with new account system
This commit is contained in:
parent
5207e193fc
commit
bffcf724d8
@ -29,12 +29,17 @@
|
||||
|
||||
require_once('judges.inc.php');
|
||||
|
||||
$user_what = array();
|
||||
$query = mysql_query("SELECT `type`, `name` FROM roles");
|
||||
while($row = mysql_fetch_assoc($query)){
|
||||
$user_what[$row['type']] = $row['name'];
|
||||
}
|
||||
|
||||
$show_types = $_GET['show_types'];
|
||||
if(user_valid_type($show_types) == false) $show_types = array('judge');
|
||||
if(user_valid_role($show_types) == false) $show_types = array('judge');
|
||||
|
||||
$show_complete = ($_GET['show_complete'] == 'yes') ? 'yes' : 'no';
|
||||
$show_year = ($_GET['show_year'] == 'current') ? 'current' : 'all';
|
||||
|
||||
$show_all = ($_GET['show_all'] == 'yes') ? 'yes' : 'no';
|
||||
$uid = intval($_GET['uid']);
|
||||
|
||||
if($_GET['action']=='remove') {
|
||||
@ -124,12 +129,12 @@ function neweditor()
|
||||
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 "<tr><td>".i18n('Conference').":</td><td>";
|
||||
echo "<select name=\"show_all\">";
|
||||
$s = ($show_all == 'no') ? 'selected="selected"' : '';
|
||||
echo "<option value=\"no\" $s>".i18n('Show only registrations from this conference')."</option>";
|
||||
$s = ($show_all == 'yes') ? 'selected="selected"' : '';
|
||||
echo "<option value=\"yes\" $s>".i18n('Show ALL conferences')."</option>";
|
||||
echo "</select>";
|
||||
echo "</td></tr></table>";
|
||||
echo "<br />";
|
||||
@ -165,56 +170,40 @@ function neweditor()
|
||||
echo "<br />";
|
||||
|
||||
/* Grab a list of users */
|
||||
$w = array();
|
||||
foreach($show_types as $t) {
|
||||
$w [] = "u1.types LIKE '%$t%'";
|
||||
$clauses = array();
|
||||
$roles = array();
|
||||
foreach($show_types as $t){
|
||||
$roles[] = "type = '$t'";
|
||||
}
|
||||
$where_types = "AND (".join(" OR ", $w).")";
|
||||
if(count($roles) > 0) $clauses[] = 'ur.roles_id IN(SELECT id FROM roles WHERE ' . implode(' OR ', $roles) . ')';
|
||||
if($show_complete == 'yes') $clauses[] = 'ur.complete = "yes"';
|
||||
if($show_all == 'no') $clauses[] = "u1.conferences_id={$conference['id']}";
|
||||
|
||||
$where_complete = "";
|
||||
if($show_complete == 'yes') {
|
||||
foreach($show_types as $t) {
|
||||
$where_complete .= "AND ({$t}_complete='yes' OR {$t}_complete IS NULL) ";
|
||||
}
|
||||
$querystr =
|
||||
"SELECT u1.id as userid, u1.*, ur.*, conferences.name AS conference_name " .
|
||||
"FROM users u1 " .
|
||||
"LEFT JOIN user_roles ur ON ur.users_id = u1.id " .
|
||||
"JOIN conferences ON u1.conferences_id = conferences.id ";
|
||||
|
||||
if(count($clauses) > 0){
|
||||
$querystr .= "WHERE " . implode(' AND ', $clauses) . " ";
|
||||
}
|
||||
|
||||
if($show_year == 'current')
|
||||
$having_year = "AND u1.year={$config['FAIRYEAR']}";
|
||||
$querystr .=
|
||||
"GROUP BY u1.accounts_id " .
|
||||
"HAVING u1.deleted = 'no' " .
|
||||
"ORDER BY lastname ASC, firstname ASC, conferences_id DESC ";
|
||||
$q = mysql_query($querystr);
|
||||
$num = mysql_num_rows($q);
|
||||
echo i18n("Listing %1 people total. See the bottom for breakdown by complete status",array($num));
|
||||
|
||||
echo mysql_error();
|
||||
echo "<table class=\"tableview\">";
|
||||
|
||||
$querystr="SELECT
|
||||
*
|
||||
FROM
|
||||
users u1
|
||||
LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`u1`.`id`
|
||||
LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`u1`.`id`
|
||||
LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`u1`.`id`
|
||||
LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`u1`.`id`
|
||||
LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`u1`.`id`
|
||||
WHERE u1.year=( SELECT MAX(`year`) FROM users u2 WHERE u1.uid=u2.uid )
|
||||
GROUP BY uid
|
||||
HAVING
|
||||
u1.deleted='no'
|
||||
$having_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 "<thead>";
|
||||
echo "<tr>";
|
||||
echo " <th>".i18n("Name")."</th>";
|
||||
echo " <th>".i18n("Email Address")."</th>";
|
||||
echo " <th>".i18n("Year")."</th>";
|
||||
echo " <th>".i18n("Conference")."</th>";
|
||||
echo " <th>".i18n("Type(s)")."</th>";
|
||||
echo " <th>".i18n("Active")."</th>";
|
||||
echo " <th>".i18n("Complete")."</th>";
|
||||
@ -227,48 +216,49 @@ function neweditor()
|
||||
$tally['inactive'] = array();
|
||||
$tally['active']['complete'] = 0;
|
||||
$tally['active']['incomplete'] = 0;
|
||||
$tally['active']['na'] = 0;
|
||||
$tally['inactive']['complete'] = 0;
|
||||
$tally['inactive']['incomplete'] = 0;
|
||||
$tally['inactive']['na'] = 0;
|
||||
while($r=mysql_fetch_assoc($q))
|
||||
{
|
||||
//JAMES - TEMP - due to the previous error with improperly setting judge status to NOT complete when special awards was turned off
|
||||
//we now need to make sure we re-calculate all the judge statuses somehow, so might as well do it here.
|
||||
//FIXME: remove this after all the fairs are done this year SUMMER 2010
|
||||
if(in_array('judge',$show_types)){
|
||||
$u=user_load_by_uid($r['uid']);
|
||||
|
||||
//we also set teh $r array so it displays properly on first load
|
||||
if(judge_status_update($u)=="complete")
|
||||
$r['judge_complete']='yes';
|
||||
// get the role data for this user
|
||||
$roleData = array();
|
||||
$roleQuery = mysql_query("SELECT * FROM roles JOIN user_roles ON user_roles.roles_id = roles.id WHERE user_roles.users_id = " . $r['userid']);
|
||||
while($dat = mysql_fetch_assoc($roleQuery)){
|
||||
//print_r($roleData);
|
||||
$roleData[] = $dat;
|
||||
$roleTypes[] = $dat['type'];
|
||||
}
|
||||
$types = split(',', $r['types']);
|
||||
$span = count($types) > 1 ? "rowspan=\"".count($types)."\"" : '';
|
||||
|
||||
$span = count($roleData) > 1 ? "rowspan=\"".count($roleData)."\"" : '';
|
||||
echo "<tr><td $span>";
|
||||
|
||||
$name = "{$r['firstname']} {$r['lastname']}";
|
||||
if(in_array('fair', $types)) {
|
||||
$qq = mysql_query("SELECT * FROM users_fair
|
||||
LEFT JOIN fairs ON fairs.id=users_fair.fairs_id
|
||||
WHERE users_id='{$r['id']}'");
|
||||
if(in_array('fair', $roleTypes)) {
|
||||
$qq = mysql_query("SELECT * FROM fairs WHERE id = " . $r['fairs_id']);
|
||||
echo $qq.";<br/>";
|
||||
$rr = mysql_fetch_assoc($qq);
|
||||
$name = "{$rr['name']}".((trim($name)=='') ? '' : "<br />($name)");
|
||||
}
|
||||
}
|
||||
if(strlen(trim($name)) == 0) $name = "<" . i18n("not specified") . ">";
|
||||
|
||||
echo "<a href=\"#\" onclick=\"return openeditor({$r['id']})\">$name</a>";
|
||||
echo "</td>";
|
||||
|
||||
echo "<td $span>{$r['email']}</td>";
|
||||
|
||||
echo "<td $span>{$r['year']}</td>";
|
||||
echo "<td $span>{$r['conference_name']}</td>";
|
||||
|
||||
$first = true;
|
||||
$complete = false;
|
||||
$incomplete = false;
|
||||
foreach($types as $t) {
|
||||
foreach($roleData as $roleData) {
|
||||
if(!$first) echo '</tr><tr>';
|
||||
echo "<td>{$user_what[$t]}</td>";
|
||||
echo "<td>{$roleData['name']}</td>";
|
||||
|
||||
echo "<td>";
|
||||
if($r["{$t}_active"] == 'yes') {
|
||||
if($roleData["active"] == 'yes') {
|
||||
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
|
||||
$userstate = 'active';
|
||||
} else {
|
||||
@ -278,9 +268,9 @@ function neweditor()
|
||||
echo "</td>";
|
||||
|
||||
echo "<td>";
|
||||
if(in_array($t, array('parent','committee','alumni','mentor','fair'))) {
|
||||
if(in_array($roleData['type'], array('parent','committee','alumni','mentor','fair'))) {
|
||||
/* Do nothing, there's nothing to complete */
|
||||
} else if($r["{$t}_complete"] == 'yes') {
|
||||
} else if($roleData["complete"] == 'yes') {
|
||||
echo "<div class=\"happy\" align=\"center\">".i18n("yes")."</div>";
|
||||
$complete = true;
|
||||
} else {
|
||||
@ -305,6 +295,8 @@ function neweditor()
|
||||
$tally[$userstate]['complete']++;
|
||||
}else if($incomplete){
|
||||
$tally[$userstate]['incomplete']++;
|
||||
}else{
|
||||
$tally[$userstate]['na']++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,11 +307,12 @@ function neweditor()
|
||||
?>
|
||||
<table rules="all" style="border:solid 1px; margin:2em">
|
||||
<thead>
|
||||
<tr><td colspan="4" align="center">List Totals</td></tr>
|
||||
<tr><td colspan="5" align="center">List Totals</td></tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Complete</th>
|
||||
<th>Incomplete</th>
|
||||
<th>N/A</th>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -328,16 +321,19 @@ function neweditor()
|
||||
<td><strong>Active</strong></td>
|
||||
<td><?=$tally['active']['complete']?></td>
|
||||
<td><?=$tally['active']['incomplete']?></td>
|
||||
<td><?=$tally['active']['complete'] + $tally['active']['incomplete']?></td>
|
||||
<td><?=$tally['active']['na']?></td>
|
||||
<td><?=$tally['active']['complete'] + $tally['active']['incomplete'] + $tally['active']['na']?></td>
|
||||
</tr><tr>
|
||||
<td><strong>Inactive</strong></td>
|
||||
<td><?=$tally['inactive']['complete']?></td>
|
||||
<td><?=$tally['inactive']['incomplete']?></td>
|
||||
<td><?=$tally['inactive']['complete'] + $tally['inactive']['incomplete']?></td>
|
||||
<td><?=$tally['inactive']['na']?></td>
|
||||
<td><?=$tally['inactive']['complete'] + $tally['inactive']['incomplete'] + $tally['inactive']['na']?></td>
|
||||
</tr><tr>
|
||||
<td><strong>Total</strong></td>
|
||||
<td><?=$tally['active']['complete'] + $tally['inactive']['complete']?></td>
|
||||
<td><?=$tally['active']['incomplete'] + $tally['inactive']['incomplete']?></td>
|
||||
<td><?=$tally['active']['na'] + $tally['inactive']['na']?></td>
|
||||
<td><?=$num?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user