<?php
	if(($this->session->userdata('sv_evaluation_filter_month') && $this->session->userdata('sv_evaluation_filter_month') != 'no result')){
		if($this->session->userdata('sv_evaluation_filter_month') == '01'){
	         $month = "JANUARY";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '02'){
	         $month = "FEBRUARY";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '03'){
	         $month = "MARCH";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '04'){
	         $month = "APRIL";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '05'){
	         $month = "MAY";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '06'){
	         $month = "JUNE";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '07'){
	         $month = "JULY";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '08'){
	         $month = "AUGUST";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '09'){
	         $month = "SEPTEMBER";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '10'){
	         $month = "OCTOBER";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '11'){
	         $month = "NOVEMBER";
	    }else if($this->session->userdata('sv_evaluation_filter_month') == '12'){
	         $month = "DECEMBER";
        }else if($this->session->userdata('sv_evaluation_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_evaluation_filter_dept')) && $this->session->userdata('sv_evaluation_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>PACKAGES</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_evaluation_filter_package')))?($this->session->userdata('sv_evaluation_filter_package')):'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_evaluation_filter_year')))?($this->session->userdata('sv_evaluation_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_evaluation_filter_month')))?($this->session->userdata('sv_evaluation_filter_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>TRAINING EVALUATION DETAIL</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width: 36.6rem;"></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($listTrainingEvaluation[0]['userName']))?$listTrainingEvaluation[0]['userName']:'N/A'; ?>
								</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($listTrainingEvaluation[0]['staff_id']))?strtoupper($listTrainingEvaluation[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($listTrainingEvaluation[0]['dept_name']))?$listTrainingEvaluation[0]['dept_name'].'/'.$listTrainingEvaluation[0]['branchName']:'N/A'; ?>
								</p>
							</div>
						</div>

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

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

						<div class="row">
							<div class="col-4">
								<b>DATE OF TRAINING</b>
							</div>
							<div class="col">
								<p class="report-font">:
									<?php echo (!empty($listTrainingEvaluation[0]['training_date']) && $listTrainingEvaluation[0]['training_date'] != '0000-00-00')?date('d-m-Y',strtotime($listTrainingEvaluation[0]['training_date'])):'N/A'; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>PACKAGES</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listTrainingEvaluation[0]['packages']))?$listTrainingEvaluation[0]['packages']:'N/A'; ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>CPD/CPE HOURS</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listTrainingEvaluation[0]['cpd_hours']))?$listTrainingEvaluation[0]['cpd_hours']:'N/A'; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>NAME OF TRAINER/SPEAKER</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listTrainingEvaluation[0]['trainer_name']))?$listTrainingEvaluation[0]['trainer_name']:'N/A'; ?>
								</p>
							</div>
						</div>

						<br><div style="border: 1px solid;"></div><br>

						<?php if(!empty($listTrainingEvaluation)){ foreach($listTrainingEvaluation as $key => $detail){ ?>
							<?php if($detail['question_type']==0){ ?>
								<div class="col-12 table-responsive">
									<table class="table table-bordered" width="100%">
										<thead align="center"> 
											<tr>
												<td width="70%"><b><?php echo $detail['category_question']; ?></b></td>
												<td width="6%">1</td>
												<td width="6%">2</td>
												<td width="6%">3</td>
												<td width="6%">4</td>
												<td width="6%">5</td>
											</tr>
										</thead>
										<tbody>
											<?php for($i=0; $i<sizeof($detail['qtn']); $i++){ ?>
												<tr align="center">
													<td class="text-left">
														<?php echo $detail['qtn'][$i];?>
													</td>
													<td>
														<input type="radio" name="answerRadio[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerRadio[]" value="1" <?php echo ($detail['radio'][$i]==1)?'checked':''; ?> disabled><br>
													</td>
													<td>
														<input type="radio" name="answerRadio[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerRadio[]" value="2" <?php echo ($detail['radio'][$i]==2)?'checked':''; ?> disabled><br>
													</td>
													<td>
														<input type="radio" name="answerRadio[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerRadio[]" value="3" <?php echo ($detail['radio'][$i]==3)?'checked':''; ?> disabled><br>
													</td>
													<td>
														<input type="radio" name="answerRadio[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerRadio[]" value="4" <?php echo ($detail['radio'][$i]==4)?'checked':''; ?> disabled><br>
													</td>
													<td>
														<input type="radio" name="answerRadio[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerRadio[]" value="5" <?php echo ($detail['radio'][$i]==5)?'checked':''; ?> disabled><br>
													</td>
												</tr>
											<?php } ?>
										</tbody>
									</table>
								</div>
							<?php } else { ?>
								<div class="form-row">
									<div class="col-12">
										<div class="form-group">
											<?php if($detail['question_category_id'] == $detail['category_id']){ ?>
												<?php for($i=0; $i<sizeof($detail['qtn']); $i++){ ?>
													<label for="attend"><?php echo $detail['qtn'][$i]; ?></label>
													<textarea rows="3" cols="50" class="form-control" name="answerText[<?php echo $detail['qtn_id'][$i]; ?>]" id="answerText[]" value="" readonly><?php echo (!empty($detail['txt']))?$detail['txt'][$i]:''; ?></textarea><br>
												<?php } ?>
											<?php } ?>
										</div>
									</div>
								</div>
							<?php } ?>
						<?php } } ?>
					</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="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" style="width: 0px;">
					#
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Training title
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Date of training
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Packages
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Venue
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Respective Department / Branch
				</th>
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					CPD / CPE hours
				</th>    
				<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
					Name of Trainer/Speaker
				</th>       
			</thead>

            <tbody>
				<?php $i=1; if(!empty($trainingEvaluation) && is_array($trainingEvaluation)){ foreach($trainingEvaluation as $key => $row){ ?>
	            	<tr>
                    	<td class="text-center"><?php echo $i++; ?></td>
	                    <td><?php echo $row['training_title']; ?></td>
                        <td class="text-center"><?php echo date('d-m-Y',strtotime($row['training_date'])) . '<br> (' . $row['time'].')'; ?></td>
	                    <td class="text-center"><?php echo $row['packages']; ?></td>
	                    <td><?php echo $row['venue']; ?></td>
                        <td class="text-center"><?php echo $row['dept_name']. ' / ' . $row['branchName']; ?></td>
                        <td class="text-center"><?php echo $row['cpd_hours']; ?></td>
	                    <td><?php echo $row['trainer_name']; ?></td>
	                </tr>
	            <?php } } ?>
	        </tbody>	
		</table>	
	</div>
<?php } ?>