CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
webchart5.php500 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");8if(is_wr_project())9	include("include/" . GetTableURL( $_SESSION['webcharts']['tables'][0] ) . "_variables.php");10 11	if( !Security::getUserName() )12	{13		$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];14		header("Location: ".GetTableLink("login", "", "message=expired"));15		return;16	}17 18Reload_Chart(postvalue("cname"));19include('include/xtempl.php');20$xt = new Xtempl();21 22if (@$_SESSION['webcharts']['settings']['title'] != "") {23	$title=@$_SESSION['webcharts']['settings']['title'];24	if(strlen($title)>25)25		$title=substr($title,25)."...";26	$xt->assign("chart_title",", "."Title".": ".$title);27} else {28	$xt->assign("chart_title","");29}30if (@$_SESSION['webcharts']['tables'][0] != "") {31	$stable=@$_SESSION['webcharts']['tables'][0];32	if(strlen($stable)>25)33		$stable=substr($stable,25)."...";34 35	$xt->assign("chart_table",", "."Table".": ".$stable);36} else {37	$xt->assign("chart_table","");38}39$xt->assign("b_is_chart_save",($_SESSION['webcharts']['tmp_active'] != "x"));	40$xt->assign("b_is_chart_name",($_SESSION['webcharts']['settings']['name'] != ""));41$xt->assign("chart_name",$_SESSION['webcharts']['settings']['name']);42$xt->assign("wr_pagestylepath", $wr_pagestylepath);43$h_includes = "";44$b_includes = "";45 46$h_includes .= '47	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/stylesheet.css").'" type="text/css">48	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/jquery-ui.css").'" type="text/css">49	<link rel="stylesheet" href="'.GetRootPathForResources("include/css/dstyle.css").'" type="text/css">50	<link rel="stylesheet" href="'.GetRootPathForResources("include/fancybox/jquery.fancybox.css").'" type="text/css" media="screen">51	52	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.min.js").'"></script>53	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.dimensions.pack.js").'"></script>54	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.easing.js").'"></script>55    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.fancybox.pack.js").'"></script>56    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery-ui.js").'"></script>57	<script type="text/javascript" src="'.GetRootPathForResources("include/js/json.js").'"></script>58'."\r\n";59 60$xt->assign("h_includes", $h_includes);61 62$b_includes .= '63<script type="text/javascript">64var timeout	= 200,65	closetimer	= 0,66	closetimerpicker = 0,67	timeoutpicker = 300,68	div_id=0;69 70$(document).ready(function(){71	';72	$b_includes .= alertDialog();73	$b_includes .= '74	function collect_input_data() {75		var output = {76			appearance : {77				slegend : $("input[id=slegend]").prop("checked").toString() || "",78				sgrid : $("input[id=sgrid]").prop("checked").toString() || "",79				sname : $("input[id=sname]").prop("checked").toString() || "",80				sval : $("input[id=sval]").prop("checked").toString() || "",81				sanim : $("input[id=sanim]").prop("checked").toString() || "",82				scur : $("input[id=scur]").prop("checked").toString() || "",83				sstacked : $("input[id=sstacked]").prop("checked").toString() || "",84				saxes : $("input[id=saxes]").prop("checked").toString() || "",85				slog : $("input[id=slog]").prop("checked").toString() || "",86				dec : $("input[id=dec]").val(),87				head : $("input[id=head]").val(),88				foot : $("input[id=foot]").val(),89				linestyle : $("select[id=linestyle]").val(),90				gaugestyle : $("select[id=gaugestyle]").val(),91				accumulstyle : $("select[id=accumulstyle]").val(),92				aqua : $("select[id=aqua]").val(),93				cview : $("select[id=cview]").val(),94				accumulinvert : $("input[id=accumulinvert]").prop("checked").toString() || "",95				is3d : ($("input[id=is3d]").prop("checked") ? $("input[id=is3d]").prop("checked").toString(): ""),96				isstacked : ($("input[id=isstacked]").prop("checked") ? $("input[id=isstacked]").prop("checked").toString() : ""),97				autoupdate : $("input[id=autoupdate]").prop("checked").toString() || "",98				cscroll : $("input[id=cscroll]").prop("checked").toString() || "",99				update_interval : $("input[id=update_interval]").val(),100				maxbarscroll : $("input[id=maxbarscroll]").val()101			}102		};103		for ( var i = 5; i <= 14; i++ ) {104			output.appearance["color"+i+"1"] = $("div[id=picker"+i+"]").attr("color1");105			output.appearance["color"+i+"2"] = $("div[id=picker"+i+"]").attr("color2");106		}		107		108		return JSON.stringify(output);		109	}110 111	$("#row5")112		.css("cursor", "default")113		.css("font-weight", "bold");114 115	$("td[id^=row]").mouseover(function(){116		for(var i=0; i<=9; i++) {117			if(i == this.id.replace("row", "")) {118				$("td[id=row" + i + "]").css("background-color","#92BEEB");119			}120			else {121				$("td[id=row" + i + "]").css("background-color","#F4F7FB");122			}123		}124	});125	126	$.each([5,6,7,8,9,10,11,12,13,14],function(i,n){127		$("#picker"+n).css("background-color", "#FFFFFF");128		$("#picker"+n)[0].color1 = "";129		$("#picker"+n)[0].color2 = "";                      130	});131	132';133	134$b_includes .= colorPickerMouse();135 136$b_includes .= JumpTo();137 138if (count(GetUserGroups()) < 2 || isset( $_SESSION['webcharts']['settings']['status'] )139	&& $_SESSION['webcharts']['settings']['status'] == "private" ) {140	$b_includes .= '$("td[id=row7]").hide();'."\r\n";141}142if (is_wr_project() || is_wr_custom()) {143	$b_includes .= '$("td[id=row1], td[id=row2]").hide();'."\r\n";144}145if($wr_is_standalone)146	$b_includes .= '$("td[id=row9]").hide();'."\n";147	148if ($_SESSION['webcharts']['settings']['title'] == "") {149	$b_includes .= '150		for (var i=2; i<=7; i++){151			$("td[id=row" + i + "]").hide();152		};153	'."\r\n";154}155 156$rLinks = "var rlinks = {};\r\n";157for($ri = 0; $ri < 10; $ri++)158	$rLinks.= "rlinks['".$ri."'] = '".GetTableLink("webchart".$ri)."';\r\n";159    160$b_includes .= '161	var activeXDetectRules = [162            {"name":"ShockwaveFlash.ShockwaveFlash.7"},163            {"name":"ShockwaveFlash.ShockwaveFlash.6"},164            {"name":"ShockwaveFlash.ShockwaveFlash"}165    ];166	var getActiveXObject = function(name){167        var obj = -1;168        try{169            obj = new ActiveXObject(name);170        }catch(err){171            obj = {activeXError:true};172        }173        return obj;174    };175	if(navigator.plugins && navigator.plugins.length>0)176	{177		var type = "application/x-shockwave-flash";178		var mimeTypes = navigator.mimeTypes;179		if(!mimeTypes || !mimeTypes[type] || !mimeTypes[type].enabledPlugin || !mimeTypes[type].enabledPlugin.description)180		{181			$("#previewbtn").parent("span").hide();182			$("#previewbtn").hide();183		}184	}185	else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript)186	{187		var isFlash = false;188		for(var i=0; i<activeXDetectRules.length; i++){189                var obj = getActiveXObject(activeXDetectRules[i].name);190                if(!obj.activeXError){191					isFlash = true;192				}193			}194		if(!isFlash){195			$("#previewbtn").parent("span").hide();196			$("#previewbtn").hide();197		}198	}	199	$("#nextbtn, #backbtn, td[id^=row], #savebtn, #saveasbtn, #previewbtn").click(function(){200		var URL = "'.GetTableLink("webreport").'";201		'.$rLinks.'202		if( this.id == "nextbtn" )203			URL = "'.GetTableLink("webchart6").'";204		if( this.id == "backbtn" )205			URL = "'.GetTableLink("webchart4").'";206		if( this.id == "saveasbtn" )207			URL = "'.GetTableLink("webchart6", "", "saveas=1").'";			208		if( this.id.substr(0,3)=="row" && this.id != "row5" )209			URL = rlinks[this.id.replace(\'row\',\'\')];210		if( this.id == "row8" )211			URL = "'.GetTableLink("webreport").'";212		if( this.id == "row9" )213			URL = "'.GetTableLink("menu").'";214		215		var output = collect_input_data();216		var_save=0;217		if( this.id == "savebtn")218			var_save=1;219		if( this.id == "savebtn" || this.id == "previewbtn" ) {220			id=this.id;221			$.ajax({222				type: "POST",223				url: "'.GetTableLink("save-state").'",224				data: {225					save: var_save,226					web: "webcharts",227					name: "appearance",228					str_xml: output,229					rnd: (new Date().getTime())230				},231				success: function(msg){232					if ( msg == "OK" ) {233						if(id == "savebtn")234						{235							$("#alert")236								.html("<p>'."Chart Saved".'</p>")237								.dialog("option", "close", function(){238									window.location = "'.GetTableLink("webreport").'";239								})240								.dialog("open");241						}242						else243						{244							$("#preview").click();245						}246					} else {247						if(this.id == "savebtn")248							$("#alert").html("<p>'."Some problems appear during saving".'</p>").dialog("open");249						else250							$("#alert").html("<p>'."Some problems appear during preview".'</p>").dialog("open");251					}252				},253				error: function() {254					if(this.id == "savebtn")255						$("#alert").html("<p>'."Some problems appear during saving".'</p>").dialog("open");256					else257						$("#alert").html("<p>'."Some problems appear during preview".'</p>").dialog("open");258				}259			});260		}261		thisid=this.id;262		if(this.id != "row5" && this.id !="savebtn" && this.id !="previewbtn") {263			$.ajax({264				type: "POST",265				url: "'.GetTableLink("save-state").'",266				data: {267					name: "appearance",268					web: "webcharts",269					str_xml: output,270					rnd: (new Date().getTime())271				},272				success: function(msg){273					if ( msg == "OK" ) {274						window.location = URL;275					} else {276						$("#alert").html("<p>"+msg+"</p>").dialog("open");277						if( thisid == "row8" || thisid == "row9" )278							window.location=URL;279					}280				}281			});282		}283	});284});285</script>'."\r\n";286 287$aColor = array();288for ( $i = 1; $i <= 14; $i++ ) {289	$aColor["color".$i."1"] = "";290	$aColor["color".$i."2"] = "";291}292 293$slegend_checked = "checked";294$sname_checked = "checked";295$sval_checked = "checked";296$sanim_checked = "checked";297$sgrid_checked = "";298$scur_checked = "";299$sstacked_checked = "";300$saxes_checked = "";301$slog_checked = "";302$isstacked_checked = "";303$is3d_checked = "";304$autoupdate_checked = "";305$update_interval_val = 5;306$cscroll_checked = "checked";307$maxbarscroll_val = 10;308$dec_val = 0;309$linestyle_val=0;310$gaugestyle_val=0;311$cview_val = 0;312$head_val = "New Chart ".CheckLastID( WR_CHART );313$foot_val = "New Chart ".CheckLastID( WR_CHART );314 315$arr = $_SESSION['webcharts']['appearance'];316if ( !empty( $arr ) ){317	for ( $i = 1; $i <= 14; $i++ ) {318		$aColor["color".$i."1"] = $arr["color".$i."1"];319		$aColor["color".$i."2"] = $arr["color".$i."1"];320	}321	322	$slegend_checked = ( $arr["slegend"] == "true" ) ? "checked" :  "";323	$sgrid_checked = ( $arr["sgrid"] == "true" ) ? "checked" :  "";324	$sname_checked = ( $arr["sname"] == "true" ) ? "checked" :  "";325	$sval_checked = ( $arr["sval"] == "true" ) ? "checked" :  "";326	$sanim_checked = ( $arr["sanim"] == "true" ) ? "checked" :  "";327	$scur_checked = ( $arr["scur"] == "true" ) ? "checked" :  "";328	$sstacked_checked = ( $arr["sstacked"] == "true" ) ? "checked" :  "";329	$saxes_checked = ( $arr["saxes"] == "true" ) ? "checked" :  "";330	$slog_checked = ( $arr["slog"] == "true" ) ? "checked" :  "";331	$is3d_checked = ( $arr["is3d"] == "true" ) ? "checked" :  "";332	$isstacked_checked = ( $arr["isstacked"] == "true" ) ? "checked" :  "";333	$autoupdate_checked = ( $arr["autoupdate"] == "true" ) ? "checked" :  "";334	$cscroll_checked = ( $arr["cscroll"] == "true" ) ? "checked" :  "";335	$accumulinvert_checked = ( $arr["accumulinvert"] == "true" ) ? "checked" :  "";336	$accumulstyle_val = $arr["accumulstyle"];337	$dec_val = $arr["dec"];338	$aqua_val = $arr["aqua"];339	$linestyle_val = $arr["linestyle"];340	$gaugestyle_val = $arr["gaugestyle"];341	$cview_val = $arr["cview"];342	$head_val = $arr["head"];343	$foot_val = $arr["foot"];344	$update_interval_val = $arr["update_interval"];345	$maxbarscroll_val = $arr["maxbarscroll"];346}347 348$xt->assign("slegend_checked", $slegend_checked);349$xt->assign("sgrid_checked", $sgrid_checked);350$xt->assign("sname_checked", $sname_checked);351$xt->assign("sval_checked", $sval_checked);352$xt->assign("sanim_checked", $sanim_checked);353$xt->assign("scur_checked", $scur_checked);354$xt->assign("sstacked_checked", $sstacked_checked);355$xt->assign("saxes_checked", $saxes_checked);356$xt->assign("slog_checked", $slog_checked);357$xt->assign("isstacked_checked", $isstacked_checked);358$xt->assign("is3d_checked", $is3d_checked);359$xt->assign("autoupdate_checked", $autoupdate_checked);360$xt->assign("cscroll_checked", $cscroll_checked);361$xt->assign("accumulinvert_checked", $accumulinvert_checked);362$xt->assign("dec_val", $dec_val);363$xt->assign("head_val", $head_val);364$xt->assign("foot_val", $foot_val);365$xt->assign("maxbarscroll_val", $maxbarscroll_val);366$xt->assign("update_interval_val", $update_interval_val);367 368$b_includes .= '<script type="text/javascript">369	$(document).ready(function(){370	371		372		$("a#preview").fancybox({373			fitToView: false,374				autoSize: false,375				width : 820,376				height : 660,377				overlayShow: true378		});379          $("select[id=aqua]").find("option").each(function(i){380            if ( this.value == "'.$aqua_val.'" ) {381              $("select[id=aqua]")[0].selectedIndex = i;382              return;383            }384          });385          $("select[id=cview]").find("option").each(function(i){386            if ( this.value == "'.$cview_val.'" ) {387              $("select[id=cview]")[0].selectedIndex = i;388              return;389            }390          });391		  $("select[id=linestyle]").find("option").each(function(i){392            if ( this.value == "'.$linestyle_val.'" ) {393              $("select[id=linestyle]")[0].selectedIndex = i;394              return;395            }396          });397		  $("select[id=gaugestyle]").find("option").each(function(i){398            if ( this.value == "'.$gaugestyle_val.'" ) {399              $("select[id=gaugestyle]")[0].selectedIndex = i;400              return;401            }402          });403		  $("select[id=accumulstyle]").find("option").each(function(i){404            if ( this.value == "'.$accumulstyle_val.'" ) {405              $("select[id=accumulstyle]")[0].selectedIndex = i;406              return;407            }408          });409		  $("#autoupdate").click(function()410		  {411			$("#sanim").prop("checked", false);412		  });413		  $("#sanim").click(function()414		  {415			$("#autoupdate").prop("checked", false);416		  });417		  $("#isstacked").click(function()418		  {419			$("#slog").prop("checked", false);420		  });		  421		  $("#slog").click(function()422		  {423			$("#isstacked").prop("checked", false);424		  });	425		  426'."\r\n";427 428for ( $i = 5; $i <= 14; $i++ ) {429	if ( $aColor["color".$i."1"] != "" ) {430            $b_includes .= '$("div[id=picker' . $i . ']").css("background-color","#' . $aColor["color".$i."1"] . '");'."\r\n";431            $b_includes .= '$("div[id=picker' . $i . ']").attr("color1","' . $aColor["color".$i."1"] . '");' . "\r\n";432            $b_includes .= '$("div[id=picker' . $i . ']").attr("color2","' . $aColor["color".$i."2"] . '");' . "\r\n";433	}	434}435 436$b_includes .= '});437</script>';438 439$xt->assign("b_includes", $b_includes);440 441$xt->assign("stacked", "<span id=\"td_stacked\" style=\"visibility:hidden\"><input type=\"checkbox\" ".$sstacked_checked." id=\"sstacked\" name=\"sstacked\" />&nbsp;"."100% Stacked"."</span>");442 443if ($_SESSION['webcharts']['chart_type']['type']=="2d_column" || $_SESSION['webcharts']['chart_type']['type']=="2d_bar" || $_SESSION['webcharts']['chart_type']['type']=="bubble" || $_SESSION['webcharts']['chart_type']['type']=="2d_pie" || $_SESSION['webcharts']['chart_type']['type']=="2d_doughnut") 444	$xt->assign("chart_is_3d","<input type=\"checkbox\" ".$is3d_checked." id=\"is3d\" name=\"is3d\">&nbsp;"."Chart 3D");445else 446	$xt->assign("chart_is_3d", '');	447 448if ($_SESSION['webcharts']['chart_type']['type']=="2d_column" || $_SESSION['webcharts']['chart_type']['type']=="2d_bar" || $_SESSION['webcharts']['chart_type']['type']=="area") 449	$xt->assign("chart_is_stacked","<input type=\"checkbox\" ".$isstacked_checked." id=\"isstacked\" name=\"isstacked\">&nbsp;"."Chart stacked");450else 451	$xt->assign("chart_is_stacked", '');	452if ( preg_match( "/bar/i", $_SESSION['webcharts']['chart_type']['type'] ) ) {453	$xt->assign("aqua", "Use Style"." <select name=\"aqua\" id=\"aqua\">454		<option value=\"0\">"."None"."</option>455		<option value=\"1\">"."AquaLight"."</option>456		<option value=\"2\">"."AquaDark"."</option>457	  </select>");458    $xt->assign("cview", "Chart Type"." <select name=\"cview\" id=\"cview\">459		<option value=\"0\">"."Column"."</option>460		<option value=\"1\">"."Cone"."</option>461		<option value=\"2\">"."Cylinder"."</option>462		<option value=\"3\">"."Pyramid"."</option>463	  </select>");464} else {465	$xt->assign("aqua", '');466    $xt->assign("cview", '');	467}468if ( preg_match( "/line/i", $_SESSION['webcharts']['chart_type']['type'] ) ) {469	$xt->assign("line", "&nbsp;&nbsp;&nbsp;&nbsp;"."Line Style"." <select name=\"linestyle\" id=\"linestyle\">470		<option value=\"0\">"."Normal"."</option>471		<option value=\"1\">"."Spline"."</option>472		<option value=\"2\">"."Step"."</option>473	  </select>");474} else {475	$xt->assign("line", '');476}477if ( preg_match( "/funnel/i", $_SESSION['webcharts']['chart_type']['type'] ) ) {478	$xt->assign("funnel", "<td colspan=2>");479	$xt->assign("tr_funnel", "");480} else {481	$xt->assign("funnel", '<td colspan=2 style="visibility:hidden;">');482	$xt->assign("tr_funnel", "style=\"display:none\"");483}484if ( preg_match( "/gauge/i", $_SESSION['webcharts']['chart_type']['type'] ) ) {485	$xt->assign("gauge", "Gauge style"." <select name=\"gaugestyle\" id=\"gaugestyle\">486		<option value=\"0\">"."Circle"."</option>487		<option value=\"1\">"."Horizontal"."</option>488		<option value=\"2\">"."Vertical"."</option>489	  </select>");490} else {491	$xt->assign("gauge", '');492}493$xt->assign("chart_name_preview",$_SESSION['webcharts']['settings']['name']);494$table_name = @$_SESSION['webcharts']['tables'][0];495$xt->assign("table_name", $table_name);496 497$templatefile = GetTemplateName("", "webchart5");498$xt->display($templatefile);499 500?>