160 lines
4.2 KiB
PHP
160 lines
4.2 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
|
|
|
|
// startLog("staff-list.print.php");
|
|
|
|
//
|
|
// Ensure that the user is logged in
|
|
//
|
|
if (SessionActive() != 1 || !UserLoggedIn()) {
|
|
header("Location: /?action=$action&error_code=NOACCESS");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Setup the 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 = 10;
|
|
|
|
$left_col = 20;
|
|
$middle_col = 100;
|
|
|
|
|
|
//
|
|
// Setup PDF document
|
|
//
|
|
require("tcpdf/config/lang/eng.php");
|
|
require("tcpdf/tcpdf.php");
|
|
|
|
$pdf = new TCPDF('P', 'mm', 'Letter', true, 'UTF-8', false);
|
|
|
|
// set default monospaced font
|
|
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
|
|
|
//set margins
|
|
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
|
|
|
//set auto page breaks
|
|
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
|
|
|
//set image scale factor
|
|
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
|
|
|
$font_red = hexdec("00");
|
|
$font_green = hexdec("00");
|
|
$font_blue = hexdec("00");
|
|
|
|
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
|
$pdf->SetFont($document_font,"",$document_font_size);
|
|
|
|
$school_name = $school_record['school_name'];
|
|
|
|
// Setup parameters for this document
|
|
$max_rows = 240;
|
|
$name_col = 20;
|
|
$grade_col = 120;
|
|
$division_col = 170;
|
|
$start_row = 25;
|
|
$curr_row = $max_rows + 10;
|
|
$incr = 5;
|
|
|
|
|
|
// Get staff and staff categories
|
|
$query = "select s.*,category_title,sc.sequence " .
|
|
"from people as s, staff_categories as sc " .
|
|
"where s.school_num = $base_school_num " .
|
|
"and s.staff_category = sc.record_num " .
|
|
"order by sc.sequence,s.last_name,s.first_name";
|
|
$staff = db_query($query);
|
|
|
|
$prev_category = "";
|
|
$page = 0;
|
|
|
|
while ($row = db_fetch_array($staff)) {
|
|
extract($row);
|
|
|
|
writeLog("curr_row: $curr_row - max_rows: $max_rows");
|
|
|
|
if ($curr_row > $max_rows) {
|
|
// Put page titles on the page whenever a page is full
|
|
$pdf->addPage();
|
|
|
|
$pdf->SetFont($document_font,"B",14);
|
|
$pdf->SetXY(20,10);
|
|
$pdf->Cell(80,$incr,$school_name,'0',1,'L');
|
|
$pdf->SetXY(20,16);
|
|
$pdf->Cell(80,$incr,getLanguageText('TEXT-STAFF-LIST'),'0',1,'L');
|
|
$pdf->SetFont($document_font,"",10);
|
|
|
|
$curr_row = $start_row;
|
|
$page++;
|
|
}
|
|
|
|
if ($prev_category != $category_title) {
|
|
if ($prev_category != "") $curr_row += $incr;
|
|
$pdf->SetFont($document_font,"B",10);
|
|
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
|
$pdf->SetXY($name_col,$curr_row);
|
|
$pdf->Cell(180,$incr,$category_title,'0',1,'L',true);
|
|
$pdf->SetFont($document_font,"",10);
|
|
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
|
$curr_row += $incr;
|
|
$prev_category = $category_title;
|
|
$count = 0;
|
|
}
|
|
|
|
// 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=staff-list.pdf");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output("staff-list.pdf","D");
|
|
return;
|
|
|
|
$name = "$title $first_name $last_name";
|
|
|
|
$class_info = "";
|
|
if ($class_num > 0) $class_info = getClassInfo($class_num,'external',0);
|
|
|
|
|
|
$bg = true;
|
|
$pdf->SetFillColor(hexdec("f8"),hexdec("f8"),hexdec("f8"));
|
|
if ($count % 2) $pdf->SetFillColor(hexdec("e8"),hexdec("e8"),hexdec("e8"));
|
|
|
|
$pdf->SetXY($name_col,$curr_row);
|
|
$pdf->Cell(180,$incr," $name",'0',1,'L',$bg);
|
|
|
|
$pdf->SetXY($grade_col + 10,$curr_row);
|
|
$pdf->Cell(50,$incr,$class_info,'0',1,'L',$bg);
|
|
|
|
$curr_row += $incr;
|
|
$count++;
|
|
}
|
|
|
|
|
|
// 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=staff-list.pdf");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output("staff-list.pdf","D");
|
|
return;
|
|
|
|
?>
|