<?php
if(!empty($this->session->userdata('sv_client_new_resignation_filter_month')) && $this->session->userdata('sv_client_new_resignation_filter_month') > 0)
{
	if($this->session->userdata('sv_client_new_resignation_filter_month') > 0){
		$month = date('F',strtotime(date('Y-').$this->session->userdata('sv_client_new_resignation_filter_month').'-01'));
	}else if($this->session->userdata('sv_client_new_resignation_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_client_new_resignation_filter_dept')) && $this->session->userdata('sv_client_new_resignation_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>CLIENT</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_client_new_resignation_filter_client_id')) && $this->session->userdata('sv_client_new_resignation_filter_client_id') != 'ALL')?$client->name:'ALL'; ?></b></span></td>
								</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_client_new_resignation_filter_status')))?(str_replace('_',' ',$this->session->userdata('sv_client_new_resignation_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_client_new_resignation_filter_year')))?(str_replace('_',' ',$this->session->userdata('sv_client_new_resignation_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_client_new_resignation_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 NEW CLIENT / RESIGNATION</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width: 45rem;"></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>STAFF NAME</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($request_list[0]['requester_name']))?$request_list[0]['requester_name']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>STAFF ID</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($request_list[0]['requester_staff_id']))?strtoupper($request_list[0]['requester_staff_id']):'N/A'; ?>
								</p>
							</div>
						</div>

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

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

						<div class="row">
							<div class="col-4">
								<b>CLIENT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($request_list[0]['client_name']))?$request_list[0]['client_name']:''; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>DETAIL</b>
							</div>
							<div class="col">
								<p class="report-font">
									<?php
										$request_type = ($request_list[0]['type'] == 1)?"New Client":(($request_list[0]['type'] == 2)?"Client Resignation":"N/A");
	                                    echo ': <b>Request Type </b> : '.$request_type; 
	                                    echo ($request_list[0]['type'] == 2)?'<br>: <b>Reason </b> : '.$request_list[0]['reason']:'';
	                                    echo ($request_list[0]['attachment_id'])?'<br>: <b>Attachment </b> : '.$request_list[0]['filename']:'';
									?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>STATUS</b>
							</div>
							<div class="col">
								<p class="report-font">: <?php //debug($request_list);?>
								<?php echo ($request_list[0]['status_app']==null || $request_list[0]['status_app']=='Pending' )?'Pending ':str_replace('_',' ',$request_list[0]['status_app']); ?>
							</p>
						</div>
					</div>

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

<?php echo $approval; ?>

<?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="20%">Requestor</th>
				<th class="text-center" width="20%">Department</th>
				<th class="text-center" width="15%">Client</th>
				<th class="text-center" width="25%">Detail</th>
				<th class="text-center" width="15%">Status</th>
			</thead>	

			<tbody>
				<?php if(!empty($request_list) && $request_list != 'No Data') { ?> 
					<?php foreach($request_list as $key => $row) { ?>
						<tr>
							<td class="text-center"><?php echo $key+1; ?></td>
							<td>
								<b>Requested By : </b><br><?php echo $row['requester_name'].' ['.$row['requester_email'].']'; ?>
							</td>
							<td><?php echo $row['dept_name'].' ['.$row['branchName'].']'; ?></td>
							<td><?php echo $row['client_name']; ?></td>
							<td>
								<?php 
                                    $request_type = ($row['type'] == 1)?"New Client":(($row['type'] == 2)?"Client Resignation":"N/A");
                                    echo '<b>Request Type </b> : '.$request_type; 
                                    echo ($row['type'] == 2)?'<br><b>Reason </b> : '.$row['reason']:'';
                                    echo ($row['attachment_id'])?'<br><b>Attachment </b> : '.$row['filename']:'';
                                ?>
							</td>
							<td class="text-center"><?php echo ($row['status_app']==null || $row['status_app']=='Pending' )?'Pending':str_replace('_',' ',$row['status_app']); ?>
						</tr>
					<?php }
				}
				?>
			</tbody>
		</table>	
	</div>	
<?php } ?>


