<?php
$edit_id = $link->hrefquery();
$get_loan = $db->get_row('loan_module',array('id'=>$edit_id['1']));
if (isset ( $_POST ['loan_submit'] ) && $_POST ['check'] == 'loanmodule') {
	$emp_id_name = $_POST['emp_name'];
	$emp_id_name = explode('___',$emp_id_name);
	$date = time();
	$day = date('d',$date);
	$month=date('m',$date);
	$year = date('Y',$date);
	
	$loan_amount = $_POST['loan_amount'];
	
	if($emp_id_name=='0'){
		$display_loan = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">
		<i class="icon-remove"></i></button><strong><i class="icon-remove"></i>Oh snap!</strong>
		You Left Employee Name Empty.<br></div>';
	}
	elseif(empty($loan_amount) && $loan_amount==""){
		$display_loan = '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">
		<i class="icon-remove"></i></button><strong><i class="icon-remove"></i>Oh snap!</strong>
		You Left Advance Amount Empty.<br></div>';
	}
	else{
		$loan_array = array(
				'e_id'=>$emp_id_name['0'],
				'e_name'=>$emp_id_name['1'],
				'advance_amount'=>$loan_amount,
				'day'=>$day,
				'month'=>$month,
				'year'=>$year
				);
		if($edit_id['0']=='edit_id'){
			$update_loan = $db->update('loan_module',$loan_array,array('id'=>$edit_id['1']));
			if($update_loan){
				$session->redirect('view_loan',Admin);
			}
		}else{
		$insert_loan = $db->insert('loan_module',$loan_array);
		if($insert_loan){
			$display_loan = '<div class="alert alert-block alert-success"><button type="button" class="close" data-dismiss="alert">
			<i class="icon-remove"></i></button><p><strong><i class="icon-ok"></i>Well done!</strong>
			You Have Been Saved Advanced Amount Successfully.</p></div>';
		}
		}
	}
}


?>