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 = "";
|
$group_query = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$components = array();
|
||||||
$q = '';
|
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']) {
|
switch($report['type']) {
|
||||||
case 'student': $q = report_students_fromwhere($report); break;
|
case 'student': $q = report_students_fromwhere($report, $components); break;
|
||||||
case 'judge': $q = report_judges_fromwhere($report); break;
|
case 'judge': $q = report_judges_fromwhere($report, $components); break;
|
||||||
case 'award': $q = report_awards_fromwhere($report); break;
|
case 'award': $q = report_awards_fromwhere($report, $components); break;
|
||||||
case 'committee': $q = report_committees_fromwhere($report); break;
|
case 'committee': $q = report_committees_fromwhere($report, $components); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = "SELECT $sel $q $group_query ORDER BY $order";
|
$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;
|
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;
|
global $config, $report_committees_fields;
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
Boston, MA 02111-1307, USA.
|
Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Components: languages, teams */
|
||||||
|
|
||||||
$report_judges_fields = array(
|
$report_judges_fields = array(
|
||||||
'last_name' => array(
|
'last_name' => array(
|
||||||
'name' => 'Judge -- Last Name',
|
'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;
|
global $config, $report_judges_fields;
|
||||||
|
|
||||||
$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', $components)) {
|
if(in_array('languages', $components)) {
|
||||||
|
@ -65,7 +65,7 @@ $report_students_fields = array(
|
|||||||
'header' => 'Student(s)',
|
'header' => 'Student(s)',
|
||||||
'width' => 3.0,
|
'width' => 3.0,
|
||||||
'table' => "CONCAT(students.firstname, ' ', students.lastname, IF(students2.lastname IS NULL,'', CONCAT(', ', students2.firstname, ' ', students2.lastname)))",
|
'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(
|
'grade' => array(
|
||||||
'name' => 'Student -- Grade',
|
'name' => 'Student -- Grade',
|
||||||
@ -209,10 +209,11 @@ $report_students_fields = array(
|
|||||||
'width' => 0.75,
|
'width' => 0.75,
|
||||||
'table' => 'schools.postalcode' ),
|
'table' => 'schools.postalcode' ),
|
||||||
|
|
||||||
|
'school_board' => array(
|
||||||
|
'name' => 'School -- Board ID',
|
||||||
|
'header' => 'Board',
|
||||||
|
'width' => 0.75,
|
||||||
|
'table' => 'schools.board' ),
|
||||||
|
|
||||||
'paid' => array(
|
'paid' => array(
|
||||||
'name' => 'Paid',
|
'name' => 'Paid',
|
||||||
@ -235,14 +236,32 @@ $report_students_fields = array(
|
|||||||
'width' => 4,
|
'width' => 4,
|
||||||
'table' => "CONCAT(IF(award_types.type='Other','Special',award_types.type),
|
'table' => "CONCAT(IF(award_types.type='Other','Special',award_types.type),
|
||||||
' ', award_awards.name)",
|
' ', award_awards.name)",
|
||||||
'table_sort' => 'award_awards.order'),
|
'table_sort' => 'award_awards.order',
|
||||||
|
'select_component' => array('awards')),
|
||||||
|
|
||||||
'pn_awards' => array(
|
'pn_awards' => array(
|
||||||
'name' => 'Project Num + Award (will be unique)',
|
'name' => 'Project Num + Award (will be unique)',
|
||||||
'header' => 'Award Name',
|
'header' => 'Award Name',
|
||||||
'width' => 4,
|
'width' => 4,
|
||||||
'table' => "CONCAT(projects.projectnumber,' ', award_awards.name)",
|
'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(
|
'req_elec' => array(
|
||||||
'name' => 'If the project requires electricity',
|
'name' => 'If the project requires electricity',
|
||||||
@ -268,19 +287,22 @@ $report_students_fields = array(
|
|||||||
'name' => 'Emergency Contact -- Name',
|
'name' => 'Emergency Contact -- Name',
|
||||||
'header' => 'Emerg. Name',
|
'header' => 'Emerg. Name',
|
||||||
'width' => 1.5,
|
'width' => 1.5,
|
||||||
'table' => "CONCAT(emergencycontact.firstname, ' ', emergencycontact.lastname)"),
|
'table' => "CONCAT(emergencycontact.firstname, ' ', emergencycontact.lastname)",
|
||||||
|
'select_component' => array('emergencycontacts')),
|
||||||
|
|
||||||
'emerg_relation' => array(
|
'emerg_relation' => array(
|
||||||
'name' => 'Emergency Contact -- Relationship',
|
'name' => 'Emergency Contact -- Relationship',
|
||||||
'header' => 'Emerg. Rlt',
|
'header' => 'Emerg. Rlt',
|
||||||
'width' => 1,
|
'width' => 1,
|
||||||
'table' => "emergencycontact.relation"),
|
'table' => "emergencycontact.relation",
|
||||||
|
'select_component' => array('emergencycontacts')),
|
||||||
|
|
||||||
'emerg_phone' => array(
|
'emerg_phone' => array(
|
||||||
'name' => 'Emergency Contact -- Phone',
|
'name' => 'Emergency Contact -- Phone',
|
||||||
'header' => 'Emerg. Phone',
|
'header' => 'Emerg. Phone',
|
||||||
'width' => 1,
|
'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 (
|
'static_text' => array (
|
||||||
'name' => 'Static Text (useful for labels)',
|
'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;
|
global $config, $report_students_fields;
|
||||||
|
|
||||||
@ -308,8 +330,7 @@ $report_students_fields = array(
|
|||||||
$awards_join = '';
|
$awards_join = '';
|
||||||
$awards_where = '';
|
$awards_where = '';
|
||||||
|
|
||||||
if(in_array('awards', $report['col']) || in_array('pn_awards', $report['col'])
|
if(in_array('awards', $components)) {
|
||||||
|| in_array('awards', $report['group']) || in_array('pn_awards', $report['group']) ) {
|
|
||||||
/* This requires some extra gymnastics */
|
/* This requires some extra gymnastics */
|
||||||
$awards_join = "LEFT JOIN winners ON(winners.projects_id = projects.id),award_prizes,award_awards,award_types";
|
$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
|
$awards_where = " AND winners.awards_prizes_id=award_prizes.id
|
||||||
@ -321,6 +342,16 @@ $report_students_fields = array(
|
|||||||
AND award_types.year='$year' ";
|
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 = '';
|
$partner_join = '';
|
||||||
if(in_array('bothnames', $report['col']) || in_array('partner', $report['col'])) {
|
if(in_array('bothnames', $report['col']) || in_array('partner', $report['col'])) {
|
||||||
$partner_join = "LEFT JOIN students AS students2
|
$partner_join = "LEFT JOIN students AS students2
|
||||||
@ -328,10 +359,18 @@ $report_students_fields = array(
|
|||||||
AND students2.id != students.id)";
|
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
|
$q = " FROM
|
||||||
students $partner_join,
|
students $partner_join,
|
||||||
schools, projects $awards_join, projectdivisions,
|
schools, projects $awards_join, projectdivisions,
|
||||||
projectcategories, registrations, emergencycontact
|
projectcategories, registrations
|
||||||
|
$emergencycontact_join
|
||||||
WHERE
|
WHERE
|
||||||
schools.id=students.schools_id
|
schools.id=students.schools_id
|
||||||
AND projects.registrations_id=students.registrations_id
|
AND projects.registrations_id=students.registrations_id
|
||||||
@ -339,13 +378,11 @@ $report_students_fields = array(
|
|||||||
AND projectcategories.id=projects.projectcategories_id
|
AND projectcategories.id=projects.projectcategories_id
|
||||||
AND registrations.id=students.registrations_id
|
AND registrations.id=students.registrations_id
|
||||||
AND (registrations.status='complete' OR registrations.status='paymentpending')
|
AND (registrations.status='complete' OR registrations.status='paymentpending')
|
||||||
AND emergencycontact.students_id=students.id
|
|
||||||
AND students.year='$year'
|
AND students.year='$year'
|
||||||
AND projects.year='$year'
|
AND projects.year='$year'
|
||||||
AND registrations.year='$year'
|
AND registrations.year='$year'
|
||||||
AND projectcategories.year='$year'
|
AND projectcategories.year='$year'
|
||||||
AND projectdivisions.year='$year'
|
AND projectdivisions.year='$year'
|
||||||
AND emergencycontact.year='$year'
|
|
||||||
$awards_where
|
$awards_where
|
||||||
";
|
";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user