<?php
use app\libraries\CommonHelper;
$totalpayment = 0;
date_default_timezone_set("Asia/Hong_Kong");
foreach ($items as $item) {
	$paydate = date('Y-m-d g:ia', $item['payment_date']);
	$totalpayment += floatval(trim($item['amount_paid']));
	$payment_item = '';
	switch ($item['payment_type_id']) {
		case PaymentType::Cheque:
			$payment = CommonHelper::currency($item['cheque_amount']);
			$payment_desc = $paydate . ' 支票<br />' . $item['cheque_bank_name'] . ' ' . $item['cheque_no'];
			break;
		case PaymentType::ATM:
			$payment = CommonHelper::currency($item['atm_amount']);
			$payment_desc = $paydate . ' 入數紙';
			break;
		case PaymentType::Cash:
			$payment = CommonHelper::currency($item['cash_amount']);
			$payment_desc = $paydate . ' 現金';
			break;
	}
?>
	<tr style="border-bottom: <?=$THEME_THEAD_COLOR_BORDER_BOTTOM;?> dotted;">
		<td colspan="4" style="text-align: left; padding-top: 5px;">付款方式: <?=$payment_desc;?></td>
		<td style="text-align: right; padding-right: 10px; padding-top: 5px;"><?=$payment?></td>
	</tr>
<?php
}
?>
<tr style="border-bottom: <?=$THEME_THEAD_COLOR_BORDER_BOTTOM;?> dotted;">
	<td colspan="4" style="text-align: right;  color: black"> <span> 付款總額:
      </span> </td>
	<td style="text-align: right; padding: 12px 10px 12px 0px;  ">
		<div style="border-bottom: 0.5px double grey;"><?=CommonHelper::currency($totalpayment);?></div>
	</td>
</tr>
