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 : 52.15.241.87
<?php
function insertUserSchemaGroup($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$internal_code=$aobj_context->mobj_data["internal_code"];
$group_user_schema=addslashes($aobj_context->mobj_data["group_user_schema"]);
$user_schema_group_name=addslashes(trim($aobj_context->mobj_data["user_schema_group_name"]));
$sequence=addslashes(trim($aobj_context->mobj_data["sequence"]));
$user_schema_parent_group=addslashes($aobj_context->mobj_data["user_schema_parent_group"]);
$is_multiple_user_schema_group=addslashes(trim($aobj_context->mobj_data["is_multiple_user_schema_group"]));
$is_grid_edit_user_schema_group=addslashes(trim($aobj_context->mobj_data["is_grid_edit_user_schema_group"]));
$is_grid_edit_inline=addslashes(trim($aobj_context->mobj_data["is_grid_edit_inline"]));
$add_row_exit_field=addslashes(trim($aobj_context->mobj_data["add_row_exit_field"]));
$is_inline_div_user_schema_group=addslashes(trim($aobj_context->mobj_data["is_inline_div_user_schema_group"]));
$is_multi_select_div_user_schema_group=addslashes(trim($aobj_context->mobj_data["is_multi_select_div_user_schema_group"]));
$user_schema_group_min_rows=addslashes(trim($aobj_context->mobj_data["user_schema_group_min_rows"]));
$user_schema_group_max_rows=addslashes(trim($aobj_context->mobj_data["user_schema_group_max_rows"]));
$user_schema_coloum_names=($aobj_context->mobj_data["user_schema_coloum_names"]);
$user_schema_coloum_models=($aobj_context->mobj_data["user_schema_coloum_models"]);
$user_schema_grid_query=($aobj_context->mobj_data["user_schema_grid_query"]);
$user_schema_group_custom_links=addslashes($aobj_context->mobj_data["user_schema_group_custom_links"]);
$user_schema_group_onclick=addslashes($aobj_context->mobj_data["user_schema_group_onclick"]);
$system_group_table_name=$aobj_context->mobj_data["system_group_table_name"];
if($internal_code==0)
{
$get_data="select count(*) as group_schema_count from s_user_schema_group
where name='{$user_schema_group_name}'
and ref_s_user_schema_code='{$group_user_schema}' ";
$lobj_rs = $aobj_context->mobj_db->GetRow($get_data);
if($lobj_rs['group_schema_count']==0)
{
$lstr_qry = "insert into s_user_schema_group(
ref_s_user_schema_code,
name,parent_group_code,sequence,multiple,
is_grid_edit,is_grid_edit_inline,add_row_exit_field,inline_div,is_multi_select,col_name,col_model,grid_edit_query,
custom_links,on_click_event,system_group_table_name,group_min_rows,group_max_rows)
values ( '{$group_user_schema}',
'{$user_schema_group_name}',
'{$user_schema_parent_group}',
'{$sequence}',
'{$is_multiple_user_schema_group}',
'{$is_grid_edit_user_schema_group}',
'{$is_grid_edit_inline}',
'{$add_row_exit_field}',
'{$is_inline_div_user_schema_group}',
'{$is_multi_select_div_user_schema_group}',
\"{$user_schema_coloum_names}\",
\"{$user_schema_coloum_models}\",
\"{$user_schema_grid_query}\",
\"{$user_schema_group_custom_links}\",
\"{$user_schema_group_onclick}\",
'{$system_group_table_name}',
'{$user_schema_group_min_rows}',
'{$user_schema_group_max_rows}'
)";
//echo $lstr_qry; die();
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
$last_inserted_id = $aobj_context->mobj_db->Insert_ID();
//if group is set to multile it will create new table with user_schema_[internal_code]_group_[internal_code] with fields internal_code,ref_s_user_schema_code,ref_s_user_schema_group_code
// we will alter this table when new elemnt has been added to coresponding schema and group
if($aobj_context->mobj_data["is_multiple_user_schema_group"]==1)
{
$qry="select concat(system_module_table_name,'_',system_group_table_name,'_group') as group_table_name,
CONCAT(system_module_table_name,'_',system_group_table_name,'_entry') as entry_table_name
from s_user_schema_group msg inner join s_user_schema ms on ms.internal_code=msg.ref_s_user_schema_code
where msg.internal_code=$last_inserted_id";
$lobj_rs = $aobj_context->mobj_db->GetRow($qry);
$create_table="CREATE TABLE ". $lobj_rs['group_table_name'].
"(
internal_code bigint(20) unsigned NOT NULL auto_increment,
ref_s_user_schema_code bigint(20),
ref_s_user_schema_group_code bigint(20),
ref_s_ref_data_code bigint(20),
created_by int(11) default NULL,
created_date datetime default NULL,
modified_by int(11) default NULL,
modified_date datetime default NULL,
PRIMARY KEY (internal_code),
KEY `ref_s_ref_data_code` (`ref_s_ref_data_code`)
) engine INNODB";
$lobj_create_table = $aobj_context->mobj_db->Execute($create_table);
$create_entry_table="CREATE TABLE {$lobj_rs['entry_table_name']}
(
internal_code bigint(20) unsigned NOT NULL auto_increment,
login_cnt int(11),
group_int_code int(11) default 0,
ref_s_user_schema_code bigint(20),
ref_s_user_schema_group_code bigint(20),
ref_s_ref_data_code bigint(20),
created_by int(11) default NULL,
created_date datetime default NULL,
modified_by int(11) default NULL,
modified_date datetime default NULL,
PRIMARY KEY (internal_code),
KEY `login_cnt` (`login_cnt`),
KEY `group_int_code` (`group_int_code`),
KEY `ref_s_ref_data_code` (`ref_s_ref_data_code`)
) engine INNODB";
$lobj_create_entry_table = $aobj_context->mobj_db->Execute($create_entry_table);
}
// to give default add permisssion to user_rights table Start on 14-nov-2008
$get_module_type="select module_type from s_user_schema where internal_code=".$aobj_context->mobj_data["group_user_schema"];
$lobj_get_module_type = $aobj_context->mobj_db->getRow($get_module_type);
// to give default add permisssion to user_rights table End on 14-nov-2008
$module_type=$lobj_get_module_type["module_type"];
$module_id=$aobj_context->mobj_data["group_user_schema"]."_".$last_inserted_id;
$insert_rights="insert into user_rights(
ref_s_sysdb_code,
module_type,
module_id,
is_view,
is_add,
is_edit,
is_del) values
(1,{$module_type},'{$module_id}',1,1,1,1)";
$lobj_insert_rights = $aobj_context->mobj_db->Execute($insert_rights);
if($lobj_rs)
{
$rdata = "Group Name inserted successfully. && ".$lobj_rs['group_table_name'] ." Created ";
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
{
$rdata = "Group Name Already Exstis!";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
return $rdata;
}
}
else
{
$group_table="select concat(system_module_table_name,'_',system_group_table_name,'_group') as group_table_name,
CONCAT(system_module_table_name,'_',system_group_table_name,'_entry') as entry_table_name
from s_user_schema_group where internal_code=".$internal_code;
$lobj_rs_row = $aobj_context->mobj_db->GetRow($group_table);
//if grou has been changed from multiple to non mutiple delete that group
if($aobj_context->mobj_data["is_multiple_user_schema_group"]==0)
{
$drop_non_multiple="drop table if EXISTS user_schema_".$aobj_context->mobj_data["group_user_schema"]."_group_".$aobj_context->mobj_data["internal_code"];
$drop_obj=$aobj_context->mobj_db->Execute($drop_non_multiple);
//echo $drop_non_multiple;
}
// if existing group has non multiple and trieng to make it as multiple
else if($lobj_rs_row["multiple"]==0 && $aobj_context->mobj_data["is_multiple_user_schema_group"]==1)
{ $create_table="CREATE TABLE {$lobj_rs_row[group_table_name]}
(
internal_code bigint(20) unsigned NOT NULL auto_increment,
ref_s_user_schema_code bigint(20),
ref_s_user_schema_group_code bigint(20),
ref_s_ref_data_code bigint(20),
created_by int(11) default NULL,
created_date datetime default NULL,
modified_by int(11) default NULL,
modified_date datetime default NULL,
PRIMARY KEY (internal_code)
) ";
$lobj_create_table = $aobj_context->mobj_db->Execute($create_table);
$create_entry_table="CREATE TABLE ". $lobj_rs_row['entry_table_name'].
"(
internal_code bigint(20) unsigned NOT NULL auto_increment,
login_cnt int(11),
group_int_code int(11) default 0,
ref_s_user_schema_code bigint(20),
ref_s_user_schema_group_code bigint(20),
ref_s_ref_data_code bigint(20),
created_by int(11) default NULL,
created_date datetime default NULL,
modified_by int(11) default NULL,
modified_date datetime default NULL,
PRIMARY KEY (internal_code),
KEY `login_cnt` (`login_cnt`),
KEY `group_int_code` (`group_int_code`)
) ";
$lobj_create_entry_table = $aobj_context->mobj_db->Execute($create_entry_table);
}
$get_exsting_values="select * from s_user_schema_group where
internal_code={$internal_code}";
$lobj_get_exsting_values = $aobj_context->mobj_db->GetRow($get_exsting_values);
$e_system_group_table_name=$lobj_get_exsting_values["system_group_table_name"];
$lstr_qry = "update s_user_schema_group
set ref_s_user_schema_code='{$group_user_schema}',
name='{$user_schema_group_name}',
parent_group_code='{$user_schema_parent_group}',
multiple='{$is_multiple_user_schema_group}',
sequence='{$sequence}',
is_grid_edit='{$is_grid_edit_user_schema_group}',
is_grid_edit_inline='{$is_grid_edit_inline}',
add_row_exit_field='{$add_row_exit_field}',
inline_div='{$is_inline_div_user_schema_group}',
is_multi_select='{$is_multi_select_div_user_schema_group}',
col_name=\"{$user_schema_coloum_names}\",
col_model=\"{$user_schema_coloum_models}\",
grid_edit_query=\"{$user_schema_grid_query}\",
custom_links=\"{$user_schema_group_custom_links}\",
on_click_event=\"{$user_schema_group_onclick}\",
system_group_table_name='{$system_group_table_name}',
group_min_rows='{$user_schema_group_min_rows}',
group_max_rows='{$user_schema_group_max_rows}'
where internal_code =".$aobj_context->mobj_data["internal_code"];
$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
$alter_field="alter table {$e_system_group_table_name} RENAME TO
{$system_group_table_name}";
//echo $alter_field;
$lobj_alter_field = $aobj_context->mobj_db->Execute($alter_field);
if($lobj_rs)
{
$rdata = "Updated Successfully.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
return;
}
else
{
$rdata = "Udatation Failed.";
print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,-1,"Failure"));
}
}
}
?>
|