- 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_students.inc.php"); /* $report_students_fields */
require_once("reports_judges.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_awards.inc.php"); /* $report_students_fields */
require_once("reports_committees.inc.php"); /* $report_students_fields */
require_once('../lpdf.php'); require_once('../lpdf.php');
require_once('../lcsv.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 */ /* FIXME: put these in a databse */
$stock = array(); $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', $stock['5964'] = array('name' => 'Avery 5964, G&T 99763',
'page_width' => 8.5, 'page_width' => 8.5,
'page_height' => 11, 'page_height' => 11,
@ -77,7 +89,7 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
'y_spacing' => 0, 'y_spacing' => 0,
'rows' => 3, 'rows' => 3,
); );
$stock['nametag'] = array('name' => '4"x3" cards', $stock['nametag'] = array('name' => 'Cards 4"x3"',
'page_width' => 8.5, 'page_width' => 8.5,
'page_height' => 11, 'page_height' => 11,
'label_width' => 4, 'label_width' => 4,
@ -88,10 +100,11 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */
'rows' => 3, 'rows' => 3,
); );
$options['stock'] = array('desc' => "Paper Type",
'values' => array() );
/* Add more types to the report format */ /* 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) { foreach($stock as $n=>$v) {
$options['stock']['values'][$n] = $v['name']; $options['stock']['values'][$n] = $v['name'];
} }
@ -104,11 +117,14 @@ foreach($stock as $n=>$v) {
{ {
global $allow_options; global $allow_options;
global $report_students_fields, $report_judges_fields, $report_awards_fields; global $report_students_fields, $report_judges_fields, $report_awards_fields;
global $report_committees_fields;
switch($report['type']) { switch($report['type']) {
case 'student': $allow_fields = array_keys($report_students_fields); break; case 'student': $allow_fields = array_keys($report_students_fields); break;
case 'judge': $allow_fields = array_keys($report_judges_fields); break; case 'judge': $allow_fields = array_keys($report_judges_fields); break;
case 'award': $allow_fields = array_keys($report_awards_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 */ /* First delete all existing fields */
@ -127,7 +143,11 @@ foreach($stock as $n=>$v) {
$val = $v; $val = $v;
} else { } else {
$field = $v; $field = $v;
$val = ''; if($type == 'col') {
$val = $loc[$field]['text'];
} else {
$val = '';
}
} }
if($q != '') $q .= ','; if($q != '') $q .= ',';
$q .= "({$report['id']}, '$field', '$type', '$val', $x, $q .= "({$report['id']}, '$field', '$type', '$val', $x,
@ -187,22 +207,23 @@ foreach($stock as $n=>$v) {
case 'option': case 'option':
if(!in_array($f, $allow_options)) { if(!in_array($f, $allow_options)) {
print("Type[$type] Field[$f] not allowed.\n"); print("Type[$type] Field[$f] not allowed.\n");
exit; continue;
} }
$report['option'][$f] = $a['value']; $report['option'][$f] = $a['value'];
break; break;
case 'col': case 'col':
/* Get the coords, if they exist */ /* Get the coords, if they exist */
$loc = array(); $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]; foreach($loc_fields as $lf) $loc[$lf] = $a[$lf];
$loc['text'] = $loc['value'];
$report['loc'][$f] = $loc; $report['loc'][$f] = $loc;
/* Fall through */ /* Fall through */
default: default:
if(!in_array($f, $allow_fields)) { if(!in_array($f, $allow_fields)) {
print("Type[$type] Field[$f] not allowed.\n"); print("Type[$type] Field[$f] not allowed.\n");
exit; continue;
} }
$report[$t][] = $f; $report[$t][] = $f;
break; break;
@ -279,13 +300,14 @@ foreach($stock as $n=>$v) {
function report_gen($report) function report_gen($report)
{ {
global $config, $report_students_fields, $report_judges_fields, $report_awards_fields; global $config, $report_students_fields, $report_judges_fields, $report_awards_fields;
global $stock; global $stock, $report_committees_fields;
//print_r($report); //print_r($report);
switch($report['type']) { switch($report['type']) {
case 'student': $fields = $report_students_fields; break; case 'student': $fields = $report_students_fields; break;
case 'judge': $fields = $report_judges_fields; break; case 'judge': $fields = $report_judges_fields; break;
case 'award': $fields = $report_awards_fields; break; case 'award': $fields = $report_awards_fields; break;
case 'committee': $fields = $report_committees_fields; break;
} }
$gen_mode = ''; $gen_mode = '';
@ -405,6 +427,7 @@ foreach($stock as $n=>$v) {
case 'student': $q = report_students_fromwhere($report); break; case 'student': $q = report_students_fromwhere($report); break;
case 'judge': $q = report_judges_fromwhere($report); break; case 'judge': $q = report_judges_fromwhere($report); break;
case 'award': $q = report_awards_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"; $q = "SELECT $sel $q $group_query ORDER BY $order";
@ -479,6 +502,9 @@ foreach($stock as $n=>$v) {
if($d['face'] == 'bold') $opt[] = 'bold'; if($d['face'] == 'bold') $opt[] = 'bold';
$opt[] = $d['align']; $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'], $rep->addLabelText2($d['xp'], $d['yp'], $d['wp'],
$d['hp'], $d['lhp'], $v, $opt); $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_students.inc.php');
require_once('reports_judges.inc.php'); require_once('reports_judges.inc.php');
require_once('reports_awards.inc.php'); require_once('reports_awards.inc.php');
require_once('reports_committees.inc.php');
require_once('reports.inc.php'); require_once('reports.inc.php');
$fields = array(); $fields = array();
@ -154,12 +155,14 @@ function reportChange()
$val = floatval($val); $val = floatval($val);
} else if($ll == 'face') { } else if($ll == 'face') {
$val = ($val == 'bold') ? 'bold' : ''; $val = ($val == 'bold') ? 'bold' : '';
} else if($ll = 'align') { } else if($ll == 'align') {
$aligns = array('left', 'right', 'center'); $aligns = array('left', 'right', 'center');
if(!in_array($val, $aligns)) { if(!in_array($val, $aligns)) {
echo "Invalid alignment $val"; echo "Invalid alignment $val";
exit; exit;
} }
} else if($ll = 'text') {
$val = stripslashes($val);
} }
$ret[$c][$ll] = $val; $ret[$c][$ll] = $val;
} }
@ -167,6 +170,7 @@ function reportChange()
return $ret; return $ret;
} }
//print_r($_POST);
/* Decode the report */ /* Decode the report */
$report = array(); $report = array();
@ -219,6 +223,12 @@ function reportChange()
echo happy(i18n("Report Deleted")); echo happy(i18n("Report Deleted"));
} }
if($repaction == 'dupe') {
$report['id'] = 0;
$report['id'] = report_save($report);
echo happy(i18n("Report Duplicated"));
}
/* ---- Setup ------ */ /* ---- Setup ------ */
@ -231,6 +241,7 @@ function reportChange()
case 'student': $fields = $report_students_fields; break; case 'student': $fields = $report_students_fields; break;
case 'judge': $fields = $report_judges_fields; break; case 'judge': $fields = $report_judges_fields; break;
case 'award': $fields = $report_awards_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 />"; 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 "<td><textarea name=\"desc\" rows=\"3\" cols=\"60\">{$report['desc']}</textarea></td>";
echo "</tr>"; echo "</tr>";
echo "<tr><td>Type: </td>"; echo "<tr><td>Type: </td>";
echo "<td><select name=\"type\">"; echo "<td>";
$sel = ($report['type'] == 'student') ? 'selected=\"selected\"' : ''; selector('type', array('student' => 'Student Report', 'judge' => 'Judge Report',
echo "<option value=\"student\" $sel>Student Report</option>"; 'award' => 'Award Report', 'committee' => 'Committee Member Report'),
$sel = ($report['type'] == 'judge') ? 'selected=\"selected\"' : ''; $report['type']);
echo "<option value=\"judge\" $sel>Judge Report</option>";
$sel = ($report['type'] == 'award') ? 'selected=\"selected\"' : ''; echo "</td>";
echo "<option value=\"award\" $sel>Award Report</option>";
echo "</select></td>";
echo "</tr></table>"; echo "</tr></table>";
echo "<h4>Report Data</h4>"; echo "<h4>Report Data</h4>";
@ -322,22 +331,32 @@ function reportChange()
echo 'Align'; echo 'Align';
selector("loc[$f][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'), selector("loc[$f][align]", array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
$report['loc'][$f]['align']); $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++; $x++;
} }
for(;$x<$n_columns;$x++) { for(;$x<$n_columns;$x++) {
echo "<tr><td align=\"right\">Loc ".($x+1).": </td>"; echo "<tr><td align=\"right\">Loc ".($x+1).": </td>";
echo "<td>"; echo "<td>";
echo i18n('Define data for the Column first');
/*
foreach($locs as $k=>$v) { 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='; echo 'Face=';
selector("loc[$f][face]", selector("new$x[face]",
array('' => '', 'bold' => 'Bold'), array('' => '', 'bold' => 'Bold'),
''); '');
echo 'Align'; echo 'Align';
selector("loc[$f][align]", selector("new$x[align]",
array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'), array('center' => 'Center', 'left' => 'Left', 'right' => 'Right'),
'center'); 'center');
echo "<input type=\"text\" size=\"8\" name=\"new$x[text]\" value=\"\">";
*/
echo "</td></tr>"; echo "</td></tr>";
} }
} }
@ -378,6 +397,8 @@ function reportChange()
$sel = ($repaction_save == 'try') ? "selected=\"selected\"" : ''; $sel = ($repaction_save == 'try') ? "selected=\"selected\"" : '';
echo " <option value=\"try\" $sel>Try this report</option>"; echo " <option value=\"try\" $sel>Try this report</option>";
echo " <option value=\"\" ></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 " <option value=\"del\" >Delete this report</option>";
echo "</select>"; echo "</select>";
echo "<input type=\"submit\" value=\"Go\">"; echo "<input type=\"submit\" value=\"Go\">";

