forked from science-ation/science-ation
- Add the judge manager to the judges admin page
- Put a total at the top of the judge manager list - Add to the table editor: - Change the filter to accept a single argument, so we're not restricted to the `$k`='$v' syntax, we want to be able to filter on a table JOIN. - Add a additionalListTable variable, and additionalListTable() function, to specify additional tables that should be part of the table select statement. I guess ideally the class would implmenent their own if alternative behaviour was desired. But this way is pretty generic. The table editor can now, for example, select judges by year.
This commit is contained in:
parent
e3035cb13f
commit
29a772ae5e
@ -34,7 +34,8 @@
|
|||||||
{
|
{
|
||||||
echo "<a href=\"judges_invite.php\">".i18n("Invite Judges")."</a><br />";
|
echo "<a href=\"judges_invite.php\">".i18n("Invite Judges")."</a><br />";
|
||||||
}
|
}
|
||||||
echo "<a href=\"judges_judges.php\">".i18n("Manage Judges")."</a> ".i18n("- Add, Delete, Edit, and List judges")."<br />";
|
echo "<a href=\"judges_judges.php\">".i18n("List Judges")."</a><br />";
|
||||||
|
echo "<a href=\"judges_manager.php\">".i18n("Manage Judges")."</a> ".i18n("- Add, Delete, Edit, and List judges")."<br />";
|
||||||
echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />";
|
echo "<a href=\"judges_teams.php\">".i18n("Manage Judging Teams")."</a><br />";
|
||||||
echo "<a href=\"judges_teams_members.php\">".i18n("Manage Judging Team Members")."</a><br />";
|
echo "<a href=\"judges_teams_members.php\">".i18n("Manage Judging Team Members")."</a><br />";
|
||||||
echo "<a href=\"judges_timeslots.php\">".i18n("Manage Judging Timeslots")."</a><br />";
|
echo "<a href=\"judges_timeslots.php\">".i18n("Manage Judging Timeslots")."</a><br />";
|
||||||
|
@ -52,9 +52,45 @@ function openjudgeinfo(id)
|
|||||||
$icon_path = $config['SFIABDIRECTORY']."/images/16/";
|
$icon_path = $config['SFIABDIRECTORY']."/images/16/";
|
||||||
$icon_exitension = $config['icon_extension'];
|
$icon_exitension = $config['icon_extension'];
|
||||||
|
|
||||||
|
print("<br /><br />");
|
||||||
|
if(isset($_POST['show_what'])) {
|
||||||
|
$show_what = $_POST['show_what'];
|
||||||
|
} else {
|
||||||
|
$show_what = "all";
|
||||||
|
}
|
||||||
|
print("<form name=\"ShowJudges\" method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">");
|
||||||
|
print("<select id=\"show_what\" name=\"show_what\">");
|
||||||
|
$s = ($show_what == 'all') ? " selected=selected " : "";
|
||||||
|
print("<option value=\"all\" $s>All Judges</option>");
|
||||||
|
$s = ($show_what == 'cy_active') ? " selected=selected " : "";
|
||||||
|
print("<option value=\"cy_active\" $s>All {$config['FAIRYEAR']} Judges (complete and incomplete)</option>");
|
||||||
|
$s = ($show_what == 'cy_complete') ? " selected=selected " : "";
|
||||||
|
print("<option value=\"cy_complete\" $s>All {$config['FAIRYEAR']} Judges (only complete)</option>");
|
||||||
|
print("</select>");
|
||||||
|
print("<input type=submit value=\"".i18n("Show")."\">");
|
||||||
|
print("</form>");
|
||||||
|
|
||||||
|
|
||||||
$editor = new TableEditor('judge');
|
$editor = new TableEditor('judge');
|
||||||
|
|
||||||
$editor->setDebug(true);
|
// $editor->setDebug(true);
|
||||||
|
|
||||||
|
switch($show_what) {
|
||||||
|
case "all":
|
||||||
|
break;
|
||||||
|
case "cy_active":
|
||||||
|
$editor->additionalListTable("judges_years");
|
||||||
|
$editor->filterList("judges_years.judges_id=judges.id");
|
||||||
|
$editor->filterList("judges_years.year={$config['FAIRYEAR']}");
|
||||||
|
break;
|
||||||
|
case "cy_complete":
|
||||||
|
$editor->additionalListTable("judges_years");
|
||||||
|
$editor->filterList("judges_years.judges_id=judges.id");
|
||||||
|
$editor->filterList("judges_years.year={$config['FAIRYEAR']}");
|
||||||
|
$editor->filterList("judges.complete='yes'");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$editor->execute();
|
$editor->execute();
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +73,9 @@ function tableEditorSetup($editor)
|
|||||||
* field where required */
|
* field where required */
|
||||||
$l = array( 'id' => 'ID',
|
$l = array( 'id' => 'ID',
|
||||||
'firstname' => 'First Name',
|
'firstname' => 'First Name',
|
||||||
'lastname' => 'Last Name'
|
'lastname' => 'Last Name',
|
||||||
|
'complete' => 'Complete'
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Most of these should be moved to the base class, as they
|
/* Most of these should be moved to the base class, as they
|
||||||
@ -88,7 +90,7 @@ function tableEditorSetup($editor)
|
|||||||
$editor->setListFields($l);
|
$editor->setListFields($l);
|
||||||
$editor->setEditFields($e);
|
$editor->setEditFields($e);
|
||||||
|
|
||||||
print_r($e);
|
// print_r($e);
|
||||||
print("<br>\n");
|
print("<br>\n");
|
||||||
/* Build an array of langauges that we support */
|
/* Build an array of langauges that we support */
|
||||||
$langs = array();
|
$langs = array();
|
||||||
@ -183,7 +185,7 @@ function tableEditorLoad()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_r($j);
|
// print_r($j);
|
||||||
|
|
||||||
return $j;
|
return $j;
|
||||||
}
|
}
|
||||||
@ -219,9 +221,6 @@ function tableEditorSave($data)
|
|||||||
echo $query;
|
echo $query;
|
||||||
mysql_query($query);
|
mysql_query($query);
|
||||||
|
|
||||||
print("data: \n");
|
|
||||||
print_r($data);
|
|
||||||
print("-- \n");
|
|
||||||
|
|
||||||
/* judges_languages */
|
/* judges_languages */
|
||||||
/* First delete all the languages, then insert the ones the judge
|
/* First delete all the languages, then insert the ones the judge
|
||||||
@ -229,7 +228,7 @@ function tableEditorSave($data)
|
|||||||
$query = "DELETE FROM judges_languages WHERE judges_id='{$this->id}'";
|
$query = "DELETE FROM judges_languages WHERE judges_id='{$this->id}'";
|
||||||
mysql_query($query);
|
mysql_query($query);
|
||||||
|
|
||||||
print_r($data['language']);
|
// print_r($data['language']);
|
||||||
$keys = array_keys($data['language']);
|
$keys = array_keys($data['language']);
|
||||||
foreach($keys as $k) {
|
foreach($keys as $k) {
|
||||||
$query = "INSERT INTO
|
$query = "INSERT INTO
|
||||||
|
@ -94,6 +94,7 @@ class TableEditor
|
|||||||
var $fieldInputOptions=array();
|
var $fieldInputOptions=array();
|
||||||
var $fieldFilterList=array();
|
var $fieldFilterList=array();
|
||||||
var $actionButtons=array();
|
var $actionButtons=array();
|
||||||
|
var $additionalListTables=array();
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
@ -270,11 +271,16 @@ class TableEditor
|
|||||||
$this->fieldInputOptions[$f]=$o;
|
$this->fieldInputOptions[$f]=$o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterList($f,$v)
|
function filterList($f,$v=false)
|
||||||
{
|
{
|
||||||
$this->fieldFilterList[$f]=$v;
|
$this->fieldFilterList[$f]=$v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function additionalListTable($t)
|
||||||
|
{
|
||||||
|
$this->additionalListTables[]=$t;
|
||||||
|
}
|
||||||
|
|
||||||
function setUploadPath($p)
|
function setUploadPath($p)
|
||||||
{
|
{
|
||||||
$this->uploadPath=$p;
|
$this->uploadPath=$p;
|
||||||
@ -875,12 +881,21 @@ class TableEditor
|
|||||||
$query.=", `$f`";
|
$query.=", `$f`";
|
||||||
$query.=" FROM `{$this->table}`";
|
$query.=" FROM `{$this->table}`";
|
||||||
|
|
||||||
|
if(count($this->additionalListTables)) {
|
||||||
|
foreach($this->additionalListTables as $t) {
|
||||||
|
$query .= ",`$t`";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->fieldFilterList))
|
if(count($this->fieldFilterList))
|
||||||
{
|
{
|
||||||
$query.=" WHERE 1 ";
|
$query.=" WHERE 1 ";
|
||||||
foreach($this->fieldFilterList AS $k=>$v)
|
foreach($this->fieldFilterList AS $k=>$v)
|
||||||
{
|
{
|
||||||
$query.=" AND `$k`='$v'";
|
if($v == false)
|
||||||
|
$query .= "AND $k ";
|
||||||
|
else
|
||||||
|
$query.=" AND `$k`='$v' ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->sortField())
|
if($this->sortField())
|
||||||
@ -1000,6 +1015,7 @@ class TableEditor
|
|||||||
// else
|
// else
|
||||||
// echo "no need to paganate, foundrows=$foundrows, rowsPerPage=".$this->rowsPerPage;
|
// echo "no need to paganate, foundrows=$foundrows, rowsPerPage=".$this->rowsPerPage;
|
||||||
|
|
||||||
|
echo " (Total: $foundrows)\n";
|
||||||
|
|
||||||
if(mysql_error()){ echo error(mysql_error()); return;}
|
if(mysql_error()){ echo error(mysql_error()); return;}
|
||||||
if(mysql_num_rows($q))
|
if(mysql_num_rows($q))
|
||||||
|
Loading…
Reference in New Issue
Block a user