add defaults for min/max team size and number of teams to each event

pull those defaults when creating a new scheduled event
show registered teams when viewing an event as an admin
This commit is contained in:
james 2010-06-17 15:06:11 +00:00
parent f1a43a9cec
commit 56b5e8269a
5 changed files with 100 additions and 40 deletions

View File

@ -48,7 +48,10 @@ $editor = new TableEditor('events',
"website" => "Link to Description",
"suggested_grades" => "Suggested Grades",
"min_judges" => "Minimum Number of Judges",
"max_judges" => "Maximum Number of Judges"
"max_judges" => "Maximum Number of Judges",
"default_max_teams" => "Maximum Number of Teams",
"default_min_team_size" => "Minimum Team Size",
"default_max_team_size" => "Maximum Team Size"
),
array(
"conferences_id" => $conference['id']

View File

@ -113,6 +113,12 @@
$js.="eventdivs[$r->id]={hour:$r->hour,minute:$r->minute,location:$r->locations_id,duration:$r->duration};\n";
$x++;
}
$js.="\n\nvar eventdefaults=new Array();\n";
$q=mysql_query("SELECT events.* FROM events WHERE conferences_id='{$conference['id']}'");
while($r=mysql_fetch_array($q)) {
$js.="eventdefaults[{$r['id']}]=".json_encode($r)."\n";
}
echo "<script type=\"text/javascript\">\n";
echo $js;
echo "</script>";
@ -121,8 +127,25 @@
$id=intval($_GET['id']);
$q=mysql_query("SELECT schedule.*, events.name, events.eventtype FROM schedule, events WHERE schedule.id='$id' AND schedule.conferences_id='{$conference['id']}' AND schedule.events_id=events.id");
echo mysql_error();
if($r=mysql_fetch_array($q)) {
if($r=mysql_fetch_assoc($q)) {
$r['idtype']=$r['events_id'].":".$r['eventtype'];
$teams=array();
$teamq=mysql_query("SELECT so_teams.id,
so_teams.name AS teamname,
schools.school AS schoolname
FROM
so_teams
JOIN schedule_registrations ON so_teams.id=schedule_registrations.so_teams_id
JOIN schools ON so_teams.schools_id=schools.id
WHERE
schedule_registrations.conferences_id='{$conference['id']}'
AND so_teams.conferences_id='{$conference['id']}'
AND schedule_registrations.schedule_id='$id'");
echo mysql_error();
while($teamr=mysql_fetch_assoc($teamq)) {
$teams[]=$teamr;
}
$r['teams']=$teams;
echo json_encode($r);
}
else
@ -145,7 +168,9 @@
duration='".mysql_real_escape_string($_POST['duration'])."',
events_id='$event_id',
locations_id='".mysql_real_escape_string($_POST['location_id'])."',
somaxteams='".mysql_real_escape_string($_POST['somaxteams'])."'
somaxteams='".mysql_real_escape_string($_POST['somaxteams'])."',
sominteamsize='".mysql_real_escape_string($_POST['sominteamsize'])."',
somaxteamsize='".mysql_real_escape_string($_POST['somaxteamsize'])."'
WHERE id='$id' AND conferences_id='{$conference['id']}'");
echo mysql_error();
happy_("Event successfully saved");
@ -243,6 +268,9 @@
$("#event_editor_dialog").dialog('option','title','Edit Event');
$.getJSON("schedule.php?action=loadevent&id="+id,function(json) {
$("#edit_event").val(json.idtype);
event_change();
//general tab
$("#edit_schedule_id").val(json.id);
$("#edit_title").val(json.title);
@ -251,17 +279,34 @@
$("#edit_minute").val(json.minute);
$("#edit_duration").val(json.duration);
$("#edit_location").val(json.locations_id);
$("#edit_event").val(json.idtype);
//science olympics tab
$("#edit_somaxteams").val(json.somaxteams);
//we do this here to set the tabs properly, becuase it also sets the defaults, then we'll override the defaults wth
//teh real values below
if(json.eventtype=="scienceolympic") {
//science olympics tab
$("#edit_somaxteams").val(json.somaxteams);
$("#edit_sominteamsize").val(json.sominteamsize);
$("#edit_somaxteamsize").val(json.somaxteamsize);
var s='<table class="summarytable"><tr><th><?=i18n("Team Name")?></th><th><?=i18n("School Name")?></th></tr>';
for(var i=0;i<json.teams.length;i++) {
var t=json.teams[i];
s+='<tr><td>'+t.teamname+'</td><td>'+t.schoolname+'</td></tr>';
}
s+='</table>';
$("#event_editor_tab_scienceolympics_registeredteams").html(s);
}
$("#schedule_tabs").tabs('select',0);
event_change();
});
}
else {
$("#event_editor_dialog").dialog('option','title','Create Event');
var a=cell.split("_");
$("#edit_event").val("");
event_change();
$("#edit_schedule_id").val(0);
$("#edit_title").val("");
$("#edit_date").val($("#date").val());
@ -269,13 +314,13 @@
$("#edit_minute").val(a[1]);
$("#edit_duration").val(60);
$("#edit_location").val(a[2]);
$("#edit_event").val("");
//science olympics tab
$("#edit_somaxteams").val("");
$("#edit_sominteamsize").val("");
$("#edit_somaxteamsize").val("");
$("#schedule_tabs").tabs('select',0);
event_change();
}
$("#event_editor_dialog").dialog('option','width',600);

View File

@ -24,8 +24,15 @@ function update_tab_scienceolympics() {
function event_change() {
var ea=$("#edit_event").val().split(":");
//if its not set, we must be on "choose" still, so disable the other tabs until they choose something
//then get the heck out of here
if(!ea[1]) {
$("#schedule_tabs").tabs("option","disabled",[1,2,3]);
return;
}
//ea[1] is the type
switch(ea[1]) {
case "":
case "general":
$("#schedule_tabs").tabs("option","disabled",[1,2,3]);
break;
@ -38,20 +45,25 @@ function event_change() {
case "tour":
$("#schedule_tabs").tabs("option","disabled",[1,2]);
break;
default:
return;
}
/*
if($("#edit_title").val().length) {
//umm if it already exists, dont change it
if($("#edit_title").val=="Choose") {
$("#edit_title").val($("#edit_event option:selected").text());
}
//no, screw it, change it anyways
}
else
{
*/
if($("#edit_event").val())
$("#edit_title").val($("#edit_event option:selected").text());
}
//}
var ed=eventdefaults[ea[0]];
$("#edit_somaxteams").val(ed.default_max_teams);
$("#edit_somaxteamsize").val(ed.default_max_team_size);
$("#edit_sominteamsize").val(ed.default_min_team_size);
}
</script>
@ -137,39 +149,34 @@ echo i18n("Maximum Number of Teams").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"somaxteams\" id=\"edit_somaxteams\" size=\"4\">";
echo "</td></tr>";
echo "</table>";
echo "FIXME: the fields below this line are not functional yet";
echo "<hr />";
echo "<tr><td>";
echo i18n("Minimum Team Size").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"sominteamsize\" id=\"edit_sominteamsize\" size=\"4\">";
echo "</td></tr>";
echo "<tr><td>";
echo i18n("Maximum Team Size").": ";
echo "</td><td>";
echo "<input type=\"text\" name=\"somaxteamsize\" id=\"edit_somaxteamsize\" size=\"4\">";
echo "</td></tr>";
echo "</table>";
echo "<h4>".i18n("Judges")."</h4>";
echo "<table style=\"width: 95%;\">";
echo "<tr>";
echo "<td>";
echo i18n("Grades Recommended").": ";
echo "</td><td>";
echo i18n("Grades Required").": ";
echo "FIXME: show list of registered judges to choose from";
echo "</td></tr>";
echo "<tr><td>";
//FIXME fix grades from config
for($x=7;$x<=12;$x++) {
echo "<input type=\"checkbox\" name=\"recommendedgrades[]\"> Grade $x <br />\n";
}
echo "</td><td>";
//FIXME fix grades from config
for($x=7;$x<=12;$x++) {
echo "<input type=\"checkbox\" name=\"recommendedgrades[]\"> Grade $x <br />\n";
}
echo "</td></tr>\n";
echo "<tr>";
echo "<td>";
echo i18n("Judges").": ";
echo "</td><td>";
echo "show list of registered judges to choose from";
echo "</td></tr>";
echo "</table>";
echo "<h4>".i18n("Registered Teams")."</h4>";
echo "<div id=\"event_editor_tab_scienceolympics_registeredteams\"></div>";
echo "</div>\n";
?>
</div>

View File

@ -1 +1 @@
186
187

5
db/db.update.187.sql Normal file
View File

@ -0,0 +1,5 @@
ALTER TABLE `events` ADD `default_max_teams` INT NOT NULL ,
ADD `default_min_team_size` INT NOT NULL ,
ADD `default_max_team_size` INT NOT NULL;
ALTER TABLE `schedule` ADD `sominteamsize` INT NOT NULL ,
ADD `somaxteamsize` INT NOT NULL