215 lines
6.3 KiB
PHP
215 lines
6.3 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
|
|
require_once("include/globals.php");
|
|
|
|
//
|
|
// Ensure that the user is logged in
|
|
//
|
|
if (SessionActive() != 1 || !UserLoggedIn()) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
$action = '';
|
|
$naction = '';
|
|
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
// startLog("staff.report.php");
|
|
|
|
$school_name = $school_record['school_name'];
|
|
$report_title = $school_name;
|
|
$report_subtitle = getLanguageText('TEXT-STAFF-REPORT');
|
|
$document_name = getLanguageText('TEXT-STAFF-REPORT');
|
|
|
|
$mode = "Detail";
|
|
if (array_key_exists('mode',$_GET) && strlen($_GET['mode'])) $mode = $_GET['mode'];
|
|
|
|
|
|
|
|
//
|
|
// 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;
|
|
|
|
|
|
// Setup parameters for this document
|
|
$max_rows = 250;
|
|
$title_width = 195;
|
|
$left_col = 10;
|
|
|
|
$start_row = 10;
|
|
$curr_row = $start_row;
|
|
$incr = 4;
|
|
|
|
|
|
|
|
//
|
|
// Setup PDF document
|
|
//
|
|
require("tcpdf/config/lang/eng.php");
|
|
require("tcpdf/tcpdf.php");
|
|
|
|
$logo_url = "www.hotlunches.net";
|
|
$logo_image = "images/" . $school_record['logo_image'];
|
|
$logo_row = $max_rows + 5;
|
|
|
|
class PDF extends TCPDF {
|
|
function Header() {
|
|
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle;
|
|
|
|
// Print the header
|
|
$this->SetFillColor(hexdec("dd"),hexdec("dd"),hexdec("dd"));
|
|
$this->SetFont($document_font,"B",$document_font_size + 1);
|
|
$this->SetXY($left_col,$start_row);
|
|
$this->Cell($title_width,$incr + 1,$report_title,'0',1,'L',true,'',1);
|
|
|
|
if (isset($report_subtitle) && strlen($report_subtitle) > 0) {
|
|
$this->SetXY($left_col,$start_row + $incr + 2);
|
|
$this->Cell($title_width,$incr + 1,$report_subtitle,'0',1,'L',true,'',1);
|
|
}
|
|
}
|
|
|
|
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',false,'',1);
|
|
|
|
$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, 45);
|
|
|
|
$this->SetXY(15,$logo_row + 8);
|
|
$this->SetFont($document_font,"B",$document_font_size);
|
|
$this->Cell($title_width,$incr,$logo_url,'0',1,'L',false,'',1);
|
|
}
|
|
}
|
|
|
|
|
|
$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, 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);
|
|
|
|
|
|
//
|
|
// Get set of staff account records
|
|
//
|
|
$query = "select p.*,u.userid,u.password from people as p, users as u " .
|
|
"where p.school_num = $base_school_num " .
|
|
"and p.user_num = u.record_num " .
|
|
"and p.people_type = 'Staff' " .
|
|
"order by last_name,first_name";
|
|
$staff = db_query($query);
|
|
|
|
|
|
//
|
|
// Generate the report
|
|
//
|
|
$col1 = $left_col;
|
|
$col1_width = 75;
|
|
$col2 = $col1 + $col1_width;
|
|
$col2_width = 60;
|
|
$col3 = $col2 + $col2_width;
|
|
$col3_width = 60;
|
|
|
|
// $curr_row = $max_rows + 20;
|
|
$curr_row = 0;
|
|
$page = 0;
|
|
$count = 0;
|
|
|
|
while ($row = db_fetch_array($staff)) {
|
|
|
|
writeLog("curr_row: $curr_row - max_rows: $max_rows");
|
|
if ($curr_row == 0 || $curr_row > ($max_rows - 10)) {
|
|
$pdf->addPage();
|
|
|
|
$pdf->SetFont($document_font,"B",$document_font_size + 1);
|
|
$pdf->SetFillColor(hexdec("aa"),hexdec("aa"),hexdec("aa"));
|
|
$curr_row = $start_row + 2 * $incr + 5;
|
|
writeLog("curr_row: $curr_row");
|
|
|
|
$pdf->SetXY($col1,$curr_row);
|
|
$pdf->Cell($col1_width,$incr,getLanguageText('TEXT-NAME'),'1',1,'L',true,'',1);
|
|
|
|
$pdf->SetXY($col2,$curr_row);
|
|
$pdf->Cell($col2_width,$incr,getLanguageText('TEXT-USER-ID'),'1',1,'L',true,'',1);
|
|
|
|
$pdf->SetXY($col3,$curr_row);
|
|
$pdf->Cell($col3_width,$incr,getLanguageText('TEXT-PASSWORD'),'1',1,'L',true,'',1);
|
|
|
|
$curr_row += $incr + .5;
|
|
}
|
|
|
|
$pdf->SetFont($document_font,"",$document_font_size);
|
|
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
|
|
|
$fill = true;
|
|
if ($count % 2) $fill = false;
|
|
$count++;
|
|
|
|
extract($row);
|
|
|
|
$pdf->SetXY($col1,$curr_row);
|
|
$name = "$first_name $last_name";
|
|
if (array_key_exists('staff_name_display', $school_record) && $school_record['staff_name_display'] == "Last Name, First Name") $name = "$last_name, $first_name";
|
|
if (!isset($first_name2)) $first_name2 = '';
|
|
if (!isset($last_name2)) $last_name2 = '';
|
|
if (strlen(trim($first_name2)) || strlen(trim($last_name2))) {
|
|
$name2 = "$first_name2 $last_name2";
|
|
if ($school_record['staff_name_display'] == "Last Name, First Name") $name2 = "$last_name2, $first_name2";
|
|
$name .= " / $name2";
|
|
}
|
|
writeLog("name: $name");
|
|
$pdf->Cell($col1_width,$incr,$name,'1',1,'L',$fill,'',1);
|
|
|
|
$pdf->SetXY($col2,$curr_row);
|
|
writeLog("userid: $userid");
|
|
$pdf->Cell($col2_width,$incr,$userid,'1',1,'L',$fill,'',1);
|
|
|
|
$pdf->SetXY($col3,$curr_row);
|
|
$pdf->Cell($col3_width,$incr,$password,'1',1,'L',$fill,'',1);
|
|
|
|
$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=staff.pdf");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output("staff.pdf","D");
|
|
|
|
?>
|