0xV3NOMx
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.119.135.231


Current Path : /var/www/html/cnv/dud/src/system/
Upload File :
Current File : /var/www/html/cnv/dud/src/system/savegeneralmaster.php

<?php
function insertUserSchemaMaster($aobj_context)
{
 
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
	$internal_code=$aobj_context->mobj_data["internal_code"];
	$active=$aobj_context->mobj_data["active"];
	$is_analytical=$aobj_context->mobj_data["is_analytical"];
	$system_module_table_name=$aobj_context->mobj_data["system_module_table_name"];
	$create_table=$aobj_context->mobj_data["create_table"];
	$module_name=(trim($aobj_context->mobj_data["module_name"]));
	$user_schema_display_module_name=(trim($aobj_context->mobj_data["user_schema_display_module_name"]));
	$grid_custom_links=(trim($aobj_context->mobj_data["grid_custom_links"]));
	$is_menu_only=(trim($aobj_context->mobj_data["is_menu_only"]));
	$module_function_name=(trim($aobj_context->mobj_data["module_function_name"]));
	$module_type=$aobj_context->mobj_data["module_type"];
	$main_menu=$aobj_context->mobj_data["main_menu"];
	$module_grid_type=$aobj_context->mobj_data["module_grid_type"];
	$grid_user_schema_coloum_names=$aobj_context->mobj_data["grid_user_schema_coloum_names"];
	$grid_user_schema_grid_query=$aobj_context->mobj_data["grid_user_schema_grid_query"];
	$grid_user_schema_coloum_models=$aobj_context->mobj_data["grid_user_schema_coloum_models"];
	$is_save=(trim($aobj_context->mobj_data["is_save"]));
	$is_clear=(trim($aobj_context->mobj_data["is_clear"]));
	$is_download=(trim($aobj_context->mobj_data["is_download"]));
	$is_view=(trim($aobj_context->mobj_data["is_view"]));
	$is_generate=(trim($aobj_context->mobj_data["is_generate"]));	
	$custom_links=(trim($aobj_context->mobj_data["custom_links"]));	
	$logo_path=(trim($aobj_context->mobj_data["logo_path"]));	
	$user_schema_js_path=(trim($aobj_context->mobj_data["user_schema_js_path"]));
	$user_schema_grid_default_rows=(trim($aobj_context->mobj_data["user_schema_grid_default_rows"]));
	$user_schema_grid_default_rows=empty($user_schema_grid_default_rows)?0:$user_schema_grid_default_rows;
	$display_type=$aobj_context->mobj_data["display_type"];
	$default_view=$aobj_context->mobj_data["default_view"];
	$grid_shrink_to_fit=$aobj_context->mobj_data["grid_shrink_to_fit"];
	$get_module_type="select value from s_ref_type where internal_code=$module_type";
	$lobj_module_type = $aobj_context->mobj_db->GetRow($get_module_type);
	$mod_type=$lobj_module_type[value];
	
	if($internal_code==0)
	{	
		$get_data="select count(*) as module_count from s_user_schema where module_name='".$module_name."'
		and  module_type='".$module_type."'";
		$lobj_rs = $aobj_context->mobj_db->GetRow($get_data);
		
		if($lobj_rs['module_count']==0)
		{
		    $lstr_qry = "insert into s_user_schema( 
		        module_name,
				display_module_name,
		        module_type,
				is_menu_only,
				menu_function,
				active,main_menu,display_type,
				include_save,include_clear,
				include_download,include_view,
				include_generate,grid_type,custom_links,
				s_col_names,s_col_model,s_grid_query,
				s_grid_custom_links,system_module_table_name,js_path,grid_default_rows,default_view,shrink_to_fit,logo_path,is_analytical)
		         values ( '{$module_name}','{$user_schema_display_module_name}','{$module_type}',
							'{$is_menu_only}',
							'{$module_function_name}',
							'{$active}',
							'{$main_menu}',
							'{$display_type}',
							'{$is_save}',
							'{$is_clear}',
							'{$is_download}',
							'{$is_view}',
							'{$is_generate}',
							'{$module_grid_type}',
							\"{$custom_links}\",
							\"{$grid_user_schema_coloum_names}\",
							\"{$grid_user_schema_coloum_models}\",
							\"{$grid_user_schema_grid_query}\",
							\"{$grid_custom_links}\",
							'{$system_module_table_name}',
							'{$user_schema_js_path}',
							\"{$user_schema_grid_default_rows}\",
							'{$default_view}',
							'{$grid_shrink_to_fit}',
							'{$logo_path}',
							'{$is_analytical}'
							)";  
	               //echo $lstr_qry; die();
					$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);  
 			
					$last_inserted_id  = $aobj_context->mobj_db->Insert_ID();
					 
						if($mod_type=='Reports')
						{
						$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
						$main_src=$main_src_obj[1];
						 $report_storage_path=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Report_details/report_result_".$last_inserted_id.".php";
						 $report_format_path=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/src/general_report_format.php";
						file_put_contents($report_storage_path,file_get_contents($report_format_path));  
						}																				
						
						
					if($create_table==1 && $mod_type!='Reports' && $is_menu_only=='0')
					{
					$create_table="CREATE TABLE {$system_module_table_name}
								(
								  internal_code bigint(20) unsigned NOT NULL auto_increment,
								  ref_s_user_schema_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)
								) engine INNODB ";		
											
					$lobj_rs = $aobj_context->mobj_db->Execute($create_table); 
 				
					}
				    if($lobj_rs)
				    {
				        $rdata = "Module 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 	
		{
		     $rdata = "Module Name Already Exstis!";
	        print_r($aobj_context->mobj_output->ToJSONEnvelope($rdata,0,"success"));
	        return $rdata;
	    }
	}
	else  
		{
		
		     $get_exsting_values="select * from s_user_schema where
							internal_code={$internal_code}";
			 $lobj_get_exsting_values = $aobj_context->mobj_db->GetRow($get_exsting_values);				  
			 
			 $e_system_table_name_code=$lobj_get_exsting_values["system_module_table_name"];	
			 
			 $lstr_qry = "update s_user_schema
						set module_name='{$module_name}',
						module_type='{$module_type}',
						display_module_name='{$user_schema_display_module_name}', 
						main_menu= '{$main_menu}', display_type= '{$display_type}',
						active= {$active} ,is_menu_only='{$is_menu_only}',
						menu_function= '{$module_function_name}',
						include_save= '{$is_save}',include_clear= '{$is_clear}',
						include_download='{$is_download}',include_view= '{$is_view}',
						include_generate = '{$is_generate}',
						custom_links= \"{$custom_links}\",
						system_module_table_name= '{$system_module_table_name}',
						grid_type= '{$module_grid_type}',
						s_col_names= \"{$grid_user_schema_coloum_names}\",
						s_col_model= \"{$grid_user_schema_coloum_models}\",
						s_grid_query= \"{$grid_user_schema_grid_query}\" ,
						s_grid_custom_links= \"{$grid_custom_links}\" ,
						js_path= '{$user_schema_js_path}',
						grid_default_rows = \"{$user_schema_grid_default_rows}\",
						default_view='{$default_view}',
						shrink_to_fit='{$grid_shrink_to_fit}',
						logo_path='{$logo_path}',
						is_analytical='{$is_analytical}'
						where internal_code ={$internal_code}";
		 // echo $lstr_qry;	
		 
			$lobj_rs = $aobj_context->mobj_db->Execute($lstr_qry);
			if($create_table==1 && $mod_type!='Reports' && $is_menu_only=='0')
			{
			$alter_field="alter table {$e_system_table_name_code}  RENAME  TO
							{$system_module_table_name}";	           
							
			$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"));      
		     } 
		}            
}

?>