- Add options for nametags to be generated

- Add committee member generator
- It is now possible to generate ALL nametags the old system could generate
  (needs a DB update before that happens... actually, the report generator
  isn't as stable as I hoped.. I'll probably just nuke the report tables the
  next upgrade and recreate them all.. I'm probably the only one who has tried
  generating a custom report. :)
This commit is contained in:
dave 2007-03-20 06:24:18 +00:00
parent 18d2bfa0d3
commit 77eee9dcdd
5 changed files with 266 additions and 54 deletions

View File

@ -24,6 +24,7 @@
require_once("reports_students.inc.php"); /* $report_students_fields */
require_once("reports_judges.inc.php"); /* $report_students_fields */
require_once("reports_awards.inc.php"); /* $report_students_fields */
require_once("reports_committees.inc.php"); /* $report_students_fields */
require_once('../lpdf.php');
require_once('../lcsv.php');
@ -67,6 +68,17 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
/* FIXME: put these in a databse */
$stock = array();
$stock['fullpage'] = array('name' => 'Letter 8.5 x 11',
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 8.5,
'x_spacing' => 0,
'cols' => 1,
'label_height' => 11,
'y_spacing' => 0,
'rows' => 1,
);
$stock['5964'] = array('name' => 'Avery 5964, G&T 99763',
'page_width' => 8.5,
'page_height' => 11,
@ -77,7 +89,7 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
'y_spacing' => 0,
'rows' => 3,
);
$stock['nametag'] = array('name' => '4"x3" cards',
$stock['nametag'] = array('name' => 'Cards 4"x3"',
'page_width' => 8.5,
'page_height' => 11,
'label_width' => 4,
@ -88,10 +100,11 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
'rows' => 3,
);
$options['stock'] = array('desc' => "Paper Type",
'values' => array() );
/* Add more types to the report format */
$options['stock'] = array('desc' => "Paper Type",
'values' => array('letter' => 'Letter 8.5 x 11') );
foreach($stock as $n=>$v) {
$options['stock']['values'][$n] = $v['name'];
}
@ -104,11 +117,14 @@ foreach($stock as $n=>$v) {
{
global $allow_options;
global $report_students_fields, $report_judges_fields, $report_awards_fields;
global $report_committees_fields;
switch($report['type']) {
case 'student': $allow_fields = array_keys($report_students_fields); break;
case 'judge': $allow_fields = array_keys($report_judges_fields); break;
case 'award': $allow_fields = array_keys($report_awards_fields); break;
case 'committee':$allow_fields = array_keys($report_committees_fields); break;
}
/* First delete all existing fields */
@ -127,7 +143,11 @@ foreach($stock as $n=>$v) {
$val = $v;
} else {
$field = $v;
$val = '';
if($type == 'col') {
$val = $loc[$field]['text'];
} else {
$val = '';
}
}
if($q != '') $q .= ',';
$q .= "({$report['id']}, '$field', '$type', '$val', $x,
@ -187,22 +207,23 @@ foreach($stock as $n=>$v) {
case 'option':
if(!in_array($f, $allow_options)) {
print("Type[$type] Field[$f] not allowed.\n");
exit;
continue;
}
$report['option'][$f] = $a['value'];
break;
case 'col':
/* Get the coords, if they exist */
$loc = array();
$loc_fields = array('xp', 'yp', 'wp', 'hp', 'lhp', 'face', 'align');
$loc_fields = array('xp', 'yp', 'wp', 'hp', 'lhp', 'face', 'align', 'value');
foreach($loc_fields as $lf) $loc[$lf] = $a[$lf];
$loc['text'] = $loc['value'];
$report['loc'][$f] = $loc;
/* Fall through */
default:
if(!in_array($f, $allow_fields)) {
print("Type[$type] Field[$f] not allowed.\n");
exit;
continue;
}
$report[$t][] = $f;
break;
@ -279,13 +300,14 @@ foreach($stock as $n=>$v) {
function report_gen($report)
{
global $config, $report_students_fields, $report_judges_fields, $report_awards_fields;
global $stock;
global $stock, $report_committees_fields;
//print_r($report);
switch($report['type']) {
case 'student': $fields = $report_students_fields; break;
case 'judge': $fields = $report_judges_fields; break;
case 'award': $fields = $report_awards_fields; break;
case 'committee': $fields = $report_committees_fields; break;
}
$gen_mode = '';
@ -405,6 +427,7 @@ foreach($stock as $n=>$v) {
case 'student': $q = report_students_fromwhere($report); break;
case 'judge': $q = report_judges_fromwhere($report); break;
case 'award': $q = report_awards_fromwhere($report); break;
case 'committee': $q = report_committees_fromwhere($report); break;
}
$q = "SELECT $sel $q $group_query ORDER BY $order";
@ -479,6 +502,9 @@ foreach($stock as $n=>$v) {
if($d['face'] == 'bold') $opt[] = 'bold';
$opt[] = $d['align'];
/* Special column, override result with static text */
if($c == 'static_text') $v = $d['text'];
$rep->addLabelText2($d['xp'], $d['yp'], $d['wp'],
$d['hp'], $d['lhp'], $v, $opt);
}

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) 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_committees_fields = array(
'name' => array(
'name' => 'Committee -- Full Name ',
'header' => 'Name',
'width' => 1.75,
'table' => 'committees_members.name'),
'email' => array(
'name' => 'Committee -- Email',
'header' => 'Email',
'width' => 2.0,
'table' => 'committees_members.email'),
'phone_home' => array(
'name' => 'Committees -- Phone (Home)',
'header' => 'Phone(Home)',
'width' => 1,
'table' => 'committees_members.phonehome'),
'phone_work' => array(
'name' => 'Committees -- Phone (Work)',
'header' => 'Phone(Work)',
'width' => 1.25,
'table' => 'committees_members.phonework'),
'phone_cel' => array(
'name' => 'Committees -- Phone (Cel)',
'header' => 'Phone(Cel)',
'width' => 1,
'table' => 'committees_members.phonecel'),
'organization' => array(
'name' => 'Committees -- Organization',
'header' => 'Organization',
'width' => 2,
'table' => 'committees_members.organization'),
'static_text' => array(
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 0.1,
'table' => "CONCAT(' ')"),
);
function report_committees_fromwhere($report)
{
global $config, $report_committees_fields;
$fields = $report_committees_fields;
$year = $report['year'];
/*
$components = array();
foreach($report['col'] as $c) {
if(!is_array($fields[$c]['select_component'])) continue;
$components = array_merge($components, $fields[$c]['select_component']);
}
$languages_from = '';
$languages_where = '';
if(in_array('languages', $components)) {
$languages_from = ', committees_languages';
$languages_where = 'AND committees_languages.committees_id=committees_members.id';
}
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
$teams_from = ",committees_teams_link, committees_teams";
$teams_where = "AND committees_teams_link.committees_id=committees_members.id
AND committees_teams_link.year='$year'
AND committees_teams.id=committees_teams_link.committees_teams_id
AND committees_teams.year='$year'";
}
*/
$q = " FROM
committees_members
WHERE
1
";
return $q;
}
?>

View File

@ -28,6 +28,7 @@
require_once('reports_students.inc.php');
require_once('reports_judges.inc.php');
require_once('reports_awards.inc.php');
require_once('reports_committees.inc.php');
require_once('reports.inc.php');
$fields = array();
@ -154,12 +155,14 @@ function reportChange()
$val = floatval($val);
} else if($ll == 'face') {
$val = ($val == 'bold') ? 'bold' : '';
} else if($ll = 'align') {
} else if($ll == 'align') {
$aligns = array('left', 'right', 'center');
if(!in_array($val, $aligns)) {
echo "Invalid alignment $val";
exit;
}
} else if($ll = 'text') {
$val = stripslashes($val);
}
$ret[$c][$ll] = $val;
}
@ -167,6 +170,7 @@ function reportChange()
return $ret;
}
//print_r($_POST);
/* Decode the report */
$report = array();
@ -219,6 +223,12 @@ function reportChange()
echo happy(i18n("Report Deleted"));
}
if($repaction == 'dupe') {
$report['id'] = 0;
$report['id'] = report_save($report);
echo happy(i18n("Report Duplicated"));
}
/* ---- Setup ------ */
@ -231,6 +241,7 @@ function reportChange()
case 'student': $fields = $report_students_fields; break;
case 'judge': $fields = $report_judges_fields; break;
case 'award': $fields = $report_awards_fields; break;
case 'committee': $fields = $report_committees_fields; break;
}
echo "<a href=\"reports.php\">&lt;&lt; ".i18n("Back to Reports")."</a><br />";
@ -268,14 +279,12 @@ function reportChange()
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\">";
$sel = ($report['type'] == 'student') ? 'selected=\"selected\"' : '';
echo "<option value=\"student\" $sel>Student Report</option>";
$sel = ($report['type'] == 'judge') ? 'selected=\"selected\"' : '';
echo "<option value=\"judge\" $sel>Judge Report</option>";
$sel = ($report['type'] == 'award') ? 'selected=\"selected\"' : '';
echo "<option value=\"award\" $sel>Award Report</option>";
echo "</select></td>";
echo "<td>";
selector('type', array('student' => 'Student Report', 'judge' => 'Judge Report',
'award' => 'Award Report', 'committee' => 'Committee Member Report'),
$report['type']);
echo "</td>";
echo "</tr></table>";
echo "<h4>Report Data</h4>";
@ -322,22 +331,32 @@ function reportChange()
echo 'Align';
selector("loc[$f][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
$report['loc'][$f]['align']);
if($f == 'static_text') {
echo "<input type=\"text\" size=\"8\" name=\"loc[$f][text]\" value=\"{$report['loc'][$f]['text']}\">";
} else {
echo "<input type=\"hidden\" name=\"loc[$f][text]\" value=\"\">";
}
$x++;
}
for(;$x<$n_columns;$x++) {
echo "<tr><td align=\"right\">Loc ".($x+1).": </td>";
echo "<td>";
echo i18n('Define data for the Column first');
/*
foreach($locs as $k=>$v) {
echo "$k=<input type=\"text\" size=\"3\" name=\"loc[$x][$v]\" value=\"\">";
echo "$k=<input type=\"text\" size=\"3\" name=\"new$x[$v]\" value=\"\">";
}
echo 'Face=';
selector("loc[$f][face]",
selector("new$x[face]",
array('' => '', 'bold' => 'Bold'),
'');
echo 'Align';
selector("loc[$f][align]",
selector("new$x[align]",
array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
'center');
echo "<input type=\"text\" size=\"8\" name=\"new$x[text]\" value=\"\">";
*/
echo "</td></tr>";
}
}
@ -378,6 +397,8 @@ function reportChange()
$sel = ($repaction_save == 'try') ? "selected=\"selected\"" : '';
echo " <option value=\"try\" $sel>Try this report</option>";
echo " <option value=\"\" ></option>";
echo " <option value=\"dupe\" >Save as a new report(duplicate)</option>";
echo " <option value=\"\" ></option>";
echo " <option value=\"del\" >Delete this report</option>";
echo "</select>";
echo "<input type=\"submit\" value=\"Go\">";

