<section class="container" style="padding-bottom: 2rem;">
	<div class="row">
		<div class="col-sm-12">
			<div class="tab-content" id="tabContent">
				<div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="profile-tab">
					<div class="card bg-light-transparent">
						<div class="card-header bg-light">
							<h4 class="card-title float-left"><?php echo (empty($ID))?'New ':'Edit '; ?>Police Report</h4>
							<h6 class="card-title float-left"><i>SALIHIN employees are required to report any damage, loss or theft of SALIHIN owned and operated equipment as soon as possible and submit a completed copy of this form within 24 hours of the incident. 
								<br><br>
							Please note that where an injury occurs as a result of any damage, loss or theft of SALIHIN owned and operated equipment, employees are required to report the incident immediately, and submit a completed Incident Report and Investigation Form.</i></h6>
						</div>
						<div class="card-body">
							<div class="card no-shadow">
								<div class="card-body">
									<?php //die(debug($policeReportDetails)); ?>
									<?php if(!empty($ID)) { ?>
										<form id="requestForm" class="form" action="<?php echo base_url('hr/Serviceform/police_report_edit') ?>" method="POST" enctype="multipart/form-data" onsubmit="return confirm('Do you really want to submit the form?')">
										<?php } else { ?>
											<form id="policereportForm" class="form" action="<?php echo base_url('hr/Serviceform/police_report_save') ?>" method="POST" enctype="multipart/form-data" onsubmit="return confirm('Do you really want to submit the form?')">
											<?php } ?>

											<input type="text" class="form-control" name="policeReportID" id="policeReportID" value="<?php echo $ID; ?>" hidden>

											<?php if(!empty($policeReportDetails)){ ?>
												<input type="text" class="form-control" name="upload_id" id="upload_id" value="<?php echo $policeReportDetails[0]['uploadID'];?>" hidden>
											<?php } ?>

											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="empno">Name</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="name" id="name" value="<?php echo $row['requestor']; ?>" readonly>
																<input type="text" class="form-control" name="reqName_id" id="reqName_id" value="<?php echo $row['user_id']; ?>" hidden>
															<?php endforeach;endif; ?>
														<?php } else { ?>
															<input type="text" class="form-control" name="name" id="name" value="<?php echo $_SESSION['user']['name']; ?>" readonly>
															<input type="text" class="form-control" name="reqName_id" id="reqName_id" value="<?php echo $_SESSION['user']['id']; ?>" hidden>
														<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="dept">Department</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="department" id="department" value="<?php echo $row['dept_name']; ?>" readonly>
																<input type="text" class="form-control" name="department_id" id="department_id" value="<?php echo $row['department_id']; ?>" hidden>
															<?php endforeach;endif; ?>
														<?php } else { ?>
															<input type="text" class="form-control" name="department" id="department" value="<?php echo $_SESSION['user']['department_name']; ?>" readonly>
															<input type="text" class="form-control" name="department_id" id="department_id" value="<?php echo $_SESSION['user']['department_id']; ?>" hidden>
														<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="date">Date submitted</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="" class="form-control" name="reqDate" id="reqDate" value="<?php echo (!empty($ID))?date('d-m-Y',strtotime($row['createdTS'])):''; ?>" disabled/>
															<?php endforeach;endif; } else { ?>
																<input type="" class="form-control" name="date" id="date" value="<?php echo date("d-m-Y"); ?>" disabled/>
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="title">Position/Title</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="position" id="position" value="<?php echo (!empty($ID))?$row['position']:''; ?>" readonly><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="position" id="position" value="<?php echo $_SESSION['user']['position_name']; ?>" readonly>
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="Phone">Phone</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="number" class="form-control" name="phone" id="phone" value="<?php echo (!empty($ID))?$row['phone']:''; ?>" readonly>
															<?php endforeach;endif; } else{ ?>
																<input type="number" class="form-control" name="phone" id="phone" value="<?php echo $user_phone; ?>" readonly>
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="Location">Specific Location</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="location" id="location" value="<?php echo (!empty($ID))?$row['location']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="location" id="location" value=""  >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="date">Incident Date</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control datepicker" name="incident_date" id="incident_date" value="<?php echo date('d-m-Y',strtotime($row['incident_date'])); ?>" > 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control datepicker" name="incident_date" id="incident_date" value="" >
															<?php } ?>
													</div>
												</div>


												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="time">Time of Incident</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="time" class="form-control" name="incident_time" id="incident_time" value="<?php echo (!empty($ID))?$row['incident_time']:''; ?>" > 
															<?php endforeach;endif; } else{ ?>
																<input type="time" class="form-control" name="incident_time" id="incident_time" value="" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="date">Reported on</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control datepicker" name="reported_date" id="reported_date" value="<?php echo date('d-m-Y',strtotime($row['reported_date'])); ?>" >
															<?php endforeach;endif; } else { ?>
																<input type="text" class="form-control datepicker" name="reported_date" id.="reported_date" value="" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-3">
													<div class="form-group">
														<label for="time">Time Reported</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="time" class="form-control" name="time_reported" id="time_reported" value="<?php echo (!empty($ID))?$row['time_reported']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="time" class="form-control" name="time_reported" id="time_reported" value="" >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="sv">Supervisor Name</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="supervisor" id="supervisor" value="<?php echo (!empty($ID))?$row['supervisor']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="supervisor" id="supervisor" value="" >
															<?php } ?>
													</div>
												</div>
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="loss">Equipment Damaged / Lost / Stolen</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="equipment_damaged" id="equipment_damaged" value="<?php echo (!empty($ID))?$row['equipment_damaged']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="equipment_damaged" id="equipment_damaged" value="" >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">	
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="idno">Equipment Identification Number(s)</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="number" class="form-control" name="equipment_number" id="equipment_number" value="<?php echo (!empty($ID))?$row['equipment_number']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="number" class="form-control" name="equipment_number" id="equipment_number" value="" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="Location">Equipment Location at Time of Damage / Loss</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="equipment_location" id="equipment_location" value="<?php echo (!empty($ID))?$row['equipment_location']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="equipment_location" id="equipment_location" value="" >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-6 ">
													<div class="form-group">
														<label for="how">How Was the Equipment Damaged / Lost / Stolen?</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<textarea rows="4" cols="50" class="form-control" name="reason_damage" id="reason_damage"  value="" ><?php echo (!empty($ID))?$row['reason_damage']:''; ?></textarea>
															<?php endforeach;endif; } else{ ?>
																<textarea rows="4" cols="50" class="form-control" name="reason_damage" id="reason_damage" value="" ></textarea>
															<?php } ?>
													</div>
												</div>

												<div class="col-6">
													<div class="form-group">
														<label for="desc">Description of Damage to Equipment</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<textarea rows="4" cols="50" class="form-control" name="description_damage" id="description_damage" value="" ><?php echo (!empty($ID))?$row['description_damage']:''; ?></textarea>
															<?php endforeach;endif; } else{ ?>
																<textarea rows="4" cols="50" class="form-control" name="description_damage" id="description_damage" value="" ></textarea>
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="Cost">Estimated Cost of Repair / Replacement</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="number" class="form-control" name="repair_cost" id="repair_cost" value="<?php echo (!empty($ID))?$row['repair_cost']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="number" class="form-control" name="repair_cost" id="repair_cost" value="" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="Responsible">Person Responsible for Equipment</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="responsible_person" id="responsible_person" value="<?php echo (!empty($ID))?$row['responsible_person']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="responsible_person" id="responsible_person" value="" >
															<?php } ?>
													</div>
												</div>
											</div>
											<hr>
											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label>Was the Equipment Damage / Loss / Theft reported to the Police?</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<div class="row">
																	<div class="col-sm-3">
																		<input type="radio" name="police_report" value="0" <?php echo ($row['police_report'] == 0)?'checked':''; ?>> No 
																	</div>
																	<div class="col-sm-3">
																		<input type="radio" name="police_report" value="1" <?php echo ($row['police_report'] == 1)?'checked':''; ?>> Yes
																	</div>
																</div>
															<?php endforeach;endif; } else{ ?>
																<div class="row">
																	<div class="col-sm-3">
																		<input type="radio" name="police_report" value="0" checked> No 
																	</div>
																	<div class="col-sm-3">
																		<input type="radio" name="police_report" value="1" > Yes
																	</div>
																</div>
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="file">Police File</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="police_file" id="police_file" value="<?php echo (!empty($ID))?$row['police_file']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="police_file" id="police_file" value="" >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="pic">Officer In Charge</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="officer_incharge" id="officer_incharge" value="<?php echo (!empty($ID))?$row['officer_incharge']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="officer_incharge" id="officer_incharge" value="" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="Station">Station</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="text" class="form-control" name="station" id="station" value="<?php echo (!empty($ID))?$row['station']:''; ?>" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="text" class="form-control" name="station" id="station" value="" >
															<?php } ?>
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="contactno">Contact No</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="number" class="form-control" name="contact_no" id="contact_no" value="<?php echo (!empty($ID))?$row['contact_no']:''; ?>" minlength="10" maxlength="11" ><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="number" class="form-control" name="contact_no" id="contact_no" value="" minlength="10" maxlength="11" >
															<?php } ?>
													</div>
												</div>

												<div class="col-12 col-sm-6">
													<div class="form-group">
														<label for="report">Police report attachment</label>
														<?php if(!empty($ID)){ ?>
															<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																<input type="file" class="form-control" name="file_upload" id="file_upload" value=""><?php //echo (!empty($ID))?$row['topic']:''; ?> 
															<?php endforeach;endif; } else{ ?>
																<input type="file" class="form-control" name="file_upload" id="file_upload" value="">
															<?php } ?>
															<!-- <input type="file" class="form-control" name="report" id="report" value=""> -->
															<br>

															<div class="form-group form-inline">
																<?php if(!empty($ID)){ ?>
																	<?php if(!empty($policeReportDetails)): foreach($policeReportDetails as $row): ?>
																		<label for="curr_picture_upload" style="padding-right: 12px;">Current picture :</label>
																		<input class="form-control" style="width: 76%;" type="text" name="curr_picture_upload" id="curr_picture_upload" value="<?php echo (!empty($ID))?$row['file_title']:''; ?>" aria-describedby="attachmentHelp" readonly>
																<?php endforeach;endif; } ?>
															</div>	
													</div>
												</div>
											</div>

											<div class="form-row">
												<div class="col-12">
													<div class="float-right" style="padding-top: 2rem;">
														<a class="btn btn-light" href="<?php echo base_url('hr/serviceform/policereport_list/'); ?>">Cancel</a>
														<button type="submit" class="btn btn-primary">Submit</button>
													</div> 
												</div>
											</div> 
										</form>
									</form>
								</div>
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
	</div>
</section>