<div class="collapse" id="collapsePCB">	
	<div class="card">
		<div class="card-header text-center" role="tablist">
			<div class="nav nav-tabs nav-fill card-header-tabs">
				<a class="nav-item nav-link active" id="nav-account-tab" data-toggle="tab" href="#nav-account" role="tab" aria-controls="nav-account" aria-selected="false">Under Employee</a>
				<a class="nav-item nav-link" id="nav-audit-tab" data-toggle="tab" href="#nav-audit" role="tab" aria-controls="nav-audit" aria-selected="false">Under Spouse</a>
			</div>
		</div>
		<div class="card-body">
			<div class="tab-content" id="nav-tabContent">
				<div class="tab-pane fade show active" id="nav-account" role="tabpanel" aria-labelledby="nav-account-tab">
					<h4 class="card-title">Under Employee</h4>
					<hr>
					
					<div class="container">
						<?php if ($role == 'admin'): ?>
							<div class="row">
								<div class="btn-group ml-auto">
									<a class="btn btn-info btn-sm" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('hr/StaffProfile/actionReport/'.$staff_id.'/16'); ?>" target="_blank">
										<i class="fa fa-print"></i> Print
									</a>
								</div>
							</div>
						<?php endif ?>
					</div>
					
					<div class="table-responsive">
						<table id="table_pcb_employee" class="table table-hover table-bordered">
							<thead>
								<tr>
									<th>Action Type</th>
									<th>Name</th>
									<th>NRIC No</th>
									<th>Age</th>
									<th>Status</th>
									<th>Created At</th>
									<!-- <?php if ($role == 'admin'): ?>
									<th>Action</th>
									<?php endif ?> -->
									
								</tr>
							</thead>
							<tbody>
								<?php $counter = 0; ?>
								<?php if($pcb) foreach ($pcb as $key => $row): ?>
									<?php if ($row->responsible_id == 0): ?>
									
									<tr class="link-row">
										<td scope="row">
											<?php 
												echo ($row->type)?$row->type:'N/A';
												echo '<br/>';
												echo ($row->action_efective_date)?date('d-F-Y',strtotime($row->action_efective_date)):'N/A';
											?>
										</td>
										<td><?php echo $row->name; ?></td>
										<td><?php echo $row->ic_no; ?></td>
										<td>
											<?php
												$birthYear = date('Y',strtotime($row->birthdate));
												$currentYear = date('Y');

												echo $currentYear - $birthYear.' Years'; 
											?>
										</td>
										<td>
											<label><b>OKU STATUS : </b></label>
											<?php if ($row->oku_status == 0): ?>
												YES <br>
											<?php else: ?>
												NO<br>
											<?php endif ?>

											<label><b>STUDENT STATUS : </b></label>
											<?php if ($row->study_status == 0): ?>
												YES <br>
											<?php else: ?>
												NO <br>
											<?php endif ?>
										</td>
										<td><?php echo $row->created_at; ?></td>
										<?php if ($role == 'admin'): ?>
										<!-- <td class="text-center">
											<div class="btn-group">
												<button class="btn btn-success btn-sm" onclick="btnEmpEditPCB(this)" data-content="<?php //echo base64_encode(json_encode($row)); ?>" data-toggle="modal" data-target="#employeePcbModal"><i class="fas fa-edit"></i></button>
												<button class="btn btn-danger btn-sm" onclick="btnRemovePCB(<?php //echo $row->id; ?>)"><i class="fas fa-trash"></i></button>
											</div>
										</td> -->
										<?php endif ?>
									
									</tr>
									<?php endif ?>
								<?php endforeach ?>
							</tbody>
						</table>
					</div>
				</div>


				<div class="tab-pane fade" id="nav-audit" role="tabpanel" aria-labelledby="nav-audit-tab">
					<h4 class="card-title">Under Spouse</h4>
					<hr>
					
					<div class="container">
						<?php if ($role == 'admin'): ?>
							<div class="row">
								<div class="btn-group ml-auto">
									<a class="btn btn-info btn-sm" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('hr/StaffProfile/actionReport/'.$staff_id.'/16'); ?>" target="_blank">
										<i class="fa fa-print"></i> Print
									</a>
								</div>
							</div>
						<?php endif ?>
					</div>
			
					<div class="table-responsive">
						<table id="table_pcb_spouse" class="table table-hover table-bordered">
							<thead>
								<tr>
									<th>Action Type</th>
									<th>Name</th>
									<th>NRIC No</th>
									<th>Age</th>
									<th>Status</th>
									<th>Created At</th>
									<!-- <?php if ($role == 'admin'): ?>
									<th>Action</th>
									<?php endif ?> -->
								</tr>
							</thead>
							<tbody>
								<?php $counter = 0; ?>
								<?php if($pcb) foreach ($pcb as $key => $row): ?>
								
									<?php if ($row->responsible_id == 1): ?>
									<tr class="link-row">
										<td scope="row">
											<?php 
												echo ($row->type)?$row->type:'N/A';
												echo '<br/>';
												echo ($row->action_efective_date)?date('d-F-Y',strtotime($row->action_efective_date)):'N/A';
											?>
										</td>
										<td><?php echo $row->name; ?></td>
										<td><?php echo $row->ic_no; ?></td>
										<td>
											<?php
												$birthYear = date('Y',strtotime($row->birthdate));
												$currentYear = date('Y');
												echo $currentYear - $birthYear.' Years'; 
											?>
										</td>
										<td>
											<label><b>OKU STATUS : </b></label>
											<?php if ($row->oku_status == 0): ?>
												YES <br>
											<?php else: ?>
												NO<br>
											<?php endif ?>

											<label><b>STUDENT STATUS</b></label>
											<?php if ($row->study_status == 0): ?>
												YES <br>
											<?php else: ?>
												NO <br>
											<?php endif ?>
										</td>
										<td><?php echo $row->created_at; ?></td>
										<?php if ($role == 'admin'): ?>
										<!-- <td class="text-center">
											<div class="btn-group">
												<button class="btn btn-success btn-sm" onclick="btnSpouseEditPCB(this)" data-content="<?php //echo base64_encode(json_encode($row)); ?>" data-toggle="modal" data-target="#spousePcbModal"><i class="fas fa-edit"></i></button>
												<button class="btn btn-danger btn-sm" onclick="btnRemovePCB(<?php //echo $row->id; ?>)"><i class="fas fa-trash"></i></button>
											</div>
										</td> -->
										<?php endif ?>
										
									</tr>
									<?php endif ?>
								<?php endforeach ?>
							</tbody>
						</table>
					</div>
				</div>

				
			</div>
		</div>
	</div><br>			
