From 77eee9dcddbdd88b56290a34c4e9041163640446 Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 20 Mar 2007 06:24:18 +0000 Subject: [PATCH] - 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. :) --- admin/reports.inc.php | 42 +++++++++--- admin/reports_committees.inc.php | 110 +++++++++++++++++++++++++++++++ admin/reports_editor.php | 45 +++++++++---- admin/reports_judges.inc.php | 74 +++++++++++---------- admin/reports_students.inc.php | 49 ++++++++++++++ 5 files changed, 266 insertions(+), 54 deletions(-) create mode 100644 admin/reports_committees.inc.php diff --git a/admin/reports.inc.php b/admin/reports.inc.php index 63f494e..f0de589 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -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); } diff --git a/admin/reports_committees.inc.php b/admin/reports_committees.inc.php new file mode 100644 index 0000000..e87d71a --- /dev/null +++ b/admin/reports_committees.inc.php @@ -0,0 +1,110 @@ + + Copyright (C) 2005 James Grant + + 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; +} + +?> diff --git a/admin/reports_editor.php b/admin/reports_editor.php index 995d8c0..f80ed91 100644 --- a/admin/reports_editor.php +++ b/admin/reports_editor.php @@ -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 "<< ".i18n("Back to Reports")."
"; @@ -268,14 +279,12 @@ function reportChange() echo ""; echo ""; echo "Type: "; - echo ""; + echo ""; + selector('type', array('student' => 'Student Report', 'judge' => 'Judge Report', + 'award' => 'Award Report', 'committee' => 'Committee Member Report'), + $report['type']); + + echo ""; echo ""; echo "

Report Data

"; @@ -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 ""; + } else { + echo ""; + } + $x++; } for(;$x<$n_columns;$x++) { echo "Loc ".($x+1).": "; echo ""; + echo i18n('Define data for the Column first'); + /* foreach($locs as $k=>$v) { - echo "$k="; + echo "$k="; } 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 ""; + */ echo ""; } } @@ -378,6 +397,8 @@ function reportChange() $sel = ($repaction_save == 'try') ? "selected=\"selected\"" : ''; echo " "; echo " "; + echo " "; + echo " "; echo " "; echo ""; echo ""; diff --git a/admin/reports_judges.inc.php b/admin/reports_judges.inc.php index 4508bd6..be12170 100644 --- a/admin/reports_judges.inc.php +++ b/admin/reports_judges.inc.php @@ -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 "; diff --git a/admin/reports_students.inc.php b/admin/reports_students.inc.php index 83daf6f..d9c76de 100644 --- a/admin/reports_students.inc.php +++ b/admin/reports_students.inc.php @@ -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'), + );