<!-- \hr\views\staff-profiling\page\list\components\content\tab-segment-professional-license.php -->
<div class="collapse" id="collapseLicense">
	<div class="card card-body">
		<h4 class="card-title">Professional License</h4>
		<hr>		
		<div class="container">
			<div class="row ">
				<?php if ($role == 'admin'): ?>
					<div class="btn-group ml-auto">
						<a class="btn btn-info btn-sm" style="margin-bottom:15px; width: 200px;" href="<?php echo base_url('hr/StaffProfile/actionReport/'.$staff_id.'/7'); ?>" target="_blank">
							<i class="fa fa-print"></i>Print
						</a>
					</div>
				<?php endif ?>
			</div>
		</div>
		<div class="table-responsive">
			<table id="table_license" class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>Action type (effective date)</th>
						<th>Details</th>
						<th>Attachment</th>
						<th>Created At</th>
						<!-- <?php if($role == 'admin'): ?>
						<th>Action</th>
						<?php endif ?> -->
					</tr>
				</thead>
				<tbody>
					<?php if(!empty($professionalLicense)) foreach ($professionalLicense as $key => $license): ?>	
						<tr class="link-row">
							<td scope="row">
								<?php
									echo $license->action_type.'<br/><b>( '.date('d-F-Y',strtotime($license->action_efective_date)).' )</b>';
								?>
							</td>
							<td>
								<?php 
									echo '<b>Name of License : </b>'.$license->profession
									.'<br/><b>License Number : </b>'.$license->license_no
									.'<br/><b>License Body/Authority : </b>'.$license->license_body_authority
									// .'<br/><b>Register Date : </b>'.date('d-F-Y',strtotime($license->register_date))
									.'<br/><b>Register Date : </b>'.mysql_to_date_format((!empty($license->register_date))?$license->register_date:null)
									.'<br/><b>Latest Renewed Date : </b>'.mysql_to_date_format((!empty($license->renewal_date))?$license->renewal_date:null)
									.'<br/><b>Next Renewal Date : </b>'.mysql_to_date_format((!empty($license->next_renewal_date))?$license->next_renewal_date:null); 
									// .'<br/><b>Renewal Date : </b>'.date('d-F-Y',strtotime($license->renewal_date)); 
								?>
							</td>
							<td><a href="<?php echo base_url('hr/staffProfile/openAttachment/'.$license->mask_id.'/3'); ?>" target="_blank"><?php echo $license->attachment_name; ?></a>
              <?php if($role == 'admin') { ?><button title="Delete Attachment" onclick="btnRemoveAttachment(<?php echo $license->attachment_id; ?>)" class="btn btn-danger btn-sm"><i class="fas fa-cut"></i></button><?php } ?>
              </td>
							<td><?php echo $license->created_at; ?></td>
							<?php if($role == 'admin'): ?>
							<td class="text-center">
								<div class="btn-group">
									<button title="Edit Professional License" onclick="btnEditLicense(this)" data-content="<?php echo base64_encode(json_encode($license)); ?>" class="btn btn-success btn-sm" data-toggle="modal" data-target="#licenseModal"><i class="fas fa-edit"></i></button>
									<button title="Delete Professional License" onclick="btnRemoveLicense(<?php echo $license->id; ?>)" class="btn btn-danger btn-sm"><i class="fas fa-trash"></i></button>
								</div>
							</td> 
							<?php endif ?>
						
						</tr>
					<?php endforeach ?>


				</tbody>
			</table>
		</div>
	</div><br>	 
</div>

<div class="modal fade" id="licenseModal">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="racks-modal-title">Edit Professional License</h5>
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
			</div>
			<form id="mdl-license-form" action="<?php echo base_url('/hr/StaffProfile/createProfessionalLicense/'.$staff_id); ?>" method="POST" enctype="multipart/form-data" class="form-horizontal" >
				<div class="modal-body">
					<input type="hidden" name="attachmentID" id="mdl-license-attachment-id">
					<input type="hidden" name="id" class="form-control" id="mdl-license-id">
					<div class="form-group">
						<label>Name of License</label>
						<input type="text" class=" form-control" id="mdl-license-profession" aria-describedby="emailHelp" placeholder="Enter Profession" name="profession">
					</div>	
					<div class="form-group">
						<label>License No</label>
						<input type="text" class=" form-control" id="mdl-license-no" aria-describedby="emailHelp" placeholder="Enter License No" name="licenseNo">
					</div>
					<div class="form-group">
						<label>License Body/Authority</label>
						<input type="text" class=" form-control" id="mdl-license-body-authority" aria-describedby="emailHelp" placeholder="Enter License Body/Authority" name="licenseBodyAuthority">
					</div>
					<div class="form-group">
						<label>Initial Registration Date</label>
						<input type="text" class="datepicker form-control" id="mdl-license-reg-date" aria-describedby="emailHelp" placeholder="Enter Initial Registration Date" name="initDate" autocomplete="off">
					</div>
					<div class="form-group">
						<label>Latest Renewal Valid</label>
						<input type="text" class="datepicker form-control" id="mdl-license-renew-date" aria-describedby="emailHelp" placeholder="Enter Latest Renewal Valid" name="renewDate" autocomplete="off">
					</div>
					<div class="form-group">
						<label>Next Renewal Valid</label>
						<input type="text" class="datepicker form-control" id="mdl-license-next-renew-date" aria-describedby="emailHelp" placeholder="Enter Next Renewal Valid" name="nextRenewDate" autocomplete="off">
					</div>
					<div class="form-group">
						<label>Attachment</label>
						<input type="file" class="form-control" name="attachment">
					</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" id="saveProfessionalLicense" class="btn btn-success btn-sm" style="margin-bottom:15px; width: 200px;"><i class="fa fa-save"></i> Submit</button>
				</div>
			</form>
		</div>
	</div>
</div>