- Add stats to the user editor window

- Go right to the fair editor from the Admin panel.
This commit is contained in:
james 2009-11-06 07:32:51 +00:00
parent 2de42b9377
commit 62fc1a9cb2
3 changed files with 72 additions and 35 deletions

View File

@ -43,7 +43,7 @@
else
echo theme_icon("volunteer_management")."<br />".i18n("Volunteer Management")."<br /><i>(".i18n("disabled").")</i>";
echo '</td></tr><tr>';
echo " <td><a href=\"sciencefairs.php\">".theme_icon("sciencefair_management")."<br />".i18n("Science Fair Management")."</a></td>";
echo " <td><a href=\"user_list.php?show_types[]=fair\">".theme_icon("sciencefair_management")."<br />".i18n("Science Fair Management")."</a></td>";
echo '<td></td>';
echo '<td></td>';
echo '<td></td></tr>';

View File

@ -32,7 +32,7 @@ $tabs = array( 'fairinfo' => array(
'types' => array('fair'),
'file' => '../fair_info.php',
'enabled' => true,),
'fairstats' => array(
'fairstatsgathering' => array(
'label' => 'Fair Stats Gathering',
'types' => array('fair'),
'file' => 'fair_stats_select.php',
@ -72,6 +72,11 @@ $tabs = array( 'fairinfo' => array(
'types' => array('volunteer'),
'file' => '../volunteer_position.php',
'enabled' => true,),
'fairstats' => array(
'label' => 'Fair Statistics and Information',
'types' => array('fair'),
'file' => '../fair_stats.php',
'enabled' => true,),
);
@ -123,15 +128,37 @@ if($_GET['sub'] == 1) {
exit;
}
send_popup_header(i18n("User Editor").": {$u['name']}");
/* Setup tabs */
echo '<div id="tabs">';
echo '<ul>';
$index = 0;
$selected_index = 0;
foreach($tabs as $k=>$t) {
/* Make sure the tab is enabled */
if($t['enabled'] == false) continue;
/* Make sure the user has the right type to see the tab */
$i = array_intersect($t['types'], $u['types']);
if(count($i) == 0) continue;
if($k == $selected) $selected_index = $index;
$index++;
/* Show the tab */
$href = "{$_SERVER['PHP_SELF']}?id=$id&tab=$k&sub=1";
echo "<li><a href=\"$href\"><span>".i18n($t['label'])."</span></a></li>";
}
echo '</ul>';
?>
<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
$("#tabs").tabs({
selected: <?=$selected_index?>
});
window.focus();
});
@ -139,24 +166,6 @@ $(document).ready(function() {
<?
/* Setup some things */
echo '<div id="tabs">';
echo '<ul>';
foreach($tabs as $k=>$t) {
/* Make sure the tab is enabled */
if($t['enabled'] == false) continue;
/* Make sure the user has the right type to see the tab */
$i = array_intersect($t['types'], $u['types']);
if(count($i) == 0) continue;
/* Show the tab */
$href = "{$_SERVER['PHP_SELF']}?id=$id&tab=$k&sub=1";
echo "<li><a href=\"$href\"><span>".i18n($t['label'])."</span></a></li>";
}
echo '</ul>';
$icon_path = $config['SFIABDIRECTORY']."/images/16/";
$icon_exitension = $config['icon_extension'];

View File

@ -1,4 +1,5 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
@ -24,7 +25,6 @@
<?
require_once('common.inc.php');
require_once('user.inc.php');
user_auth_required('fair');
require_once('admin/stats.inc.php');
@ -46,14 +46,16 @@ $u = user_load($eid);
switch($_GET['action']) {
case 'save':
$stats = $_POST['stats'];
$year = intval($_POST['year']);
foreach($stats as $k=>$v) {
$stats[$k] = mysql_escape_string($stats[$k]);
}
// $str = join(',',$stats);
$keys = '`fairs_id`,`year`,`'.join('`,`', array_keys($stats)).'`';
$vals = "'{$u['fairs_id']}','{$config['FAIRYEAR']}','".join("','", array_values($stats))."'";
mysql_query("DELETE FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}' AND year='{$config['FAIRYEAR']}'");
$vals = "'{$u['fairs_id']}','$year','".join("','", array_values($stats))."'";
mysql_query("DELETE FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}' AND year='$year'");
echo mysql_error();
mysql_query("INSERT INTO fairs_stats (`id`,$keys) VALUES ('',$vals)");
echo mysql_error();
@ -63,10 +65,18 @@ case 'save':
}
send_header("Fair Information and Statistics",
if($_SESSION['embed'] == true) {
echo "<br/>";
display_messages();
echo "<h3>".i18n("Fair Information and Statistics")."</h3>";
echo "<br/>";
} else {
send_header("Fair Information and Statistics",
array('Fair Main' => 'fair_main.php'),
"fair_stats"
);
}
?>
<script type="text/javascript">
function stats_save()
@ -78,10 +88,6 @@ function stats_save()
<?
echo "<br />";
/* This was the remote upload code, seems silly to change the config names. server_config really isn't
* from the server here, it's just our local name */
@ -97,7 +103,9 @@ $server_config['next_chair'] = false;
$server_config['scholarships'] = false;
$server_config['delegates'] = false;
$year = $config['FAIRYEAR'];
$year = intval($_POST['year']);
if($year < 1900) $year = $config['FAIRYEAR'];
/* Get the stats we want from this fair */
$q = mysql_query("SELECT * FROM fairs WHERE id='{$u['fairs_id']}'");
@ -108,17 +116,34 @@ $s = split(',', $fair['gather_stats']);
foreach($s as $k) $server_config[$k] = true;
/*
$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'fair_stats.php';
echo "<form id=\"year_form\" name=\"year_form\" method=\"post\" action=\"$s\">";
echo i18n('Select Year').": ";
$q = mysql_query("SELECT DISTINCT year FROM config WHERE year>1000 ORDER BY year DESC");
echo "<select name=\"year\" id=\"year\" onchange=\"this.form.submit()\">";
while($i = mysql_fetch_assoc($q)) {
$y = $i['year'];
$sel = ($config['FAIRYEAR'] == $y) ? 'selected=\"selected\"' : '';
echo "<option value=\"$y\" $sel>$y</option>";
}
echo "</select>";
echo "</form>";
*/
echo "<br />";
/* Load stats */
$q = mysql_query("SELECT * FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}'
AND year='{$config['FAIRYEAR']}'");
AND year='$year'");
$stats = mysql_fetch_assoc($q);
/* Print stats */
/* Print all blocks the server requests */
echo "<form id=\"stats_form\" name=\"stats_form\">";
echo "<form id=\"stats_form\" name=\"stats_form\">";
echo "<input type=\"hidden\" name=\"year\" value=\"$year\" />";
if($server_config['info']) {
echo '<h3>'.i18n('%1 Fair information', array($year)).'</h3>';
@ -310,5 +335,8 @@ $stats = mysql_fetch_assoc($q);
print_r($stats);
echo "</pre>";
*/
send_footer();
if($_SESSION['embed'] != true) {
send_footer();
}
?>