<?php 
if($_COOKIE['sejahtera_role'] == 10)
{
	include_once ("includes/setup_pemohon.inc.php");
}
else
{
	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);
$dateTimeNow = dateTimeNow();
$name_id_program = $id_program;
if ($id_program < 10 && (!(substr($id_program, 0, 1) === '0')))
{
	$name_id_program = '0'.$id_program;
}

if($id_program == 1)
{
	$kawalan = 1;
}
else if($id_program == 2)
{
	$kawalan = 2;
}
else if($id_program == 3)
{
	$kawalan = 3;
}
else if($id_program == 4)
{
	$kawalan = 4;
}
else if($id_program == 7)
{
	$kawalan = 5;
}

$kawalan_Query = "SELECT A.*
				  FROM i_kawalan A
				  WHERE A.id_kawalan = ?
				  AND A.aktif = 1";
$PDO_stmt = $PDO->prepare($kawalan_Query);
$PDO_stmt->bindValue(1, $kawalan, PDO::PARAM_INT);
$PDO_stmt->execute();
$kawalan_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);

$indicator_Query = "SELECT A.*,B.desk_program,C.desk_statusmohon, E.desk_khairatkat, F.desk_sahmati, H.desk_aktifmohon, I.desk_statushidup, J.desk_rumahorgtua, K.nama AS nama_keyinmati, L.desk_daerah AS daerah_keyinmati, M.nama AS nama_keysahmati, N.desk_daerah AS daerah_keysahmati, O.nama AS nama_terima, P.desk_dun AS dun_terima, Q.desk_daerah AS daerah_terima, R.nama AS nama_sah, S.desk_dun AS dun_sah, T.desk_daerah AS daerah_sah, U.nama AS nama_saheft, V.desk_dun AS dun_saheft, W.desk_daerah AS daerah_saheft, X.desk_carabayar, Y.desk_bank, Z.desk_sbbtunai, AA.desk_byrkepada, AB.desk_jenisakaun, AC.desk_poskod, AD.desk_negeri, AE.desk_dun AS dun_pemohon, AF.desk_daerah AS daerah_pemohon, AG.desk_warganegara, AH.desk_dun AS dun_pasangan, AI.desk_poskod AS desk_poskodpas, AJ.desk_negeri AS desk_negeripas, AK.desk_caramohon, AL.nama AS nama_daftar, AM.desk_dun AS dun_daftar, AN.desk_daerah AS daerah_daftar
				  FROM m_pemohon A
				  LEFT JOIN i_program B ON B.id_program = A.id_program
				  LEFT JOIN i_statusmohon C ON C.id_statusmohon = A.id_statusmohon
				  LEFT JOIN i_khairatkat E ON E.id_khairatkat = A.id_khairatkat
				  LEFT JOIN i_sahmati F ON F.id_sahmati = A.id_sahmati
				  LEFT JOIN i_aktifmohon H ON H.id_aktifmohon = A.id_aktifmohon
				  LEFT JOIN i_statushidup I ON I.id_statushidup = A.id_statushidup
				  LEFT JOIN i_rumahorgtua J ON J.id_rumahorgtua = A.id_rumahorgtua
				  LEFT JOIN t_pengguna K ON K.id_pengguna = A.id_keyinmati
				  LEFT JOIN i_daerah L ON L.id_daerah = K.id_daerah
				  LEFT JOIN t_pengguna M ON M.id_pengguna = A.id_keysahmati
				  LEFT JOIN i_daerah N ON N.id_daerah = M.id_daerah
				  LEFT JOIN t_pengguna O ON O.id_pengguna = A.id_terima
				  LEFT JOIN i_dun P ON P.id_dun = O.id_dun
				  LEFT JOIN i_daerah Q ON Q.id_daerah = O.id_daerah
				  LEFT JOIN t_pengguna R ON R.id_pengguna = A.id_sah
				  LEFT JOIN i_dun S ON S.id_dun = R.id_dun
				  LEFT JOIN i_daerah T ON T.id_daerah = R.id_daerah
				  LEFT JOIN t_pengguna U ON U.id_pengguna = A.id_saheft
				  LEFT JOIN i_dun V ON V.id_dun = U.id_dun
				  LEFT JOIN i_daerah W ON W.id_daerah = U.id_daerah
				  LEFT JOIN i_carabayar X ON X.id_carabayar = A.id_carabayar
				  LEFT JOIN i_bank Y ON Y.id_bank = A.id_bank
				  LEFT JOIN i_sbbtunai Z ON Z.id_sbbtunai = A.id_sbbtunai
				  LEFT JOIN i_byrkepada AA ON AA.id_byrkepada = A.id_byrkepada
				  LEFT JOIN i_jenisakaun AB ON AB.id_jenisakaun = A.id_jenisakaun
				  LEFT JOIN i_poskod AC ON AC.id_poskod = A.id_poskod
				  LEFT JOIN i_negeri AD ON AD.id_negeri = A.id_negeri
				  LEFT JOIN i_dun AE ON AE.id_dun = A.id_dun
				  LEFT JOIN i_daerah AF ON AF.id_daerah = AE.id_daerah
				  LEFT JOIN i_warganegara AG ON AG.id_warganegara = A.id_warganegara
				  LEFT JOIN i_dun AH ON AH.id_dun = A.id_dunpasangan
				  LEFT JOIN i_poskod AI ON AI.id_poskod = A.id_poskodpasangan
				  LEFT JOIN i_negeri AJ ON AJ.id_negeri = A.id_negeripasangan
				  LEFT JOIN i_caramohon AK ON AK.id_caramohon = A.id_caramohon
				  LEFT JOIN t_pengguna AL ON AL.id_pengguna = A.id_daftar
				  LEFT JOIN i_dun AM ON AM.id_dun = AL.id_dun
				  LEFT JOIN i_daerah AN ON AN.id_daerah = AL.id_daerah
				  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_hubungan, C.desk_poskod, D.desk_negeri, E.desk_bank
				  FROM m_waris A
				  LEFT JOIN i_hubungan B ON B.id_hubungan = A.id_hubungan
				  LEFT JOIN i_poskod C ON C.id_poskod = A.id_poskodwaris
				  LEFT JOIN i_negeri D ON D.id_negeri = A.id_negeriwaris
				  LEFT JOIN i_bank E ON E.id_bank = A.id_bankwaris
				  WHERE A.id_pemohon = ? 
				  AND A.status = 1";
