
<?php 

// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB; ?>">
<?php
// BOF: Lango Added for template MOD
if (SHOW_HEADING_TITLE_ORIGINAL == 'yes') {
$header_text = '&nbsp;'
//EOF: Lango Added for template MOD
?>
	<tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
				<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_history.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
			</tr>
		</table></td>
	</tr>
<?php
// BOF: Lango Added for template MOD
}else{
$header_text = HEADING_TITLE;
}
// EOF: Lango Added for template MOD
	if(!isset($hide_row_top)) {
?>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	</tr>
<?php
	}
// BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
table_image_border_top(false, false, $header_text);
}
// EOF: Lango Added for template MOD
?>

	<?php
	
		$history_query_raw = 	"select o.orders_id, o.date_purchased, op.products_id, op.products_tax, op.products_name, op.final_price,op.products_tax,op.products_type from " . 
								TABLE_ORDERS . " o, " . TABLE_ORDERS_PRODUCTS . " op where o.customers_id = '" . (int)$customer_id . "' and op.products_type in('P','E','S') and o.orders_id=op.orders_id order by op.products_type,o.orders_id,o.date_purchased desc";
		
		$history_query=tep_db_query($history_query_raw);
		
		$history_split = new splitPageResults($history_query_raw, MAX_DISPLAY_SEARCH_RESULTS);
		if ( ($history_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {

		$rows=0;
		if ($history_split->number_of_rows > 0) {
		$history_query = tep_db_query($history_split->sql_query);
		if (tep_db_num_rows($history_query)){	
	?>
	<tr>
    <td class="smallText"><?php echo $history_split->display_count(TEXT_DISPLAY_NUMBER_OF_CURRENT); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $history_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
	<?php while ($history = tep_db_fetch_array($history_query)) {
		   if($history['products_type']=='P'){
			$type=TEXT_PRODUCT_NAME;
			$filename=FILENAME_TELL_A_FRIEND;
			$path='products_id=' . $history["products_id"].'&return=as';
		   }else if($history['products_type']=='E'){
			$type=TEXT_EVENT_NAME;
			$filename=FILENAME_EVENTS_INVITE_FRIEND;
			$path="eID=".$history['products_id'].'&path=ASU';
		  }else{
			$type=TEXT_SUBSCRIPTION_NAME;
			$filename=FILENAME_SUBSCRIPTION_INVITE_FRIEND;
			$path='suID='.$history['products_id'].'&path=ASC';
		 }
				$rows++; ?>
	<tr>
		<td>
				<table border="0" width=100% cellspacing="0" cellpadding="2">
					<tr>
						<td class="main">
						<?php 
							echo '<b>' . $type . '</b>&nbsp;'.$history['products_name'] .'<a href="' . tep_href_link($filename,tep_get_all_get_params() . $path) . '"> ' .  '&nbsp;' . tep_image(DIR_WS_ICONS . 'invite.gif',IMAGE_INVITE_FRIEND,24,24,'align=absmiddle') . '</a>';
						?>
						</td>
	      				<td class="main" width=100>
						<?php
							echo '<b>' . TEXT_ORDER_ID . '</b>&nbsp;' .$history['orders_id'];
						?>
						</td>
					</tr>
					<tr>
						<td class="main" valign="top"><?php echo '<b>' . TEXT_COSTS . '</b> ' . $currencies->display_price($history['final_price'],$history['products_tax']); ?></td>
					</tr>
			</table>
	  </td>
	</tr>
		<tr>
		  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
	<?php
		}
	} else {
	?>
		<table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
			<tr class="infoBoxContents">
				<td><table border="0" width="100%" cellspacing="2" cellpadding="4">
					<tr>
						<td class="main"><?php echo TEXT_NO_SUBSCRIPTIONS; ?></td>
					</tr>
				</table></td>
			</tr>
		</table>
	<?php
	}
}
}
	?>
	    </td>
	</tr>
	<?php
	// BOF: Lango Added for template MOD
	if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_bottom();
	}
	// EOF: Lango Added for template MOD
	?>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	</tr>
	<tr>
		<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
			<tr class="infoBoxContents">
				<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr>
						<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
						<td><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_template_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
						<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
					</tr>
				</table></td>
			</tr>
		</table></td>
	</tr>
</table>
