<?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);
$readonly = fetch_postget_val('readonly',$_POST, $_GET);
$dateTimeNow = dateTimeNow();

$indicator_Query = "SELECT A.*, B.*, C.desk_jantina, D.desk_bangsa, F.desk_dun, G.desk_parlimen, H.desk_daerah, i_negeri.desk_negeri,
					i_status_ladang.desk_status_ladang, i_projek_kerajaan.desk_projek_kerajaan, i_katpemilik.desk_katpemilik,
					i_status_lesen.desk_status_lesen, i_sistem_pemeliharaan.desk_sistem_pemeliharaan, i_hakmilik.desk_hakmilik,
					i_kategori_tanah.desk_kategori_tanah, i_syarat_nyata_tanah.desk_syarat_nyata_tanah
					FROM m_ladang A
					LEFT JOIN m_pemilik B ON B.id_pemilik = A.id_pemilik
					LEFT JOIN i_jantina C ON C.id_jantina = B.id_jantina
					LEFT JOIN i_bangsa D ON D.id_bangsa = B.id_bangsa
					LEFT JOIN i_dun F ON F.id_dun = A.id_dun
					LEFT JOIN i_parlimen G ON G.id_parlimen = A.id_parlimen
					LEFT JOIN i_daerah H ON H.id_daerah = A.id_daerah
					LEFT JOIN i_negeri ON i_negeri.id_negeri = A.id_negeri
					LEFT JOIN i_status_ladang ON i_status_ladang.id_status_ladang = A.id_status_ladang
					LEFT JOIN i_projek_kerajaan ON i_projek_kerajaan.id_projek_kerajaan = A.id_projek_kerajaan
					LEFT JOIN i_katpemilik ON i_katpemilik.id_katpemilik = A.id_katpemilik
					LEFT JOIN i_status_lesen ON i_status_lesen.id_status_lesen = A.id_status_lesen
					LEFT JOIN i_sistem_pemeliharaan ON i_sistem_pemeliharaan.id_sistem_pemeliharaan = A.id_sistem_pemeliharaan
					LEFT JOIN i_hakmilik ON i_hakmilik.id_hakmilik = A.id_hakmilik
					LEFT JOIN i_kategori_tanah ON i_kategori_tanah.id_kategori_tanah = A.id_kategori_tanah
					LEFT JOIN i_syarat_nyata_tanah ON i_syarat_nyata_tanah.id_syarat_nyata_tanah = A.id_syarat_nyata_tanah
					WHERE A.id_ladang = ?";
$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);

if($info_List['id_ladang_ruminan'] > 0)
{
	$indicator_Query = "SELECT *
						FROM m_ladang_ruminan
						WHERE id_ladang_ruminan = ?";
	$PDO_stmt = $PDO->prepare($indicator_Query); 
	$PDO_stmt->bindValue(1, $info_List['id_ladang_ruminan'], PDO::PARAM_INT);
	$PDO_stmt->execute();
	$ruminan_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
}

if($info_List['id_ladang_tenusu'] > 0)
{
	$indicator_Query = "SELECT *
						FROM m_ladang_tenusu
						WHERE id_ladang_tenusu = ?";
	$PDO_stmt = $PDO->prepare($indicator_Query); 
	$PDO_stmt->bindValue(1, $info_List['id_ladang_tenusu'], PDO::PARAM_INT);
	$PDO_stmt->execute();
	$tenusu_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
}

if($info_List['id_ladang_babi'] > 0)
{
	$indicator_Query = "SELECT *
						FROM m_ladang_babi
						WHERE id_ladang_babi = ?";
	$PDO_stmt = $PDO->prepare($indicator_Query); 
	$PDO_stmt->bindValue(1, $info_List['id_ladang_babi'], PDO::PARAM_INT);
	$PDO_stmt->execute();
	$babi_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
}

if($info_List['id_ladang_aneka'] > 0)
{
	$indicator_Query = "SELECT *
						FROM m_ladang_aneka
						WHERE id_ladang_aneka = ?";
	$PDO_stmt = $PDO->prepare($indicator_Query); 
	$PDO_stmt->bindValue(1, $info_List['id_ladang_aneka'], PDO::PARAM_INT);
	$PDO_stmt->execute();
	$aneka_List = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
}
?>

<div class="modal-header">
	<h5 class="modal-title">Pemilik : <b><?=$info_List['nama_pemilik']?> (<?=$info_List['kpbaru_pemilik']?>)</b>
	</h5>
	<button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeBtn" name="closeBtn" ></button>
