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;
}
	
	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.min.js").'"></script>
	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.dimensions.pack.js").'"></script>
	<script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.easing.js").'"></script>
    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery.fancybox.pack.js").'"></script>
    <script type="text/javascript" src="'.GetRootPathForResources("include/js/jquery-ui.js").'"></script>
	<script type="text/javascript" src="'.GetRootPathForResources("include/js/json.js").'"></script>
'."\r\n";

$xt->assign("h_includes", $h_includes);

$table_selected = @$_SESSION['webreports']['tables'][0];
$xt->assign("table_selected", runner_htmlspecialchars($table_selected));

$fields_table_selected = "";
$arr_fields = WRGetFieldsList($table_selected);
foreach ($arr_fields as $fld_name) {
	$fields_table_selected .= $fld_name.", ";
}
$fields_table_selected = substr($fields_table_selected,0,strlen($fields_table_selected)-2);
$xt->assign("fields_table_selected", $fields_table_selected);

$arr_rel = $_SESSION['webreports']['table_relations'];
if ( !empty( $arr_rel ) )
	$arr_relations = array_slice(explode("@END@", $arr_rel["relations"]), 0, -1);


$tables = "";
$b_includes .= "
<script type='text/javascript'>
var left_wrapper = '".$strLeftWrapper."';