From 29a772ae5ea0f26bcc90fe9fe7081432ac3eb5e3 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 18 Oct 2006 07:50:23 +0000 Subject: [PATCH] - 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. --- admin/judges.php | 3 ++- admin/judges_manager.php | 38 +++++++++++++++++++++++++++++++++++++- judge.class.php | 13 ++++++------- tableeditor.class.php | 20 ++++++++++++++++++-- 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/admin/judges.php b/admin/judges.php index 7261a27..b71b192 100644 --- a/admin/judges.php +++ b/admin/judges.php @@ -34,7 +34,8 @@ { echo "".i18n("Invite Judges")."
"; } - echo "".i18n("Manage Judges")." ".i18n("- Add, Delete, Edit, and List judges")."
"; + echo "".i18n("List Judges")."
"; + echo "".i18n("Manage Judges")." ".i18n("- Add, Delete, Edit, and List judges")."
"; echo "".i18n("Manage Judging Teams")."
"; echo "".i18n("Manage Judging Team Members")."
"; echo "".i18n("Manage Judging Timeslots")."
"; diff --git a/admin/judges_manager.php b/admin/judges_manager.php index ef6e279..3573115 100644 --- a/admin/judges_manager.php +++ b/admin/judges_manager.php @@ -52,9 +52,45 @@ function openjudgeinfo(id) $icon_path = $config['SFIABDIRECTORY']."/images/16/"; $icon_exitension = $config['icon_extension']; + print("

"); + if(isset($_POST['show_what'])) { + $show_what = $_POST['show_what']; + } else { + $show_what = "all"; + } + print("
"); + print(""); + print(""); + print("
"); + + $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(); diff --git a/judge.class.php b/judge.class.php index 6821103..74197c4 100644 --- a/judge.class.php +++ b/judge.class.php @@ -73,7 +73,9 @@ function tableEditorSetup($editor) * field where required */ $l = array( 'id' => 'ID', 'firstname' => 'First Name', - 'lastname' => 'Last Name' + 'lastname' => 'Last Name', + 'complete' => 'Complete' + ); /* Most of these should be moved to the base class, as they @@ -88,7 +90,7 @@ function tableEditorSetup($editor) $editor->setListFields($l); $editor->setEditFields($e); - print_r($e); +// print_r($e); print("
\n"); /* Build an array of langauges that we support */ $langs = array(); @@ -183,7 +185,7 @@ function tableEditorLoad() } } - print_r($j); +// print_r($j); return $j; } @@ -219,9 +221,6 @@ function tableEditorSave($data) echo $query; mysql_query($query); - print("data: \n"); - print_r($data); - print("-- \n"); /* judges_languages */ /* 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}'"; mysql_query($query); - print_r($data['language']); +// print_r($data['language']); $keys = array_keys($data['language']); foreach($keys as $k) { $query = "INSERT INTO diff --git a/tableeditor.class.php b/tableeditor.class.php index bc81da3..be0165f 100644 --- a/tableeditor.class.php +++ b/tableeditor.class.php @@ -94,6 +94,7 @@ class TableEditor var $fieldInputOptions=array(); var $fieldFilterList=array(); var $actionButtons=array(); + var $additionalListTables=array(); /**#@-*/ /**#@+ @@ -270,11 +271,16 @@ class TableEditor $this->fieldInputOptions[$f]=$o; } - function filterList($f,$v) + function filterList($f,$v=false) { $this->fieldFilterList[$f]=$v; } + function additionalListTable($t) + { + $this->additionalListTables[]=$t; + } + function setUploadPath($p) { $this->uploadPath=$p; @@ -875,12 +881,21 @@ class TableEditor $query.=", `$f`"; $query.=" FROM `{$this->table}`"; + if(count($this->additionalListTables)) { + foreach($this->additionalListTables as $t) { + $query .= ",`$t`"; + } + } + if(count($this->fieldFilterList)) { $query.=" WHERE 1 "; foreach($this->fieldFilterList AS $k=>$v) { - $query.=" AND `$k`='$v'"; + if($v == false) + $query .= "AND $k "; + else + $query.=" AND `$k`='$v' "; } } if($this->sortField()) @@ -1000,6 +1015,7 @@ class TableEditor // else // echo "no need to paganate, foundrows=$foundrows, rowsPerPage=".$this->rowsPerPage; + echo " (Total: $foundrows)\n"; if(mysql_error()){ echo error(mysql_error()); return;} if(mysql_num_rows($q))