forked from science-ation/science-ation
- Add the judges expertise. This should be all the cross referencing required
for judge specific stuff. Haven't tested/debugged adding and deleting. But editing works.
This commit is contained in:
parent
5e26bd1395
commit
e2e1f3433c
@ -53,8 +53,20 @@ function tableEditorSetup($editor)
|
|||||||
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
||||||
while($r=mysql_fetch_object($q)) {
|
while($r=mysql_fetch_object($q)) {
|
||||||
$cat[$r->id]=$r->category;
|
$cat[$r->id]=$r->category;
|
||||||
$catf["catpref_{$r->id}"] = "Category Preference ({$r->category})";
|
$catf["catpref_{$r->id}"] = "Category Pref|{$r->category}:";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$div = array();
|
||||||
|
$diff = array();
|
||||||
|
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
||||||
|
while($r=mysql_fetch_object($q)) {
|
||||||
|
// $divshort[$r->id]=$r->division_shortform;
|
||||||
|
$div[$r->id]=$r->division;
|
||||||
|
/* yes, catf */
|
||||||
|
$catf["divpref_{$r->id}"] = "Expertise|{$r->division}:";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Setup the table editor with the fields we want to display
|
/* Setup the table editor with the fields we want to display
|
||||||
* when displaying a list of judges, and also the type of each
|
* when displaying a list of judges, and also the type of each
|
||||||
@ -87,12 +99,6 @@ function tableEditorSetup($editor)
|
|||||||
$editor->setFieldOptions('language', $langs);
|
$editor->setFieldOptions('language', $langs);
|
||||||
$editor->setFieldInputType('language', 'multicheck');
|
$editor->setFieldInputType('language', 'multicheck');
|
||||||
|
|
||||||
// $div = array();
|
|
||||||
// $q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
|
|
||||||
// while($r=mysql_fetch_object($q)) {
|
|
||||||
// $divshort[$r->id]=$r->division_shortform;
|
|
||||||
// $div[$r->id]=$r->division;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* Pulled these out of register_judges.inc.php */
|
/* Pulled these out of register_judges.inc.php */
|
||||||
$preferencechoices=array(
|
$preferencechoices=array(
|
||||||
@ -106,7 +112,17 @@ function tableEditorSetup($editor)
|
|||||||
$editor->setFieldOptions("catpref_$cid", $preferencechoices);
|
$editor->setFieldOptions("catpref_$cid", $preferencechoices);
|
||||||
$editor->setFieldInputType("catpref_$cid", 'select');
|
$editor->setFieldInputType("catpref_$cid", 'select');
|
||||||
}
|
}
|
||||||
|
$expertisechoices=array(
|
||||||
|
array('key' => 1, 'val' => "(1) Low"),
|
||||||
|
array('key' => 2, 'val' => "(2) Med-Low"),
|
||||||
|
array('key' => 3, 'val' => "(3) Medium"),
|
||||||
|
array('key' => 4, 'val' => "(4) Med-High"),
|
||||||
|
array('key' => 5, 'val' => "(5) High") );
|
||||||
|
|
||||||
|
foreach($div as $did=>$division) {
|
||||||
|
$editor->setFieldOptions("divpref_$did", $expertisechoices);
|
||||||
|
$editor->setFieldInputType("divpref_$did", 'select');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Functions for $this */
|
/* Functions for $this */
|
||||||
@ -157,6 +173,15 @@ function tableEditorLoad()
|
|||||||
$j["catpref_{$r->projectcategories_id}"] = $r->rank;
|
$j["catpref_{$r->projectcategories_id}"] = $r->rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$q=mysql_query("SELECT *
|
||||||
|
FROM judges_expertise
|
||||||
|
WHERE judges_id='$id'
|
||||||
|
AND year='{$config['FAIRYEAR']}'");
|
||||||
|
if(mysql_num_rows($q)) {
|
||||||
|
while($r=mysql_fetch_object($q)) {
|
||||||
|
$j["divpref_{$r->projectdivisions_id}"] = $r->val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_r($j);
|
print_r($j);
|
||||||
|
|
||||||
@ -216,7 +241,7 @@ function tableEditorSave($data)
|
|||||||
|
|
||||||
/* judges_catpref */
|
/* judges_catpref */
|
||||||
$query = "DELETE FROM judges_catpref WHERE judges_id='{$this->id}'";
|
$query = "DELETE FROM judges_catpref WHERE judges_id='{$this->id}'";
|
||||||
print($query);
|
// print($query);
|
||||||
mysql_query($query);
|
mysql_query($query);
|
||||||
|
|
||||||
/* Find all the catpref_[number] keys */
|
/* Find all the catpref_[number] keys */
|
||||||
@ -227,6 +252,22 @@ function tableEditorSave($data)
|
|||||||
$query = "INSERT INTO judges_catpref
|
$query = "INSERT INTO judges_catpref
|
||||||
(judges_id,projectcategories_id,rank,year)
|
(judges_id,projectcategories_id,rank,year)
|
||||||
values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
|
values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
|
||||||
|
// print($query."<br>\n");
|
||||||
|
mysql_query($query);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Find all the divpref_[number] keys */
|
||||||
|
$query = "DELETE FROM judges_expertise WHERE judges_id='{$this->id}'";
|
||||||
|
// print($query);
|
||||||
|
mysql_query($query);
|
||||||
|
$keys = array_keys($data);
|
||||||
|
foreach($keys as $k) {
|
||||||
|
if(ereg("^divpref_([0-9]*)$", $k, $regs)) {
|
||||||
|
if($data[$k] == "''") continue;
|
||||||
|
$query = "INSERT INTO judges_expertise
|
||||||
|
(judges_id,projectdivisions_id,val,year)
|
||||||
|
values ('{$this->id}','{$regs[1]}',{$data[$k]},'{$config['FAIRYEAR']}')";
|
||||||
print($query."<br>\n");
|
print($query."<br>\n");
|
||||||
mysql_query($query);
|
mysql_query($query);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user