<?php
if(!empty($this->session->userdata('sv_talent_referral_filter_month')) && $this->session->userdata('sv_talent_referral_filter_month') > 0)
{
	if($this->session->userdata('sv_talent_referral_filter_month') > 0){
		$month = date('F',strtotime(date('Y-').$this->session->userdata('sv_talent_referral_filter_month').'-01'));
	}else if($this->session->userdata('sv_talent_referral_filter_month') == 'ALL'){
		$month = "ALL";
	}else  $month = "Unknown";
}
?>

<header>
	<div class="row">
		<div class="col-12">
			<div class="t-corp pull-left">
				<div class="t-corp-logo">
					<img src="<?php echo base_url().'assets/images/logo/salihin-logo.png'; ?>" alt="company logo" />
				</div>
				<div class="t-corp-name"><b>SPS</b> | HR SYSTEM</div>
			</div>
			<div class="report-title pull-right" style="padding-top: 30px;">
				<h5><?php echo (isset($title) ? $title : 'Report'); ?></h5>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-12">
			<table class="company">
				<tr>
					<td class="divider">
						<span class="line">&nbsp;</span>
					</td>
					<td class="details">
						<span><b>SALIHIN (AF 1426)</b></span>
						<span>555, Jalan Samudra Utara 1, Taman Samudra, Batu Caves,</span>
						<span>68100, Batu Caves, Selangor</span>
						<span>Phone: 03-6185 9970 &nbsp;&nbsp; Fax: 03-6185 9970</span>
						<span>Website: salihin.com.my</span>
					</td>
					<?php if(!empty($ID)) { ?>
						<td class="divider">
							<span class="line">&nbsp;</span>
							
						</td>
					<?php } else { ?>
						<td class="divider">
							<span class="line">&nbsp;</span>
							<table>
								<tr>
									<td><span><b>DEPARTMENT</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<?php if(!empty($this->session->userdata('sv_talent_referral_filter_dept')) && $this->session->userdata('sv_talent_referral_filter_dept') != 'ALL'){ ?>
										<td><span><b style="padding-left: 1rem;"><?php echo $department['name'].' ['.$department['branch_name'].']'; ?></b></span></td>
									<?php } else {?>
										<?php if($_SESSION['module_data']['role']=='admin'){ ?>
											<td><span><b style="padding-left: 1rem;">ALL</b></span></td>
										<?php } else{ ?>
											<td><span><b style="padding-left: 1rem;"><?php echo $_SESSION['user']['department_name'].' ['.$_SESSION['user']['branch_name'].']'; ?></b></span></td>
										<?php } ?>
									<?php } ?>
								</tr>
								<tr>
									<td><span><b>STATUS</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_talent_referral_filter_status')))?(str_replace('_',' ',$this->session->userdata('sv_talent_referral_filter_status'))):'ALL'; ?></b></span></td>
								</tr>
								<tr>
									<td><span><b>YEAR</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_talent_referral_filter_year')))?(str_replace('_',' ',$this->session->userdata('sv_talent_referral_filter_year'))):'ALL'; ?></b></span></td>
								</tr>
								<tr>
									<td><span><b>MONTH</b></span></td>
									<td><span><b style="padding-left: 2rem;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_talent_referral_filter_month')))?$month:'ALL'; ?></b></span></td>
								</tr>
							</table>
						</td>
					<?php } ?>
				</tr>
			</table>
		</div>
	</div>
</header>

<?php if(!empty($ID)){ ?>
	<div class="container">
		<div class="col-12" style="margin-top:2rem">
			<div class="row">
				<div class="col">
					<h3><b>DETAIL OF TALENT REFERRAL PROGRAM FORM</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width:53.5rem;"></p><br>
				</div>
			</div>
			<div class="row">
				<div class="col-1" >
				</div>
				<div class="col d-flex">
					<div class="align-self-end w-100">
						<div class="row">
							<div class="col-4">
								<b>EMPLOYEE'S NAME</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($talentReferralList[0]['requester_name']))?$talentReferralList[0]['requester_name']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>DATE</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($talentReferralList[0]['createdTS']))?date('d-m-Y',strtotime($talentReferralList[0]['createdTS'])):''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>DEPARTMENT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($talentReferralList[0]['dept_name']))?$talentReferralList[0]['dept_name'].' ['.$talentReferralList[0]['branchName'].']':''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>E-MAIL ADDRESS</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($talentReferralList[0]['requester_email']))?$talentReferralList[0]['requester_email']:'N/A'; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>CANDIDATE'S DETAIL</b>
							</div>
							<div class="col">
								<p class="report-font">
									<?php  
									echo ': <b>Name</b> - '.$talentReferralList[0]['candidate_name'].'<br>'; 
									echo ': <b>E-Mail Address</b> - '.$talentReferralList[0]['candidate_email'].'<br>'; 
									echo ': <b>Position Applied</b> - '.$talentReferralList[0]['candidate_position'].'<br>'; 
									echo ': <b>Telephone Number</b> - '.$talentReferralList[0]['candidate_contact']; 
									?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>STATUS</b>
							</div>
							<div class="col">
								<p class="report-font">
								<?php 
								$status = ($talentReferralList[0]['status_app']==null || $talentReferralList[0]['status_app']=='Pending' )?'Pending ':(($talentReferralList[0]['status_app'] == 'In_progress')?'Processed':$talentReferralList[0]['status_app']);
								$status_person = ($talentReferralList[0]['processedBY'] <= 1)?$talentReferralList[0]['processedBY_name']:$talentReferralList[0]['verifiedBY_name'];
								echo ': '.$status.'<br>'; 
								echo ': <b>'.$status.' By</b> - '.$status_person; 
								?>
							</p>
						</div>
					</div>

				</div>
			</div>
		</div>
	</div>
</div>

<?php } else { ?>

	<div class="col-12 table-responsive " style="margin-top:2rem">

		<table class="table table-bordered" width="100%" border="1">
			<thead>
				<th class="text-center" width="5%">#</th>
				<th class="text-center" width="40%">Employee's Information</th>
				<th class="text-center" width="40%">Candidate's Information</th>
				<th class="text-center" width="13%">Status</th>
			</thead>	

			<tbody>
				<?php if(!empty($talentReferralList) && $talentReferralList != 'No Data') { ?> 
					<?php foreach($talentReferralList as $key => $row) { ?>
						<tr>
							<td class="text-center"><?php echo $key+1; ?></td>
							<td>
								<b>Name</b> : <?php echo $row['requester_name'].' ['.$row['requester_email'].']'; ?><br>
								<b>Department</b> : <?php echo $row['dept_name'] . ' [' . $row['branchName'].']'; ?><br>
								<b>Date</b> : <?php echo date('d-m-Y',strtotime($row['createdTS'])); ?>
							</td>
							<td>
								<b>Name</b> : <?php echo $row['candidate_name'].' ['.$row['candidate_email'].']'; ?><br>
								<b>Position Applied</b> : <?php echo $row['candidate_position']; ?><br>
								<b>Telephone Number</b> : <?php echo $row['candidate_contact']; ?>
							</td>
							<td class="text-center"><?php echo ($row['status_app']==null || $row['status_app']=='Pending' )?'Pending ':(($row['status_app'] == 'In_progress')?'Processed':$row['status_app']); ?>
						</tr>
					<?php }
				}
				?>
			</tbody>
		</table>	
	</div>	
<?php } ?>


