<?php 
include_once ("includes/setup.inc.php");

$myID = fetch_postget_val('id',$_POST, $_GET);
$id_program = fetch_postget_val('program',$_POST, $_GET);
$readonly = fetch_postget_val('readonly',$_POST, $_GET);

$indicator_Query = "SELECT A.*,B.desk_program
				  FROM m_pemohon A
				  LEFT JOIN i_program B ON B.id_program = A.id_program
				  WHERE A.id_pemohon = ?";
$PDO_stmt = $PDO->prepare($indicator_Query); 
$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
$PDO_stmt->execute();
$info_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
							
$indicator_Query = "SELECT A.*,B.desk_program,C.desk_dun,D.desk_carabayar,E.desk_bank
				  FROM m_tukarprogram A
				  LEFT JOIN i_program B ON B.id_program = A.id_programasal
				  LEFT JOIN i_dun C ON C.id_dun = A.id_dunasal
				  LEFT JOIN i_carabayar D ON D.id_carabayar = A.id_carabayarasal
				  LEFT JOIN i_bank E ON E.id_bank = A.id_bankasal
				  WHERE A.id_pemohon = ?
				  ORDER BY A.id_tukarprogram DESC";
$PDO_stmt = $PDO->prepare($indicator_Query);
$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
$PDO_stmt->execute();

$log_List = array();
while($result = $PDO_stmt->fetch(PDO::FETCH_ASSOC))
{
	$log_List[] = $result;
}

?>
<div class="modal-header">
	<h5 class="modal-title"><b>LOG TUKAR PROGRAM</b><br>Pemohon : <b><?=$info_List['nama_pemohon']?></b></h5>
	<button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeBtn" name="closeBtn" ></button>
</div>
<div class="modal-body">
	<div class="row">
		<div class="col-md-12">		
			<!--begin::Card-->
			<div class="card card-custom gutter-b example-hover">
				<div class="card-body">	
					<table class="table table-separate table-head-custom table-checkable" id="kt_datatable2">
						<thead>
							<tr>
								<th>Bil</th>
								<th>Program Asal</th>
								<th>No. Siri</th>
								<th>DUN</th>
								<th>Cara Bayar</th>
								<th>Bank</th>
								<th>No. Akaun</th>
								<th>Tkh. Daftar</th>
								<th>Tkh. Terima</th>
								<th>Tkh. Sah</th>
								<th>Tkh. Sah EFT</th>
								<th>Ulasan</th>
							</tr>
						</thead>
						<tbody>	
						<?php
							for($num = 0; $num < count($log_List); $num++)
							{									
								echo '<tr>';
									echo '<td>'.($num + 1).'</td>';
									echo '<td>'.$log_List[$num]['desk_program'].'</td>';
									echo '<td>'.$log_List[$num]['no_siriasal'].'</td>';
									echo '<td>'.$log_List[$num]['desk_dun'].'</td>';
									echo '<td>'.$log_List[$num]['desk_carabayar'].'</td>';
									echo '<td>'.$log_List[$num]['desk_bank'].'</td>';
									echo '<td>'.$log_List[$num]['no_akaunasal'].'</td>';
									echo '<td>'.formatDate($log_List[$num]['tkh_daftarasal'],'d M Y').'</td>';
									echo '<td>'.formatDate($log_List[$num]['tkh_terimaasal'],'d M Y').'</td>';
									echo '<td>'.formatDate($log_List[$num]['tkh_sahasal'],'d M Y').'</td>';
									echo '<td>'.formatDate($log_List[$num]['tkh_saheftasal'],'d M Y').'</td>';
									echo '<td>'.$log_List[$num]['ulasan_tukar'].'</td>';
								echo '</tr>';
							}							
						?>
						</tbody>
					</table>					
				</div>
			</div>
			<!--end::Card-->										
		</div>
	</div>
</div>
<div class="modal-footer">
	<?php
		echo '<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>';
	?>
</div>
<script src="assets/plugins/custom/datatables/datatables.bundle.js"></script>
<script>
"use strict";
var KTDatatablesBasicScrollable = function() {

    var initTable2 = function() {
        var table = $('#kt_datatable2');

        // begin second table
        table.DataTable({
            scrollY: '50vh',
            scrollX: true,
            scrollCollapse: true,
        });
    };

    return {

        //main function to initiate the module
        init: function() {
            initTable2();
        },

    };

}();

jQuery(document).ready(function() {
    KTDatatablesBasicScrollable.init();
});
</script>