$PDO_stmt = $PDO->prepare($indicator_Query); 
$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
$PDO_stmt->execute();
$latestwaris_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);

$id_pemohon = $info_List['id_pemohon'];
							
$indicator_Query = "SELECT A.*, B.desk_bayaranfasa, C.desk_bayaranjenis, D.desk_bayarankat, E.nama AS namasah, F.nama AS namadaftar, G.desk_daerah, H.desk_dun, I.desk_carabayar, J.desk_bank
				  FROM m_bayaran_KH A
				  LEFT JOIN i_bayaranfasa B ON B.id_bayaranfasa = A.id_bayaranfasa
				  LEFT JOIN i_bayaranjenis C ON C.id_bayaranjenis = A.id_bayaranjenis
				  LEFT JOIN i_bayarankat D ON D.id_bayarankat = A.id_bayarankat
				  LEFT JOIN t_pengguna E ON E.id_pengguna = A.id_sah
				  LEFT JOIN t_pengguna F ON F.id_pengguna = A.id_daftar
				  LEFT JOIN i_daerah G ON G.id_daerah = A.id_daerah
				  LEFT JOIN i_dun H ON H.id_dun = A.id_dun
				  LEFT JOIN i_carabayar I ON I.id_carabayar = A.id_carabayar
				  LEFT JOIN i_bank J ON J.id_bank = A.id_bank
				  WHERE A.id_pemohon = ?
				  ORDER BY A.tahun_bayar ASC";
$PDO_stmt = $PDO->prepare($indicator_Query);
$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
$PDO_stmt->execute();

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

?>

<div class="modal-header">
	<h5 class="modal-title">Pemohon : <b><?=$info_List['nama_pemohon']?> (<?=$info_List['kpbaru_pemohon']?>)</b>
		<?php
		if($info_List['id_program'] != 0)
		{
			$telahsaheft = '';
			if(($info_List['id_carabayar'] == 2 || $info_List['id_byrkepada'] == 2) && $info_List['id_statusmohon'] == 4 && $info_List['flag_saheft'] == 0 && $info_List['id_program'] != 4)
			{				
				$telahsaheft = ' (EFT BELUM DISAHKAN)';
			}
			
			$statussemasa = $info_List['desk_statusmohon'];
			if($info_List['id_statusmohon'] == 2 && $info_List['id_caramohon'] == 2)
			{
				$statussemasa = 'PENDAFTARAN ONLINE (DOKUMEN BELUM DITERIMA)';				
			}
		?>
			<br>Program : <b><?=$info_List['desk_program']?></b>
			<br>Status Semasa : <b><?=$statussemasa.$telahsaheft?></b>
			<br>Status Aktif : <b><?=$info_List['desk_aktifmohon']?></b>
			<?php
			if($info_List['id_aktifmohon'] != 1)
			{
			?>	
				<br>Ulasan Aktif : <b><?=$info_List['ulasan_aktifmohon']?></b>
			<?php
			}
			
			if($info_List['id_rumahorgtua'] > 0)
			{
			?>	
				<br>Rumah Orang Tua : <b><?=$info_List['desk_rumahorgtua']?></b>
				<br>Ulasan Orang Tua : <b><?=$info_List['ulasan_rumahorgtua']?></b>
			<?php
			}
			?>
			<br>Status Hidup : <b><?=$info_List['desk_statushidup']?></b>
		<?php
		}
		?>
	</h5>
	<button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeBtn" name="closeBtn" ></button>