View File

@ -90,31 +90,41 @@ $report_judges_fields = array(
'width' => 1.25,
'table' => "CONCAT(judges.phonework, ' ', judges.phoneworkext)"),
'organization' => array(
'name' => 'Judges -- Organization',
'header' => 'Organization',
'width' => 2,
'table' => 'judges.organization'),
'languages' => array(
'name' => 'Judges -- Languages (REQUIRES MySQL 5.0)',
'header' => 'Lang',
'width' => 0.75,
'table' => "GROUP_CONCAT(judges_languages.languages_lang ORDER BY judges_languages.languages_lang SEPARATOR ' ')",
'group_by' => array('judges.id')),
'group_by' => array('judges.id'),
'select_component' => array('languages')),
'captain' => array(
'name' => 'Judge Team -- Captain?',
'header' => 'Cptn',
'width' => 0.5,
'table' => 'judges_teams_link.captain',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'value_map' => array ('no' => 'No', 'yes' => 'Yes'),
'select_component' => array('teams')),
'team' => array(
'name' => 'Judge Team -- Name',
'header' => 'Team Name',
'width' => 3.0,
'table' => 'judges_teams.name'),
'table' => 'judges_teams.name',
'select_component' => array('teams')),
'teamnum' => array(
'name' => 'Judge Team -- Team Number',
'header' => 'Team',
'width' => 0.5,
'table' => 'judges_teams.num'),
'table' => 'judges_teams.num',
'select_component' => array('teams')),
'complete' => array(
'name' => 'Judge -- Registration Complete',
@ -122,6 +132,12 @@ $report_judges_fields = array(
'width' => 0.5,
'table' => 'judges.complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'static_text' => array(
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 0.1,
'table' => "CONCAT(' ')"),
);
@ -132,48 +148,38 @@ $report_judges_fields = array(
$fields = $report_judges_fields;
$year = $report['year'];
$components = array();
foreach($report['col'] as $c) {
if(!is_array($fields[$c]['select_component'])) continue;
$components = array_merge($components, $fields[$c]['select_component']);
}
$languages_from = '';
$languages_where = '';
if(in_array('languages', $report['col'])) {
if(in_array('languages', $components)) {
$languages_from = ', judges_languages';
$languages_where = 'AND judges_languages.judges_id=judges.id';
}
/*
$awards_join = '';
$awards_where = '';
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' ";
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
$teams_from = ",judges_teams_link, judges_teams";
$teams_where = "AND judges_teams_link.judges_id=judges.id
AND judges_teams_link.year='$year'
AND judges_teams.id=judges_teams_link.judges_teams_id
AND judges_teams.year='$year'";
}
$partner_join = '';
if(in_array('bothnames', $report['col']) || in_array('partner', $report['col'])) {
$partner_join = "LEFT JOIN judges AS judges2
ON(judges2.registrations_id=judges.registrations_id
AND judges2.id != judges.id)";
}
*/
$q = " FROM
judges, judges_years, judges_teams_link, judges_teams
judges, judges_years
$teams_from
$languages_from
WHERE
judges_years.judges_id = judges.id
AND judges_years.year='$year'
AND judges_teams_link.judges_id=judges.id
AND judges_teams_link.year='$year'
AND judges_teams.id=judges_teams_link.judges_teams_id
AND judges_teams.year='$year'
$teams_where
$languages_where
";

View File

@ -178,6 +178,42 @@ $report_students_fields = array(
'width' => 1,
'table' => 'schools.fax' ),
'school_address' => array(
'name' => 'School Address -- Street Address',
'header' => 'Address',
'width' => 2.0,
'table' => 'schools.address'),
'school_city' => array(
'name' => 'School Address -- City',
'header' => 'City',
'width' => 1.5,
'table' => 'schools.city' ),
'school_province' => array(
'name' => 'School Address -- Province',
'header' => 'Province',
'width' => 0.75,
'table' => 'schools.province_code' ),
'school_city_prov' => array(
'name' => 'School Address -- City, Province (for mailing)',
'header' => 'City',
'width' => 1.5,
'table' => "CONCAT(schools.city, ', ', schools.province_code)" ),
'school_postal' => array(
'name' => 'School Address -- Postal Code',
'header' => 'Postal',
'width' => 0.75,
'table' => 'schools.postalcode' ),
'paid' => array(
'name' => 'Paid',
'header' => 'Paid',
@ -246,6 +282,19 @@ $report_students_fields = array(
'width' => 1,
'table' => "CONCAT(emergencycontact.phone1, ' ', emergencycontact.phone2, ' ', emergencycontact.phone3, ' ', emergencycontact.phone4)"),
'static_text' => array (
'name' => 'Static Text (useful for labels)',
'header' => '',
'width' => 0.1,
'table' => "CONCAT(' ')"),
'gvrsf_tn' => array (
'name' => 'GVRSF Project Number (Table Number)',
'header' => '#',
'width' => 0.6,
'table' => "CAST(projects.projectnumber AS UNSIGNED) AS GVRSFTBL, CONCAT(projectcategories.category_shortform, ' ', projects.projectnumber, ' ', projectdivisions.division_shortform)",
'table_sort' => 'GVRSFTBL'),
);