<?php
	
	if(!function_exists('random_no')){
		function random_no()
		{
			return rand(10,100);
		}
	}


function hrm_attendance_list_updated($name){
    return true;
    return isset($_POST['_'.$name.'_update']) || isset($_POST['_'.$name.'_button']);
}

function pf_employer_calculation($allowance_id, $post, $Allowances, $empl_id=''){

		//return 0 ;
		$KVAllowance = kv_get_allowances(null, 0, $post['grade_id']);
		$allowance_var_ar = array();
		foreach($KVAllowance as $single) {
			$allowance_var_ar[$single['id']] = '{$'.$single['unique_name'].'}';			
			$_POST[$single['id']] = 0;
		}

		foreach($Allowances as $single) {	
			if($single['basic'] == 1) {
				$basic_id = $single['id'];
				$basic_name = $single['unique_name'];
			}	

			if($single['formula'] == '' && $single['value'] == 'Percentage' && $single['percentage']>0){			
				$_POST[$single['id']] = input_num($basic_id)*($single['percentage']/100);
			}elseif($single['value'] == 'Gross Percentage' && $single['percentage']>0){			
				$_POST[$single['id']] = input_num('gross')*($single['percentage']/100);
			}elseif($single['formula'] != '' && is_numeric($single['formula'])) {
				$_POST[$single['id']] = $single['formula'];					
			} elseif($single['formula'] != '' && !is_numeric($single['formula']) && (strpos($single['formula'], '{$ctc}') === false)){
				foreach($allowance_var_ar as $key => $allown){
					$single['formula'] = str_replace($allown, (isset($_POST['E_'.$key]) ? input_num('E_'.$key) : '0'),strtolower($single['formula']));
				}
				if(strpos($single['formula'], '{$gros}'))
					$single['formula'] = str_replace('{$gros}', (isset($_POST['gross']) ? input_num('gross') : 0 ), strtolower($single['formula']));

				if(strpos($single['formula'], '{$'.$basic_name.'}')){
					$single['formula'] = str_replace('{'.$basic_name.'}', (isset($_POST[$basic_id]) ? input_num('E_'.$basic_id) : 0 ), strtolower($single['formula']));
				}
				$_POST[$single['id']] = round(calculate_string($single['formula']),2);
			}
		}

		return rand(10,100);
	}

	function pf_employee_calculation($allowance_id, $post, $Allowances, $empl_id){
		return rand(10,100);
	}

?>