</div>
<div class="modal fade" id="employeePcbModal">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="racks-modal-title">Edit Employee PCB</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<form id="mdl-emp-pcb-form" action="<?php echo base_url('/hr/staffProfile/createPCB/'.$staff_id); ?>" method="POST" class="form-horizontal" enctype="multipart/form-data">
				<input type="hidden" value="" id="emp_pcb_id" name="id">
				<input type="hidden" value="0" name="responsible_id">
				<div class="modal-body">
					<div class="form-group">
						<label for="employee_pcb_name">Name</label>
						<select name="family_id" id="employee_pcb_name" class="form-control">

							<?php $flag = true; ?>
								<?php if(!empty($families))  foreach ($families as $key => $family): ?>
									<!-- diplay only child -->
									<?php if ($family->relation == 2): ?>
										
										<!-- display only not chosen child -->
										<?php if($pcb) foreach ($pcb as $key => $row): ?>
											<?php if ($row->family_id == $family->id): $flag = false;?><?php endif ?>
										<?php endforeach?>

										<?php if ($flag): ?>
											<option value="<?php echo $family->id; ?>"><?php echo $family->name; ?></option>	
										<?php endif ?>

										<?php $flag = true; ?>


									<?php endif ?>								
								<?php endforeach ?>	
													
						</select>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger btn-sm" style="margin-bottom:15px; width: 200px;" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>
					<button type="submit" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> Submit</button>
				</div>
			</form>
		</div>
	</div>
</div>
<div class="modal fade" id="spousePcbModal">
<div class="modal-dialog modal-lg">
	<div class="modal-content">
		<div class="modal-header">
			<h5 class="modal-title" id="racks-modal-title">Add Spouse PCB</h5>
			<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span>
			</button>
		</div>
		<form id="mdl-spouse-pcb-form" action="<?php echo base_url('/hr/staffProfile/createPCB/'.$staff_id); ?>" method="POST" class="form-horizontal" enctype="multipart/form-data">
			<input type="hidden" value="" id="spouse_pcb_id" name="id">
			<input type="hidden" value="1" name="responsible_id">
			<div class="modal-body">
				<div class="form-group">
					<label for="spouse_pcb_name">Name</label>
					<select name="family_id" id="spouse_pcb_name" class="form-control">
						
						<?php $flag = true; ?>
						<?php if(!empty($families))  foreach ($families as $key => $family): ?>
							<!-- diplay only child -->
							<?php if ($family->relation == 2): ?> 
								
								<!-- display only not chosen child -->
								<?php if($pcb) foreach ($pcb as $key => $row): ?>
									<?php if ($row->family_id == $family->id): $flag = false;?><?php endif ?>
								<?php endforeach?>

								<?php if ($flag): ?>
									<option value="<?php echo $family->id; ?>"><?php echo $family->name; ?></option>	
								<?php endif ?>
								<?php $flag = true; ?>
							<?php endif ?>								
						<?php endforeach ?>							
					</select>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-danger btn-sm" style="margin-bottom:15px; width: 200px;" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>
				<button type="submit" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> Submit</button>
			</div>
		</form>
	</div>
</div>
</div>