<script type="text/javascript">
	$(document).ready(function(){
		console.log('tab academic qualification loaded..');
	});

	function editAcademicQualification(elem) {
		var b64 = $(elem).data('content');
		var json= JSON.parse(atob(b64));

		console.log(json);

		$('#mdl-qualification-id').val(json.id);
		$('#mdl-qualification-level-id').val(json.level_id);
		$('#mdl-qualification-program').val(json.program);
		$('#mdl-qualification-institution').val(json.institution);
		$('#mdl-qualification-year').val(json.year);
		$('#mdl-qualification-cgpa').val(json.cgpa);
		$('#mdl-qualification-attachment-id').val(json.attachment_id);
	}

	function removeAcademicQualification(id){
	    iziToast.question({
	        title: '',
	        timeout:20000,
	        close: false,
	        toastOnce: true,
	        message: 'Are you sure you want to remove this record? ',
	        position:"center",
	        buttons: [
	                    ['<button><b>YES</b></button>', function (instance, toast) {
	                        _removeAcademic(id);
	                        instance.hide(toast, {
	                            transitionOut: 'fadeOutUp'
	                        });
	                    }],
	                    ["<button>No</button>", function (instance, toast) {
	                        instance.hide(toast, {
	                            transitionOut: 'fadeOutUp'
	                        });

	                        iziToast.warning({
	                            position: 'bottomRight',
	                            message: 'Operation cancelled.'
	                        });

	                    },true]
	                ]
	        });
	}

	function _removeAcademic(id) {
		var frmData = new FormData();
		frmData.append('id',id);

		$.ajax({
            url:"<?php echo base_url('hr/StaffProfile/removeAcademicQualification/'); ?>",
            type:'post',
            dataType:'json', //return type value
            data:frmData,
            processData: false,
            contentType: false,
            success:function(data){
                iziToast.success({
                    title: '',
                    message:'success'
                });
                window.location.replace("<?php echo base_url('hr/StaffProfile/staffDetail/'.$this->uri->segment(4)); ?>");            
            },error:function(){
                iziToast.error({
                    title: '',
                    message: '500 internal server error'
                });
            }
        });
	}

	
</script>