		<div class="container-fluid" style="padding-bottom: 2rem;">
			<div class="card bg-light-transparent">  
				<div class="card-header bg-white">
					<div class="float-left">
						<h4>Police Report List</h4>		
						<a href="<?php echo base_url('hr/serviceform/police_report_form'); ?>" class="btn btn-outline-dark btn-sm" title="Add New report">
							<i class="fa fa-plus"></i> Add New Report</a>
							<a href="<?php echo base_url('hr/Serviceform_report/policereport_print')?>" target="_blank" class="btn btn-outline-dark btn-sm" title="Print"><i class="fa fa-print"></i>Print</a>
							<a id="btnShowFilters" type="button" class="btn btn-outline-dark btn-sm collapsed" data-trigger="hover" title="Show Filters Box" data-toggle="collapse" data-target="#collapseFilter" aria-expanded="false">
								<i class="fas fa-filter"></i>Show Filters
							</a> 
					</div>
				</div>

				<div class="collapse" id="collapseFilter">
					<div class="card-header">
						<div class="row">
							<div class="col">
								<div class="card no-shadow">
									<div class="card-body">
										<input type="hidden" name="user_id" id="user_id" value="<?php echo $_SESSION['user']['id']; ?>">
										<?php if($_SESSION['module_data']['role']=='admin'){ ?>
											<div class="form-group row">
												<label for="sv_police_filter_dept" class="col-lg-3">
													Department
												</label>                           
												<div class="col-lg-4" >
													<select class="custom-select" name="sv_police_filter_dept" id="sv_police_filter_dept">
														<option value="-1">[All]</option>
														<?php if($department) foreach($department as $row){ ?>
															<option value="<?php echo $row['id']; ?>"><?php echo $row['name'].' ['.$row['branch_name'].']'; ?></option> 
														<?php } ?>
													</select>
												</div>
											</div>
										<?php } ?>
										<div class="form-group row">
											<label for="sv_police_filter_year" class="col-lg-3">
												Year
											</label>                           
											<div class="col-lg-4" >
												<input type="text" name="sv_police_filter_year" id="sv_police_filter_year" class="form-control datepicker-yyyy">
											</div>
										</div>
										<div class="form-group row">
											<label for="sv_police_filter_month" class="col-lg-3">
												Requested Month
											</label>                           
											<div class="col-lg-4" >
												<input type="text" name="sv_police_filter_month" id="sv_police_filter_month" class="form-control datepicker-mm">
											</div>
										</div>
										<div class="row">
											<div class="col d-print-none">
												<button class="btn btn-info" id="searchBtn">Search</button>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>  
				</div>

				<div class="tab-content">
					<div class="tab-pane fade active show" id="tableView" role="tabpanel" aria-labelledby="nav-table-tab">
						<div class="card-body">
							<div class="card no-shadow">
								<div class="card-body">
									<div class="table-responsive">
										<table id="filter_table_police" class="table table-bordered p-0 m-0" width="100%">
											<thead>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" aria-label="#: activate to sort column ascending" style="width: 0px;">
													#
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Incident date and time
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Reported date and time
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Equipment Damaged / Lost / Stolen
												</th>
												<!-- <th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Equipment No.
												</th> -->
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Person Responsible for Equipment
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Police File
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Officer In Charge
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Contact No
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="1" colspan="1" style="width: 0px;">
													Attachment
												</th>
												<th class="sorting text-center" tabindex="0" aria-controls="table_contact" rowspan="" colspan="1" style="width: 0px;">
													Action
												</th>           
											</thead>

											<tbody>
												<?php //die(debug($listPoliceReport)); ?>
												<?php if(!empty($listPoliceReport)) { ?>
													<?php foreach ($listPoliceReport as $key => $row) {  ?>
														<tr>
															<td class="text-center"><?php echo $key+1; ?></td>
															<td class="text-center"><?php echo date ('d-m-Y',strtotime($row['incident_date'])); ?><br>
																<?php echo $row['incident_time']; ?>
															</td>
															<td class="text-center"><?php echo date ('d-m-Y',strtotime($row['reported_date'])); ?><br>
																<?php echo $row['time_reported']; ?>
															</td>
															<td><?php echo $row['equipment_damaged']; ?></td>
															<!-- <td><?php //echo $row['equipment_number']; ?></td> -->
															<td><?php echo $row['responsible_person']; ?></td>
															<td><?php echo $row['police_file']; ?></td>
															<td><?php echo $row['officer_incharge']; ?></td>
															<td><?php echo $row['contact_no']; ?></td>
															<td>
																<a download href="<?php echo base_url($row['file_location'].$row['file_title']); ?>" ><?php echo $row['file_title']; ?></a>
															</td>
															<td class="text-center"> 
																<div class="btn-group btn-group-sm" role="group">
																	<button type="button" class="btn btn-outline-dark" data-toggle="modal" data-target="#viewDetails" data-trigger="hover" data-tooltip="tooltip" 
																	title="View Detail" 
																	data-name="<?php echo $row['requestor']; ?>" 
																	data-dept="<?php echo $row['dept_name'].'/'.$row['branchName']; ?>" 
																	data-datereq="<?php echo date('d-m-Y',strtotime($row['createdTS'])); ?>" 
																	data-position="<?php echo $row['position']; ?>" 
																	data-phone="<?php echo $row['phone']; ?>" 
																	data-location="<?php echo $row['location']; ?>" 
																	data-incidentdate="<?php echo date('d-m-Y',strtotime($row['incident_date'])); ?>" 
																	data-incidenttime="<?php echo $row['incident_time']; ?>" 
																	data-report="<?php echo date('d-m-Y',strtotime($row['reported_date'])); ?>" 
																	data-reporttime="<?php echo $row['time_reported']; ?>" 
																	data-sv="<?php echo $row['supervisor']; ?>" 
																	data-damage="<?php echo $row['equipment_damaged']; ?>" 
																	data-id="<?php echo $row['equipment_number']; ?>" 
																	data-loc_damage="<?php echo $row['equipment_location']; ?>" 
																	data-condition="<?php echo $row['reason_damage']; ?>" 
																	data-description= "<?php echo $row['description_damage']; ?>" 
																	data-cost="<?php echo $row['repair_cost']; ?>" 
																	data-report_police="<?php echo $row['police_report']?>"
																	data-responsible="<?php echo $row['responsible_person']; ?>"  
																	data-police_file="<?php echo $row['police_file']; ?>" 
																	data-officer="<?php echo $row['officer_incharge']; ?>" 
																	data-station="<?php echo $row['station']; ?>" 
																	data-contactno="<?php echo $row['contact_no']; ?>" 
																	data-attachment="<?php echo$row['file_title']; ?>" 
																	onclick="open_view_modal(this)">
																	<i class="far fa-eye"></i></button>

																	<?php if(($_SESSION['user']['id'] == $row['user_id']) || ($_SESSION['user']['id'] == $row['createdBY'])){ ?>
																		<a href="<?php echo base_url('hr/serviceform/police_report_form/'.$row['ID']); ?>" class="btn btn-outline-dark btn-sm" data-tooltip="tooltip" data-trigger="hover" title="Edit Police Report"  data-original-title="Go To My Department's Applications"><i class="far fa-edit"></i></a>
																	<?php } ?>

																	<a type="button" class="btn btn-outline-dark" href="<?php echo base_url('hr/serviceform_report/policereport_print/').$row['ID']; ?>" target="_blank" data-trigger="hover" data-tooltip="tooltip" title="Print Detail"><i class="fa fa-print"></i></a>

																	<?php if(($_SESSION['user']['id'] == $row['user_id']) || ($_SESSION['user']['id'] == $row['createdBY'])){ ?>
																		<button id="deleteButton" type="button" class="btn btn-outline-dark" onclick="deleteData(<?php echo $row['ID']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete"><i class="far fa-trash-alt"></i></button>
																	<?php } ?>
																</div>
															</td>
														</tr>
													<?php }?>
												<?php } ?>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	<!-- modal view detail -->

	<div class="modal fade d-print-none" id="viewDetails" role="dialog" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="exampleModalLongTitle">Police Report Detail</h5>&emsp;
					<!-- <a href="javascript:window.print()" class="btn btn-outline-dark btn-sm" title="Print"><i class="fa fa-print"></i>Print</a> -->
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>

				<div class="modal-body">
					<div class="row">
						<div class="col-4">
							<label>Name</label>
							<input type="text" class="form-control" name="modal_view_name" id="modal_view_name" disabled>
						</div>
						<div class="col-4">
							<label>Department</label>
							<input type="text" class="form-control" name="modal_view_dept" id="modal_view_dept" disabled>
						</div>
						<div class="col-4">
							<label>Date Request</label>
							<input type="text" class="form-control" name="modal_view_date_req" id="modal_view_date_req" disabled>
						</div>
					</div>
					<div class="row">
						<div class="col-4">
							<label>Position/Title</label>
							<input type="text" class="form-control" name="modal_view_position" id="modal_view_position" disabled>
						</div>
						<div class="col-4">
							<label>Phone</label>
							<input type="text" class="form-control" name="modal_view_phone" id="modal_view_phone" disabled>
						</div>
						<div class="col-4">
							<label>Specific Location</label>
							<input type="text" class="form-control" name="modal_view_location" id="modal_view_location" disabled>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<label>Incident Date</label>
							<input type="text" class="form-control" name="modal_view_incidentdate" id="modal_view_incidentdate" disabled>
						</div>
						<div class="col-4">
							<label>Time of Incident</label>
							<input type="text" class="form-control" name="modal_view_incidenttime" id="modal_view_incidenttime" disabled>
						</div>
						<div class="col-4">
							<label>Reported on</label>
							<input type="text" class="form-control" name="modal_view_report" id="modal_view_report" disabled>
						</div>
					</div>
					<div class="row">
						<div class="col-6">
							<label>Time Reported</label>
							<input type="text" class="form-control" name="modal_view_reporttime" id="modal_view_reporttime" disabled>
						</div>
						<div class="col-6">
							<label>Supervisor</label>
							<input type="text" class="form-control" name="modal_view_sv" id="modal_view_sv" disabled>
						</div>
					</div>

					<div class="row">
						<div class="col-6">
							<label>Equipment Damaged / Lost / Stolen</label>
							<input type="text" class="form-control" name="modal_view_damage" id="modal_view_damage" disabled>
						</div>
						<div class="col-6">
							<label>Equipment Identification Number(s)</label>
							<input type="text" class="form-control" name="modal_view_id" id="modal_view_id" disabled>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<label>Equipment Location at Time of Damage / Loss</label>
							<input type="text" class="form-control" name="modal_view_loc_damage" id="modal_view_loc_damage" disabled>
						</div>
						<div class="col-4">
							<label>How Was the Equipment Damaged / Lost / Stolen?</label>
							<input type="text" class="form-control" name="modal_view_condition" id="modal_view_condition" disabled>
						</div>
						<div class="col-4">
							<label>Description of Damage to Equipment</label>
							<input type="text" class="form-control" name="modal_view_description" id="modal_view_description" disabled>
						</div>
					</div>
					<div class="row">
						<div class="col-6">
							<label>Estimated Cost of Repair / Replacement</label>
							<input type="text" class="form-control" name="modal_view_cost" id="modal_view_cost" disabled>
						</div>
						<div class="col-6">
							<label>Person Responsible for Equipment</label>
							<input type="text" class="form-control" name="modal_view_responsible" id="modal_view_responsible" disabled>
						</div>
					</div>

					<div class="row">
						<div class="col-4">
							<label>Was the Equipment Damage / Loss / Theft reported to the Police?</label>
							<input type="text" class="form-control" name="modal_view_report_police" id="modal_view_report_police" disabled>
						</div>
						<div class="col-4">
							<label>Police File</label>
							<input type="text" class="form-control" name="modal_view_police_file" id="modal_view_police_file" disabled>
						</div>
						<div class="col-4">
							<label>Officer In Charge</label>
							<input type="text" class="form-control" name="modal_view_officer" id="modal_view_officer" disabled>
						</div>
					</div>
					<div class="row">
						<div class="col-4">
							<label>Station</label>
							<input type="text" class="form-control" name="modal_view_station" id="modal_view_station" disabled>
						</div>
						<div class="col-4">
							<label>Contact No</label>
							<input type="text" class="form-control" name="modal_view_contactno" id="modal_view_contactno" disabled>
						</div>
						<div class="col-4">
							<label>Police report attachment</label>
							<input type="text" class="form-control" name="modal_view_attachment" id="modal_view_attachment" disabled>
						</div>
					</div>
					<br>
					<div class="float-right"></div>
				</div>
			</div>
		</div>
	</div>

	<!-- modal view detail -->


	<script>

		function open_view_modal(elem) 
		{
			let name            = $(elem).data('name');
			let dept            = $(elem).data('dept');
			let datereq         = $(elem).data('datereq');
			let position        = $(elem).data('position');
			let phone           = $(elem).data('phone');
			let location        = $(elem).data('location');
			let incidentdate    = $(elem).data('incidentdate');
			let incidenttime    = $(elem).data('incidenttime');
			let report          = $(elem).data('report');
			let reporttime      = $(elem).data('reporttime');
			let sv              = $(elem).data('sv');
			let damage          = $(elem).data('damage');
			let id              = $(elem).data('id');
			let loc_damage      = $(elem).data('loc_damage');
			let condition       = $(elem).data('condition');
			let description     = $(elem).data('description');
			let cost            = $(elem).data('cost');
			let responsible     = $(elem).data('responsible');
			let report_police   = $(elem).data('report_police');
			let police_file     = $(elem).data('police_file');
			let officer         = $(elem).data('officer');
			let station         = $(elem).data('station');
			let contactno       = $(elem).data('contactno');
			let attachment      = $(elem).data('attachment');
				// console.log(dept);
				
				/* view modal */
				$('#modal_view_name').val(name);
				$('#modal_view_dept').val(dept);
				$('#modal_view_date_req').val(datereq);
				$('#modal_view_position').val(position);
				$('#modal_view_phone').val(phone);
				$('#modal_view_location').val(location);
				$('#modal_view_incidentdate').val(incidentdate);
				$('#modal_view_incidenttime').val(incidenttime);
				$('#modal_view_report').val(report);
				$('#modal_view_reporttime').val(reporttime);
				$('#modal_view_sv').val(sv);
				$('#modal_view_damage').val(damage);
				$('#modal_view_id').val(id);
				$('#modal_view_loc_damage').val(loc_damage);
				$('#modal_view_condition').val(condition);
				$('#modal_view_description').val(description);
				$('#modal_view_cost').val(cost);
				$('#modal_view_responsible').val(responsible);

				if (report_police == 1)
				{
					$('#modal_view_report_police').val('Yes');
				} else
				{
					$('#modal_view_report_police').val('No');
				}

				$('#modal_view_police_file').val(police_file);
				$('#modal_view_officer').val(officer);
				$('#modal_view_station').val(station);
				$('#modal_view_contactno').val(contactno);
				$('#modal_view_attachment').val(attachment);
			}

			function deleteData(ID) {
				validateForm("#deleteButton", "Delete this police report list?", function() {
					$.ajax({
						url:'<?php echo base_url('hr/serviceform/deletePoliceReportList') ?>',
						data: {
							policeReportID : ID,
						},
						type: 'post',
						dataType: 'json',
						success: (data) => {
							if(data.status == "Success") {

								localStorage.setItem("status", data.status);
								localStorage.setItem("msg", data.msg);

								location.reload();

							// redirect(base_url('hr/serviceform/hotel_list'));
						}
					}
				});
				});
			}

			$(document).ready(function(){

				//getData();

				$('#searchBtn').click(function(){
					getData();
				});

			});

			function getData() {
				var table = $('#filter_table_police').DataTable();
				// $('#table_equipment').DataTable().destroy();
				table.clear().draw();
				var frmData = new FormData();

				frmData.append('sv_police_filter_dept',$('#sv_police_filter_dept').val());
				frmData.append('sv_police_filter_year',$('#sv_police_filter_year').val());
				frmData.append('sv_police_filter_month',$('#sv_police_filter_month').val());
				frmData.append('user_id',$('#user_id').val());

				$.ajax({
					url:"<?php echo base_url('/hr/api/serviceform/get_police_filter'); ?>",
					type:'post',
					dataType:'json',
					data:frmData,
					processData: false,
					contentType: false,
					success:function(data){

						iziToast.success({
							position: 'bottomRight',
							message: 'filtering data',
						});

						let policereport = data.table;

						if(policereport != null){
							var index = 1;
							$.each(policereport,function(key,content)
							{
								var i = key + 1;
								console.log(content);

								if(content.incident_date != '0000-00-00'){
									var incident_date = moment(content.incident_date).format('DD-MM-YYYY');;
								}
								if(content.reported_date != '0000-00-00'){
									var reported_date = moment(content.reported_date).format('DD-MM-YYYY');;
								}

								if(content.file_title != null && content.file_title != '' && content.file_title != undefined){
									var download_file = '<a download href="<?php echo base_url();?>hr/serviceform_report/policereport_print/'+content.file_location+content.file_title+'">'+content.file_title+'</a>';
								}else{
									var download_file = '';
								}

								var btn_view = '<button type="button" class="btn btn-outline-dark" data-toggle="modal" data-target="#viewDetails" data-trigger="hover" data-tooltip="tooltip" title="View Detail" data-name="'+content.requestor+'" data-dept="'+content.dept_name+'/'+content.branchName+'" data-datereq="'+moment(content.createdTS).format('DD-MM-YYYY')+'" data-position="'+content.position+'" data-phone="'+content.phone+'" data-location="'+content.location+'" data-incidentdate="'+content.incident_date+'" data-incidenttime="'+content.incident_time+'" data-report="'+reported_date+'" data-reporttime="'+content.time_reported+'" data-sv="'+content.supervisor+'" data-damage="'+content.equipment_damaged+'" data-id="'+content.equipment_number+'" data-loc_damage="'+content.equipment_location+'" data-condition="'+content.reason_damage+'" data-description="'+content.description_damage+'" data-cost="'+content.repair_cost+'" data-responsible="'+content.responsible_person+'" data-police_file="'+content.police_file+'" data-officer="'+content.officer_incharge+'" data-station="'+content.station+'" data-contactno="'+content.contact_no+'" data-attachment="'+content.file_title+'" onclick="open_view_modal(this)"> <i class="far fa-eye"></i> </button>';

								var btn_print = '<a type="button" class="btn btn-outline-dark" href="<?php echo base_url();?>hr/serviceform_report/policereport_print/'+content.ID+'" target="_blank" data-trigger="hover" data-tooltip="tooltip" title="Print Detail"><i class="fa fa-print"></i></a>';

								var btn_edit = '<a type="button" class="btn btn-outline-dark" href="<?php echo base_url();?>hr/serviceform/police_report_form/'+content.ID+'" data-trigger="hover" data-tooltip="tooltip" title="Edit"><i class="far fa-edit"></i></a>';

								var btn_delete = '<button type="button" class="btn btn-outline-dark" onclick="delete_equipment('+content.ID+')" data-trigger="hover" data-tooltip="tooltip" title="Delete"><i class="far fa-trash-alt"></i></button>';

								if(('<?php echo $_SESSION['user']['id']; ?>' == content.borrower_id) || ('<?php echo $_SESSION['user']['id']; ?>' == content.createdBY))
		                        {
		                            var btn = btn_view+btn_edit+btn_print+btn_delete;
		                        }else{
		                            var btn = btn_view+btn_print;
		                        }

								table.row.add({
									0   : '<div class="text-center">'+i+'</div>',
									1   : '<div class="text-center">'+incident_date+' <br> '+content.incident_time+'</div>',
									2   : '<div class="text-center">'+reported_date+' <br> ' +content.time_reported+'</div>',
									3	: content.equipment_damaged,
									4   : content.responsible_person,
									5   : content.police_file,
									6   : content.officer_incharge,
									7   : content.contact_no,
									8   : download_file,
									9	: '<div class="text-center"><div class="btn-group btn-group-sm" role="group">'+btn+'</div>',
								}).draw();
								console.log(data);

							});                        
						}

					},
					error:function(){
						iziToast.warning({
							position: 'bottomRight',
							message: '500 Internal Server Error.'
						});
					}
				});
			}
	</script>