<?php 
require('includes/header.php'); 
$id_program = fetch_postget_val("id_program", $_POST, $_GET);
$id_carabayar = fetch_postget_val("id_carabayar", $_POST, $_GET);
$id_sah = fetch_postget_val("id_sah", $_POST, $_GET);
$id_daerah = fetch_postget_val("id_daerah", $_POST, $_GET);
$tkh_mula = formatDate(fetch_postget_val("tkh_mula", $_POST, $_GET), 'Y-m-d');
$tkh_hingga = formatDate(fetch_postget_val("tkh_hingga", $_POST, $_GET), 'Y-m-d');
$tahun_bayar_year = fetch_postget_val("tahun_bayar_year", $_POST, $_GET);
$bayaranfasa_sc = fetch_postget_val("bayaranfasa_sc", $_POST, $_GET);
$dun_sc = fetch_postget_val("dun_sc", $_POST, $_GET);

$PDO_stmt = $PDO->prepare("
	SELECT *
	FROM i_program
	WHERE id_program = ?
");
$PDO_stmt->bindValue(1, $id_program, PDO::PARAM_STR);
$PDO_stmt->execute();
$program_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);

?>	

<!--begin::Content-->
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
	<!--begin::Subheader-->
	<div class="subheader py-2 py-lg-4 subheader-solid" id="kt_subheader">
		<div class="container-fluid d-flex align-items-center justify-content-between flex-wrap flex-sm-nowrap">
			<!--begin::Info-->
			<div class="d-flex align-items-center flex-wrap mr-2">
				<!--begin::Page Title-->
				<h5 class="text-dark font-weight-bold mt-2 mb-2 mr-5">Senarai Pemohon Pembayaran Harian</h5>
				<!--end::Page Title-->
				<!--begin::Actions-->
				<div class="subheader-separator subheader-separator-ver mt-2 mb-2 mr-4 bg-gray-200"></div>
			</div>
			<!--end::Info-->
		</div>
	</div>
	<!--end::Subheader-->
	<!--begin::Entry-->
	<div class="d-flex flex-column-fluid">
		<!--begin::Container-->
		<div class="container">
			<!--begin::Dashboard--> 
			<!--begin::Row-->
			<div class="row">
				<input type="hidden" id="program" value="<?=$id_program?>">
				<input type="hidden" id="kod_program" value="<?=$program_List['kod_program']?>">
				<input type="hidden" id="carabayar" value="<?=$id_carabayar?>">
				<input type="hidden" id="daerah" value="<?=$id_daerah?>">
				<input type="hidden" id="tkh_mula" value="<?=$tkh_mula?>">
				<input type="hidden" id="tkh_hingga" value="<?=$tkh_hingga?>">
				<input type="hidden" id="pengesah" value="<?=$id_sah?>">
				<input type="hidden" id="tahun_bayar_year" value="<?=$tahun_bayar_year?>">
				<input type="hidden" id="bayaranfasa_sc" value="<?=$bayaranfasa_sc?>">
				<input type="hidden" id="dun_sc" value="<?=$dun_sc?>">
				<?php
					$tbColumn = array();
					$tbColumn[] = array('Bil', 10);
					$tbColumn[] = array('Nama', 30);
					if($id_program == 5)
					{
						$tbColumn[] = array('No MyKID', 20);
					}
					else
					{
						$tbColumn[] = array('No KP', 20);
					}
					$tbColumn[] = array('DUN', 20);
					$tbColumn[] = array('Tarikh Bayaran', 20);
					$tbColumn[] = array('Fasa', 20);
					$tbColumn[] = array('Kategori', 20);
					$tbColumn[] = array('Tahun', 20);
					$tbColumn[] = array('Jumlah Bayaran', 20);
					$tbColumn[] = array('Cara Bayaran', 20);
					$tbColumn[] = array('Bank', 20);
					$tbColumn[] = array('No Akaun', 20);
					$tbColumn[] = array('Tindakan', 0);
					
					createTable('program_table', $tbColumn, 'Senarai Pemohon Pembayaran Harian Program '.$program_List['desk_program'], formatDate($tkh_mula,'d M Y').' hingga '.formatDate($tkh_hingga,'d M Y'), 2, $userBtn, 'ajax-modal', 12);
				?>
				
			</div>
			<!--end::Row-->
			<!--end::Dashboard-->
		</div>
		<!--end::Container-->
	</div>
	<!--end::Entry-->
</div>
<!--end::Content-->
					
<?php 
require('includes/footer.php');
?>

<script>
var ajaxUrl = "la_harian-pemohon_ajax.php";
function getData()
{
	return {
		sqlOnly: 0,
		id_program: $('#program').val(),
		kod_program: $('#kod_program').val(),
		id_carabayar: $('#carabayar').val(),
		id_sah: $('#pengesah').val(),
		id_daerah: $('#daerah').val(),
		tkh_mula: $('#tkh_mula').val(),
		tkh_hingga: $('#tkh_hingga').val(),
		tahun_bayar_year: $('#tahun_bayar_year').val(),
		bayaranfasa_sc: $('#bayaranfasa_sc').val(),
		dun_sc: $('#dun_sc').val()
	};
}

function reloadTable()
{
	reinitTable($('#table_name').val(), this.ajaxUrl, this.getData(), 1, 0);
}

$(document).ready(function(){  

	$('#ajax-modal').on('shown.bs.modal', function () {  // this is to clear modal cache each time modal load
	 $(this).removeData('bs.modal');
	}); 
	
	initTable($('#table_name').val(), ajaxUrl, getData(), 1, 0);
	
	//print function
	$('#printExcel, #printPdf').click(function() {
		printFunc($('#table_name').val(), $(this).attr("value"), "normalPrint.php", $('#script_base_name').val(), $('#table_title').val(), $('#table_header').val());
	});
});
</script>