<?php $table_open = '<table cellspacing="0" cellpadding="4" border="0" class="mainTable store_table">'; ?>

<style>
div.report { font-size: 66%; }

table
{
	width: 100%;
}

table td, table th
{
	text-align: left;
	border: 1px black solid;
}

table.no_border td
{
	border: none;
}

table td.empty
{
	border: none;
	background-color: #FFFFFF;
}

table tr.even
{
	background-color: #EBF0F2;
}

table tr.odd
{
	background-color: #F4F6F6;
}

div.header_right
{
	text-align: right;
}
</style>
<div class="report">

<h1><?= $report_title ?></h1>
<div class="header_right"><?= $header_right ?></div>
<strong><?= lang('order_details') ?></strong>
<br />
<?= $table_open ?>
	<thead>
	<tr>
		<th width="13%"><?= lang('order_id') ?></th>
		<th width="20%"><?= lang('member') ?></th>
		<th width="20%"><?= lang('order_total') ?></th>
		<th width="17%"><?= lang('paid?') ?></th>
		<th width="30%"><?= lang('order_status') ?></th>
	</tr>
	</thead>
	<tbody>
	<tr>
		<td width="13%"><?= $order['order_id'] ?></td>
		<td width="20%"><?= $order['screen_name'] ?></td>
		<td width="20%"><?= $order['order_total'] ?></td>
		<td width="17%"><?= $order['order_paid_str'] ?></td>
		<td width="30%">
			<?= $order['order_status_html'] ?>
			<?php if ($order['order_completed_date']): ?>
				(<?= $this->localize->set_human_time($order['order_status_updated']) ?>)
			<?php endif ?>
		</td>
	</tr>
	</tbody>
