/home/mip/public_html_/old_mip/apply_online_employment.php
<?php
require_once( "func-all.php"); 
do_header(); 
$works = getdata("select * from web_employment where applicant_id='$applicant_id'");
?>

<div class="inner-header">
    
<img src="images/img-inner-header-apply.jpg" class="img-responsive"/>

</div>
<div class="container">
<div class="row">

<div class="col-sm-12">
<h3>Apply Online Work Experience</h3>
<div class="pull-right"><a href="javascript:void(0)" id="addexperience" class="btn btn-warning btn-sm">Add Experience</a></div>
<table class="table table-striped">
	<tbody>
		<?php if(count($works)){ ?>
		<?php foreach ($works as $key => $work) { ?>
		<tr>
			<td>Company Name</td>
			<td>
				<?php echo $work['company']; ?> 
				<div class="pull-right">
					<a href="javascript:void(0)" onclick="editemployment(<?php echo $work['id']; ?>)" class="btn btn-success btn-xs">Edit</a>
					<a href="sqldelete.php?what=web_employment&id=<?php echo $work['id']; ?>&applicant_id=<?php echo $applicant_id; ?>" onclick="confirm('Are you sure you want to delete this?');" class="btn btn-danger btn-xs">Remove</a>
				</div>
			</td>
		</tr>
		<tr>
			<td>Address</td>
			<td><?php echo $work['address']; ?></td>
		</tr>
		<tr>
			<td>Position</td>
			<td><?php echo $work['position']; ?></td>
		</tr>
		<tr>
			<td>Duration</td>
			<td><?php echo ($work['from_date']!='0000-00-00') ? date('M Y', strtotime($work['from_date'])) : ''; ?><?php if($work['to_date']!='0000-00-00'){ echo' - '.date('M Y', strtotime($work['to_date'])); } else if($work['from_date']!='0000-00-00' && $work['to_date']=='0000-00-00'){ echo 'Present'; } else { echo ''; } ?></td>
		</tr>
		<tr>
			<td>Job Details</td>
			<td><?php echo $work['job_desc']; ?></td>
		</tr>
		<tr>
			<td>Reason for Leaving</td>
			<td><?php echo $work['reason_for_leaving']; ?></td>
		</tr>
		<tr>
			<td style="height:18px !important" colspan="2"></td>
		</tr>
		<?php } ?>
		<?php } else { ?>
		<tr>
			<td style="font-size:16px"><h3>No record found</h3></td>
		</tr>
		<?php } ?>
	</tbody>
</table>
<div class="pull-right"><a href="<?php if(count($works)<>0){ ?>apply_online_training.php?applicant_id=<?php echo $applicant_id; } else { echo '#'; } ?>" id="thirdnext" <?php echo (count($works)<>0) ? '' : 'disabled=disabled' ?> class="btn btn-warning btn-sm">Move to the Next Stage</a></div>
</div>
</div>
</div>
<div class="modal fade bs-example-modal-md" id="workModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
	<div class="modal-dialog modal-md modal-z-index">
		<div class="modal-content">
			<form action="sqladd.php?what=web_employment" method="post" id="myForm">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">Add Work Experience</h4>
			</div>
			<div class="modal-body">
				<div class="form-group" id="companyField">
				    <label class="formlabel">Company <span style="color:#d9534f; font-size:16px !important">*</span></label>
				    <input type="text" name="company" class="form-control" id="company" />
				    <small id="companyInput"></small>
				</div>
				<div class="form-group">
					<label class="formlabel">Address</label>
					<input type="text" name="address" id="address" class="form-control" />
				</div>
				<div class="form-group" id="positionField">
					<label class="formlabel">Position <span style="color:#d9534f; font-size:16px !important">*</span></label>
					<input type="text" name="position" class="form-control" id="position" />
					<small id="positionInput"></small>
				</div>
				<div class="form-group">
					<label class="formlabel">Duration</label>
					<div class="form-inline">
						From <input type="text" name="from_date" class="form-control datemask" id="from_date" />
						To <input type="text" name="to_date" class="form-control datemask" id="to_date" />
					</div>
				</div>
				<div class="form-group">
					<label class="formlabel">Job Description</label>
					<textarea name="job_desc" class="form-control" id="job_desc" style="height:100px; resize:none"></textarea>
				</div>
				<div class="form-group">
					<label class="formlabel">Reason for Leaving</label>
					<textarea name="reason_for_leaving" class="form-control" id="reason_for_leaving" style="height:100px; resize:none"></textarea>
				</div>
			</div>
			<div class="modal-footer">
				<input type="hidden" name="applicant_id" id="applicant_id" value="<?php echo $applicant_id; ?>" />
				<button type="submit" class="btn btn-warning btn-sm" id="addexperiencebtn">Save</button>
			</div>
			</form>
		</div>
	</div>
</div>

<script src="plugins/input-mask/jquery.inputmask.js"></script>
<script src="plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$(".datemask").inputmask("mm/yyyy", {"placeholder": "mm/yyyy"});

	$('#addexperience').click(function() {
		$('#workModal').modal();
	});
	$('#addexperiencebtn').click(function() {
		if($('#company').val()==''){
			$('#companyField').addClass('has-error');
			$('#companyField').css('color', '#d9534f');
			$('#companyInput').html('Company field is required');
			$('#company').focus();
			return false;
		} else if($('#position').val()==''){
			$('#positionField').addClass('has-error');
			$('#positionField').css('color', '#d9534f');
			$('#positionInput').html('Position field is required');
			$('#position').focus();
			return false;
		} else {
			$('#addexperiencebtn').html('Processing..');
			$('#addexperiencebtn').attr('disabled', true);
			$('#myForm').submit();
		}
	});
});
function editemployment(id){
	$('#workModal').modal();
	$.ajax({
		url: 'sqloption.php?what=employment',
		type: 'POST',
		data: {
			id: id
		},
		dataType: "json",
		success: function(result){
			$('#company').val(result.company);
			$('#address').val(result.address);
			$('#position').val(result.position);
			$('#from_date').val(result.from_date);
			$('#to_date').val(result.to_date);
			$('#job_desc').val(result.job_desc);
			$('#reason_for_leaving').val(result.reason_for_leaving);
			$('#myForm').attr('action', 'sqlupdate.php?what=web_employment&id='+result.id);
		}
	});
	
}
</script>
<?php
do_employerlogin();
do_footer(); 
?>