forked from science-ation/science-ation
121 lines
3.0 KiB
PHP
121 lines
3.0 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("School Projects"),
|
|
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif"
|
|
);
|
|
|
|
$rep->newPage();
|
|
$rep->setFontSize(11);
|
|
}
|
|
else if($type=="csv")
|
|
{
|
|
$rep=new lcsv(i18n("School Projects"));
|
|
}
|
|
|
|
$projq=mysql_query("SELECT
|
|
schools.school,
|
|
projects.title,
|
|
projects.projectnumber,
|
|
registrations.id AS reg_id
|
|
FROM
|
|
schools,
|
|
projects,
|
|
registrations,
|
|
students
|
|
WHERE
|
|
projects.registrations_id=registrations.id
|
|
AND students.registrations_id=registrations.id
|
|
AND students.schools_id=schools.id
|
|
AND registrations.year='".$config['FAIRYEAR']."'
|
|
AND ( registrations.status='complete'
|
|
OR registrations.status='paymentpending' )
|
|
ORDER BY school,projectnumber
|
|
");
|
|
|
|
echo mysql_Error();
|
|
$oldschool="nothing";
|
|
$first=true;
|
|
$havealready=array();
|
|
while($proj=mysql_fetch_object($projq))
|
|
{
|
|
if(in_array($proj->reg_id,$havealready))
|
|
continue;
|
|
else
|
|
$havealready[]=$proj->reg_id;
|
|
|
|
$sq=mysql_query("SELECT students.firstname,
|
|
students.lastname
|
|
FROM
|
|
students
|
|
WHERE
|
|
students.registrations_id='$proj->reg_id'
|
|
");
|
|
|
|
$students="";
|
|
$studnum=0;
|
|
while($studentinfo=mysql_fetch_object($sq))
|
|
{
|
|
if($studnum>0) $students.=", ";
|
|
$students.="$studentinfo->firstname $studentinfo->lastname";
|
|
$studnum++;
|
|
}
|
|
if($oldschool!=$proj->school)
|
|
{
|
|
if(!$first)
|
|
{
|
|
$rep->addTable($table);
|
|
unset($table);
|
|
$rep->newPage();
|
|
}
|
|
|
|
$rep->heading($proj->school);
|
|
$rep->nextline();
|
|
$oldschool=$proj->school;
|
|
$table=array();
|
|
$table['header']=array(i18n("Proj Num"),i18n("Project Title"),i18n("Students"));
|
|
$table['widths']=array( 0.8, 3.75, 2.75);
|
|
$table['dataalign']=array("left","left","left");
|
|
$first=false;
|
|
}
|
|
|
|
$table['data'][]=array($proj->projectnumber,$proj->title,$students);
|
|
}
|
|
$rep->addTable($table);
|
|
unset($table);
|
|
|
|
$rep->output();
|
|
?>
|