<?php if (true === $this->no_stores): ?>
	<script type="text/javascript">
	//<![CDATA[
	Jsw.onReady(function() {
		new Jsw.Hint({
			renderTo: 'main',
			hint: <?php echo $this->safetyJs('TRANS_NO_INVOICES_TO_PAY'); ?>
		});
	});
	//]]>
	</script>
<?php else:?>

<?php echo $this->partial('partials/page-hint.phtml', array("hint_desc" => "TRANS_PAY_INVOICES_PAGE_DESC")); ?>
	<div id="<?php echo $this->renderTo; ?>-form-tabs"></div>
	<?php if (1 < $this->tabsCount): ?>
	<?php echo $this->partial('partials/tabs.phtml', array('tabs' => $this->tabs, 'renderTo' => "{$this->renderTo}-form-tabs")); ?>
	<?php endif;?>
	<div id="billing-invoices-pay-list">
		<div class="list-box">
			<div class="box-area">
				<div class="content">
					<div class="content-area">
						<div class="list">
							<table>
								<tbody>
									<tr>
										<th><?php echo blmsg('TRANS_INVOICE_NUMBER'); ?></th>
										<th><?php echo blmsg('TRANS_AMOUNT'); ?></th>
										<th><?php echo blmsg('TRANS_AMOUNT_PAID'); ?></th>
										<th><?php echo blmsg('TRANS_DATE_GENERATED'); ?></th>
										<th><?php echo blmsg('TRANS_DATE_DUE'); ?></th>
										<th><?php echo blmsg('TRANS_STATUS'); ?></th>
										<th><?php echo blmsg('TRANS_AMOUNT_DUE'); ?></th>
										<?php foreach ($this->pay_form["secondary"] as $gateway): ?>
											<th><?php echo $gateway; ?></th>
										<?php endforeach; ?>
									</tr>
									<?php foreach ($this->pay_form["invoices"] as $invoice): ?>
										<tr>
											<td><?php echo $invoice["invoice_number"]; ?></td>
											<td><?php echo BillingLocale::getCurrency($invoice["invoice_amount"], $invoice["currency_id"]); ?></td>
											<td><?php echo BillingLocale::getCurrency($invoice["invoice_amount_paid"], $invoice["currency_id"]); ?></td>
											<td><?php echo BillingLocale::getDateMedium($invoice["invoice_date_entered"]); ?></td>
											<td><?php echo BillingLocale::getDateMedium($invoice["invoice_date_entered"]); ?></td>
											<td><?php echo blmsg($this->invoice_statuses[$invoice["invoice_status"]]); ?></td>
											<td><?php echo BillingLocale::getCurrency($invoice["invoice_amount_due"], $invoice["currency_id"]); ?></td>
											<?php foreach ($this->pay_form["secondary"] as $gateway): ?>
												<td><?php echo $invoice["secondary"][$gateway][0]["paymentForm"]; ?></td>
											<?php endforeach; ?>
										</tr>
									<?php endforeach; ?>
									<tr>
										<td colspan="6" align="right"><?php echo blmsg('TRANS_TOTAL_TO_PAY'); ?></td>
										<td><?php echo BillingLocale::getCurrency($this->pay_form["total_amount_due"], $this->pay_form["currency_id"]); ?></td>
										<?php foreach ($this->pay_form["secondary"] as $gateway): ?>
										<td>&nbsp;</td>
										<?php endforeach; ?>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<?php echo $this->form; ?>
		<?php if ($accountsElement = $this->form->getElement('accounts')): ?>
			<script type="text/javascript">
				//<![CDATA[
				Jsw.namespace('Billing.Invoices.Pay');
				Billing.Invoices.Pay = {
					updateControlsState: function() {
						var accountValue = $('<?php echo $accountsElement->getId(); ?>').value;
						var accounts = $('main').getElementsBySelector('[id^="account_"][class^="form-box"]');
						for(var i = 0; i < accounts.length; i++) {
							if (accounts[i] == null)
								continue;
		
							accounts[i].hide();
						}
						if ($('account_'+accountValue) != null)
							$('account_'+accountValue).show();
					}
				}
				Jsw.onReady(function() {
					$('<?php echo $accountsElement->getId(); ?>').observe('change', Billing.Invoices.Pay.updateControlsState);
					Billing.Invoices.Pay.updateControlsState();
				});
				//]]>
			</script>
		<?php endif; ?>
	<?php endif; ?>