174 lines
4.8 KiB
PHP
174 lines
4.8 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
|
|
// Guarded session handling to avoid warnings and align with other modules
|
|
if (!empty($sessionName) && session_name() !== $sessionName) {
|
|
session_name($sessionName);
|
|
}
|
|
if (session_status() === PHP_SESSION_NONE || session_id() === '') {
|
|
session_start();
|
|
}
|
|
|
|
|
|
//
|
|
// Ensure that the user is logged in
|
|
//
|
|
if (SessionActive() != 1 || !UserLoggedIn()) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid Access";
|
|
include "form.messages.php";
|
|
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','Financial','Financial Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
|
|
$query = "SELECT * FROM people WHERE school_num = $base_school_num AND notes IS NOT NULL AND LENGTH(TRIM(notes)) > 0 ORDER BY people_type, last_name, first_name";
|
|
$people = db_query($query);
|
|
|
|
|
|
//
|
|
// 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;
|
|
|
|
|
|
// Set parameters for this document
|
|
$max_rows = 240;
|
|
$left_col = 15;
|
|
$name_col = 15;
|
|
$account_col = 55;
|
|
$email_col = 115;
|
|
$balance_col = 180;
|
|
$sched_col = 119;
|
|
|
|
$title_width = 185;
|
|
$start_row = 20;
|
|
$incr = 5.0;
|
|
|
|
|
|
//
|
|
// Setup PDF document
|
|
//
|
|
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;
|
|
|
|
$school_name = $school_record['school_name'];
|
|
$report_title = $school_record['school_name'];
|
|
$document_name = getLanguageText('TEXT-STUDENT-NOTES');
|
|
|
|
|
|
class PDF extends TCPDF {
|
|
function Header() {
|
|
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle, $school_record;
|
|
|
|
// Print the header
|
|
$this->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
|
$this->SetFont($document_font,"B",$document_font_size + 2);
|
|
$this->SetXY($left_col,10);
|
|
$this->Cell($title_width,$incr + 1,'--- '.$school_record['school_name'].' ---','0',1,'L',true);
|
|
}
|
|
|
|
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(20,$logo_row + 9);
|
|
$this->SetFont($document_font,"B",$document_font_size);
|
|
$this->Cell($title_width,$incr,$logo_url,'0',1,'L');
|
|
}
|
|
}
|
|
|
|
// Force exact physical size for Letter: 8.5 x 11 inches => 215.9mm x 279.4mm (portrait)
|
|
$pageFormat = array(215.9, 279.4);
|
|
|
|
$pdf= new PDF('P', 'mm', $pageFormat, 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);
|
|
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
|
|
|
$pdf->addPage();
|
|
$curr_row = $start_row;
|
|
|
|
|
|
|
|
// Process student records
|
|
$page_count = 0;
|
|
$prev_class = 0;
|
|
while ($row = db_fetch_array($people)) {
|
|
extract($row);
|
|
|
|
$name = $first_name . " " . $last_name;
|
|
|
|
$fill = true;
|
|
$pdf->SetXY($name_col,$curr_row);
|
|
$pdf->Cell($title_width,$incr,$name,'0',1,'L',$fill,'',1);
|
|
|
|
$curr_row += $incr + 1;
|
|
|
|
$pdf->SetXY($name_col + 5,$curr_row);
|
|
$pdf->MultiCell($title_width - 5,$incr,$notes,'0','L',false,1,'','',true,0,false,true);
|
|
$curr_row = $pdf->GetY();
|
|
$curr_row += $incr;
|
|
}
|
|
|
|
|
|
// 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=student-notes.pdf");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output("student-notes.pdf","D");
|
|
exit();
|
|
|
|
?>
|