<?php
	if(($this->session->userdata('sv_request_month') && $this->session->userdata('sv_request_month') != 'no result')){
		if($this->session->userdata('sv_request_month') == '01'){
	         $month = "JANUARY";
	    }else if($this->session->userdata('sv_request_month') == '02'){
	         $month = "FEBRUARY";
	    }else if($this->session->userdata('sv_request_month') == '03'){
	         $month = "MARCH";
	    }else if($this->session->userdata('sv_request_month') == '04'){
	         $month = "APRIL";
	    }else if($this->session->userdata('sv_request_month') == '05'){
	         $month = "MAY";
	    }else if($this->session->userdata('sv_request_month') == '06'){
	         $month = "JUNE";
	    }else if($this->session->userdata('sv_request_month') == '07'){
	         $month = "JULY";
	    }else if($this->session->userdata('sv_request_month') == '08'){
	         $month = "AUGUST";
	    }else if($this->session->userdata('sv_request_month') == '09'){
	         $month = "SEPTEMBER";
	    }else if($this->session->userdata('sv_request_month') == '10'){
	         $month = "OCTOBER";
	    }else if($this->session->userdata('sv_request_month') == '11'){
	         $month = "NOVEMBER";
	    }else if($this->session->userdata('sv_request_month') == '12'){
	         $month = "DECEMBER";
        }else if($this->session->userdata('sv_request_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_request_dept')) && $this->session->userdata('sv_request_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>BUSINESS ENTITY</b></span></td>
									<td><span><b style="padding-left: 2rem; text-align: justify;">:</b></span></td>
									<td><span><b style="padding-left: 1rem;"><?php echo (!empty($this->session->userdata('sv_request_business')) && $this->session->userdata('sv_request_business') != 'ALL')?$business_entity['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_request_filter_status')))?(str_replace('_',' ',$this->session->userdata('sv_request_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_request_year')))?($this->session->userdata('sv_request_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_request_month')))?($this->session->userdata('sv_request_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 TRAINING REQUEST</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width: 35rem;"></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($listTrainingRequest[0]['requestor']))?$listTrainingRequest[0]['requestor']:''; ?>
								</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($listTrainingRequest[0]['staff_id']))?strtoupper($listTrainingRequest[0]['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($listTrainingRequest[0]['dept_name']))?$listTrainingRequest[0]['dept_name'].'/'.$listTrainingRequest[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($listTrainingRequest[0]['createdTS']))?date('d-m-Y',strtotime($listTrainingRequest[0]['createdTS'])):''; ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>TRAINING TITLE / TOPIC</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($listTrainingRequest[0]['topic']))?$listTrainingRequest[0]['topic']:''; ?>
								</p>
							</div>
						</div>

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

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

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

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

						<div class="row">
							<div class="col-4">
								<b>PARTICIPANT</b>
							</div>
							<div class="col">
								<?php
									if(!empty($listTrainingRequest[0]['participant_name']))
									{
										$pName 		= explode(',', $listTrainingRequest[0]['participant_name']);
										$pStatus	= explode(',', $listTrainingRequest[0]['participant_hod_status']);

										foreach ($pName as $key => $value) 
										{
											if($pStatus[$key] == 1)
											{
												echo '<p class="report-font">: '.$value.'</p>';
											}
										}
									}
									else
									{
										echo ': N/A';
									}
								?>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>PROPOSED SHARING SESSION</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listTrainingRequest[0]['proposed_date'] && $listTrainingRequest[0]['proposed_date']))?date('d-m-Y',strtotime($listTrainingRequest[0]['proposed_date'])):''; ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>STATUS</b>
							</div>
							<div class="col">
								<p class="report-font">: <?php //debug($rsCarBookingList);?>
                                    <?php echo ($listTrainingRequest[0]['status_app']==null || $listTrainingRequest[0]['status_app']=='Pending' )?'Pending ':str_replace('_',' ',$listTrainingRequest[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="sorting border-top text-center" tabindex="0" aria-controls="table_booking_list" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" width="1%">
					#
                </th>
				<th class="sorting border-top text-center" width="20%">
					Business entity
				</th>
				<th class="sorting border-top text-center" width="20%">
					Proposed sharing session
				</th>
				<th class="sorting border-top text-center" width="40%">
					Event
				</th>
				<th class="sorting border-top text-center" width="10%">
					Attachment
				</th>   
				<th class="sorting border-top text-center" width="10%">
					Status
				</th>   
			</thead>	

			<tbody>
				<?php if(!empty($listTrainingRequest) && is_array($listTrainingRequest)) { foreach($listTrainingRequest as $key => $row){ ?>
					<tr>
						<td class="text-center"><?php echo $key+1 ?></td>
						<td><?php echo $row['business_entity'] ?></td>
						<td>
							<b>Date</b> : <?php echo date ('d-m-Y', strtotime($row['proposed_date'])); ?><br>
							<b>Time</b> : <?php echo $row['time']; ?><br>
							<b>Venue</b> : <?php echo $row['venue']; ?><br>
							<b>Cost</b> : <?php echo 'RM'.$row['cost']; ?>
						</td>
						<td> 
							<b>Topic</b> : <?php echo $row['topic']; ?><br>
							<b>Organizer</b> : <?php echo $row['organizer']; ?><br>
							<b>Participant</b> : 
							<?php
								if(!empty($row['participant_name']))
								{
									$pName 		= explode(',', $row['participant_name']);

									foreach ($pName as $key => $value) 
									{
										echo '<div class="row"><div class="col-12 col-md-9"><li style="margin-top: 2px;">'.$value.'</div></li></div>';
									}
								}
								else
								{
									echo 'N/A';
								}
							?>
						</td>
						<td><?php echo $row['photo_title']; ?></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 } ?>


