From e6cd95ebfc072f72e2f9c7844e9e62ef285534fd Mon Sep 17 00:00:00 2001 From: james Date: Wed, 5 Jan 2011 20:25:14 +0000 Subject: [PATCH] Fix science head and principal queries in branch --- admin/communication.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/communication.inc.php b/admin/communication.inc.php index 122e2de..8d9bfae 100644 --- a/admin/communication.inc.php +++ b/admin/communication.inc.php @@ -142,13 +142,21 @@ */ "school_principals"=>array("name"=>"School principals","query"=> - "SELECT school, principal AS firstname, schoolemail AS email FROM schools WHERE schools.year='".$config['FAIRYEAR']."' AND schoolemail!=''"), + "SELECT school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools + JOIN users ON schools.principal_uid=users.uid AND users.id=(SELECT id FROM users WHERE users.uid=schools.principal_uid ORDER BY `year` DESC LIMIT 1) + WHERE schools.year='".$config['FAIRYEAR']."' AND email!=''"), + "school_scienceheads"=>array("name"=>"School science heads","query"=> - "SELECT school, sciencehead AS firstname, scienceheademail AS email FROM schools WHERE schools.year='".$config['FAIRYEAR']."' AND scienceheademail!=''"), + "SELECT school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools + JOIN users ON schools.sciencehead_uid=users.uid AND users.id=(SELECT id FROM users WHERE users.uid=schools.sciencehead_uid ORDER BY `year` DESC LIMIT 1) + WHERE schools.year='".$config['FAIRYEAR']."' AND email!=''"), + "school_teachers_thisyear"=>array("name"=>"Teachers (as entered by students) this year","query"=> "SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".$config['FAIRYEAR']."' AND teacheremail!=''"), + "school_teachers_lastyear"=>array("name"=>"Teachers (as entered by students) last year","query"=> "SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".($config['FAIRYEAR']-1)."' AND teacheremail!=''"), + "school_teachers_allyears"=>array("name"=>"Teachers (as entered by students) all years","query"=> "SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE teacheremail!=''"), /* Volunteers */