<script type="text/javascript">
	function btnEditContractElement(elem) {
		var b64 = $(elem).data('content');
		var json = JSON.parse(atob(b64));

		$('#modal-contract-id').val(json.id);
		$('#modal-contract-type').val(json.contract_hiring_type_id);
		$('#modal-contract-confirmation').val(json.confirmation);
		$('#modal-contract-duration-period').val(json.duration);
		$('#modal-contract-confirmation-date').val(moment(json.confirmation_date,'YYYY-MM-DD').format('DD-MM-YYYY'));
		$('#modal-contract-probationary-period').val(json.probation);
		$('#modal-contract-probationary-duration').val(json.probation_duration);
		$('#modal-contract-er-period').val(json.er_notice);
		$('#modal-contract-er-duration').val(json.er_notice_duration);
		$('#modal-contract-ee-period').val(json.ee_notice);
		$('#modal-contract-ee-duration').val(json.ee_notice_duration);
	}

	function btnRemoveContractElement(elem) {
		toastConfirm('Are you sure you want remove this contract element?',function(){
			var b64 = $(elem).data('content');
			var json = JSON.parse(atob(b64));
			var data = {
				id:json.id,
			}
			
			ajxRequest('<?php echo base_url('hr/StaffProfile/removeContractElement/');?>','POST',data,'<?php echo current_url(); ?>');

		});
	}

	function EditContractElem() {
		var data = {
			id:$('#modal-contract-id').val(),
			type_id:$('#modal-contract-type').val(),
			confirmation:$('#modal-contract-confirmation').val(),
			duration:$('#modal-contract-duration-period').val(),
			confirmation_date:$('#modal-contract-confirmation-date').val(),
			probationary_period:$('#modal-contract-probationary-period').val(),
			probationary_duration:$('#modal-contract-probationary-duration').val(),
			er_notice:$('#modal-contract-er-period').val(),
			er_notice_duration:$('#modal-contract-er-duration').val(),
			ee_notice:$('#modal-contract-ee-period').val(),
			ee_notice_duration:$('#modal-contract-ee-duration').val(),
			confirmation_reminder:$('#modal-contract-confirmation_reminder').val()

		}

		ajxRequest('<?php echo base_url('hr/StaffProfile/updateContractElement/'); ?>','POST', data, '<?php echo current_url(); ?>');

		console.log('save contract');
		console.log(data);
	}
</script>