- partially working judges_teams_members

- working judges_info, except for the configurable questions/answers
This commit is contained in:
dave 2008-10-20 05:20:42 +00:00
parent d1c7fa968e
commit d86ea6257f
3 changed files with 202 additions and 176 deletions

View File

@ -199,4 +199,23 @@ function getJudgingEligibilityCode() {
}
}
function judges_load_all()
{
global $config;
$ret = array();
$query = "SELECT id FROM users WHERE types LIKE '%judge%'
AND year='{$config['FAIRYEAR']}'
AND deleted='no'";
$r = mysql_query($query);
while($i = mysql_fetch_assoc($r)) {
$u = user_load($i['id']);
if($u['judge_complete'] == 'no') continue;
$ret[$i['id']] = $u;
}
return $ret;
}
?>

View File

@ -40,167 +40,165 @@ $preferencechoices=array(
);
if($_GET['id'])
{
//include "../register_judges.inc.php";
$id = intval($_GET['id']);
$q=mysql_query("SELECT
judges.*
FROM
judges
WHERE
judges.id='".$_GET['id']."'");
echo mysql_error();
$judgeinfo=mysql_fetch_object($q);
send_popup_header(i18n("Judge Information - %1 %2",array($judgeinfo->firstname,$judgeinfo->lastname)));
echo "Complete for {$config['FAIRYEAR']}: ".(($judgeinfo->complete=="yes") ? "Yes" : "No");
echo "<br />";
echo "<h3>".i18n("Personal Info")."</h3>";
echo "<table class=\"viewtable\">\n";
echo "<tr>\n";
echo " <th>".i18n("First Name")."</th><td>$judgeinfo->firstname</td>\n";
echo " <th>".i18n("Last Name")."</th><td>$judgeinfo->lastname</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Email Address")."</th><td>$judgeinfo->email</td>\n";
echo " <th>".i18n("City")."</th><td>$judgeinfo->city</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Address 1")."</th><td>$judgeinfo->address</td>\n";
echo " <th>".i18n($config['provincestate'])."</th><td>$judgeinfo->province";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n("Address 2")."</th><td>$judgeinfo->address2</td>\n";
echo " <th>".i18n("Phone (Home)")."</th><td>$judgeinfo->phonehome</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th>".i18n($config['postalzip'])."</th><td>$judgeinfo->postalcode</td>\n";
echo " <th>".i18n("Phone (Work)")."</th><td>$judgeinfo->phonework&nbsp;ext $judgeinfo->phoneworkext</td>\n";
echo "</tr>";
echo "<tr>\n";
echo " <th>".i18n("Organization")."</th><td>$judgeinfo->organization</td>\n";
echo " <th>".i18n("Phone (Cell)")."</th><td>$judgeinfo->phonecell</td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n";
echo " <th valign=\"top\"colspan=\"2\">".i18n("Age category preference")."</th><td colspan=\"2\">";
$q=mysql_query("SELECT judges_catpref.*,projectcategories.category FROM judges_catpref,projectcategories WHERE judges_id='{$_GET['id']}' AND judges_catpref.year='".$config['FAIRYEAR']."' AND projectcategories.year='".$config['FAIRYEAR']."' AND judges_catpref.projectcategories_id=projectcategories.id");
echo mysql_error();
while($r=mysql_fetch_object($q))
echo i18n($r->category).": ".$preferencechoices[$r->rank]." <br />";
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\">".i18n("Highest post-secondary degree")."</th>";
echo " <td colspan=\"2\">$judgeinfo->highest_psd</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\">".i18n("Other professional qualifications")."</th>";
echo " <td colspan=\"2\">$judgeinfo->professional_quals</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th colspan=\"2\" valign=\"top\">".i18n("Languages")."</th>";
echo " <td colspan=\"2\">";
$q=mysql_query("SELECT languages_lang FROM judges_languages WHERE judges_id='$judgeinfo->id'");
while($r=mysql_fetch_object($q))
{
echo $r->languages_lang;
echo "<br />";
}
echo " </td>\n";
echo "</tr>\n";
questions_print_answers('judgereg',$judgeinfo->id, $config['FAIRYEAR']);
echo "</table>";
echo "<hr />";
echo "<br />";
echo "<h3>Areas of Expertise</h3>";
echo "<table class=\"viewtable\">";
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE judges_id='$judgeinfo->id'
AND judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY projectdivisions_id, projectsubdivisions_id");
echo mysql_error();
$judge_divs=array();
$judge_subdivs=array();
$divdata=array();
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
foreach($divs as $div)
{
echo "<tr><th>".i18n($divnames[$div])."</th>";
echo " <td>".$judge_divs[$div]."/5</td>";
echo "<td>";
if(count($judge_subdivs[$div]))
{
$divdata=implode(", ",$judge_subdivs[$div]);
echo "$divdata";
}
else
echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
send_popup_header("Judge Information");
send_popup_header("Judge Information");
if($id < 1) {
echo error(i18n("No Judge ID passed to Judges Info"));
send_popup_footer();
exit;
}
$judgeinfo = user_load($id);
send_popup_header(i18n("Judge Information - %1 %2",array($judgeinfo['firstname'],$judgeinfo['lastname'])));
echo "Complete for {$config['FAIRYEAR']}: ".(($judgeinfo['complete']=="yes") ? "Yes" : "No");
echo "<br />";
echo "<h3>".i18n("Personal Info")."</h3>";
echo "<table class=\"viewtable\">\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("First Name").": </th><td>{$judgeinfo['firstname']}</td>\n";
echo " <th align=\"right\">".i18n("Last Name").":</th><td>{$judgeinfo['lastname']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Email Address").":</th><td>{$judgeinfo['email']}</td>\n";
echo " <th align=\"right\">".i18n("City").":</th><td>{$judgeinfo['city']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 1").":</th><td>{$judgeinfo['address']}</td>\n";
echo " <th align=\"right\">".i18n($config['provincestate']).": </th><td>{$judgeinfo['province']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Address 2").":</th><td>{$judgeinfo['address2']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Home)").":</th><td>{$judgeinfo['phonehome']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\">".i18n($config['postalzip']).":</th><td>{$judgeinfo['postalcode']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Work)").":</th><td>{$judgeinfo['phonework']}</td>\n";
echo "</tr>";
echo "<tr>\n";
echo " <th align=\"right\">".i18n("Organization").":</th><td>{$judgeinfo['organization']}</td>\n";
echo " <th align=\"right\">".i18n("Phone (Cell)").":</th><td>{$judgeinfo['phonecell']}</td>\n";
echo "</tr>";
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "</table>";
echo "<table>";
echo "<tr>\n";
echo " <th valign=\"top\" align=\"right\" colspan=\"2\">".i18n("Age category preference").":</th><td colspan=\"2\">";
$q=mysql_query("SELECT * FROM projectcategories
WHERE year='{$config['FAIRYEAR']}'");
echo mysql_error();
while($r=mysql_fetch_object($q)) {
$p = intval($judgeinfo['cat_prefs'][$r->id]);
echo i18n($r->category).": {$preferencechoices[$p]}<br />";
}
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\">".i18n("Highest post-secondary degree").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['highest_psd']}</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <th align=\"right\" colspan=\"2\" valign=\"top\">".i18n("Languages").":</th>";
echo " <td colspan=\"2\">".join(', ', $judgeinfo['languages']). "<br />";
echo " </td>\n";
echo "</tr>\n";
//questions_print_answers('judgereg',$judgeinfo['id'], $config['FAIRYEAR']);
echo "</table>";
echo "<hr />";
echo "<br />";
echo "<h3>Areas of Expertise</h3>";
echo "<table class=\"viewtable\">";
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
$divs=array();
while($r=mysql_fetch_object($q))
{
$divs[]=$r->id;
$divnames[$r->id]=$r->division;
}
/*
$subdivq=mysql_query("SELECT judges_expertise.*,
projectsubdivisions.subdivision,
projectsubdivisions.projectdivisions_id AS parent_id
FROM judges_expertise
LEFT JOIN projectsubdivisions ON judges_expertise.projectsubdivisions_id=projectsubdivisions.id
WHERE judges_id='{$judgeinfo['id']}'
AND judges_expertise.year='".$config['FAIRYEAR']."'
ORDER BY projectdivisions_id, projectsubdivisions_id");
echo mysql_error();
$judge_divs=array();
$judge_subdivs=array();
$divdata=array();
*/
/*
while($subdivr=mysql_fetch_object($subdivq))
{
if($subdivr->projectdivisions_id)
{
$judge_divs[$subdivr->projectdivisions_id]=$subdivr->val;
}
else
$judge_subdivs[$subdivr->parent_id][]=$subdivr->subdivision;
}
*/
foreach($divs as $div)
{
$p = $judgeinfo['div_prefs'][$div];
echo "<tr><th align=\"right\" >".i18n($divnames[$div]).":</th>";
echo " <td>$p/5</td>";
echo "<td>";
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE
projectdivisions_id='$div' AND year='{$config['FAIRYEAR']}' ORDER BY subdivision");
$sd = array();
while($subr=mysql_fetch_object($subq)) {
if($u['div_prefs_sub'][$subr->id] == 1) {
$sd[] = $subdivr->subdivision;
}
}
/* Only show subdiv if main div >=3 */
if($p >= 3) echo implode(", ",$sd);
else echo "&nbsp;";
echo "</td>";
echo "</tr>";
}
echo "<tr>\n";
echo " <th align=\"right\" valign=\"top\">".i18n("Other").":</th>";
echo " <td colspan=\"2\">{$judgeinfo['expertise_other']}<br />";
echo " </td>\n";
echo "</tr>\n";
echo "</table>";
send_popup_footer();
send_popup_footer();
?>

