159 lines
4.1 KiB
PHP
159 lines
4.1 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
|
|
require_once("include/globals.php");
|
|
|
|
// Guarded session handling to avoid warnings and align with other modules
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
if (!empty($sessionName)) {
|
|
session_name($sessionName);
|
|
}
|
|
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();
|
|
}
|
|
|
|
|
|
// Other user types can view any order
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Supplier');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid Access";
|
|
include "form.messages.php";
|
|
exit();
|
|
}
|
|
|
|
|
|
|
|
// Get parameters to script
|
|
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
|
|
|
|
|
// Verify the schedule_num is a valid and active schedule
|
|
$swhere = "";
|
|
if ($_SESSION['UserInfo']['type'] == 'Supplier') $swhere = " and supplier_num = " . $_SESSION['UserInfo']['supplier_num'];
|
|
$today = date("Y-m-d",time());
|
|
$query = "select * from hotlunch_schedules " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $schedule_num " .
|
|
"and status != 'Deleted' $swhere";
|
|
$results = db_query($query);
|
|
|
|
if (db_num_rows($results) == 0) {
|
|
echo("<br>\n");
|
|
$error_message = "Invalid schedule number - $schedule_num";
|
|
include "form.messages.php";
|
|
return;
|
|
}
|
|
|
|
$schedule = db_fetch_array($results);
|
|
|
|
|
|
|
|
|
|
//
|
|
// Setup the PDF
|
|
//
|
|
$template_file = "Blank.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;
|
|
|
|
$left_col = 20;
|
|
$middle_col = 100;
|
|
|
|
|
|
//
|
|
// Setup PDF document
|
|
//
|
|
define('FPDF_FONTPATH',"include/font/");
|
|
require("include/fpdi.php");
|
|
|
|
$pdf= new fpdi('P','mm','Letter');
|
|
|
|
$pagecount = $pdf->setSourceFile("$template_file");
|
|
$tplidx = $pdf->ImportPage(1);
|
|
|
|
$pdf->addPage();
|
|
$pdf->useTemplate($tplidx);
|
|
|
|
$font_red = hexdec("00");
|
|
$font_green = hexdec("00");
|
|
$font_blue = hexdec("00");
|
|
|
|
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
|
|
|
|
|
// Get set of orders to print
|
|
$query = "select hloh.*,first_name,last_name,class_num,user_num " .
|
|
"from hotlunch_order_header as hloh, people as p " .
|
|
"where hloh.school_num = $school_num " .
|
|
"and p.school_num = $base_school_num " .
|
|
"and hloh.schedule_num = $schedule_num " .
|
|
"and hloh.ordered_by_num = p.record_num " .
|
|
"and ((order_total - amount_paid > 0.00) or amount_paid is NULL) " .
|
|
"and hloh.status NOT IN ('Complimentary','Inactive','Deleted') " .
|
|
"order by last_name,first_name";
|
|
$order_records = db_query($query);
|
|
|
|
if (db_num_rows($order_records) > 0) {
|
|
|
|
$count = 0;
|
|
|
|
while ($order_header = db_fetch_array($order_records)) {
|
|
extract($order_header);
|
|
|
|
if ($count > 0) {
|
|
$pdf->addPage();
|
|
$pdf->useTemplate($tplidx);
|
|
}
|
|
|
|
$name = "$first_name $last_name";
|
|
|
|
// Get teacher and class info
|
|
$teacher_info = "";
|
|
if ($class_num > 0) {
|
|
$class_info = getClassInfo($class_num);
|
|
}
|
|
|
|
// Get userid
|
|
$query = "select userid from users " .
|
|
"where school_num = $base_school_num " .
|
|
"and record_num = $user_num";
|
|
$userid = db_getVal($query);
|
|
|
|
include "hotlunch_orders.print.inc.php";
|
|
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
|
|
// Output the completed PDF
|
|
$filename = "orders-list.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=$filename");
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
$pdf->Output($filename,"D");
|
|
|
|
?>
|