CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
webchart4.php968 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	if( !Security::getUserName() )10	{11		$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];12		header("Location: ".GetTableLink("login", "", "message=expired"));13		return;14	}15 16$root=&$_SESSION['webcharts'];17Reload_Chart(postvalue("cname"));18if(is_wr_project())19{20	include_once("include/" . GetTableURL($root['tables'][0]) . "_settings.php");	21}22 23include('include/xtempl.php');24$xt = new Xtempl();25 26$table_name = $root['tables'][0];27 28if (@$_SESSION['webcharts']['settings']['title'] != "") {29	$title=@$_SESSION['webcharts']['settings']['title'];30	if(strlen($title)>25)31		$title=substr($title,25)."...";32	$xt->assign("chart_title",", "."Title".": ".$title);33} else {34	$xt->assign("chart_title","");35}36if (@$_SESSION['webcharts']['tables'][0] != "") {37	$stable=@$_SESSION['webcharts']['tables'][0];38	if(strlen($stable)>25)39		$stable=substr($stable,25)."...";40 41	$xt->assign("chart_table",", "."Table".": ".$stable);42} else {43	$xt->assign("chart_table","");44}45$xt->assign("b_is_chart_save",($_SESSION['webcharts']['tmp_active'] != "x"));	46$xt->assign("b_is_chart_name",($_SESSION['webcharts']['settings']['name'] != ""));47$xt->assign("chart_name",$root['settings']['name']);48 49$h_includes = "";50$b_includes = "";51 52$h_includes .= '53	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/stylesheet.css").'" type="text/css">54	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/jquery-ui.css").'" type="text/css">55	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/dstyle.css").'" type="text/css">56	<link rel="stylesheet" href="'.GetRootPathForResources("include/fancybox/jquery.fancybox.css").'" type="text/css" media="screen">57	58	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.min.js").'"></script>59	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.dimensions.pack.js").'"></script>60	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.easing.js").'"></script>61    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.fancybox.pack.js").'"></script>62    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery-ui.js").'"></script>63	<script type="text/javascript" src="'.GetRootPathForResources("include/js/json.js").'"></script>64'."\r\n";65 66$xt->assign("h_includes", $h_includes);67 68$b_includes .= '<script type="text/javascript">'."\r\n";69$b_includes .= '70 71arr_color = new Array();72 73arr_color["0"]="#FFFFFF";74 75arr_color["1"]="#FF0000";76arr_color["2"]="#008000";77arr_color["3"]="#0000FF";78 79arr_color["4"]="#DC143C";80arr_color["5"]="#2E8B57";81arr_color["6"]="#6A5ACD";82 83arr_color["7"]="#FF7F50";84arr_color["8"]="#7FFF00";85arr_color["9"]="#5F9EA0";86 87arr_color["10"]="#FF8C00";88arr_color["11"]="#8FBC8B";89arr_color["12"]="#00008B";90 91arr_color["13"]="#FF1493";92arr_color["14"]="#556B2F";93arr_color["15"]="#00BFFF";94 95arr_color["16"]="#FF69B4";96arr_color["17"]="#008B8B";97arr_color["18"]="#ADD8E6";98 99arr_color["19"]="#F08080";100arr_color["20"]="#32CD32";101arr_color["21"]="#4169E1";102 103arr_color["22"]="#A52A2A";104arr_color["23"]="#006400";105arr_color["24"]="#6495ED";106 107var timeout	= 200,108	closetimer	= 0,109	fld_labels = new Array();110'."\r\n";111 112$dataSeries = "";113 114/*115$arr_group_by = array();116if ( !empty( $root['group_by_condition'][0] ) )117{118	for ($i=0; $i < count($root['group_by_condition'])-1; $i++) 119	{120		$arr = $root['group_by_condition'][$i];121		if ( rawurldecode($arr['group_by_value']) != "-1" &&122			rawurldecode($arr['group_by_value']) != "GROUP BY" ) {123			$arr_group_by[rawurldecode($arr['field_opt'])]["agr_func"] = rawurldecode($arr['group_by_value']);124			$arr_group_by[rawurldecode($arr['field_opt'])]["label"] = rawurldecode($arr['group_by_value'])."(".rawurldecode($arr['field_opt']).")";125		}126	}127}128*/129$arr_data_series=array();130$arr_label_series=array();131get_chart_series_fields($arr_data_series,$arr_label_series);132foreach ( $arr_data_series as $arr ) 133{134		$dataSeries .= '<option value="'.runner_htmlspecialchars($arr["field"]).'">'.runner_htmlspecialchars($arr["field"]).'</option>';135		$b_includes .= 'fld_labels[\''.jsreplace($arr["field"]).'\'] = \'' . jsreplace($arr["label"]) . '\';'."\r\n";136}137$xt->assign("dataSeries", $dataSeries);138 139$strLabel = "";140foreach ( $arr_label_series as $arr ) 141{142		$strLabel .= '<option value="'.runner_htmlspecialchars($arr["field"]).'">'.runner_htmlspecialchars($arr["field"]).'</option>';143}144/*145foreach ($arr_label_series as $arr) {146	$strLabel .= '<option value="'.$arr["table"].'.'.$arr["name"].'">'.$arr["table"].'.'.$arr["name"].'</option>';147}148*/149$xt->assign("label", $strLabel);150 151$b_includes .= '152var timeout	= 200,153closetimer	= 0,154closetimerpicker = 0,155timeoutpicker = 300;156$(document).ready(function(){157 158		$("a#sql_query").fancybox({159		fitToView: false,160				autoSize: false,161				width : 800,162				height : 550,163				overlayShow: true164	});165	166		$("a#preview").fancybox({167			fitToView: false,168				autoSize: false,169				width : 820,170				height : 660,171				overlayShow: true172		});173	';174	$b_includes .= alertDialog();175	$b_includes .= '176	177	function add_dataseries(num)178	{179		if($("tr[id^=ds]").length!=num)180			return;181		dataseries=$("tr[id=clone]").clone();182		dataseries.insertBefore("#ds");183		dataseries.attr("id","ds"+num);184		dataseries.find("td:eq(1)").html("Data Series "+num);185		';186if ($_SESSION['webcharts']['chart_type']['type']!="ohlc" && $_SESSION['webcharts']['chart_type']['type']!="candlestick")187{188	$b_includes .= '	189			dataseries.find("td:eq(3)").attr("id","label_title_"+num);190			dataseries.find("td:eq(4)").attr("id","label_value_"+num);		191			dataseries.find("input:eq(0)").attr("id","series_label_"+num);					192			dataseries.find("select:eq(0)").attr("id","field"+num);193			dataseries.find("select:eq(0)").attr("name","field"+num);194			$("select[id=field"+num+"]").bind("change", function(){195					add_field_change(this);196			});';197 198	if ($_SESSION['webcharts']['chart_type']['type']=="gauge")		199	{		200	$b_includes .= '	201			gaugeseries=$("tr[id=clone_range]").clone();202			gaugeseries.insertBefore("#ds");203			gaugeseries.attr("id","tr_range"+num);204			gaugeseries.find("input:eq(0)").attr("name","gaugeMinValue"+num);205			gaugeseries.find("input:eq(1)").attr("name","gaugeMaxValue"+num);206			gaugeseries.show();207	';208	}209	else210	{211	$b_includes .= '212			dataseries.find("td:eq(5)").attr("id","picker_div"+num);213			dataseries.find("td:eq(6)").attr("id","picker_selector"+num);214			dataseries.find("div:eq(0)").attr("id","picker"+num);215			dataseries.find("#picker"+num).css("background-color", arr_color[num]);216			dataseries.find(".selector,.ColorPickerDivSample").click(function(){217				click_color_event(this);218			});219			dataseries.find("td[id^=picker]").hide();220			dataseries.find("td[id^=label_title]").hide();221			dataseries.find("td[id^=label_value]").hide();222			dataseries.find("td[id^=label_title]").prev("td").attr("colSpan",5);';223	}224			225	if ($_SESSION['webcharts']['chart_type']['type']=="bubble")		226	{		227	$b_includes .= '	228			sizeseries=$("tr[id=clone_size]").clone();229			sizeseries.insertAfter("#ds"+num);230			sizeseries.attr("id","");231			sizeseries.find("td:eq(1)").html("Size Series "+num);232			sizeseries.find("select:eq(0)").attr("id","size"+num);233			sizeseries.find("select:eq(0)").attr("name","size"+num);234			sizeseries.show();235			';236	}237}238else239{240	$b_includes .= '241			dataseries1=$("tr[id=clone1]").clone();242			dataseries1.insertBefore("#ds");243			244			dataseries2=$("tr[id=clone2]").clone();245			dataseries2.insertBefore("#ds");246			247			dataseries3=$("tr[id=clone3]").clone();248			dataseries3.insertBefore("#ds");249			250			dataseries1.attr("id","");251			dataseries2.attr("id","");252			dataseries3.attr("id","");253			dataseries1.find("select:eq(0)").attr("id","field_open"+num);254			dataseries1.find("select:eq(0)").attr("name","field_open"+num);255			dataseries1.find("select:eq(1)").attr("id","field_close"+num);256			dataseries1.find("select:eq(1)").attr("name","field_close"+num);257			dataseries2.find("select:eq(0)").attr("id","field_high"+num);258			dataseries2.find("select:eq(0)").attr("name","field_high"+num);259			dataseries2.find("select:eq(1)").attr("id","field_low"+num);260			dataseries2.find("select:eq(1)").attr("name","field_low"+num);261			262			263			$("select[id^=field]").bind("change", function(){264				if($(this).attr("id").length>5)265					add_field_change(this);266			});267			268			269			dataseries3.find("td:eq(1)").attr("id","label_title_"+num);270			dataseries3.find("td:eq(2)").attr("id","label_value_"+num);	271			272			dataseries3.find("td:eq(4)").attr("id","picker1_div"+num);273			dataseries3.find("td:eq(5)").attr("id","picker1_selector"+num);274			dataseries3.find("td:eq(6)").attr("id","picker2_div"+num);275			dataseries3.find("td:eq(7)").attr("id","picker2_selector"+num);276			277			dataseries3.find("div:eq(0)").attr("id","picker1_"+num);278			dataseries3.find("div:eq(1)").attr("id","picker2_"+num);279			280			dataseries3.find("#picker1_"+num).css("background-color", arr_color[num]);281			dataseries3.find("#picker2_"+num).css("background-color", arr_color[num]);282			283			dataseries3.find("input:eq(0)").attr("id","series_label_"+num);		284			dataseries3.find(".selector,.ColorPickerDivSample").click(function(){285				click_color_event(this);286			});287			dataseries3.find("td[id^=picker]").hide();288			dataseries3.find("td[id^=label_title]").hide();289			dataseries3.find("td[id^=label_value]").hide();290			dataseries1.show();291			dataseries2.show();292			dataseries3.show();293			';294}295 296$b_includes .= '	297		dataseries.show();298		299		separat=$("tr[id=clone_separator]").clone();300		separat.attr("id","tr_separator"+num);301		separat.insertBefore("#ds");302		separat.show();303	}304 305	function collect_input_data() {306		var output = {};307		output.parameters = [];308		output.fields = [];309		count=0;310		$("tr[id^=ds]").each(function(i){311			var func, reg_match,parts,sfield,stable,ssize,label, color, field_open, field_close, field_high, field_low, color2, color1;312			reg_match = $("select[id^=field]",this).val();313			if (reg_match != null)314				reg_match = reg_match.match(/(.*)\((.*)\)/i);315			if (reg_match != null) 316			{317				parts =	reg_match[2].split(".");318				sfield=parts[parts.length-1];319				stable = reg_match[2];320				stable = stable.substring(0,stable.length-sfield.length-1);321				label=$("input[id=series_label_"+(i+1)+"]").val();322				color=rgbToHex($("#picker"+(i+1)).css("background-color"));323				func = reg_match[1];324			} 325			else 326			{327				parts = $("select[id^=field]",this).val();328				if(parts!=null)329				{330					parts = parts.split(".");331					sfield=parts[parts.length-1];332					stable = $("select[id^=field]",this).val();333					stable = stable.substring(0,stable.length-sfield.length-1);334					label=$("input[id^=series_label_"+(i+1)+"]",this).val();335					color=rgbToHex($("#picker"+(i+1)).css("background-color"));336				}337				func = "";338			}339 340			trn=$(this).next("tr");';341 342if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")343$b_includes .= '344			//finance345			var fin_fields = new Array();346			fin_tr=trn;347			fin_fields[0]="field_open";348			fin_fields[1]="field_close";349			fin_fields[2]="field_high";350			fin_fields[3]="field_low";351			fin_fields[4]="label";352			353			for(j=0;j<5;j++)354			{	355				if(j<4)356				{357					reg_match = $(fin_tr).find("select[id="+fin_fields[j]+""+(i+1)+"]",this).val();358					if (reg_match != null)359						reg_match = reg_match.match(/(.*)\((.*)\)/i);360					if (reg_match != null) 361					{362						parts =	reg_match[2].split(".");363						sfield=parts[parts.length-1];364						stable = reg_match[2];365						stable = stable.substring(0,stable.length-sfield.length-1);366					} 367					else 368					{369						parts = $(fin_tr).find("select[id="+fin_fields[j]+""+(i+1)+"]",this).val();370						if(parts!=null)371						{372							parts = parts.split(".");373							sfield=parts[parts.length-1];374							stable = $("select[id="+fin_fields[j]+""+(i+1)+"]").val();375							stable = stable.substring(0,stable.length-sfield.length-1);376						}377					}378					eval(fin_fields[j]+"=sfield;");379					if(j==1 || j==3)380						fin_tr=$(fin_tr).next("tr");381				}382				else383				{384					label=$("input[id=series_label_"+(i+1)+"]").val();385					color1=rgbToHex($("#picker1_"+(i+1)).css("background-color"));386					color2=rgbToHex($("#picker2_"+(i+1)).css("background-color"));387					break;388				}389			}';390			391$b_includes .= '			392			393			//bubble size394			reg_match = $(trn).find("select[id^=size]",this).val();395			if (reg_match != null)396				reg_match = reg_match.match(/(.*)\((.*)\)/i);397			if (reg_match != null) 398			{399				parts =	reg_match[2].split(".");400				ssize=parts[parts.length-1];401			} 402			else 403			{404				parts = $(trn).find("select[id^=size]",this).val();405				if(parts!=null)406				{407					parts = parts.split(".");408					ssize=parts[parts.length-1];409				}410			}411			412			//gauge range413			gminvalue=$(trn).find("input[name^=gaugeMinValue]").val();414			gmaxvalue=$(trn).find("input[name^=gaugeMaxValue]").val();415			416			//gauge color 417			k=0;418			var gcolorzone = [];419			gcolorzone[0] = {420						gaugeColor : "FF0000",421						gaugeBeginColor : "",422						gaugeEndColor : ""423					};424			$("tr[name=tr_color"+(i+1)+"]").each(function(j){425				if($(this).find("tr[minus=yes]").attr("minus")=="yes")426				{427					gcolorzone[k] = {428						gaugeColor : rgbToHex($(this).find("div[name=gaugeColor"+(i+1)+"]").css("background-color")) || "",429						gaugeBeginColor : $(this).find("input[name=gaugeBeginColor"+(i+1)+"]").val() || "",430						gaugeEndColor : $(this).find("input[name=gaugeEndColor"+(i+1)+"]").val() || ""431					};432					k++;433				}434			});';435if ($_SESSION['webcharts']['chart_type']['type']!="ohlc" && $_SESSION['webcharts']['chart_type']['type']!="candlestick")436	$b_includes .= 'if(sfield!="")';437else438	$b_includes .= 'if(field_open!="" && field_close!="" && field_high!="" && field_low!="")';439$b_includes .= '440			{441				output.parameters[count] = {442					name     : sfield || "",443					size     : ssize || "",444					gaugeMinValue     : gminvalue || "",445					gaugeMaxValue     : gmaxvalue || "",446					gaugeColorZone     : gcolorzone || "",447					table    : stable || "",448					agr_func : func,449					series_color	: color || "",450					label    : label || "",451					ohlcOpen : field_open || "",452					ohlcClose : field_close || "",453					ohlcHigh : field_high || "",454					ohlcLow : field_low || "",455					ohlcColor : color1 || "",456					ohlcCandleColor : color2 || ""457					458				};459				// needed for compliance with previous version460				output.fields[count] = {461					name   : sfield || "",462					label  : label || "",463					search : ""464				};465				count++;466			}467		});468		return JSON.stringify(output);			469	}470 471	$("td[id^=label_title]").hide();472	$("td[id^=label_value]").hide();473	$("td[id^=picker]").hide();';474	if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")475		$b_includes .= '$("td[id^=label_title]").next("td").next("td").attr("colSpan",2);';476	else477		$b_includes .= '$("td[id^=label_title]").prev("td").attr("colSpan",5);';478	479	$b_includes .= '$("div[id^=picker]").css("background-color", "#FF0000");480	481	$("select[id^=field]").bind("change", function(){482		if($(this).attr("id").length>5)483			add_field_change(this);484	});485	486	function add_field_change(th)487	{488		var value = $(th).val(),489			tr = $(th).parents("tr:first");';490if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")491{492	$b_includes .= '493		if($(tr).prev("tr:[id^=ds]").length==0)494			tr=$(tr).prev("tr").prev("tr:[id^=ds]")495		else496			tr=$(tr).prev("tr:[id^=ds]");497		498		tr_input1=$(tr).next("tr");499		tr_input2=$(tr).next("tr").next("tr");500 501		val1=$(tr_input1).find("select:eq(0)").val();502		val2=$(tr_input1).find("select:eq(1)").val();503		val3=$(tr_input2).find("select:eq(0)").val();504		val4=$(tr_input2).find("select:eq(1)").val();505		506		if(val1=="" || val2=="" || val3=="" || val4=="")507			value="";508		id=$(tr).attr("id").replace("ds","");509		tr=$(tr).next("tr").next("tr").next("tr");510	';			511}512		513$b_includes .= '514		if ( value != "" && value != null)515		{516			$(tr).find("td[id^=label_title]").show();517			$(tr).find("td[id^=label_value]").show();518			$(tr).find("td[id^=picker_div]").show();';519if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")			520	$b_includes .= '$(tr).find("td[id^=label_title]").next("td").next("td").attr("colSpan",2);';521else	522	$b_includes .= '$(tr).find("td[id^=label_title]").prev("td").attr("colSpan",1);';523	524	$b_includes .= '$(tr).find("td[id^=picker_selector]").show();525			$(tr).find("input[id^=series_label]").val(fld_labels[value]);526			if($(th).attr("id")!="field")527			{528				num=$(th).attr("id").replace("field","");';529 530if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")531{532	$b_includes .= '533				$(tr).find("input[id^=series_label]").val("Data Series "+id);534				$(tr).find("td[id^=picker1_div]").show();535				$(tr).find("td[id^=picker1_selector]").show();';536	if($_SESSION['webcharts']['chart_type']['type']=="candlestick")537	{538		$b_includes .= '539				$(tr).find("td[id^=picker2_div]").show();540				$(tr).find("td[id^=picker2_selector]").show();541		';542	}	543}544$b_includes .= '545				num=num.replace("_open","");546				num=num.replace("_close","");547				num=num.replace("_high","");548				num=num.replace("_low","");549'."\r\n";				550				551$b_includes .= 'add_dataseries(parseInt(num)+1);552			}553			'."\r\n";554			555 556if ($_SESSION['webcharts']['chart_type']['type']=="gauge")		557{			558$b_includes .= '559			ds_id=$(tr).attr("id");560			ds_id=ds_id.replace("ds","");561			if($("tr[name=tr_color"+ds_id+"]").attr("name")==undefined)562			{563				add_new_color(ds_id);564			}565			'."\r\n";566}			567			568			569$b_includes .= '570		} 571		else 572		{';573if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")574{575	$b_includes .= '576			$(tr).find("td[id^=picker1_div]").hide();577			$(tr).find("td[id^=picker1_selector]").hide();578			$(tr).find("td[id^=picker2_div]").hide();579			$(tr).find("td[id^=picker2_selector]").hide();580	';581}		582$b_includes .= '583			$(tr).find("td[id^=picker_div]").hide();584			$(tr).find("td[id^=picker_selector]").hide();585			$(tr).find("td[id^=label_title]").hide();586			$(tr).find("td[id^=label_value]").hide();';587if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")			588	$b_includes .= '$(tr).find("td[id^=label_title]").next("td").next("td").attr("colSpan",4);';589else	590	$b_includes .= '$(tr).find("td[id^=label_title]").prev("td").attr("colSpan",5);';591	592	$b_includes .= '$(tr).find("input[id^=series_label]").val("");'."\r\n";593			594if ($_SESSION['webcharts']['chart_type']['type']=="bubble")		595{596	$b_includes .= 'trn = $(tr).next("tr");'."\r\n";597	$b_includes .= '$(trn).find("select[id ^=size]")[0].selectedIndex = 0;'."\r\n";598}599if ($_SESSION['webcharts']['chart_type']['type']=="gauge")		600{601	//$b_includes .= '$("tr_").find("select[id ^=size]")[0].selectedIndex = 0;'."\r\n";602	$b_includes .= 'ds_id=$(tr).attr("id");'."\r\n";603	$b_includes .= 'ds_id=ds_id.replace("ds","");'."\r\n";604	$b_includes .= '$("tr[name=tr_color"+ds_id+"]").remove();'."\r\n";605	$b_includes .= '$("input[name=gaugeMinValue"+ds_id+"]").val("");'."\r\n";606	$b_includes .= '$("input[name=gaugeMaxValue"+ds_id+"]").val("");'."\r\n";607}608 609 610$b_includes .= '611		}612	}613	614	function add_new_color(ds_id)615	{616		tr_color=$("tr[name=tr_color]").clone();617		tr_color.insertBefore("#tr_separator"+ds_id);618		tr_color.attr("name","tr_color"+ds_id);619		tr_color.find("input[name=gaugeBeginColor]").attr("name","gaugeBeginColor"+ds_id);620		tr_color.find("input[name=gaugeEndColor]").attr("name","gaugeEndColor"+ds_id);621		tr_color.find("input[name=minus]").attr("name","minus"+ds_id);622		tr_color.find("div[name=gaugeColor]").attr("name","gaugeColor"+ds_id);623		div_len=$("div[name=gaugeColor"+ds_id+"]").length;624		div_len=div_len-parseInt(div_len/24);625		tr_color.find("div[name=gaugeColor"+ds_id+"]").css("background-color", arr_color[div_len]);626		tr_color.find(".selector,.ColorPickerDivSample").click(function(){627			click_color_event(this);628		});629		tr_color.find("input[name=gaugeEndColor"+ds_id+"]").keydown(function(){630			endcolor_event(this);631		});632		tr_color.find("input[name=gaugeBeginColor"+ds_id+"]").keydown(function(){633			begincolor_event(this);634		});635		tr_color.find("input[name=minus"+ds_id+"]").click(function(){636			$(this).parents("tr:first").parents("tr:first").hide();637			$(this).parents("tr:first").attr("minus","");638		});639		tr_color.show();640	}641	642	function endcolor_event(th)643	{644		tr = $(th).parents("tr:first");645		id=$(th).attr("name").replace("gaugeEndColor","");646		if(tr.find("input[name=gaugeBeginColor"+id+"]").val()!="" && tr.attr("minus")!="yes")647		{648			tr.attr("minus","yes");649			tr.find("input[name=minus"+id+"]").show();650			add_new_color(id);651		}652	}653	654	function begincolor_event(th,ev)655	{656		tr = $(th).parents("tr:first");657		id=$(th).attr("name").replace("gaugeBeginColor","");658		if(tr.find("input[name=gaugeEndColor"+id+"]").val()!="" && tr.attr("minus")!="yes")659		{660			tr.attr("minus","yes");661			tr.find("input[name=minus"+id+"]").show();662			add_new_color(id);663		}664	}665	666	667	$("#sqlbtn").click(function(){668		669		var output = collect_input_data();670		$.ajax({671			type: "POST",672			url: "'.GetTableLink("save-state").'",673			data: {674				name: "parameters",675				web: "webcharts",676				str_xml: output,677				rnd: (new Date().getTime())678			},679			success: function(msg){680				if ( msg == "OK" ) {681					$("#sql_query").click();682				} else {683					$("#alert").html("<p>"+msg+"</p>").dialog("open");684				}685			}686		});687	});	688	689	$("#row4")690		.css("cursor", "default")691		.css("font-weight", "bold");692 693	$("td[id^=row]").mouseover(function(){694		for(var i=0; i<=9; i++) {695			if(i == this.id.replace("row", "")) {696				$("td[id=row" + i + "]").css("background-color","#92BEEB");697			}698			else {699				$("td[id=row" + i + "]").css("background-color","#F4F7FB");700			}701		}702	});703	704 705'."\r\n";706 707$b_includes .= colorPickerMouse();708 709$b_includes .= JumpTo();710 711if (count(GetUserGroups()) < 2 || isset( $root['settings']['status'] )712	&& $root['settings']['status'] == "private" ) {713	$b_includes .= '$("td[id=row7]").hide();'."\r\n";714}715if (is_wr_project() || is_wr_custom()) {716	$b_includes .= '$("td[id=row1], td[id=row2]").hide();'."\r\n";717}718if($wr_is_standalone)719	$b_includes .= '$("td[id=row9]").hide();'."\n";720	721if ($root['settings']['title'] == "") {722	$b_includes .= '723		for (var i=2; i<=7; i++){724			$("td[id=row" + i + "]").hide();725		};726	'."\r\n";727}728 729$rLinks = "var rlinks = {};\r\n";730for($ri = 0; $ri < 10; $ri++)731	$rLinks.= "rlinks['".$ri."'] = '".GetTableLink("webchart".$ri)."';\r\n";732    733$b_includes .= '734	var activeXDetectRules = [735            {"name":"ShockwaveFlash.ShockwaveFlash.7"},736            {"name":"ShockwaveFlash.ShockwaveFlash.6"},737            {"name":"ShockwaveFlash.ShockwaveFlash"}738    ];739	var getActiveXObject = function(name){740        var obj = -1;741        try{742            obj = new ActiveXObject(name);743        }catch(err){744            obj = {activeXError:true};745        }746        return obj;747    };748	if(navigator.plugins && navigator.plugins.length>0)749	{750		var type = "application/x-shockwave-flash";751		var mimeTypes = navigator.mimeTypes;752		if(!mimeTypes || !mimeTypes[type] || !mimeTypes[type].enabledPlugin || !mimeTypes[type].enabledPlugin.description)753		{754			$("#previewbtn").parent("span").hide();755			$("#previewbtn").hide();756		}757	}758	else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript)759	{760		var isFlash = false;761		for(var i=0; i<activeXDetectRules.length; i++){762                var obj = getActiveXObject(activeXDetectRules[i].name);763                if(!obj.activeXError){764					isFlash = true;765				}766			}767		if(!isFlash){768			$("#previewbtn").parent("span").hide();769			$("#previewbtn").hide();770		}771	}	772	$("#nextbtn, #backbtn, td[id^=row], #savebtn, #saveasbtn, #previewbtn").click(function(){773		if($("#colorPickerVtd"))774			$("#colorPickerVtd").hide();775		var URL = "'.GetTableLink("webchart").'";776		'.$rLinks.'777		if( this.id == "nextbtn" )778			URL = "'.GetTableLink("webchart5").'";779		if( this.id == "backbtn" )780			URL = "'.GetTableLink("webchart3").'";781		if( this.id == "saveasbtn" )782			URL = "'.GetTableLink("webchart6", "", "saveas=1").'";			783		if( this.id.substr(0,3)=="row" && this.id != "row4" )784			URL = rlinks[this.id.replace(\'row\',\'\')];785		if( this.id == "row8" )786			URL = "'.GetTableLink("webreport").'";787		if( this.id == "row9" )788			URL = "'.GetTableLink("menu").'";789		790		var output = collect_input_data();791		var_save=0;792		if( this.id == "savebtn")793			var_save=1;794		if( this.id == "savebtn" || this.id == "previewbtn") {795			id=this.id;796			$.ajax({797				type: "POST",798				url: "'.GetTableLink("save-state").'",799				data: {800					save: var_save,801					web: "webcharts",802					name: "parameters",803					str_xml: output,804					rnd: (new Date().getTime())805				},806				success: function(msg){807					if ( msg == "OK" ) {808						if( id == "savebtn" )809						{810							$("#alert")811								.html("<p>'."Chart Saved".'</p>")812								.dialog("option", "close", function(){813									window.location = "'.GetTableLink("webreport").'";814								})815								.dialog("open");816						}817						else818							$("#preview").click();819					} else {820						$("#alert").html("<p>'."Some problems appear during saving".'</p>").dialog("open");821					}822				},823				error: function() {824					$("#alert").html("<p>'."Some problems appear during saving".'</p>").dialog("open");825				}826			});827		}828		thisid=this.id;829		if(this.id != "row4" && this.id !="savebtn" && this.id !="previewbtn") {830			$.ajax({831				type: "POST",832				url: "'.GetTableLink("save-state").'",833				data: {834					name: "parameters",835					web: "webcharts",836					str_xml: output,837					rnd: (new Date().getTime())838				},839				success: function(msg){840					if ( msg == "OK" ) {841						window.location = URL;842					} else {843						$("#alert").html("<p>"+msg+"</p>").dialog("open");844						if( thisid == "row8" || thisid == "row9" )845							window.location=URL;846					}847				}848			});849		}850	});'."\r\n";851 852$arr = $root['parameters'];853//print_r($arr);854if ( !empty( $arr ) ){855	for ( $i=0; $i < count($arr)-1; $i++ ) 856	{857		if(is_wr_custom())858			$table_name="";859		else860			$table_name=$arr[$i]["table"].".";861		$computed_value = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["name"].")" : $table_name.$arr[$i]["name"];862		$b_includes .= '863			add_dataseries('.($i+1).');864			$("select[id=field' . ($i+1) . ']").val(\'' . jsreplace($computed_value) . '\');';865			if($arr[$i]["series_color"])866				$b_includes .= '$("#picker' . ($i+1) . '").css("background-color", "#'.$arr[$i]["series_color"].'");'."\r\n";867		if ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")868		{869			$value_Open = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["ohlcOpen"].")" : $table_name.$arr[$i]["ohlcOpen"];870			$value_Close = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["ohlcClose"].")" : $table_name.$arr[$i]["ohlcClose"];871			$value_High = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["ohlcHigh"].")" : $table_name.$arr[$i]["ohlcHigh"];872			$value_Low = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["ohlcLow"].")" : $table_name.$arr[$i]["ohlcLow"];873			$b_includes .= '874			$("select[id=field_open' . ($i+1) . ']").val(\'' . jsreplace($value_Open) . '\');875			$("select[id=field_close' . ($i+1) . ']").val(\'' . jsreplace($value_Close) . '\');876			$("select[id=field_high' . ($i+1) . ']").val(\'' . jsreplace($value_High) . '\');877			$("select[id=field_low' . ($i+1) . ']").val(\'' . jsreplace($value_Low) . '\');';878			879			if( $arr[$i]["ohlcColor"] || $arr[$i]["ohlcCandleColor"] )880				$b_includes .= '881				$("#picker1_' . ($i+1) . '").css("background-color", "#'.$arr[$i]["ohlcColor"].'");882				$("#picker2_' . ($i+1) . '").css("background-color", "#'.$arr[$i]["ohlcCandleColor"].'");883				'."\r\n";884		}885		if ($_SESSION['webcharts']['chart_type']['type']=="bubble")886		{887			$size_value = ($arr[$i]["agr_func"]) ? $arr[$i]["agr_func"]."(".$table_name.$arr[$i]["size"].")" : $table_name.$arr[$i]["size"];888			$b_includes .= '$("select[id=size' . ($i+1) . ']").val(\'' . jsreplace($size_value) . '\');889			'."\r\n";890		}891		if ($_SESSION['webcharts']['chart_type']['type']=="gauge")892		{893			$b_includes .= '$("input[name=gaugeMinValue' . ($i+1) . ']").val(\'' . jsreplace($arr[$i]["gaugeMinValue"]) . '\');'."\r\n";894			$b_includes .= '$("input[name=gaugeMaxValue' . ($i+1) . ']").val(\'' . jsreplace($arr[$i]["gaugeMaxValue"]) . '\');'."\r\n";895			896			for ( $j=0; $j < count($arr[$i]["gaugeColorZone"]); $j++ ) 897			{898				$b_includes .= 'add_new_color('.($i+1).');'."\r\n";899				$b_includes .= '$("input[name=gaugeBeginColor' . ($i+1) . ']:last").val(\'' . jsreplace($arr[$i]["gaugeColorZone"][$j]["gaugeBeginColor"]) . '\');900				$("input[name=gaugeEndColor' . ($i+1) . ']:last").val(\'' . jsreplace($arr[$i]["gaugeColorZone"][$j]["gaugeEndColor"]) . '\');901				$("div[name=gaugeColor' . ($i+1) . ']:last").css("background-color","#'.$arr[$i]["gaugeColorZone"][$j]["gaugeColor"].'");';902				if ( $j!==0 ) {903					$b_includes .= '904					tr = $("input[name=gaugeBeginColor' . ($i+1) . ']:last").parents("tr:first");905					tr.attr("minus","yes");906					tr.find("input[name=minus'.($i+1).']:last").show();'."\r\n";907				}908			}909			$b_includes .= 'add_new_color('.($i+1).');'."\r\n";910		}911	}912	913	if(is_wr_custom())914		$label_name="";915	else916		$label_name=$arr[count($arr)-1]["table"].".";917		918	$b_includes .= '		919	$("select[id=field]").val(\'' . jsreplace($label_name.$arr[count($arr)-1]["name"]). '\');920	$("select[id^=field]").change();921	'."\r\n";922	for ( $i=0; $i < count($arr)-1; $i++ ) 923	{924		if(is_wr_custom())925			$table_name="";926		else927			$table_name=$arr[$i]["table"].".";928		$computed_value = ($arr[$i]["agr_func"]) ?929			$arr[$i]["agr_func"]."(".$table_name.$arr[$i]["name"].")" :930			$table_name.$arr[$i]["name"];931			932		if ($_SESSION['webcharts']['chart_type']['type']!="ohlc" && $_SESSION['webcharts']['chart_type']['type']!="candlestick")933		{934			$b_includes .= 'if($("select[id=field' . ($i+1) . ']").val()==\''.jsreplace($computed_value).'\')935			$("input[id=series_label_' . ($i+1) . ']").val(\''.jsreplace($arr[$i]["label"]).'\');'."\r\n";936		}937		else938			$b_includes .= '$("input[id=series_label_' . ($i+1) . ']").val(\''.jsreplace($arr[$i]["label"]).'\');'."\r\n";939	}		940}941 942$b_includes .= '});943</script>'."\r\n";944 945 946if(is_wr_project())947	$xt->assign("disable", "disabled");948	949if ($_SESSION['webcharts']['chart_type']['type']!="gauge" && $_SESSION['webcharts']['chart_type']['type']!="bubble")950	$xt->assign("separator","style='display:none'");951 952if ($_SESSION['webcharts']['chart_type']['type']!="bubble")953	$xt->assign("span_style","style='display:none'");954 955$xt->assign("b_includes", $b_includes);956	$xt->assign("wr_pagestylepath", $wr_pagestylepath);957$xt->assign("chart_name_preview",$_SESSION['webcharts']['settings']['name']);958 959if ($_SESSION['webcharts']['chart_type']['type']=="gauge")960	$templatefile = GetTemplateName("", "webchart4_gauge");961elseif ($_SESSION['webcharts']['chart_type']['type']=="ohlc" || $_SESSION['webcharts']['chart_type']['type']=="candlestick")962	$templatefile = GetTemplateName("", "webchart4_ohlc");963else964	$templatefile = GetTemplateName("", "webchart4");965$xt->display($templatefile);966 967 968?>