kenken999/php
0
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"] = GetTableLink("webreport");12 header("Location: ".GetTableLink("login", "", "message=expired"));13 return;14 }15 16 17Reload_Report(postvalue("rname"));18include('include/xtempl.php');19$xt = new Xtempl();20 21if (@$_SESSION['webreports']['settings']['title'] != "") {22 $title=@$_SESSION['webreports']['settings']['title'];23 if(strlen($title)>25)24 $title=substr($title,25)."...";25 $xt->assign("report_title",", "."Title".": ".$title);26} else {27 $xt->assign("report_title","");28}29if (@$_SESSION['webreports']['tables'][0] != "") {30 $stable=@$_SESSION['webreports']['tables'][0];31 if(strlen($stable)>25)32 $stable=substr($stable,25)."...";33 34 $xt->assign("report_table",", "."Table".": ".$stable);35} else {36 $xt->assign("report_table","");37}38$xt->assign("b_is_report_name",($_SESSION['webreports']['settings']['name'] != ""));39$xt->assign("report_name",$_SESSION['webreports']['settings']['name']);40 41if(!$_SESSION['webreports_oldname'])42 $_SESSION['webreports_oldname']=$_SESSION['webreports']['settings']['name'];43 44$h_includes = "";45$b_includes = "";46 47$h_includes .= '48 <link rel="stylesheet" href="'.GetRootPathForResources("include/css/dstyle.css").'" type="text/css">49 <link rel="stylesheet" href="'.GetRootPathForResources("include/css/jquery-ui.css").'" type="text/css">50 51 <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.min.js").'"></script>52 <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.dimensions.pack.js").'"></script>53 <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery-ui.js").'"></script>54 <script type="text/javascript" src="'.GetRootPathForResources("include/js/json.js").'"></script>55'."\r\n";56 57 58$xt->assign("h_includes", $h_includes);59 60$b_includes .= '61<script type="text/javascript">62var timeout = 200;63var closetimer = 0;64var relation_stack = [];65$(document).ready(function(){66';67 $b_includes .= alertDialog();68 $b_includes .= '69 70 71 function collect_input_data() {72 var output = {73 settings : {74 name : $("#rname").val().replace(/\W/g, "_"),75 title : $("#rtitle").val(),76 status : ( $("#rstatus")[0].checked ) ? "private" : "public"77 }78 };79 80 return JSON.stringify(output); 81 } 82 83 84 $("#row8")85 .css("cursor", "default")86 .css("font-weight", "bold");87 88 $("td[id^=row]").mouseover(function(){89 for(var i=0; i<=11; i++) {90 if(i == this.id.replace("row", "")) {91 $("td[id=row" + i + "]").css("background-color","#92BEEB");92 }93 else {94 $("td[id=row" + i + "]").css("background-color","#F4F7FB");95 }96 }97 });98 99'."\r\n";100 101$b_includes .= JumpTo();102 103if (count(GetUserGroups()) < 2 || isset( $_SESSION['webreports']['settings']['status'] )104 && $_SESSION['webreports']['settings']['status'] == "private" ) {105 $b_includes .= '$("td[id=row9]").hide();'."\r\n";106}107if (is_wr_project() || is_wr_custom()) {108 $b_includes .= '$("td[id=row1], td[id=row2]").hide();'."\r\n";109}110if($wr_is_standalone)111 $b_includes .= '$("td[id=row11]").hide();'."\n";112 113if ($_SESSION['webreports']['settings']['title'] == "") {114 $b_includes .= '115 for (var i=2; i<=9; i++){116 $("td[id=row" + i + "]").hide();117 };118 '."\r\n";119}120if($_SESSION['webreports']['group_fields'][count($_SESSION['webreports']['group_fields'])-1]["cross_table"]=="true")121 $b_includes .= '$("#row5,#row6").hide();'."\r\n";122 123$rLinks = "var rlinks = {};\r\n";124for($ri = 0; $ri < 10; $ri++)125 $rLinks.= "rlinks['".$ri."'] = '".GetTableLink("webreport".$ri)."';\r\n";126 127$b_includes .= '128 $("#nextbtn, #backbtn, td[id^=row], #savebtn").click(function(){129 var URL = "'.GetTableLink("webreport").'";130 '.$rLinks.'131 if( this.id == "nextbtn" )132 URL = "'.GetTableLink("webreport9").'";133 if( this.id == "backbtn" )134 URL = "'.GetTableLink("dreport").'?edit=style&rname='.@$_SESSION['webreports']['settings']['name'].'";135 if( this.id.substr(0,3)=="row" && this.id != "row8" )136 URL = rlinks[this.id.replace(\'row\',\'\')];137 if( this.id == "row10" )138 URL = "'.GetTableLink("webreport").'";139 if( this.id == "row11" )140 URL = "'.GetTableLink("menu").'";141 if ( this.id == "row7" )142 URL = "'.GetTableLink("dreport").'?edit=style&rname='.@$_SESSION['webreports']['settings']['name'].'"; 143 144 if ( $("#rname").val() == "" && this.id!="row10" && this.id!="row11" ) {145 $("#menujump").hide();146 $("#alert").html("<p>'."Set report name".'</p>").dialog("open");147 return false;148 }149 150 if ( $("#rtitle").val() == "" && this.id!="row10" && this.id!="row11" ) {151 $("#menujump").hide();152 $("#alert").html("<p>'."Set report title".'</p>").dialog("open");153 return false;154 } 155 156 var output = collect_input_data();157 158 if( this.id == "savebtn" ) {159 $.ajax({160 type: "POST",161 url: "'.GetTableLink("save-state").'",162 data: {163 save: 1,164 ';165if(@$_REQUEST["saveas"]==1) 166 $b_includes .= 'saveas:1,';167$b_includes .= ' 168 web: "webreports",169 name: "settings",170 str_xml: output,171 rnd: (new Date().getTime())172 },173 success: function(msg){174 if ( msg == "OK" ) {175 $("#alert")176 .html("<p>Report Saved</p>")177 .dialog("option", "close", function(){178 window.location = "'.GetTableLink("webreport").'";179 })180 .dialog("open");181 } else {182 $("#alert").html("<p>"+msg+"</p>").dialog("open");183 }184 },185 error: function() {186 $("#alert").html("<p>'."Some problems appear during saving".'</p>").dialog("open");187 }188 });189 }190 thisid=this.id;191 if(this.id != "row8" && this.id !="savebtn") {192 $.ajax({193 type: "POST",194 url: "'.GetTableLink("save-state").'",195 data: {196 name: "settings",197 web: "webreports",198 str_xml: output,199 rnd: (new Date().getTime())200 },201 success: function(msg){202 if ( msg == "OK" ) {203 window.location = URL;204 } else {205 $("#alert").html("<p>"+msg+"</p>").dialog("open");206 if( thisid == "row10" || thisid == "row11" )207 window.location=URL; 208 }209 }210 });211 }212 });213';214 215if (count(GetUserGroups()) > 1){216 $b_includes.='217 $("#rstatus").click(function(){218 if ( this.checked == true ) {219 $("#nextbtn").hide();220 $("#row9").hide();221 } else {222 $("#nextbtn").show();223 $("#row9").show();224 }225 });226 ';227} 228 229$report_name = ( isset( $_SESSION['webreports']['settings']['name'] ) ) ?230 $_SESSION['webreports']['settings']['name'] :231 GoodFieldName(@$_SESSION['webreports']['tables'][0]).'_'.CheckLastID( WR_REPORT );232 233$report_title = ( isset( $_SESSION['webreports']['settings']['title'] ) ) ?234 $_SESSION['webreports']['settings']['title'] :235 @$_SESSION['webreports']['tables'][0].' Report '.CheckLastID( WR_REPORT );236 237 238 $show_status = 'style="display:line;"';239 if ( isset( $_SESSION['webreports']['settings']['status'] ) && $_SESSION['webreports']['settings']['status'] == "private" ) 240 {241 $report_status = 'checked';242 $b_includes .= '$("#nextbtn").hide();$("#nextprob").hide();';243 } 244 else 245 {246 if (count(GetUserGroups()) > 1) 247 {248 $report_status = '';249 } 250 else 251 {252 $report_status = '';253 $b_includes .= '$("#nextbtn").hide();';254 } 255 }256 257 258$b_includes .= '259});260</script>'."\r\n";261$xt->assign("b_includes", $b_includes);262$xt->assign("wr_pagestylepath", $wr_pagestylepath);263$xt->assign("report_name", $report_name);264$xt->assign("report_title", runner_htmlspecialchars($report_title));265$xt->assign("report_status", $report_status);266$xt->assign("show_status", $show_status);267 268$templatefile = GetTemplateName("", "webreport8");269$xt->display($templatefile);270?>