SetXY($left_col,$max_rows - $incr * 2); $this->SetFont($document_font,"B",$document_font_size + 2); $this->Cell($title_width,$incr + 1,$school_record['school_name'],'0',0,'C',false,'',1); $this->SetXY($left_col,$max_rows - $incr); $this->SetFont($document_font,"",$document_font_size); $this->Cell($title_width,$incr + 1,$school_record['address'].", ".$school_record['city'].", ".$school_record['province']." ".$school_record['postal'],'0',0,'C',false,'',1); $this->SetXY($left_col,$max_rows); $this->SetFont($document_font,"",$document_font_size); $this->Cell($title_width,$incr + 1,$school_record['phone'],'0',0,'C',false,'',1); } } $pdf= new PDF('P', 'mm', 'Letter', true, 'UTF-8', false); $font_red = hexdec("00"); $font_green = hexdec("00"); $font_blue = hexdec("00"); $pdf->SetTextColor($font_red,$font_green,$font_blue); $pdf->SetFillColor(200,200,200); $pdf->addPage(); $curr_row = $start_row; // Add logo if (strlen($receipt_image) && is_file($receipt_image)) { $pdf->Image($receipt_image,$left_col,$start_row,0,$image_height); $curr_row += $image_height; } // Print receipt title if (strlen($school_record['receipt_title'])) { $pdf->SetFont($document_font,"B",$document_font_size + 8); $pdf->SetXY($left_col,$curr_row); $pdf->Cell($title_width,$incr + 6,$school_record['receipt_title'],'0',0,'L',false,'',0); } $pdf->SetFont($document_font,"B",$document_font_size + 1); $curr_row += $incr + 2; $pdf->SetXY($left_col,$curr_row); $pdf->Cell($date_width,$incr + 6,date($school_record['date_format'],time()),'0',0,'L',false,'',0); $pdf->SetFont($document_font,"B",$document_font_size); $curr_row += $incr * 4; // Print user info $pdf->SetXY($name_col,$curr_row); $pdf->Cell($title_width,$incr,$user['first_name'] . ' ' . $user['last_name'],'0',0,'L',false,'',0); $curr_row += $incr; $pdf->SetXY($name_col,$curr_row); $pdf->Cell($title_width,$incr,$user['home_phone'],'0',0,'L',false,'',0); $curr_row += $incr * 4; // Get and print all user transactions $transactions = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND user_num = $user_num AND deleted != 'Y' ORDER BY transaction_datetime"); if (db_num_rows($transactions) == 0) { $pdf->SetFont($document_font,"",$document_font_size + 2); $pdf->SetXY($left_col,$curr_row); $pdf->Cell($title_width,$incr,"No Transactions Found",'0',0,'L',false,'',0); } else { $pdf->SetFont($document_font,"",$document_font_size + 2); $pdf->SetXY($left_col,$curr_row); $pdf->Cell($title_width,$incr,"Transactions",'0',0,'L',false,'',0); $curr_row += $incr + 2; $pdf->SetFont($document_font,"",$document_font_size); $columns = array(30,100,30,30); $alignment = array('L','L','R','R','R'); $headers = array("Date","Description","Amount","Total"); $col = $left_col; for ($i = 0; $i < count($headers); $i++) { $width = $columns[$i]; $pdf->SetXY($col,$curr_row); $pdf->Cell($width,$incr,$headers[$i],'1',0,$alignment[$i],true,'',0); $col += $width; } $curr_row += $incr; $total = 0; while ($row = db_fetch_array($transactions)) { switch ($row['transaction_type']) { case 'Order': $description = translateText($row['note']); $amount = $row['transaction_amount']; $total += $row['transaction_amount']; $sign = ""; break; case 'Tax Charge': default: $description = translateText($row['transaction_type']) . ": " . translateText($row['note']); $amount = $row['transaction_amount']; $total += $row['transaction_amount']; $sign = ""; break; case 'Payment': $description = translateText($row['payment_method']) . ' ' . translateText($row['transaction_type']) . ": " . translateText($row['note']); $amount = $row['transaction_amount']; $total += $row['transaction_amount']; $sign = "-"; break; } $tsign = ""; if ($total < 0) $tsign = "-"; $data = array(date($school_record['date_format'],$row['entered_time']), $description, $sign . $currencySymbol . number_format(abs($amount),2), $tsign . $currencySymbol . number_format(abs($total),2)); // Display the data $col = $left_col; for ($i = 0; $i < count($data); $i++) { $width = $columns[$i]; $pdf->SetXY($col,$curr_row); $pdf->Cell($width,$incr,$data[$i],'1',0,$alignment[$i],false,'',0); $col += $width; } $curr_row += $incr; } } // Print current account balance $tsign = ""; if ($total < 0) $tsign = "-"; $curr_row += $incr; $pdf->SetFillColor(230,230,230); $pdf->SetXY($left_col,$curr_row); $pdf->Cell(190,$incr,"Current Account Balance: " . $tsign . $currencySymbol . number_format($total,2),'1',0,'R',true,'',0); // 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=account-receipt.pdf"); header('Content-Transfer-Encoding: binary'); $pdf->Output("account-receipt.pdf","D"); return; ?>