science-ation/admin/reports_gen.php
dave 998fe35d67 - Add a tour number to the database, and modify the tour editor to include the
number, and an option to create numbers automatically
- Completely remove all references (hopefully) to the Tour ID
- Add a Tour type report
- Rework the student report query so it actually makes sense.  It really should
  be a whole bunch of left joins based on the students.  Using comma (cross)
  joins creates situations where if the right side of the join doesn't have
  information, it wipes out the left side.  (Happened before with emergency
  contact info).
- Remove the (two) old custom tour reports
- Add 4 new tour reports to the database:
	- ALL tours for the committee, tour list for students, 
	student emergency contact info for tour coordinators, and 
	a list of tour assignments for students
2007-12-20 01:05:04 +00:00

136 lines
4.3 KiB
PHP

<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@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");
user_auth_required('committee', 'admin');
require_once('reports.inc.php');
$id = intval($_GET['id']);
$sid = intval($_GET['sid']);
$type = stripslashes($_GET['type']);
$stock = stripslashes($_GET['stock']);
$year = intval($_GET['year']);
$show_options = array_key_exists('show_options', $_GET);
if($year < 1000) $year = $config['FAIRYEAR'];
/* If it's a system report, turn that into the actual report id */
if($sid > 0) {
$q = mysql_query("SELECT id FROM reports WHERE system_report_id='$sid'");
$r = mysql_fetch_assoc($q);
$id = $r['id'];
}
if($show_options == false) {
if($id && $year) {
$report = report_load($id);
$report['year'] = $year;
if($type != '') $report['option']['type'] = $type;
if($stock != '') $report['option']['stock'] = $stock;
report_gen($report);
} else {
exit;
header("Location: reports.php");
}
exit;
}
$report = report_load($id);
send_header('Report Options', array(
'Committee Main' => 'committee_main.php',
'My Reports' => 'admin/reports.php'));
echo '<table class="tableedit">';
echo "<tr><td><b>".i18n('Report&nbsp;Name')."</b>:</td>";
echo "<td>{$report['name']}</td></tr>";
echo "<tr><td><b>".i18n('Description')."</b>:</td>";
echo "<td>{$report['desc']}</td></tr>";
echo "<tr><td><b>".i18n('Created By')."</b>:</td>";
echo "<td>{$report['creator']}</td></tr>";
echo '<tr><td colspan="2"><hr /></td></tr>';
/* See if the report is in this committee member's list */
$q = mysql_query("SELECT * FROM reports_committee
WHERE users_id='{$_SESSION['users_id']}'
AND reports_id='{$report['id']}'");
echo "<tr><td colspan=\"2\"><h4>".i18n('My Reports Info')."</h4></td></tr>";
if(mysql_num_rows($q) > 0) {
/* Yes, it is */
$i = mysql_fetch_object($q);
echo "<tr><td><b>".i18n('Category')."</b>:</td>";
echo "<td>{$i->category}</td></tr>";
echo "<tr><td><b>".i18n('Comment')."</b>:</td>";
echo "<td>{$i->comment}</td></tr>";
} else {
echo "<tr><td colspan=\"2\">".i18n('This report is NOT in your \'My Reports\' list.')."</td></tr>";
}
echo "</table>";
echo '<hr />';
echo "<h3>".i18n('Report Options')."</h3>";
echo '<form method=\"get\" action="reports_gen.php">';
echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
echo "<table class=\"tableedit\">";
$format = $report['options']['type'];
$stock = $report['options']['stock'];
$year = $config['FAIRYEAR'];
/* Out of all the report optoins, we really only want these ones */
$option_keys = array('type','stock');
foreach($report_options as $ok=>$o) {
if(!in_array($ok, $option_keys)) continue;
echo "<tr><td><b>{$o['desc']}</b>:</td>";
echo "<td><select name=\"$ok\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) {
$sel = ($report['option'][$ok] == $k) ? 'selected=\"selected\"' : '';
echo "<option value=\"$k\" $sel>$v</option>";
}
echo "</select></td></tr>";
}
/* Find all the years */
$q = mysql_query("SELECT DISTINCT year FROM config WHERE year>1000");
echo "<tr><td><b>".i18n('Year')."</b>:</td>";
echo "<td><select name=\"year\" id=\"year\">";
while($i = mysql_fetch_assoc($q)) {
$y = $i['year'];
$sel = ($config['FAIRYEAR'] == $y) ? 'selected=\"selected\"' : '';
echo "<option value=\"$y\" $sel>$y</option>";
}
echo "</select></td></tr>";
echo "</table>";
echo '<br />';
echo "<input type=\"submit\" value=\"".i18n('Generate Report')."\" />";
echo '</form>';
send_footer();
?>