CSV of award winners - we used this at ORSF to do a Mail-Merge into a MS publisher template which export to a PDF to create a presentation for the awards ceremony... Next year we should automate this to create an OpenDocument Presentation (.odp)

This commit is contained in:
james 2007-04-03 20:05:39 +00:00
parent 35ccf2a2ad
commit e7776a6b9c
2 changed files with 168 additions and 0 deletions

View File

@ -166,6 +166,9 @@ while($catr=mysql_fetch_object($catq))
echo i18n("Award Ceremony Script").": ";
echo "<a href=\"reports_acscript.php?type=pdf\">PDF</a> &nbsp; ";
echo "<a href=\"reports_acscript.php?type=csv\">CSV</a> &nbsp; ";
echo "<br />";
echo "<a href=\"reports_acpresentation.php?type=csv\">Award Winners CSV</a> &nbsp; ";
echo "<br />";
if($config['tours_enable'] == 'yes') {
echo "<br />";

View File

@ -0,0 +1,165 @@
<?
require("../common.inc.php");
auth_required('admin');
require("../lpdf.php");
require("../lcsv.php");
$type=$_GET['type'];
if(!$type) $type="csv";
if($type=="csv")
{
$rep=new lcsv(i18n("Awards Ceremony Presentation"));
}
$q=mysql_query("SELECT
award_awards.id,
award_awards.name,
award_awards.presenter,
award_awards.order AS awards_order,
award_types.type
FROM
award_awards,
award_types
WHERE
award_awards.year='".$config['FAIRYEAR']."'
AND award_types.year='".$config['FAIRYEAR']."'
AND award_awards.award_types_id=award_types.id
AND award_awards.excludefromac='0'
ORDER BY awards_order");
echo mysql_error();
$table=array();
// $table['header']=array(i18n("Timeslot"),i18n("Judging Team"));
$table['widths']=array( 1,1,1,1,1,1,1,1);
$table['dataalign']=array("left","left","left","left","left","left","left","left");
if(mysql_num_rows($q))
{
while($r=mysql_fetch_object($q))
{
$award=$r->name;
$pq=mysql_query("SELECT
award_prizes.prize,
award_prizes.number,
award_prizes.id,
award_prizes.cash,
award_prizes.scholarship,
winners.projects_id,
projects.projectnumber,
projects.title,
projects.registrations_id AS reg_id,
projectcategories.category,
projectdivisions.division
FROM
award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
LEFT JOIN projects ON projects.id=winners.projects_id
LEFT JOIN projectcategories ON projects.projectcategories_id=projectcategories.id
LEFT JOIN projectdivisions ON projects.projectdivisions_id=projectdivisions.id
WHERE
award_awards_id='$r->id'
AND award_prizes.year='".$config['FAIRYEAR']."'
AND award_prizes.excludefromac='0'
AND projectcategories.year='".$config['FAIRYEAR']."'
AND projectdivisions.year='".$config['FAIRYEAR']."'
ORDER BY
projectcategories.id,projectdivisions.id,
`order`");
echo mysql_error();
$prevprizeid=-1;
while($pr=mysql_fetch_object($pq))
{
if($prevprizeid!=$pr->id)
{
$prizetext=$pr->prize;
if($pr->cash || $pr->scholarship)
{
$prizetext.=" (";
if($pr->cash && $pr->scholarship)
$prizetext.="\$$pr->cash cash / \$$pr->scholarship scholarship";
else if($pr->cash)
$prizetext.= "\$$pr->cash cash";
else if($pr->scholarship)
$prizetext.= "\$$pr->scholarship scholarship";
$prizetext.= ")";
}
$prevprizeid=$pr->id;
}
if($pr->projectnumber)
{
$sq=mysql_query("SELECT students.firstname,
students.lastname,
students.schools_id,
schools.school,
schools.board,
schools.district,
schools.postalcode,
schools.city
FROM
students,
schools
WHERE
students.registrations_id='$pr->reg_id'
AND students.schools_id=schools.id
");
$students=" Students: ";
$studnum=0;
$student1="";
$student2="";
while($studentinfo=mysql_fetch_object($sq))
{
if($studnum==0) $student1="$studentinfo->firstname $studentinfo->lastname";
if($studnum==1) $student2="$studentinfo->firstname $studentinfo->lastname";
if($studnum>0) $students.=", ";
$studnum++;
//we will assume that they are coming from the same school, so lets just grab the last students school
//and use it.
$school=$studentinfo->school;
$schoolboard=$studentinfo->board;
$schooldistrict=$studentinfo->district;
$schoolpostalcode=$studentinfo->postalcode;
$schoolcity=$studentinfo->city;
}
}
else
{
}
/*
$table['data'][]=array(i18n("Division"),$proj->division);
$table['data'][]=array(i18n("Category"),$proj->category);
$table['data'][]=array(i18n("Prize"),$prizetext);
$table['data'][]=array(i18n("Proj #"),$pr->projectnumber);
$table['data'][]=array(i18n("Project Title"),$pr->title);
$table['data'][]=array(i18n("Name 1"),$student1);
$table['data'][]=array(i18n("Name 2"),$student2);
$table['data'][]=array(i18n("School"),$school->school);
*/
$table['data'][]=array($pr->division,
i18n($pr->division,array(),array(),"fr"),
"$pr->category / ".i18n($pr->category,array(),array(),"fr"),
$award,
$prizetext,
$pr->projectnumber,
$pr->title,
$student1,
$student2,
$school,
$schoolcity,
$schoolboard,
$schoolpostalcode
);
}
}
}
$rep->addTable($table);
$rep->output();
?>