From 6bd4d0394153aad3dd53f325646fc26b77dfbae5 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 17 Sep 2009 07:00:09 +0000 Subject: [PATCH] - Selection screen to select what stats to download from feeder fairs --- admin/fair_stats_select.php | 110 +++++++++++++++++++++++++++++++++++ admin/user_editor_window.php | 5 ++ db/db.code.version.txt | 2 +- db/db.update.133.sql | 1 + 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 admin/fair_stats_select.php create mode 100644 db/db.update.133.sql diff --git a/admin/fair_stats_select.php b/admin/fair_stats_select.php new file mode 100644 index 0000000..a774678 --- /dev/null +++ b/admin/fair_stats_select.php @@ -0,0 +1,110 @@ + + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation, version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> + 'Feeder Fair', 'sfiab' => 'SFIAB Upstream', 'ysf' => 'YSF/CWSF Upstream'); + $stats = array('participation' => 'Particpation Numbers', + 'schools_ext' => 'Extra school participation data, number of public/private school students', + 'minorities' => 'Data on minority group participation', + 'guests' => 'Number of student, public guests', + 'sffbc_misc' => 'Number of teachers supporting science, number of students interested in careers in science', + 'info' => 'Fair address, dates, budget, charity info', + 'next_chair' => 'The chair of the regional fair next year', + 'scholarships' => 'Information about scholarships available to be won', + 'delegates' => 'Delegate information/jacket size for CWSF', + ); + + user_auth_required('committee', 'admin'); + + + switch($_GET['action']) { + case 'save': + print_r($_POST); + $id = intval($_POST['fairs_id']); + if(!is_array($_POST['stats'])) $_POST['stats'] = array(); + foreach($_POST['stats'] as $k=>$s) { + if(!array_key_exists($s, $stats)) { + echo "Undefined stat $s, abort.\n"; + exit; + } + } + $s = join(',', $_POST['stats']); + $q = mysql_query("UPDATE fairs SET gather_stats='$s' WHERE id='$id'"); + echo mysql_error(); + echo "UPDATE fairs SET gather_stats='$s' WHERE id='$id'"; + happy_("Saved"); + exit; + + } + /* Load the user we're editting */ + $u = user_load($_SESSION['embed_edit_id']); + /* Load the fair attached to the user */ + $q = mysql_query("SELECT * FROM fairs WHERE id={$u['fairs_id']}"); + $f = mysql_fetch_assoc($q); + +?> + +

+
+ + + +'.i18n('Select which statistics to request from the feeder fair').'

'; + } else { + echo '

'.i18n('Not supported for upstream fairs').'

'; + exit; + } + +?> +
+ + +$d) { + $ch = in_array($s, $selected_stats) ? 'checked="checked"' : ''; + echo ""; + echo ""; + } +?> + +
".i18n($d)."
+
+ + + diff --git a/admin/user_editor_window.php b/admin/user_editor_window.php index a1689f7..aca2bd8 100644 --- a/admin/user_editor_window.php +++ b/admin/user_editor_window.php @@ -32,6 +32,11 @@ $tabs = array( 'fairinfo' => array( 'types' => array('fair'), 'file' => '../fair_info.php', 'enabled' => true,), + 'fairstats' => array( + 'label' => 'Fair Stats Gathering', + 'types' => array('fair'), + 'file' => 'fair_stats_select.php', + 'enabled' => true,), 'personal' => array( 'label' => 'Personal', 'types' => array('student','judge','committee','volunteer','sponsor','fair'), diff --git a/db/db.code.version.txt b/db/db.code.version.txt index 94361d4..6a4573e 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -132 +133 diff --git a/db/db.update.133.sql b/db/db.update.133.sql new file mode 100644 index 0000000..4c5b39a --- /dev/null +++ b/db/db.update.133.sql @@ -0,0 +1 @@ +ALTER TABLE `fairs` ADD `gather_stats` SET( 'participation', 'schools_ext', 'minorities', 'guests', 'sffbc_misc', 'info', 'next_chair', 'scholarships', 'delegates' ) NOT NULL ;