forked from science-ation/science-ation
finish messign around with team naming
This commit is contained in:
parent
09cf68145c
commit
c8149a40d5
@ -34,11 +34,12 @@ function addbuttonclicked(team)
|
||||
document.forms.judges.team_num.value=team;
|
||||
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.team_id.value=team_id;
|
||||
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.submit();
|
||||
}
|
||||
@ -58,17 +59,19 @@ function saveteamnamesbuttonclicked()
|
||||
if($_POST['action']=="add" && $_POST['team_num'] && count($_POST['judgelist'])>0)
|
||||
{
|
||||
//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))
|
||||
{
|
||||
$r=mysql_fetch_object($q);
|
||||
$team_id=$r->id;
|
||||
$team_name=$r->name;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo notice(i18n("Creating new team #%1 with name '%2'",array($_POST['team_num'],$_POST['team_name'])));
|
||||
mysql_query("INSERT INTO judges_teams (num,name,year) VALUES ('".$_POST['team_num']."','".$_POST['team_name']."','".$config['FAIRYEAR']."')");
|
||||
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['new_team_name']."','".$config['FAIRYEAR']."')");
|
||||
$team_id=mysql_insert_id();
|
||||
$team_name=$_POST['new_team_name'];
|
||||
}
|
||||
|
||||
$added=0;
|
||||
@ -82,19 +85,19 @@ function saveteamnamesbuttonclicked()
|
||||
if($added==1) $j=i18n("judge");
|
||||
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'])
|
||||
{
|
||||
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']."'");
|
||||
if(mysql_num_rows($q)==0)
|
||||
{
|
||||
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(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'");
|
||||
}
|
||||
@ -118,6 +121,7 @@ function saveteamnamesbuttonclicked()
|
||||
echo "<input type=\"hidden\" name=\"action\">";
|
||||
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 "<table>";
|
||||
echo "<tr>";
|
||||
@ -229,7 +233,7 @@ function saveteamnamesbuttonclicked()
|
||||
echo "</td><td>";
|
||||
|
||||
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 "</td></tr></table>";
|
||||
@ -245,15 +249,15 @@ function saveteamnamesbuttonclicked()
|
||||
echo "<input onclick=\"addbuttonclicked('".$team['num']."')\" type=\"button\" value=\"Add >>\">";
|
||||
echo "</td><td>";
|
||||
|
||||
echo "<table>";
|
||||
echo "<table>\n";
|
||||
echo "<tr><th colspan=\"2\" align=\"left\">#".$team['num'].": ";
|
||||
echo "<input type=\"text\" name=\"teamname[".$team['id']."]\" value=\"".$team['name']."\" size=\"10\">";
|
||||
echo "</th></tr>";
|
||||
echo "<input type=\"text\" name=\"team_names[".$team['id']."]\" value=\"".$team['name']."\" size=\"10\">";
|
||||
echo "</th></tr>\n";
|
||||
|
||||
foreach($team['members'] AS $member)
|
||||
{
|
||||
echo "<tr><td>";
|
||||
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".$member['id']."')\" type=\"button\" value=\"<<\">";
|
||||
echo "<input onclick=\"delbuttonclicked('".$team['id']."','".$team['num']."','".htmlspecialchars($team['name'])."','".$member['id']."')\" type=\"button\" value=\"<<\">";
|
||||
echo "</td><td>";
|
||||
echo $member['firstname']." ".$member['lastname'];
|
||||
echo "</td></tr>";
|
||||
|
Loading…
Reference in New Issue
Block a user