<?php
	if(($this->session->userdata('sv_police_filter_month') && $this->session->userdata('sv_police_filter_month') != 'no result')){
		if($this->session->userdata('sv_police_filter_month') == '01'){
	         $month = "JANUARY";
	    }else if($this->session->userdata('sv_police_filter_month') == '02'){
	         $month = "FEBRUARY";
	    }else if($this->session->userdata('sv_police_filter_month') == '03'){
	         $month = "MARCH";
	    }else if($this->session->userdata('sv_police_filter_month') == '04'){
	         $month = "APRIL";
	    }else if($this->session->userdata('sv_police_filter_month') == '05'){
	         $month = "MAY";
	    }else if($this->session->userdata('sv_police_filter_month') == '06'){
	         $month = "JUNE";
	    }else if($this->session->userdata('sv_police_filter_month') == '07'){
	         $month = "JULY";
	    }else if($this->session->userdata('sv_police_filter_month') == '08'){
	         $month = "AUGUST";
	    }else if($this->session->userdata('sv_police_filter_month') == '09'){
	         $month = "SEPTEMBER";
	    }else if($this->session->userdata('sv_police_filter_month') == '10'){
	         $month = "OCTOBER";
	    }else if($this->session->userdata('sv_police_filter_month') == '11'){
	         $month = "NOVEMBER";
	    }else if($this->session->userdata('sv_police_filter_month') == '12'){
	         $month = "DECEMBER";
        }else if($this->session->userdata('sv_police_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>
					<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_police_filter_dept')) && $this->session->userdata('sv_police_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>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_police_filter_year')))?($this->session->userdata('sv_police_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_stationerysv_police_filter_month_filter_month')))?$month:'ALL'; ?></b></span></td>
							</tr>
						</table>
					</td>
				</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 POLICE REPORT</b></h3>
				</div>
			</div>
			<div class="row">
				<div class="col">
					<p style="border-top: 3px solid; width: 31rem;"></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($listPoliceReport[0]['requestor']))?$listPoliceReport[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($listPoliceReport[0]['staff_id']))?strtoupper($listPoliceReport[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($listPoliceReport[0]['dept_name']))?$listPoliceReport[0]['dept_name'].'/'.$listPoliceReport[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($listPoliceReport[0]['createdTS']))?date('d-m-Y',strtotime($listPoliceReport[0]['createdTS'])):''; ?>
								</p>
							</div>
						</div>

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

                        <div class="row">
							<div class="col-4">
								<b>PHONE NO.</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listPoliceReport[0]['phone']))?$listPoliceReport[0]['phone']:''; ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>INCIDENT DATE AND TIME</b>
							</div>
							<div class="col">
								<p class="report-font">: 
								    <?php echo (!empty($listPoliceReport[0]['incident_date'] && $listPoliceReport[0]['incident_time']))?date('d-m-Y',strtotime($listPoliceReport[0]['incident_date'])).' / '.$listPoliceReport[0]['incident_time']:'N/A'; ?>
								</p>
							</div>
						</div>

						<div class="row">
							<div class="col-4">
								<b>REPORTED DATE AND TIME</b>
							</div>
							<div class="col">
								<p class="report-font">:
                                    <?php echo (!empty($listPoliceReport[0]['reported_date'] && $listPoliceReport[0]['time_reported']))?date('d-m-Y',strtotime($listPoliceReport[0]['reported_date'])).' / '.$listPoliceReport[0]['time_reported']:'N/A'; ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>EQUIPMENT DAMAGE/LOST/STOLEN</b>
							</div>
							<div class="col">
								<p class="report-font">: 
                                    <?php echo (!empty($listPoliceReport[0]['equipment_damaged']))?$listPoliceReport[0]['equipment_damaged']:''; ?>
								</p>
							</div>
						</div>

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

                        <div class="row">
							<div class="col-4">
								<b>EQUIPMENT LOCATION AT TIME OF DAMAGE/LOSS</b>
							</div>
							<div class="col">
								<p class="report-font">: 
                                    <?php echo (!empty($listPoliceReport[0]['equipment_location']))?$listPoliceReport[0]['equipment_location']:''; ?>
								</p>
							</div>
						</div>

                        <div class="row">
							<div class="col-4">
								<b>HOW WAS THE EQUIPMENT DAMAGED/LOSS/STOLEN</b>
							</div>
							<div class="col">
								<p class="report-font">: 
                                    <?php echo (!empty($listPoliceReport[0]['reason_damage']))?$listPoliceReport[0]['reason_damage']:''; ?>
								</p>
							</div>
						</div>

                        <div class="row">
							<div class="col-4">
								<b>DESCRIPTION OF DAMAGE TO EQUIPMENT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
                                    <?php echo (!empty($listPoliceReport[0]['description_damage']))?$listPoliceReport[0]['description_damage']:''; ?>
								</p>
							</div>
						</div>

                        <div class="row">
							<div class="col-4">
								<b>ESTIMATED COST OF REPAIR/REPLACEMENT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
                                    <?php echo (!empty($listPoliceReport[0]['repair_cost']))?$listPoliceReport[0]['repair_cost']:''; ?>
								</p>
							</div>
						</div>

                        <div class="row">
							<div class="col-4">
								<b>PERSON RESPONSIBLE FOR EQUIPMENT</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listPoliceReport[0]['responsible_person']))?$listPoliceReport[0]['responsible_person']:''; ?>
								</p>
							</div>
						</div>

                        <div class="row">
							<div class="col-4">
								<b>WAS THE EQUIPMENT DAMAGE/LOSS/THEFT REPORTED TO THE POLICE</b>
							</div>
                            <div class="col">
								<p class="report-font">: 
									<?php if ($listPoliceReport[0]['police_report'] == 1){
                                        echo 'Yes';
                                    } else {
                                        echo 'No';
                                    } ?>
								</p>
							</div>
						</div>

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

						<div class="row">
							<div class="col-4">
								<b>OFFICER IN CHARGE</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listPoliceReport[0]['officer_incharge']))?$listPoliceReport[0]['officer_incharge']:''; ?>
								</p>
							</div>
						</div>

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

                        <div class="row">
							<div class="col-4">
								<b>CONTACT NO.</b>
							</div>
							<div class="col">
								<p class="report-font">: 
									<?php echo (!empty($listPoliceReport[0]['contact_no']))?$listPoliceReport[0]['contact_no']:''; ?>
								</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="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;">
				Incident date and time
			</th>
			<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Reported date and time
			</th>
			<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Equipment Damaged / Lost / Stolen
			</th>
			<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Person Responsible for Equipment
			</th>
            <th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Police File No.
			</th>
			<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Officer In Charge
			</th>
			<th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Contact No
			</th> 
            <th class="sorting border-top text-center" tabindex="0" rowspan="1" colspan="1" style="width: 0px;">
                Attachment
			</th>             
		</thead>	

        <tbody>
			<?php $i=1; if(!empty($listPoliceReport) && is_array($listPoliceReport)) { foreach($listPoliceReport as $key => $row){ ?>
		        <tr>
                    <td class="text-center"><?php echo $i++; ?></td>
                    <td class="text-center"><?php echo date('d-m-Y',strtotime($row['incident_date'])).'<br> (' .$row['incident_time']. ')'; ?>
                    </td>
		            <td class="text-center"><?php echo date('d-m-Y',strtotime($row['reported_date'])).'<br> ('. $row['time_reported']. ')'; ?>
                    </td>
		            <td><?php echo $row['equipment_damaged']; ?></td>
		            <td><?php echo $row['responsible_person']; ?></td>
                    <td><?php echo $row['police_file'] ?></td>
					<td><?php echo $row['officer_incharge'] ?></td>
                    <td class="text-center"><?php echo $row['contact_no'] ?></td>
                    <td><?php echo $row['file_title']; ?></td>
		        </tr>
		    <?php } } ?>
		</tbody>
	</table>
</div>	
<?php } ?>



