2007-03-18 19:59:02 +00:00
|
|
|
<?
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2009-02-02 06:31:39 +00:00
|
|
|
|
|
|
|
/* Take the language array in users_judge, unserialize it, and join it
|
|
|
|
* with a space */
|
|
|
|
function report_judges_languages(&$report, $text)
|
|
|
|
{
|
|
|
|
$l = unserialize($text);
|
|
|
|
return join(' ', $l);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-26 01:54:18 +00:00
|
|
|
/* Components: languages, teams */
|
|
|
|
|
2007-03-18 19:59:02 +00:00
|
|
|
$report_judges_fields = array(
|
|
|
|
'last_name' => array(
|
2007-03-18 21:48:36 +00:00
|
|
|
'name' => 'Judge -- Last Name',
|
|
|
|
'header' => 'Last Name',
|
2007-03-18 19:59:02 +00:00
|
|
|
'width' => 1.0,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.lastname' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'first_name' => array(
|
2007-03-18 21:48:36 +00:00
|
|
|
'name' => 'Judge -- First Name',
|
|
|
|
'header' => 'First Name',
|
2007-03-18 19:59:02 +00:00
|
|
|
'width' => 1.0,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.firstname' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'name' => array(
|
|
|
|
'name' => 'Judge -- Full Name (last, first)',
|
|
|
|
'header' => 'Name',
|
|
|
|
'width' => 1.75,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => "CONCAT(users.lastname, ', ', users.firstname)",
|
|
|
|
'table_sort'=> 'users.lastname' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'namefl' => array(
|
|
|
|
'name' => 'Judge -- Full Name (first last)',
|
|
|
|
'header' => 'Name',
|
|
|
|
'width' => 1.75,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => "CONCAT(users.firstname, ' ', users.lastname)",
|
|
|
|
'table_sort'=> 'users.lastname' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'email' => array(
|
|
|
|
'name' => 'Judge -- Email',
|
|
|
|
'header' => 'Email',
|
2007-03-18 21:48:36 +00:00
|
|
|
'width' => 2.0,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.email'),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'address' => array(
|
|
|
|
'name' => 'Judge -- Address Street',
|
|
|
|
'header' => 'Address',
|
|
|
|
'width' => 2.0,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => "CONCAT(users.address, ' ', users.address2)"),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'city' => array(
|
|
|
|
'name' => 'Judge -- Address City',
|
|
|
|
'header' => 'City',
|
|
|
|
'width' => 1.5,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.city' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'province' => array(
|
2008-07-16 17:23:53 +00:00
|
|
|
'name' => 'Judge -- Address '.$config['provincestate'],
|
|
|
|
'header' => $config['provincestate'],
|
2007-03-18 19:59:02 +00:00
|
|
|
'width' => 0.75,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.province' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'postal' => array(
|
2008-07-16 17:23:53 +00:00
|
|
|
'name' => 'Judge -- Address '.$config['postalzip'],
|
|
|
|
'header' => $config['postalzip'],
|
2007-03-18 19:59:02 +00:00
|
|
|
'width' => 0.75,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.postalcode' ),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'phone_home' => array(
|
2007-12-22 22:16:12 +00:00
|
|
|
'name' => 'Judge -- Phone (Home)',
|
2007-03-18 19:59:02 +00:00
|
|
|
'header' => 'Phone(Home)',
|
|
|
|
'width' => 1,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.phonehome'),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
'phone_work' => array(
|
2007-12-22 22:16:12 +00:00
|
|
|
'name' => 'Judge -- Phone (Work)',
|
2007-03-18 19:59:02 +00:00
|
|
|
'header' => 'Phone(Work)',
|
|
|
|
'width' => 1.25,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => "users.phonework"),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
2007-03-20 06:24:18 +00:00
|
|
|
'organization' => array(
|
2007-12-22 22:16:12 +00:00
|
|
|
'name' => 'Judge -- Organization',
|
2007-03-20 06:24:18 +00:00
|
|
|
'header' => 'Organization',
|
|
|
|
'width' => 2,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.organization'),
|
2007-03-20 06:24:18 +00:00
|
|
|
|
2007-03-18 19:59:02 +00:00
|
|
|
'languages' => array(
|
2009-02-02 06:31:39 +00:00
|
|
|
'name' => 'Judge -- Languages',
|
2007-03-18 21:48:36 +00:00
|
|
|
'header' => 'Lang',
|
2007-03-18 19:59:02 +00:00
|
|
|
'width' => 0.75,
|
2009-02-02 06:31:39 +00:00
|
|
|
'table' => 'users_judge.languages',
|
|
|
|
'exec_function' => 'report_judges_languages',
|
|
|
|
'components' => array('users_judge')),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
2007-12-22 22:16:12 +00:00
|
|
|
'complete' => array(
|
|
|
|
'name' => 'Judge -- Registration Complete',
|
2007-12-30 22:30:28 +00:00
|
|
|
'header' => 'Cmpl',
|
|
|
|
'width' => 0.4,
|
2009-02-02 06:31:39 +00:00
|
|
|
'table' => 'users_judge.judge_complete',
|
|
|
|
'value_map' => array ('no' => 'No', 'yes' => 'Yes'),
|
|
|
|
'components' => array('users_judge')),
|
2007-12-22 22:16:12 +00:00
|
|
|
|
|
|
|
'year' => array(
|
|
|
|
'name' => 'Judge -- Year',
|
|
|
|
'header' => 'Year',
|
|
|
|
'width' => 0.5,
|
2009-01-21 09:08:00 +00:00
|
|
|
'table' => 'users.year'),
|
2007-12-22 22:16:12 +00:00
|
|
|
|
2007-03-18 21:48:36 +00:00
|
|
|
'captain' => array(
|
|
|
|
'name' => 'Judge Team -- Captain?',
|
|
|
|
'header' => 'Cptn',
|
|
|
|
'width' => 0.5,
|
|
|
|
'table' => 'judges_teams_link.captain',
|
2007-03-20 06:24:18 +00:00
|
|
|
'value_map' => array ('no' => 'No', 'yes' => 'Yes'),
|
- BAM!
- Overhauled the report generator.. It's more versatile now
- Added 'filter' option to the generator, so you can filter any column by (=,
<=, >=, <, >, IS, IS NOT, LIKE, NOT LIKE). It doesn't support AND or OR
combinations, but that should cover what we need for now. Example: We can
filter "Award Name" LIKE "%Gold%" to generate a report of just the Gold medal
projects.
- Wipe out the report database, and create it again from scratch.
update.48.sql contains an example of how to add additional reports to the
system without knowing the report_ids, because after regions start adding
their own reports, we won't be able to just wipe out the whole report system
to add one.
- We handle more reports now, specifically nametags and table labels, so remove
those files, and update the reports.php file to link the old links to the new
report generator (so people don't get too confused in this transition).
- Beginnings of moving the report generator to proper LEFT JOIN style
constructs instead of just one big massive EQUALS JOIN.
2007-03-26 06:15:41 +00:00
|
|
|
'components' => array('teams')),
|
2007-03-18 21:48:36 +00:00
|
|
|
|
|
|
|
'team' => array(
|
|
|
|
'name' => 'Judge Team -- Name',
|
|
|
|
'header' => 'Team Name',
|
|
|
|
'width' => 3.0,
|
2007-03-20 06:24:18 +00:00
|
|
|
'table' => 'judges_teams.name',
|
- BAM!
- Overhauled the report generator.. It's more versatile now
- Added 'filter' option to the generator, so you can filter any column by (=,
<=, >=, <, >, IS, IS NOT, LIKE, NOT LIKE). It doesn't support AND or OR
combinations, but that should cover what we need for now. Example: We can
filter "Award Name" LIKE "%Gold%" to generate a report of just the Gold medal
projects.
- Wipe out the report database, and create it again from scratch.
update.48.sql contains an example of how to add additional reports to the
system without knowing the report_ids, because after regions start adding
their own reports, we won't be able to just wipe out the whole report system
to add one.
- We handle more reports now, specifically nametags and table labels, so remove
those files, and update the reports.php file to link the old links to the new
report generator (so people don't get too confused in this transition).
- Beginnings of moving the report generator to proper LEFT JOIN style
constructs instead of just one big massive EQUALS JOIN.
2007-03-26 06:15:41 +00:00
|
|
|
'components' => array('teams')),
|
2007-03-18 21:48:36 +00:00
|
|
|
|
|
|
|
'teamnum' => array(
|
|
|
|
'name' => 'Judge Team -- Team Number',
|
|
|
|
'header' => 'Team',
|
|
|
|
'width' => 0.5,
|
2007-03-20 06:24:18 +00:00
|
|
|
'table' => 'judges_teams.num',
|
- BAM!
- Overhauled the report generator.. It's more versatile now
- Added 'filter' option to the generator, so you can filter any column by (=,
<=, >=, <, >, IS, IS NOT, LIKE, NOT LIKE). It doesn't support AND or OR
combinations, but that should cover what we need for now. Example: We can
filter "Award Name" LIKE "%Gold%" to generate a report of just the Gold medal
projects.
- Wipe out the report database, and create it again from scratch.
update.48.sql contains an example of how to add additional reports to the
system without knowing the report_ids, because after regions start adding
their own reports, we won't be able to just wipe out the whole report system
to add one.
- We handle more reports now, specifically nametags and table labels, so remove
those files, and update the reports.php file to link the old links to the new
report generator (so people don't get too confused in this transition).
- Beginnings of moving the report generator to proper LEFT JOIN style
constructs instead of just one big massive EQUALS JOIN.
2007-03-26 06:15:41 +00:00
|
|
|
'components' => array('teams')),
|
2007-03-18 21:48:36 +00:00
|
|
|
|
2007-12-22 21:50:25 +00:00
|
|
|
'project_pn' => array(
|
|
|
|
'name' => 'Project -- Number',
|
|
|
|
'header' => 'Number',
|
|
|
|
'width' => 0.5,
|
|
|
|
'table' => 'projects.projectnumber',
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_title' => array(
|
|
|
|
'name' => 'Project -- Title',
|
|
|
|
'header' => 'Project',
|
|
|
|
'width' => 3,
|
|
|
|
'table' => 'projects.title',
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_summary' => array(
|
|
|
|
'name' => 'Project -- Summary',
|
|
|
|
'header' => 'Summary',
|
|
|
|
'width' => 5,
|
|
|
|
'table' => 'projects.summary',
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_language' => array(
|
|
|
|
'name' => 'Project -- Language',
|
|
|
|
'header' => 'Lang',
|
|
|
|
'width' => 0.4,
|
|
|
|
'table' => 'projects.language',
|
|
|
|
'components' => array('teams', 'projects')),
|
2007-03-20 06:24:18 +00:00
|
|
|
|
2007-12-22 21:50:25 +00:00
|
|
|
'project_students' => array(
|
|
|
|
'name' => 'Project -- Student Name(s) (REQUIRES MYSQL 5.0) ',
|
|
|
|
'header' => 'Student(s)',
|
|
|
|
'width' => 3.0,
|
|
|
|
'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')",
|
2009-02-02 06:31:39 +00:00
|
|
|
'group_by' => array('users.id','judges_teams_timeslots_projects_link.id'),
|
2007-12-22 21:50:25 +00:00
|
|
|
'components' => array('teams', 'projects', 'students')),
|
|
|
|
|
|
|
|
'project_timeslot_start' => array(
|
|
|
|
'name' => 'Project -- Timeslot Start Time (HH:MM)',
|
|
|
|
'header' => 'Start',
|
|
|
|
'width' => 0.75,
|
|
|
|
'table' => "TIME_FORMAT(judges_timeslots.starttime,'%H:%i')",
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_timeslot_end ' => array(
|
|
|
|
'name' => 'Project -- Timeslot End Time (HH:MM)',
|
|
|
|
'header' => 'End',
|
|
|
|
'width' => 0.75,
|
|
|
|
'table' => "TIME_FORMAT(judges_timeslots.endtime,'%H:%i')",
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_timeslot' => array(
|
|
|
|
'name' => 'Project -- Timeslot Start - End (HH:MM - HH:MM)',
|
|
|
|
'header' => 'Timeslot',
|
|
|
|
'width' => 1.5,
|
|
|
|
'table' => "CONCAT(TIME_FORMAT(judges_timeslots.starttime,'%H:%i'),'-',TIME_FORMAT(judges_timeslots.endtime,'%H:%i'))",
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
|
|
|
'project_timeslot_date' => array(
|
|
|
|
'name' => 'Project -- Timeslot Date - (YYYY-MM-DD)',
|
|
|
|
'header' => 'Timeslot Date',
|
|
|
|
'width' => 1,
|
|
|
|
'table' => "judges_timeslots.date",
|
|
|
|
'components' => array('teams', 'projects')),
|
|
|
|
|
2007-03-20 06:24:18 +00:00
|
|
|
'static_text' => array(
|
|
|
|
'name' => 'Static Text (useful for labels)',
|
|
|
|
'header' => '',
|
|
|
|
'width' => 0.1,
|
|
|
|
'table' => "CONCAT(' ')"),
|
2007-03-18 19:59:02 +00:00
|
|
|
|
|
|
|
);
|
|
|
|
|
2007-03-26 01:54:18 +00:00
|
|
|
function report_judges_fromwhere($report, $components)
|
2007-03-18 19:59:02 +00:00
|
|
|
{
|
|
|
|
global $config, $report_judges_fields;
|
|
|
|
|
|
|
|
$fields = $report_judges_fields;
|
|
|
|
$year = $report['year'];
|
|
|
|
|
2009-02-02 06:31:39 +00:00
|
|
|
if(in_array('users_judge', $components)) {
|
|
|
|
$uj_from = 'LEFT JOIN users_judge ON users_judge.users_id=users.id';
|
2007-03-18 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 06:24:18 +00:00
|
|
|
$teams_from = '';
|
|
|
|
$teams_where = '';
|
|
|
|
if(in_array('teams', $components)) {
|
2009-02-02 06:31:39 +00:00
|
|
|
$teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.users_id=users.id
|
2007-12-22 21:50:25 +00:00
|
|
|
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_link.judges_teams_id";
|
|
|
|
$teams_where = "AND judges_teams_link.year='$year'
|
2007-03-20 06:24:18 +00:00
|
|
|
AND judges_teams.year='$year'";
|
2007-03-18 19:59:02 +00:00
|
|
|
}
|
2007-12-22 21:50:25 +00:00
|
|
|
|
|
|
|
$projects_from='';
|
|
|
|
$projects_where='';
|
|
|
|
if(in_array('projects', $components)) {
|
|
|
|
$projects_from = "LEFT JOIN judges_teams_timeslots_projects_link ON
|
|
|
|
judges_teams_timeslots_projects_link.judges_teams_id=judges_teams.id
|
|
|
|
LEFT JOIN projects ON projects.id=judges_teams_timeslots_projects_link.projects_id
|
|
|
|
LEFT JOIN judges_timeslots ON judges_timeslots.id=judges_teams_timeslots_projects_link.judges_timeslots_id";
|
|
|
|
$projects_where = "AND judges_teams_timeslots_projects_link.year='$year'
|
|
|
|
AND projects.year='$year'";
|
|
|
|
}
|
|
|
|
|
|
|
|
$students_from='';
|
|
|
|
$students_where='';
|
|
|
|
if(in_array('students', $components)) {
|
|
|
|
$students_from = "LEFT JOIN students ON students.registrations_id=projects.registrations_id";
|
|
|
|
$students_where = "AND students.year='$year'";
|
|
|
|
}
|
2007-12-22 22:16:12 +00:00
|
|
|
|
|
|
|
/* Search the report for a filter based on judge year */
|
2009-02-02 06:31:39 +00:00
|
|
|
$year_where = "AND users.year='$year'";
|
2007-12-22 22:16:12 +00:00
|
|
|
foreach($report['filter'] as $d) {
|
|
|
|
if($d['field'] == 'year') {
|
2009-02-02 06:31:39 +00:00
|
|
|
/* Don't interally filter on year, we'll do it externally */
|
|
|
|
$year_where = '';
|
2007-12-22 22:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-20 06:24:18 +00:00
|
|
|
|
2009-01-21 09:08:00 +00:00
|
|
|
$q = " FROM users
|
2007-12-22 21:50:25 +00:00
|
|
|
$teams_from
|
|
|
|
$projects_from
|
|
|
|
$students_from
|
2009-02-02 06:31:39 +00:00
|
|
|
$uj_from
|
2007-03-18 19:59:02 +00:00
|
|
|
WHERE
|
2009-02-02 06:31:39 +00:00
|
|
|
users.types LIKE '%judge%'
|
2007-12-22 22:16:12 +00:00
|
|
|
$year_where
|
2007-03-20 06:24:18 +00:00
|
|
|
$teams_where
|
2007-12-22 21:50:25 +00:00
|
|
|
$projects_where
|
|
|
|
$students_where
|
2007-03-18 19:59:02 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
return $q;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|