- Selection screen to select what stats to download from feeder fairs

This commit is contained in:
dave 2009-09-17 07:00:09 +00:00
parent 792a581357
commit 6bd4d03941
4 changed files with 117 additions and 1 deletions

110
admin/fair_stats_select.php Normal file
View File

@ -0,0 +1,110 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2009 David Grant <dave@lightbox.org>
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.
*/
?>
<?
require_once('../common.inc.php');
require_once('../user.inc.php');
require_once('../fair.inc.php');
$fair_type = array('feeder' => '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);
?>
<h4><?=i18n('Fair Stats Gathering')?></h3>
<div id="stats_notice" class="notice_area"></div>
<script type="text/javascript">
function stats_save()
{
$("#debug").load("fair_stats_select.php?action=save", $("#gather_stats").serializeArray());
return 0;
}
notice_div_id('stats_notice');
</script>
<?
if($f['type'] == 'feeder') {
echo '<p>'.i18n('Select which statistics to request from the feeder fair').'</p>';
} else {
echo '<p>'.i18n('Not supported for upstream fairs').'</p>';
exit;
}
?>
<form id="gather_stats">
<input type="hidden" name="fairs_id" value="<?=$f['id']?>" />
<table class="tableedit">
<?
$selected_stats = split(',', $f['gather_stats']);
foreach($stats as $s=>$d) {
$ch = in_array($s, $selected_stats) ? 'checked="checked"' : '';
echo "<tr><td class=\"left\"><input type=\"checkbox\" id=\"stats_$s\" name=\"stats[]\" value=\"$s\" $ch /></td>";
echo "<td class=\"right\">".i18n($d)."</td></tr>";
}
?>
</table>
</form>
<input type="submit" onClick="stats_save();" value="Save" />

View File

@ -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'),

View File

@ -1 +1 @@
132
133

1
db/db.update.133.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE `fairs` ADD `gather_stats` SET( 'participation', 'schools_ext', 'minorities', 'guests', 'sffbc_misc', 'info', 'next_chair', 'scholarships', 'delegates' ) NOT NULL ;