Add a TCPDF version of the signature page, TCPDF does not require any extra PDF libraries (eg pdflib) to be installed

Create PNG versions of the uploaded logo image file
Detect which version of the signature page to use
Bump version to development series 2.0.5
This commit is contained in:
james 2006-12-18 20:55:30 +00:00
parent 0bd7ab8a93
commit 9fc98fc288
5 changed files with 214 additions and 2 deletions

View File

@ -361,6 +361,7 @@ if($config['participant_student_personal']=="yes")
} }
echo "<br />"; echo "<br />";
echo i18n("WARNING! If you make a change to the grade that would affect the project number, you must update the project number manually, it will NOT be automatically updated"); echo i18n("WARNING! If you make a change to the grade that would affect the project number, you must update the project number manually, it will NOT be automatically updated");
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Student Information")."\" />\n"; echo "<input type=\"submit\" value=\"".i18n("Save Student Information")."\" />\n";
echo "</form>"; echo "</form>";
echo "<br />"; echo "<br />";

View File

@ -36,10 +36,18 @@ if($_POST['action']=="addimage")
if($imagesize[2]==1 || $imagesize[2]==2 || $imagesize[2]==3) // GIF or JPG or PNG if($imagesize[2]==1 || $imagesize[2]==2 || $imagesize[2]==3) // GIF or JPG or PNG
{ {
echo notice(i18n("Creating sized logo files:<br />&nbsp;logo-100.gif<br />&nbsp;logo-200.gif<br />&nbsp;logo-500.gif<br />&nbsp;logo.gif")); echo notice(i18n("Creating sized logo files:<br />&nbsp;logo-100.gif<br />&nbsp;logo-200.gif<br />&nbsp;logo-500.gif<br />&nbsp;logo.gif"));
//Make the gif's
system("convert -sample 100 \"".$_FILES['image']['tmp_name']."\" ../data/logo-100.gif"); system("convert -sample 100 \"".$_FILES['image']['tmp_name']."\" ../data/logo-100.gif");
system("convert -sample 200 \"".$_FILES['image']['tmp_name']."\" ../data/logo-200.gif"); system("convert -sample 200 \"".$_FILES['image']['tmp_name']."\" ../data/logo-200.gif");
system("convert -sample 500 \"".$_FILES['image']['tmp_name']."\" ../data/logo-500.gif"); system("convert -sample 500 \"".$_FILES['image']['tmp_name']."\" ../data/logo-500.gif");
system("convert \"".$_FILES['image']['tmp_name']."\" ../data/logo.gif"); system("convert \"".$_FILES['image']['tmp_name']."\" ../data/logo.gif");
echo notice(i18n("Creating sized logo files:<br />&nbsp;logo-100.png<br />&nbsp;logo-200.png<br />&nbsp;logo-500.png<br />&nbsp;logo.png"));
//make some PNG's as well
system("convert -sample 100 \"".$_FILES['image']['tmp_name']."\" ../data/logo-100.png");
system("convert -sample 200 \"".$_FILES['image']['tmp_name']."\" ../data/logo-200.png");
system("convert -sample 500 \"".$_FILES['image']['tmp_name']."\" ../data/logo-500.png");
system("convert \"".$_FILES['image']['tmp_name']."\" ../data/logo.png");
echo happy(i18n("Logo Image successfully uploaded")); echo happy(i18n("Logo Image successfully uploaded"));
} }
else else
@ -58,6 +66,7 @@ if($_POST['action']=="addimage")
echo "<table>"; echo "<table>";
if(file_exists("../data/logo.gif")) if(file_exists("../data/logo.gif"))
{ {
echo "<tr><td colspan=\"2\">".i18n("GIF Images")."</td></tr>";
echo "<tr><td>"; echo "<tr><td>";
echo "<img src=\"../data/logo-100.gif\" border=\"0\">"; echo "<img src=\"../data/logo-100.gif\" border=\"0\">";
echo "</td><td>"; echo "</td><td>";
@ -67,6 +76,18 @@ if($_POST['action']=="addimage")
echo "<a target=\"_blank\" href=\"../data/logo-500.gif\">500 Pixel width</a><br />"; echo "<a target=\"_blank\" href=\"../data/logo-500.gif\">500 Pixel width</a><br />";
echo "</td></tr>"; echo "</td></tr>";
} }
if(file_exists("../data/logo.png"))
{
echo "<tr><td colspan=\"2\">".i18n("PNG Images")."</td></tr>";
echo "<tr><td>";
echo "<img src=\"../data/logo-100.png\" border=\"0\">";
echo "</td><td>";
echo "<a target=\"_blank\" href=\"../data/logo.png\">",i18n("Original size")."</a><br />";
echo "<a target=\"_blank\" href=\"../data/logo-100.png\">".i18n("100 Pixel width")."</a><br />";
echo "<a target=\"_blank\" href=\"../data/logo-200.png\">".i18n("200 Pixel width")."</a><br />";
echo "<a target=\"_blank\" href=\"../data/logo-500.png\">500 Pixel width</a><br />";
echo "</td></tr>";
}
echo "<tr><td colspan=2>"; echo "<tr><td colspan=2>";
echo "<input type=\"file\" name=\"image\">"; echo "<input type=\"file\" name=\"image\">";
echo "<input type=\"submit\" value=\"".i18n("Upload Logo")."\" />\n"; echo "<input type=\"submit\" value=\"".i18n("Upload Logo")."\" />\n";

View File

