<!-- @todo NEED to translate this -->
<table class="box-left" border="0">
	<tr>
		<td style="vertical-align: top">
			<table class="company_details" border="0">
				<tr>
					<td class="logo"><?php echo Config::logo(); ?></td>
					<td class="address"><span class="company_name"><?php echo Company::name(); ?></span><br/><?php echo Company::address(); ?><br/><?php echo Company::contacts(); ?></td>
				</tr>
			</table>
		</td>
		<td>&nbsp;</td>
		<td>
			<table class="invoice_summary" border="0">
				<tr>
					<td>TAX INVOICE</td>
					<td class="bold-right"><?php echo $io->id(); ?></td>
				</tr>
				<tr>
					<td>Issue Date</td>
					<td class="bold-right"><?php echo $io->display('date_orig'); ?></td>
				</tr>
				<tr>
					<td>Due Date</td>
					<td class="bold-right"><?php echo $io->display('due_date'); ?></td>
				</tr>
				<tr>
					<td>Current Charges</td>
					<td class="bold-right"><?php echo $io->total(TRUE); ?></td>
				</tr>
				<tr>
					<td>Payments Received to Date</td>
					<td class="bold-right"><?php echo $io->payments_total(TRUE); ?></td>
				</tr>
				<tr>
					<td>Total Charges Due This Invoice</td>
					<td class="bold-right"><?php echo $io->due(TRUE); ?></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr><td class="spacer" colspan="3">&nbsp;</td></tr>
	<tr>
		<td colspan="3">
			<table class="box-full" border="0">
				<tr>
					<td class="head" colspan="4">Charges Detail:</td>
				</tr>
				<?php foreach ($io->items_service_periods() as $rs => $items) { ?>
					<tr>
						<td>+</td>
					<?php if ($rs) { ?>
						<td><?php echo StaticList_RecurSchedule::display($rs); ?></td>
						<td colspan="1"><?php printf('%s Service(s)',count($items)); ?></td>
					<?php } else { ?>
						<td colspan="2">Other Items</td>
					<?php } ?>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td colspan="2">
							<div id="detail_toggle_<?php echo $rs; ?>">
								<table class="box-full" border="0">
								<?php if ($items) { ?>
									<?php foreach ($io->items_services($items) as $sid => $ito) { ?>
										<?php $so = ORM::factory('service',$sid); ?>
									<!-- Product Information -->
									<tr class="head">
										<td><?php echo $so->id(); ?></td>
										<td colspan="5"><?php echo $so->service_name(); ?> (<?php echo $so->product_id; ?>)</td>
										<td class="right"><?php echo Currency::display($io->items_service_total($so->id));?></td>
									</tr>
									<!-- End Product Information -->

										<?php foreach ($io->items_service($sid) as $ito) { ?>
									<!-- Product Sub Information -->
									<tr>
										<td>&nbsp;</td>
										<td><?php echo $ito->trannum();?></td>
										<td><?php echo $ito->name();?></td>
										<td><?php echo $ito->detail();?></td>
										<td><?php echo $ito->period();?></td>
										<td class="right"><?php echo Currency::display($ito->subtotal());?>&nbsp;</td>
									</tr>
									<!-- End Product Sub Information -->

										<?php if ($ito->discount_amt) { ?>
									<tr>
										<td colspan="4">&nbsp;</td>
										<td><?php echo _('Discounts'); ?></td>
										<td class="right">(<?php echo Currency::display($io->items_service_discount($so->id));?>)</td>
									</tr>
										<?php } ?>
									<!-- Product Sub Items Tax -->
									<tr>
										<td colspan="4">&nbsp;</td>
										<td><?php echo _('Taxes'); ?></td>
										<td class="right"><?php echo Currency::display($io->items_service_tax($so->id));?>&nbsp;</td>
									</tr>
									<!-- Product End Sub Items Tax -->
									<?php } ?>
										<?php } ?>
								<?php } ?>
								</table>
							</div>
						</td>
					</tr>
				<?php } ?>
				<tr>
					<td class="head" colspan="3">Sub Total of Items:</td>
					<td class="bold-right"><?php echo $io->subtotal(TRUE); ?>&nbsp;</td>
				</tr>
				<?php if ($io->discount()) { ?>
				<tr>
					<td class="head" colspan="3">Discounts:</td>
					<td class="bold-right">(<?php echo $io->discount(TRUE); ?>)</td>
				</tr>
				<?php } ?>
				<tr>
					<td class="head" colspan="4">Taxes Included:</td>
				</tr>
				<?php
					foreach ($io->tax_summary() as $tid => $amount) {
						$m = ORM::factory('tax',$tid);
				?>
				<tr>
					<td>&nbsp;</td>
					<td colspan="2"><?php echo $m->description; ?></td>
					<td class="bold-right"><?php echo Currency::display($amount); ?>&nbsp;</td>
				</tr>
				<?php }?>
				<!-- @todo Add discounts -->
				<tr>
					<td class="head" colspan="3">Total This Invoice:</td>
					<td class="bold-right"><?php echo $io->total(TRUE); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="head" colspan="3">Total Outstanding This Account:</td>
					<td class="bold-right"><?php echo $io->account->invoices_due_total(NULL,TRUE); ?>&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
