示例#1
0
function get_chart_groupbyseries_fields(&$arr_data_series, &$arr_label_series)
{
    $root =& $_SESSION['webcharts'];
    $arr_data_series = array();
    $arr_label_series = array();
    for ($i = 0; $i < count($root['group_by_condition']) - 1; $i++) {
        $arr =& $root['group_by_condition'][$i];
        $field = $arr["field_opt"];
        $strLabel = WRChartLabel($field);
        $isLabel = false;
        $isData = false;
        if ($arr["group_by_value"] != "-1" && $arr["group_by_value"] != "GROUP BY") {
            $field = $arr["group_by_value"] . "(" . $field . ")";
            $isData = true;
            $isLabel = true;
        } else {
            if ($arr["group_by_value"] == "GROUP BY") {
                $type = WRGetFieldType($field);
                if (IsNumberType($type)) {
                    $isData = true;
                }
                $isLabel = true;
            }
        }
        $ret = array("field" => $field, "label" => $strLabel);
        if ($isLabel) {
            $arr_label_series[] = $ret;
        }
        if ($isData) {
            $arr_data_series[] = $ret;
        }
    }
    if (!count($arr_data_series)) {
        $arr_data_series = $arr_label_series;
    }
}
示例#2
0
function set_default_chart_parameter($idx, $labelMode, $addLabel)
{
    $root =& $_SESSION["webcharts"];
    $arr_join_tables = getChartTablesList();
    if (is_groupby_chart()) {
        for ($i = 0; $i < count($root["group_by_condition"]) - 1; $i++) {
            if (!$root["group_by_condition"][$i]["group_by_value"]) {
                continue;
            }
            $type = WRGetFieldType($root["group_by_condition"][$i]["field_opt"]);
            $grvalue = $root["group_by_condition"][$i]["group_by_value"];
            if (!$labelMode && (IsNumberType($type) || $grvalue != "GROUP BY") || $labelMode) {
                $table = "";
                $field = "";
                WRSplitFieldName($root["group_by_condition"][$i]["field_opt"], $table, $field);
                $root["parameters"][$idx]["name"] = $field;
                $root["parameters"][$idx]["table"] = $table;
                if ($grvalue != "GROUP BY") {
                    $root["parameters"][$idx]["agr_func"] = $grvalue;
                }
                if ($addLabel) {
                    $root["parameters"][$idx]["label"] = $field;
                }
                break;
            }
        }
    } else {
        foreach ($arr_join_tables as $tbl) {
            if (!$labelMode) {
                $fields = GetNumberFieldsList($tbl);
            } else {
                $fields = WRGetNBFieldsList($tbl);
            }
            if (count($fields)) {
                $root["parameters"][$idx]["name"] = $fields[0];
                $root["parameters"][$idx]["table"] = $tbl;
                $root["parameters"][$idx]["agr_func"] = "";
                if ($addLabel) {
                    $root["parameters"][$idx]["label"] = WRChartLabel($tbl . "." . $fields[0]);
                }
                break;
            }
        }
    }
}