Example #1
0
function update_report_sort_fields()
{
    //	ensure all group fields are listed in the tables
    $root =& $_SESSION["webreports"];
    if (!$root["sort_fields"]) {
        return;
    }
    //	ensure all fields in reports are listed in the tables
    $tables = getReportTablesList();
    $changed = false;
    $arr_unset = array();
    foreach ($root["sort_fields"] as $idx => $fld) {
        $table = "";
        $field = "";
        if (is_wr_db()) {
            WRSplitFieldName($fld["name"], $table, $field);
        } else {
            $field = $fld["name"];
            $table = $root['tables'][0];
        }
        if (array_search($table, $tables) !== false) {
            $fields = WRGetFieldsList($table);
            if (array_search($field, $fields) !== false) {
                continue;
            }
        }
        //	remove $total if found
        $arr_unset[] = $idx;
    }
    foreach ($arr_unset as $idx => $fld) {
        unset($root["sort_fields"][$fld]);
    }
    //	make new array
    $newarr = array();
    //	add group fields
    foreach ($root["group_fields"] as $fld) {
        if ($fld["name"] == "Summary") {
            continue;
        }
        $newarr[] = array("name" => $fld["name"], "desc" => "false");
    }
    //	add the rest of fields
    $keys = array_keys($root["sort_fields"]);
    $j = count($newarr);
    foreach ($keys as $idx) {
        $found = false;
        foreach ($newarr as $nfld) {
            if ($nfld["name"] == $root["sort_fields"][$idx]["name"]) {
                $found = true;
                break;
            }
        }
        if ($found) {
            continue;
        }
        $newarr[$j] = $root["sort_fields"][$idx];
        $j++;
    }
    $root["sort_fields"] = $newarr;
}
Example #2
0
function update_report_totals()
{
    $root =& $_SESSION["webreports"];
    //	ensure all fields in reports are listed in the tables
    $tables = getReportTablesList();
    if (is_wr_custom()) {
        $fields = WRGetFieldsList('');
    }
    $arr_unset = array();
    foreach ($root["totals"] as $idx => $fld) {
        if (array_search($fld["table"], $tables) !== false || is_null($fld["table"]) && is_wr_custom()) {
            if (!is_wr_custom()) {
                $fields = WRGetFieldsList($fld["table"]);
            }
            if (array_search($fld["name"], $fields) !== false) {
                continue;
            }
        }
        //	remove $total if found
        $arr_unset[] = $idx;
    }
    foreach ($arr_unset as $idx => $fld) {
        unset($root["totals"][$fld]);
    }
    //	ensure all fields appear in the totals
    $all_fields = array();
    foreach ($tables as $t) {
        $fields = WRGetFieldsList($t);
        foreach ($fields as $f) {
            if (is_wr_db()) {
                $all_fields[] = $t . "." . $f;
            } else {
                $all_fields[] = $f;
            }
        }
    }
    //	ensure all series  fields appear in the totals
    foreach ($all_fields as $fieldItem) {
        $f = $fieldItem;
        $table = "";
        $fld = "";
        if (is_wr_db()) {
            WRSplitFieldName($f, $table, $fld);
        } else {
            $table = $tables[0];
            $fld = $f;
            $f = $table . "_" . $f;
        }
        if (array_key_exists(GoodFieldName($f), $root["totals"])) {
            continue;
        }
        $pSet = new ProjectSettings($table, PAGE_LIST);
        $root['totals'][GoodFieldName($f)] = array();
        $root['totals'][GoodFieldName($f)]["name"] = $fld;
        $root['totals'][GoodFieldName($f)]["table"] = $table;
        $root['totals'][GoodFieldName($f)]["label"] = $pSet->label($fld);
        $root['totals'][GoodFieldName($f)]["show"] = "true";
        $root['totals'][GoodFieldName($f)]["min"] = "false";
        $root['totals'][GoodFieldName($f)]["max"] = "false";
        $root['totals'][GoodFieldName($f)]["sum"] = "false";
        $root['totals'][GoodFieldName($f)]["avg"] = "false";
        $root['totals'][GoodFieldName($f)]["curr"] = "false";
        $root['totals'][GoodFieldName($f)]["search"] = "";
        $root['totals'][GoodFieldName($f)]["view_format"] = GetGenericViewFormat($table, $fld);
        $root['totals'][GoodFieldName($f)]["edit_format"] = GetGenericEditFormat($table, $fld);
        $root['totals'][GoodFieldName($f)]["display_field"] = $pSet->getDisplayField($fld);
        $root['totals'][GoodFieldName($f)]["linkfield"] = $pSet->getLinkField($fld);
        $root['totals'][GoodFieldName($f)]["show_thumbnail"] = $pSet->showThumbnail($fld);
        $root['totals'][GoodFieldName($f)]["need_encode"] = $pSet->NeedEncode($fld);
        $root['totals'][GoodFieldName($f)]["thumbnail"] = $pSet->getStrThumbnail($fld);
        $root['totals'][GoodFieldName($f)]["listformatobj_imgwidth"] = $pSet->getImageWidth($fld);
        $root['totals'][GoodFieldName($f)]["listformatobj_imgheight"] = $pSet->getImageHeight($fld);
        $root['totals'][GoodFieldName($f)]["hlprefix"] = $pSet->getLinkPrefix($fld);
        $root['totals'][GoodFieldName($f)]["listformatobj_filename"] = $pSet->getFilenameField($fld);
        $root['totals'][GoodFieldName($f)]["lookupobj_lookuptype"] = $pSet->getLookupType($fld);
        $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_customdispaly"] = $pSet->getDisplayField($fld);
        $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_table"] = $pSet->getLookupTable($fld);
        $root['totals'][GoodFieldName($f)]["editformatobj_lookupobj_where"] = GetLWWhere($fld, PAGE_REPORT);
    }
    $_SESSION["webreports"] = $root;
}
	if (count(GetUserGroups()) > 1) {
		$arr_reports = array();
		$arr_reports = GetReportsList();
		foreach ( $arr_reports as $rpt ) {
			if (( $rpt["owner"] != @$_SESSION["UserID"] || $rpt["owner"] == "") && $rpt["view"]==0 && $rpt_array['settings']['name']==$rpt["name"])
			{
				exit();
			}
		}
	}


	
$field="";
$table="";
WRSplitFieldName(postvalue("field"),$table,$field);
//	check if field is allowed to display
$show=false;
foreach($rpt_array["totals"] as $fld)
{
	if($fld["table"]==$table && $fld["name"]==$field)
	{
		if($fld["show"])
			$show=true;
		break;
	}
}
if(!$show)
	exit();

//	security - end