Exemple #1
0
$mode = postvalue("mode");
$table = postvalue("table");
$field = postvalue("field");
$pageType = postvalue('pagetype');
$mainTable = postvalue("maintable");
$mainField = postvalue("mainfield");
$lookup = false;
if ($mainTable && $mainField) {
    $lookup = true;
}
if (!checkTableName($table)) {
    exit(0);
}
require_once "include/" . $table . "_variables.php";
$pSet = new ProjectSettings(GetTableByShort($table), $pageType);
$cipherer = new RunnerCipherer(GetTableByShort($table), $pSet);
$_connection = $cman->byTable($strTableName);
if (!$pSet->checkFieldPermissions($field)) {
    $returnJSON = array("success" => false, "error" => 'Error: You have not permission for read this text');
    echo printJSON($returnJSON);
    return;
}
if (!$gQuery->HasGroupBy()) {
    // Do not select any fields except current (full text) field.
    // If query has 'group by' clause then other fields are used in it and we may not simply cut 'em off.
    // Just don't do anything in that case.
    $gQuery->RemoveAllFieldsExcept($pSet->getFieldIndex($field));
}
$keysArr = $pSet->getTableKeys();
$keys = array();
foreach ($keysArr as $ind => $k) {
<?php

@ini_set("display_errors", "1");
@ini_set("display_startup_errors", "1");
require_once "include/dbcommon.php";
add_nocache_headers();
$table = postvalue("table");
$strTableName = GetTableByShort($table);
if (!checkTableName($table)) {
    exit(0);
}
require_once "include/" . $table . "_variables.php";
$searchFor = postvalue('searchFor');
// if nothing to search
if ($searchFor == '') {
    echo printJSON(array('success' => true, 'result' => ''));
    return;
}
$_connection = $cman->byTable($strTableName);
// array of vals
$response = array();
$searchOpt = postvalue("start") ? "Starts with" : "Contains";
$searchField = GoodFieldName(postvalue('searchField'));
$strSecuritySql = SecuritySQL("Search", $strTableName);
$numberOfSuggests = GetGlobalData("searchSuggestsNumber", 10);
$pSet = new ProjectSettings($strTableName, PAGE_SEARCH);
if ($searchField == "") {
    $allSearchFields = $pSet->getGoogleLikeFields();
} else {
    // array of fields which were added in wizard for search
    $allSearchFields = $pSet->getAllSearchFields();
Exemple #3
0
function xt_showchart($params)
{
    $width = 700;
    $height = 530;
    if (isset($params["custom1"])) {
        $width = $params["custom1"];
    }
    if (isset($params["custom2"])) {
        $height = $params["custom2"];
    }
    $settings = new ProjectSettings(GetTableByShort($params["chartname"]));
    $refresh = $settings->getChartRefreshTime() * 60000;
    if ($_SERVER["SERVER_PORT"] == 443) {
        $http = "https";
    } else {
        $http = "http";
    }
    ?>
<div id='<?php 
    echo $params["chartname"];
    ?>
' style="width:<?php 
    echo $width;
    ?>
px;height:<?php 
    echo $height;
    ?>
px">
<noscript>
	<object id="'.htmlspecialchars(postvalue('cname')).'" 
		name="'.htmlspecialchars(postvalue('cname')).'" 
		classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
		width="100%" 
		height="100%" 
		codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
		<param name="movie" value="libs/swf/Preloader.swf" />
		<param name="bgcolor" value="#FFFFFF" />

		<param name="allowScriptAccess" value="always" />
		<param name="flashvars" value="swfFile=dchartdata.php%3Fcname%3D'.htmlspecialchars(postvalue('cname')).'%26ctype%3D'.$chrt_array['chart_type']['type'].'" />
		
		<embed type="application/x-shockwave-flash" 
			   pluginspage="http://www.adobe.com/go/getflashplayer" 
			   src="libs/swf/Preloader.swf" 
			   width="100%" 
			   height="100%" 
			   id="'.htmlspecialchars(postvalue('cname')).'" 
			   name="'.htmlspecialchars(postvalue('cname')).'" 
			   bgColor="#FFFFFF" 
			   allowScriptAccess="always" 
			   flashvars="swfFile=dchartdata.php%3Fcname%3D'.htmlspecialchars(postvalue('cname')).'%26ctype%3D'.$chrt_array['chart_type']['type'].'" />
	</object>				
</noscript>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
var svgSupported = window.SVGAngle != undefined;
if (!svgSupported)
{
 	//<![CDATA[
	document.write('<center>');
	document.write("You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />");
	document.write("<a href=\"<?php 
    echo $http;
    ?>
://www.adobe.com/go/getflashplayer\"><img border=\"0\" src=\"<?php 
    echo $http;
    ?>
://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" /></a><br />");
	document.write('</center>');
	//]]>
}	
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	chart.width = '<?php 
    echo $width;
    ?>
';
	chart.height = '<?php 
    echo $height;
    ?>
';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php 
    echo $params["chartname"];
    ?>
';
	var xmlFile = 'dchartdata.php?chartname=<?php 
    echo jsreplace($params["chartname"]);
    ?>
';
	xmlFile += '&ctype=<?php 
    echo $params["ctype"];
    ?>
';
	chart.setXMLFile(xmlFile);
	chart.write('<?php 
    echo $params["chartname"];
    ?>
');
	if("<?php 
    echo $refresh;
    ?>
"!="0" && "<?php 
    echo isMobile();
    ?>
"=="false")
		setInterval('refreshChart()',<?php 
    echo $refresh;
    ?>
);
	function refreshChart()
	{
		page='dchartdata.php?chartname=<?php 
    echo jsreplace($params["chartname"]);
    ?>
';
		params={
				action:'refresh',
				rndval:Math.random()
				};
		$.get(page,params,function(xml)
			{
				var arr = new Array();
				arr=xml.split("\n");
				for(i=0; i<arr.length;i+=2)
				{
					chart.removeSeries(arr[i]);
					chart.addSeries(arr[i+1]);
					chart.updatePointData(arr[i]+"_gauge",arr[i]+"_point",{value: arr[i+1]});
				}
				chart.refresh();
			});

	}
	//]]>
</script>
</div>
<?php 
}
Exemple #4
0
function GetChartXML($chartname)
{
    $strTableName = GetTableByShort($chartname);
    $settings = new ProjectSettings($strTableName);
    return $settings->getChartXml();
}
function xt_showchart($params)
{
	$width=700;
	$height=530;
	$chartPreview = "";
	if($params["chartPreview"])
		$chartPreview = "&chartPreview=true";
	if(isset($params["custom1"]))
		$width=$params["custom1"];
	if(isset($params["custom2"]))
		$height=$params["custom2"];
	if ($params["resize"])
	{
		$maxWidth = 400;
		$maxHeight = 280;
		$r = $maxWidth / $maxHeight;
		$r2 = $width / $height;
		if (($width > $maxWidth) || ($height > $maxHeight))
		{
			if ($r2 >= $r)
			{ // width
				$height = round( $height * $maxWidth / $width );
				$width = $maxWidth;
			}
			else
			{
				$width = round ( $width * $maxHeight / $height );
				$height = $maxHeight;
			}
		}
	}

	$showDetails = isset( $params["showDetails"] ) ? $params["showDetails"] :  true;

	$settings = new ProjectSettings(GetTableByShort($params["chartname"]));
	$refresh = $settings->getChartRefreshTime()*60000;
	if ($_SERVER["SERVER_PORT"]==443)
		$http = "https";
	else
		$http="http";	
?>
<div id='<?php echo $params["chartname"].$params["id"] ?>' style="width:<?php echo $width; ?>px;height:<?php echo $height; ?>px">
<?php if (!$params["singlePage"]) { ?>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
<?php global $useFlashChartLibrary; if (!$useFlashChartLibrary) { ?>
var	svgSupported = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
	AnyChart.renderingType = svgSupported ? anychart.RenderingType.SVG_PREFERRED : anychart.RenderingType.FLASH_PREFERRED;
<?php } else { ?>
	AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
<?php } ?>
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	
	chart.width = '<?php echo $width; ?>';
	chart.height = '<?php echo $height; ?>';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php echo $params["chartname"];?>';
	
	var xmlFile = '<?php echo GetTableLink("dchartdata")?>?chartname=<?php echo jsreplace($params["chartname"]).$chartPreview;?>';
	xmlFile += '&ctype=<?php echo $params["ctype"];?>';
	xmlFile += '&showDetails=<?php echo $showDetails;?>';
	xmlFile += '&hasFlash=' + AnyChart.platform.hasRequiredVersion;
	
	chart.setXMLFile(xmlFile);
	chart.write('<?php echo $params["chartname"].$params["id"];?>');
	<?php
	
	$chartname = jsreplace($params["chartname"]);
	if($params["ctype"]=="Gauge")
		$refrFunction="Runner.updateGaugeChart(\'".$chartname."\')";
	else
		$refrFunction="Runner.updateChart(\'".$chartname."\', ".($showDetails ? "true" : "false").")";
	
	if(!$useFlashChartLibrary && ( $params["ctype"]=="2DPie" || $params["ctype"]=="2DDoughnut" || $params["ctype"]=="Funnel" || $params["ctype"]=="OHLC" || $params["ctype"]=="Candle" ))
		$refresh="0";
	if($refresh!="0" && !isMobile())
		echo "setInterval('".$refrFunction."',".$refresh.");";
	?>
	//]]>
</script>
<?php } ?>
</div>
<?php
}
Exemple #6
0
function xt_showchart($params)
{
    $width = 700;
    $height = 530;
    $chartPreview = "";
    if ($params["chartPreview"]) {
        $chartPreview = "&chartPreview=true";
    }
    if (isset($params["custom1"])) {
        $width = $params["custom1"];
    }
    if (isset($params["custom2"])) {
        $height = $params["custom2"];
    }
    if ($params["dashResize"]) {
        if ($params["dashWidth"] && $params["dashHeight"]) {
            $width = $params["dashWidth"];
            $height = $params["dashHeight"];
        } elseif ($params["dashWidth"]) {
            $height = round($height * $params["dashWidth"] / $width);
            $width = $params["dashWidth"];
        } elseif ($params["dashHeight"]) {
            $width = round($width * $params["dashHeight"] / $height);
            $height = $params["dashHeight"];
        }
        // adjust the chart size to fit it in the dash cell
        $width *= 0.95;
        $height *= 0.95;
    } elseif ($params["resize"]) {
        $maxWidth = 400;
        $maxHeight = 280;
        $r = $maxWidth / $maxHeight;
        $r2 = $width / $height;
        if ($width > $maxWidth || $height > $maxHeight) {
            if ($r2 >= $r) {
                // width
                $height = round($height * $maxWidth / $width);
                $width = $maxWidth;
            } else {
                $width = round($width * $maxHeight / $height);
                $height = $maxHeight;
            }
        }
    }
    $showDetails = isset($params["showDetails"]) ? $params["showDetails"] : true;
    $settings = new ProjectSettings(GetTableByShort($params["chartname"]));
    $refresh = $settings->getChartRefreshTime() * 1000;
    if ($_SERVER["SERVER_PORT"] == 443) {
        $http = "https";
    } else {
        $http = "http";
    }
    ?>
<div id='<?php 
    echo $params["chartname"] . $params["id"];
    ?>
' style="width:<?php 
    echo $width;
    ?>
px;height:<?php 
    echo $height;
    ?>
px">
<?php 
    if (!$params["singlePage"]) {
        ?>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
<?php 
        global $useFlashChartLibrary;
        if (!$useFlashChartLibrary) {
            ?>
var	svgSupported = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
	AnyChart.renderingType = svgSupported ? anychart.RenderingType.SVG_PREFERRED : anychart.RenderingType.FLASH_PREFERRED;
<?php 
        } else {
            ?>
	AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
<?php 
        }
        ?>
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	
	chart.width = '<?php 
        echo $width;
        ?>
';
	chart.height = '<?php 
        echo $height;
        ?>
';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php 
        echo $params["chartname"];
        ?>
';
	
	var xmlFile = '<?php 
        echo GetTableLink("dchartdata");
        ?>
?chartname=<?php 
        echo jsreplace($params["chartname"]) . $chartPreview;
        ?>
';
	xmlFile += '&ctype=<?php 
        echo $params["ctype"];
        ?>
';
	xmlFile += '&showDetails=<?php 
        echo $showDetails;
        ?>
';
	xmlFile += '&hasFlash=' + AnyChart.platform.hasRequiredVersion;

<?php 
        if (isset($params["dash"]) && $params["dash"]) {
            ?>
	xmlFile += '&dashChart=<?php 
            echo $params["dash"];
            ?>
';
<?php 
        }
        ?>
	
<?php 
        if (isset($params["dashTName"]) && $params["dashTName"]) {
            ?>
	xmlFile += '&dashTName=<?php 
            echo $params["dashTName"];
            ?>
';
	xmlFile += '&dashElName=<?php 
            echo $params["dashElementName"];
            ?>
';
	xmlFile += '&pageId=<?php 
            echo $params["id"];
            ?>
';
	$.ajax( {
		type: "GET",
		url: xmlFile,
		dataType: "xml",
		success: function( xml ) {
			var $xml = $( xml );
			Runner.updateDetailsForDashboardChart( $xml.find( "detail_master_keys" ).text(), $xml.find( "detail_page_id" ).text() );
		}
	});
<?php 
        }
        ?>
	chart.setXMLFile(xmlFile);
	chart.write('<?php 
        echo $params["chartname"] . $params["id"];
        ?>
');
	<?php 
        $chartname = jsreplace($params["chartname"]);
        if ($params["ctype"] == "Gauge") {
            $refrFunction = "Runner.updateGaugeChart(\\'" . $chartname . "\\')";
        } else {
            $refrFunction = "Runner.updateChart(\\'" . $chartname . "\\', " . ($showDetails ? "true" : "false") . ", " . ($params["dash"] ? "true" : "false") . ")";
        }
        if (!$useFlashChartLibrary && ($params["ctype"] == "2DPie" || $params["ctype"] == "2DDoughnut" || $params["ctype"] == "Funnel" || $params["ctype"] == "OHLC" || $params["ctype"] == "Candle")) {
            $refresh = "0";
        }
        if ($refresh != "0" && !isMobile()) {
            echo "setInterval('" . $refrFunction . "'," . $refresh . ");";
        }
        ?>
	//]]>
</script>
<?php 
    }
    ?>
</div>
<?php 
}
 function CrossTableReport($rpt_array)
 {
     global $conn;
     $this->xml_array = $rpt_array;
     $arrdata = array();
     $arravgsum = array();
     $arravgcount = array();
     $group_y = array();
     $group_x = array();
     $sort_y = array();
     $grid_row = array();
     $avgsumx = array();
     $avgcountx = array();
     $this->total_summary = 0;
     $this->is_value_empty = true;
     $this->table_type = $rpt_array["table_type"];
     if (!$this->table_type) {
         $this->table_type = "project";
     }
     if ($rpt_array["fromWizard"]) {
         $this->fromWizard = true;
     }
     $this->TableName = $this->xml_array["tables"][0];
     $this->pSet = new ProjectSettings(GetTableByShort($this->TableName), PAGE_REPORT);
     $sum_x = $this->xml_array["group_fields"][count($this->xml_array["group_fields"]) - 1]["sum_x"];
     $sum_y = $this->xml_array["group_fields"][count($this->xml_array["group_fields"]) - 1]["sum_y"];
     $sum_total = $this->xml_array["group_fields"][count($this->xml_array["group_fields"]) - 1]["sum_total"];
     if (postvalue("group_func") != "") {
         $_SESSION[$this->TableName . "_group_func"] = postvalue("group_func");
     }
     if (postvalue("field") != "") {
         $_SESSION[$this->TableName . "_field"] = postvalue("field");
     }
     if (postvalue("axis_x") != "") {
         $_SESSION[$this->TableName . "_gr_x"] = postvalue("axis_x");
     }
     if (postvalue("axis_y") != "") {
         $_SESSION[$this->TableName . "_gr_y"] = postvalue("axis_y");
     }
     if (postvalue("rname") != "") {
         $_SESSION[$this->TableName . "_rname"] = postvalue("rname");
     }
     $crtableSQL = $this->getstrSQL();
     $rs = db_query($crtableSQL, $conn);
     while ($data = db_fetch_numarray($rs)) {
         if (!in_array($data[1], $group_y)) {
             $group_y[] = $data[1];
             $sort_y[] = count($sort_y);
         }
         if (!in_array($data[2], $group_x)) {
             $group_x[] = $data[2];
             $this->col_summary["data"][count($group_x) - 1]["col_summary"] = "&nbsp;";
             $this->col_summary["data"][count($group_x) - 1]["id_col_summary"] = "total_x_" . (count($group_x) - 1);
         }
         for ($i = 0; $i < count($group_y); $i++) {
             if ($group_y[$i] == $data[1]) {
                 $key_y = $i;
             }
         }
         for ($i = 0; $i < count($group_x); $i++) {
             if ($group_x[$i] == $data[2]) {
                 $key_x = $i;
                 $avgsumx[$key_x] = 0;
                 $avgcountx[$key_x] = 0;
             }
         }
         if (!$this->is_value_empty) {
             $arrdata[$key_y][$key_x] = $data[0];
             $arravgsum[$key_y][$key_x] = $data[3];
             $arravgcount[$key_y][$key_x] = $data[4];
         } else {
             $arrdata[$key_y][$key_x] = "&nbsp;";
         }
     }
     global $group_sort_y;
     $group_sort_y = $group_y;
     usort($sort_y, array("CrossTableReport", "sort_arr_y"));
     $group_func = $_SESSION[$this->TableName . "_group_func"];
     $idx_field = $_SESSION[$this->TableName . "_field"];
     if (!$idx_field) {
         $idx_field = 0;
     }
     if ($group_func == "") {
         $arr_value = $this->getSelectedValue();
         if (empty($arr_value)) {
             $field = $_SESSION['webreports']['group_fields'][0]["name"];
             $arr_value[] = $field;
         } else {
             $field = $arr_value[$idx_field];
         }
         $group_func = $this->getGroupFunction($field, "");
     } else {
         $arr_value = $this->getSelectedValue();
         $field = $arr_value[$idx_field];
         $isGroupFuncExists = false;
         foreach ($this->xml_array["totals"] as $key => $value) {
             if ($this->FullFieldName($value["name"], $value["table"]) == $field) {
                 if ($value["sum"] == true && $group_func == "sum") {
                     $isGroupFuncExists = true;
                     break;
                 }
                 if ($value["max"] == true && $group_func == "max") {
                     $isGroupFuncExists = true;
                     break;
                 }
                 if ($value["min"] == true && $group_func == "min") {
                     $isGroupFuncExists = true;
                     break;
                 }
                 if ($value["avg"] == true && $group_func == "avg") {
                     $isGroupFuncExists = true;
                     break;
                 }
             }
         }
         if (!$isGroupFuncExists) {
             $group_func = $this->getGroupFunction($arr_value[$idx_field], "");
         }
     }
     foreach ($sort_y as $key_y) {
         $value_y = $group_y[$key_y];
         $this->rowinfo[$key_y]["row_summary"] = "&nbsp;";
         $this->rowinfo[$key_y]["group_y"] = $this->getDisplayValue($this->index_field_y, $value_y);
         foreach ($group_x as $key_x => $value_x) {
             if (array_key_exists($key_y, $arrdata)) {
                 if (array_key_exists($key_x, $arrdata[$key_y]) && !$this->is_value_empty && !is_null($arrdata[$key_y][$key_x])) {
                     if ($group_func == "avg") {
                         $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"] = round($arrdata[$key_y][$key_x], 2);
                     } else {
                         $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"] = $arrdata[$key_y][$key_x];
                     }
                 } else {
                     $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"] = "&nbsp;";
                 }
                 $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["id_data"] = $key_y . "_" . $key_x;
             }
         }
         $this->rowinfo[$key_y]["id_row_summary"] = "total_y_" . $key_y;
     }
     foreach ($group_x as $key_x => $value_x) {
         if ($value_x != "") {
             $this->group_header["data"][$key_x]["gr_value"] = $this->getDisplayValue($this->index_field_x, $value_x);
         } else {
             $this->group_header["data"][$key_x]["gr_value"] = "&nbsp;";
         }
     }
     $this->total_summary = "&nbsp;";
     foreach ($this->rowinfo as $key_y => $obj_y) {
         $obj_x = $obj_y["row_record"]["data"];
         foreach ($obj_x as $key_x => $value) {
             if ($value["row_value"] !== "&nbsp;") {
                 switch ($group_func) {
                     case "sum":
                         if (!is_null($value["row_value"])) {
                             $this->rowinfo[$key_y]["row_summary"] += $value["row_value"];
                             $this->col_summary["data"][$key_x]["col_summary"] += $value["row_value"];
                             $this->total_summary += $value["row_value"];
                         }
                         break;
                     case "min":
                         if (($this->rowinfo[$key_y]["row_summary"] === "&nbsp;" || $value["row_value"] < $this->rowinfo[$key_y]["row_summary"]) && !is_null($value["row_value"])) {
                             $this->rowinfo[$key_y]["row_summary"] = $value["row_value"];
                         }
                         if (($this->col_summary["data"][$key_x]["col_summary"] === "&nbsp;" || $this->col_summary["data"][$key_x]["col_summary"] > $value["row_value"]) && !is_null($value["row_value"])) {
                             $this->col_summary["data"][$key_x]["col_summary"] = $value["row_value"];
                         }
                         if (($this->total_summary === "&nbsp;" || $this->total_summary > $value["row_value"]) && !is_null($value["row_value"])) {
                             $this->total_summary = $value["row_value"];
                         }
                         break;
                     case "max":
                         if ($this->rowinfo[$key_y]["row_summary"] === "&nbsp;" || $value["row_value"] > $this->rowinfo[$key_y]["row_summary"]) {
                             $this->rowinfo[$key_y]["row_summary"] = $value["row_value"];
                         }
                         if ($this->col_summary["data"][$key_x]["col_summary"] === "&nbsp;" || $this->col_summary["data"][$key_x]["col_summary"] < $value["row_value"]) {
                             $this->col_summary["data"][$key_x]["col_summary"] = $value["row_value"];
                         }
                         if ($this->total_summary === "&nbsp;" || $this->total_summary < $value["row_value"]) {
                             $this->total_summary = $value["row_value"];
                         }
                         break;
                     case "avg":
                         $this->rowinfo[$key_y]["avgsumy"] += $arravgsum[$key_y][$key_x];
                         $this->rowinfo[$key_y]["avgcounty"] += $arravgcount[$key_y][$key_x];
                         $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["avgsumx"] += $arravgsum[$key_y][$key_x];
                         $this->rowinfo[$key_y]["row_record"]["data"][$key_x]["avgcountx"] += $arravgcount[$key_y][$key_x];
                         break;
                 }
                 if ($sum_x == true && !$this->is_value_empty && !is_null($this->col_summary["data"][$key_x]["col_summary"])) {
                     if (is_numeric($this->col_summary["data"][$key_x]["col_summary"])) {
                         $this->col_summary["data"][$key_x]["col_summary"] = round($this->col_summary["data"][$key_x]["col_summary"], 2);
                     }
                 } else {
                     $this->col_summary["data"][$key_x]["col_summary"] = "&nbsp;";
                 }
             }
         }
         if ($sum_y == true && !$this->is_value_empty && !is_null($this->rowinfo[$key_y]["row_summary"])) {
             if (is_numeric($this->rowinfo[$key_y]["row_summary"])) {
                 $this->rowinfo[$key_y]["row_summary"] = round($this->rowinfo[$key_y]["row_summary"], 2);
             }
         } else {
             $this->rowinfo[$key_y]["row_summary"] = "&nbsp;";
         }
     }
     if ($group_func == "avg") {
         $total_sum = 0;
         $total_count = 0;
         foreach ($this->rowinfo as $key_y => $valuey) {
             if ($valuey["avgcounty"]) {
                 $this->rowinfo[$key_y]["row_summary"] = round($valuey["avgsumy"] / $valuey["avgcounty"], 2);
                 $total_sum += $valuey["avgsumy"];
                 $total_count += $valuey["avgcounty"];
             }
             foreach ($valuey["row_record"]["data"] as $key_x => $valuex) {
                 if ($valuex["avgcountx"]) {
                     $avgsumx[$key_x] += $valuex["avgsumx"];
                     $avgcountx[$key_x] += $valuex["avgcountx"];
                     $total_sum += $valuex["avgsumx"];
                     $total_count += $valuex["avgcountx"];
                 }
             }
         }
         foreach ($avgsumx as $key => $value) {
             if ($avgcountx[$key]) {
                 $this->col_summary["data"][$key]["col_summary"] = round($value / $avgcountx[$key], 2);
             }
         }
         if ($total_count) {
             $this->total_summary = $total_sum / $total_count;
         }
     }
     if ($sum_total == true && !$this->is_value_empty) {
         if (is_numeric($this->total_summary)) {
             $this->total_summary = round($this->total_summary, 2);
         }
     } else {
         $this->total_summary = "&nbsp;";
     }
     $prefix = "";
     if ($this->table_type != "db") {
         if (!$this->fromWizard) {
             $prefix = $this->xml_array["tables"][0] . "_";
         }
         $field = $arr_value[$idx_field];
     } else {
         $field = GoodFieldName($arr_value[$idx_field]);
     }
     if ($this->xml_array['totals'][$prefix . $field]['curr'] == true && count($this->rowinfo)) {
         foreach ($this->rowinfo as $arrkey => $arrfield) {
             foreach ($arrfield["row_record"]["data"] as $fieldkey => $fieldvalue) {
                 if (is_numeric($fieldvalue["row_value"])) {
                     $this->rowinfo[$arrkey]["row_record"]["data"][$fieldkey]["row_value"] = str_format_currency($fieldvalue["row_value"]);
                 }
             }
             if (is_numeric($arrfield["row_summary"])) {
                 $this->rowinfo[$arrkey]["row_summary"] = str_format_currency($arrfield["row_summary"]);
             }
         }
         if (is_numeric($this->total_summary)) {
             $this->total_summary = str_format_currency($this->total_summary);
         }
         foreach ($this->col_summary["data"] as $arrkey => $arrvalue) {
             if (is_numeric($arrvalue["col_summary"])) {
                 $this->col_summary["data"][$arrkey]["col_summary"] = str_format_currency($arrvalue["col_summary"]);
             }
         }
     }
 }
Exemple #8
0
<?php

include_once "include/dbcommon.php";
include_once "include/" . (isset($pdf) ? @$params["table"] : postvalue("table")) . "_variables.php";
if (!isset($gQuery)) {
    if (!isset($gSettings)) {
        $gSettings = new ProjectSettings(GetTableByShort(isset($pdf) ? @$params["table"] : postvalue("table")));
    }
    $gQuery = $gSettings->getSQLQuery();
}
$file = GetImageFromDB($gQuery, isset($pdf), isset($params) ? $params : array());
function GetChartXML($chartname)
{
    $strTableName = GetTableByShort($chartname);
    return GetTableData($strTableName, '.chartXml', '');
}
if( !checkTableName($tableName) )
{
	exit(0);
}

include("include/".$tableName."_variables.php");

if($pageType != PAGE_REGISTER && ( !isLogged() || !CheckSecurity(@$_SESSION["_".$tableName."_OwnerID"], "Search") ))
{ 
	$returnJSON = array("success" => false, "error" => "Error: You have not permissions to read the ".$tableName." table's data");
	echo "<div>".printJSON($returnJSON)."</div>";
	return;
}

$pSet = new ProjectSettings(GetTableByShort($tableName), $pageType);
$denyChecking = $pSet->allowDuplicateValues( $fieldName );

if( $denyChecking )
{
	$returnJSON = array("success" => false, "error" => "Duplicated values are allowed");
	echo "<div>".printJSON($returnJSON)."</div>";
	return;
}

$cipherer = new RunnerCipherer($tableName, $pSet);

if( $cipherer->isFieldEncrypted($fieldName) )
	$value = $cipherer->MakeDBValue($fieldName, $value, $fieldControlType, "", true);	
else
	$value = make_db_value($fieldName, $value, $fieldControlType, "", $tableName);
Exemple #11
0
<?php

@ini_set("display_errors", "1");
@ini_set("display_startup_errors", "1");
include "include/dbcommon.php";
$table = postvalue("table");
$pSet = new ProjectSettings(GetTableByShort($table), postvalue('pagetype'));
if (!checkTableName($table)) {
    exit(0);
}
include "include/" . $table . "_variables.php";
if (!isLogged() || !CheckSecurity(@$_SESSION["_" . $strTableName . "_OwnerID"], "Search")) {
    $returnJSON = array("success" => false, "error" => '');
    echo my_json_encode($returnJSON);
    return;
}
$id = postvalue("id");
$field = postvalue("field");
if (!$pSet->checkFieldPermissions($field)) {
    $returnJSON = array("success" => false, "error" => 'Error: You have not permission for read this text');
    echo my_json_encode($returnJSON);
    return;
}
if (!$gQuery->HasGroupBy()) {
    // Do not select any fields except current (full text) field.
    // If query has 'group by' clause then other fields are used in it and we may not simply cut 'em off.
    // Just don't do anything in that case.
    $gQuery->RemoveAllFieldsExcept($pSet->getFieldIndex($field));
}
$keysArr = $pSet->getTableKeys();
$keys = array();