218 lines
5.3 KiB
PHP
218 lines
5.3 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
|
|
|
|
//
|
|
// Ensure that the user is logged in
|
|
//
|
|
if (SessionActive() != 1 || !UserLoggedIn()) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid Access";
|
|
include "form.messages.php";
|
|
exit();
|
|
}
|
|
|
|
|
|
// Check permissions
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid Access";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
// 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 = 9;
|
|
|
|
|
|
$max_rows = 250;
|
|
$start_row = 20;
|
|
$left_col = 15;
|
|
$title_width = 190;
|
|
|
|
$document_name = "Staff Notice";
|
|
|
|
|
|
//
|
|
// Setup the PDF libraries
|
|
//
|
|
require("tcpdf/config/lang/eng.php");
|
|
require("tcpdf/tcpdf.php");
|
|
|
|
$logo_url = $school_record['logo_url'];
|
|
$logo_image = "images/" . $school_record['logo_image'];
|
|
$logo_row = $max_rows + 5;
|
|
|
|
class PDF extends TCPDF {
|
|
function Header() {
|
|
return;
|
|
}
|
|
|
|
function Footer() {
|
|
global $incr, $left_col, $title_width, $max_rows, $document_font, $document_font_size, $document_name, $logo_image, $logo_url, $logo_row, $school_name;
|
|
|
|
// Print the date
|
|
$this->SetFont($document_font,"",$document_font_size - 1);
|
|
$this->SetXY($left_col,$logo_row);
|
|
$date = dateString('datetime');
|
|
$this->Cell($title_width,$incr - 1,"$document_name: $date",'0',1,'R');
|
|
|
|
$this->SetXY($left_col,$logo_row + $incr);
|
|
$this->Cell($title_width,$incr - 1,"$school_name",'0',1,'R','',1);
|
|
|
|
$this->Image($logo_image, 10, $logo_row, 50);
|
|
|
|
$this->SetXY(10,$logo_row + 10);
|
|
$this->SetFont($document_font,"B",$document_font_size);
|
|
$this->Cell($title_width,$incr,$logo_url,'0',1,'L');
|
|
}
|
|
}
|
|
|
|
$pdf= new PDF('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, 40);
|
|
|
|
//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);
|
|
|
|
$pdf->addPage();
|
|
|
|
$school_name = $school_record['school_name'];
|
|
$pac_name = $school_record['pac_name'];
|
|
|
|
|
|
|
|
//
|
|
// Get staff list
|
|
//
|
|
$query = "select * from people " .
|
|
"where school_num = $base_school_num " .
|
|
"and people_type = 'Staff' " .
|
|
"order by last_name";
|
|
$staff = db_query($query);
|
|
|
|
|
|
//
|
|
// Get staff notice text
|
|
//
|
|
$staff_text = db_getVal("select text_data from text_data where school_num = $school_num and text_id = 'Staff Notice'");
|
|
|
|
|
|
|
|
// Process the staff
|
|
if (db_num_rows($staff) > 0) {
|
|
|
|
// Process each menu date
|
|
$count = 0;
|
|
while ($row = db_fetch_array($staff)) {
|
|
extract($row);
|
|
|
|
// Add a page if this is not the first entry
|
|
if ($count > 0) {
|
|
$pdf->addPage();
|
|
}
|
|
|
|
$count++;
|
|
|
|
// Setup new page
|
|
$curr_row = $start_row;
|
|
$incr = 4;
|
|
|
|
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
|
$pdf->SetFont($document_font,"B",$document_font_size + 1);
|
|
|
|
|
|
// Page titles
|
|
$pdf->SetXY($left_col,$curr_row);
|
|
$pdf->Cell(180,$incr + 1,"$pac_name",'0',1,'L',true);
|
|
|
|
$curr_row += $incr + 6;
|
|
|
|
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
|
$pdf->SetFont($document_font,"",$document_font_size);
|
|
|
|
|
|
$name = "$title $first_name $last_name";
|
|
|
|
$pdf->SetXY($left_col,$curr_row);
|
|
$pdf->Cell(180,$incr,$name,'0',1,'L',true);
|
|
|
|
$curr_row += $incr + 5;
|
|
|
|
$pdf->SetXY($left_col,$curr_row);
|
|
$pdf->MultiCell(180,$incr,$staff_text,'0','L',false);
|
|
|
|
$curr_row = $pdf->GetY() + 2;
|
|
|
|
// Get user id and password
|
|
$userid = "";
|
|
$query = "select * from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $user_num";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results)) {
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
}
|
|
|
|
$url = $school_record['url'];
|
|
|
|
$text = "\n" .
|
|
" Web Address: $url\n" .
|
|
" Your User ID: $userid\n";
|
|
|
|
$pdf->SetXY($left_col + 20,$curr_row);
|
|
$pdf->MultiCell(140,$incr,$text,'1','L',true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Printed date line
|
|
if ($curr_row < $max_rows - 3) {
|
|
$pdf->SetXY(20,255);
|
|
$date = date("F j, Y",time());
|
|
$pdf->Cell(182,$incr - 1,"Printed: $date",'0',0,'R');
|
|
}
|
|
|
|
|
|
|
|
// 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-notice.pdf");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output("staff-notice.pdf","D");
|
|
|
|
?>
|