diff --git a/admin/events.php b/admin/events.php index 51f7f3f..59013f7 100644 --- a/admin/events.php +++ b/admin/events.php @@ -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'] diff --git a/admin/schedule.php b/admin/schedule.php index 7c8bf3d..7067ad0 100644 --- a/admin/schedule.php +++ b/admin/schedule.php @@ -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 ""; @@ -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=''; + + for(var i=0;i'; + } + s+='
'+t.schoolname+'
'; + $("#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); diff --git a/admin/schedule_edit_dialog.php b/admin/schedule_edit_dialog.php index b694f4c..1ccae98 100644 --- a/admin/schedule_edit_dialog.php +++ b/admin/schedule_edit_dialog.php @@ -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); } @@ -137,39 +149,34 @@ echo i18n("Maximum Number of Teams").": "; echo ""; echo ""; echo ""; -echo ""; -echo "FIXME: the fields below this line are not functional yet"; -echo "
"; +echo ""; +echo i18n("Minimum Team Size").": "; +echo ""; +echo ""; +echo ""; + +echo ""; +echo i18n("Maximum Team Size").": "; +echo ""; +echo ""; +echo ""; + +echo ""; + +echo "

".i18n("Judges")."

"; echo ""; echo ""; echo ""; -echo "\n"; - -echo ""; -echo ""; - - echo "
"; -echo i18n("Grades Recommended").": "; echo ""; -echo i18n("Grades Required").": "; +echo "FIXME: show list of registered judges to choose from"; echo "
"; -//FIXME fix grades from config -for($x=7;$x<=12;$x++) { - echo " Grade $x
\n"; -} -echo "
"; -//FIXME fix grades from config -for($x=7;$x<=12;$x++) { - echo " Grade $x
\n"; -} -echo "
"; -echo i18n("Judges").": "; -echo ""; -echo "show list of registered judges to choose from"; -echo "
"; +echo "

".i18n("Registered Teams")."

"; +echo "
"; +echo "\n"; + ?> diff --git a/db/db.code.version.txt b/db/db.code.version.txt index bc3d544..9870ccc 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -186 +187 diff --git a/db/db.update.187.sql b/db/db.update.187.sql new file mode 100644 index 0000000..011e336 --- /dev/null +++ b/db/db.update.187.sql @@ -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