View File

@ -22,10 +22,10 @@
*/
?>
<?
require("../common.inc.php");
require_once("../user.inc.php");
require_once('../common.inc.php');
require_once('../user.inc.php');
user_auth_required('committee', 'admin');
include "judges.inc.php";
require_once('judges.inc.php');
send_header("Judging Team Members",
array('Committee Main' => 'committee_main.php',
@ -98,7 +98,7 @@ function switchjudgeinfo()
{
//before we insert them, we need to make sure they dont already belong to this team. We can not have the same judge assigned to the same team multiple times.
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_id='$selectedjudge' AND judges_teams_id='$team_id'");
$q=mysql_query("SELECT * FROM judges_teams_link WHERE users_id='$selectedjudge' AND judges_teams_id='$team_id'");
if(mysql_num_rows($q))
{
echo notice(i18n("Judge (%1) already belongs to judging team: %2",array($selectedjudge,$team_name)));
@ -107,7 +107,7 @@ function switchjudgeinfo()
else
{
//lets make the first one we add a captain, the rest, non-captains :)
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
mysql_query("INSERT INTO judges_teams_link (users_id,judges_teams_id,captain,year) VALUES ('$selectedjudge','$team_id','$captain','".$config['FAIRYEAR']."')");
$added++;
}
//if this is alreayd no, then who cares, but if its the first one that is going into the new team, then
@ -122,9 +122,9 @@ function switchjudgeinfo()
echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$team_name)));
}
if($_GET['action']=="del" && $_GET['team_num'] && $_GET['team_id'] && $_GET['judges_id'])
if($_GET['action']=="del" && $_GET['team_num'] && $_GET['team_id'] && $_GET['users_id'])
{
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_GET['judges_id']."' AND judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
mysql_query("DELETE FROM judges_teams_link WHERE users_id='".$_GET['users_id']."' AND judges_teams_id='".$_GET['team_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Removed judge from team #%1 (%2)",array($_GET['team_num'],$_GET['team_name'])));
//if there is still members left in the team, make sure we have a captain still
@ -139,7 +139,7 @@ function switchjudgeinfo()
{
if($first)
{
$firstjudge=$r->judges_id;
$firstjudge=$r->users_id;
$first=false;
}
@ -152,7 +152,7 @@ function switchjudgeinfo()
if(!$gotcaptain)
{
//make the first judge the captain
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
}
}
@ -181,7 +181,7 @@ function switchjudgeinfo()
{
//teams can have as many captains as they want, so just add it.
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='".$_GET['judge_id']."'");
echo happy(i18n("Team captain assigned"));
}
@ -195,7 +195,7 @@ function switchjudgeinfo()
}
else
{
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND judges_id='".$_GET['judge_id']."'");
mysql_query("UPDATE judges_teams_link SET captain='no' WHERE judges_teams_id='".$_GET['team_id']."' AND users_id='".$_GET['judge_id']."'");
echo happy(i18n("Team captain removed"));
}
}
@ -211,7 +211,7 @@ function switchjudgeinfo()
echo "<input type=\"hidden\" name=\"team_id\">";
echo "<input type=\"hidden\" name=\"team_num\">";
echo "<input type=\"hidden\" name=\"team_name\">";
echo "<input type=\"hidden\" name=\"judges_id\">";
echo "<input type=\"hidden\" name=\"users_id\">";
echo "<table>";
echo "<tr>";
echo "<th>".i18n("Judges List");
@ -250,13 +250,21 @@ function switchjudgeinfo()
judges_years
WHERE
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id AND
judges.id NOT IN (SELECT judges_id AS id FROM judges_teams_link WHERE judges_teams_link.year='".$config['FAIRYEAR']."')
judges.id=judges_years.users_id AND
judges.id NOT IN (SELECT users_id AS id FROM judges_teams_link WHERE judges_teams_link.year='".$config['FAIRYEAR']."')
ORDER BY
lastname,
firstname";
*/
$querystr="SELECT
/* Load all the judges (judge_complete=yes, deleted=no, year=fairyear) */
$judgelist = judges_load_all();
/* Load all the team links */
/* $querystr="SELECT
judges.id,
judges.firstname,
judges.lastname
@ -265,7 +273,7 @@ function switchjudgeinfo()
judges_years
WHERE
judges_years.year='".$config['FAIRYEAR']."' AND
judges.id=judges_years.judges_id AND
judges.id=judges_years.users_id AND
judges.complete='yes'
ORDER BY
lastname,
@ -275,6 +283,7 @@ function switchjudgeinfo()
while($r=mysql_fetch_object($q)) {
$judgelist[$r->id]=$r;
}
*/
if($_SESSION['viewstate']['judges_teams_list_show']=='unassigned')
{
$querystr="SELECT
@ -288,8 +297,8 @@ function switchjudgeinfo()
WHERE
judges_years.year='".$config['FAIRYEAR']."'
AND judges_teams_link.year='".$config['FAIRYEAR']."'
AND judges.id=judges_years.judges_id
AND judges.id=judges_teams_link.judges_id
AND judges.id=judges_years.users_id
AND judges.id=judges_teams_link.users_id
AND judges.complete='yes'
ORDER BY
lastname,
@ -307,9 +316,9 @@ function switchjudgeinfo()
echo mysql_error();
echo "<select name=\"judgelist[]\" onchange=\"switchjudgeinfo()\" multiple=\"multiple\" style=\"width: 250px; height: 600px;\">";
foreach($judgelist AS $r) {
if($r->firstname && $r->lastname)
echo "<option value=\"$r->id\">$r->firstname $r->lastname</option>\n";
foreach($judgelist AS $id=>$u) {
if($u['firstname'] && $u['lastname'])
echo "<option value=\"$id\">{$u['firstname']} {$u['lastname']}</option>\n";
}
echo "</select>";
@ -337,7 +346,7 @@ function switchjudgeinfo()
foreach($team['members'] AS $member)
{
echo "<tr><td>";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams_members.php?action=del&team_id=".$team['id']."&team_num=".$team['num']."&judges_id=".$member['id']."&team_name=".rawurlencode($team['name'])."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "<a onclick=\"return confirmClick('Are you sure you want to remove this judge from this team?')\" href=\"judges_teams_members.php?action=del&team_id=".$team['id']."&team_num=".$team['num']."&users_id=".$member['id']."&team_name=".rawurlencode($team['name'])."\"><img border=0 src=\"".$config['SFIABDIRECTORY']."/images/16/button_cancel.".$config['icon_extension']."\"></a>";
echo "</td><td width=\"100%\">";
if($member['captain']=="yes")
{