First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,604 @@
|
||||
<?php
|
||||
$ValidAccess = 2010;
|
||||
|
||||
require_once("include/globals.php");
|
||||
|
||||
// Start session only if none active to avoid session_name/session_start warnings
|
||||
if (function_exists('session_status') && session_status() == PHP_SESSION_NONE) {
|
||||
if (isset($sessionName) && strlen($sessionName)) session_name($sessionName);
|
||||
session_start();
|
||||
}
|
||||
|
||||
$action = "menu-details";
|
||||
|
||||
|
||||
//
|
||||
// Ensure that the user is logged in
|
||||
//
|
||||
if (SessionActive() != 1 || !UserLoggedIn()) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Check permissions
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Application Volunteer','Schedule Volunteer','Administration Team','Schedule Team','Supplier','Financial Team');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Get parameters to script
|
||||
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
||||
if (array_key_exists('show_status',$_GET)) $show_status = $_GET['show_status'];
|
||||
|
||||
if (!isset($schedule_num)) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 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 " .
|
||||
"$swhere";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
header("Location: /?action=$action&error_code=INVALIDSCHED");
|
||||
exit();
|
||||
}
|
||||
|
||||
$schedule = db_fetch_array($results);
|
||||
$schedule_name = $schedule['schedule_name'];
|
||||
|
||||
|
||||
// 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) {
|
||||
header("Location: /?action=$action&error_code=NOACCESS");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// 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 = 8;
|
||||
|
||||
|
||||
// Set parameters for this document
|
||||
$max_rows = 180;
|
||||
$title_col = 10;
|
||||
$columns = array(10,70,90,110,180,220,240,270);
|
||||
|
||||
$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 = $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;
|
||||
|
||||
// Print the header
|
||||
$this->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
$this->SetFont($document_font,"B",$document_font_size + 2);
|
||||
$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) {
|
||||
$offset = 150;
|
||||
$this->SetXY($left_col + $offset,$start_row);
|
||||
$this->Cell($title_width - $offset,$incr + 1,"$report_subtitle ",'0',1,'R',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, 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',false,'',1);
|
||||
}
|
||||
}
|
||||
|
||||
// Force exact physical size for Letter: 8.5 x 11 inches => 279.4mm x 215.9mm (landscape)
|
||||
$pageFormat = array(279.4, 215.9);
|
||||
|
||||
$pdf= new PDF('L', 'mm', $pageFormat, true, 'UTF-8', false);
|
||||
|
||||
$font_red = hexdec("00");
|
||||
$font_green = hexdec("00");
|
||||
$font_blue = hexdec("00");
|
||||
|
||||
$pdf->SetTextColor($font_red,$font_green,$font_blue);
|
||||
|
||||
$school_name = $school_record['school_name'];
|
||||
|
||||
|
||||
$document_name = getLanguageText('TEXT-ORDERS-SUMMARY');
|
||||
$report_title = "$document_name - $schedule_name";
|
||||
$PrintTitle = "Orders Summary";
|
||||
|
||||
// Set the status condition if required
|
||||
$show_where = "";
|
||||
$show_having = "";
|
||||
if (array_key_exists('show_status',$_GET)) {
|
||||
switch ($_GET['show_status']) {
|
||||
case 'Paid':
|
||||
case 'Unpaid':
|
||||
case 'Inactive':
|
||||
case 'Deleted':
|
||||
case 'Complimentary':
|
||||
$code = "TEXT-" . strtoupper($_GET['show_status']);
|
||||
$codetext = getLanguageText($code);
|
||||
$show_where .= "and hloh.status = '$show_status' ";
|
||||
$report_title = "$document_name ($codetext) - $schedule_name";
|
||||
$PrintTitle = "$show_status Orders";
|
||||
break;
|
||||
|
||||
case 'Owing':
|
||||
$show_having .= "having sum(ua.transaction_amount) > 0.00 ";
|
||||
$report_title = "Balance Owing Orders By Classroom - $schedule_name";
|
||||
$PrintTitle = "Balance Owing Orders";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$show_only = "";
|
||||
$order_by = " order by scs,gss";
|
||||
if (array_key_exists('show_only',$_GET)) {
|
||||
$show_only = $_GET['show_only'];
|
||||
$show_where .= "and hloh.ordered_by_type = '$show_only' ";
|
||||
$report_title = "Staff Orders";
|
||||
}
|
||||
|
||||
|
||||
// Get list of classes
|
||||
$query = "select c.*,program_name from classes as c left join class_programs as cp on c.class_program = cp.record_num " .
|
||||
"where c.school_num = $base_school_num " .
|
||||
"order by sequence";
|
||||
$cresults = db_query($query);
|
||||
|
||||
$classes = array();
|
||||
$count = 0;
|
||||
while ($class = db_fetch_array($cresults)) {
|
||||
$class_num = $class['record_num'];
|
||||
$classes[$count]['num'] = $class_num;
|
||||
|
||||
// Get class info for the report
|
||||
$class_info = getClassInfo($class_num,'internal',1);
|
||||
$class_label = $class['label_description'];
|
||||
if (strlen($class_label) > 0) $class_info .= " ($class_label)";
|
||||
$classes[$count]['info'] = $class_info;
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
// Handle staff entries
|
||||
$classes[$count]['num'] = 0;
|
||||
$classes[$count]['info'] = $GlobalText['Staff'];
|
||||
$count++;
|
||||
|
||||
|
||||
// Handle customer entries
|
||||
$classes[$count]['num'] = 1;
|
||||
$classes[$count]['info'] = getLanguageText('TEXT-CUSTOMER');
|
||||
$count++;
|
||||
|
||||
|
||||
$processed_staff = array();
|
||||
$page = 0;
|
||||
$grand_total = 0;
|
||||
|
||||
for ($c = 0; $c < count($classes); $c++) {
|
||||
$class_num = $classes[$c]['num'];
|
||||
$class_total = 0;
|
||||
$curr_row = $max_rows + 1;
|
||||
|
||||
// Get orders for this schedule
|
||||
$query = "SELECT p.last_name,p.first_name,people_type,hloh.source,hloh.order_total,hloh.status,p.user_num,hloh.record_num,userid,hloh.payment_method,sum(ua.transaction_amount) as balance " .
|
||||
"FROM people AS p, hotlunch_order_header AS hloh, " .
|
||||
"users AS u LEFT JOIN user_account AS ua ON ua.school_num = $school_num AND ua.user_num = u.record_num AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " .
|
||||
"WHERE p.school_num = $base_school_num " .
|
||||
"AND hloh.school_num = $school_num " .
|
||||
"AND hloh.status NOT IN ('Deleted') " .
|
||||
"AND p.record_num = hloh.ordered_by_num " .
|
||||
"AND p.class_num = $class_num " .
|
||||
"AND hloh.schedule_num = $schedule_num " .
|
||||
"AND p.user_num = u.record_num " .
|
||||
$show_where .
|
||||
"GROUP BY 1,2,3,4,5,6,7,8,9,10 " .
|
||||
$show_having .
|
||||
"ORDER BY 1,2";
|
||||
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0 && !array_key_exists('show_only',$_GET)) continue;
|
||||
|
||||
// Process all the orders found for this page
|
||||
while ($row = db_fetch_array($results)) {
|
||||
// Normalize commonly-used fields to avoid undefined index notices
|
||||
if (!array_key_exists('ptype', $row)) $row['ptype'] = array_key_exists('people_type', $row) ? $row['people_type'] : '';
|
||||
if (!array_key_exists('total', $row)) $row['total'] = array_key_exists('order_total', $row) ? $row['order_total'] : 0;
|
||||
|
||||
if ($curr_row > $max_rows) {
|
||||
$class_info = getClassInfo($class_num);
|
||||
$report_subtitle = $class_info;
|
||||
|
||||
$pdf->addPage();
|
||||
$curr_row = $start_row + $incr + 2;
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetFont($document_font,"",$document_font_size);
|
||||
|
||||
$page++;
|
||||
$count = 0;
|
||||
|
||||
// Titles
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-NAME'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-TYPE'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ORDER')." ",'0',1,'R',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ACCOUNT'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-BALANCE')." ",'0',1,'R',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-SOURCE'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-STATUS'),'0',1,'L',true,'',1);
|
||||
|
||||
$curr_row += $incr;
|
||||
}
|
||||
|
||||
$name = $row['last_name'] . ', ' . $row['first_name'];
|
||||
|
||||
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
$bg = true;
|
||||
if ($count % 2) $bg = false;
|
||||
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$name,'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['people_type'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($row['order_total'],2) . " ",'0',1,'R',$bg,'',1);
|
||||
$class_total += $row['order_total'];
|
||||
|
||||
// Check if this user id has more than one student
|
||||
$unum = $row['user_num'];
|
||||
$num_students = db_getVal("select count(*) from people where school_num = $base_school_num and user_num = $unum");
|
||||
$umodifier = "";
|
||||
if ($num_students > 1) $umodifier = " ($num_students)";
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['userid'] . $umodifier,'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($row['balance'],2) . " ",'0',1,'R',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['source'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['status']." - ".$row['payment_method'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$curr_row += $incr;
|
||||
$count++;
|
||||
|
||||
if ($row['ptype'] == 'Staff') $processed_staff[] = $row['record_num'];
|
||||
}
|
||||
|
||||
// Class total
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetFont($document_font,"B",$document_font_size);
|
||||
$pdf->SetXY($title_col,$curr_row);
|
||||
$pdf->Cell(260,$incr," ",'0',1,'L',true);
|
||||
|
||||
$width = $columns[1] - $columns[0];
|
||||
$curr_col = $columns[0];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-TOTAL').":",'0',1,'R',true);
|
||||
|
||||
$width = $columns[3] - $columns[2];
|
||||
$curr_col = $columns[2];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($class_total,2) . " ",'0',1,'R',true);
|
||||
|
||||
$grand_total += $class_total;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Get and display other staff order information
|
||||
//
|
||||
$pwhere = "";
|
||||
if (count($processed_staff) > 0) $pwhere = "and p.record_num not in (" . implode(",",$processed_staff) . ") ";
|
||||
|
||||
// Get orders for this schedule
|
||||
$query = "SELECT p.last_name,p.first_name,people_type,hloh.source,hloh.order_total,hloh.status,p.user_num,hloh.record_num,userid,hloh.payment_method,sum(ua.transaction_amount) as balance " .
|
||||
"FROM people AS p, hotlunch_order_header AS hloh, " .
|
||||
"users AS u LEFT JOIN user_account AS ua ON ua.school_num = $school_num AND ua.user_num = u.record_num AND (ua.deleted != 'Y' OR ua.deleted IS NULL) " .
|
||||
"WHERE p.school_num = $base_school_num " .
|
||||
"AND hloh.school_num = $school_num " .
|
||||
"AND hloh.status NOT IN ('Inactive','Deleted') " .
|
||||
"AND p.record_num = hloh.ordered_by_num " .
|
||||
"AND p.people_type = 'Staff' " .
|
||||
"AND p.class_num = $class_num " .
|
||||
"AND hloh.schedule_num = $schedule_num " .
|
||||
"AND p.user_num = u.record_num " .
|
||||
$pwhere .
|
||||
"GROUP BY 1,2,3,4,5,6,7,8,9,10 " .
|
||||
$show_having .
|
||||
"ORDER BY 1,2";
|
||||
$results = db_query($query);
|
||||
|
||||
$count = 0;
|
||||
$staff_total = 0;
|
||||
|
||||
// Process all the staff orders found
|
||||
if (db_num_rows($results)) {
|
||||
$report_subtitle = getLanguageText('TEXT-STAFF');
|
||||
$pdf->addPage();
|
||||
$curr_row = $start_row + $incr + 2;
|
||||
|
||||
// $pdf->SetXY($title_col,$curr_row);
|
||||
// $pdf->Cell(260,$incr,"Staff Orders",'0',1,'L',true);
|
||||
|
||||
$pdf->SetFont($document_font,"",$document_font_size);
|
||||
|
||||
// Titles
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-NAME'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-TYPE'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ORDER')." ",'0',1,'R',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-ACCOUNT'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-BALANCE')." ",'0',1,'R',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-SOURCE'),'0',1,'L',true,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-STATUS'),'0',1,'L',true,'',1);
|
||||
|
||||
$curr_row += $incr;
|
||||
|
||||
// Display staff orders
|
||||
while ($row = db_fetch_array($results)) {
|
||||
// Normalize fields expected by the template to avoid undefined key notices
|
||||
if (!array_key_exists('ptype', $row)) $row['ptype'] = array_key_exists('people_type', $row) ? $row['people_type'] : '';
|
||||
if (!array_key_exists('total', $row)) $row['total'] = array_key_exists('order_total', $row) ? $row['order_total'] : 0;
|
||||
|
||||
$name = $row['last_name'] . ', ' . $row['first_name'];
|
||||
|
||||
$pdf->SetFillColor(hexdec("ee"),hexdec("ee"),hexdec("ee"));
|
||||
$bg = true;
|
||||
if ($count % 2) $bg = false;
|
||||
|
||||
$cnum = 0;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$name,'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['ptype'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($row['total'],2) . " ",'0',1,'R',$bg,'',1);
|
||||
$staff_total += $row['total'];
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['userid'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . $row['balance'] . " ",'0',1,'R',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['source'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$cnum++;
|
||||
$curr_col = $columns[$cnum];
|
||||
$width = $columns[$cnum + 1] - $columns[$cnum];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$row['status']." - ".$row['payment_method'],'0',1,'L',$bg,'',1);
|
||||
|
||||
$curr_row += $incr;
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
// Staff total
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetFont($document_font,"B",$document_font_size);
|
||||
$pdf->SetXY($title_col,$curr_row);
|
||||
$pdf->Cell(260,$incr," ",'0',1,'L',true);
|
||||
|
||||
$width = $columns[1] - $columns[0];
|
||||
$curr_col = $columns[0];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,"Total:",'0',1,'R',true);
|
||||
|
||||
$width = $columns[3] - $columns[2];
|
||||
$curr_col = $columns[2];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($staff_total,2) . " ",'0',1,'R',true);
|
||||
|
||||
$grand_total += $staff_total;
|
||||
}
|
||||
|
||||
$curr_row = $max_rows - $incr * 2;
|
||||
|
||||
|
||||
// Grand total
|
||||
$pdf->SetFillColor(hexdec("cc"),hexdec("cc"),hexdec("cc"));
|
||||
$pdf->SetFont($document_font,"B",$document_font_size);
|
||||
$pdf->SetXY($title_col,$curr_row);
|
||||
$pdf->Cell(260,$incr," ",'0',1,'L',true);
|
||||
|
||||
$width = $columns[1] - $columns[0];
|
||||
$curr_col = $columns[0];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,getLanguageText('TEXT-TOTAL').":",'0',1,'R',true);
|
||||
|
||||
$width = $columns[3] - $columns[2];
|
||||
$curr_col = $columns[2];
|
||||
$pdf->SetXY($curr_col,$curr_row);
|
||||
$pdf->Cell($width,$incr,$school_record['currency_symbol'] . number_format($grand_total,2) . " ",'0',1,'R',true);
|
||||
|
||||
|
||||
// Output the completed PDF
|
||||
$filename = "order-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");
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user