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.151.11
<?php
function createModuleMetaColumns($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$get_schema_id="(select distinct internal_code as schema_id from
(select s.internal_code,ifnull(multiple,0) as multiple 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
left join s_user_schema_group ug on ug.internal_code=su.ref_s_user_schema_group_code
where t.value='Meta' order by ug.sequence,su.sequence,su.internal_code ) l
where multiple=0 ) ";
$lobj_get_schema_id = $aobj_context->mobj_db->GetAll($get_schema_id);
foreach($lobj_get_schema_id as $key1=>$schema_value)
{
$get_display_cols="select schema_id as module_id,module_name, concat('module_',schema_id) as table_name,
GROUP_CONCAT(name order by sequence SEPARATOR '-ele-') as field_name,
GROUP_CONCAT(field_name order by sequence separator ',\'-\',') as field_id from
(select ref_s_user_schema_code as schema_id,s.sequence,module_name,name,db_field as field_name
from s_user_schema_elements s inner join s_user_schema su on su.internal_code=ref_s_user_schema_code
where is_key_field=1 and ref_s_user_schema_code=".$schema_value[schema_id]."
order by ref_s_user_schema_group_code,ifnull(s.sequence,0),su.internal_code
limit 2) a group by schema_id";
$lobj_data = $aobj_context->mobj_db->GetRow($get_display_cols);
// if Pop up columns are not exstis it will use Old Logic
// GROUP_CONCAT('module_',schema_id,'.',field_name separator ',\'-\',')
if(empty($lobj_data))
{
$aobj_context->mobj_db->Execute("SET @@session.group_concat_max_len=10000");
$get_display_cols="select schema_id as module_id,module_name, concat('module_',schema_id) as table_name,
GROUP_CONCAT(name SEPARATOR '-ele-') as field_name,
GROUP_CONCAT(field_name separator ',\'-\',') as field_id from
(select * from
(select s.internal_code as schema_id,module_name,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
left join s_user_schema_group ug on ug.internal_code=su.ref_s_user_schema_group_code
where s.internal_code=".$schema_value[schema_id] ." and t.value='Meta'
order by ifnull(ug.sequence,0),su.sequence,su.internal_code ) l where
multiple=0 limit 2) a group by schema_id";
$lobj_data = $aobj_context->mobj_db->GetRow($get_display_cols);
}
$delete_qry="delete from module_meta_columns where module_id={$lobj_data[module_id]}";
$lobj_delete_qry = $aobj_context->mobj_db->Execute($delete_qry);
$insert_qry="insert into module_meta_columns (
module_id,
module_name,
table_name,
field_name,
field_id) values
({$lobj_data[module_id]},\"{$lobj_data[module_name]}\",\"{$lobj_data[table_name]}\",\"{$lobj_data[field_name]}\",\"{$lobj_data[field_id]}\")";
$lobj_insert_qry = $aobj_context->mobj_db->Execute($insert_qry);
$get_field_names="(select ref_s_user_schema_code as schema_id,module_name,name as field,db_field as field_name
from s_user_schema_elements s inner join s_user_schema su on su.internal_code=ref_s_user_schema_code
where is_key_field=1 and ref_s_user_schema_code=".$schema_value[schema_id]."
order by ref_s_user_schema_group_code,ifnull(s.sequence,0),su.internal_code desc
limit 2)";
$lobj_get_field_names = $aobj_context->mobj_db->GetAll($get_field_names);
// if Pop up columns are not exstis it will use Old Logic
if(empty($lobj_get_field_names))
{
$get_field_names="(select ref_s_user_schema_code as schema_id,module_name,name as field,db_field as field_name
from s_user_schema_elements s inner join s_user_schema su on su.internal_code=ref_s_user_schema_code
where ref_s_user_schema_code=".$schema_value[schema_id]."
order by ref_s_user_schema_group_code,ifnull(s.sequence,0),su.internal_code desc
limit 2)";
$lobj_get_field_names = $aobj_context->mobj_db->GetAll($get_field_names);
}
$field_name1=$lobj_get_field_names[0][field];
$field_name2=$lobj_get_field_names[1][field];
$field_id1=$lobj_get_field_names[0][field_name];
$field_id2=$lobj_get_field_names[1][field_name];
$update_ids="update module_meta_columns set
field_name1='{$field_name1}',
field_name2='{$field_name2}',
field_id1='{$field_id1}',
field_id2='{$field_id2}' where module_id=".$schema_value[schema_id] ;
$lobj_update_ids = $aobj_context->mobj_db->Execute($update_ids);
//echo $update_ids;
}
/* if(count($lobj_insert_qry) != 0){
$data="Fields Updated Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
}
else {
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"Failure");
$data="Fields Updation Failed";
}
return; */
}
?>
|