</div>
<div class="modal-body">
	<!--begin::Row-->
	
	<?php	
	if($info_List['id_program'] != 0)
	{
		
		if($info_List['id_statusmohon'] >= 3)
		{
	?>
		<a class="btn btn-success" id="printMaklumatBtn">Cetak Maklumat</a><br>
		<?php	
		}
		?>
		<div class="row">
			<div class="col-lg-6">
				<!--begin::Card-->
				<div class="card card-custom card-stretch">
					<div class="card-header">
						<div class="card-title">
							<h3 class="card-label">Maklumat Permohonan</h3>
						</div>
					</div>
					<div class="card-body">				
						<table>
							<tbody>
								<?php
									createtableLabels('No. Siri', '10', $info_List['no_siri']);
									createtableLabels('Tarikh Lahir', '10', formatdate($info_List['tkh_lahir'],'d M Y'));								
									
									$icno = $info_List['kpbaru_pemohon'];
									$year = substr($icno , 0, 2);
									$year = (($year < date('y'))?('20'.$year):('19'.$year));
									$month = substr($icno , 2, 2);
									$day = substr($icno , 4, 2);							
									
									//$age = dateDifference(date('Y-m-d') , $year.'-'.$month.'-'.$day, '%y' );
									$age = date('Y') - $year;
											
									createtableLabels('Umur', '10', $age.' Tahun');
									createtableLabels('Alamat', '10', $info_List['alamat'].''.$info_List['alamat2'].''.$info_List['alamat3'].','.$info_List['desk_poskod'].' '.$info_List['bandar'].','.$info_List['desk_negeri']);
									createtableLabels('DUN', '10', $info_List['dun_pemohon']);
									createtableLabels('Daerah', '10', $info_List['daerah_pemohon']);
									createtableLabels('No Tel HP', '10', $info_List['tel_hp']);
									createtableLabels('No Tel Rumah', '10', $info_List['tel_rumah']);
								?>
							</tbody>
						</table>
					</div>
				</div>
				<!--end::Card-->
			</div>
			
			<?php
			if($id_program == 7)
			{
			?>
			<div class="col-lg-6">
				<!--begin::Card-->
				<div class="card card-custom card-stretch">
					<div class="card-header">
						<div class="card-title">
							<h3 class="card-label">Maklumat Pasangan</h3>
						</div>
					</div>
					<div class="card-body">				
						<table>
							<tbody>
								<?php
									createtableLabels('Nama Pasangan', '10', $info_List['nama_pasangan']);		
									createtableLabels('Warganegara Pasangan', '10', $info_List['desk_warganegara']);		
									createtableLabels('No Kp Baru Pasangan', '10', $info_List['kpbaru_pasangan']);		
									createtableLabels('No Kp Lama/Pasport Pasangan', '10', $info_List['kplama_pasangan']);		
									createtableLabels('DUN Pasangan', '10', $info_List['dun_pasangan']);		
									createtableLabels('No Tel HP Pasangan', '10', $info_List['tel_hppasangan']);		
									createtableLabels('Emel Pasangan', '10', $info_List['emel_pasangan']);		
									createtableLabels('Alamat', '10', $info_List['alamat_pasangan'].''.$info_List['alamat_pasangan2'].''.$info_List['alamat_pasangan3'].','.$info_List['desk_poskodpas'].' '.$info_List['bandar_pasangan'].','.$info_List['desk_negeripas']);
								?>
							</tbody>
						</table>
					</div>
				</div>
				<!--end::Card-->
			</div>
			<?php
			}
			
			if($latestwaris_List['id_waris'] > 0)
			{
			?>
				<div class="col-lg-6">
					<!--begin::Card-->
					<div class="card card-custom card-stretch">
						<div class="card-header">
							<div class="card-title">
								<h3 class="card-label">Maklumat Waris</h3>
							</div>
						</div>
						<div class="card-body">					
							<table>
								<tbody>
									<?php
										createtableLabels('Nama Waris', '10', $latestwaris_List['nama_waris']);
										createtableLabels('No Kp Baru Waris', '10', $latestwaris_List['kpbaru_waris']);											
										createtableLabels('Hubungan', '10', $latestwaris_List['desk_hubungan']);
										createtableLabels('Alamat Waris', '10', $latestwaris_List['alamat_waris'].''.$latestwaris_List['alamat_waris2'].''.$latestwaris_List['alamat_waris3'].','.$latestwaris_List['desk_poskod'].' '.$latestwaris_List['bandar_waris'].','.$latestwaris_List['desk_negeri']);
										createtableLabels('No Tel HP/Rumah', '10', $latestwaris_List['tel_hpwaris']);
										createtableLabels('Emel', '10', $latestwaris_List['emel_waris']);
										createtableLabels('Bank Waris', '10', $latestwaris_List['desk_bank']);
										createtableLabels('No Akaun Waris', '10', $latestwaris_List['no_akaunwaris']);
									?>
								</tbody>
							</table>
						</div>
					</div>
					<!--end::Card-->
				</div>				
			<?php
			}
			?>
			<div class="col-lg-6">
				<!--begin::Card-->
				<div class="card card-custom card-stretch">
					<div class="card-header">
						<div class="card-title">
							<h3 class="card-label">Maklumat Bank (Pembayaran)</h3>
							<?php
								//echo '<a class="btn btn-success btn-sm mr-2" onclick="loadMyModal(\'general-logbank.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Log Bank"><i class="flaticon2-poll-symbol"></i>Log Bank</a>';
							?>
						</div>
					</div>
					<div class="card-body">					
						<table>
							<tbody>
								<?php
									createtableLabels('Cara Pembayaran', '10', $info_List['desk_carabayar']);
									createtableLabels('Bank', '10', $info_List['desk_bank']);
									createtableLabels('No Akaun', '10', $info_List['no_akaun']);
									createtableLabels('Sebab Tunai', '10', $info_List['desk_sbbtunai']);
									createtableLabels('Bayaran Kepada', '10', $info_List['desk_byrkepada']);
									createtableLabels('Jenis Akaun', '10', $info_List['desk_jenisakaun']);
									createtableLabels('Nama Perkongsian Akaun', '10', $info_List['nama_kongsiakaun']);
									if($info_List['flag_saheft'] > 0)
									{
										$dun_saheft = '<br>KADUN : '.$info_List['dun_saheft'];
										$daerah_saheft = '<br>DAERAH : '.$info_List['daerah_saheft'];
										
										if($info_List['dun_saheft'] == '')
										{											
											$dun_saheft = '';
										}
										
										if($info_List['daerah_saheft'] == '')
										{											
											$daerah_saheft = '';
										}
										createtableLabels('Tarikh Pengesahan EFT', '10', formatDate($info_List['tkh_saheft'],'d M Y'));
										createtableLabels('Pegawai Pengesahan EFT', '10', $info_List['nama_saheft'].$dun_saheft.$daerah_saheft);
									}
								?>
							</tbody>
						</table>
					</div>
				</div>
				<!--end::Card-->
			</div>
			<div class="col-lg-6">
				<!--begin::Card-->
				<div class="card card-custom card-stretch">
					<div class="card-header">
						<div class="card-title">
							<h3 class="card-label">Maklumat Pengesahan</h3>
						</div>
					</div>
					<div class="card-body">
						<table>
							<tbody><br>
								<?php
									createtableLabels('Tarikh Daftar', '10', formatDate($info_List['tkh_daftar'],'d M Y').' ('.$info_List['desk_caramohon'].')');
																		
									if($info_List['id_caramohon'] == 1)
									{
										$dun_daftar = '<br>KADUN : '.$info_List['dun_daftar'];
										$daerah_daftar = '<br>DAERAH : '.$info_List['daerah_daftar'];
										
										if($info_List['dun_daftar'] == '')
										{											
											$dun_daftar = '';
										}
										
										if($info_List['daerah_daftar'] == '')
										{											
											$daerah_daftar = '';
										}										
										createtableLabels('Pegawai Daftar Dokumen', '10', $info_List['nama_daftar'].$dun_daftar.$daerah_daftar);
									}
									
									$tkh_terima = $info_List['tkh_terima'];
									if($tkh_terima == '0000-00-00 00:00:00' && $info_List['tkh_sah'] == '0000-00-00 00:00:00')
									{
										$tkh_terima = 'Dokumen Belum Diterima';										
									}
									else if($tkh_terima == '0000-00-00 00:00:00' && $info_List['tkh_sah'] != '0000-00-00 00:00:00')
									{
										$tkh_terima = formatDate($info_List['tkh_daftar'],'d M Y');										
									}
									else
									{
										$tkh_terima = formatDate($info_List['tkh_terima'],'d M Y');										
									}
									
									createtableLabels('Tarikh Terima Dokumen', '10', $tkh_terima);
									
									if($info_List['id_terima'] > 0)
									{
										$dun_terima = '<br>KADUN : '.$info_List['dun_terima'];
										$daerah_terima = '<br>DAERAH : '.$info_List['daerah_terima'];
										
										if($info_List['dun_terima'] == '')
										{											
											$dun_terima = '';
										}
										
										if($info_List['daerah_terima'] == '')
										{											
											$daerah_terima = '';
										}										
										createtableLabels('Pegawai Terima Dokumen', '10', $info_List['nama_terima'].$dun_terima.$daerah_terima);
									}
									if($info_List['id_sah'] > 0)
									{
										$dun_sah = '<br>KADUN : '.$info_List['dun_sah'];
										$daerah_sah = '<br>DAERAH : '.$info_List['daerah_sah'];
										
										if($info_List['dun_sah'] == '')
										{											
											$dun_sah = '';
										}
										
										if($info_List['daerah_sah'] == '')
										{											
											$daerah_sah = '';
										}
										createtableLabels('Tarikh Pengesahan', '10', formatDate($info_List['tkh_sah'],'d M Y'));
										createtableLabels('Pegawai Pengesahan', '10', $info_List['nama_sah'].$dun_sah.$daerah_sah);
									}
								?>
							</tbody>
						</table>	
					</div>
				</div>
				<!--end::Card-->
			</div>
			<?php
			if($info_List['id_statushidup'] == 2)
			{
			?>
				<div class="col-lg-6">
					<!--begin::Card-->
					<div class="card card-custom card-stretch">
						<div class="card-header">
							<div class="card-title">
								<h3 class="card-label">Maklumat Khairat Kematian</h3>
								<?php			
									if((count($pembayaran_KH_List) > 0 || $info_List['id_sahmati'] == 2) && $my_details->user_level <= 3)
									{
										echo '<br><a class="btn btn-success" onclick="loadMyModal(\'general-khairat.php?id='.$info_List['id_pemohon'].'&type=1\', \'#ajax-modal\')" title="Kemaskini"><span class="svg-icon svg-icon-primary svg-icon-2x">Kemaskini Rekod Khairat</span></a>';
									}
								?>
							</div>
						</div>
						<div class="card-body">	
							<table>
								<tbody>
									<?php
										$statusbyrkhairat = 'BELUM DIBAYAR';
										if(count($pembayaran_KH_List) > 0)
										{
											$statusbyrkhairat = 'TELAH DIBAYAR';												
										}
										
										createtableLabels('Pendaftar', '10', $info_List['nama_keyinmati'].' ('.$info_List['daerah_keyinmati'].')');
										createtableLabels('Tarikh Daftar Kematian', '10', formatDate($info_List['tkh_keyinmati'],'d M Y'));
										if($info_List['id_keysahmati'] > 0)
										{
											createtableLabels('Pengesah', '10', $info_List['nama_keysahmati'].' ('.$info_List['daerah_keysahmati'].')');
											createtableLabels('Tarikh Pengesahan', '10', formatDate($info_List['tkh_keysahmati'],'d M Y'));
										}
										createtableLabels('Status Khairat', '10', $info_List['desk_sahmati']);
										createtableLabels('Kategori Khairat', '10', $info_List['desk_khairatkat']);
										createtableLabels('Tarikh Kematian', '10', formatDate($info_List['tkh_mati'],'d M Y'));
										createtableLabels('No Sijil Kematian', '10', $info_List['no_sijilmati']);
										createtableLabels('Ulasan', '10', $info_List['ulasan_mati']);
										createtableLabels('Status Pembayaran', '10', $statusbyrkhairat);
										if(count($pembayaran_KH_List) > 0)
										{
											for($num2 = 0; $num2 < count($pembayaran_KH_List); $num2++)
											{
												createtableLabels('Tarikh Bayaran', '10', formatDate($pembayaran_KH_List[$num2]['tkh_bayar'],'d M Y'));											
												createtableLabels('Cara Bayaran', '10', $pembayaran_KH_List[$num2]['desk_carabayar']);											
												createtableLabels('Nama Bank', '10', $pembayaran_KH_List[$num2]['desk_bank']);											
												createtableLabels('No akaun', '10', $pembayaran_KH_List[$num2]['no_akaun']);
											}
										}
										//createtableLabels('Bank Waris', '10', $info_List['desk_bank']);
										//createtableLabels('No. Akaun Waris', '10', $info_List['no_akaunwaris']);

										$pathkhairat = 'upload_khairat/'.$myID.'/*';
										$imageskhairat = glob($pathkhairat);
										if(count($imageskhairat) > 0)
										{
											echo '<table>';
											echo '<br>Dokumen Khairat';
													for($numk = 0; $numk < count($imageskhairat); $numk++)
													{
														echo '<tr>';
															echo '<td>'.($numk + 1).'.<td>';
															echo '<td style="width:5%"></td>';
															echo '<td><a href="'.$imageskhairat[$numk].'" target="_blank">'.end(explode('/', $imageskhairat[$numk])).'</a></td>';
														echo '</tr>';
													}
											echo '</table>';
										}
									?>
								</tbody>
							</table>
						</div>
					</div>
					<!--end::Card-->
				</div>
			<?php
			}
			?>
		</div>
	
	<?php	
	}
	?>
	<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor1">
		<div class="card">
			<div class="card-header" id="head1">
				<div class="card-title collapsed" data-toggle="collapse" data-target="#col1">
					<div class="card-label">													
						<span class="svg-icon svg-icon-primary menu-icon">
							<?=$Tapisanhome_svg?>
						</span>Maklumat Permohonan Lengkap, Cetakan Borang & Pengemaskinian</div>
					<span class="svg-icon">
						<?=$Tapisan_svg?>
					</span>
				</div>
			</div>
			<div id="col1" class="collapse" data-parent="#accor1">					
				<div class="row">
					<div class="col-md-12">
						<div class="card-body"><br>
							<?php
								require('general-papar.php');
							?>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>  
	<!--begin::Row-->
	
	<?php	
	if($info_List['id_program'] != 0)
	{
	?>	
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accordionExample8">
			<div class="card">
				<div class="card-header" id="headingThree8">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#collapseThree8">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Rekod Sejarah Pembayaran</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="collapseThree8" class="collapse" data-parent="#accordionExample8">					
					<div class="row">
						<?php
							$tbColumn = array();
							$tbColumn[] = array('Bil', 5);
							$tbColumn[] = array('Jumlah Bayaran', 10);
							$tbColumn[] = array('Tahun Bayaran', 7);
							$tbColumn[] = array('Fasa', 10);
							$tbColumn[] = array('Tarikh Bayaran', 10);
							$tbColumn[] = array('Tarikh Daftar', 0);
							$tbColumn[] = array('Tarikh Sah', 0);
							$tbColumn[] = array('Sah Oleh', 0);
							$tbColumn[] = array('Pejabat Pendaftar', 13);
							$tbColumn[] = array('Kaedah Bayaran', 10);
							$tbColumn[] = array('Bank', 10);
							$tbColumn[] = array('No. Akaun', 15);
							$tbColumn[] = array('Catatan', 10);
							
							createTable('we_table', $tbColumn, 'Pembayaran Program Warga Emas', '', 4, '', '', 12, 1, 'background-color:transparent', 1);
							createTable('it_table', $tbColumn, 'Pembayaran Program Ibu Tunggal', '', 4, '', '', 12, 1, 'background-color:transparent', 1);
							createTable('ie_table', $tbColumn, 'Pembayaran Program Ibu Emas', '', 4, '', '', 12, 1, 'background-color:transparent', 1);
							createTable('oku_table', $tbColumn, 'Pembayaran Program OKU', '', 4, '', '', 12, 1, 'background-color:transparent', 1);
							
						if($info_List['id_statushidup'] == 2)
						{
						?>	
							<div class="col-md-12">
								<div class="card-body">							
									<br>									
									<h5 class="card-title font-weight-bolder text-primary">Pembayaran Khairat Kematian</h5>
									<div class="table-responsive">
									<table class="table table-separate table-head-custom table-checkable" id="kt_datatable2">
										<thead>
											<tr>
												<th>Bil</th>
												<th>Jumlah Bayaran</th>
												<th>Tahun Bayaran</th>
												<th>Fasa</th>
												<th>Tarikh Bayaran</th>
												<th>Tarikh Daftar</th>
												<th>Tarikh Sah</th>
												<th>Sah Oleh</th>
												<th>Pejabat Pendaftar</th>
												<th>Kaedah Bayaran</th>
												<?php
												if($my_details->user_level <= 3)
												{
												?>
													<th>Tindakan</th>
												<?php
												}
												?>
											</tr>
										</thead>
										<tbody>	
										<?php
											if(count($pembayaran_KH_List) > 0)
											{
												for($num = 0; $num < count($pembayaran_KH_List); $num++)
												{									
													echo '<tr>';
														echo '<td>'.($num + 1).'.</td>';
														echo '<td>RM'.$pembayaran_KH_List[$num]['jum_bayaran'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['tahun_bayar'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['desk_bayaranfasa'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['tkh_bayar'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['tkh_daftar'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['tkh_sah'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['namasah'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['desk_daerah'].'</td>';
														echo '<td>'.$pembayaran_KH_List[$num]['desk_bayarankat'].'</td>';
														if($my_details->user_level <= 3)
														{
															echo '<td><a class="btn btn-sm btn-default btn-text-primary btn-hover-primary btn-icon mr-2" onclick="loadMyModal(\'general-khairat.php?id='.$info_List['id_pemohon'].'&type=1\', \'#ajax-modal\')" title="Kemaskini"><span class="svg-icon svg-icon-primary svg-icon-2x">'.$Edit_svg.'</span></a></td>';
														}
													echo '</tr>';
												}
											}
											else
											{															
												echo '<tr>';
													echo '<td colspan="10" style="text-align: center">Tiada Rekod</td>';
												echo '</tr>';
											}
										?>
										</tbody>
									</table>
									</div>
								</div>
							</div>
						<?php
						}
						?>	
					</div>
				</div>
			</div>
		</div>  
	<?php
	}
	
	if($info_List['id_statushidup'] == 2)
	{
	?>	
		<!--begin::Row-->
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor2">
			<div class="card">
				<div class="card-header" id="head1">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col2">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Khairat Kematian</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col2" class="collapse" data-parent="#accor2">					
					<div class="row">
						<div class="col-md-12">
							<div class="card-body">
								<table>
									<tbody>
										<?php
											$statusbyrkhairat = 'BELUM DIBAYAR';
											if(count($pembayaran_KH_List) > 0)
											{
												$statusbyrkhairat = 'TELAH DIBAYAR';												
											}
											
											createtableLabels('Pendaftar', '10', $info_List['nama_keyinmati'].' ('.$info_List['daerah_keyinmati'].')');
											createtableLabels('Tarikh Daftar Kematian', '10', formatDate($info_List['tkh_keyinmati'],'d M Y'));
											if($info_List['id_keysahmati'] > 0)
											{
												createtableLabels('Pengesah', '10', $info_List['nama_keysahmati'].' ('.$info_List['daerah_keysahmati'].')');
												createtableLabels('Tarikh Pengesahan', '10', formatDate($info_List['tkh_keysahmati'],'d M Y'));
											}
											createtableLabels('Status Khairat', '10', $info_List['desk_sahmati']);
											createtableLabels('Kategori Khairat', '10', $info_List['desk_khairatkat']);
											createtableLabels('Tarikh Kematian', '10', formatDate($info_List['tkh_mati'],'d M Y'));
											createtableLabels('No Sijil Kematian', '10', $info_List['no_sijilmati']);
											createtableLabels('Ulasan', '10', $info_List['ulasan_mati']);
											createtableLabels('Status Pembayaran', '10', $statusbyrkhairat);
											//createtableLabels('Bank Waris', '10', $info_List['desk_bank']);
											//createtableLabels('No. Akaun Waris', '10', $info_List['no_akaunwaris']);
											
											if(count($pembayaran_KH_List) > 0)
											{
												for($num2 = 0; $num2 < count($pembayaran_KH_List); $num2++)
												{
													createtableLabels('Tarikh Bayaran', '10', formatDate($pembayaran_KH_List[$num2]['tkh_bayar'],'d M Y'));											
													createtableLabels('Cara Bayaran', '10', $pembayaran_KH_List[$num2]['desk_carabayar']);											
													createtableLabels('Nama Bank', '10', $pembayaran_KH_List[$num2]['desk_bank']);											
													createtableLabels('No akaun', '10', $pembayaran_KH_List[$num2]['no_akaun']);
												}
											}
											
											$pathkhairat = 'upload_khairat/'.$myID.'/*';
											$imageskhairat = glob($pathkhairat);
											if(count($imageskhairat) > 0)
											{
												echo '<table>';
												echo '<br>Dokumen Khairat';
														for($numk = 0; $numk < count($imageskhairat); $numk++)
														{
															echo '<tr>';
																echo '<td>'.($numk + 1).'.<td>';
																echo '<td style="width:5%"></td>';
																echo '<td><a href="'.$imageskhairat[$numk].'" target="_blank">'.end(explode('/', $imageskhairat[$numk])).'</a></td>';
															echo '</tr>';
														}
												echo '</table>';
											}
											
											if((count($pembayaran_KH_List) > 0 || $info_List['id_sahmati'] == 2) && $my_details->user_level <= 3)
											{
												echo '<br><a class="btn btn-success" onclick="loadMyModal(\'general-khairat.php?id='.$info_List['id_pemohon'].'&type=1\', \'#ajax-modal\')" title="Kemaskini"><span class="svg-icon svg-icon-primary svg-icon-2x">Kemaskini Rekod Khairat</span></a>';
											}
										?>
									</tbody>
								</table>								
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	<?php
	}
	
	if($info_List['id_aktifmohon'] != 1)
	{
	?>	
		<!--begin::Row-->
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor3">
			<div class="card">
				<div class="card-header" id="head1">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col3">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Status Tidak Aktif</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col3" class="collapse" data-parent="#accor3">					
					<div class="row">
						<div class="col-md-12">
							<div class="card-body"><br>
								<table>
									<tbody>
										<?php
											createtableLabels('Status Aktif', '10', $info_List['desk_aktifmohon']);
											createtableLabels('Ulasan', '10', $info_List['ulasan_aktifmohon']);
										?>
									</tbody>
								</table>								
							</div>
						</div>
					</div>
				</div>
			</div>
		</div> 
	<?php
	}	
							
	$indicator_Query = "SELECT A.*, B.desk_statusmohon
					  FROM m_anakemas A
					  LEFT JOIN i_statusmohon B ON B.id_statusmohon = A.id_statusmohon
					  WHERE A.id_pemohon = ?";
	$PDO_stmt = $PDO->prepare($indicator_Query);
	$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
	$PDO_stmt->execute();
	$AE_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);

	if($AE_List['id_anakemas'] > 0)
	{
	?>	
		<!--begin::Row-->
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor3">
			<div class="card">
				<div class="card-header" id="head1">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col3">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Permohonan Anak Emas</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col3" class="collapse" data-parent="#accor3">					
					<div class="row">
						<div class="col-md-12">
							<div class="card-body"><br>
								<?php
									echo '<table>';
										echo '<table class="table table-striped table-bordered table-hover">';
											echo '<tr>';
												echo '<td>No. Siri</td>';
												echo '<td>Nama Anak</td>';
												echo '<td>MyKid</td>';
												echo '<td>Status Permohonan</td>';
											echo '</tr>';		
							
											$indicator_Query = "SELECT A.*, B.desk_statusmohon
															  FROM m_anakemas A
															  LEFT JOIN i_statusmohon B ON B.id_statusmohon = A.id_statusmohon
															  WHERE A.id_pemohon = ?";
											$PDO_stmt = $PDO->prepare($indicator_Query);
											$PDO_stmt->bindValue(1, $myID, PDO::PARAM_INT);
											$PDO_stmt->execute();
											
											while($AE_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC))
											{
												echo '<tr>';
													echo '<td>'.$AE_List['no_sirianakemas'].'</td>';
													echo '<td>'.$AE_List['nama_anakemas'].'</td>';
													echo '<td>'.$AE_List['kpbaru_anakemas'].'</td>';
													echo '<td>'.$AE_List['desk_statusmohon'].'</td>';
												echo '</tr>';
											}
										echo '</table>';
									echo '</table>';
								?>							
							</div>
						</div>
					</div>
				</div>
			</div>
		</div> 
	<?php
	}
	
	if($my_details->user_level != 10 && $info_List['id_program'] != 0)
	{
	?>
		<!--begin::Row-->
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor4">
			<div class="card">
				<div class="card-header" id="head1">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col4">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Log Sistem</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col4" class="collapse" data-parent="#accor4">					
					<div class="row">
						<div class="col-md-12">
							<div class="card-body">
								<table>
									<tbody><br>
										<?php
											echo '<a class="btn btn-success btn-sm mr-2" onclick="loadMyModal(\'general-log.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Log Permohonan"><i class="flaticon2-poll-symbol"></i>Log Permohonan</a>';
											
											echo '<a class="btn btn-success btn-sm mr-2" onclick="loadMyModal(\'general-logborang.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Log Data Borang"><i class="flaticon2-poll-symbol"></i>Log Data Borang</a>';
											
											echo '<a class="btn btn-success btn-sm mr-2" onclick="loadMyModal(\'general-logtukar.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Log Tukar Program"><i class="flaticon2-poll-symbol"></i>Log Tukar Program</a>';
										?>
									</tbody>
								</table>								
							</div>
						</div>
					</div>
				</div>
			</div>
		</div> 
		<br>
		<div class="row" style="margin-left:0px">
		<?php
		
		$indicator_Query = "SELECT *
						  FROM l_penerima
						  WHERE id_pemohon = ?";
		$PDO_stmt = $PDO->prepare($indicator_Query);
		$PDO_stmt->bindValue(1, $id_pemohon, PDO::PARAM_INT);
		$PDO_stmt->execute();
		$paymentList['l_penerima'] = $PDO_stmt->fetch(PDO::FETCH_ASSOC);

		$id_pemohonterima = $paymentList['l_penerima']['id_pemohon'];
		$thn_pemohonterima = $paymentList['l_penerima']['tahun_bayar'];
											
		//if($dateTimeNow < $kawalan_List['tkh_buka'] && $id_pemohonterima == 0) 
		if($dateTimeNow < $kawalan_List['tkh_buka']) 
		{
			$notestutup = '<h5 class="card-title font-weight-bolder text-primary">*PERTUKARAN PROGRAM DARI PROGRAM '.$info_List['desk_program'].', KHAIRAT KEMATIAN & PERTUKARAN STATUS AKTIF SEDANG DITUTUP BUAT MASA INI DARI '.formatDate($kawalan_List['tkh_tutup'],'d M Y').' SEHINGGA '.formatDate($kawalan_List['tkh_buka'],'d M Y').'</h5>';	
			
			$link_khairat = '';
			$link_aktifmohon = '';
			
			if($kawalan_List['flag_khairat'] == 0 && $info_List['id_statusmohon'] == 4 && $info_List['id_aktifmohon'] == 1 && $info_List['id_statushidup'] == 1 && (($my_details->user_level <= 4 && in_array($info_List['id_program'], array(1,2))) || ($my_details->user_level == 8 && $info_List['id_program'] == 4)))
			{
				$notestutup = '<h5 class="card-title font-weight-bolder text-primary">*PERTUKARAN PROGRAM DARI PROGRAM '.$info_List['desk_program'].' SEDANG DITUTUP BUAT MASA INI DARI '.formatDate($kawalan_List['tkh_tutup'],'d M Y').' SEHINGGA '.formatDate($kawalan_List['tkh_buka'],'d M Y').'</h5>';
				
				$link_khairat = '<br><a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-khairat.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Khairat Kematian">Permohonan Khairat Kematian</a>';			
			}
			
			if($kawalan_List['flag_aktifmohon'] == 0 && (($info_List['id_aktifmohon'] != 9 && in_array($my_details->user_level, array(1,2,3,4,5)) && in_array($info_List['id_program'], array(1,2,7))) || (in_array($my_details->user_level, array(8,9,13,18)) && $info_List['id_program'] == 4)))
			{
				$notestutup = '<h5 class="card-title font-weight-bolder text-primary">*PERTUKARAN PROGRAM DARI PROGRAM '.$info_List['desk_program'].' SEDANG DITUTUP BUAT MASA INI DARI '.formatDate($kawalan_List['tkh_tutup'],'d M Y').' SEHINGGA '.formatDate($kawalan_List['tkh_buka'],'d M Y').'</h5>';
				
				$link_aktifmohon = '<br><a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-aktif.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Kemaskini Status Aktif">Kemaskini Status Aktif</a>';			
			}
			
			echo $notestutup.$link_khairat.$link_aktifmohon;
		}
		else
		{
			if($info_List['id_statusmohon'] == 4 && $info_List['id_aktifmohon'] == 1 && $info_List['id_statushidup'] == 1)
			{
				if(($my_details->user_level <= 4 && in_array($info_List['id_program'], array(1,2))) || ($my_details->user_level == 8 && $info_List['id_program'] == 4))
				{
					echo '<a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-khairat.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Khairat Kematian">Permohonan Khairat Kematian</a>';
				}
			
				if($info_List['id_program'] != 4)
				{
					echo '<a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-tukar.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Pertukaran Program">Pertukaran Program</a>';
				}
			
				if($my_details->user_level <= 3 && $info_List['id_program'] == 2)
				{
					echo '<a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-orangtua.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Pertukaran Rumah Orang Tua">Pertukaran Rumah Orang Tua</a>';
				}
			}
			
			if(($info_List['id_aktifmohon'] != 9 && in_array($my_details->user_level, array(1,2,3,4,5)) && in_array($info_List['id_program'], array(1,2,7))) || (in_array($my_details->user_level, array(8,9,13,18)) && $info_List['id_program'] == 4))
			{
				echo '<a class="btn btn-primary btn-sm mr-2" onclick="loadMyModal(\'general-aktif.php?id='.$id_pemohon.'\', \'#ajax-modal\')" title="Kemaskini Status Aktif">Kemaskini Status Aktif</a>';			
			}
		}
		?>
		</div>
	<?php
	}
	?>
</div>
<div class="modal-footer">
	<?php
		echo '<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>';
	?>
</div>

<script>
//print function
$('#printMaklumatBtn').click(function() {
	//alert('printBtn');
	var dataOption = [];
	dataOption.id = "<?=$myID?>";
	dataOption.program = "<?=$id_program?>";
	post("general-print_maklumat.php", dataOption);
});
</script>
<script>
var maklumat_ajaxUrl = "general-maklumat_ajax.php";
function maklumat_getData(id_program)
{
	return {
		sqlOnly: 0,
		program: id_program,
		pemohon: "<?=$myID?>",
	};
}

function maklumat_reloadTable(table_name, id_program)
{
	reinitTable(table_name, this.maklumat_ajaxUrl, this.maklumat_getData(id_program), 2, 0);
}

$(document).ready(function(){  
	maklumat_reloadTable('we_table', 2);
	maklumat_reloadTable('it_table', 1);
	maklumat_reloadTable('ie_table', 7);
	maklumat_reloadTable('oku_table', 4);
	
	var subHeaderTitle = 'Pemohon : ' + "<?=$info_List['nama_pemohon']?>" + ' (' + "<?=$info_List['kpbaru_pemohon']?>" + ')';
	//print function
	$('#we_table_printPdf').click(function() {
		printFunc('we_table', '', "normalPrint.php", 'general-maklumat', $('#we_table_table_title').val(), $('#we_table_table_header').val(), null, null, 'L', subHeaderTitle);
	});
	$('#it_table_printPdf').click(function() {
		printFunc('it_table', '', "normalPrint.php", 'general-maklumat', $('#it_table_table_title').val(), $('#it_table_table_header').val(), null, null, 'L', subHeaderTitle);
	});
	$('#ie_table_printPdf').click(function() {
		printFunc('ie_table', '', "normalPrint.php", 'general-maklumat', $('#ie_table_table_title').val(), $('#ie_table_table_header').val(), null, null, 'L', subHeaderTitle);
	});
	$('#oku_table_printPdf').click(function() {
		printFunc('oku_table', '', "normalPrint.php", 'general-maklumat', $('#oku_table_table_title').val(), $('#oku_table_table_header').val(), null, null, 'L', subHeaderTitle);
	});
});
</script>