</table>
<table class="no_border" width=100% cellspacing="0" cellpadding="4" border=0>
	<tr>
		<td style="vertical-align:top">
			<table class="mainTable store_table" width=100% cellspacing="0" cellpadding="4" border=0 style="padding-right:10px;">
				<tr>
					<td width="40%" class="top_td_no_header"><strong><?= lang('billing_name') ?></strong></td>
					<td width="60%" class="top_td_no_header"><?= $order['billing_name'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('billing_address') ?></strong></td>
					<td width="60%"><?= $order['billing_address_full'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('billing_phone') ?></strong></td>
					<td width="60%"><?= $order['billing_phone'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('order_email') ?></strong></td>
					<td width="60%"><?= $order['order_email'] ?></td>
				</tr>
				<?php foreach ($order_fields as $field_name => $field): ?>
					<?php if (strpos($field_name, 'order_custom') !== FALSE AND ! empty($order[$field_name.'_name'])): ?>
						<tr>
							<td width="40%"><strong><?= $order[$field_name.'_name'] ?></strong></td>
							<td width="60%"><?= $order[$field_name] ?></td>
						</tr>
					<?php endif; ?>
				<?php endforeach; ?>
			</table>
		</td>
		<td style="vertical-align:top">
			<table class="mainTable store_table" width=100% cellspacing="0" cellpadding="4" border=0 style="padding-left:10px;">
				<tr>
					<td width="40%" class="top_td_no_header"><strong><?= lang('shipping_name') ?></strong></td>
					<td width="60%" class="top_td_no_header"><?= $order['shipping_name'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('shipping_address') ?></strong></td>
					<td width="60%"><?= $order['shipping_address_full'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('shipping_phone') ?></strong></td>
					<td width="60%"><?= $order['shipping_phone'] ?></td>
				</tr>
				<tr>
					<td width="40%"><strong><?= lang('shipping_method') ?></strong></td>
					<td width="60%"><?= $order['shipping_method'] ?></td>
				</tr>
				<?php if ($order['promo_code']): ?>
					<tr>
						<td><strong><?= lang('promo_code') ?></strong></td>
						<td><?= $order['promo_code'] ?></td>
					</tr>
				<?php endif; ?>
			</table>
		</td>
	</tr>
</table>
<br />
<strong><?= lang('items') ?></strong>
<br />
<?= $table_open ?>
	<thead>
	<tr>
		<th width="5%">#</th>
		<th width="20%"><?= lang('product') ?></th>
		<th width="13%"><?= lang('sku') ?></th>
		<th width="32%"><?= lang('modifiers') ?></th>
		<th width="10%"><?= lang('price') ?></th>
		<th width="10%"><?= lang('quantity') ?></th>
		<th width="10%"><?= lang('total') ?></th>
	</tr>
	</thead>
	<tbody>
	<?php foreach ($order['items'] as $item): ?>
		<tr>
			<td width="5%"><?= $item['entry_id'] ?></td>
			<td width="20%"><?= $item['title'] ?></td>
			<td width="13%"><?= $item['sku'] ?></td>
			<td width="32%"><?= $item['modifiers_desc'] ?></td>
			<td width="10%"><?= $item['price'] ?></td>
			<td width="10%"><?= $item['item_qty'] ?></td>
			<td width="10%"><?= $item['item_subtotal'] ?></td>
		</tr>
	<?php endforeach ?>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2"><?= lang('order_subtotal') ?></td>
		<td><?= $order['order_subtotal'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2"><?= lang('order_discount') ?></td>
		<td><?= $order['order_discount'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2"><?= lang('order_shipping').' ('.$order['shipping_method'].')' ?></td>
		<td><?= $order['order_shipping'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2"><?= empty($order['tax_name']) ? lang('order_tax') : lang('order_tax').' ('.$order['tax_name'].' @ '.((double)$order['tax_rate']*100).'%)' ?></td>
		<td><?= $order['order_tax'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2" style="font-weight:bold"><?= lang('order_total') ?></td>
		<td style="font-weight:bold"><?= $order['order_total'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2"><?= lang('paid') ?></td>
		<td><?= $order['order_paid'] ?></td>
	</tr>
	<tr>
		<td colspan="4" class="empty"></td>
		<td colspan="2" style="font-weight:bold"><?= lang('balance_due') ?></td>
		<td style="font-weight:bold"><?= $order['order_owing'] ?></td>
	</tr>
	</tbody>
</table>
<br />
<strong><?= lang('payments') ?></strong>
<br />
<?= $table_open ?>
	<thead>
	<tr>
		<th width="5%">#</th>
		<th width="10%"><?= lang('payment_method') ?></th>
		<th width="15%"><?= lang('reference') ?></th>
		<th width="20%"><?= lang('payment_message') ?></th>
		<th width="10%"><?= lang('amount') ?></th>
		<th width="20%"><?= lang('payment_date') ?></th>
		<th width="10%"><?= lang('recorded_by') ?></th>
		<th width="10%"><?= lang('payment_status') ?></th>
	</tr>
	</thead>
	<tbody>
	<?php if (empty($order_payments)): ?>
		<tr>
			<td colspan="8"><em><?=lang('no_payments')?></em></td>
		</tr>
	<?php else: ?>
		<?php foreach ($order_payments as $payment): ?>
			<tr>
				<td width="5%"><?= $payment['payment_id'] ?></td>
				<td width="10%"><?= $payment['payment_method_title'] ?></td>
				<td width="15%"><?= $payment['reference'] ?></td>
				<td width="20%"><?= $payment['message'] ?></td>
				<td width="10%"><?= store_format_currency($payment['amount']) ?></td>
				<td width="20%"><?= $this->localize->set_human_time($payment['payment_date']) ?></td>
				<td width="10%"><?= $payment['payment_member'] ?></td>
				<td width="10%"><?= store_payment_status($payment['payment_status']) ?></td>
			</tr>
		<?php endforeach ?>
	<?php endif ?>
	</tbody>
</table>

<div><?= $footer ?></div>

</div>