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 : 3.12.165.68
<?php
function getMapAtEmployeeIdQuery($aobj_context,$map_at,$map_value)
{
$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);
if($map_at>0)
{
$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}'";
}
}
else
{
$SQL = "select internal_code as id,".$obj_get_emp_id_field["db_field"]." as emp_code from ".
$obj_get_emp_id_field[table_name]." order by 1";
}
return $SQL;
}
function getMapAtEmployeeIdCondition($aobj_context,$map_at,$map_value)
{
$get_emp_id_field="select table_name,module_id, 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);
$module_id=$obj_get_emp_id_field[module_id];
if($map_at>0)
{
$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
{
$where_cond = " where module_{$module_id}.".$get_source_details["db_field"]."='{$map_value}'";
}
}
else
{
$where_cond = " ";
}
//echo $where_cond.'as';
return $where_cond;
}
?>
|