First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
// Get parameters to script
|
||||
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
||||
if (array_key_exists('order_num',$_GET)) $order_num = intval($_GET['order_num']);
|
||||
|
||||
if (!isset($order_num)) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid Access";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get order information
|
||||
$query = "select * from hotlunch_order_header " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $order_num";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid Order Number";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$order_header = db_fetch_array($results);
|
||||
|
||||
$ordered_by_num = $order_header['ordered_by_num'];
|
||||
$ordered_by_type = $order_header['ordered_by_type'];
|
||||
$source = $order_header['source'];
|
||||
$status = getLanguageText('TEXT-'.$order_header['status']);
|
||||
|
||||
// Get ordered by info
|
||||
$query = "select concat_ws(' ',first_name,last_name) as name,class_num,user_num from people " .
|
||||
"where school_num = $base_school_num " .
|
||||
"and record_num = $ordered_by_num";
|
||||
$people_record = db_query($query);
|
||||
if (db_num_rows($people_record) == 0) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Ordered by person not found - $ordered_by_num";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$row = db_fetch_assoc($people_record);
|
||||
$name = $row['name'];
|
||||
$class_info = getClassInfo($row['class_num'],'parent');
|
||||
|
||||
|
||||
// Verify that this student is linked to the current user
|
||||
if ($_SESSION['UserInfo']['type'] == 'Parent') {
|
||||
$unum = intval($_SESSION['UserInfo']['record_num']);
|
||||
if ($row['user_num'] != $unum) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid access - student number";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that a Staff user can only see their own order
|
||||
if ($_SESSION['UserInfo']['type'] == 'Staff') {
|
||||
$unum = intval($_SESSION['UserInfo']['record_num']);
|
||||
$query = "select concat_ws(' ',first_name,last_name) as name from people " .
|
||||
"where school_num = $base_school_num " .
|
||||
"and user_num = $unum " .
|
||||
"and record_num = $ordered_by_num";
|
||||
$name = db_getVal($query);
|
||||
|
||||
if ($name = '') {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid Access";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Other user types can view any order
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team');
|
||||
if (checkPermission($AllowedUserTypes) == 1) {
|
||||
if ($ordered_by_type == 'Student') {
|
||||
$query = "select concat_ws(' ',first_name,last_name) as name,class_num from people " .
|
||||
"where school_num = $base_school_num " .
|
||||
"and record_num = $ordered_by_num";
|
||||
$results = db_query($query);
|
||||
$row = db_fetch_array($results);
|
||||
$name = $row['name'];
|
||||
$class_num = $row['class_num'];
|
||||
|
||||
$class_info = getClassInfo($class_num,'internal');
|
||||
}
|
||||
|
||||
if ($ordered_by_type == 'Staff') {
|
||||
$query = "select concat_ws(' ',first_name,last_name) as name from people " .
|
||||
"where school_num = $base_school_num " .
|
||||
"and record_num = $ordered_by_num";
|
||||
$name = db_getVal($query);
|
||||
}
|
||||
|
||||
if ($ordered_by_type == 'Concession') {
|
||||
$name = "Concession Order";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ordered_by = db_fetch_array($results);
|
||||
|
||||
|
||||
// Verify the schedule_num is valid
|
||||
$today = date("Y-m-d",time());
|
||||
$query = "select * from hotlunch_schedules " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $schedule_num " .
|
||||
"and status != 'Deleted'";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
echo("<br>\n");
|
||||
$error_message = "Invalid schedule number";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
|
||||
$schedule = db_fetch_array($results);
|
||||
|
||||
|
||||
// If this is a ScheduleTeam user check if they have permission to access this schedule
|
||||
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
|
||||
$userNum = intval($_SESSION['UserInfo']['record_num']);
|
||||
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
|
||||
|
||||
if (!$access || $access == 0) {
|
||||
echo("<br>\n");
|
||||
$error_message = "You are not allowed access to the requested hot lunch schedule";
|
||||
include "form.messages.php";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Setup the PDF
|
||||
//
|
||||
require("tcpdf/config/lang/eng.php");
|
||||
require("tcpdf/tcpdf.php");
|
||||
|
||||
$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;
|
||||
|
||||
$max_rows = 230;
|
||||
|
||||
$logo_url = $school_record['logo_url'];
|
||||
$logo_image = "images/" . $school_record['logo_image'];
|
||||
$logo_row = $max_rows + 10;
|
||||
|
||||
$document_name = getLanguageText('TEXT-ORDER-DETAILS');
|
||||
|
||||
|
||||
class PDF extends TCPDF {
|
||||
function Header() {
|
||||
global $incr, $left_col, $start_row, $title_width, $document_font, $document_font_size, $report_title, $report_subtitle;
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Setup PDF document
|
||||
//
|
||||
// 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);
|
||||
|
||||
$pdf->addPage();
|
||||
|
||||
$font_red = hexdec("00");
|
||||
$font_green = hexdec("00");
|
||||
$font_blue = hexdec("00");
|
||||
|
||||
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
||||
|
||||
include "hotlunch_orders.print.inc.php";
|
||||
|
||||
|
||||
// Output the completed PDF
|
||||
$filename = "order.pdf";
|
||||
|
||||
if (function_exists('ob_get_length') && ob_get_length()) { @ob_end_clean(); }
|
||||
|
||||
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");
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user