View File

@ -90,31 +90,41 @@ $report_judges_fields = array(
'width' => 1.25, 'width' => 1.25,
'table' => "CONCAT(judges.phonework, ' ', judges.phoneworkext)"), 'table' => "CONCAT(judges.phonework, ' ', judges.phoneworkext)"),
'organization' => array(
'name' => 'Judges -- Organization',
'header' => 'Organization',
'width' => 2,
'table' => 'judges.organization'),
'languages' => array( 'languages' => array(
'name' => 'Judges -- Languages (REQUIRES MySQL 5.0)', 'name' => 'Judges -- Languages (REQUIRES MySQL 5.0)',
'header' => 'Lang', 'header' => 'Lang',
'width' => 0.75, 'width' => 0.75,
'table' => "GROUP_CONCAT(judges_languages.languages_lang ORDER BY judges_languages.languages_lang SEPARATOR ' ')", '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( 'captain' => array(
'name' => 'Judge Team -- Captain?', 'name' => 'Judge Team -- Captain?',
'header' => 'Cptn', 'header' => 'Cptn',
'width' => 0.5, 'width' => 0.5,
'table' => 'judges_teams_link.captain', '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( 'team' => array(
'name' => 'Judge Team -- Name', 'name' => 'Judge Team -- Name',
'header' => 'Team Name', 'header' => 'Team Name',
'width' => 3.0, 'width' => 3.0,
'table' => 'judges_teams.name'), 'table' => 'judges_teams.name',
'select_component' => array('teams')),
'teamnum' => array( 'teamnum' => array(
'name' => 'Judge Team -- Team Number', 'name' => 'Judge Team -- Team Number',
'header' => 'Team', 'header' => 'Team',
'width' => 0.5, 'width' => 0.5,
'table' => 'judges_teams.num'), 'table' => 'judges_teams.num',
'select_component' => array('teams')),
'complete' => array( 'complete' => array(
'name' => 'Judge -- Registration Complete', 'name' => 'Judge -- Registration Complete',
@ -122,6 +132,12 @@ $report_judges_fields = array(
'width' => 0.5, 'width' => 0.5,
'table' => 'judges.complete', 'table' => 'judges.complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')), '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; $fields = $report_judges_fields;
$year = $report['year']; $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_from = '';
$languages_where = ''; $languages_where = '';
if(in_array('languages', $report['col'])) { if(in_array('languages', $components)) {
$languages_from = ', judges_languages'; $languages_from = ', judges_languages';
$languages_where = 'AND judges_languages.judges_id=judges.id'; $languages_where = 'AND judges_languages.judges_id=judges.id';
} }
$teams_from = '';
/* $teams_where = '';
$awards_join = ''; if(in_array('teams', $components)) {
$awards_where = ''; $teams_from = ",judges_teams_link, judges_teams";
$teams_where = "AND judges_teams_link.judges_id=judges.id
if(in_array('awards', $report['col']) || in_array('pn_awards', $report['col']) AND judges_teams_link.year='$year'
|| in_array('awards', $report['group']) || in_array('pn_awards', $report['group']) ) { AND judges_teams.id=judges_teams_link.judges_teams_id
/* This requires some extra gymnastics AND judges_teams.year='$year'";
$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' ";
} }
$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 $q = " FROM
judges, judges_years, judges_teams_link, judges_teams judges, judges_years
$teams_from
$languages_from $languages_from
WHERE WHERE
judges_years.judges_id = judges.id judges_years.judges_id = judges.id
AND judges_years.year='$year' AND judges_years.year='$year'
AND judges_teams_link.judges_id=judges.id $teams_where
AND judges_teams_link.year='$year'
AND judges_teams.id=judges_teams_link.judges_teams_id
AND judges_teams.year='$year'
$languages_where $languages_where
"; ";

View File

@ -178,6 +178,42 @@ $report_students_fields = array(
'width' => 1, 'width' => 1,
'table' => 'schools.fax' ), '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( 'paid' => array(
'name' => 'Paid', 'name' => 'Paid',
'header' => 'Paid', 'header' => 'Paid',
@ -246,6 +282,19 @@ $report_students_fields = array(
'width' => 1, 'width' => 1,
'table' => "CONCAT(emergencycontact.phone1, ' ', emergencycontact.phone2, ' ', emergencycontact.phone3, ' ', emergencycontact.phone4)"), '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'),
); );