finish messign around with team naming

This commit is contained in:
james 2005-03-29 20:28:35 +00:00
parent 09cf68145c
commit c8149a40d5

View File

@ -34,11 +34,12 @@ function addbuttonclicked(team)
document.forms.judges.team_num.value=team; document.forms.judges.team_num.value=team;
document.forms.judges.submit(); document.forms.judges.submit();
} }
function delbuttonclicked(team_id,team_num,judge) function delbuttonclicked(team_id,team_num,team_name,judge)
{ {
document.forms.judges.action.value="del"; document.forms.judges.action.value="del";
document.forms.judges.team_id.value=team_id; document.forms.judges.team_id.value=team_id;
document.forms.judges.team_num.value=team_num; document.forms.judges.team_num.value=team_num;
document.forms.judges.team_name.value=team_name;
document.forms.judges.judges_id.value=judge; document.forms.judges.judges_id.value=judge;
document.forms.judges.submit(); document.forms.judges.submit();
} }
@ -58,17 +59,19 @@ function saveteamnamesbuttonclicked()
if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0) if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0)
{ {
//first check if this team exists. //first check if this team exists.
$q=mysql_query("SELECT id FROM judges_teams WHERE num='".$_POST['team_num']."' AND year='".$config['FAIRYEAR']."'"); $q=mysql_query("SELECT id,name FROM judges_teams WHERE num='".$_POST['team_num']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)) if(mysql_num_rows($q))
{ {
$r=mysql_fetch_object($q); $r=mysql_fetch_object($q);
$team_id=$r->id; $team_id=$r->id;
$team_name=$r->name;
} }
else else
{ {
echo notice(i18n("Creating new team #%1 with name '%2'",array($_POST['team_num'],$_POST['team_name']))); echo notice(i18n("Creating new team #%1 with name '%2'",array($_POST['team_num'],$_POST['new_team_name'])));
mysql_query("INSERT INTO judges_teams (num,name,year) VALUES ('".$_POST['team_num']."','".$_POST['team_name']."','".$config['FAIRYEAR']."')"); mysql_query("INSERT INTO judges_teams (num,name,year) VALUES ('".$_POST['team_num']."','".$_POST['new_team_name']."','".$config['FAIRYEAR']."')");
$team_id=mysql_insert_id(); $team_id=mysql_insert_id();
$team_name=$_POST['new_team_name'];
} }
$added=0; $added=0;
@ -82,19 +85,19 @@ function saveteamnamesbuttonclicked()
if($added==1) $j=i18n("judge"); if($added==1) $j=i18n("judge");
else $j=i18n("judges"); else $j=i18n("judges");
echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$_POST['team_name']))); echo happy(i18n("%1 %2 added to team #%3 (%4)",array($added,$j,$_POST['team_num'],$team_name)));
} }
if($_POST['action']=="del" && $_POST['team_num'] && $_POST['team_id'] && $_POST['judges_id']) if($_POST['action']=="del" && $_POST['team_num'] && $_POST['team_id'] && $_POST['judges_id'])
{ {
mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_POST['judges_id']."' AND judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'"); mysql_query("DELETE FROM judges_teams_link WHERE judges_id='".$_POST['judges_id']."' AND judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
echo happy(i18n("Removed judge from team #%1",array($_POST['team_num']))); echo happy(i18n("Removed judge from team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
$q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'"); $q=mysql_query("SELECT * FROM judges_teams_link WHERE judges_teams_id='".$_POST['team_id']."' AND year='".$config['FAIRYEAR']."'");
if(mysql_num_rows($q)==0) if(mysql_num_rows($q)==0)
{ {
mysql_query("DELETE FROM judges_teams WHERE year='".$config['FAIRYEAR']."' AND id='".$_POST['team_id']."'"); mysql_query("DELETE FROM judges_teams WHERE year='".$config['FAIRYEAR']."' AND id='".$_POST['team_id']."'");
echo notice(i18n("Removed empty team #%1",array($_POST['team_num']))); echo notice(i18n("Removed empty team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
} }
@ -103,9 +106,9 @@ function saveteamnamesbuttonclicked()
if($_POST['action']=="saveteamnames") if($_POST['action']=="saveteamnames")
{ {
if(count($_POST['teamname'])) if(count($_POST['team_names']))
{ {
foreach($_POST['teamname'] AS $team_id=>$team_name) foreach($_POST['team_names'] AS $team_id=>$team_name)
{ {
mysql_query("UPDATE judges_teams SET name='".mysql_escape_string(stripslashes($team_name))."' WHERE id='$team_id'"); mysql_query("UPDATE judges_teams SET name='".mysql_escape_string(stripslashes($team_name))."' WHERE id='$team_id'");
} }
@ -118,6 +121,7 @@ function saveteamnamesbuttonclicked()
echo "<input type=\"hidden\" name=\"action\">"; echo "<input type=\"hidden\" name=\"action\">";
echo "<input type=\"hidden\" name=\"team_id\">"; echo "<input type=\"hidden\" name=\"team_id\">";
echo "<input type=\"hidden\" name=\"team_num\">"; 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=\"judges_id\">";
echo "<table>"; echo "<table>";
echo "<tr>"; echo "<tr>";
@ -229,7 +233,7 @@ function saveteamnamesbuttonclicked()
echo "</td><td>"; echo "</td><td>";
echo "<table>"; echo "<table>";
echo "<tr><th align=\"left\">New #$newteamid: <input type=\"text\" name=\"team_name\" value=\"Team #$newteamid\" /></th></tr>"; echo "<tr><th align=\"left\">New #$newteamid: <input type=\"text\" name=\"new_team_name\" value=\"Team #$newteamid\" /></th></tr>";
echo "</table>"; echo "</table>";
echo "</td></tr></table>"; echo "</td></tr></table>";
@ -245,15 +249,15 @@ function saveteamnamesbuttonclicked()
echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add &gt;&gt;\">"; echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add &gt;&gt;\">";
echo "</td><td>"; echo "</td><td>";
echo "<table>"; echo "<table>\n";
echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": "; echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": ";
echo "<input type=\"text\" name=\"teamname[".$team['id']."]\" value=\"".$team['name']."\" size=\"10\">"; echo "<input type=\"text\" name=\"team_names[".$team['id']."]\" value=\"".$team['name']."\" size=\"10\">";
echo "</th></tr>"; echo "</th></tr>\n";
foreach($team['members'] AS $member) foreach($team['members'] AS $member)
{ {
echo "<tr><td>"; echo "<tr><td>";
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".$member['id']."')\" type=\"button\" value=\"&lt;&lt\">"; echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".htmlspecialchars($team['name'])."','".$member['id']."')\" type=\"button\" value=\"&lt;&lt\">";
echo "</td><td>"; echo "</td><td>";
echo $member['firstname']." ".$member['lastname']; echo $member['firstname']." ".$member['lastname'];
echo "</td></tr>"; echo "</td></tr>";