forked from science-ation/science-ation
- This will break things, but I need to get these home so I can work on 'em.
WIth luck, I'll have a new report generator commiteed witha proper DB update tonight.
This commit is contained in:
parent
c22b3fa86b
commit
80ca088be2
@ -432,13 +432,22 @@ foreach($stock as $n=>$v) {
|
||||
$group_query = "";
|
||||
}
|
||||
|
||||
|
||||
$q = '';
|
||||
$components = array();
|
||||
foreach($report['col'] as $c) {
|
||||
if(!is_array($fields[$c]['select_component'])) continue;
|
||||
$components = array_merge($components, $fields[$c]['select_component']);
|
||||
}
|
||||
foreach($report['group'] as $c) {
|
||||
if(!is_array($fields[$c]['select_component'])) continue;
|
||||
$components = array_merge($components, $fields[$c]['select_component']);
|
||||
}
|
||||
|
||||
$q = '';
|
||||
switch($report['type']) {
|
||||
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;
|
||||
case 'student': $q = report_students_fromwhere($report, $components); break;
|
||||
case 'judge': $q = report_judges_fromwhere($report, $components); break;
|
||||
case 'award': $q = report_awards_fromwhere($report, $components); break;
|
||||
case 'committee': $q = report_committees_fromwhere($report, $components); break;
|
||||
}
|
||||
|
||||
$q = "SELECT $sel $q $group_query ORDER BY $order";
|
||||
|
@ -81,7 +81,7 @@ $report_awards_fields = array(
|
||||
|
||||
);
|
||||
|
||||
function report_awards_fromwhere($report)
|
||||
function report_awards_fromwhere($report, $components)
|
||||
{
|
||||
global $config, $report_awards_fields;
|
||||
|
||||
|
@ -66,7 +66,7 @@ $report_committees_fields = array(
|
||||
|
||||
);
|
||||
|
||||
function report_committees_fromwhere($report)
|
||||
function report_committees_fromwhere($report, $components)
|
||||
{
|
||||
global $config, $report_committees_fields;
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Components: languages, teams */
|
||||
|
||||
$report_judges_fields = array(
|
||||
'last_name' => array(
|
||||
'name' => 'Judge -- Last Name',
|
||||
@ -141,20 +143,13 @@ $report_judges_fields = array(
|
||||
|
||||
);
|
||||
|
||||
function report_judges_fromwhere($report)
|
||||
function report_judges_fromwhere($report, $components)
|
||||
{
|
||||
global $config, $report_judges_fields;
|
||||
|
||||
$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', $components)) {
|
||||
|
@ -65,7 +65,7 @@ $report_students_fields = array(
|
||||
'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'),
|
||||
'table_sort' => 'students.lastname'),
|
||||
|
||||
'grade' => array(
|
||||
'name' => 'Student -- Grade',
|
||||
@ -209,10 +209,11 @@ $report_students_fields = array(
|
||||
'width' => 0.75,
|
||||
'table' => 'schools.postalcode' ),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
'school_board' => array(
|
||||
'name' => 'School -- Board ID',
|
||||
'header' => 'Board',
|
||||
'width' => 0.75,
|
||||
'table' => 'schools.board' ),
|
||||
|
||||
'paid' => array(
|
||||
'name' => 'Paid',
|
||||
@ -235,14 +236,32 @@ $report_students_fields = array(
|
||||
'width' => 4,
|
||||
'table' => "CONCAT(IF(award_types.type='Other','Special',award_types.type),
|
||||
' ', award_awards.name)",
|
||||
'table_sort' => 'award_awards.order'),
|
||||
'table_sort' => 'award_awards.order',
|
||||
'select_component' => array('awards')),
|
||||
|
||||
'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'),
|
||||
'table_sort' => 'award_awards.order',
|
||||
'select_component' => array('awards')),
|
||||
|
||||
'nom_awards' => array(
|
||||
'name' => 'Award Nominations -- Award Name (warning: duplicates student for multiple awards!)',
|
||||
'header' => 'Award Name',
|
||||
'width' => 4,
|
||||
'table' => "CONCAT(award_types.type,' ',award_awards.name)",
|
||||
'table_sort' => 'award_awards.order',
|
||||
'select_component' => array('awards_nominations')),
|
||||
|
||||
'nom_pn_awards' => array(
|
||||
'name' => 'Award Nominations -- Project Num + Award Name(will be unique)',
|
||||
'header' => 'Award Name',
|
||||
'width' => 4,
|
||||
'table' => "CONCAT(projects.projectnumber,' ', award_awards.name)",
|
||||
'table_sort' => 'award_awards.order',
|
||||
'select_component' => array('awards_nominations')),
|
||||
|
||||
'req_elec' => array(
|
||||
'name' => 'If the project requires electricity',
|
||||
@ -268,19 +287,22 @@ $report_students_fields = array(
|
||||
'name' => 'Emergency Contact -- Name',
|
||||
'header' => 'Emerg. Name',
|
||||
'width' => 1.5,
|
||||
'table' => "CONCAT(emergencycontact.firstname, ' ', emergencycontact.lastname)"),
|
||||
'table' => "CONCAT(emergencycontact.firstname, ' ', emergencycontact.lastname)",
|
||||
'select_component' => array('emergencycontacts')),
|
||||
|
||||
'emerg_relation' => array(
|
||||
'name' => 'Emergency Contact -- Relationship',
|
||||
'header' => 'Emerg. Rlt',
|
||||
'width' => 1,
|
||||
'table' => "emergencycontact.relation"),
|
||||
'table' => "emergencycontact.relation",
|
||||
'select_component' => array('emergencycontacts')),
|
||||
|
||||
'emerg_phone' => array(
|
||||
'name' => 'Emergency Contact -- Phone',
|
||||
'header' => 'Emerg. Phone',
|
||||
'width' => 1,
|
||||
'table' => "CONCAT(emergencycontact.phone1, ' ', emergencycontact.phone2, ' ', emergencycontact.phone3, ' ', emergencycontact.phone4)"),
|
||||
'table' => "CONCAT(emergencycontact.phone1, ' ', emergencycontact.phone2, ' ', emergencycontact.phone3, ' ', emergencycontact.phone4)",
|
||||
'select_component' => array('emergencycontacts')),
|
||||
|
||||
'static_text' => array (
|
||||
'name' => 'Static Text (useful for labels)',
|
||||
@ -298,7 +320,7 @@ $report_students_fields = array(
|
||||
|
||||
);
|
||||
|
||||
function report_students_fromwhere($report)
|
||||
function report_students_fromwhere($report, $components)
|
||||
{
|
||||
global $config, $report_students_fields;
|
||||
|
||||
@ -308,8 +330,7 @@ $report_students_fields = array(
|
||||
$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']) ) {
|
||||
if(in_array('awards', $components)) {
|
||||
/* 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
|
||||
@ -321,6 +342,16 @@ $report_students_fields = array(
|
||||
AND award_types.year='$year' ";
|
||||
}
|
||||
|
||||
if(in_array('awards_nominations', $components)) {
|
||||
$awards_join = "LEFT JOIN project_specialawards_link
|
||||
ON(projects.id=project_specialawards_link.projects_id),
|
||||
award_awards,award_types";
|
||||
$awards_where = " AND project_specialawards_link.award_awards_id=award_awards_id
|
||||
AND award_types.id=award_awards.award_types_id
|
||||
AND award_awards.year='$year'
|
||||
AND award_types.year='$year' ";
|
||||
}
|
||||
|
||||
$partner_join = '';
|
||||
if(in_array('bothnames', $report['col']) || in_array('partner', $report['col'])) {
|
||||
$partner_join = "LEFT JOIN students AS students2
|
||||
@ -328,10 +359,18 @@ $report_students_fields = array(
|
||||
AND students2.id != students.id)";
|
||||
}
|
||||
|
||||
$emergencycontact_join = '';
|
||||
if(in_array('emergencycontacts', $components)) {
|
||||
/* No need to put the year in here, students.id is unique across years */
|
||||
$emergencycontact_join = "LEFT JOIN emergencycontact ON (
|
||||
students.id=emergencycontact.students_id )";
|
||||
}
|
||||
|
||||
$q = " FROM
|
||||
students $partner_join,
|
||||
schools, projects $awards_join, projectdivisions,
|
||||
projectcategories, registrations, emergencycontact
|
||||
projectcategories, registrations
|
||||
$emergencycontact_join
|
||||
WHERE
|
||||
schools.id=students.schools_id
|
||||
AND projects.registrations_id=students.registrations_id
|
||||
@ -339,13 +378,11 @@ $report_students_fields = array(
|
||||
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
|
||||
";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user