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

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

	console.log(json);
	$('#mdl-recurring-payment-id').val(json.id);
	$('#mdl-recurring-payment-date_start').val(json.date_start);
	$('#mdl-recurring-payment-date_end').val(json.date_end);
	$('#mdl-recurpay-type').val(json.type);
	$('#mdl-recurpay-amount').val(json.amount);
	$('#mdl-recurpay-status').val(json.status);
}

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

	console.log(json);
	$('#mdl-recurring-deduct-id').val(json.id);
	$('#mdl-recurring-deduct-date_start').val(json.date_start);
	$('#mdl-recurring-deduct-date_end').val(json.date_end);
	$('#mdl-recurring-deduct-type').val(json.type);
	$('#mdl-recurring-deduct-amount').val(json.amount);
	$('#mdl-recurring-deduct-status').val(json.status);
}

function btnRemovePayment(id) {
	toastConfirm('Are you sure you want to remove this record ? ',function(){
		_removePayment(id);
	});
}

function btnRemoveDeduction(id) {
	toastConfirm('Are you sure you want to remove record ? ',function(){
		_removededuct(id);
	});
}

function _removePayment(id) {
	ajxRequest('<?php echo base_url('/hr/StaffProfile/removeRecurringPay/'); ?>','POST',{id:id},'<?php echo base_url('/hr/StaffProfile/staffDetail/'.$staff_id); ?>');
}

function _removededuct(id) {
	ajxRequest('<?php echo base_url('/hr/StaffProfile/removeRecurringDeduct/'); ?>','POST',{id:id},'<?php echo base_url('/hr/StaffProfile/staffDetail/'.$staff_id); ?>');
}
</script>