<?php
	/***********************************************************************************
	*   Filename    : register_thanks.php
   	*
	*   Copyright Keysoft Pty Ltd 2009
	***********************************************************************************/

	/******************** Global Settings ********************/
	require_once '../phpobjects/common/global.php';

	/********************* Page Settings *********************/
	$gaPage['title'] = 'Petsafe.com.au';
	$gaPage['root_directory'] = '..';
	$gaPage['colour'] = 'orange';
	
	/********************* Page Defaults *********************/
	fDefaultParameter('err_code', $_GET, '');
	
	fDefaultParameter('id', $_GET, '');
	
	$payment_reference = $_GET['id'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<?php require '../phpobjects/templates/common/page_head.php'; ?>
</head>

<?php

require '../phpobjects/templates/common/page_header.php';
/*********************** Page Start **********************/
?>

<td valign="top">

<br/><h2 class="orangeheading">Invoice Payment: Complete</h2><br/>

<div class="boldtext">Thankyou, You have successfully paid your invoice(s).</div>
<br/><br/>

<?php
	//show invoice details
	if ($payment_reference != ''){
		$aRequest = array();
//		$aRequest['_pk_invoice_id'] = '="' . $invoice_id . '"';
		$aRequest['payment_reference'] = '="' . $payment_reference . '"';
		$fmrInvoice = fFMPerformFind('petsafe', 'Web - Invoice', $aRequest);

		if ($fmrInvoice === FALSE){
				// invoice not found
		}else{
			$rowstyle = "tr1";
			echo '<table class="tbl" width="100%" border="0" cellspacing="0" cellpadding="5">';
			echo '	<tr>';
			echo '		<td class="tableheader"><b>Invoice Number</b></td>';
			echo '		<td class="tableheader" colspan="2"><b>PayFlow Reference No.</b></td>';

			echo '	</tr>';
			$fmcInvoice = $fmrInvoice["response"]["data"];

			foreach ($fmcInvoice as $invoice_record){
				$payment_reference = $invoice_record['fieldData']['payment_reference'];
				$invoiceNumber = $invoice_record['fieldData']['_pk_invoice_id'];
				$invoiceNumber = substr('00000000' . $invoiceNumber, -8, 8);
				echo '<tr class="'.$rowstyle.'">';
				echo '<td>'.$invoiceNumber.'<td>';
				echo '<td>'.$payment_reference.'</td>';
				echo '</tr>';
				if ($rowstyle == "tr1"){
					$rowstyle = "tr2";
				} else {
					$rowstyle = "tr1";
				}
			}


			echo '	<tr>';
			echo '		<td class="tablesummary" colspan="3"><a href="invoice_list.php" style="color:blue;">Pay another invoice</a></td>';
			echo '	</tr>';
			echo '</table>';
		}
		
	}
?>


</td>

<?php
/************************ Page End ***********************/

require '../phpobjects/templates/common/page_footer.php';
?>

</html>
<?php fCleanup(); ?>