<style>
    .datatables, .table {
        border: 2px solid #444 !important;
    }
    .datatables th, .datatables td, .table th, .table td{
        border: 1px solid #444 !important;
    }
	.tableTitle{
        font-size: 1.5em;
        font-weight: bold;
    }
    .tableTitle2{
        font-size: 1.2em;
        font-weight: bold;
    }
    .tableheader1{
        width: 20%;
        font-weight: bold;
    }
    .tableheader2{
        font-weight: bold;
    }
    .subheader{
        font-weight: bold;
        text-align: center;
    }
    .subheader2{
        font-weight: bold;
    }
</style>
<script>
    $(document).ready(function(){
    });
</script>
<section class="container">
	<?php if (isset($table)) { ?>
	<div class="row">
		<div class="col-xs-12 table-responsive">
			<table width="100%" class="datatables">
				<?php if (isset($table['header'])) { ?>
					<?php
					$index = 0;
					foreach (array_combine($table['header']['reviewHeader'], $table['header']['reviewInfo']) as $header => $detail) {
					?>
						<tr>
							<th class="text-center" width="20%"><?php echo $header; ?></th>
							<td><?php echo $detail; ?></td>
						</tr>
					<?php } ?>
					<?php if (isset($table['header']['childrenInfo'])) {
						$str = 'a';
						?>
						<tr>
							<th></th>
							<td>
								<?php foreach ($table['header']['childrenInfo'] as $children):
									echo $str++.')'.'&nbsp;'.$children['text'].'<br><br>';
								endforeach; ?>
							</td>
						</tr>
					<?php } ?>
				<?php } ?>
			</table>
		</div>
	</div><br>
    <div class="clearfix">

    </div>
    <?php   ?>
		<div class="row">
			<div class="col-xs-12">
				<div class="tableTitle">
					BUTIRAN DATA PERMOHONAN
				</div>
				<br>
				<?php
				if (isset($table['body']['applicationInfo']['table'])) {
					$this->lang->load('data_col', $this->session->userdata('language'));

					//echo "<div class=\"row\">\n";
					$k = 0;
					foreach($table['body']['applicationInfo']['table'] as $key=>$value) {
						if($value['view']) {
							//echo ($k > 0 && $k%2 == 0) ? "</div><div class=\"row\">\n" : NULL;
							//if ($value['clearLeft']) { echo "</div><div class=\"row\">\n"; $k--; }
							//echo "<div class=\"col-xs-12\">\n";
							$view = APPPATH.'views/'.$value['view'];
							$view = str_replace("\\","/",$view);
							$d['data'] = $value;

							if (file_exists($view.".php")) $this->load->view($value['view'],$d);

							//echo "</div>\n";
							$k++;
							//if ($value['clearRight']) { echo "</div><div class=\"row\">\n"; $k--; }
						}
					}
				}
				?>
			</div>
		</div>
    <?php  ?>
	<?php if (isset($table['body'])) { ?>
	<div class="row">
		<div class="col-xs-12 table-responsive">
			<div class="tableTitle">
                PROSEDUR AUDIT
            </div>
			<table width="100%" class="datatables">
				<tr>
					<?php
					$index = 0;
					foreach ($table['body']['detailHeader'] as $header) {
					?>
					<th class="text-center"><?php echo $header; ?></th>
					<?php
					}
					?>
				</tr>
				<?php if(isset($table['body']['detailInfo'])) {
                    if (isset($table['body']['detailInfoHead'])) {
                        foreach ($table['body']['detailInfoHead'] as $rowHead) { ?>
                        <tr>
                            <td class="text-center" width="10%"><?php echo "<b>".$rowHead['bil']."</b>" ?></td>
                            <td>
                                <?php
                                    echo "<b>".nl2br($rowHead['text'])."</b>";
                                ?>
                            </td>
                            <td colspan="4"></td>
                        </tr>
                        <?php
                        $bil = 1;
                        foreach ($table['body']['detailInfo'][$rowHead['ID']] as $row) { ?>
                                <tr>
                                    <td class="text-center" width="10%"><?php echo $row['bil'].'-'.$bil ?></td>
                                    <td>
                                        <?php
                                            echo nl2br($row['text']);
                                        ?>
                                    </td>
                                    <td class="text-center" width="10%">
                                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 1) ? "<i class='fa fa-check'></i>" : NULL; ?>
                                    </td>
                                    <td class="text-center" width="10%">
                                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 2) ? "<i class='fa fa-check'></i>" : NULL; ?>
                                    </td>
                                    <td class="text-center" width="10%">
                                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 0) ? "<i class='fa fa-check'></i>" : NULL; ?>
                                    </td>
                                    <td class="text-center" width="10%">
                                        <?php echo ($table['body']['answerInfo'][$index]['comment']) ? $table['body']['answerInfo'][$index]['comment'] : "TIDAK BERKAITAN"; ?>
                                    </td>
                                </tr>
                        <?php
        				$index++;
        				$bil++;
                    } ?>
                <?php
                    }
                } else {
                    $bil = 1;
                    foreach ($table['body']['detailInfo'] as $row) {
                ?>
                <tr>
                    <td class="text-center" width="10%"><?php echo $row['bil'].'-'.$bil ?></td>
                    <td>
                        <?php
                            echo nl2br($row['text']);
                        ?>
                    </td>
                    <td class="text-center" width="10%">
                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 1) ? "<i class='fa fa-check'></i>" : NULL; ?>
                    </td>
                    <td class="text-center" width="10%">
                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 2) ? "<i class='fa fa-check'></i>" : NULL; ?>
                    </td>
                    <td class="text-center" width="10%">
                        <?php echo ($table['body']['answerInfo'][$index]['answer'] == 0) ? "<i class='fa fa-check'></i>" : NULL; ?>
                    </td>
                    <td class="text-center" width="10%">
                        <?php echo ($table['body']['answerInfo'][$index]['comment']) ? $table['body']['answerInfo'][$index]['comment'] : "TIDAK BERKAITAN"; ?>
                    </td>
                </tr>
                <?php
				$index++;
				$bil++;
				} } }
				?>
			</table>
		</div>
	</div><br><br>
	<?php } ?>
	<div class="row">
		<div class="col-xs-12">
			<div class="tableTitle">
				ULASAN &amp; KEPUTUSAN
			</div>
		</div>
		<div class="col-xs-9">
			<table width="100%" class="datatables">
				<tr>
					<th class="subheader">
						Ulasan Keseluruhan Pencarian Audit
					</th>
				</tr>
				<tr>
					<td rowspan="2">
						<?php echo ($table['body']['summaryInfo']['comment']) ? $table['body']['summaryInfo']['comment'] : "TIADA KOMEN" ?>
					</td>
				</tr>
			</table>
		</div>
		<div class="col-xs-3">
			<table width="100%" class="datatables pull-right">
				<tr>
					<th colspan="2" class="subheader">
						Keputusan
					</th>
				</tr>
				<tr>
					<th class="subheader">
						Status
					</th>
					<th class="subheader">
						Markah
					</th>
				</tr>
				<tr>
					<td class="text-center">
						<?php echo $table['body']['summaryInfo']['status'] ?>
					</td>
					<td class="text-center">
						<?php echo $table['body']['summaryInfo']['mark'] ?>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<?php  ?>
	<div class="row">
		<div class="col-xs-12">
			<div class="tableTitle">
				SENARAI LAMPIRAN
			</div>
			<table class="datatables" width="100%">
				<tr>
					<th width="5%">#</th>
					<th width="25%">Nama Fail</th>
					<th>Keterangan</th>
				</tr>
				<?php
                if (isset($table['body']['attachmentInfo'])) {
				$i = 1;
    				foreach ($table['body']['attachmentInfo'] as $row){
    					$ext = (file_exists($row->attachment)) ? pathinfo($row->attachment, PATHINFO_EXTENSION) : NULL;
    					if($row->attachment && $ext) {
    						$att = str_replace("/","\\",$row->attachment);
				?>
				<tr>
					<td width="5%"><?php echo $i++ ?></td>
					<td><?php echo basename($att); ?></td>
					<td><?php echo ($row->title) ? $row->title : NULL; ?></td>
				</tr>
			<?php } } } ?>
			</table>
		</div>
	</div><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>
	<?php } ?>
</section>
