Files
HotLunches/agreement.print.php
2026-10-19 15:22:52 -07:00

286 lines
7.4 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();
}
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser');
if (checkPermission($AllowedUserTypes) != 1) {
$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();
}
//
// Ensure that there is an school number passed
//
unset($school_num);
if (array_key_exists('school_num',$_GET)) $school_num = intval($_GET['school_num']);
if (!isset($school_num)) {
$error_message = getLanguageText('ERRORMSG-MISSING-SCHOOL-NUM');
$action = '';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
//
// Check that this is a valid school number
//
$query = "select * from schools where record_num = $school_num";
$results = db_query($query);
if (db_num_rows($results) == 0) {
$error_message = getLanguageText('ERRORMSG-MISSING-SCHOOL-NUM');
$action = '';
$naction = '';
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
exit();
}
$school = db_fetch_array($results);
extract($school);
// Setup variables for the document
$annual_fee = "$400.00";
if ($system_configuration == 'Basic') $annual_fee = "$300.00";
$effective_date = date("F jS, Y",time());
//
// Initialize 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;
$max_rows = 250;
$start_row = 25;
$left_col = 15;
$title_width = 190;
$report_title = "SOFTWARE LICENSE AGREEMENT";
$document_name = "License Agreement";
//
// 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() {
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle;
// add header image
$this->Image('images/logo-agreement.gif', 130, 5, 80);
// 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);
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);
}
}
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 + 6);
$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();
include "agreement.php";
$pdf->SetTopMargin($start_row + 10);
$pdf->MultiCell(0,5,$agreement,0,'L',false);
// Print signature lines
$pdf->addPage();
$pdf->SetFont($document_font,'B',10);
$col1 = 20;
$col2 = 90;
$current_row = 35;
$day = date("jS",time());
$month = date("F",time());
$year = date("Y",time());
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Signed and agreed to on this $day day of $month $year",'0','0','L',false);
$current_row += 10;
$pdf->SetFont($document_font,'B',12);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"HotLunches.net",'0','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(110,5,$pac_name,'0','0','C',false);
$col2 = 120;
$current_row += 20;
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5," ",'B','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5," ",'B','0','L',false);
$current_row += 5;
$pdf->SetFont($document_font,'',10);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Signature",'0','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5,"Signature",'0','0','L',false);
$current_row += 20;
$pdf->SetFont($document_font,'B',12);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Mark Fester",'B','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5," ",'B','0','L',false);
$current_row += 5;
$pdf->SetFont($document_font,'',10);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Print Name",'0','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5,"Print Name",'0','0','L',false);
$current_row += 20;
$pdf->SetFont($document_font,'B',12);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"President",'B','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5," ",'B','0','L',false);
$current_row += 5;
$pdf->SetFont($document_font,'',10);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Title",'0','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5,"Title",'0','0','L',false);
$current_row += 20;
$pdf->SetFont($document_font,'B',12);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"$month $day, $year",'B','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5," ",'B','0','L',false);
$current_row += 5;
$pdf->SetFont($document_font,'',10);
$pdf->SetXY($col1,$current_row);
$pdf->Cell(60,5,"Date",'0','0','L',false);
$pdf->SetXY($col2,$current_row);
$pdf->Cell(60,5,"Date",'0','0','L',false);
// Output the completed PDF
$file_name = str_replace(" ","_","Agreement-" . date("Y",time()) . "-$school_name.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=$file_name");
header('Content-Transfer-Encoding: binary');
$pdf->Output("$file_name","D");
return;
?>