First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
require_once("include/globals.php");
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
header("Location: /?error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Administration Team','Schedule Team');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
header("Location: /?error_code=INVALIDACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Setup the PDF
|
||||
//
|
||||
$template_file = "Blank.pdf";
|
||||
$document_font = $school_record['document_font'];
|
||||
if (strlen($document_font) == 0) $document_font = "Helvetica";
|
||||
|
||||
$document_font_weight = "";
|
||||
$document_text_color = "#000000";
|
||||
$document_font_size = 9;
|
||||
|
||||
$left_col = 20;
|
||||
$middle_col = 100;
|
||||
|
||||
|
||||
//
|
||||
// Setup PDF document
|
||||
//
|
||||
define('FPDF_FONTPATH',"include/font/");
|
||||
require("include/fpdi.php");
|
||||
|
||||
$pdf= new fpdi('L','mm','Letter');
|
||||
|
||||
$pagecount = $pdf->setSourceFile("$template_file");
|
||||
$tplidx = $pdf->ImportPage(1);
|
||||
|
||||
$pdf->addPage();
|
||||
$pdf->useTemplate($tplidx);
|
||||
|
||||
$font_red = hexdec("00");
|
||||
$font_green = hexdec("00");
|
||||
$font_blue = hexdec("00");
|
||||
|
||||
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
||||
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
|
||||
$pdf->SetFont("Arial","",$document_font_size);
|
||||
|
||||
$school_name = $school_record['school_name'];
|
||||
|
||||
|
||||
// Set parameters for this document
|
||||
$max_rows = 190;
|
||||
$columns = array(5,55,130,165,200,275);
|
||||
|
||||
$start_row = 5;
|
||||
$incr = 4.0;
|
||||
|
||||
|
||||
// Get set of classes in system
|
||||
$results = db_query("SELECT * FROM classes WHERE school_num = $school_num ORDER BY sequence");
|
||||
$classes = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$classes[] = $row;
|
||||
}
|
||||
$classes[] = array('record_num' => 0);
|
||||
|
||||
|
||||
// Process each class
|
||||
$page_count = 0;
|
||||
$prev_class = 0;
|
||||
$curr_row = $max_rows;
|
||||
for ($i = 0; $i < count($classes); $i++) {
|
||||
extract($classes[$i]);
|
||||
$class_num = $record_num;
|
||||
|
||||
// Get list of people in class with an allergy
|
||||
$query = "select last_name,first_name,user_num,allergen from people as p,allergies as a, allergens as al " .
|
||||
"where p.school_num = $base_school_num " .
|
||||
"and p.class_num = $class_num " .
|
||||
"and a.school_num = $base_school_num " .
|
||||
"and a.people_num = p.record_num " .
|
||||
"and a.allergen_num = al.record_num " .
|
||||
"order by p.last_name,p.first_name,allergen";
|
||||
$students = db_query($query);
|
||||
|
||||
$num_students = db_num_rows($students);
|
||||
|
||||
if ($num_students > 0) {
|
||||
if ($page_count) {
|
||||
// Printed date line
|
||||
$pdf->SetFont("Arial","",$document_font_size - 1);
|
||||
$pdf->SetXY(5,$max_rows);
|
||||
$date = date("F j, Y",time());
|
||||
$pdf->Cell(100,$incr - 1,getLanguageText('TEXT-ALLERGIES') . ": $date",'0',0,'L');
|
||||
$pdf->Image('images/'.$school_record['logo_image'],5,$max_rows + 5,50);
|
||||
$pdf->addPage();
|
||||
}
|
||||
|
||||
$page_count++;
|
||||
$curr_row = $start_row;
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size + 2);
|
||||
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
|
||||
$pdf->SetXY($columns[0],$curr_row);
|
||||
$pdf->Cell(270,$incr + 1,"$school_name " . getLanguageText('TEXT-ALLERGY-REPORT'),'0',1,'L',true);
|
||||
|
||||
$curr_row += $incr + 2;
|
||||
|
||||
$class_info = getClassInfo($class_num);
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size);
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetXY($columns[0],$curr_row);
|
||||
$pdf->Cell(270,$incr,$class_info,'0',1,'L',true);
|
||||
$curr_row += $incr + 1;
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size);
|
||||
$pdf->SetXY($columns[0],$curr_row);
|
||||
$width = $columns[1] - $columns[0];
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-NAME'),'0',1,'L',true);
|
||||
|
||||
$pdf->SetXY($columns[1],$curr_row);
|
||||
$width = $columns[2] - $columns[1];
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ALLERGEN'),'0',1,'L',true);
|
||||
|
||||
$pdf->SetXY($columns[2],$curr_row);
|
||||
$width = $columns[5] - $columns[2];
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ACCOUNT'),'0',1,'L',true);
|
||||
$curr_row += $incr;
|
||||
|
||||
$pdf->SetFont("Arial","",$document_font_size);
|
||||
$pdf->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
|
||||
$line_count = 0;
|
||||
|
||||
while ($student = db_fetch_array($students)) {
|
||||
extract($student);
|
||||
$name = "$first_name $last_name";
|
||||
|
||||
$contact_info = getContactInfo($user_num);
|
||||
|
||||
$fill = false;
|
||||
if ($line_count % 2) $fill = true;
|
||||
$cnum = 0;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$name,'0',1,'L',$fill);
|
||||
|
||||
$cnum = 1;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$allergen,'0',1,'L',$fill);
|
||||
|
||||
$cnum = 2;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$contact_info[0],'0',1,'L',$fill);
|
||||
|
||||
$cnum = 3;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$contact_info[1],'0',1,'L',$fill);
|
||||
|
||||
$cnum = 4;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$contact_info[2],'0',1,'L',$fill);
|
||||
|
||||
$line_count++;
|
||||
$curr_row += $incr;
|
||||
}
|
||||
|
||||
$curr_row += $incr + 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$pdf->addPage();
|
||||
$page_count++;
|
||||
$curr_row = $start_row;
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size + 2);
|
||||
$pdf->SetFillColor(hexdec("bb"),hexdec("bb"),hexdec("bb"));
|
||||
$pdf->SetXY($columns[0],$curr_row);
|
||||
$pdf->Cell(270,$incr + 1,"$school_name " . getLanguageText('TEXT-ALLERGY-REPORT'),'0',1,'L',true);
|
||||
|
||||
$curr_row += $incr + 2;
|
||||
|
||||
$title = getLanguageText('TEXT-SPECIAL-DIET-REQUESTS');
|
||||
|
||||
$pdf->SetFont("Arial","B",$document_font_size);
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetXY($columns[0],$curr_row);
|
||||
$pdf->Cell(270,$incr,$title,'0',1,'L',true);
|
||||
$curr_row += $incr + 1;
|
||||
|
||||
|
||||
|
||||
|
||||
// Get special diet requests
|
||||
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND diet_requests != '' ORDER BY last_name,first_name";
|
||||
$people = db_query($query);
|
||||
$num_students = db_num_rows($people);
|
||||
|
||||
if ($num_students) {
|
||||
$mode = "Diet";
|
||||
|
||||
while ($row = db_fetch_assoc($people)) {
|
||||
extract($row);
|
||||
$name = "$first_name $last_name";
|
||||
|
||||
$class_info = getClassInfo($class_num,'internal',1);
|
||||
$contact_info = getContactInfo($user_num);
|
||||
|
||||
$fill = false;
|
||||
if ($line_count % 2) $fill = true;
|
||||
$cnum = 0;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$width = 270;
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$name,'0',1,'L',$fill);
|
||||
|
||||
$cnum = 1;
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($columns[$cnum],$curr_row);
|
||||
$pdf->Cell($width,$incr,$class_info,'0',1,'L',$fill);
|
||||
|
||||
$cnum = 2;
|
||||
$col = 120;
|
||||
$width = 275 - $col;
|
||||
$pdf->SetXY($col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$diet_requests,'0',1,'L',$fill,'',1);
|
||||
|
||||
$line_count++;
|
||||
$curr_row += $incr;
|
||||
|
||||
if ($curr_row >= $max_rows) {
|
||||
$pdf->addPage();
|
||||
$curr_row = $start_row + 3 * $incr + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Printed date line
|
||||
$pdf->SetFont("Arial","",$document_font_size - 1);
|
||||
$pdf->SetXY(5,$max_rows);
|
||||
$date = date("F j, Y",time());
|
||||
$pdf->Cell(100,$incr - 1,"Allergies: $date",'0',0,'L');
|
||||
$pdf->Image('images/'.$school_record['logo_image'],5,$max_rows + 5,50);
|
||||
|
||||
|
||||
|
||||
// Output the completed PDF
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Cache-Control: private',false);
|
||||
header('Content-type: application/pdf');
|
||||
header("Content-Disposition: attachment; filename=allergies.pdf");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
$pdf->Output("allergies.pdf","D");
|
||||
return;
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user