diff --git a/admin/judges_sa.php b/admin/judges_sa.php
index 8d6c216..09eec68 100644
--- a/admin/judges_sa.php
+++ b/admin/judges_sa.php
@@ -327,6 +327,15 @@ $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR'
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
+
+if($config['filterdivisionbycategory']=="yes")
+{
+ $q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
+ while($r=mysql_fetch_object($q))
+ $catdiv[$r->projectcategories_id][]=$r->projectdivisions_id;
+}
+
+
$langr = array();
$q=mysql_query("SELECT * FROM languages WHERE active='Y'");
while($r=mysql_fetch_object($q))
@@ -368,6 +377,12 @@ foreach($div AS $d_id=>$d_val)
{
foreach($cat AS $c_id=>$c_val)
{
+ //only make the teams for the ones that are needed
+ if($config['filterdivisionbycategory']=="yes")
+ {
+ if(!in_array($d_id,$catdiv[$c_id]))
+ continue;
+ }
foreach($langr AS $l_id) {
$num = count($jdivisions[$d_id][$c_id][$l_id]);
diff --git a/admin/judges_schedulerconfig_check.inc.php b/admin/judges_schedulerconfig_check.inc.php
index 61a1b18..1addd2f 100644
--- a/admin/judges_schedulerconfig_check.inc.php
+++ b/admin/judges_schedulerconfig_check.inc.php
@@ -22,7 +22,11 @@ function checkPrerequisites()
echo "
$catr->category
";
echo "";
echo "Division | Projects | Teams |
";
- $divq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
+ if($config['filterdivisionbycategory']=="yes")
+ $divq=mysql_query("SELECT projectdivisions.* FROM projectdivisions,projectcategoriesdivisions_link WHERE projectdivisions.year='{$config['FAIRYEAR']}' AND projectcategoriesdivisions_link.projectcategories_id='$catr->id' AND projectcategoriesdivisions_link.projectdivisions_id=projectdivisions.id AND projectcategoriesdivisions_link.year='".$config['FAIRYEAR']."' ORDER BY id");
+ else
+ $divq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
+ echo mysql_error();
while($divr=mysql_fetch_object($divq))
{
$langq=mysql_query("SELECT * FROM languages WHERE active='Y'");
@@ -82,6 +86,12 @@ function checkPrerequisites()
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
+ if($config['filterdivisionbycategory']=="yes")
+ {
+ $q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
+ while($r=mysql_fetch_object($q))
+ $catdiv[$r->projectcategories_id][]=$r->projectdivisions_id;
+ }
$foundawards="";
$notfoundawards="";
$foundteams="";
@@ -89,6 +99,11 @@ function checkPrerequisites()
{
foreach($cat AS $c_id=>$c_category)
{
+ if($config['filterdivisionbycategory']=="yes")
+ {
+ if(!in_array($d_id,$catdiv[$c_id]))
+ continue;
+ }
$q=mysql_query("SELECT award_awards.id FROM
award_awards,
award_awards_projectcategories,