<?php
session_start();
$where 					= " WHERE 1=1 ";
$next_page_condition 	= "";
$paging ="";

if($_REQUEST['start']){
	$paging .="&start=".$_REQUEST['start'];
}
if(isset($_REQUEST["from"]) && $_REQUEST["from"] !=""){
	$_SESSION["from"] = $_REQUEST["from"];
}
if(isset($_REQUEST['id']) && $_REQUEST['id'] !=""){
	$where .= " AND id = ".$_REQUEST['id']." ";
}
###########################################  PAGING WITH PER PAGE  #####################################
$file_name		= "index"; // this is file name which is used during paging  , included at the bottom of the page
$table_name		= "admin";
$paging_table_name	= $table_name;
$paging_query		= $where;
$join_query_for_paging = "SELECT * FROM $table_name  $where ";
include("paging/paging_query.inc.php");
############################################ END PAGING WITH PER PAGE  #######################################
$query = "SELECT * FROM $table_name $where ";
$rs = mysqli_query($conn,$query);
$user_row = mysqli_fetch_assoc($rs);
$user_row=utility::validate_crypt_data($user_row);
?>
<style>
	.form-group .control-label {
		padding-top: 0px;
	}

	.content {
		min-height: 0px;
	}

	.content-header h1 {
		float: left;
		padding-bottom: 10px;
	}

	#example1 {
		border-collapse: collapse;
	}

	#example1 th,
	#example1 td {
		border: none;
		padding: 8px;
	}
	.responsebar {
    position: sticky; /* Makes the section sticky */
    top: 0; /* Keeps it at the top of the viewport */
    z-index: 1037; /* Ensures it stays above other elements */
    background: #fff; /* Keeps a white background for clarity */
    transition: box-shadow 0.3s ease, background 0.3s ease; /* Adds smooth effects */
}

.responsebar_active {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Adds a shadow for visual effect */
    background: #efefef; /* Changes the background when scrolled */
}
</style>
<section class="content-header responsebar">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12 col-md-6 col-sm-6">
				<div class="col-sm-6">
					<h1 style="float:left;clear:right;">
						User Details -<span style='color:#ed5c5c;'><?= ucfirst($user_row['uname']) . ' ' . ucfirst($user_row['surname']); ?></span>
						
					</h1>
				</div>
				<?
				$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
				$query_string = str_ireplace("page=admin_progress", "page=admin_view", $query_string);
			?>
				<button type="button" id="back" name="back" value="back" style="float:right;margin-bottom: 15px;"
					class="btn btn-primary"
					onclick="window.location.href = 'index?<?=$query_string.$next_page_condition.$paging;?>'">Back</button>

				<? if((isset($_REQUEST["from"]) && $_REQUEST["from"] == "admin_view") || (isset($_REQUEST["from"]) && $_REQUEST['from'] == "admin_progress")){ 
			  ?>
				<a href="index?page=add_admin&from=admin_progress&action=edit&user_id=<?=urlencode(utility::app_crypt($_REQUEST['id'],'e'));?>&id=<?=$_REQUEST['id'].$next_page_condition;?>"
					style="float:right;margin-right:5px;" class="btn btn-primary">Edit</a>
				<? } ?>
			</div>
		</div>
	</div>
