<style>
	table.datatables{ order: 2px solid #444 !important; }
	table.datatables th, .datatables td { border: 1px solid #444 !important; }
	table.datatables th { background-color: #F9F9F9 !important; }
	table.datatables th.header { background-color: #F4F4F4 !important; }
	table.datatables tr.total td,
	table.datatables tr.total th { font-weight: bold !important; }
</style>
<script>
$(document).ready(function() {
	$('td.blk5').prepend('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	$('td.blk10').prepend('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
});
</script>


<section class="container">
	<h3>Penyata Kunci Kira-kira</h3>
	<table width="100%" class="datatables">
		<thead>
			<tr>
				<th rowspan="2" class="col-sm-8">Perkara</th>
				<th class="text-center col-sm-2 year_curr"><?php echo $years[0]; ?></th>
				<th class="text-center col-sm-2 year_prev"><?php echo $years[1]; ?></th>
			</tr>
			<tr><th class="text-center col-sm-2">RM</th><th class="text-center col-sm-2">RM</th></tr>
		</thead>
		
		<tbody>
		<?php
		if($parents && $pos && $years) {
			foreach($parents as $parID=>$parDet) {
				if(isset($pos[$parID]) && $pos[$parID]) {
					foreach($pos[$parID] as $grpID=>$grpDet) {
						$total = NULL;
						?>
						<tr class="pagebreak"><th class="header" colspan="3"><?php echo $this->lang->line(strtolower($grpDet['section'])); ?></th></tr>
						<?php
						if($grpDet['details']) {
							foreach($grpDet['details'] as $accID=>$accDet) {
								?>
								<tr>
									<td class="blk10"><?php echo $accDet['name']; ?></td>
									<?php
									foreach($years as $y=>$year) {
										if(!isset($total[$year])) $total[$year] = 0;
										$total[$year] += $accDet['data'][$year];
										?><td class="text-center col-sm-2" id="fp_item_<?php echo $parID; ?>_<?php echo $parID; ?>_<?php echo $grpID; ?>_<?php echo $accID; ?>_<?php echo $y; ?>"><?php echo number_format($accDet['data'][$year],2); ?></td><?php
									}
									?>
								</tr>
								<?php
							}
							?>
							<tr class="total">
								<td class="blk10">Jumlah</td>
								<?php
								foreach($years as $y=>$year) {
									?><td class="text-center col-sm-2" id="fp_total_<?php echo $parID; ?>_<?php echo $parID; ?>_<?php echo $grpID; ?>_<?php echo $y; ?>"><?php echo number_format($total[$year],2); ?></td><?php
								}
								?>
							</tr>
							<?php
						}	
						?><tr><td colspan="3">&nbsp;</td></tr><?php
					}
				}
				
				if($parDet['section']) {
					foreach($parDet['section'] as $sectID=>$sectDet) {
						if(isset($pos[$sectID]) && $pos[$sectID]) {
							foreach($pos[$sectID] as $grpID=>$grpDet) {
								$total = NULL;
								?>
								<tr class="pagebreak"><th colspan="3"><?php echo $this->lang->line(strtolower($grpDet['section'])); ?></th></tr>
								<?php
								if($grpDet['details']) {
									foreach($grpDet['details'] as $accID=>$accDet) {
										?>
										<tr>
											<td class="blk10"><?php echo $accDet['name']; ?></td>
											<?php
											foreach($years as $y=>$year) {
												if(!isset($total[$year])) $total[$year] = 0;
												$total[$year] += $accDet['data'][$year];
												?><td class="text-center col-sm-2" id="fp_item_<?php echo $parID; ?>_<?php echo $sectID; ?>_<?php echo $grpID; ?>_<?php echo $accID; ?>_<?php echo $y; ?>"><?php echo number_format($accDet['data'][$year],2); ?></td><?php
											}
											?>
										</tr>
										<?php
									}
									?>
									<tr class="total">
										<td class="blk10">Jumlah</td>
										<?php
										foreach($years as $y=>$year) {
											?><td class="text-center col-sm-2" id="fp_total_<?php echo $parID; ?>_<?php echo $sectID; ?>_<?php echo $grpID; ?>_<?php echo $y; ?>"><?php echo number_format($total[$year],2); ?></td><?php
										}
										?>
									</tr>
									<tr><td colspan="3">&nbsp;</td></tr>
									<?php
								}
							}
							?>
							<tr class="total">
								<td class="blk5"><?php echo $this->lang->line(strtolower($sectDet['name'])); ?></td>
								<?php
								foreach($years as $y=>$year) {
									?><td class="text-center col-sm-2" id="fp_sub_<?php echo $parID; ?>_<?php echo $sectID; ?>_<?php echo $grpID; ?>_<?php echo $y; ?>"><?php echo number_format($sectDet['total'][$year],2); ?></td><?php
								}
								?>
							</tr>
							<?php
						}
					}
				}
				?>
				<tr class="total">
					<td><?php echo $this->lang->line(strtolower($parDet['name'])); ?></td>
					<?php
					foreach($years as $y=>$year) {
						?><td class="text-center col-sm-2" id="fp_grand_<?php echo $parID; ?>_<?php echo $y; ?>"><?php echo number_format($parDet['total'][$year],2); ?></td><?php
					}
					?>
				</tr>
				<tr><td colspan="3">&nbsp;</td></tr>
				<?php
			}
		}
		?>
		</tbody>
		
	</table>
	
	
	<br><br>
	<div class="row">
		<div class="col-xs-12">
			<div class="tableTitle">
					PENGESAHAN
			</div>
			<table class="datatables" width = "100%">
					<tr>
							<th class="subheader" width="25%" colspan="2">JURUAUDIT I</th>
							<th class="subheader" width="25%" colspan="2">JURUAUDIT II</th>
							<th class="subheader" width="25%" colspan="2">DISEMAK</th>
							<th class="subheader" width="25%" colspan="2">DIPERAKUI</th>
					</tr>
					<tr>
							<td class="text-center">TANDATANGAN</td>
							<td class="text-center">TARIKH</td>
							<td class="text-center">TANDATANGAN</td>
							<td class="text-center">TARIKH</td>
							<td class="text-center">TANDATANGAN</td>
							<td class="text-center">TARIKH</td>
							<td class="text-center">TANDATANGAN</td>
							<td class="text-center">TARIKH</td>
					</tr>
					<tr>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
					</tr>
			</table>
		</div>
   </div>
		
</section>
