Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.117.101.250
<?php
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-7);
require_once($main_src."/custom_src/salcompclass.php");
function getFormulaNames($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$get_values="select internal_code,formula_name as type from formula_header order by 2";
$lobj_get_all_values = $aobj_context->mobj_db->GetAll($get_values);
// for main source
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name='name'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get__source_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name]";
$lobj_get__source_values = $aobj_context->mobj_db->GetAll($get__source_values);
// for main reference data
$arr[0]=$lobj_get_all_values;
$arr[1]=$lobj_get__source_values;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
function getEmpColumnName($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$get_values="select table_name,field_name1,field_id1,field_name2,field_id2 from module_meta_columns
where module_name='Employee'";
$lobj_get_all_values = $aobj_context->mobj_db->GetRow($get_values);
// for main source
echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_all_values,0,"success");
}
function getFormulaComponents($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name='name'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name]";
$lobj_get_all_values = $aobj_context->mobj_db->GetAll($get_values);
// for main reference data
$arr[0]=$lobj_get_all_values;
// to get Earning Data
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Component Type'
and name='Component type'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name] where $lobj_rs[field_name]='EARNINGS'";
$lobj_get_values = $aobj_context->mobj_db->GetRow($get_values);
$lstr_earning_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name in('name','Type')";
$lobj_lstr_earning_qry = $aobj_context->mobj_db->GetAll($lstr_earning_qry);
$field_name=$lobj_lstr_earning_qry[0]['field_name'];
$table_name=$lobj_lstr_earning_qry[0]['table_name'];
$where_field_name=$lobj_lstr_earning_qry[1]['field_name'];
$get_lstr_earning_qry="select internal_code,$field_name as type from $table_name where $where_field_name=$lobj_get_values[internal_code] ";
$lobj_get_lstr_earning_qry = $aobj_context->mobj_db->GetAll($get_lstr_earning_qry);
$arr[1]=$lobj_get_lstr_earning_qry;
// to get deduction Data
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Component Type'
and name='Component type'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get_ded_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name] where $lobj_rs[field_name]='DEDUCTIONS'";
$lobj_ded_get_values = $aobj_context->mobj_db->GetRow($get_ded_values);
$lstr_ded_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name in('name','Type')";
$lobj_lstr_ded_qry = $aobj_context->mobj_db->GetAll($lstr_ded_qry);
$field_name=$lobj_lstr_ded_qry[0]['field_name'];
$table_name=$lobj_lstr_ded_qry[0]['table_name'];
$where_field_name=$lobj_lstr_ded_qry[1]['field_name'];
$get_lstr_ded_qry="select internal_code,$field_name as type from $table_name where $where_field_name=$lobj_ded_get_values[internal_code] ";
$lobj_get_lstr_ded_qry = $aobj_context->mobj_db->GetAll($get_lstr_ded_qry);
$arr[2]=$lobj_get_lstr_ded_qry;
//to get Special Fields Data
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Component Type'
and name='Component type'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get_spe_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name] where $lobj_rs[field_name]='SPECIAL FIELDS'";
$lobj_spe_values = $aobj_context->mobj_db->GetRow($get_spe_values);
$lstr_spe_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name in('name','Type')";
$lobj_lstr_spe_qry = $aobj_context->mobj_db->GetAll($lstr_spe_qry);
$field_name=$lobj_lstr_spe_qry[0]['field_name'];
$table_name=$lobj_lstr_spe_qry[0]['table_name'];
$where_field_name=$lobj_lstr_spe_qry[1]['field_name'];
$get_lstr_spe_qry="select internal_code,$field_name as type from $table_name
where $where_field_name=$lobj_spe_values[internal_code] ";
$lobj_get_lstr_spe_qry = $aobj_context->mobj_db->GetAll($get_lstr_spe_qry);
$arr[3]=$lobj_get_lstr_spe_qry;
//rounded off
$lstr_qry = "select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Rounded Off'
and name='name'";
$lobj_rs = $aobj_context->mobj_db->GetRow($lstr_qry);
$get_values="select internal_code,$lobj_rs[field_name] as type from $lobj_rs[table_name]";
$lobj_get_all_values = $aobj_context->mobj_db->GetAll($get_values);
// for main reference data
$arr[4]=$lobj_get_all_values;
$get_employee_fields="select suse.internal_code,
concat('EMP_',REPLACE(name,' ','_')) as type
from s_user_schema_elements suse
inner join s_user_schema s on s.internal_code=suse.ref_s_user_schema_code
where s.module_name='Employee'
";
$lobj_get_employee_fields = $aobj_context->mobj_db->GetAll($get_employee_fields);
$arr[5]=$lobj_get_employee_fields;
if(count($lobj_get_all_values) != 0)
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
else
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");
return;
}
function insertFormulaHeader($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$formula_name=addslashes(trim($aobj_context->mobj_data["formula_name"]));
$formula_valid_from=addslashes(trim($aobj_context->mobj_data["formula_valid_from"]));
$formula_valid_to=addslashes(trim($aobj_context->mobj_data["formula_valid_to"]));
$starting_element=addslashes(trim($aobj_context->mobj_data["starting_element"]));
if($internal_code==0)
{
$dup_formula_name="select internal_code from formula_header where formula_name='{$formula_name}'";
$lobj_dup_formula_name = $aobj_context->mobj_db->GetRow($dup_formula_name);
if(!empty($lobj_dup_formula_name))
{
$update_qry="update formula_header
set formula_name='{$formula_name}',
starting_element={$starting_element} where internal_code={$lobj_dup_formula_name[internal_code]}";
$lobj_rs = $aobj_context->mobj_db->Execute($update_qry);
$rdata['msg']="Formula Header Inserted Successfully";
$rdata['last_inserted_id']=$lobj_dup_formula_name[internal_code];
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{
$insert_qry="insert into formula_header
(formula_name,
starting_element
) values
('{$formula_name}','{$starting_element}')";
$lobj_rs = $aobj_context->mobj_db->Execute($insert_qry);
if($aobj_context->mobj_db->Insert_ID()!= 0)
{
$rdata['msg']="Formula Header Inserted Successfully";
$rdata['last_inserted_id']=$aobj_context->mobj_db->Insert_ID();
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{
$rdata['msg']="Insertion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
}
}
else
{
$get_header_id="select ref_formula_header_code from formula_details where internal_code={$internal_code}";
$lobj_get_header_id = $aobj_context->mobj_db->getRow($get_header_id);
$update_qry="update formula_header
set formula_name='{$formula_name}',
starting_element={$starting_element} where internal_code={$lobj_get_header_id[ref_formula_header_code]}";
$lobj_rs = $aobj_context->mobj_db->Execute($update_qry);
if($lobj_rs)
{
$rdata['msg']="Formula Header updated Successfully";
$rdata['last_inserted_id']=$lobj_get_header_id[ref_formula_header_code];
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{
$rdata['msg']="Updataion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
}
}
function insertFormulaHeaderDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$ref_formula_header_code=$aobj_context->mobj_data["ref_formula_header_code"];
$formula_main_component=addslashes(trim($aobj_context->mobj_data["formula_main_component"]));
//$formula_sequecne=addslashes(trim($aobj_context->mobj_data["formula_sequecne"]));
$formula=stripslashes(trim($aobj_context->mobj_data["formula_text_area"]));
$formula_for_ui=stripslashes(trim($aobj_context->mobj_data["formula_for_ui"]));
$ref_round_off_code=0;
$delete_qry="delete from formula_details where internal_code={$internal_code}";
$lobj_rs = $aobj_context->mobj_db->Execute($delete_qry);
$insert_qry="insert into formula_details(
ref_formula_header_code,
ref_component_code,
ref_round_off_code,
formula,formula_for_ui) values ('{$ref_formula_header_code}','{$formula_main_component}',
\"{$ref_round_off_code}\", \"{$formula}\",\"{$formula_for_ui}\")";
$lobj_insert = $aobj_context->mobj_db->Execute($insert_qry);
$comp_class=$aobj_context->main_src."/src/salcompclass.php";
require_once($comp_class);
$check_type_obj=new SalCompClass($aobj_context);
$select_child_comps="select
fd.ref_component_code,formula
from formula_details fd
inner join {$check_type_obj->salary_comp_table_name} sal
on sal.internal_code=fd.ref_component_code
where ( fd.formula like '%{{$formula_main_component}}%' or
fd.ref_component_code={$formula_main_component})
order by sal.{$check_type_obj->salary_comp_sequence}";
$lobj_select_child_comps = $aobj_context->mobj_db->GetAll($select_child_comps);
foreach($lobj_select_child_comps as $k=>$v)
{
UpdateSalarySetuForUpdatedFormula($aobj_context,$v['ref_component_code'],$v['formula']);
}
if($lobj_insert)
{
$rdata="Formula Header Details Inserted Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
else
{
$rdata="Insertion Failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success");
return $rdata;
}
}
function UpdateSalarySetuForUpdatedFormula($aobj_context,$formula_main_component,$formula)
{
$emp_class=$aobj_context->main_src."/src/employeeClass.php";
$orignial_formula=$formula;
include_once($emp_class);
$obj_emp=new employeeClass($aobj_context);
$obj_emp->employee();
$check_type_obj=new SalCompClass($aobj_context);
$all_employees_personal_details_arr="";
$emp_pos=strpos($formula,'EMP_');
if($emp_pos===false){} else
{
$all_employees=getAllEmployeeValuesForFormula($aobj_context);
$all_obj= $aobj_context->mobj_db->GetAll($all_employees);
foreach($all_obj as $ek=>$ev)
{
$ref_emp_code=$ev['emp_code'];
foreach($ev as $emp_key=>$emp_val)
$all_employees_personal_details_arr[$ref_emp_code][$emp_key]=$emp_val;
}
}
$user_id=$_SESSION['user_id'];
$client=$_SESSION['client_db'];
$tmp_salary_setup_insert_file= $aobj_context->main_src."/imported_files/tmp_salary_setup_insert_file_{$client}_{$user_id}.txt";;
unlink($tmp_salary_setup_insert_file);
$fh = fopen($tmp_salary_setup_insert_file, 'a') or die("can't open file");
$tmp_table_name="tmp_formula_update_result_{$user_id}".date("His");
$create_table="CREATE TABLE `{$tmp_table_name}` (
`internal_code` int(11) NOT NULL AUTO_INCREMENT,
`ref_emp_code` int(11),
`ref_salary_setup_header_code` int(11),
`ref_component_code` int(11),
`amount` decimal(14,2),
PRIMARY KEY (`internal_code`),
KEY `ref_emp_code` (`ref_emp_code`),
KEY `ref_salary_setup_header_code` (`ref_salary_setup_header_code`),
KEY `ref_component_code` (`ref_component_code`)) ";
$aobj_context->mobj_db->Execute("drop table {$tmp_table_name}");
$lobj_create_table = $aobj_context->mobj_db->Execute($create_table);
$get_salary_setup_data=" select * from
(select date_format(effective_date,'%d/%m/%Y') as effective_date,header_code,
ref_emp_code,
group_concat(ref_source_component,'->',source_value order by ref_source_component) as concat_heads
from
( select ref_emp_code,effective_date,internal_code as header_code,ref_source_component,source_value
from salary_setup_header
union
select ssh.ref_emp_code,ssh.effective_date ,ssh.internal_code as header_code,ref_component_code,result
from
salary_setup_header ssh inner join salary_setup_result
ssr on ssh.internal_code=ssr.ref_salary_setup_header_code
order by ref_emp_code,effective_date,ref_source_component)a
group by 1,ref_emp_code
order by effective_date desc ,ref_emp_code)a
group by ref_emp_code order by ref_emp_code ";
$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=100000");
$lobj_get_salary_setup_data = $aobj_context->mobj_db->GetAll($get_salary_setup_data);
foreach($lobj_get_salary_setup_data as $key=>$val)
{
$ref_emp_code=$val['ref_emp_code'];
$comma_split=explode(',',$val[concat_heads]);
foreach($comma_split as $c_key )
{
$arrow_split=explode('->',$c_key);
$employee_slary_master_arr[$ref_emp_code][$arrow_split[0]]=$arrow_split[1];
}
$employee_slary_master_arr[$ref_emp_code]['salary_header_code']=$val['header_code'];
}
foreach($employee_slary_master_arr as $key=>$v)
{
$formula=$orignial_formula;
$brace_count=substr_count($formula, "{");
$emp_code=$key;
$salary_header_code=$employee_slary_master_arr[$emp_code]['salary_header_code'];
if($brace_count>0)
{
for($k=0;$k<($brace_count);$k++)
{
$pos_open_brace=strpos($formula,'{');
$pos_close_brace=strpos($formula,'}');
if ($pos_open_brace === false && $pos_close_brace===false) {
}
else
{
$id=substr($formula, $pos_open_brace+1, (($pos_close_brace)-($pos_open_brace+1)));
$emp_pos=strpos($id,'EMP_');// To Check Emp Postion
if($emp_pos===false)
{
$sal_val=is_null($employee_slary_master_arr[$emp_code][$id])?0:$employee_slary_master_arr[$emp_code][$id];
$value= str_replace("{".$id."}", $sal_val, $formula);
}
else
{
$emp_value=is_null($all_employees_personal_details_arr[$emp_code][$id])?0:$all_employees_personal_details_arr[$emp_code][$id];
$value= str_replace("{".$id."}", $emp_value, $formula);
}
$formula=$value;
}
}
}
else {
$value=$formula;
}
$value=(empty($value))?0:$value;
error_reporting(0);
if(false===eval("\$value = ($value);"))
{
$get_sql_value="select ". stripslashes($value)." as result";
$lobj_get_sql_value = $aobj_context->mobj_db->GetRow($get_sql_value);
$value= empty($lobj_get_sql_value[result])?0:$lobj_get_sql_value[result];
}
else
{
$value=$value;
}
$value=(empty($value))?0:$value;
$field_data = "0"."|".$emp_code."|".$salary_header_code."|".$formula_main_component."|".$value."\n";
fwrite($fh, $field_data);
}
$insert_into_table = "load DATA INFILE '{$tmp_salary_setup_insert_file}'
into table {$tmp_table_name}
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'";
$lobj_insert_boe_text_file = $aobj_context->mobj_db->Execute($insert_into_table);
fclose($fh);
unlink($tmp_salary_setup_insert_file);
$update_salary_setup_result="update salary_setup_result ssr ,{$tmp_table_name} tmp
set ssr.result=tmp.amount
where ssr.ref_salary_setup_header_code=tmp.ref_salary_setup_header_code
and ssr.ref_component_code=tmp.ref_component_code";
$lobj_update_salary_setup_result = $aobj_context->mobj_db->Execute($update_salary_setup_result);
$aobj_context->mobj_db->Execute("drop table {$tmp_table_name}");
}
function getAllEmployeeValuesForFormula($aobj_context)
{
$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=100000");
$aobj_context->mobj_db->execute("set @a:=0");
$select_ref_module_code="select schema_id,GROUP_CONCAT(join_table_name SEPARATOR ' ') as qry from
(select s.internal_code as schema_id,@a:=@a+1,ref_module_code,
concat(' left join module_',ref_module_code, ' as module_',ref_module_code,'_',sus.internal_code,' on module_',ref_module_code,'_',sus.internal_code,'.internal_code =m_',ref_s_user_schema_code, '_ele_',sus.internal_code) as join_table_name
from s_user_schema_elements sus
inner join s_user_schema s on s.internal_code=sus.ref_s_user_schema_code
where module_name='Employee' and is_multiple_group=0 and sus.name!='Reporting Head'
and ref_module_code>0)j group by schema_id";
$obj_select_ref_module_code = $aobj_context->mobj_db->GetRow($select_ref_module_code);
$join_qry=(count($obj_select_ref_module_code)>0)?$obj_select_ref_module_code[qry]:'';
$schema_id=$obj_select_ref_module_code[schema_id];
$get_display_cols="select GROUP_CONCAT(field_name) as field_name from (select table_name,name,
field_name as grid_field_name,
if(ref_module_code<>0,
concat('module_',ref_module_code,'_',ele_ic_code,'.',field_id1,' as \'', 'EMP_',REPLACE(name,' ','_') ,\"'\"),
concat('module_',internal_code,'.',field_name,' as \'', 'EMP_',REPLACE(name,' ','_') ,\"'\")
) as
field_name
,ref_module_code from
(select s.internal_code, t1.value as data_type,ref_module_code,concat('module_',s.internal_code) as table_name ,
field_id,su.internal_code as ele_ic_code,field_id1,
su.name,ifnull(multiple,0) as multiple,ifnull(ug.name,'0None') as group_name,concat('m_',s.internal_code,'_ele_',su.internal_code) as field_name from s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=data_type
left join s_user_schema_group ug on ug.internal_code=su.ref_s_user_schema_group_code
left join module_meta_columns mmc on mmc.module_id=su.ref_module_code
where s.internal_code={$schema_id} and t.value='Meta' and su.name!='Reporting Head'
order by ug.sequence,su.sequence,su.internal_code ) l
where multiple=0
) a ";
$lobj_get_display_cols = $aobj_context->mobj_db->GetRow($get_display_cols);
$select_data="(select module_{$schema_id}.internal_code as emp_code,
{$lobj_get_display_cols[field_name]}
from module_{$schema_id} {$join_qry}
) ";
return $select_data;
}
function getFormulaSetUpDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code = $aobj_context->mobj_data["internal_code"];
$get_formula_details="select fd.internal_code ,ref_component_code,formula_name as grid_formula_name,
formula_for_ui,formula,ref_formula_header_code,
ref_round_off_code,
DATE_FORMAT(from_date,'%d/%m/%Y') as grid_formula_valid_from,
DATE_FORMAT(to_date,'%d/%m/%Y') as grid_formula_valid_to,
starting_element
from formula_header fh inner join
formula_details fd on fh.internal_code=fd.ref_formula_header_code
where fd.internal_code={$internal_code}";
$formula_obj=$aobj_context->mobj_db->GetRow($get_formula_details);
if( $formula_obj)
echo $aobj_context->mobj_output->ToJSONEnvelope($formula_obj,0,"success");
}
function getEmployeeFormulaMappingEmpDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$get_details="
(select su.internal_code,name as module_name from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) ";
$lobj_details = $aobj_context->mobj_db->getAll($get_details);
$arr['emp']=$lobj_details;
$get_formula_details="select internal_code,formula_name
from formula_header order by formula_name";
$lobj_get_formula_details = $aobj_context->mobj_db->getAll($get_formula_details);
$arr['formula']=$lobj_get_formula_details;
if( $lobj_details)
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
function getEmployeeFormulaMappingFormulaDetails($aobj_context)
{
$formula_id=trim($aobj_context->mobj_data["formula_id"]);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$check_type="select * from
(select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name in('name','Type') order by name)a
union
select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Component Type'
and name in('Component type')";
$lobj_check_type = $aobj_context->mobj_db->GetAll($check_type);
$maping="select fh.internal_code,formula_name,formula_for_ui,component,type
from formula_header fh inner join
formula_details fd on fh.internal_code=ref_formula_header_code
inner join
(select c.internal_code as ref_component_code,{$lobj_check_type[0][field_name]} as component,{$lobj_check_type[2][field_name]} as type
from {$lobj_check_type[0][table_name]} c inner join {$lobj_check_type[2][table_name]} d on
d.internal_code={$lobj_check_type [1][field_name]}) a on a.ref_component_code=fd.ref_component_code
where fh.internal_code={$formula_id}";
$lobj_maping = $aobj_context->mobj_db->GetAll($maping);
//background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);
$e_data.="<table align='left' cellspacing='0' cellpadding='0' border='0' width='49%'>";
$e_data.=" <tr ><td class='act_txtclr' colspan='2' style='background-color:#3D83CC; color:#fff; font-weight:700; width:222px; padding:3px 6px; letter-spacing:0.5pt;'>Earnings</td> </tr>";
$e_data.="<tr style='background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);border-bottom:1px solid #CBC7B8; color:#000; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'><td style='padding:2px; border-left:1px solid #ccc; border-right:1px solid #ccc;'>Title</td><td style='border-right:1px solid #ccc; padding:2px;'width='188'>Formula</td> </tr>";
$d_data.="<table align='right' cellspacing='0' cellpadding='0' border='0' width='49%'>";
$d_data.=" <tr ><td class='act_txtclr' colspan='2' style='background-color:#3D83CC; color:#fff; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'>Deductions</td> </tr>";
$d_data.="<tr style='background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);border-bottom:1px solid #CBC7B8; color:#000; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'><td style='padding:2px;border-left:1px solid #ccc; border-right:1px solid #ccc;' >Title</td><td style='padding:2px; border-right:1px solid #ccc;'width='188'>Formula</td></tr>";
$k=0;
$l=0;
foreach($lobj_maping as $key=>$value)
{
if($value[type]=='EARNINGS')
{
if($k%2==0)
$class='tbl_row';
else
$class='tbl_row1';
$e_data.="<tr class={$class} ><td style=' border-left:1px solid #ccc;padding:2px;'>{$value[component]}</td><td style='padding:2px;'>{$value[formula_for_ui]}</td> </tr>";
$k++;
}
else if($value[type]=='DEDUCTIONS')
{
if($l%2==0)
$class='tbl_row';
else
$class='tbl_row1';
$d_data.="<tr class={$class} ><td style='border-left:1px solid #ccc; padding:2px;'>{$value[component]}</td><td style='padding:2px;'>{$value[formula_for_ui]}</td> </tr>";
$l++;
}
}
$arr =$e_data."</table>".$d_data."</table>";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
function getEmployeeFormulaMappingValue($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["emp_ele_name"];
$qry="select a.*,meta_cols.field_id as field_name,ifnull(field_name,a.name) as name,
ifnull(table_name,0) as table_name from
(select su.internal_code,name ,t1.value as data_type,su.ref_module_code,db_field from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0
and su.internal_code={$internal_code}
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) a
left join module_meta_columns meta_cols on meta_cols.module_id=ref_module_code";
// echo $qry;
$lobj_rs = $aobj_context->mobj_db->GetRow($qry);
//echo $qry;
print_r($aobj_context->mobj_output->ToJSONEnvelope($lobj_rs,0,"success"));
return $lobj_rs;
}
function getAddedMappedValue($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$id=$aobj_context->mobj_data["ele_id"];
$qry="select a.*,meta_cols.field_id as field_name,ifnull(field_name,a.name) as name,ifnull(table_name,0) as table_name from
(select s.internal_code as schema_id,t.value as meta, su.internal_code,name ,t1.value as data_type,su.ref_module_code,db_field from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0 and su.internal_code={$id}
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) a
left join module_meta_columns meta_cols on meta_cols.module_id=ref_module_code";
$get_source_details = $aobj_context->mobj_db->GetRow($qry);
if($get_source_details["ref_module_code"]<>0)
{
$table_name="module_".$get_source_details["ref_module_code"];
$get_map_qry="select internal_code,".$get_source_details["ref_module_code"]." as ref_module_code,concat(".$get_source_details["field_name"].") as result from {$table_name} where internal_code={$internal_code}";
}
else if ($get_source_details["meta"]=='Meta')
{
$table_name="module_".$get_source_details["schema_id"];
$get_map_qry="select internal_code,0 as ref_module_code, ".$get_source_details["db_field"]." as result from {$table_name} where internal_code={$internal_code}";
}
else if ($get_source_details["meta"]=='User')
{
$table_name="module_".$get_source_details["schema_id"]."_details";
$get_map_qry="select internal_code,0 as ref_module_code,value as result from {$table_name}
where internal_code={$internal_code} and ref_s_user_schema_elements_code={$id}";
}
$obj_get_map_qry = $aobj_context->mobj_db->GetRow($get_map_qry);
print_r($aobj_context->mobj_output->ToJSONEnvelope($obj_get_map_qry,0,"success"));
return $lobj_rs;
}
function saveFormulaMappingDetails($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$map_at=addslashes(trim($aobj_context->mobj_data["map_at"]));
$map_value=addslashes(trim($aobj_context->mobj_data["map_value"]));
$ref_module_code=addslashes(trim($aobj_context->mobj_data["ref_module_code"]));
$ref_formula_code=addslashes(trim($aobj_context->mobj_data["ref_formula_code"]));
$ref_module_code=(empty($ref_module_code))?0:$ref_module_code;
if($internal_code==0)
{
if($map_at==0 || $map_at=='0')
{
$delete_from_emp_formula_map="delete from emp_formula_map";
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from_emp_formula_map);
}
$delete_emp_formula_map="delete from emp_formula_map where
map_at={$map_at} and map_value={$map_value} and ref_formula_code={$ref_formula_code}";
$obj_delete_emp_formula_map = $aobj_context->mobj_db->Execute($delete_emp_formula_map);
$insert_emp_formula_map="insert into emp_formula_map
(map_at,
map_value,
ref_module_code,
ref_formula_code
)
values ('{$map_at}','{$map_value}','{$ref_module_code}','{$ref_formula_code}')";
$lobj_insert_qry = $aobj_context->mobj_db->Execute($insert_emp_formula_map);
// to insert ids in second table
$get_emp_id_field="select table_name, field_id1 as db_field from module_meta_columns
where module_name='Employee' ";
$obj_get_emp_id_field = $aobj_context->mobj_db->GetRow($get_emp_id_field);
$get_emp_ids="select a.*,meta_cols.field_id as field_name,ifnull(field_name,a.name) as name,ifnull(table_name,0) as table_name from
(select s.internal_code as schema_id,t.value as meta, su.internal_code,name ,t1.value as data_type,su.ref_module_code,db_field from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0 and su.internal_code={$map_at}
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) a
left join module_meta_columns meta_cols on meta_cols.module_id=ref_module_code";
//echo $get_emp_ids;
$get_source_details = $aobj_context->mobj_db->GetRow($get_emp_ids);
$emp_table_name="module_".$get_source_details["schema_id"];
if ($get_source_details["meta"]=='Meta')
$table_name="module_".$get_source_details["schema_id"];
else if ($get_source_details["meta"]=='User')
$table_name="module_".$get_source_details["schema_id"]."_details";
if ($get_source_details["meta"]=='User')
{
$SQL = "select t.ref_s_module_code as id, ".$obj_get_emp_id_field["db_field"]." as emp_code
from $table_name t inner join $emp_table_name t1 on t1.internal_code=t.ref_s_module_code
where ref_s_user_schema_elements_code={$map_at} and value= '{$map_value}' " ;
}
else
{
$SQL = " select internal_code as id,".$obj_get_emp_id_field["db_field"]." as emp_code
from $table_name where ".$get_source_details["db_field"]."='{$map_value}'";
}
$get_emp_id_details = $aobj_context->mobj_db->GetAll($SQL);
// If user selects map At for All Employee
if($map_at==0 || $map_at=='0')
{
$delete_from="delete from emp_formula_mapped_ids";
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from);
$insert_for_all=" insert into emp_formula_mapped_ids
(ref_emp_code,
emp_code,
ref_formula_code)
select internal_code as ref_emp_code,'',{$ref_formula_code} as ref_formula_code
from {$obj_get_emp_id_field[table_name]}";
$obj_insert_for_all = $aobj_context->mobj_db->Execute($insert_for_all);
}
else
{
foreach($get_emp_id_details as $key=>$value)
{
$delete_from="delete from emp_formula_mapped_ids where ref_emp_code=".$value['id'];
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from);
$insert_emp_formula_mapped_ids="insert into emp_formula_mapped_ids
(ref_emp_code,
emp_code,
ref_formula_code) values
(
'".$value['id']."','".$value['emp_code']."',
{$ref_formula_code}
)";
$obj_insert_emp_formula_mapped_ids = $aobj_context->mobj_db->Execute($insert_emp_formula_mapped_ids);
}
}
if($lobj_insert_qry)
{
$rdata = "Formula Mapping Details Inserted Successfully.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
return $rdata;
}
else
{
$rdata = "insertion Failed.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));
return $rdata;
}
}
else if($internal_code>0)
{
if($map_at==0 || $map_at=='0')
{
$delete_from_emp_formula_map="delete from emp_formula_map";
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from_emp_formula_map);
}
$update_emp_formula_map="update emp_formula_map
set map_at='{$map_at}',map_value='{$map_value}',ref_module_code='{$ref_module_code}',
ref_formula_code='{$ref_formula_code}' where internal_code={$internal_code}";
// to insert ids in second table
$get_emp_id_field="select table_name, field_id1 as db_field from module_meta_columns
where module_name='Employee'";
$obj_get_emp_id_field = $aobj_context->mobj_db->GetRow($get_emp_id_field);
$get_emp_ids="select a.*,meta_cols.field_id as field_name,ifnull(field_name,a.name) as name,ifnull(table_name,0) as table_name from
(select s.internal_code as schema_id,t.value as meta, su.internal_code,name ,t1.value as data_type,su.ref_module_code,db_field from
s_user_schema s inner join s_user_schema_elements su on
su.ref_s_user_schema_code=s.internal_code
inner join s_ref_type t on t.internal_code=su.s_ref_type_meta
inner join s_ref_type t1 on t1.internal_code=su.data_type
where module_name='Employee' and is_multiple_group=0 and su.internal_code={$map_at}
and ((
t1.value in('List Of Values','Reference Data')) or (t.value='meta' and is_unique=1))) a
left join module_meta_columns meta_cols on meta_cols.module_id=ref_module_code";
//echo $get_emp_ids;
$get_source_details = $aobj_context->mobj_db->GetRow($get_emp_ids);
$emp_table_name="module_".$get_source_details["schema_id"];
if ($get_source_details["meta"]=='Meta')
$table_name="module_".$get_source_details["schema_id"];
else if ($get_source_details["meta"]=='User')
$table_name="module_".$get_source_details["schema_id"]."_details";
if ($get_source_details["meta"]=='User')
{
$SQL = "select t.ref_s_module_code as id, ".$obj_get_emp_id_field["db_field"]." as emp_code
from $table_name t inner join $emp_table_name t1 on t1.internal_code=t.ref_s_module_code
where ref_s_user_schema_elements_code={$map_at} and value= '{$map_value}' " ;
}
else
{
$SQL = " select internal_code as id,".$obj_get_emp_id_field["db_field"]." as emp_code
from $table_name where ".$get_source_details["db_field"]."='{$map_value}'";
}
$get_emp_id_details = $aobj_context->mobj_db->GetAll($SQL);
if($map_at==0 || $map_at=='0')
{
$delete_from="delete from emp_formula_mapped_ids";
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from);
$insert_for_all=" insert into emp_formula_mapped_ids
(ref_emp_code,
emp_code,
ref_formula_code)
select internal_code as ref_emp_code,'',{$ref_formula_code} as ref_formula_code
from {$obj_get_emp_id_field[table_name]}";
$obj_insert_for_all = $aobj_context->mobj_db->Execute($insert_for_all);
}
else
{
foreach($get_emp_id_details as $key=>$value)
{
$delete_from="delete from emp_formula_mapped_ids where ref_emp_code=".$value['id'] ;
$obj_delete_from=$aobj_context->mobj_db->Execute($delete_from);
$insert_emp_formula_mapped_ids="insert into emp_formula_mapped_ids
(ref_emp_code,
emp_code,
ref_formula_code) values
(
'".$value['id']."','".$value['emp_code']."',
{$ref_formula_code}
)";
$obj_insert_emp_formula_mapped_ids = $aobj_context->mobj_db->Execute($insert_emp_formula_mapped_ids);
}
}
$lobj_update_emp_formula_map = $aobj_context->mobj_db->Execute($update_emp_formula_map);
if($lobj_update_emp_formula_map)
{
$rdata = "Formula Mapping Details Updated Successfully.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
return $rdata;
}
else
{
$rdata = "Updation Failed.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));
return $rdata;
}
}
}
function getEmployeeFormulaMapping($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$get_module_code="select ref_module_code,concat('module_',ref_module_code) as table_name ,field_id
from emp_formula_map efm inner
join module_meta_columns mtc on mtc.module_id=ref_module_code
where efm.internal_code={$internal_code}";
$lobj_get_module_code = $aobj_context->mobj_db->getRow($get_module_code);
if(!empty($lobj_get_module_code))
{
$get_details="select efm.internal_code,map_at,ref_formula_code,ref_module_code,
concat(".$lobj_get_module_code["field_id"].") as map_value, t.internal_code as hidden_id
from emp_formula_map efm inner join ".$lobj_get_module_code["table_name"]." t on t.internal_code=map_value
where efm.internal_code={$internal_code}";
}
else
{
$get_details="select efm.internal_code,map_at,ref_formula_code,ref_module_code,
map_value, 0 as hidden_id
from emp_formula_map efm where efm.internal_code={$internal_code} ";
}
$lobj_get_details = $aobj_context->mobj_db->getRow($get_details);
print_r($aobj_context->mobj_output->ToJSONEnvelope($lobj_get_details,0,"success"));
return $rdata;
}
function getAddedSalaryMappedValue($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$ref_emp_code=$aobj_context->mobj_data["internal_code"];
require_once("employeeClass.php");
$obj_emp=new employeeClass($aobj_context);
$obj_emp->employee();
$get_emp_row="select internal_code,concat({$obj_emp->employee_code},'-',{$obj_emp->employee_name}) as value,
DATE_FORMAT({$obj_emp->employee_dateofjoining},'%d/%m/%Y') as doj from ".
$obj_emp->employee_table." where internal_code={$ref_emp_code}";
$lobj_get_emp_row = $aobj_context->mobj_db->GetRow($get_emp_row);
// to get the formula name based on the emp_id
$get_salary_component_table="select concat('module_',ref_s_user_schema_code) as table_name,
concat('m_',ref_s_user_schema_code,'_ele_',us.internal_code) as field_name
from s_user_schema_elements us
inner join s_user_schema s on s.internal_code=ref_s_user_schema_code
where module_name='Salary Components'
and name ='name' ";
$lobj_get_salary_component_table = $aobj_context->mobj_db->GetRow($get_salary_component_table);
$cmp_field_name=$lobj_get_salary_component_table[field_name];
$cmp_table_name=$lobj_get_salary_component_table[table_name];
$get_formula_name="select fh.internal_code,fh.formula_name,$cmp_field_name as source_component,starting_element
from formula_header fh inner join emp_formula_mapped_ids efmi
on efmi.ref_formula_code=fh.internal_code
inner join $cmp_table_name t on t.internal_code=starting_element
where efmi.ref_emp_code={$ref_emp_code}";
$lobj_get_formula_name = $aobj_context->mobj_db->GetRow($get_formula_name);
//echo $get_formula_name;
// get whether salary has been set allready for emp
$get_emp_eff_date_count="(select count(*) as emp_count from
salary_setup_header ssh inner join salary_setup_result ssr
on ssh.internal_code=ref_salary_setup_header_code
where ref_emp_code={$ref_emp_code} )";
$lobj_get_emp_eff_date_count = $aobj_context->mobj_db->GetRow($get_emp_eff_date_count);
$arr["emp_data"]=$lobj_get_emp_row;
$arr["formula_name"]=$lobj_get_formula_name;
$arr["effective_date"]=$lobj_get_emp_eff_date_count;
// echo $get_emp_row;
print_r($aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"));
return $lobj_rs;
}
function addMappedFinYearElement($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
include_once("employeeClass.php");
$fin_obj=new employeeClass($aobj_context);
$fin_obj->fin_year();
$get_data="select internal_code,
{$fin_obj->fin_year_start_date} as start_date,
{$fin_obj->fin_year_end_date} as end_date,
{$fin_obj->fin_year_code} as year_code
from {$fin_obj->fin_year_table}
where internal_code={$internal_code}";
$lobj_get_data = $aobj_context->mobj_db->GetRow($get_data);
$arr["fin_data"]=$lobj_get_data;
print_r($aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"));
return $lobj_rs;
}
function getEmployeeFormulaSetupFormulaDetails($aobj_context)
{
$formula_id=trim($aobj_context->mobj_data["formula_id"]);
$ref_emp_code=trim($aobj_context->mobj_data["ref_emp_code"]);
$salary_header_ic=trim($aobj_context->mobj_data["salary_header_ic"]);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$check_type_obj=new SalCompClass($aobj_context);
if($salary_header_ic==0)
{
require_once("employeeClass.php");
$obj_emp=new employeeClass($aobj_context);
$obj_emp->employee();
$get_emp_row="select internal_code,concat(".$obj_emp->employee_code.") as value,
DATE_FORMAT({$obj_emp->employee_dateofjoining},'%d/%m/%Y') as effective_date from ".
$obj_emp->employee_table." where internal_code={$ref_emp_code}";
$lobj_get_formula_code = $aobj_context->mobj_db->GetRow($get_emp_row);
}
else
{
$get_max_date="select max(effective_date) as effective_date
from salary_setup_header where internal_code=$salary_header_ic";
$lobj_get_max_date = $aobj_context->mobj_db->GetRow($get_max_date);
$max_effective_date=$lobj_get_max_date[effective_date];
$get_formula_code="select ref_formula_code,source_value,
DATE_FORMAT(effective_date,'%d/%m/%Y') as effective_date,
DATE_FORMAT(arrear_month,'%d/%m/%Y') as arrear_month
from salary_setup_header
where internal_code=$salary_header_ic";
$lobj_get_formula_code = $aobj_context->mobj_db->GetRow($get_formula_code);
}
$get_start_ele="select starting_element from formula_header where internal_code={$formula_id}";
$lobj_get_start_ele = $aobj_context->mobj_db->GetRow($get_start_ele);
$check_type="(select c.internal_code as ref_component_code,
{$check_type_obj->salary_comp_field_name} as component,
{$check_type_obj->salary_comp_type_field_name} as type,
{$check_type_obj->round_off_field_name} as round_off,
{$check_type_obj->salary_comp_sequence} as sequence
from {$check_type_obj->salary_comp_table_name} c
inner join {$check_type_obj->salary_comp_type_table_name} d on
d.internal_code={$check_type_obj->salary_comp_type}
left join {$check_type_obj->round_off_table} r on
r.internal_code={$check_type_obj->salary_comp_round_off}
where c.internal_code<>{$lobj_get_start_ele[starting_element]}
order by {$check_type_obj->salary_comp_type_field_name} desc,c.internal_code)";
$maping="select ifnull(fh.internal_code,0) as internal_code,
concat('salary_setup_comp_',a.ref_component_code ) as ref_component_code,
a.ref_component_code as ref_component_id,
formula_name,
formula,component,
type,
result,round_off,
a.sequence from
formula_header fh inner join
formula_details fd on fh.internal_code=ref_formula_header_code
right join
({$check_type}) a
on a.ref_component_code=fd.ref_component_code
and fh.internal_code={$formula_id} left join
(select ref_component_code,result from
salary_setup_header ssh inner join salary_setup_result ssr
on ssh.internal_code=ref_salary_setup_header_code
where ref_emp_code={$ref_emp_code} and ref_formula_code={$formula_id}
and effective_date='{$max_effective_date}') b
on b.ref_component_code=a.ref_component_code order by sequence";
$lobj_maping = $aobj_context->mobj_db->GetAll($maping);
//echo $maping;
//background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);
$e_data.="<table align='left' cellspacing='0' cellpadding='0' border='0' width='49%'>";
$e_data.=" <tr ><td class='act_txtclr' colspan='3' style='background-color:#3D83CC; color:#fff; font-weight:700; width:222px; padding:3px 6px; letter-spacing:0.5pt;'>Earnings</td> </tr>";
$e_data.="<tr style='background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);border-bottom:1px solid #CBC7B8; color:#000; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'><td style='padding:2px; border-left:1px solid #ccc; border-right:1px solid #ccc;'>Title</td><td style='padding:2px; border-right:1px solid #ccc;'>Old value</td><td style='border-right:1px solid #ccc; padding:2px; width:75px'>Value</td> </tr>";
$d_data.="<table align='right' cellspacing='0' cellpadding='0' border='0' width='49%'>";
$d_data.=" <tr ><td class='act_txtclr' colspan='3' style='background-color:#3D83CC; color:#fff; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'>Deductions</td> </tr>";
$d_data.="<tr style='background-image:url(../jqGrid3/themes/tarka/images/grid-blue-hd.gif);border-bottom:1px solid #CBC7B8; color:#000; font-weight:700; padding:3px 6px; letter-spacing:0.5pt;'><td style='padding:2px;border-left:1px solid #ccc; border-right:1px solid #ccc;' >Title</td><td style='padding:2px; border-right:1px solid #ccc;'>Old Value</td><td style='padding:2px; border-right:1px solid #ccc;width:75px'>Value</td></tr>";
$k=0;
$l=0;
foreach($lobj_maping as $key=>$value)
{
if($value[type]=='EARNINGS')
{
if($k%2==0)
$class='tbl_row';
else
$class='tbl_row1';
$disabled=$value[internal_code]>0?"disabled='true'":'';
$td_value=$value[internal_code]>0?0:$value[result];
$e_data.="<tr class={$class} ><td style=' border-left:1px solid #ccc;padding:2px;'>{$value[component]}</td><td align='right' style='padding:3px 6px;'>{$td_value}</td><td style='padding:2px;' align=right><input style='width:75px' id={$value[ref_component_code]} type='text' {$disabled} value={$td_value}></td> </tr>";
$k++;
}
else
{
if($l%2==0)
$class='tbl_row';
else
$class='tbl_row1';
$disabled1=$value[internal_code]>0?"disabled='true'":'';
$td_value1=$value[internal_code]>0?0:$value[result];
$d_data.="<tr class={$class} ><td style='border-left:1px solid #ccc; padding:2px;'>{$value[component]}</td><td align='right' style='padding:3px 6px;'>{$td_value1} </td><td align=right style='padding:2px;' ><input style='width:75px' id={$value[ref_component_code]} type='text' {$disabled1} value={$td_value1}></td> </tr>";
$l++;
}
}
$arr['table_data'] =$e_data."</table>".$d_data."</table>";
$arr['formula_details'] =$lobj_maping;
$arr['effective_date'] = $lobj_get_formula_code;
//$arr['effective_date'] =empty($lobj_get_formula_code)? "00/00/0000":$lobj_get_formula_code;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
//IF({Gross Earnings}<4999,0,IF({Gross Earnings}<7999,60,IF({Gross Earnings}<9999,100,IF({Gross Earnings}<14999,150,200))));
//IF({Gross Earnings}<10000,0,IF({Gross Earnings}<14999,150,200))
?>
|