</section>
<section class="content">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12 no-padding">
				<div class="row">
					<!----------------------- Message ------------------------------->
					<? if(isset($_SESSION['info_message'])){ ?>
					<div class="col-sm-12 alert alert-info alert-dismissable">
						<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
						<? echo $_SESSION['info_message']; unset($_SESSION['info_message']);?>
					</div>
					<? } ?>
					<!----------------------- End Message ------------------------------->
					<!-- general form elements -->
					<? 
						$col_width = 12;
					?>
					<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
					  <div class="scrollbar-default box box-warning card" style="height: 600px;overflow: hidden;overflow-y: scroll;">
						<form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_supp&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
						  <div class="box-body">
						  <h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Details</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="form-group col-lg-12 d-flex">
								<label for="User Reference" class="col-sm-4 control-label">User Reference</label>
								<div class="col-sm-8">
									<? echo $user_row['user_reference']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Home Telephone" class="col-sm-4 control-label">Home Telephone</label>
								<div class="col-sm-8">
									<? echo $user_row['home_phone']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="First Name" class="col-sm-4 control-label">First Name</label>
								<div class="col-sm-8">
									<? echo ucfirst($user_row['uname']); ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Surname" class="col-sm-4 control-label">Surname</label>
								<div class="col-sm-8">
									<? echo ucfirst($user_row['surname']); ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Clock No." class="col-sm-4 control-label">Clock No.</label>
								<div class="col-sm-8">
									<? echo $user_row['clock_no']; ?>
								</div>
							</div>

							<div class="form-group col-lg-12 d-flex">
								<label for="Email Address" class="col-sm-4 control-label">Email Address</label>
								<div class="col-sm-8">
									<? echo $user_row['email']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Department" class="col-sm-4 control-label">Department</label>
								<div class="col-sm-8">
									<? echo  Admin::getGroupById($user_row['group_id']);  ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Mobile" class="col-sm-4 control-label">Mobile</label>
								<div class="col-sm-8">
									<? echo $user_row['mobile']; ?>
								</div>
							</div>
							
							<div class="form-group col-lg-12 d-flex">
								<label for="Address 1" class="col-sm-4 control-label">Address</label>
								<div class="col-sm-8">
									<?php 
										if(isset($user_row["address_1"]) && $user_row["address_1"] !=""){
											echo $user_row["address_1"]; 
										}
										if(isset($user_row["address_2"]) && $user_row["address_2"] !=""){
											echo " ".$user_row["address_2"]; 
										}
										if(isset($user_row["address_3"]) && $user_row["address_3"] !=""){
											echo " ".$user_row["address_3"]; 
										}
										if(isset($user_row["post_code"]) && $user_row["post_code"] !=""){
											echo " ".$user_row["post_code"]; 
										}
									?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="N.I. Number" class="col-sm-4 control-label">N.I. Number</label>
								<div class="col-sm-8">
									<? echo $user_row['ni_number']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Start Date" class="col-sm-4 control-label">Start Date</label>
								<div class="col-sm-8">
									<? echo isset($user_row['start_date']) && $user_row['start_date'] != "" ? utility::getFormatedDate($user_row['start_date']) : ""; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Leave Date" class="col-sm-4 control-label">Leave Date</label>
								<div class="col-sm-8">
									<? echo isset($user_row['leave_date']) && $user_row['leave_date'] != "" ? utility::getFormatedDate($user_row['leave_date']) : ""; ?>
								</div>
							</div>
							
							<div class="form-group col-lg-12 d-flex">
								<label for="Pension" class="col-sm-4 control-label">Pension</label>
								<div class="col-sm-8">
									<? echo $gsi->getPensionTypeById($user_row['pension']); ?>
								</div>
							</div>
						  </div>
		<!-- /.box-body -->
						</form>
					  </div><!-- /.box -->
					</div>
					<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
					  <div class="scrollbar-default box box-warning card" style="height: 600px;overflow: hidden;overflow-y: scroll;">
						<form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_supp&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
						  <div class="box-body">
						  <h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Next of Kin Details 1</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
							<div class="form-group col-lg-12 d-flex">
								<label for="Name" class="col-sm-4 control-label">Name</label>
								<div class="col-sm-8">
									<? echo $user_row['kin1_name']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Address 1" class="col-sm-4 control-label">Address</label>
								<div class="col-sm-8">
									<?php 
										if(isset($user_row["kin1_address_1"]) && $user_row["kin1_address_1"] !=""){
											echo $user_row["kin1_address_1"]; 
										}
										if(isset($user_row["kin1_address_2"]) && $user_row["kin1_address_2"] !=""){
											echo " ".$user_row["kin1_address_2"]; 
										}
										if(isset($user_row["kin1_address_3"]) && $user_row["kin1_address_3"] !=""){
											echo " ".$user_row["kin1_address_3"]; 
										}
										if(isset($user_row["kin1_post_code"]) && $user_row["kin1_post_code"] !=""){
											echo " ".$user_row["kin1_post_code"]; 
										}
									?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Relationship to Yourself" class="col-sm-4 control-label">Relationship to Yourself</label>
								<div class="col-sm-8">
									<? echo $user_row['kin1_relationship']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Phone" class="col-sm-4 control-label">Phone</label>
								<div class="col-sm-8">
									<? echo $user_row['kin1_phone']; ?>
								</div>
							</div>
							<div class="form-group col-lg-12 d-flex">
								<label for="Phone Type" class="col-sm-4 control-label">Phone Type</label>
								<div class="col-sm-8">
									<? echo $gsi->getKinPhoneTypeById($user_row['kin1_phone_type']); ?>
								</div>
							</div>
						  </div>
						  <h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Next of Kin Details 2</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
								<div class="form-group col-lg-12 d-flex">
									<label for="Name" class="col-sm-4 control-label">Name</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_name']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Address 1" class="col-sm-4 control-label">Address</label>
									<div class="col-sm-8">
										<?php 
											if(isset($user_row["kin2_address_1"]) && $user_row["kin2_address_1"] !=""){
												echo $user_row["kin2_address_1"]; 
											}
											if(isset($user_row["kin2_address_2"]) && $user_row["kin2_address_2"] !=""){
												echo " ".$user_row["kin2_address_2"]; 
											}
											if(isset($user_row["kin2_address_3"]) && $user_row["kin2_address_3"] !=""){
												echo " ".$user_row["kin2_address_3"]; 
											}
											if(isset($user_row["kin2_post_code"]) && $user_row["kin2_post_code"] !=""){
												echo " ".$user_row["kin2_post_code"]; 
											}
										?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Relationship to Yourself" class="col-sm-4 control-label">Relationship to Yourself</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_relationship']; ?>
									</div>
								</div> 
								<div class="form-group col-lg-12 d-flex">
									<label for="Phone" class="col-sm-4 control-label">Phone</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_phone']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Phone Type" class="col-sm-4 control-label">Phone Type</label>
									<div class="col-sm-8">
										<? echo $gsi->getKinPhoneTypeById($user_row['kin2_phone_type']); ?>
									</div>
								</div>
							</div>
		<!-- /.box-body --></div>
						</form>
					  </div><!-- /.box -->
					</div>
					<div class="col-lg-4 col-md-4 col-sm-12" style="/* min-height:700px; */">
					  <div class="scrollbar-default box box-warning card" style="height: 600px;overflow: hidden;overflow-y: scroll;">
						<form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_supp&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
						  <div class="box-body">
							<h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Next of Kin Details 2</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
								<div class="form-group col-lg-12 d-flex">
									<label for="Name" class="col-sm-4 control-label">Name</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_name']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Address 1" class="col-sm-4 control-label">Address</label>
									<div class="col-sm-8">
										<?php 
											if(isset($user_row["kin2_address_1"]) && $user_row["kin2_address_1"] !=""){
												echo $user_row["kin2_address_1"]; 
											}
											if(isset($user_row["kin2_address_2"]) && $user_row["kin2_address_2"] !=""){
												echo " ".$user_row["kin2_address_2"]; 
											}
											if(isset($user_row["kin2_address_3"]) && $user_row["kin2_address_3"] !=""){
												echo " ".$user_row["kin2_address_3"]; 
											}
											if(isset($user_row["kin2_post_code"]) && $user_row["kin2_post_code"] !=""){
												echo " ".$user_row["kin2_post_code"]; 
											}
										?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Relationship to Yourself" class="col-sm-4 control-label">Relationship to Yourself</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_relationship']; ?>
									</div>
								</div> 
								<div class="form-group col-lg-12 d-flex">
									<label for="Phone" class="col-sm-4 control-label">Phone</label>
									<div class="col-sm-8">
										<? echo $user_row['kin2_phone']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Phone Type" class="col-sm-4 control-label">Phone Type</label>
									<div class="col-sm-8">
										<? echo $gsi->getKinPhoneTypeById($user_row['kin2_phone_type']); ?>
									</div>
								</div>
							</div>
							
							<h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Doctor Details</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
								<div class="form-group col-lg-12 d-flex">
									<label for="Name" class="col-sm-4 control-label">Name</label>
									<div class="col-sm-8">
										<? echo $user_row['doctor_name']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Phone" class="col-sm-4 control-label">Phone</label>
									<div class="col-sm-8">
										<? echo $user_row['doctor_phone']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Address 1" class="col-sm-4 control-label">Address</label>
									<div class="col-sm-8">
										<?php 
											if(isset($user_row["doctor_address_1"]) && $user_row["doctor_address_1"] !=""){
												echo $user_row["doctor_address_1"]; 
											}
											if(isset($user_row["doctor_address_2"]) && $user_row["doctor_address_2"] !=""){
												echo " ".$user_row["doctor_address_2"]; 
											}
											if(isset($user_row["doctor_address_3"]) && $user_row["doctor_address_3"] !=""){
												echo " ".$user_row["doctor_address_3"]; 
											}
											if(isset($user_row["doctor_post_code"]) && $user_row["doctor_post_code"] !=""){
												echo " ".$user_row["doctor_post_code"]; 
											}
										?>
									</div>
								</div>
							</div>	
							
							<h4 class="" style="margin-top: 0; margin-bottom: 0; margin-left: 5px; color:#9c4893;">Bank Details</h4>
							<hr style="background-color: #9c4893; height:1px; margin-top: 0; margin-bottom: 1;">
							<div class="row">
								<div class="form-group col-lg-12 d-flex">
									<label for="Bank Name" class="col-sm-4 control-label">Bank Name</label>
									<div class="col-sm-8">
										<? echo $user_row['bank_name']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Address 1" class="col-sm-4 control-label">Address</label>
									<div class="col-sm-8">
										<?php 
											if(isset($user_row["bank_address_1"]) && $user_row["bank_address_1"] !=""){
												echo $user_row["bank_address_1"]; 
											}
											if(isset($user_row["bank_address_2"]) && $user_row["bank_address_2"] !=""){
												echo " ".$user_row["bank_address_2"]; 
											}
											if(isset($user_row["bank_address_3"]) && $user_row["bank_address_3"] !=""){
												echo " ".$user_row["bank_address_3"]; 
											}
											if(isset($user_row["bank_post_code"]) && $user_row["bank_post_code"] !=""){
												echo " ".$user_row["bank_post_code"]; 
											}
										?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Account Number" class="col-sm-4 control-label">Account Number</label>
									<div class="col-sm-8">
										<? echo $user_row['account_no']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Sort Code" class="col-sm-4 control-label">Sort Code</label>
									<div class="col-sm-8">
										<? echo $user_row['short_code']; ?>
									</div>
								</div>
								<div class="form-group col-lg-12 d-flex">
									<label for="Personal Reference No." class="col-sm-4 control-label">Personal Reference No.</label>
									<div class="col-sm-8">
										<? echo $user_row['personal_ref_no']; ?>
									</div>
								</div>
							</div>
		<!-- /.box-body --></div>
						</form>
					  </div><!-- /.box -->
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<section class="content" >
	<div class="container-fluid">
		<div class="row">
			<div class="col-12"> 
				<div id="" class="card">
					<div class="card-header">
						<h3 class="card-title">Disciplinary Records</h3>
					</div>
					<?
					//$query_quotation = "SELECT * FROM admin WHERE disciplinary_record = ".$_REQUEST['id']." ORDER BY created_on DESC";
					//$sql_quotation=mysqli_query($conn,$query_quotation);
					//$result_quotation=mysqli_num_rows($sql_quotation);

					//$total_no_of_quotation = mysqli_num_rows(mysqli_query($conn,$query_quotation));
					?>
					<div class="card-body table-responsive" style="height: auto;">
						<? if($result_quotation>0){ ?>
						<div class="box box-primary" id="overflow_div">
						<!-- Start  records header -->
						<table id="example1" class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>QAF Number</th>
									<th>Customer Name</th>
									<th>Part Number</th>
									<th>Type</th>
									<th>Annual Value</th>
								</tr>
							</thead>
							<tbody>
							
							<!-- End records header -->
							
							<?
								//while($row_quotation = mysqli_fetch_array($sql_quotation)){	
							?>
							<!-- Start data -->
							<tr>
                                <td class="" ><?php echo $row_quotation['quotation_number']?></td>
									<td nowrap><?=$gsi->getCustomerById($row_quotation['customer_id']); ?></td>
									<td nowrap><?=($row_quotation['part_number']); ?></td>
									<td nowrap><?=$gsi->getYesNoById($row_quotation['type']); ?></td>
									<td nowrap><?=($row_quotation['anuual_value']); ?></td>							
								</tr>
							<!-- End data -->
							<? //}?>
							
							</tbody>
						</table>
						</div>
						<? }else{ ?>
						<div class="box box-primary p-15">No Disciplinary Records found...</div>
						<? } ?>
					</div>					
				</div>
			</div>
		</div>
	</div>