</div>
<div class="modal-body">
	<!--begin::Row-->
	<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 Penternak</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>
							<table>
								<tbody><br>
									<?php
										createtableLabels('Nama Pemilik', '10', $info_List['nama_pemilik']);
										createtableLabels('No KP Baru', '10', $info_List['kpbaru_pemilik']);
										createtableLabels('Tarikh Lahir', '10', formatDate($info_List['tkhlahir_pemilik'], 'd M Y'));
										createtableLabels('Jantina', '10', $info_List['desk_jantina']);
										createtableLabels('Umur', '10', date("Y") - formatDate($info_List['tkhlahir_pemilik'], 'Y'));
										createtableLabels('Bangsa', '10', $info_List['desk_bangsa']);
										createtableLabels('Status BumiPutera', '10', $info_List['id_bangsa'] == 1?'YA':'-');
										createtableLabels('No Telefon', '10', $info_List['tel_pemilik']);
										createtableLabels('Alamat Rumah', '10', $info_List['alamat_pemilik']);
										
										createtableLabels('Nama Penternak', '10', $info_List['nama_penternak']);
										createtableLabels('ID Premis', '10', $info_List['id_premis']);
										createtableLabels('Alamat Premis', '10', $info_List['alamat_ladang']);
										createtableLabels('GPS (Pintu masuk premis)', '10', $info_List['gps_ladang_lat'].','.$info_List['gps_ladang_long']);
										createtableLabels('Negeri', '10', $info_List['desk_negeri']);
										createtableLabels('Daerah', '10', $info_List['desk_daerah']);
										createtableLabels('Parlimen', '10', $info_List['desk_parlimen']);
										createtableLabels('DUN', '10', $info_List['desk_dun']);
										createtableLabels('Status', '10', $info_List['desk_status_ladang']);

										createtableLabels('Projek Kerajaan', '10', $info_List['desk_projek_kerajaan']);
										createtableLabels('Kategori Pemilik / Tuan Punya', '10', $info_List['desk_katpemilik']);
										
										createtableLabels('Status Pelesenan', '10', $info_List['desk_status_lesen']);
										createtableLabels('Sistem Pemeliharaan', '10', $info_List['desk_sistem_pemeliharaan']);
										createtableLabels('Hak Milik Tanah', '10', $info_List['desk_hakmilik']);
										createtableLabels('Kategori Tanah', '10', $info_List['desk_kategori_tanah']);
										createtableLabels('Syarat Nyata Tanah', '10', $info_List['desk_syarat_nyata_tanah']);
									?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<?php 
	if($info_List['id_ladang_ruminan'] > 0)
	{ 
	?>
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor_ruminan">
			<div class="card">
				<div class="card-header" id="head2">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col_ruminan">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Ladang Ruminan</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col_ruminan" class="collapse" data-parent="#accor_ruminan">		
					<?php
						require('papar_ruminan.php');
					?>
				</div>
			</div>
		</div>
	<?php 
	} 
	?>
	
	
	<?php 
	if($info_List['id_ladang_tenusu'] > 0)
	{ 
	?>
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor_tenusu">
			<div class="card">
				<div class="card-header" id="head2">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col_tenusu">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Ladang Tenusu</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col_tenusu" class="collapse" data-parent="#accor_tenusu">		
					<?php
						require('papar_tenusu.php');
					?>
				</div>
			</div>
		</div>
	<?php 
	} 
	?>
	
	
	<?php 
	if($info_List['id_ladang_babi'] > 0)
	{ 
	?>
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor_babi">
			<div class="card">
				<div class="card-header" id="head2">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col_babi">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Ladang Babi</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col_babi" class="collapse" data-parent="#accor_babi">		
					<?php
						require('papar_babi.php');
					?>
				</div>
			</div>
		</div>
	<?php 
	} 
	?>
	
	
	<?php 
	if($info_List['id_ladang_aneka'] > 0)
	{ 
	?>
		<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor_aneka">
			<div class="card">
				<div class="card-header" id="head2">
					<div class="card-title collapsed" data-toggle="collapse" data-target="#col_aneka">
						<div class="card-label">													
							<span class="svg-icon svg-icon-primary menu-icon">
								<?=$Tapisanhome_svg?>
							</span>Maklumat Ladang Aneka Haiwan</div>
						<span class="svg-icon">
							<?=$Tapisan_svg?>
						</span>
					</div>
				</div>
				<div id="col_aneka" class="collapse" data-parent="#accor_aneka">		
					<?php
						require('papar_aneka.php');
					?>
				</div>
			</div>
		</div>	
	<?php 
	} 
	?>
	
	<div class="accordion accordion-solid accordion-panel accordion-svg-toggle" id="accor3">
		<div class="card">
			<div class="card-header" id="head3">
				<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>Dokumen Lampiran</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><br>
									<?php
										$path = 'upload_borang/'.$myID.'/*';
										$images = glob($path);
										if(count($images) > 0)
										{
											for($num = 0; $num < count($images); $num++)
											{
												echo '<tr>';
												echo '<td>'.($num + 1).'.<td>';
												echo '<td style="width:5%"></td>';
												echo '<td><a href="'.$images[$num].'" target="_blank">'.end(explode('/', $images[$num])).'</a></td>';
												echo '</tr>';
											}										
										}
										else
										{
											echo '<tr>';
												echo '<td>Tiada Dokumen<td>';
											echo '</tr>';
										}
									?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>  
	<!--begin::Row-->
</div>
<div class="modal-footer">
	<?php
		echo '<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>';
	?>
</div>

<script>

</script>