- Add a new student report generator

- Add an editor for that generator.. it's not flawless, but it's not hard to
  use either.
- Add 19 default reports
- Replace several reports on the report page with the new generator versions
  (they pretty much look the same, same info, same sort order, same pagination)
- Add a pulldown menu to the report pages so any report can be generated
This commit is contained in:
dave 2007-03-18 07:10:54 +00:00
parent 7c96874571
commit b3978c7dae
9 changed files with 1346 additions and 627 deletions

View File

@ -35,6 +35,7 @@
echo "<a href=\"schools.php\">".i18n("School Management")."</a> <br />";
echo "<a href=\"judges.php\">".i18n("Judging Management")."</a> <br />";
echo "<a href=\"translations.php\">".i18n("Translations Management")."</a> <br />";
echo "<a href=\"reports_editor.php\">".i18n("Report Management")."</a> <br />";
if($config['tours_enable'] == 'yes') {
echo "<a href=\"tours_manager.php\">".i18n("Tour Management")."</a> <br />";
}

265
admin/reports.inc.php Normal file
View File

@ -0,0 +1,265 @@
<?
/*
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("reports_students.inc.php"); /* $report_students_fields */
$options = array();
$options['type'] = array( 'desc' => 'Report Format',
'values' => array('pdf'=>'PDF', 'csv'=>'CSV')
);
$options['group_new_page'] = array( 'desc' => 'Start each new grouping on a new page',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
$options['allow_multiline'] = array( 'desc' => 'Allow table rows to span multiple lines',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
/*
Viceroy Grand Avery rows? w x h" per page
& Toy
LRP 130 99180 5960 3 2 5/8 x 1 30
LRP 120 99189 5961 2 4 x 1 20
LRP 114 99179 5959 7 4 x 1 1/2 14
LRP 214 99190 5962 7 4 x 1 1/3 14
LRP 110 99181 5963 5 4 x 2 10
LRP 106 99763 5964 3 4 x 3 1/3 6
LRP 100 99764 5965 1 8 1/2 x 11 1
LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
/* FIXME: put these in a databse */
$stock = array();
$stock['5964'] = array('name' => 'Avery 5964, G&T 99763',
'page_width' => 8 + 1/2,
'page_height' => 11,
'label_width' => 4,
'x_spacing' => 3/16,
'cols' => 2,
'label_height' => 3 + 1/3,
'y_spacing' => 0,
'rows' => 3,
);
$labels[] = array( 'name' => 'GVRSF Project Labels',
'options' => array('fair_header' => true),
'items' => array(
array( 'field' => 'pn',
'x' => 'center',
'y' => 'center',
'h' => 50 ),
array( 'field' => 'bothnames',
'x' => 'center',
'y' => 80,
'h' => 10 ),
array( 'field' => 'categorydivision',
'x' => 'center',
'y' => 90,
'h' => 10 ),
),
);
/* Add more types to the report format */
foreach($stock as $n=>$v) {
$options['type']['values'][$n] = $v['name'];
}
$allow_options = array_keys($options);
function report_load_field($report, $type)
{
global $allow_options, $report_students_fields;
$allow_fields = array();
switch($report['type']) {
case 'student':
$allow_fields = array_keys($report_students_fields);
break;
}
$ret = array();
$q = mysql_query("SELECT * FROM reports_items
WHERE reports_id='{$report['id']}'
AND type='$type'
ORDER BY `order`");
print(mysql_error());
if(mysql_num_rows($q) == 0) return $ret;
while($a = mysql_fetch_assoc($q)) {
$f = $a['field'];
if($type == 'option') {
if(!in_array($f, $allow_options)) {
print("Type[$type] Field[$f] not allowed.\n");
exit;
}
$ret[$f] = $a['value'];
} else {
if(!in_array($f, $allow_fields)) {
print("Type[$type] Field[$f] not allowed.\n");
exit;
}
$ret[] = $a['field'];
}
}
return $ret;
}
function report_save_field($report, $type)
{
global $allow_options, $report_students_fields;
switch($report['type']) {
case 'student':
$allow_fields = array_keys($report_students_fields);
break;
}
/* First delete all existing fields */
mysql_query("DELETE FROM reports_items
WHERE `reports_id`='{$report['id']}'
AND `type`='$type'");
/* Now add new ones */
if(count($report[$type]) == 0) return;
$q = '';
$x = 0;
foreach($report[$type] as $k=>$v) {
if($type == 'option') {
$field = $k;
$val = $v;
} else {
$field = $v;
$val = '';
}
if($q != '') $q .= ',';
$q .= "({$report['id']}, '$field', '$type', '$val', $x)";
$x++;
}
mysql_query("INSERT INTO reports_items(`reports_id`,`field`,`type`,`value`,`order`)
VALUES $q;");
echo mysql_error();
}
function report_load($report_id)
{
$report = array();
$q = mysql_query("SELECT * FROM reports WHERE id='$report_id'");
$r = mysql_fetch_assoc($q);
$report['name'] = $r['name'];
$report['id'] = $r['id'];
$report['desc'] = $r['desc'];
$report['creator'] = $r['creator'];
$report['type'] = $r['type'];
/* Get the data */
$report['col'] = report_load_field($report, 'col');
$report['group'] = report_load_field($report, 'group');
$report['sort'] = report_load_field($report, 'sort');
$report['distinct'] = report_load_field($report, 'distinct');
$report['option'] = report_load_field($report, 'option');
return $report;
}
function report_save($report)
{
if($report['id'] == 0) {
/* New report */
mysql_query("INSERT INTO reports (`id`) VALUES ('')");
$report['id'] = mysql_insert_id();
}
mysql_query("UPDATE reports SET
`name`='".mysql_escape_string($report['name'])."',
`desc`='".mysql_escape_string($report['desc'])."',
`creator`='".mysql_escape_string($report['creator'])."',
`type`='".mysql_escape_string($report['type'])."'
WHERE `id`={$report['id']}");
report_save_field($report, 'col');
report_save_field($report, 'group');
report_save_field($report, 'sort');
report_save_field($report, 'distinct');
report_save_field($report, 'option');
return $report['id'];
}
function report_load_all()
{
$ret = array();
$q = mysql_query("SELECT * FROM reports ORDER BY `name`");
while($r = mysql_fetch_assoc($q)) {
$report = array();
$report['name'] = $r['name'];
$report['id'] = $r['id'];
$report['desc'] = $r['desc'];
$report['creator'] = $r['creator'];
$report['type'] = $r['type'];
$ret[] = $report;
}
return $ret;
}
function report_gen($report)
{
if($report['type'] == 'student') {
return report_students_gen($report);
}
}
function report_gen_by_id($report_id, $format=NULL)
{
$report = report_load($report_id);
if($format != NULL) {
$keys = array_keys($options['type']['values']);
if(in_array($format, $keys)) {
$report['option']['type'] = $format;
} else {
print("type [$format] not permitted\n");
exit;
}
}
return report_gen($report);
}
function report_delete($report_id)
{
$r = intval($report_id);
mysql_query("DELETE FROM reports WHERE `id`=$r");
mysql_query("DELETE FROM reports_items WHERE `reports_id`=$r");
}
?>

View File

@ -23,14 +23,37 @@
?>
<?
require("../common.inc.php");
require_once('reports.inc.php');
auth_required('admin');
send_header("Administration - Reports");
echo "<a href=\"index.php\">&lt;&lt; ".i18n("Back to Administration")."</a><br />";
echo "<br />";
echo "<table><tr><td>";
echo i18n("Day of Fair Registration/Checkin Forms").": ";
echo "</td>";
$id = intval($_POST['id']);
echo "<h4>".i18n("All Reports")."</h4>";
echo "<form method=\"post\" name=\"reportload\" action=\"reports.php\" onChange=\"document.reportload.submit()\">";
echo "<select name=\"id\" id=\"report\">";
echo "<option value=\"0\">".i18n("Select a Report")."</option>\n";
$reports = report_load_all();
$x=0;
foreach($reports as $r) {
$sel = ($id == $r['id']) ? 'selected=\"selected\"' : '';
echo "<option value=\"{$r['id']}\" $sel>{$r['name']}</option>\n";
}
echo "</select><br />";
echo "<a href=\"reports_gen.php?id=$id&type=pdf\">Generate PDF</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=$id&type=csv\">Generate CSV</a> &nbsp; ";
echo "<hr />";
echo "<h4>".i18n("Custom Reports")."</h4>";
echo i18n("Day of Fair Registration/Checkin Forms (All Categories)").": ";
echo "<a href=\"reports_gen.php?id=9&type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=9&type=csv\">CSV</a> &nbsp; ";
//lets split this up by age category,
/*
$catq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($catr=mysql_fetch_object($catq))
{
@ -40,9 +63,9 @@ while($catr=mysql_fetch_object($catq))
echo "<a href=\"reports_checkin.php?type=csv&cat=$catr->id\">$catr->category (CSV)</a> &nbsp; ";
echo "</td>";
}
echo "</tr>";
echo "</table>";
*/
echo "<br />";
echo "<br />";
echo i18n("Mailing Labels").": ";
echo "<a href=\"reports_mailinglabels.php\">".i18n("Mailing Label Generator")."</a>";
@ -55,18 +78,23 @@ echo "</table>";
echo "<br />";
echo i18n("Student Emergency Contact Names/Numbers").": ";
echo "<a href=\"reports_emergencycontact.php?type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_emergencycontact.php?type=csv\">CSV</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=17&type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=17&type=csv\">CSV</a> &nbsp; ";
// echo "<a href=\"reports_emergencycontact.php?type=pdf\">PDF</a> &nbsp; ";
// echo "<a href=\"reports_emergencycontact.php?type=csv\">CSV</a> &nbsp; ";
echo "<br />";
echo i18n("Students/Projects From Each School").": ";
echo "<a href=\"reports_schoolprojects.php?type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_schoolprojects.php?type=csv\">CSV</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=19&type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=19&type=csv\">CSV</a> &nbsp; ";
//cho "<a href=\"reports_schoolprojects.php?type=pdf\">PDF</a> &nbsp; ";
//cho "<a href=\"reports_schoolprojects.php?type=csv\">CSV</a> &nbsp; ";
echo "<br />";
echo i18n("Project Logistical Requirements (tables, electricity)").": ";
echo "<a href=\"reports_projects_requirements.php?type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_projects_requirements.php?type=csv\">CSV</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=16&type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_gen.php?id=16&type=csv\">CSV</a> &nbsp; ";
// echo "<a href=\"reports_projects_requirements.php?type=pdf\">PDF</a> &nbsp; ";
// echo "<a href=\"reports_projects_requirements.php?type=csv\">CSV</a> &nbsp; ";
echo "<br />";
echo i18n("Project Table Labels").": ";

299
admin/reports_editor.php Normal file
View File

@ -0,0 +1,299 @@
<?
/*
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("../common.inc.php");
auth_required('admin');
require_once('reports_students.inc.php');
require_once('reports.inc.php');
$fields = array();
function field_selector($name, $id, $selected)
{
global $fields;
echo "<select name=\"$name\" id=\"$id\">";
echo "<option value=\"\" />-- None --</option>";
foreach($fields as $k=>$f) {
$sel = ($selected == $k) ? 'selected=\"selected\"': '' ;
echo "<option value=\"$k\" $sel >{$f['name']}</option>";
}
echo "</select>";
}
/*
<script type="text/javascript">
function reportChange()
{
var index = document.forms.report.report.selectedIndex;
document.getElementById('report').submit();
return;
/* Clean out existing settings
<?foreach($fields as $k=>$f) {
echo "document.getElementById('$k').checked=false;\n";
}?>
document.getElementById('group0').value = '';
document.getElementById('group1').value = '';
// document.getElementById('group2').value = '';
document.getElementById('sort0').value = '';
document.getElementById('sort1').value = '';
document.getElementById('sort2').value = '';
document.getElementById('distinct0').value = '';
document.getElementById('type').value = 'pdf';
document.getElementById('group_new_page').value = 'no';
/* Load appropriate settings
if(index == 0) {
/* Do nothing
}
<?$x=1;
foreach($reports as $r) {
echo "else if(index == $x) {\n";
foreach($r['cols'] as $c) {
echo "document.getElementById('$c').checked=true;\n";
}
$i = 0;
foreach($r['sort'] as $c) {
echo "document.getElementById('sort$i').value='$c';\n";
$i++;
}
$i = 0;
foreach($r['group'] as $c) {
echo "document.getElementById('group$i').value='$c';\n";
$i++;
}
if(is_array($r['distinct'])) {
$i = 0;
foreach($r['distinct'] as $c) {
echo "document.getElementById('distinct$i').value='$c';\n";
$i++;
}
}
if(is_array($r['option'])) {
foreach($r['option'] as $k=>$v) {
echo "document.getElementById('$k').value='$v';\n";
}
}
$x++;
echo "}\n";
}
?>
}
</script>
*/
function parse_fields($f)
{
$ret = array();
if(!is_array($_POST[$f])) return array();
foreach($_POST[$f] as $c) {
if(trim($c) == '') continue;
$ret[] = stripslashes($c);
}
return $ret;
}
function parse_options($f)
{
$ret = array();
if(!is_array($_POST[$f])) return array();
foreach($_POST[$f] as $c=>$v) {
if(trim($c) == '') continue;
$ret[$c] = stripslashes($v);
}
return $ret;
}
/* Decode the report */
$report = array();
$report['id'] = intval($_POST['id']);
$report['name'] = stripslashes($_POST['name']);
$report['creator'] = stripslashes($_POST['creator']);
$report['desc'] = stripslashes($_POST['desc']);
$report['type'] = stripslashes($_POST['type']);
$report['col'] = parse_fields('col');
$report['group'] = parse_fields('group');
$report['sort'] = parse_fields('sort');
$report['distinct'] = parse_fields('distinct');
$report['option'] = parse_options('option');
$loadaction = $_POST['loadaction'];
$colaction = $_POST['colaction'];
$repaction = $_POST['repaction'];
$repaction_save = $repaction;
/* Sort out priorities */
if($loadaction != '') {
$report = report_load(intval($_POST['id']));
$colaction = '';
$repaction = '';
}
if($colaction != '') {
$repaction = '';
}
if($repaction == 'try') {
/* Try this report save it to the database under a new report, and mark it as
* temporary, so when the generator finishes with it, it deletes it */
report_gen($report);
exit;
}
send_header("Administration - Reports > Editor");
if($repaction == 'save') {
/* Save the report */
$report['id'] = report_save($report);
echo happy(i18n("Report Saved"));
}
if($repaction == 'del') {
report_delete($report['id']);
echo happy(i18n("Report Deleted"));
}
/* ---- Setup ------ */
$n_columns = intval($_POST['ncolumns']);
$n = count($report['col']) + 1;
if($n > $n_columns) $n_columns = $n;
if($colaction == 'add') $n_columns+=3;
switch($report['type']) {
case 'student':
$fields = $report_students_fields;
break;
}
echo "<a href=\"reports.php\">&lt;&lt; ".i18n("Back to Reports")."</a><br />";
echo "<br />";
echo "<form method=\"post\" name=\"reportload\" action=\"reports_editor.php\" onChange=\"document.reportload.submit()\">";
echo "<input type=\"hidden\" name=\"loadaction\" value=\"load\" />";
echo "<select name=\"id\" id=\"report\">";
echo "<option value=\"0\">".i18n("Create New Report")."</option>\n";
$reports = report_load_all();
$x=0;
foreach($reports as $r) {
$sel = ($report['id'] == $r['id']) ? 'selected=\"selected\"' : '';
echo "<option value=\"{$r['id']}\" $sel>{$r['name']}</option>\n";
}
echo "</select>";
echo "<input type=\"submit\" value=\"Load\"></form>";
echo "<hr />";
echo "<form method=\"post\" name=\"report\" action=\"reports_editor.php\">";
echo "<input type=\"hidden\" name=\"id\" value=\"{$report['id']}\" />";
echo "<input type=\"hidden\" name=\"ncolumns\" value=\"$n_columns\" />";
echo "<h4>Report Information</h4>";
echo "<table>";
echo "<tr><td>Name: </td>";
echo "<td><input type=\"text\" name=\"name\" size=\"80\" value=\"{$report['name']}\" /></td>";
echo "</tr>";
echo "<tr><td>Created By: </td>";
echo "<td><input type=\"text\" name=\"creator\" size=\"80\" value=\"{$report['creator']}\" /></td>";
echo "</tr>";
echo "<tr><td>Description: </td>";
echo "<td><textarea name=\"desc\" rows=\"3\" cols=\"60\">{$report['desc']}</textarea></td>";
echo "</tr>";
echo "<tr><td>Type: </td>";
echo "<td><select name=\"type\" /><option value=\"student\">Student Report</option></select></td>";
echo "</tr></table>";
echo "<h4>Report Data</h4>";
echo "<table>";
$x=0;
foreach($report['col'] as $f) {
echo "<tr><td>Column ".($x + 1).": </td>";
echo "<td>";
field_selector("col[]", "col$x", $f);
echo "</td></tr>";
$x++;
}
for(;$x<$n_columns;$x++) {
echo "<tr><td>Column ".($x + 1).": </td>";
echo "<td>";
field_selector("col[]", "col$x", '');
echo "</td></tr>";
}
echo "<tr><td></td>";
echo "<td align=\"right\">";
echo "<select name=\"colaction\"><option value=\"\"></option><option value=\"add\">Add more columns</option></select>";
echo "<input type=\"submit\" value=\"Go\">";
echo "</td></tr>";
echo "</table>\n";
echo "<h4>Grouping</h4>";
for($x=0;$x<2;$x++) {
echo "Group By".($x + 1).": ";
field_selector("group[]", "group$x", $report['group'][$x]);
echo "<br />";
}
echo "<h4>Sorting</h4>";
for($x=0;$x<3;$x++) {
echo "Sort By".($x + 1).": ";
field_selector("sort[]", "sort$x", $report['sort'][$x]);
echo "<br />";
}
echo "<h4>Distinct</h4>";
echo "Distinct Column: ";
field_selector("distinct[]", "distinct0", $report['distinct'][0]);
echo "<h4>Options</h4>";
foreach($options as $ok=>$o) {
echo "{$o['desc']}: <select name=\"option[$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><br />\n";
}
echo "<br />";
echo "<select name=\"repaction\">";
$sel = ($repaction_save == 'save') ? "selected=\"selected\"" : '';
echo " <option value=\"save\" $sel>Save this report</option>";
$sel = ($repaction_save == 'try') ? "selected=\"selected\"" : '';
echo " <option value=\"try\" $sel>Try this report</option>";
echo " <option value=\"\" ></option>";
echo " <option value=\"del\" >Delete this report</option>";
echo "</select>";
echo "<input type=\"submit\" value=\"Go\">";
echo "</form>";
send_footer();
?>

38
admin/reports_gen.php Normal file
View File

@ -0,0 +1,38 @@
<?
/*
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("../common.inc.php");
auth_required('admin');
require_once('reports_students.inc.php');
require_once('reports.inc.php');
$id = intval($_GET['id']);
$format = stripslashes($_GET['format']);
if($format == '') $format = NULL;
report_gen_by_id($id, $format);
?>

View File

@ -0,0 +1,481 @@
<?
/*
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.
*/
$report_students_fields = array(
'pn' => array(
'name' => 'Project Number',
'header' => '#',
'width' => 0.5,
'table' => 'projects.projectnumber' ),
'last_name' => array(
'name' => 'Last Name',
'header' => 'Last Name',
'width' => 1.0,
'table' => 'students.lastname' ),
'first_name' => array(
'name' => 'First Name',
'header' => 'First Name',
'width' => 1.0,
'table' => 'students.firstname' ),
'name' => array(
'name' => 'Full Student Name (last, first)',
'header' => 'Name',
'width' => 1.75,
'table' => "CONCAT(students.lastname, ', ', students.firstname)",
'table_sort'=> 'students.lastname' ),
'partner' => array(
'name' => 'Partner Name',
'header' => 'Partner',
'width' => 1.5,
'table' => "CONCAT(students2.lastname, ', ', students2.firstname)" ),
'bothnames' => array(
'name' => "Both Student Names",
'header' => 'Student(s)',
'width' => 3.0,
'table' => "CONCAT(students.firstname, ' ', students.lastname, IF(students2.lastname IS NULL,'', CONCAT(', ', students2.firstname, ' ', students2.lastname)))",
'table_sort' => 'students.lastnmae'),
'grade' => array(
'name' => 'Grade',
'header' => 'Grade',
'width' => 0.5,
'table' => 'students.grade'),
'gender' => array(
'name' => 'Gender',
'header' => 'Gender',
'width' => 0.5,
'table' => 'students.sex',
'value_map' =>array ('male' => 'Male', 'female' => 'Female')),
'title' => array(
'name' => 'Project Title',
'header' => 'Project Title',
'width' => 2.75,
'table' => 'projects.title' ),
'division' => array(
'name' => 'Project Division',
'header' => 'Division',
'width' => 3.0,
'table' => 'projectdivisions.division' ),
'div' => array(
'name' => 'Project Division Short Form' ,
'header' => 'Div',
'width' => 0.4,
'table' => 'projectdivisions.division_shortform' ),
'category' => array(
'name' => 'Project Category',
'header' => 'Category',
'width' => 1,
'table_sort' => 'projectcategories.id',
'table' => 'projectcategories.category' ),
'categorydivision' => array(
'name' => 'Project Category - Project Division',
'header' => 'Category/Division',
'width' => 3.5,
'table_sort' => 'projectcategories.id',
'table' => "CONCAT(projectcategories.category',' - ', projectdivisions.division)"),
'address' => array(
'name' => 'Student Address -- Street Address',
'header' => 'Address',
'width' => 2.0,
'table' => 'students.address'),
'city' => array(
'name' => 'Student Address -- City',
'header' => 'City',
'width' => 1.5,
'table' => 'students.city' ),
'province' => array(
'name' => 'Student Address -- Province',
'header' => 'Province',
'width' => 0.75,
'table' => 'students.province' ),
'postal' => array(
'name' => 'Student Address -- Postal Code',
'header' => 'Postal',
'width' => 0.75,
'table' => 'students.postalcode' ),
'school' => array(
'name' => 'School -- Name',
'header' => 'School Name',
'width' => 2.25,
'table' => 'schools.school' ),
'schooladdr' => array(
'name' => 'School -- Full Address',
'header' => 'School Address',
'width' => 3.0,
'table' => "CONCAT(schools.address, ', ', schools.city, ', ', schools.province_code, ', ', schools.postalcode)" ),
'teacher' => array(
'name' => 'School -- Teacher Name',
'header' => 'Teacher',
'width' => 1.5,
'table' => 'students.teachername' ),
'teacheremail' => array(
'name' => 'School -- Teacher Email',
'header' => 'Teacher Email',
'width' => 2.0,
'table' => 'students.teacheremail' ),
'school_phone' => array(
'name' => 'School -- Phone',
'header' => 'School Phone',
'width' => 1,
'table' => 'schools.phone' ),
'school_fax' => array(
'name' => 'School -- Fax',
'header' => 'School Fax',
'width' => 1,
'table' => 'schools.fax' ),
'paid' => array(
'name' => 'Paid',
'header' => 'Paid',
'width' => '0.4',
'table' => 'registrations.status',
'value_map' => array ('complete' => '', 'paymentpending' => 'No')),
'tshirt' => array(
'name' => 'T-Shirt Size',
'header' => 'T-Shirt',
'width' => 0.55,
'table' => 'students.tshirt',
'value_map' => array ('none' => '', 'small' => 'Small', 'medium' => 'Medium',
'large' => 'Large', 'xlarge' => 'X-Large')),
'awards' => array(
'name' => 'Awards (warning: duplicates student for multiple awards!)',
'header' => 'Award Name',
'width' => 4,
'table' => "CONCAT(IF(award_types.type='Other','Special',award_types.type),
' ', award_awards.name)",
'table_sort' => 'award_awards.order'),
'pn_awards' => array(
'name' => 'Project Num + Award (will be unique)',
'header' => 'Award Name',
'width' => 4,
'table' => "CONCAT(projects.projectnumber,' ', award_awards.name)",
'table_sort' => 'award_awards.order'),
'req_elec' => array(
'name' => 'If the project requires electricity',
'header' => 'Elec',
'width' => .5,
'table' => "projects.req_electricity",
'value_map' => array ('no' => '', 'yes' => 'Yes')),
'req_table' => array(
'name' => 'If the project requires a table',
'header' => 'Table',
'width' => .5,
'table' => "projects.req_table",
'value_map' => array ('no' => '', 'yes' => 'Yes')),
'req_special' => array(
'name' => 'Any special requirements the project has',
'header' => 'Special Requirements',
'width' => 3,
'table' => "projects.req_special"),
'emerg_name' => array(
'name' => 'Emergency Contact -- Name',
'header' => 'Emerg. Name',
'width' => 1.5,
'table' => "CONCAT(emergencycontact.firstname, ' ', emergencycontact.lastname)"),
'emerg_relation' => array(
'name' => 'Emergency Contact -- Relationship',
'header' => 'Emerg. Rlt',
'width' => 1,
'table' => "emergencycontact.relation"),
'emerg_phone' => array(
'name' => 'Emergency Contact -- Phone',
'header' => 'Emerg. Phone',
'width' => 1,
'table' => "CONCAT(emergencycontact.phone1, ' ', emergencycontact.phone2, ' ', emergencycontact.phone3, ' ', emergencycontact.phone4)"),
);
require_once('../lpdf.php');
require_once('../lcsv.php');
function report_students_gen($report)
{
global $config, $report_students_fields;
$fields = $report_students_fields;
//print_r($report);
$gen_mode = '';
$fieldname = array();
$thead = array();
$table['header']=array();
$table['widths']=array();
$table['dataalign']=array();
$table['option']=array();
if($report['option']['type']=='csv') {
$rep=new lcsv(i18n($report_name));
$gen_mode = 'table';
} else if($report['option']['type']=='label') {
/* Label */
$label_stock = $stock($report['option']['stock']);
$rep=new lpdf( i18n($config['fairname']),
i18n($report_name),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif");
$rep->newPage($label_stock['pw'], $label_stock['ph']);
$rep->setFontSize(11);
$rep->setLabelDimensions($label_stock['w'], $label_stock['h'],
$label_stock['xs'], $label_stock['ys']);
$gen_mode = 'label';
} else {
$rep=new lpdf( i18n($config['fairname']),
i18n($report['name']),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif");
$rep->newPage();
$rep->setFontSize(11);
$gen_mode = 'table';
if($report['option']['allow_multiline'] == 'yes')
$table['option']['allow_multiline'] = true;
}
$sel = array();
$x=0;
/* Select columns to display */
foreach($report['col'] as $f) {
$table['header'][] = i18n($fields[$f]['header']);
$table['widths'][] = $fields[$f]['width'];
$table['dataalign'][] = 'left';
$sel[] = "{$fields[$f]['table']} AS C$x";
$fieldname[$f] = "C$x";
$x++;
}
/* We also want to select any column groupings, but we won't display them */
$x=0;
foreach($report['group'] as $f) {
if(isset($fieldname[$f])) continue;
$sel[] = "{$fields[$f]['table']} AS G$x";
$fieldname[$f] = "G$x";
$x++;
}
$x=0;
foreach($report['sort'] as $f) {
if(isset($fieldname[$f])) continue;
$sel[] = "{$fields[$f]['table']} AS S$x";
$fieldname[$f] = "S$x";
$x++;
}
$x=0;
foreach($report['distinct'] as $f) {
if(isset($fieldname[$f])) continue;
$sel[] = "{$fields[$f]['table']} AS D$x";
$fieldname[$f] = "D$x";
$x++;
}
$sel = implode(",", $sel);
$order = array();
/* Setup the order: groups, then sort order */
foreach($report['group'] as $f) {
if(isset($fields[$f]['table_sort'])) {
$order[] = $fields[$f]['table_sort'];
} else {
$order[] = $fieldname[$f];//ields[$f]['table'];
}
}
foreach($report['sort'] as $f) {
if(isset($fields[$f]['table_sort'])) {
$order[] = $fields[$f]['table_sort'];
} else {
$order[] = $fieldname[$f];//$fields[$f]['table'];
}
}
$order = implode(",", $order);
$year = $config['FAIRYEAR'];
$group_query = array();
if(count($report['distinct'])) {
foreach($report['distinct'] as $f) {
$group_query[] = $fieldname[$f];
}
}
if(count($group_query)) {
$group_query = "GROUP BY ".implode(",", $group_query);
} else {
$group_query = "";
}
if(in_array('awards', $report['col']) || in_array('pn_awards', $report['col'])
|| in_array('awards', $report['group']) || in_array('pn_awards', $report['group']) ) {
/* This requires some extra gymnastics */
$awards_join = "LEFT JOIN winners ON(winners.projects_id = projects.id),award_prizes,award_awards,award_types";
$awards_where = " AND winners.awards_prizes_id=award_prizes.id
AND award_prizes.award_awards_id=award_awards.id
AND award_types.id=award_awards.award_types_id
AND winners.year=$year
AND award_awards.year=$year
AND award_prizes.year=$year
AND award_types.year=$year ";
} else {
$awards_join = '';
$awards_where = '';
}
if(in_array('bothnames', $report['col']) || in_array('partner', $report['col'])) {
$partner_join = "LEFT JOIN students AS students2
ON(students2.registrations_id=students.registrations_id
AND students2.id != students.id)";
} else {
$partner_join = '';
}
$q = " SELECT $sel
FROM
students $partner_join,
schools, projects $awards_join, projectdivisions,
projectcategories, registrations, emergencycontact
WHERE
schools.id=students.schools_id
AND projects.registrations_id=students.registrations_id
AND projectdivisions.id=projects.projectdivisions_id
AND projectcategories.id=projects.projectcategories_id
AND registrations.id=students.registrations_id
AND (registrations.status='complete' OR registrations.status='paymentpending')
AND emergencycontact.students_id=students.id
AND students.year='$year'
AND projects.year='$year'
AND registrations.year='$year'
AND projectcategories.year='$year'
AND projectdivisions.year='$year'
AND emergencycontact.year='$year'
$awards_where
$group_query
ORDER BY
$order";
//print("$q");
$r = mysql_query($q);
echo mysql_error();
$ncols = count($report['col']);
$n_groups = count($report['group']);
$last_group_data = array();
while($i = mysql_fetch_assoc($r)) {
if($n_groups > 0) {
$group_change = false;
for($x=0; $x<$n_groups; $x++) {
if($last_group_data["G$x"] != $i["G$x"]) {
$group_change = true;
}
$last_group_data["G$x"] = $i["G$x"];
}
if($group_change) {
/* Dump the last table */
if(count($table['data'])) {
// print_r($table);
$rep->addTable($table);
$rep->nextLine();
$table['data'] = array();
/* Start a new page AFTER a table is
* dumped, so the first page doesn't
* end up blank */
if($report['option']['group_new_page'] == 'yes') {
$rep->newPage();
} else {
$rep->hr();
$rep->vspace(-0.1);
}
}
/* Construct a new header */
$h = implode(" -- ", $last_group_data);
$rep->heading($h);
$rep->nextLine();
}
}
$data = array();
$x=0;
foreach($report['col'] as $c) {
if(is_array($fields[$c]['value_map'])) {
$v = $fields[$c]['value_map'][$i["C$x"]];
} else {
$v = $i["C$x"];
}
if($gen_mode == 'table') {
$data[] = $v;
} else if($gen_mode == 'label') {
$d = $label_data[$c];
/* Label text: x%, y%, width%, height%, text */
$this->addLabelText2($d['x'], $d['y'], $d['w'],
$d['h'], $v);
}
$x++;
}
$table['data'][] = $data;
}
if(count($table['data'])) {
$rep->addTable($table);
}
$rep->output();
}
?>

View File

@ -1,614 +0,0 @@
<?
/*
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("../common.inc.php");
require("../lpdf.php");
require("../lcsv.php");
auth_required('admin');
$fields = array();
$fields['pn'] = array( 'name' => 'Project Number',
'header' => '#',
'width' => 0.5,
'table' => 'projects.projectnumber' );
$fields['last_name'] = array( 'name' => 'Last Name',
'header' => 'Last Name',
'width' => 1.0,
'table' => 'students.lastname' );
$fields['first_name'] = array( 'name' => 'First Name',
'header' => 'First Name',
'width' => 1.0,
'table' => 'students.firstname' );
$fields['name'] = array( 'name' => 'Full Student Name (last, first)',
'header' => 'Name',
'width' => 1.5,
'table' => "CONCAT(students.lastname, ', ', students.firstname)",
'table_sort'=> 'students.lastname' );
$fields['partner'] = array( 'name' => 'Partner Name',
'header' => 'Partner',
'width' => 1.5,
'table' => "CONCAT(students2.lastname, ', ', students2.firstname)" );
$fields['bothnames'] = array( 'name' => "Both Student Names",
'header' => 'Student(s)',
'width' => 3.0,
'table' => "CONCAT(students.firstname, ' ', students.lastname, IF(students2.lastname IS NULL,'', CONCAT(', ', students2.firstname, ' ', students2.lastname)))",
'table_sort' => 'students.lastnmae');
$fields['grade'] = array( 'name' => 'Grade',
'header' => 'Grade',
'width' => 0.5,
'table' => 'students.grade');
$fields['gender'] = array( 'name' => 'Gender',
'header' => 'Gender',
'width' => 0.5,
'table' => 'students.sex',
'value_map' =>array ('male' => 'Male', 'female' => 'Female'));
$fields['title'] = array( 'name' => 'Project Title',
'header' => 'Project Title',
'width' => 3.0,
'table' => 'projects.title' );
$fields['division'] = array( 'name' => 'Project Division',
'header' => 'Division',
'width' => 3.0,
'table' => 'projectdivisions.division' );
$fields['div'] = array( 'name' => 'Project Division Short Form' ,
'header' => 'Div',
'width' => 0.4,
'table' => 'projectdivisions.division_shortform' );
$fields['category'] = array( 'name' => 'Project Category',
'header' => 'Category',
'width' => 1,
'table_sort' => 'projectcategories.id',
'table' => 'projectcategories.category' );
$fields['address'] = array( 'name' => 'Student Address -- Street Address',
'header' => 'Address',
'width' => 2.0,
'table' => 'students.address');
$fields['city'] = array( 'name' => 'Student Address -- City',
'header' => 'City',
'width' => 1.5,
'table' => 'students.city' );
$fields['province'] = array( 'name' => 'Student Address -- Province',
'header' => 'Province',
'width' => 0.75,
'table' => 'students.province' );
$fields['postal'] = array( 'name' => 'Student Address -- Postal Code',
'header' => 'Postal',
'width' => 0.75,
'table' => 'students.postalcode' );
$fields['school'] = array( 'name' => 'School -- Name',
'header' => 'School Name',
'width' => 2.0,
'table' => 'schools.school' );
$fields['teacher'] =array( 'name' => 'School -- Teacher Name',
'header' => 'Teacher',
'width' => 2.0,
'table' => 'students.teachername' );
$fields['school_phone'] =array( 'name' => 'School -- Phone',
'header' => 'School Phone',
'width' => 1.0,
'table' => 'schools.phone' );
$fields['school_fax'] =array( 'name' => 'School -- Fax',
'header' => 'School Fax',
'width' => 1.0,
'table' => 'schools.fax' );
$fields['paid'] = array( 'name' => 'Paid',
'header' => 'Paid',
'width' => '0.4',
'table' => 'registrations.status',
'value_map' =>array ('complete' => '', 'paymentpending' => 'No'));
$fields['tshirt'] = array( 'name' => 'T-Shirt Size',
'header' => 'T-Shirt',
'width' => 0.75,
'table' => 'students.tshirt' );
$fields['awards'] = array( 'name' => 'Awards (warning: duplicates student for multiple awards!)',
'header' => 'Award Name',
'width' => 4,
'table' => "CONCAT(IF(award_types.type='Other','Special',award_types.type), ' ', award_awards.name)",
'table_sort' => 'award_awards.order');
$fields['pn_awards'] = array( 'name' => 'Project Num + Award (will be unique)',
'header' => 'Award Name',
'width' => 4,
'table' => "CONCAT(projects.projectnumber,' ', award_awards.name)",
'table_sort' => 'award_awards.order');
$reports = array();
$reports[] = array( 'name' => "Student Name, Project Num and Title, Category sorted by Last Name",
'cols' => array('pn', 'name', 'title', 'category'),
'sort' => array('last_name'),
'group' => array()
);
$reports[] = array( 'name' => "Student Name, Project Num and Title, Category sorted by Project Number",
'cols' => array('pn', 'name', 'title', 'category'),
'sort' => array('pn'),
'group' => array()
);
$reports[] = array( 'name' => "Student Name, Project Num and Title, Category sorted by Last Name, grouped by Category",
'cols' => array('pn', 'name', 'title'),
'sort' => array('last_name'),
'group' => array('category')
);
$reports[] = array( 'name' => "Student Name, Project Num, School Name sorted by Last Name",
'cols' => array('pn', 'name', 'school'),
'sort' => array('last_name'),
'group' => array()
);
$reports[] = array( 'name' => "Student Name, Project Num and Name sorted by Last Name, grouped by School Name",
'cols' => array('pn', 'name', 'title', 'category'),
'sort' => array('last_name'),
'group' => array('school'),
);
$reports[] = array( 'name' => "Teacher, School Info sorted by Teacher Name",
'cols' => array('teacher', 'school','school_phone','school_fax'),
'sort' => array('teacher'),
'group' => array(),
'distinct' => array('teacher'),
);
$reports[] = array( 'name' => "Teacher, School Info sorted by Teacher Name grouped by School Name",
'cols' => array('teacher', 'school','school_phone','school_fax'),
'sort' => array('teacher'),
'group' => array('school'),
'distinct' => array('teacher'),
);
$reports[] = array( 'name' => "Project Checkin",
'cols' => array('paid', 'pn', 'title', 'name', 'partner','tshirt', 'div'),
'sort' => array('pn'),
'group' => array('category'),
'option' => array('group_new_page' => 'yes'),
);
$reports[] = array( 'name' => "Student Pairs, Project Name/Num Grouped by School",
'cols' => array('pn', 'name', 'partner','title'),
'sort' => array('pn'),
'group' => array('school'),
'distinct' => array('pn'),
);
$reports[] = array( 'name' => "Individual Students, Project Name/Num Grouped by School",
'cols' => array('pn', 'name', 'title'),
'sort' => array('pn'),
'group' => array('school'),
);
$reports[] = array( 'name' => "Individual Students, Project Num, TShirt, Grouped by School",
'cols' => array('pn', 'name', 'tshirt'),
'sort' => array('pn'),
'group' => array('school'),
);
$reports[] = array( 'name' => "Program Guide",
'cols' => array('pn', 'bothnames', 'title'),
'sort' => array('pn'),
'group' => array('school'),
'distinct' => array('pn'),
);
$reports[] = array( 'name' => "Project Name/Num, Grade Grouped by School",
'cols' => array('pn', 'title', 'grade'),
'sort' => array('pn'),
'group' => array('school'),
'distinct' => array('pn'),
);
$reports[] = array( 'name' => "Award List (Media)",
'cols' => array('pn', 'name', 'address','city','province','postal'),
'sort' => array('pn'),
'group' => array('awards'),
);
$options = array();
$options['type'] = array( 'desc' => 'Report Format',
'values' => array('pdf'=>'PDF', 'csv'=>'CSV')
);
$options['group_new_page'] = array( 'desc' => 'Start each new grouping on a new page',
'values' => array('no'=>'No', 'yes'=>'Yes')
);
$allow_fields = array_keys($fields);
function check_fields_array($a, $name)
{
global $allow_fields;
$n = array();
foreach($a as $f) {
if($f=='') continue;
if(!in_array($f, $allow_fields)) {
echo "$name [$f] not allowed.\n";
exit;
}
$n[] = $f;
}
return $n;
}
/* ---- Generator -----*/
$action= $_GET['action'];
if($action == 'gen') {
/* Scrub the data */
$col = check_fields_array($_GET['col'], "Column");
$group = check_fields_array($_GET['group'], "Group");
$sort = check_fields_array($_GET['sort'], "Sort");
$distinct = check_fields_array($_GET['distinct'], "Distinct");
$option = $_GET['option'];
//print_r($option);
foreach($option as $k=>$v) {
$keys = array_keys($options[$k]['values']);
if(!in_array($v, $keys)) {
echo "option $k [$v] not allowed.\n";
exit;
}
}
$fieldname = array();
$thead = array();
if($option['type']=="pdf") {
$rep=new lpdf( i18n($config['fairname']),
i18n($report_name),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif");
$rep->newPage();
$rep->setFontSize(11);
} else if($option['type']=="csv") {
$rep=new lcsv(i18n($report_name));
}
$table['header']=array();
$table['widths']=array();
$table['dataalign']=array();
$sel = array();
$x=0;
/* Select columns to display */
foreach($col as $f) {
$table['header'][] = i18n($fields[$f]['header']);
$table['widths'][] = $fields[$f]['width'];
$table['dataalign'][] = 'left';
$sel[] = "{$fields[$f]['table']} AS C$x";
$fieldname[$f] = "C$x";
$x++;
}
/* We also want to select any column groupings, but we won't display them */
$x=0;
foreach($group as $f) {
if(isset($fieldnmae[$f])) continue;
$sel[] = "{$fields[$f]['table']} AS G$x";
$fieldname[$f] = "G$x";
$x++;
}
$x=0;
foreach($distinct as $f) {
if(isset($fieldname[$f])) continue;
$sel[] = "{$fields[$f]['table']} AS D$x";
$fieldname[$f] = "D$x";
$x++;
}
$sel = implode(",", $sel);
$n_groups = count($group);
$last_group_data = array();
$order = array();
/* Setup the order: groups, then sort order */
foreach($group as $f) {
if(isset($fields[$f]['table_sort'])) {
$order[] = $fields[$f]['table_sort'];
} else {
$order[] = $fieldname[$f];//ields[$f]['table'];
}
}
foreach($sort as $f) {
if(isset($fields[$f]['table_sort'])) {
$order[] = $fields[$f]['table_sort'];
} else {
$order[] = $fieldname[$f];//$fields[$f]['table'];
}
}
$order = implode(",", $order);
$year = $config['FAIRYEAR'];
$group_query = "";
if(count($distinct)) {
$f = $distinct[0];
$group_query = "GROUP BY {$fieldname[$f]}";//$$fields[$f]['table']}";
}
if(in_array('awards', $col) || in_array('pn_awards', $col)
|| in_array('awards', $group) || in_array('pn_awards', $group) ) {
/* This requires some extra gymnastics */
$awards_join = "LEFT JOIN winners ON(winners.projects_id = projects.id),award_prizes,award_awards,award_types";
$awards_where = " AND winners.awards_prizes_id=award_prizes.id
AND award_prizes.award_awards_id=award_awards.id
AND award_types.id=award_awards.award_types_id
AND winners.year=$year
AND award_awards.year=$year
AND award_prizes.year=$year
AND award_types.year=$year ";
} else {
$awards_join = '';
$awards_where = '';
}
if(in_array('bothnames', $col) || in_array('partner', $col)) {
$partner_join = "LEFT JOIN students AS students2
ON(students2.registrations_id=students.registrations_id
AND students2.id != students.id)";
} else {
$partner_join = '';
}
$q = " SELECT $sel
FROM
students $partner_join,
schools, projects $awards_join, projectdivisions,
projectcategories, registrations
WHERE
schools.id=students.schools_id
AND projects.registrations_id=students.registrations_id
AND projectdivisions.id=projects.projectdivisions_id
AND projectcategories.id=projects.projectcategories_id
AND registrations.id=students.registrations_id
AND (registrations.status='complete' OR registrations.status='paymentpending')
AND students.year='$year'
AND projects.year='$year'
AND registrations.year='$year'
AND projectcategories.year='$year'
AND projectdivisions.year='$year'
$awards_where
$group_query
ORDER BY
$order";
//print("$q");
$r = mysql_query($q);
echo mysql_error();
$ncols = count($col);
while($i = mysql_fetch_assoc($r)) {
if($n_groups > 0) {
$group_change = false;
for($x=0; $x<$n_groups; $x++) {
if($last_group_data["G$x"] != $i["G$x"]) {
$group_change = true;
}
$last_group_data["G$x"] = $i["G$x"];
}
if($group_change) {
/* Dump the last table */
if(count($table['data'])) {
// print_r($table);
$rep->addTable($table);
$rep->nextLine();
$table['data'] = array();
/* Start a new page AFTER a table is
* dumped, so the first page doesn't
* end up blank */
if($option['group_new_page'] == 'yes') {
$rep->newPage();
} else {
$rep->hr();
$rep->vspace(-0.1);
}
}
/* Construct a new header */
$h = implode(", ", $last_group_data);
$rep->heading($h);
$rep->nextLine();
}
}
$data = array();
$x=0;
foreach($col as $c) {
if(is_array($fields[$c]['value_map'])) {
$v = $fields[$c]['value_map'][$i["C$x"]];
} else {
$v = $i["C$x"];
}
$data[] = $v;
$x++;
}
$table['data'][] = $data;
}
if(count($table['data'])) {
$rep->addTable($table);
}
$rep->output();
exit;
}
send_header("Administration - Reports > Student Report Generator");
?>
<script type="text/javascript">
function reportChange()
{
var index = document.forms.report.report.selectedIndex;
/* Clean out existing settings */
<?foreach($fields as $k=>$f) {
echo "document.getElementById('$k').checked=false;\n";
}?>
document.getElementById('group0').value = '';
// document.getElementById('group1').value = '';
// document.getElementById('group2').value = '';
document.getElementById('sort0').value = '';
document.getElementById('sort1').value = '';
document.getElementById('sort2').value = '';
document.getElementById('distinct0').value = '';
document.getElementById('type').value = 'pdf';
document.getElementById('group_new_page').value = 'no';
/* Load appropriate settings */
if(index == 0) {
/* Do nothing */
}
<?$x=1;
foreach($reports as $r) {
echo "else if(index == $x) {\n";
foreach($r['cols'] as $c) {
echo "document.getElementById('$c').checked=true;\n";
}
$i = 0;
foreach($r['sort'] as $c) {
echo "document.getElementById('sort$i').value='$c';\n";
}
$i = 0;
foreach($r['group'] as $c) {
echo "document.getElementById('group$i').value='$c';\n";
}
if(is_array($r['distinct'])) {
$i = 0;
foreach($r['distinct'] as $c) {
echo "document.getElementById('distinct$i').value='$c';\n";
}
}
if(is_array($r['option'])) {
foreach($r['option'] as $k=>$v) {
echo "document.getElementById('$k').value='$v';\n";
}
}
$x++;
echo "}\n";
}
?>
}
</script>
<?
/* ---- Setup ------ */
echo "<a href=\"reports.php\">&lt;&lt; ".i18n("Back to Reports")."</a><br />";
echo "<br />";
echo "<form method=\"get\" name=\"report\" action=\"reports_students.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"gen\">";
echo "<select name=\"report\" onchange=\"reportChange()\">";
echo "<option value=\"Custom::::::\">".i18n("Choose Report")."</option>\n";
$x=0;
foreach($reports as $r) {
echo "<option value=\"$x\">{$r['name']}</option>\n";
}
echo "</select>";
echo "<h4>Table Columns</h4>";
echo "<table>";
$x=0;
foreach($fields as $k=>$f) {
if($x%2==0) echo "<tr>";
echo "<td align=right><input type=\"checkbox\" type=\"text\" name=\"col[]\" id=\"$k\" value=\"$k\" /></td><td>{$f['name']}</td>";
if($x%2 == 1) echo "</tr>";
$x++;
}
echo "</table>";
echo "<h4>Grouping</h4>";
echo "Group By: ";
echo "<select name=\"group[]\" id=\"group0\">";
echo "<option value=\"\" />-- None --</option>";
foreach($fields as $k=>$f) {
echo "<option value=\"$k\" />{$f['name']}</option>";
}
echo "</select>";
echo "<h4>Sorting</h4>";
for($x=0;$x<3;$x++) {
echo "Sort By".($x + 1).": ";
echo "<select name=\"sort[]\" id=\"sort$x\">";
echo "<option value=\"\" />-- None --</option>";
foreach($fields as $k=>$f) {
echo "<option value=\"$k\" />{$f['name']}</option>";
}
echo "</select><br />";
}
echo "<h4>Distinct</h4>";
echo "Distinct Column: ";
echo "<select name=\"distinct[]\" id=\"distinct0\">";
echo "<option value=\"\" />-- None --</option>";
foreach($fields as $k=>$f) {
echo "<option value=\"$k\" />{$f['name']}</option>";
}
echo "</select>";
echo "<h4>Options</h4>";
foreach($options as $ok=>$o) {
echo "{$o['desc']}: <select name=\"option[$ok]\" id=\"$ok\">";
foreach($o['values'] as $k=>$v) {
echo "<option value=\"$k\">$v</option>";
}
echo "</select><br />\n";
}
echo "<br />";
echo "<input type=\"submit\" value=\"Generate Report\">";
echo "</form>";
send_footer();
?>

View File

@ -1 +1 @@
44
45

221
db/db.update.45.sql Normal file
View File

@ -0,0 +1,221 @@
-- --------------------------------------------------------
--
-- Table structure for table `reports`
--
CREATE TABLE `reports` ( `id` int(11) NOT NULL auto_increment, `name` varchar(128) NOT NULL default '', `desc` tinytext NOT NULL, `creator` varchar(128) NOT NULL default '', `type` enum('student','judge') NOT NULL default 'student', PRIMARY KEY (`id`)) TYPE=MyISAM;
--
-- Dumping data for table `reports`
--
INSERT INTO `reports` VALUES (1, 'Student+Project -- Sorted by Last Name', 'Student Name, Project Number and Title, Category, Division short form sorted by Last Name', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (2, 'Student+Project -- Sorted by Project Number', 'Student Name, Project Number and Title, Category sorted by Project Number', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (3, 'Student+Project -- Grouped by Category', 'Student Name, Project Number and Title sorted by Last Name, grouped by Category', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (4, 'Student+Project -- School Names sorted by Last Name', 'Student Name, Project Num, School Name sorted by Last Name', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (5, 'Student+Project -- Grouped by School sorted by Last Name', 'Student Name, Project Number and Name sorted by Last Name, grouped by School Name', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (6, 'Teacher -- Name and School Info sorted by Teacher Name', 'Teacher, School Info sorted by Teacher Name', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (8, 'Teacher -- Names and Contact for each Student by School', 'Student Name, Teacher Name, Teacher Email, School Phone and Fax grouped by School Name with Addresses', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (9, 'Check-in Lists', 'List of students and partners, project number and name, division, registration fees, tshirt size, sorted by project number, grouped by age category', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (10, 'Student+Project -- Student (and Partner) grouped by School', 'Student Pairs, Project Name/Num Grouped by School', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (11, 'Student+Project -- Grouped by School sorted by Project Number', 'Individual Students, Project Name/Num Grouped by School', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (12, 'Student -- T-Shirt List by School', 'Individual Students, Project Num, TShirt, Grouped by School', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (13, 'Media -- Program Guide', 'Project Number, Both student names, and Project Title, grouped by School', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (14, 'Projects -- Titles and Grades from each School', 'Project Name/Num, Grade Grouped by School', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (15, 'Media -- Award Winners List', 'Project Number, Student Name and Contact info, by each Award', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (16, 'Projects -- Logistical Display Requirements', 'Project Number, Students, Electricity, Table, and special needs', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (17, 'Emergency Contact Information', 'Emergency Contact Names, Relationship, and Phone Numbers for each student.', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (18, 'Student -- Grouped by Grade and Gender (YSF Stats)', 'A list of students grouped by Grade and Gender. A quick way to total up the info for the YSF regional stats page.', 'The Grant Brothers', 'student');
INSERT INTO `reports` VALUES (19, 'Student+Project -- Grouped by School, 1 per page', 'Both students names grouped by school, each school list begins on a new page.', 'The Grant Brothers', 'student');
-- --------------------------------------------------------
--
-- Table structure for table `reports_items`
--
CREATE TABLE `reports_items` ( `id` int(11) NOT NULL auto_increment, `reports_id` int(11) NOT NULL default '0', `field` varchar(64) NOT NULL default '', `type` enum('col','sort','group','distinct','option') NOT NULL default 'col', `value` varchar(64) NOT NULL default '', `order` int(11) NOT NULL default '0', PRIMARY KEY (`id`)) TYPE=MyISAM ;
--
-- Dumping data for table `reports_items`
--
INSERT INTO `reports_items` VALUES ('', 1, 'grade', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 1, 'div', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 1, 'last_name', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 2, 'category', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 2, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 2, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 3, 'div', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 4, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'last_name', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 3, 'category', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 4, 'grade', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 4, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 4, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 4, 'last_name', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 5, 'category', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 5, 'div', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 5, 'last_name', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 5, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'school_phone', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 6, 'school', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 6, 'teacher', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'teacher', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'teacher', 'distinct', '', 0);
INSERT INTO `reports_items` VALUES ('', 11, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 11, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 11, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 8, 'school_fax', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 8, 'school_phone', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 8, 'teacheremail', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 8, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 9, 'div', 'col', '', 6);
INSERT INTO `reports_items` VALUES ('', 9, 'tshirt', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 9, 'name', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 9, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 9, 'category', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 9, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'partner', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 10, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 10, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'pn', 'distinct', '', 0);
INSERT INTO `reports_items` VALUES ('', 2, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 11, 'div', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 11, 'category', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 11, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 11, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 12, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 12, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 12, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 12, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 13, 'bothnames', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 13, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 13, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 13, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 13, 'pn', 'distinct', '', 0);
INSERT INTO `reports_items` VALUES ('', 14, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 14, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 14, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 14, 'pn', 'distinct', '', 0);
INSERT INTO `reports_items` VALUES ('', 15, 'postal', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 15, 'province', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 15, 'city', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 15, 'address', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 15, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 15, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 15, 'awards', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 1, 'allow_multiline', 'option', 'yes', 2);
INSERT INTO `reports_items` VALUES ('', 1, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 1, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 1, 'category', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 1, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 3, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 9, 'partner', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 9, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 9, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 9, 'pn', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 9, 'group_new_page', 'option', 'yes', 1);
INSERT INTO `reports_items` VALUES ('', 5, 'grade', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 5, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 5, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 4, 'school', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 8, 'teacher', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 8, 'schooladdr', 'group', '', 1);
INSERT INTO `reports_items` VALUES ('', 8, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 11, 'grade', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 2, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 2, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 2, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 12, 'tshirt', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 12, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 8, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 12, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 12, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 8, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 8, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 8, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 15, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 15, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 15, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 15, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 13, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 13, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 13, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 13, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 14, 'title', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 14, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 14, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 14, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'req_special', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 16, 'req_table', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 16, 'req_elec', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 16, 'title', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 16, 'category', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'pn', 'distinct', '', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 16, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 16, 'allow_multiline', 'option', 'yes', 2);
INSERT INTO `reports_items` VALUES ('', 17, 'emerg_phone', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 17, 'emerg_relation', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 17, 'emerg_name', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 17, 'last_name', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 8, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 14, 'grade', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 17, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 17, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'school_fax', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 17, 'allow_multiline', 'option', 'yes', 2);
INSERT INTO `reports_items` VALUES ('', 17, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 17, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 6, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 6, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 9, 'paid', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 1, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 2, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 3, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 4, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 4, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'title', 'col', '', 3);
INSERT INTO `reports_items` VALUES ('', 10, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 10, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 10, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 5, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 5, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 5, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 5, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 11, 'title', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 11, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 11, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 18, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 18, 'name', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 18, 'school', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 18, 'grade', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 18, 'gender', 'group', '', 1);
INSERT INTO `reports_items` VALUES ('', 18, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 18, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 18, 'group_new_page', 'option', 'no', 1);
INSERT INTO `reports_items` VALUES ('', 18, 'allow_multiline', 'option', 'no', 2);
INSERT INTO `reports_items` VALUES ('', 3, 'grade', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 1, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 2, 'div', 'col', '', 4);
INSERT INTO `reports_items` VALUES ('', 2, 'grade', 'col', '', 5);
INSERT INTO `reports_items` VALUES ('', 19, 'pn', 'col', '', 0);
INSERT INTO `reports_items` VALUES ('', 19, 'title', 'col', '', 1);
INSERT INTO `reports_items` VALUES ('', 19, 'bothnames', 'col', '', 2);
INSERT INTO `reports_items` VALUES ('', 19, 'school', 'group', '', 0);
INSERT INTO `reports_items` VALUES ('', 19, 'pn', 'sort', '', 0);
INSERT INTO `reports_items` VALUES ('', 19, 'type', 'option', 'pdf', 0);
INSERT INTO `reports_items` VALUES ('', 19, 'group_new_page', 'option', 'yes', 1);
INSERT INTO `reports_items` VALUES ('', 19, 'allow_multiline', 'option', 'no', 2);