science-ation/admin/reports_emergencycontact.php

116 lines
3.9 KiB
PHP

<?
/*
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.
*/
?>
<?
require("../common.inc.php");
auth_required('admin');
require("../lpdf.php");
require("../lcsv.php");
$type=$_GET['type'];
if($type=="pdf")
{
$rep=new lpdf( i18n($config['fairname']),
i18n("Emergency Contact List"),
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
);
$rep->newPage();
$rep->setFontSize(10);
}
else if($type=="csv")
{
$rep=new lcsv(i18n("Emergency Contact")." - ".i18n($catr->category));
}
$q=mysql_query("SELECT students.firstname,
students.lastname,
emergencycontact.firstname AS emerg_firstname,
emergencycontact.lastname AS emerg_lastname,
emergencycontact.relation,
emergencycontact.phone1,
emergencycontact.phone2,
emergencycontact.phone3,
emergencycontact.phone4,
emergencycontact.email,
registrations.status,
projects.title,
projects.projectnumber
FROM
students
left outer join emergencycontact ON students.id=emergencycontact.students_id
left outer join registrations ON students.registrations_id=registrations.id
left outer join projects ON projects.registrations_id=registrations.id
WHERE
registrations.year='".$config['FAIRYEAR']."'
AND ( registrations.status='complete' OR registrations.status='paymentpending' )
ORDER BY
students.lastname,
students.firstname
");
echo mysql_error();
$table=array();
//if its a PDF we'll put each additional phone number on a new line, for CSV, we'll have a column for each
if($type=="pdf")
{
$table['header']=array(i18n("First Name"),i18n("Last Name"),i18n("Emerg First"),i18n("Emerg Last"), i18n("Relation"), i18n("Emerg Phone"));
$table['widths']=array( 1.25, 1.25, 1.25, 1.25, 1, 1.25);
$table['dataalign']=array("left","left","left","left","left","left");
}
else if($type=="csv")
{
$table['header']=array(i18n("First Name"),i18n("Last Name"),i18n("Emerg First"),i18n("Emerg Last"), i18n("Relation"), i18n("Emerg Phone 1"),i18n("Emerg Phone 2"),i18n("Emerg Phone 3"),i18n("Emerg Phone 4"));
//.widths mean nothing for csv
$table['widths']=array( 1.25, 1.25, 1.25, 1.25, 1, 1.25,1.25,1.25,1.25);
$table['dataalign']=array("left","left","left","left","left","left","left","left","left");
}
while($r=mysql_fetch_object($q))
{
//put each phone number on a new line, if it exists
if($type=="pdf")
{
$table['data'][]=array($r->firstname,$r->lastname,$r->emerg_firstname,$r->emerg_lastname,$r->relation,$r->phone1);
if($r->phone2)
$table['data'][]=array('','','','','',$r->phone2);
if($r->phone3)
$table['data'][]=array('','','','','',$r->phone3);
if($r->phone4)
$table['data'][]=array('','','','','',$r->phone4);
}
//put all phone numbers on the same line, in their own columns
else if($type=="csv")
{
$table['data'][]=array($r->firstname,$r->lastname,$r->emerg_firstname,$r->emerg_lastname,$r->relation,$r->phone1,$r->phone2,$r->phone3,$r->phone4);
}
}
$rep->addTable($table);
$rep->output();
?>