<?php 
	$this->load->helper('az_core');
?>
<!DOCTYPE html>
<html>
<head>
	<title>Detail</title>
</head>
<body>
	<input type="hidden" id="hd_idtrx" value="<?php echo az_encode_url($data['idtransaction_group']);?>">
	<table width="100%">
		<tr>
			<td width="50%" valign="top">
				<table>
					<tr>
						<td>Outlet</td>
						<td width="10px" align="center">:</td>
						<td><?php echo $outlet['outlet_name'];?></td>
					</tr>
					<tr>
						<td>Tgl Transaksi</td>
						<td align="center">:</td>
						<td><?php echo Date('d-m-Y H:i', strtotime($data['date']));?></td>
					</tr>
					<tr>
						<td>Tgl Selesai</td>
						<td align="center">:</td>
						<td>
							<?php 
								$duedate = '';
								if (strlen($data['duedate']) > 0) {
									$duedate = Date('d-m-Y H:i', strtotime($data['duedate']));
								}
								echo $duedate;
							?>
						</td>
					</tr>
					<tr>
						<td valign="top">Pelanggan</td>
						<td valign="top" width="10px" align="center">:</td>
						<td valign="top">
							<?php echo $data['customer_name'].'<br>'.$data['customer_address'];?>
						</td>
					</tr>
				</table>
			</td>
			<td valign="top">
				<table>
					<tr>
						<td>Kode Transaksi</td>
						<td width="10px" align="center">:</td>
						<td><?php echo $data['code'];?></td>
					</tr>
					<tr>
						<td>Status Transaksi</td>
						<td align="center">:</td>
						<td><?php echo $data['transaction_group_status'];?></td>
					</tr>
					<tr>
						<td>Hal Pembayaran</td>
						<td align="center">:</td>
						<td><?php echo $data['payment_status'];?></td>
					</tr>
					<tr>
						<td>Total Transaksi</td>
						<td align="center">:</td>
						<td><?php echo az_thousand_separator($data['grand_total_final']);?></td>
					</tr>
			        <tr>
						<td>Posisi Stock</td>
						<td align="center">:</td>
						<td style="font-size: 50px;padding-left: 30px;"><?php echo $data['stock_position']; ?></td>
					</tr>
			    	<?php 
						if ($data['transaction_group_status'] == 'Pick Up') {
					?>
					<tr>
						<td>No Gantungan</td>
						<td align="center">:</td>
						<td><?php echo $data['hanger_no'];?></td>
					</tr>
					<tr>
						<td>Rak</td>
						<td align="center">:</td>
						<td><?php echo $data['rack'];?></td>
					</tr>
					<?php
						}
					?>
				</table>
			</td>
		</tr>
	</table>
	<br>
	<table class="table table-condensed">
		<tr>
			<th>Barang</th>
			<th style="text-align: right">Harga</th>
		</tr>
		<?php 
			$total_change = $data['total_pay'] - $data['grand_total_final'];
			if ($data['payment_status'] == 'PANJAR') {
				$total_change = $data['total_pay'] - $data['total_panjar'];
			}
			foreach ($trx as $key => $value) {
		?>
		<tr>
			<td>
				<div class="trx-item">
					<?php echo $value['item_code'].' - '.$value['product_name'];?>
				</div>
				<div class="trx-item-chs">
					<?php 
						if (strlen($value['colour']) > 0) {
							echo 'Warna: '.$value['colour'].'. ';
						}
						if (strlen($value['hue']) > 0) {
							echo 'Corak: '.$value['hue'].'. ';
						}
						if (strlen($value['spot']) > 0) {
							echo 'Noda: '.$value['spot'].'. ';
						}
						if (strlen($value['trx_note']) > 0) {
							echo 'Ket: '.$value['trx_note'];
						}
					?>
				</div>
				<div>
					<?php echo $value['img'];?>
				</div>
			</td>
			<td align="right"><?php echo az_thousand_separator($value['price']);?></td>
		</tr>
		<?php
				foreach ((array) $value['arr_cost'] as $cost_key => $cost_value) {
		?>
		<tr>
			<td>+ <?php echo $cost_value['name'];?></td>
			<td align="right"><?php echo az_thousand_separator($cost_value['price']);?></td>
		</tr>
		<?php
				}
		?>
		<tr>
			<td align="right">TOTAL</td>
			<td align="right"><?php echo az_thousand_separator($value['total']);?></td>
		</tr>
		<tr>
			<td colspan="2">
				<div style="border:1px dashed #e2e1e1;"></div>
			</td>
		</tr>
		<?php
			}
		?>

		<?php
			if ($data['grand_discount'] > 0 || $data['grand_add_cost'] > 0) {
		?>
		<tr>
			<td align="right">SUBTOTAL</td>
			<td align="right"><?php echo az_thousand_separator($data['grand_total']);?></td>
		</tr>
		<?php
			if ($data['grand_discount'] > 0) {
		?>
		<tr>
			<td align="right">DISKON</td>
			<td align="right"><?php echo az_thousand_separator($data['grand_discount']);?></td>
		</tr>
		<?php
			}
		?>
		<?php
			if ($data['grand_add_cost'] > 0) {
		?>
		<tr>
			<td align="right"><?php echo $data['add_cost_note'];?></td>
			<td align="right"><?php echo az_thousand_separator($data['grand_add_cost']);?></td>
		</tr>
		<?php
			}
		?>
		<tr>
			<td align="right">GRAND TOTAL</td>
			<td align="right"><?php echo az_thousand_separator($data['grand_total_final']);?></td>
		</tr>
		<?php
			}
		?>
		<?php 
			if ($data['payment_status'] == 'PANJAR') {
		?>
		<tr>
			<td align="right">Panjar</td>
			<td align="right"><?php echo az_thousand_separator($data['total_panjar']);?></td>
		</tr>
		<?php
			}
			if ($data['payment_status'] != 'BELUM BAYAR') {
		?>
		<tr>
			<td align="right">Bayar</td>
			<td align="right"><?php echo az_thousand_separator($data['total_pay']);?></td>
		</tr>
		<tr>
			<td align="right">Kembalian</td>
			<td align="right"><?php echo az_thousand_separator($total_change);?></td>
		</tr>
		<?php
			}
		?>
	</table>
</body>
</html>