<!DOCTYPE html>
<html>
	<head>
		<style>
			html {
				font-family: sans-serif;
				font-size:12px
			}
			p{
				margin-top: 5px;
			}
			table {
				border-collapse: collapse;
			}

			table, th, td {
				border: 1px solid black;
				padding:5px;
			}
		</style>
			<title>Laporan Approval Reimburse</title>
	</head>
	<body>
		<p style="text-align:center"><b>LAPORAN APPROVAL REIMBURSE</b></p>
		<p style="text-align:center"><b><?= $title ?></b></p>
		<p style="text-align:center"><b><?= "PERIODE ".$tgl_awal." S/D ".$tgl_akhir; ?></b></p>

		<table width="100%">
			<thead style="background-color: #1062b1;color: #fff;font-weight: 600;">
				<tr>
					<th>NO</th>
					<th>TANGGAL</th>
					<th>NO PENGAJUAN</th>
					<th>CABANG<BR>DEPARTEMEN</th>
					<th>KARYAWAN</th>
					<th>PLATFON</th>
					<th>KETERANGAN</th>
					<th>PLATFON MAX</th>
					<th>NOMINAL DIAJUKAN</th>
					<th>NOMINAL DISETUJUI</th>
				</tr>
			</thead>
			<tbody>
				<?php
					if(isset($list_data)) {

						$no = 0;
						$ttl_nominal_pengajuan = 0;
						$ttl_nominal_disetujui = 0;
						foreach ($list_data as $val) {
							$no++;
							$data_reimburse = $this->fungsi->data_reimburse($val->id_pengajuan);

							$jumlah_row = $data_reimburse->num_rows()+1;
				?>
							<tr>
								<td rowspan="<?= $jumlah_row ?>" style="text-align:center"><?= $no ?></td>
								<td rowspan="<?= $jumlah_row ?>" style="text-align:center"><?= date('d-m-Y', strtotime($val->tgl_pengajuan));?></td>
								<td rowspan="<?= $jumlah_row ?>"><?= "<b>".$val->no_pengajuan."</b><br>".$val->keterangan ?></td>
								<td rowspan="<?= $jumlah_row ?>"><?= "<b>".$val->kode_cabang."</b> - ".$val->nama_cabang."<br><b>".$val->kode_departemen."</b> - ".$val->nama_departemen ?></td>
								<td rowspan="<?= $jumlah_row ?>"><?= $val->nama_karyawan."<br><b>".$val->nik."</b>" ?></td>
								<?php

									$nominal_pengajuan = 0;
									$nominal_disetujui = 0;
									foreach ($data_reimburse->result() as $dat) {
										$nominal_pengajuan = $nominal_pengajuan + $dat->nominal;
										$nominal_disetujui = $nominal_disetujui + $dat->nominal_disetujui;

										$ttl_nominal_pengajuan = $ttl_nominal_pengajuan + $dat->nominal;
										$ttl_nominal_disetujui = $ttl_nominal_disetujui + $dat->nominal_disetujui;
								?>
												<td><?= $dat->jenis_plafon; ?></td>
												<td><?= $dat->keterangan; ?></td>
												<td style="text-align:right"><?= number_format($dat->max_plafon,0,",","."); ?></td>
												<td style="text-align:right"><?= number_format($dat->nominal,0,",","."); ?></td>
												<td style="text-align:right"><?= number_format($dat->nominal_disetujui,0,",","."); ?></td>
										</tr>
								<?php
										}
								?>
						<tr style="font-weight: bold;">
							<td style="text-align: center;" colspan="3">SUB TOTAL</td>
							<td style="text-align:right"><?= number_format($nominal_pengajuan,0,",","."); ?></td>
							<td style="text-align:right"><?= number_format($nominal_disetujui,0,",","."); ?></td>
						</tr>
						<tr>
							<td colspan="10">&nbsp;</td>
						</tr>
				<?php
						}
				?>

				<tr style="font-weight: bold; font-size:14px">
					<td colspan="8" style="text-align:right">TOTAL</td>
					<td style="text-align:right"><?= number_format($ttl_nominal_pengajuan,0,",","."); ?></td>
					<td style="text-align:right"><?= number_format($ttl_nominal_disetujui,0,",","."); ?></td>
				</tr>
				<?php
					}else{
						echo "<center></center>";
					}
				?>
			</tbody>
		</table>
	</body>
</html>