<!-- joining group / Entitlement detail-->
<section id="sect-joining" class="border p-3 <?php echo (!empty($default)&& $default=='open')?'':'d-none'; ?>">
	<div class="row title-row" data-toggle="collapse" href="#collapse_joining_group" role="button" aria-expanded="false">
		<div class="col-12">
			<h3 id="sect-joining-header">Employment Details</h3>
		</div>
	</div>

	<div id="collapse_joining_group">
		
		<div class="row">
			<div class="col-12 col-lg-6">
				<label><b>Reason</b></label>

				<div class="input-group">
				  <select class="form-control" name="join_group_reason_hiring" data-join="group">
					<option disabled selected>Please Select Reason</option>
					<?php foreach ($hiringReasons as $key => $reason): ?>
					<?php if (!empty($join_group->reason_id)){ ?>
						<option value="<?php echo $reason->id?>" <?php echo($join_group->reason_id == $reason->id)?'selected="selected"':''?>><?php echo $reason->type; ?></option>

					<?php 
						}else{
					?>
						<option value="<?php echo $reason->id?>"><?php echo $reason->type; ?></option>
					<?php	
						}
					?>
					<?php endforeach ?>
				</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#hiring-reason"><i class="fas fa-plus"></i></button>
				  </div>
				</div>

				
				<br>
				<input type="text" id="join-group-other-reason" class="form-control d-none" placeholder="Other reson for hiring" name="join_group_other_reason" disabled>
			</div>
			<div class="col-12 col-lg-6">
				<label><b>Contract Element</b></label>
				<div class="input-group mb-3">
				  	<select class="form-control" name="join_group_contract_element">
						<option disabled selected>Please Select Contract Element</option>
						<?php foreach ($contractTypes as $key => $contract): ?>
							<?php if (!empty($join_group->contract_element_id)): ?>
								<option value="<?php echo $contract->id; ?>" <?php echo ($join_group->contract_element_id == $contract->id)?'selected="selected"':''; ?>><?php echo $contract->type; ?></option>
							<?php else: ?>
								<option value="<?php echo $contract->id; ?>"><?php echo $contract->type; ?></option>
							<?php endif ?>
						<?php endforeach ?>
					</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#newContractElement"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-12 col-lg-6">
				<label><b>Employee Group</b></label>
				<div class="input-group mb-3">
				  	<select class="form-control" name="join_group_employee_group">
						<option disabled selected>Please Select Employee Group</option>
						<?php foreach ($employee_groups as $key => $group): ?>
							<?php if (!empty($join_group->employee_group_id)): ?>
								<option value="<?php echo $group->id; ?>" <?php echo ($join_group->employee_group_id == $group->id)?'selected="selected"':''; ?>><?php echo $group->type; ?></option>
							<?php else: ?>
								<option value="<?php echo $group->id; ?>"><?php echo $group->type; ?></option>
							<?php endif ?>
						<?php endforeach ?>
					</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#newHiringGroup"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
			<div class="col-12 col-lg-6">
				<label><b>Employee Subgroup/Level</b></label>
				<div class="input-group mb-3">
				  	<!-- <select class="form-control" name="join_group_employee_subgroup">
						<option disabled selected>Please Select Employee Subgroup</option>
						<?php //foreach ($salaryScales as $key => $scale): ?>
							<?php //if (!empty($join_group->employee_subgroup_id)): ?>
								<option value="<?php //echo $scale->id; ?>" <?php //echo ($join_group->employee_subgroup_id == $scale->id)?'selected="selected"':''; ?>><?php //echo $scale->indicator.' - '.$scale->designation; ?></option>
							<?php //else: ?>
								<option value="<?php //echo $scale->id; ?>"><?php //echo $scale->indicator.' - '.$scale->designation; ?></option>
							<?php// endif ?>
						<?php //endforeach ?>
					</select> -->
					<!-- <div class="input-group-append">
					<button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#hiring-designation"><i class="fas fa-plus"></i></button>
					</div> -->
					<select class="form-control" name="join_group_employee_subgroup" onchange="subgroupSelect(this);">
						<option disabled selected>Please Select Employee Subgroup</option>
						<?php foreach ($parentPositions as $key => $parentPositions): ?>
							<?php if (!empty($join_group->employee_subgroup_id)): ?>
								<option value="<?php echo $parentPositions->id; ?>" <?php echo ($join_group->employee_subgroup_id == $parentPositions->id)?'selected="selected"':''; ?>><?php echo $parentPositions->position; ?></option>
							<?php else: ?>
								<option value="<?php echo $parentPositions->id; ?>"><?php echo $parentPositions->position; ?></option>
							<?php endif ?>
						<?php endforeach ?>
					</select>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-12 col-lg-6">
				<label><b>Grade - Positions</b></label>

				<div class="input-group">
				  		<select class="form-control" name="join_group_position" data-join="position" id="position" onchange="positionSelect(this);">
							<option disabled selected>Please Select Positions</option>
							<?php //foreach ($jobPositions as $key => $post): ?>
								<?php //if (!empty($join_group->position_id)){ ?>
									<!-- <option value="<?php //echo $post->id; ?>" data-grade="<?php //echo $post->grade; ?>" <?php //echo ($join_group->position_id == $post->id)?'selected="selected"':''; ?>><?php //echo $post->grade; ?> - <?php //echo $post->position; ?></option> -->
								<?php //}else{ ?>
									<!-- <option value="<?php //echo $post->id; ?>" data-grade="<?php //echo $post->grade; ?>"><?php //echo $post->grade; ?> - <?php //echo $post->position; ?></option> -->
								<?php //} ?>
							<?php // endforeach ?>
						</select>
					  <!-- <div class="input-group-append">
					    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#hiring-designation"><i class="fas fa-plus"></i></button>
					  </div> -->
				</div>
				<br>
				<input type="text" id="join-group-other-position" class="form-control d-none" placeholder="Other position" name="join_group_other_position" disabled>
			</div>
			<div class="col-12 col-lg-6">
				<label><b>Designation</b></label>
				<div class="input-group mb-3">
				  <select class="form-control" name="join_group_position_information" id="designation">
				  		<option selected disabled>Please Select Designation</option>
				  		<?php //if(!empty($designations)) foreach ($designations as $key => $designation): ?>
					  		<?php //if (!empty($join_group->position_information)): ?>
					  			<!-- <option value="<?php //echo $designation->id; ?>" <?php //echo ($join_group->position_information == $designation->id)?'selected':''; ?>><?php //echo $designation->designation; ?></option> -->
					  		<?php //else: ?>
					  			<!-- <option value="<?php //echo $designation->id; ?>"><?php //echo $designation->designation; ?></option> -->
					  		<?php //endif ?>
					  	<?php //endforeach ?>
				  </select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#pos_info-designation"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
		</div>
	
		<div class="row">
			<div class="col">
				<label><b>Branch</b></label>

				<div class="input-group mb-3">
				  	<select class="form-control" name="join_group_branch">
						<option disabled selected>Please Select Branch</option>
						<?php foreach ($branches as $key => $branch): ?>
							<?php if (!empty($join_group->branch_id)){ ?>
								<option value="<?php echo $branch['id']; ?>" <?php echo ($join_group->branch_id == $branch['id'])?'selected="selected"':''; ?>><?php echo $branch['name'];?></option>
							<?php }else{ ?>
								<option value="<?php echo $branch['id']; ?>"><?php echo $branch['name'];?></option>
							<?php } ?>
						<?php endforeach ?>
					</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#newBranch"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
			<div class="col">
				<label><b>Business Entity</b></label>
				<select class="form-control" name="join_group_business_entity">
					<option selected disabled>Please Select Business Entity</option>
					<?php if(!empty($business_entities)) foreach ($business_entities as $key => $business_entity): ?>
						<?php if (!empty($join_group->business_entity_id)): ?>
							<option value="<?php echo $business_entity->id; ?>" <?php echo ($join_group->business_entity_id == $business_entity->id)?'selected':''; ?>><?php echo $business_entity->name; ?></option>
						<?php else: ?>
							<option value="<?php echo $business_entity->id; ?>"><?php echo $business_entity->name; ?></option>
						<?php endif ?>
					<?php endforeach ?>
				</select>
			</div>
		</div>

		<div class="row">
			<div class="col-12 col-lg-6">
				<label><b>Personnel Area (Department) </b></label>

				<div class="input-group mb-3">
					<select class="form-control" name="join_group_personnel_area">
						<option disabled selected>Please Select Personnel Area</option>


						<?php foreach ($departments as $key => $dept): ?>
							
							<?php if (!empty($join_group->personnel_area_id)): ?>
								<option value="<?php echo $dept['id'];?>" <?php echo ($join_group->personnel_area_id == $dept['id'])?'selected="selected"':'';?>><?php echo $dept['name'].' - '.$dept['branch_name']; ?></option>
							<?php else: ?>
								<option value="<?php echo $dept['id'];?>"><?php echo $dept['name'].' - '.$dept['branch_name']; ?></option>
							<?php endif ?>
						<?php endforeach ?>
						
					</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#newDepartment"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
			<div class="col-12 col-lg-6">
				<label><b>Personal subarea (Division) </b></label>
				<div class="input-group mb-3">
				  	<select class="form-control" name="join_group_personal_subarea">
						<option disabled selected>Please Select Subarea</option>
						<?php foreach ($divisions as $key => $division): ?>
							<?php if (!empty($join_group->personal_subarea_id)){ ?>
								<option value="<?php echo $division->id; ?>" <?php echo ($join_group->personal_subarea_id == $division->id)?'selected="selected"':'';?>><?php echo $division->name; ?></option>
							<?php }else{ ?>
								<option value="<?php echo $division->id; ?>"><?php echo $division->name; ?></option>
							<?php } ?>
						<?php endforeach ?>
					</select>
				  <div class="input-group-append">
				    <button class="btn btn-warning btn-sm" type="button" data-toggle="modal" data-target="#newDivision"><i class="fas fa-plus"></i></button>
				  </div>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-12 col-lg-6">
				<label><b>Reporting to</b></label>
				<select class="select form-control" name="join_group_reporting_to">
					<option disabled selected>Please Select Reporting To</option>
					<?php foreach ($allStaff as $key => $row){ 
						if(!empty($join_group->user_reporting_id)){
						?>
							<option value="<?php echo $row['id']; ?>" <?php echo($join_group->user_reporting_id == $row['id'])?'selected="selected"':''; ?>><?php echo $row['name']; ?></option>
						<?php
						}else{
						?>
							<option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option>
						<?php
						}
						?>
					<?php } ?>
				</select>
			</div>
			
			<div class="col-12 col-lg-6">
				<label><b>Employment Status</b></label>
				<select class="form-control" name="join_group_employment_status">
					<option disabled selected>Please Select Status</option>

					<?php if (!empty($join_group->is_active)): ?>
						<option <?php echo ($join_group->is_active == 1)?'selected':''; ?> value="1">Active</option>
						<option <?php echo ($join_group->is_active == 0)?'selected':'' ?> value="0">Inactive</option>
						<?php else: ?>
						<option value="1">Active</option>
						<option value="0">Inactive</option>
					<?php endif ?>
					
				</select>
			</div>
			
		</div>

	</div>
</section>
<!-- joining group --> 