</section>
<section class="content" >
	<div class="container-fluid">
		<div class="row">
			<div class="col-12"> 
				<div id="" class="card">
					<div class="card-header">
						<h3 class="card-title">Training Records</h3>
					</div>
					<?
					//$query_quotation = "SELECT * FROM admin WHERE training_record = ".$_REQUEST['id']." ORDER BY created_on DESC";
					//$sql_quotation=mysqli_query($conn,$query_quotation);
					//$result_quotation=mysqli_num_rows($sql_quotation);

					//$total_no_of_quotation = mysqli_num_rows(mysqli_query($conn,$query_quotation));
					?>
					<div class="card-body table-responsive" style="height: auto;">
						<? if($result_quotation>0){ ?>
						<div class="box box-primary" id="overflow_div">
						<!-- Start  records header -->
						<table id="example1" class="table table-bordered table-striped">
							<thead>
								<tr>
									<th>QAF Number</th>
									<th>Customer Name</th>
									<th>Part Number</th>
									<th>Type</th>
									<th>Annual Value</th>
								</tr>
							</thead>
							<tbody>
							
							<!-- End records header -->
							
							<?
								//while($row_quotation = mysqli_fetch_array($sql_quotation)){	
							?>
							<!-- Start data -->
							<tr>
                                <td class="" ><?php echo $row_quotation['quotation_number']?></td>
									<td nowrap><?=$gsi->getCustomerById($row_quotation['customer_id']); ?></td>
									<td nowrap><?=($row_quotation['part_number']); ?></td>
									<td nowrap><?=$gsi->getYesNoById($row_quotation['type']); ?></td>
									<td nowrap><?=($row_quotation['anuual_value']); ?></td>							
								</tr>
							<!-- End data -->
							<? //}?>
							
							</tbody>
						</table>
						</div>
						<? }else{ ?>
						<div class="box box-primary p-15">No Training Records found...</div>
						<? } ?>
					</div>					
				</div>
			</div>
		</div>
	</div>
</section>
<style>
	#overflow_div::-webkit-scrollbar {
		width: 5px;
		/* for vertical scrollbars */
		height: 5px;
		/* for horizontal scrollbars */
	}

	#overflow_div::-webkit-scrollbar-track {
		background: #E7E8E9;
	}

	#overflow_div::-webkit-scrollbar-thumb {
		background: #3c8dbc;
	}

	#overflow_div {
		height: 200px;
		overflow-y: auto;
	}

	@media print {
		body {
			visibility: hidden;
		}

		#overflow_div {
			height: auto;
		}

		.printable {
			visibility: visible;
		}

		.printable {
			position: absolute;
			left: 0;
			top: 0;
		}
	}
</style>
<script type="text/javascript">
$(function () {
	$(".close_button").click(function(){
		$(".modal_iframe").attr("src","");
		location.reload();
	});
});
</script>