<div class="collapse" id="collapseAddress">
	<div class="card card-body">
		<h4 class="card-title">Addresses</h4>
		<hr>
		<div class="container">
			<?php if ($role == 'admin'): ?>
				<div class="row">
					<div class="btn-group ml-auto">
						<a class="btn btn-info btn-sm text-white" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('/hr/StaffProfile/actionReport/'.$staff_id.'/1'); ?>" target="_blank">
							<i class="fa fa-print"></i> Print 
						</a>
					</div>
				</div>
			<?php endif ?>
		</div>
		<div class="table-responsive">
			<table id="table_address" class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>Action Type (Effective date)</th>
						<th>Type</th>
						<th>Address</th>
						<th>Contact No.</th>
						<th>Created At</th>
						<!-- <?php if($role == 'admin'): ?>
						<th>Action</th>
						<?php endif ?> -->
					</tr>
				</thead>
				<tbody>
					<?php if(!empty($addresses)) foreach ($addresses as $key => $addr): ?>
						<tr class="link-row">
							<td>
								<?php echo $addr->action_type.'<br/><b>( '.date('d-F-Y',strtotime($addr->action_efective_date)).' )</b>'; ?>
							</td>
							<td>
								<?php
									if ($addr->type == 1) {
										echo 'Permanent Residence';
									}elseif ($addr->type == 2) {
										echo 'Temporary Residence';
									}else{
										echo 'Correspondence Residence';
									}
								?>
							</td>
							<td>
								<?php 
								echo $addr->address.'<br/>'
									.$addr->postcode.'<br/>'
									.$addr->city.'<br/>'
									.$addr->state_name.'<br/>'
									.$addr->country_name; 
								?>
							</td>
							
							<td><?php echo $addr->contact_no; ?></td>
							<td><?php echo $addr->created_at;  ?></td>
							<?php if($role == 'admin'): ?>						
							<!-- <td class="text-center">
								<div class="btn-group" role="group">
								 	<button class="btn btn-success btn-sm" data-content="<?php //echo base64_encode(json_encode($addr));?>" onclick="btnEditAddress(this)" data-toggle="modal" data-target="#addressModal"><i class="fas fa-edit" ></i></button>
								 	<button class="btn btn-danger btn-sm" onclick="deleteAddress(<?php //echo $addr->id; ?>)"><i class="fas fa-trash-alt"></i></button>
								</div>
							</td>  -->
						<?php endif ?>
						</tr>				
					<?php endforeach ?>
				</tbody>
			</table>
		</div>
	</div><br>
</div>


<div class="modal fade" id="addressModal">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title">Add Address</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<form action="<?php echo base_url('/hr/StaffProfile/createAddress/'.$staff_id); ?>" method="POST" class="form-horizontal" id="mdl-address-form">
				<input type="hidden" class="form-control" id="mdl-address-id" name="id">
				<div class="modal-body">
					<div class="form-group">
						<label for="address_type">Type</label>
						<select id="mdl-address-type" type="text" class="form-control" name="type">
							<?php foreach ($residenceType as $key => $type): ?>
								<option value="<?php echo $type->id; ?>"><?php echo $type->type; ?></option>
							<?php endforeach ?>
						</select>
					</div>
					<div class="form-group">
						<label for="address">Address</label>
						<input type="text" class="form-control" aria-describedby="enter email" placeholder="Enter Address" name="address" id="mdl-address">
					</div>	
					<div class="row form-group">
						<div class="col">
							<label for="postcode">Postcode</label>
							<input type="text" class="form-control" aria-describedby="enter postcode" placeholder="Enter Postcode" name="postcode" id="mdl-address-postcode">
						</div>
						<div class="col">
							<label for="city">City</label>
							<input type="text" class="form-control" aria-describedby="enter city" placeholder="Enter City" name="city" id="mdl-address-city">
						</div>
					</div>	
					<div class="row form-group">
						<div class="col">
							<label for="state">State</label>
							<select type="text" class="form-control form-control-sm select" name="state" id="mdl-address-state-id">
								<option value="-1" selected="selected">Select State</option>
                                <?php if($states) foreach ($states as $key => $state): ?>
                                	<option value="<?php echo $state->id; ?>"><?php echo $state->state; ?></option>
                                <?php endforeach ?>
							</select>
						</div>
						<div class="col">
							<label for="country">Country</label>
							<select type="text" class="form-control form-control-sm select" name="country" id="mdl-address-country-id">
								<option value="-1" selected="selected"> Select Country</option>
                               <?php if($countries) foreach ($countries as $key => $country): ?>
                               	<option value="<?php echo $country->id; ?>"><?php echo $country->country; ?></option>
                               <?php endforeach ?>
							</select>
						</div>
					</div>	
					<div class="form-group">
						<label for="address">Contact No.</label>
						<input type="text" class="form-control" aria-describedby="contact no" placeholder="Enter Contact No." name="contact" id="mdl-address-contact-no">
					</div>					
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger btn-sm" style="margin-bottom:15px; width: 200px;" data-dismiss="modal"><i class="fa fa-ban"></i> Cancel</button>
					<button type="submit" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> save</button>
				</div>
			</form>
		</div>
	</div>
</div>