@ -165,10 +165,23 @@ echo "<table><tr><td>";
echo outputStatus($statussafety); echo outputStatus($statussafety);
echo "</td></tr>"; echo "</td></tr>";
//FIXME: this should be a global detection so we can use the results elsewhere, especially for all the reports!
if(function_exists("pdf_new"))
$sigfile="register_participants_signature.php";
else if(file_exists("tcpdf/tcpdf.php"))
$sigfile="register_participants_signature_tcpdf.php";
else
$sigfile="";
//signature page //signature page
echo "<tr><td>"; echo "<tr><td>";
if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete") if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo "<a href=\"register_participants_signature.php\">"; {
if($sigfile)
echo "<a href=\"$sigfile\">";
else
echo error(i18n("No PDF generation library detected"),true);
}
echo i18n("Signature Page"); echo i18n("Signature Page");
if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete") if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo "</a>"; echo "</a>";

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) 2006 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");
include "register_participants.inc.php";
require_once("tcpdf/tcpdf.php");
//authenticate based on email address and registration number from the SESSION
if(!$_SESSION['email'])
{
header("Location: register_participants.php");
exit;
}
if(!$_SESSION['registration_number'])
{
header("Location: register_participants.php");
exit;
}
$q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
"WHERE students.email='".$_SESSION['email']."' ".
"AND registrations.num='".$_SESSION['registration_number']."' ".
"AND registrations.id='".$_SESSION['registration_id']."' ".
"AND students.registrations_id=registrations.id ".
"AND registrations.year=".$config['FAIRYEAR']." ".
"AND students.year=".$config['FAIRYEAR']);
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_participants.php");
exit;
}
$authinfo=mysql_fetch_object($q);
$pdf=new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle(i18n("Participant Signature Page (".$_SESSION['registration_number'].")"));
$pdf->SetSubject("");
$pdf->SetKeywords("");
$pdf->SetHeaderData("logo-200.png", 15, i18n($config['fairname']), i18n("Participant Signature Page (".$_SESSION['registration_number'].")"));
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->AliasNbPages();
$pdf->AddPage();
//grab the project info
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
$projectinfo=mysql_fetch_object($q);
$q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
while($si=mysql_fetch_object($q))
$studentinfoarray[]=$si;
$pagetext="<h2>".i18n("Registration Summary")."</h2>";
$pagetext.="<b>Registration Number</b>: ".$_SESSION['registration_number']."<br />".
"<b>Project Title</b>: $projectinfo->title<br />";
if(count($studentinfoarray)>1)
$plural="s";
else
$plural="";
$pagetext.="<b>Exhibitor$plural</b>: ";
foreach($studentinfoarray AS $studentinfo)
{
$pagetext.="$studentinfo->firstname $studentinfo->lastname, ";
}
$pagetext=substr($pagetext,0,-2);
$pagetext.="<hr />";
$pdf->WriteHTML($pagetext);
$pagetext="";
$q=mysql_query("SELECT * FROM signaturepage WHERE name='exhibitordeclaration'");
$r=mysql_fetch_object($q);
if($r->use)
{
$pagetext="<h2>".i18n("Exhibitor Declaration")."</h2>";
$pagetext.=nl2br($r->text);
$pdf->WriteHTML($pagetext);
foreach($studentinfoarray AS $studentinfo)
{
$pdf->Ln(10);
//signature line
$pdf->Line(20,$pdf->GetY(),120,$pdf->GetY());
$pdf->Line(140,$pdf->GetY(),180,$pdf->GetY());
//show their name
$pdf->Ln(5);
$pdf->Text(30,$pdf->GetY(),i18n("%1 %2 (signature)",array($studentinfo->firstname,$studentinfo->lastname)));
$pdf->Text(150,$pdf->GetY(),i18n("Date"));
}
$pdf->WriteHTML("<hr />");
}
$q=mysql_query("SELECT * FROM signaturepage WHERE name='parentdeclaration'");
$r=mysql_fetch_object($q);
if($r->use)
{
$pagetext="<h2>".i18n("Parent/Guardian Declaration")."</h2>";
$pagetext.=nl2br($r->text);
$pdf->WriteHTML($pagetext);
foreach($studentinfoarray AS $studentinfo)
{
$pdf->Ln(10);
//signature line
$pdf->Line(20,$pdf->GetY(),120,$pdf->GetY());
$pdf->Line(140,$pdf->GetY(),180,$pdf->GetY());
//show their name
$pdf->Ln(5);
$pdf->Text(30,$pdf->GetY(),i18n("Parent/Guardian of %1 %2 (signature)",array($studentinfo->firstname,$studentinfo->lastname)));
$pdf->Text(150,$pdf->GetY(),i18n("Date"));
}
$pdf->WriteHTML("<hr />");
}
$q=mysql_query("SELECT * FROM signaturepage WHERE name='teacherdeclaration'");
$r=mysql_fetch_object($q);
if($r->use)
{
//now for the teacher signature
$pagetext="<h2>".i18n("Teacher Declaration")."</h2>";
$pagetext.=nl2br($r->text);
$pdf->WriteHTML($pagetext);
//we only need 1 teacher signature line, we can assume (maybe incorrectly) that both students
//have the same teacher.. if they are not the same, then they can get the best teacher to sign
//it doesnt matter.
$pdf->Ln(10);
//signature line
$pdf->Line(20,$pdf->GetY(),120,$pdf->GetY());
$pdf->Line(140,$pdf->GetY(),180,$pdf->GetY());
//show their name
$pdf->Ln(5);
$pdf->Text(30,$pdf->GetY(),i18n("Teacher Signature",array($studentinfo->firstname,$studentinfo->lastname)));
$pdf->Text(150,$pdf->GetY(),i18n("Date"));
}
$pdf->Output();
exit;
?>

View File

@ -1 +1 @@
2.0.4 2.0.5