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.14.247.170
<?php
function populateAllGridGroupFiles($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$schema_id =$aobj_context->mobj_data["schema_id"];
$schema_cond='';
if(!($schema_id==0 or $schema_id=='0'))
{
$schema_cond=" and ref_s_user_schema_code={$schema_id} ";
}
$group_table_name="select
internal_code as group_code,
name,
col_name,col_model,grid_edit_query,
ifnull(group_order_by,'id') as group_order_by,
ifnull(group_default_rows,5) as group_default_rows,
ifnull(is_grid_edit,0) as is_grid_edit,
ifnull(parent_group_code,0) as parent_group_code,
concat('user_schema_',ref_s_user_schema_code,'_group_',internal_code) as group_table_name,
concat('user_schema_',ref_s_user_schema_code,'_entry_',internal_code) as entry_table_name
from s_user_schema_group
where multiple=1 {$schema_cond}
";
;
$lobj_group_table_name = $aobj_context->mobj_db->GetAll($group_table_name);
foreach($lobj_group_table_name as $key1=>$table_name)
{
$somecontent='';
$group_default_rows=$table_name[group_default_rows] ;
$grid_height=$group_default_rows*22;
$width=($table_name[parent_group_code]>0)?760:809;
//$hieght=($table_name[parent_group_code]>0)?102:$grid_height;
$hieght=($table_name[parent_group_code]>0)?$grid_height:$grid_height;
$group_code=$table_name[group_code] ;
$group_name=$table_name[name] ;
$group_order_by=empty($table_name[group_order_by])?"id":$table_name[group_order_by];
$sortorder=empty($table_name[group_order_by])?"desc":"asc";
$entry_table_name=$table_name[entry_table_name] ;
$group_table_name_id=$table_name[group_table_name];
$grid_col_name=$table_name[col_name];
$grid_col_model=$table_name[col_model];
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$filename = $_SERVER["DOCUMENT_ROOT"]."//".$main_src."//grid_display_files//".$group_table_name_id.".js";
if($table_name[is_grid_edit]==0 or $table_name[is_grid_edit]=='0')
{
$str_desc = "desc $group_table_name_id";
$obj_desc=$aobj_context->mobj_db->GetAll($str_desc);
$id='';
foreach ($obj_desc as $key=>$value)
{
if($value['Field']!='internal_code' && $value['Field']!='ref_s_user_schema_code' &&
$value['Field']!='ref_s_user_schema_group_code' && $value['Field']!='ref_s_ref_data_code' &&
$value['Field']!='created_by' && $value['Field']!='created_date' &&
$value['Field']!='modified_by' && $value['Field']!='modified_date' )
{
$ele_id=explode('ele_',$value['Field']);
$filed_id=$value['Field'];
$id.=$ele_id[1].",";
}
$i++;
}
$id= substr($id,0,strlen($id) - 1);
$filed_id= substr($filed_id,0,strlen($filed_id) - 1);
$get_name="select concat('u_',ref_s_user_schema_code,'_g_',ref_s_user_schema_group_code,'_ele_',su.internal_code) as field_name,
su.internal_code,name,value as Type,is_read_only,default_value,optional,su.ref_module_code,
list_of_values,linked_field,source_field,suffix,width*9 as width,
ifnull(su.grid_width,85) as grid_width from
s_user_schema_elements su left join
s_ref_type s on s.internal_code=su.data_type
where su.internal_code in (".$id.")
and ifnull(su.is_defined,1)=1
and ifnull(su.is_visible,1)=1
and include_in_grid=1 order by su.sequence,su.internal_code";
$lobj_get_display_cols = $aobj_context->mobj_db->GetAll($get_name);
$m=1;
$details_arr='';
$field_name='';
$grid_header='';
$grid_header_val='';
foreach($lobj_get_display_cols as $key=>$value11)
{
$grid_width=$value11[grid_width];
if($m!=count($lobj_get_display_cols)) {
$grid_header.="'".$lobj_get_display_cols[$key]['name']."',";
$grid_header_val.="{name:'".$lobj_get_display_cols[$key]['field_name']."',index:'".$lobj_get_display_cols[$key][field_name]."' , width:{$grid_width}} ,";
$field_name.=$lobj_get_display_cols[$key]['field_name'].",";
}
else {
$grid_header.="'".$lobj_get_display_cols[$key]['name']."'";
$grid_header_val.="{name:'".$lobj_get_display_cols[$key]['field_name']."',index:'".$lobj_get_display_cols[$key][field_name]."' , width:{$grid_width}}";
$field_name.=$lobj_get_display_cols[$key]['field_name'];
}
$m++;
}
$somecontent = "var group_div_{$group_code} =jQuery('#table_group_grid_{$group_code}').jqGrid(
{
url:\$host_url+\"viewUserSchemaModuleGroupDetails.demo&table_name={$group_table_name_id}&login_cnt=\"+document.getElementById('login_counter').value+\"&field_name={$field_name}&s_ref_data_code=\"+document.getElementById('g_group_s_ref_data_code').value,
datatype: 'json',
colNames:[{$grid_header}],
colModel:[{$grid_header_val}],
rowNum:30,
rowList:[5,10,30,50,75,100,200,500,1000],
imgpath:\$img_path,
pager: jQuery('#sub_grid_group_div_{$group_code}'),
sortname: '{$group_order_by}',
height:'{$hieght}',
viewrecords: true,
sortorder: '{$sortorder}',
multiselect: false,
width:'{$width}',
cellEdit: true,
forceFit : true,
cellsubmit: 'clientArray',
caption:'{$group_name} Details',
onSelectRow:function(id)
{
},
ondblClickRow:function(id)
{
EditMultiGroupElement('table_group_grid_{$group_code}','{$group_table_name_id}');
},
editurl:\$host_url+'deleteUserSchemaModuleGroupDetails.demo&delete_table={$group_name}&table_name={$group_table_name_id}&s_ref_data_code='+\$g_group_s_ref_data_code
}
).navGrid('#sub_grid_group_div_{$group_code}',{edit:false,add:false,del:true,search:true},{},{},{},{multipleSearch:true}).
navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Toggle\",
buttonicon :'ui-icon-pin-s', onClickButton:function(){ group_div_{$group_code}[0].toggleToolbar() } })
.navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Edit\",
onClickButton:function()
{
EditMultiGroupElement('table_group_grid_{$group_code}','{$group_table_name_id}');
}
}).
navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Del All\",
onClickButton:function()
{
ClearEntryTableNameForLoginCnt('{$entry_table_name}','{$group_code}','{$group_table_name_id}');
}
});
\n
group_div_{$group_code}.filterToolbar();
\n
group_div_{$group_code}[0].toggleToolbar();
" ;
if($table_name[parent_group_code]>0)
$somecontent.=";";
}
else
{
$somecontent = " var group_div_{$group_code} = jQuery('#table_group_grid_{$group_code}').jqGrid(
{
url:\$host_url+\"viewUserSchemaModuleGridGroupDetails.demo&table_name={$group_table_name_id}&login_cnt=\"+document.getElementById('login_counter').value+\"&field_name={$field_name}&s_ref_data_code=\"+document.getElementById('g_group_s_ref_data_code').value,
datatype: 'json',
colNames:{$grid_col_name},
colModel:{$grid_col_model},
rowNum:30,
rowList:[5,10,30,50,75,100,200,500,1000],
imgpath:\$img_path,
pager: jQuery('#sub_grid_group_div_{$group_code}'),
sortname: '{$group_order_by}',
height:'{$hieght}',
viewrecords: true,
sortorder: '{$sortorder}',
multiselect: false,
cellEdit: true,
forceFit : true,
cellEdit: true,
cellsubmit: 'clientArray',
width:'{$width}',
caption:'{$group_name} Details',
afterEditCell: function (id,name,val,iRow,iCol)
{
preCustomGridafterEditCell('table_group_grid_{$group_code}',id,name,val,iRow,iCol);
},
afterSaveCell : function(rowid,name,val,iRow,iCol) {
UpdateMultiGroupTableWithGridEdit('table_group_grid_{$group_code}',rowid,name,val,'{$entry_table_name}');
},
editurl:\$host_url+'deleteUserSchemaModuleGroupDetails.demo&delete_table={$group_name}&table_name={$group_table_name_id}&s_ref_data_code='+\$g_group_s_ref_data_code
}
).navGrid('#sub_grid_group_div_{$group_code}',{edit:false,add:false,del:false,search:false},{},{},{},{multipleSearch:true}).
navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Toggle\",
buttonicon :'ui-icon-pin-s', onClickButton:function(){ group_div_{$group_code}[0].toggleToolbar() } })
.navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Edit\",
onClickButton:function()
{
EditMultiGroupElement('table_group_grid_{$group_code}','{$group_table_name_id}');
}
}).
navButtonAdd('#sub_grid_group_div_{$group_code}',{caption:\"Del All\",
onClickButton:function()
{
ClearEntryTableNameForLoginCnt('{$entry_table_name}','{$group_code}','{$group_table_name_id}');
}
});
\n
group_div_{$group_code}.filterToolbar(); \n
group_div_{$group_code}[0].toggleToolbar();
";
if($table_name[parent_group_code]>0)
$somecontent.=";";
}
// Let's make sure the file exists and is writable first.
unlink($filename);
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
//chmod($filename,"777");
//echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
}
if(($schema_id==0 or $schema_id=='0'))
{
$data="Grid Group Files Generated Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
return;
}
}
?>
|