- Add a nomination form as an example of "additional materials". And connect

everything up.  This is coincidentally the form we use for the provincal
  system in BC, but I made it generic.  :)
This commit is contained in:
dave 2009-09-25 19:14:37 +00:00
parent 3a921ba3bf
commit bc3a0e8d67
3 changed files with 225 additions and 3 deletions

View File

@ -0,0 +1,177 @@
<?
/*
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_once('common.inc.php');
require_once('projects.inc.php');
require_once('lpdf.php');
/* Creates a nomination form for every winner of a specific award, should only be called
* by remote.php, which calls it only if the award has additional materials. */
function fair_additional_materials($fair, $award, $year)
{
global $config;
$rep=new lpdf( "{$config['fairname']} Awards Program",
"Nomination Form",
$_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo.gif");
/* Grab a list of winners */
$q = mysql_query("SELECT * FROM award_prizes
LEFT JOIN winners ON winners.awards_prizes_id=award_prizes.id
WHERE winners.year='$year'
AND winners.fairs_id='{$fair['id']}'");
while($r = mysql_fetch_assoc($q)) {
$pid = $r['projects_id'];
$rep->newPage("","",1);
$rep->setFontSize(12);
/* Left margin width */
$x = 1;
$rep->setFontSize(14);
$rep->addText("{$award['name']}", "center");
$rep->setFontSize(12);
$rep->addText("{$r['prize']}", "center");
$rep->nextLine();
$rep->hr();
$rep->nextLine();
$rep->addTextX("Name of Regional Fair: ___________________________________________________", $x);
$rep->addTextX("{$fair['name']}", $x + 1.75);
$rep->nextLine();
$rep->addTextX("Authorized By: __________________________________________________________", $x);
$rep->nextLine();
$rep->addTextX("Position: _______________________________________________________________", $x);
$rep->nextLine();
$rep->addTextX("Date: ________________________________________", $x);
$rep->addTextX(date('l F dS, Y'), $x + 0.5);
$rep->nextLine();
$rep->nextLine();
$p = project_load($pid);
// print_r($p);
$rep->addTextX("Project Title: ____________________________________________________________", $x);
$rep->prevLine();
$rep->addText("{$p['title']}", "left", $x+1) ;
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
foreach($p['student'] as $s) {
$rep->addTextX("Name of Student: ________________________________________________________", $x);
$rep->addTextX("{$s['firstname']} {$s['lastname']}", $x+1.25);
$rep->nextLine();
$rep->addTextX("Grade: _____________ Age: _____________", $x);
$rep->addTextX("{$s['grade']}", $x+0.75);
$rep->addTextX("{$s['age']}", $x+2.75);
$rep->nextLine();
$rep->addTextX("School: ________________________________________________________________", $x);
$rep->addTextX("{$s['school']}", $x + 0.75);
$rep->nextLine();
$rep->addTextX("Home Address: __________________________________________________________", $x);
$rep->prevLine();
$rep->addText("{$s['address']} {$s['city']}, {$s['province']} {$s['postalcode']}", "left", $x + 1.25);
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
}
$rep->hr();
$rep->setFontBold();
$rep->addText("To be considered for this award the following materials need to be included with this form:\n");
$rep->setFontNormal();
$rep->nextLine();
$rep->addText("1.");
$rep->prevLine();
$rep->addText("Project Summary/Discussion Paper (Please include a copy of the summary sheet and any documentation that accompanied the display, including charts and diagrams, that will improve the understanding and comprehension of the science fair project.\n", "left", 0.9);
$rep->addText("2. Copy of Judges Report and Comments.");
$rep->addText("3. Colour photograph(s) of the exhibitor(s) and the exhibit.");
$rep->addText("4. Completed Declaration of Exhibitor form (next page) ");
$rep->nextLine();
$rep->newPage();
$rep->nextLine();
$rep->setFontBold();
$rep->addText("DECLARATION OF EXHIBITOR", "center");
$rep->nextLine();
$rep->setFontNormal();
$rep->nextLine();
$rep->nextLine();
$i = ($p['num_students'] == 1) ? "I" : "We";
$my = ($p['num_students'] == 1) ? "my" : "our";
$rep->addText("1. $i certify this exhibit and report is $my own work.");
$rep->nextLine();
$fn = strtoupper($config['fairname']);
$rep->addText("2.");
$rep->prevLine();
$rep->addText("$i hereby give permission to $fn the AWARDING ORGANIZATION to publicize $my award and reprint $my project summary.", "left", 0.9);
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
foreach($p['student'] as $s) {
$rep->addText("______________________________________ _____________________", "center");
$rep->nextLine();
$rep->addTextX("SIGNATURE ({$s['firstname']} {$s['lastname']})", 1.5);
$rep->addTextX("Date", 6.25);
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
}
$rep->addText("Certified by:");
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
$rep->addText("______________________________________ _____________________", "center");
$rep->nextLine();
$rep->addTextX("POSITION", 2.5);
$rep->addTextX("Date", 6.25);
$rep->nextLine();
$rep->nextLine();
$rep->nextLine();
$rep->addText("_________________________________________________", "center");
$rep->nextLine();
$rep->addText("(Regional Chairperson, Awards Chairperson, or Chief Judge)", "center");
}
return $rep->outputArray();
}
?>

View File

@ -268,6 +268,24 @@ function getSpecialAwardsNominatedByRegistrationID($id)
} }
function project_load($pid)
{
/* Load this project */
$q = mysql_query("SELECT * FROM projects WHERE id='$pid'");
$proj = mysql_fetch_array($q);
/* Load the students */
$q = mysql_query("SELECT students.*,schools.school FROM students
LEFT JOIN schools ON schools.id=students.schools_id
WHERE registrations_id='{$proj['registrations_id']}' AND students.year='{$proj['year']}' ORDER BY students.id");
$proj['num_students'] = 0;
while($s = mysql_fetch_assoc($q)) {
$proj['num_students']++;
$proj['student'][] = $s;
}
return $proj;
}
?> ?>

View File

@ -27,6 +27,8 @@ require_once('common.inc.php');
require_once('user.inc.php'); require_once('user.inc.php');
require_once('fair_additional_materials.inc.php');
function handle_getstats(&$u, $fair,&$data, &$response) function handle_getstats(&$u, $fair,&$data, &$response)
{ {
$year = $data['getstats']['year']; $year = $data['getstats']['year'];
@ -247,6 +249,10 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response)
projectdivisions_id='".intval($project['projectdivisions_id'])."' projectdivisions_id='".intval($project['projectdivisions_id'])."'
WHERE id='$pid'"); WHERE id='$pid'");
/* Record the winner */
mysql_query("INSERT INTO winners(`awards_prizes_id`,`projects_id`,`year`,`fairs_id`)
VALUES('{$prize['id']}','$pid','$year','{$fair['id']}')");
/* Delete the students attached to this project */ /* Delete the students attached to this project */
mysql_query("DELETE FROM students WHERE registrations_id='$registrations_id'"); mysql_query("DELETE FROM students WHERE registrations_id='$registrations_id'");
@ -262,8 +268,8 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response)
foreach($student_fields as $k=>$v) foreach($student_fields as $k=>$v)
$values .= ",'".mysql_real_escape_string($student[$k])."'"; $values .= ",'".mysql_real_escape_string($student[$k])."'";
/* Note lack of comma before $keys, we added it above for both keys and values */ /* Note lack of comma before $keys, we added it above for both keys and values */
mysql_query("INSERT INTO students (`registrations_id`,`fairs_id`, `schools_id` $keys) mysql_query("INSERT INTO students (`registrations_id`,`fairs_id`, `schools_id`,`year` $keys)
VALUES('$registrations_id','{$fair['id']}','$schools_id' $values )"); VALUES('$registrations_id','{$fair['id']}','$schools_id','$year' $values )");
} }
} }
@ -337,6 +343,26 @@ function handle_get_divisions(&$u, &$fair, &$data, &$response)
$response['error'] = 0; $response['error'] = 0;
} }
function handle_award_additional_materials(&$u, &$fair, &$data, &$response)
{
$year = intval($data['award_additional_materials']['year']);
$external_identifier = $data['award_additional_materials']['identifier'];
$eid = mysql_real_escape_string($external_identifier);
$q = mysql_query("SELECT * FROM award_awards WHERE external_identifier='$eid' AND year='$year'");
if(mysql_num_rows($q) != 1) {
$response['message'] = "Unknown award identifier '$eid'";
$response['error'] = 1;
return;
}
$award = mysql_fetch_assoc($q);
$pdf = fair_additional_materials($fair, $award, $year);
$response['award_additional_materials']['pdf']['header'] = $pdf['header'];
$response['award_additional_materials']['pdf']['data64'] = base64_encode($pdf['data']);
$response['error'] = 0;
}
/* magic quotes DEPRECATED as of PHP 5.3.0, REMOVE as of 6.0, on by default * /* magic quotes DEPRECATED as of PHP 5.3.0, REMOVE as of 6.0, on by default *
* for any PHP < 5.3.0. Pain in the ASS. php is running the urldecode for us, * for any PHP < 5.3.0. Pain in the ASS. php is running the urldecode for us,
* seeing that the string has quotes, then adding quotes before we can * seeing that the string has quotes, then adding quotes before we can
@ -395,7 +421,8 @@ function handle_get_divisions(&$u, &$fair, &$data, &$response)
if(array_key_exists('award_upload', $data)) handle_award_upload($u,$fair,$data, $response); if(array_key_exists('award_upload', $data)) handle_award_upload($u,$fair,$data, $response);
if(array_key_exists('get_categories', $data)) handle_get_categories($u,$fair,$data, $response); if(array_key_exists('get_categories', $data)) handle_get_categories($u,$fair,$data, $response);
if(array_key_exists('get_divisions', $data)) handle_get_divisions($u,$fair,$data, $response); if(array_key_exists('get_divisions', $data)) handle_get_divisions($u,$fair,$data, $response);
if(array_key_exists('award_additional_materials', $data)) handle_award_additional_materials($u,$fair,$data, $response);
$response['hi'] = 'hi';
echo urlencode(json_encode($response)); echo urlencode(json_encode($response));
// echo "Success!<br />"; // echo "Success!<br />";