CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
webchart0.php418 linesDownload Raw Back to public
1<?php2ini_set("display_errors","1");3ini_set("display_startup_errors","1");4include("include/dbcommon.php");5header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");6 7include("include/reportfunctions.php");8 9 10	if( !Security::getUserName() )11	{12		$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];13		header("Location: ".GetTableLink("login", "", "message=expired"));14		return;15	}16 17Reload_Chart(postvalue("cname"));18include('include/xtempl.php');19$xt = new Xtempl();20 21$arr_tables_db = DBGetTablesListByGroup("db");22$arr_tables_project = DBGetTablesListByGroup("project");23$arr_tables_custom = DBGetTablesListByGroup("custom");24 25$root=&$_SESSION["webcharts"];26$_SESSION["webchart".GoodFieldName(@$root["settings"]["name"])."_search"]="";27 28$h_includes = "";29$b_includes = "";30 31$h_includes .= '32	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/jquery-ui.css").'" type="text/css">33	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/dstyle.css").'" type="text/css">34	<link rel="stylesheet" href="'.GetRootPathForResources("include/fancybox/jquery.fancybox.css").'" type="text/css" media="screen">35	36	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.min.js").'"></script>37	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.dimensions.pack.js").'"></script>38	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.easing.js").'"></script>39    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.fancybox.pack.js").'"></script>40    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery-ui.js").'"></script>41	<script type="text/javascript" src="'.GetRootPathForResources("include/js/json.js").'"></script>42'."\r\n";43 44$xt->assign("h_includes", $h_includes);45$xt->assign("wr_pagestylepath", $wr_pagestylepath);46$b_includes .= '47<script type="text/javascript">'."\r\n";48 49if (is_wr_db() && pre8count($arr_tables_db)) {50	$b_includes .= '51	var NEXT_PAGE_URL = "'.GetTableLink("webchart1").'",52		PREV_PAGE_URL = "'.GetTableLink("webreport").'";53	'."\r\n";54} else {55	$b_includes .= '56	var NEXT_PAGE_URL = "'.GetTableLink("webchart3").'",57		PREV_PAGE_URL = "'.GetTableLink("webreport").'";58	'."\r\n";59}60 61$b_includes .= '62var timeout	= 200,63	closetimer	= 0;64 65$(document).ready(function(){';66if($wr_is_standalone)67	$b_includes .= '$("#radio_project").hide();';68$b_includes .= '69	$("a#sql_query").fancybox({70		fitToView: false,71				autoSize: false,72				width : 800,73				height : 550,74				overlayShow: true75	});76	';77$b_includes .= alertDialog();78	79	$b_includes.='$("#radio_db,#radio_project,#radio_custom").click(function(){80		$("#tables").empty();81		$("#li_db").removeClass("selected").removeClass("ui-state-selected").removeClass("ui-state-active");82		$("#li_project").removeClass("selected").removeClass("ui-state-selected").removeClass("ui-state-active");83		$("#li_custom").removeClass("selected").removeClass("ui-state-selected").removeClass("ui-state-active");84		$("#li_db").css("background","");85		$("#li_project").css("background","");86		$("#li_custom").css("background","");87		if($(this).attr("id")=="radio_db")88		{89			$("#add_new_query").hide();90			$("#li_db").addClass("selected").addClass("ui-state-selected").addClass("ui-state-active");;91			li_selected="db";92			$("#tl").html("'."Select table which you will use to create the chart:".'");93			NEXT_PAGE_URL = "'.GetTableLink("webchart1").'";94			PREV_PAGE_URL = "'.GetTableLink("webreport").'";';95	$b_includes .= '96			$("td[id=row1], td[id=row2]").show();'."\r\n";			97	foreach ($arr_tables_db as $tbl) 98	{99		$selected="";100		if ( !empty( $root['tables'] ) )101			if ( in_array( $tbl,$root['tables'] ) )102				$selected = "selected";103			$b_includes .= "$('<option ".$selected."></option>').attr('value', '".jsreplace($tbl)."').html('".jsreplace($tbl)."').appendTo($('#tables'));"."\r\n";104	}		105	$b_includes .= '106		}107		else if($(this).attr("id")=="radio_project")108		{109			$("#add_new_query").hide();110			$("#li_project").addClass("selected").addClass("ui-state-selected").addClass("ui-state-active");;111			li_selected="project";112			$("#tl").html("'."Select table which you will use to create the chart:".'");113			NEXT_PAGE_URL = "'.GetTableLink("webchart3").'";114			PREV_PAGE_URL = "'.GetTableLink("webreport").'";';115	$b_includes .= '116			$("td[id=row1], td[id=row2]").hide();'."\r\n";117	foreach ($arr_tables_project as $tbl) 118	{119		$selected="";120		if ( !empty( $root['tables'] ) )121			if ( in_array( $tbl, $root['tables'] ) )122				$selected = "selected";123		$b_includes .= "$('<option ".$selected."></option>').attr('value', '".jsreplace($tbl)."').html('".jsreplace(getCaptionTable($tbl)). (getCaptionTable($tbl)!=$tbl ? '&nbsp;('.jsreplace($tbl).')' : '' )."').appendTo($('#tables'));"."\r\n";124	}		125		126	$b_includes .= '127		}128		else129		{';130		131	132		if(isWRAdmin() && ($_SESSION['webcharts']['tmp_active']=="x" || $root['settings']['title']==""))133			$b_includes .= '$("#add_new_query").show();';134		else135			$b_includes .= '$("#add_new_query").hide();';136	$b_includes .= '137			li_selected="custom";138			$("#li_custom").addClass("selected").addClass("ui-state-selected").addClass("ui-state-active");;139			$("#tl").html("'."Select SQL query which you will use to create the chart:".'");140			NEXT_PAGE_URL = "'.GetTableLink("webchart3").'";141			PREV_PAGE_URL = "'.GetTableLink("webreport").'";';142	$b_includes .= '143			$("td[id=row1], td[id=row2]").hide();'."\r\n";144	foreach ($arr_tables_custom as $tbl) 145	{146		$selected="";147		if ( !empty( $root['tables'] ) )148			if ( in_array( $tbl["sqlname"], $root['tables'] ))149				$selected = "selected";150			if(postvalue("sqlname")==$tbl["sqlname"])151				$selected = "selected";152		$b_includes .= "$('<option ".$selected."></option>').attr('value', '".jsreplace($tbl["sqlname"])."').html('".jsreplace(getCaptionTable($tbl["sqlname"]))."').appendTo($('#tables'));"."\r\n";153	}		154		155	$b_includes .= '156	}157	$("li").css("list-style-type","none");	158	$(".selected").css("padding-bottom","0px");159	if($("#tables").get(0).selectedIndex==-1)160		$("#tables").get(0).selectedIndex=0;161	empty_table_list();162	});163	164	';165	166	$b_includes .= '167 168	li_selected="db";169	$("#tl").attr("html","Select table which you will use to create the chart:");170	$(function() {171		$("#radio_select_table").tabs();';172if(postvalue("sqlname"))173	$b_includes .= '174					li_selected_start="custom";175					$("#radio_custom").click();176					li_selected="custom";177					$("#tl").html("'."Select SQL query which you will use to create the report:".'");178					';179else180{	181	if(is_wr_db() && pre8count($arr_tables_db))182		$b_includes .= '183						li_selected_start="db";184						$("#radio_db").click();185						li_selected="db";186						$("#tl").html("'."Select table which you will use to create the chart:".'");187						';188	elseif(is_wr_project() && pre8count($arr_tables_project))189		$b_includes .= '190						li_selected_start="project";191						$("#radio_project").click();192						li_selected="project";193						$("#tl").html("'."Select table which you will use to create the chart:".'");194						';195	else196		$b_includes .= '197						li_selected_start="custom";198						$("#radio_custom").click();199						li_selected="custom";200						$("#tl").html("'."Select SQL query which you will use to create the report:".'");201						';202}203	$b_includes .= '});204	205	function empty_table_list()206	{207		if($("#tables").val()==null)208		{209			$("#nextbtn,#sqlbtn,#jumpto").css("display","none");210			$("#nextbtn,#sqlbtn,#jumpto").parent("span").css("display","none");211		}212		else213		{214			$("#nextbtn,#sqlbtn,#jumpto").css("display","");215			$("#nextbtn,#sqlbtn,#jumpto").parent("span").css("display","");216 217		}218	}219	function collect_input_data() {220		var output = {};221		output.table_type=li_selected;222		output.tables = [];223		$(":selected").each(function(i){224			output.tables[i] = $(this).val();225		});226		return JSON.stringify(output);		227	}228	229	$("#sqlbtn").click(function(){230		231		var output = collect_input_data();232		233		$.ajax({234			type: "POST",235			url: "'.GetTableLink("save-state").'",236			data: {237				name: "tables",238				web: "webcharts",239				str_xml: output,240				rnd: (new Date().getTime())241			},242			success: function(msg){243				if ( msg == "OK" ) {244					$("#sql_query").click();245				} else {246					$("#alert").html("<p>"+msg+"</p>").dialog("open");247				}248			}249		});250	});251	252	$("#row0")253		.css("cursor", "default")254		.css("font-weight", "bold");255 256	$("td[id^=row]").mouseover(function(){257		for(var i=0; i<=9; i++) {258			if(i == this.id.replace("row", "")) {259				$("td[id=row" + i + "]").css("background-color","#92BEEB");260			}261			else {262				$("td[id=row" + i + "]").css("background-color","#F4F7FB");263			}264		}265	});266	267'."\r\n";268 269$b_includes .= JumpTo();270 271if (pre8count(GetUserGroups()) < 2 || $root['settings']['status']!="public" )272{273	$b_includes .= '$("td[id=row7]").hide();'."\r\n";274}275if (is_wr_project() || is_wr_custom()) {276	$b_includes .= '$("td[id=row1], td[id=row2]").hide();'."\r\n";277}278if($wr_is_standalone)279	$b_includes .= '$("td[id=row9]").hide();'."\n";280 281//if ($root['settings']['title'] == "") {282//	$b_includes .= '283//		for (var i=2; i<=7; i++){284//			$("td[id=row" + i + "]").hide();285//		};286//	'."\r\n";287//}288 289$rLinks = "var rlinks = {};\r\n";290for($ri = 0; $ri < 10; $ri++)291	$rLinks.= "rlinks['".$ri."'] = '".GetTableLink("webchart".$ri)."';\r\n";292 293 294$b_includes .= '295	$("a#a_addsql").fancybox({296		fitToView: false,297				autoSize: false,298				width : 850,299				height : 550,300				overlayShow: true301	});302	303	$("#addsql").click(function(){304		$("#a_addsql").click();305	});306	307	$("#nextbtn, #backbtn, td[id^=row], #savebtn").click(function(){308		var URL = "'.GetTableLink("webreport").'";309		'.$rLinks.'310		if( this.id == "nextbtn" )311			URL = NEXT_PAGE_URL;312		if( this.id == "backbtn" )313			URL = PREV_PAGE_URL;314		if( this.id.substr(0,3)=="row" && this.id != "row0" )315			URL = rlinks[this.id.replace(\'row\',\'\')];316		if( this.id == "row8" )317			URL = "'.GetTableLink("webreport").'";318		if( this.id == "row9" )319			URL = "'.GetTableLink("menu").'";320 321		if (this.id == "backbtn" || this.id == "row8" || this.id == "row9") {322			window.location = URL;323			return;324		}325		326		var output = collect_input_data();327		thisid=this.id;328		if(this.id !="row0") {329			$.ajax({330				type: "POST",331				url: "'.GetTableLink("save-state").'",332				data: {333					name: "tables",334					web: "webcharts",335					str_xml: output,336					rnd: (new Date().getTime())337				},338				success: function(msg){339					if ( msg == "OK" ) {340						window.location = URL;341					} else {342						$("#alert").html("<p>"+msg+"</p>").dialog("open");343						if( thisid == "row8" || thisid == "row9" )344							window.location=URL;345					}346				}347			});348		}349	});350	351	if ($("option:selected").length == 0) {352		$("select").get(0).selectedIndex = 0;353	}354	empty_table_list();';355$tables = "";356$arr_tables = array();357 358if (is_wr_db() && pre8count($arr_tables_db)) 359{360	$arr_tables = $arr_tables_db;361	$isCustom=false;362} 363elseif(pre8count($arr_tables_project) && is_wr_project())364{365	$arr_tables = $arr_tables_project;366	$isCustom=false;367}368else369{370	$arr_tables = $arr_tables_custom;371	$isCustom=true;372}373 374$b_includes .= '});375</script>'."\r\n";376 377 378$xt->assign("b_includes", $b_includes);	379	380foreach ($arr_tables as $tbl_name) 381{382	if($isCustom)383	{384		$tbl=$tbl_name["sqlname"];385		$isStorProc=$tbl_name["isStorProc"];386	}387	else388	{389		$tbl=$tbl_name;390		$isStorProc=false;391	}	392	$selected = "";393	if ( !empty( $root['tables'] ) ){394		if ( in_array( $tbl, $root['tables'] ) )395			$selected = "selected";396	}397	$tables .= '<option ' . $selected . ' value="' . runner_htmlspecialchars($tbl) . '">'.(!is_wr_project() ? $tbl : getCaptionTable($tbl)) . (is_wr_project() ? (getCaptionTable($tbl)!=$tbl ? "&nbsp;(".$tbl.")" : "" ) : "").'</option>'."\r\n";398}399 400if (@$root['settings']['title'] != "") {401	$xt->assign("chart_title",", "."Title".": ".@$root['settings']['title']);402} else {403	$xt->assign("chart_title","");404}405$xt->assign("tables", $tables);406 407if(!pre8count($arr_tables_db) && !pre8count($arr_tables_project) || !pre8count($arr_tables_custom) && !pre8count($arr_tables_project) || !pre8count($arr_tables_custom) && !pre8count($arr_tables_db))408	$xt->assign("radio_style","style='display:none';");409	410if(pre8count($arr_tables_db))411	$xt->assign("view_radio_db",true);412if(pre8count($arr_tables_project))413	$xt->assign("view_radio_project",true);414 415$templatefile = GetTemplateName("", "webchart0");416$xt->display($templatefile);417 418?>