function GetGroupDisplay($field, $value) {
    global $locale_info, $rpt_array, $tbl, $fields_type;
    for ($i = 0; $i < count($rpt_array['group_fields']) - 1; $i++){
	$arr = $rpt_array['group_fields'][$i];
	foreach ($rpt_array['totals'] as $fld){
	    if ($arr['name'] == fldname($fld)) {
		if (!is_wr_custom())
		    $ftype = WRGetFieldType($fld['table'] . "." . $fld['name']);
		else
		    $ftype = $fields_type[$fld['name']];
		if ($field == $arr['name']) {
		    if ($arr['int_type'] == 0) {
			$prefix = "";
			if (!is_wr_db())
			    $prefix = $rpt_array["tables"][0] . "_";
			else
			    $field = GoodFieldName($field);
			if ($rpt_array['totals'][$prefix . $field]['curr'] == "true")
			    return str_format_currency($value);
			else
			    return $value;
		    } elseif (IsNumberType($ftype)) {
			$start = $value - ($value % $arr['int_type']);
			$end = $start + $arr['int_type'];
			$prefix = "";
			if (!is_wr_db())
			    $prefix = $rpt_array["tables"][0] . "_";
			else
			    $field = GoodFieldName($field);
			if ($rpt_array['totals'][$prefix . $field]['curr'] == "true")
			    return str_format_currency($start) . " - " . str_format_currency($end);
			else
			    return $start . " - " . $end;
		    } elseif (IsCharType($ftype)) {
			return substr($value, 0, $arr['int_type']);
		    } elseif (IsDateFieldType($ftype)) {
			$tm = db2time($value);
			if (!count($tm))
			    return "";
			if ($arr['int_type'] == 1) { // DATE_INTERVAL_YEAR
			    return $tm[0];
			} elseif ($arr['int_type'] == 2) { // DATE_INTERVAL_QUARTER
			    return $tm[0] . "/Q" . floor(($tm[1] - 1) / 4 + 1);
			} elseif ($arr['int_type'] == 3) { // DATE_INTERVAL_MONTH
			    return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0];
			} elseif ($arr['int_type'] == 4) { // DATE_INTERVAL_WEEK
			    $start = getweekstart($tm);
			    $end = adddays($start, 6);
			    return format_shortdate($start) . " - " . format_shortdate($end);
			} elseif ($arr['int_type'] == 5) { // DATE_INTERVAL_DAY
			    return format_shortdate($tm);
			} elseif ($arr['int_type'] == 6) { // DATE_INTERVAL_HOUR
			    $tm[4] = 0;
			    $tm[5] = 0;
			    return str_format_datetime($tm);
			} elseif ($arr['int_type'] == 7) { // DATE_INTERVAL_MINUTE
			    $tm[5] = 0;
			    return str_format_datetime($tm);
			} else {
			    return str_format_datetime($tm);
			}
		    }
		}
	    }
	}
    }
}
$ngFieldNames=array();
$arr_page_order_fields=array();
$arr_page_order_fields["data"]=array();
$arr_not_group_fields=array();

for ( $i=0; $i < count($xml_array['group_fields'])-1; $i++ ) {
	$aGroupFields[] = $xml_array['tables'][0]."_".$xml_array['group_fields'][$i]['name'];
}


$aTotFields=array();


foreach ( $inspect_fields as $fld ) {
	if(is_wr_db())
		$fld_type=WRGetFieldType($fld['table'].".".$fld['name']);
	elseif(is_wr_custom())
		$fld_type=WRCustomGetFieldType($fld['table'],$fld['name']);
	else
		$fld_type=GetFieldType($fld['name'],$fld['table']);	
	
	if ( !IsBinaryType($fld_type)) {
		$aTotFields[] = $fld['table']."_".$fld['name'];
	}
}

$ngFieldNames = array_diff( $aTotFields, $aGroupFields );


$arr_alias = array();
foreach ( $aGroupFields as $gr_name  ) {
Example #3
0
 protected function getFieldType($field)
 {
     if ($this->table_type == "db") {
         $ftype = WRGetFieldType($this->FullFieldName($field));
     } elseif ($this->table_type == "project") {
         $ftype = $this->pSet->getFieldType($field);
     } else {
         $fields_type = WRGetAllCustomFieldType();
         $ftype = $fields_type[$field];
     }
     return $ftype;
 }
Example #4
0
function WRprepare_for_db($field, $value, $table = "")
{
    $type = WRGetFieldType($table . "." . $field);
    if (is_array($value)) {
        $value = combinevalues($value);
    }
    if (($value === "" || $value === FALSE) && !IsCharType($type)) {
        return "";
    }
    if (IsDateFieldType($type)) {
        $value = localdatetime2db($value);
    }
    return $value;
}
arr_color["22"]="A52A2A";
arr_color["23"]="006400";
arr_color["24"]="6495ED";
'."\r\n";
$b_includes .= 'fld_types = new Array();'."\r\n";

if(is_wr_custom())
{
	$fields_type=array();
	$fields_type=WRGetAllCustomFieldType();
}

foreach ($group_fields as $fld) {
	if(!is_wr_custom())
		$type = WRGetFieldType($fld);
	else
		$type = $fields_type[$fld];

	if ( IsNumberType( $type ) ) {
		$b_includes .= "fld_types['" . jsreplace($fld) . "'] = \"number\";"."\r\n";
	} elseif ( IsCharType( $type ) ) {
		$b_includes .= "fld_types['" . jsreplace($fld) . "'] = \"string\";"."\r\n";
	} elseif ( IsDateFieldType( $type ) ) {
		$b_includes .= "fld_types['" . jsreplace($fld) . "'] = \"date\";"."\r\n";
	}
}

if (is_wr_db()) {
	$b_includes .= '
	var NEXT_PAGE_URL = "'.GetTableLink("webreport4").'",
Example #6
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;
            }
        }
    }
}
	exit();

//	security - end

//	construct sql

$keys = DBGetTableKeys($table);
if(!count($keys))
	exit();
$strkeywhere = "";
foreach($keys as $idx=>$k)
{
	if(strlen($strkeywhere))
		$strkeywhere.=" and ";
	$strkeywhere.=AddTableWrappers($table).".".AddFieldWrappers($k)."=";
	$type=WRGetFieldType($table.".".$k);
	if(NeedQuotes($type))
		$strkeywhere.=db_prepare_string(postvalue("key".($idx+1)));
	else
	{
		$value=postvalue("key".($idx+1));
		$strvalue = (string)$value;
		$strvalue = str_replace(",",".",$strvalue);
		if(is_numeric($strvalue))
			$value=$strvalue;
		else
			$value=0;
		$strkeywhere.=$value;
	}
}
 function getDisplayValue($index, $value)
 {
     global $locale_info;
     $field = $this->xml_array["group_fields"][$index]["name"];
     if ($value == "" || is_null($value)) {
         return "";
     }
     if ($this->table_type == "db") {
         $ftype = WRGetFieldType($this->FullFieldName($field));
     } elseif ($this->table_type == "project") {
         $ftype = GetFieldType($field, "");
     } else {
         $fields_type = WRGetAllCustomFieldType();
         $ftype = $fields_type[$field];
     }
     $arr = array();
     $arr = $this->xml_array["group_fields"];
     for ($i = 0; $i < count($arr) - 1; $i++) {
         if ($field == $arr[$i]["name"] && $index == $i) {
             $int_type = $arr[$i]["int_type"];
             break;
         }
     }
     if ($int_type == 0) {
         return $value;
     } elseif (IsNumberType($ftype)) {
         $start = $value - $value % $int_type;
         $end = $start + $int_type;
         return $start . " - " . $end;
     } elseif (IsCharType($ftype)) {
         return substr($value, 0, $int_type);
     } elseif (IsDateFieldType($ftype)) {
         $dvalue = substr($value, 0, 4) . '-' . substr($value, 4, 2) . '-' . substr($value, 6, 2);
         if (strlen($value) == 10) {
             $dvalue .= " " . substr($value, 8, 2) . "00:00";
         } elseif (strlen($value) == 12) {
             $dvalue .= " " . substr($value, 8, 2) . ":" . substr($value, 10, 2) . ":00";
         }
         $tm = db2time($dvalue);
         if (!count($tm)) {
             return "";
         }
         if ($int_type == 1) {
             // DATE_INTERVAL_YEAR
             return $tm[0];
         } elseif ($int_type == 2) {
             // DATE_INTERVAL_QUARTER
             return $tm[0] . "/Q" . $tm[1];
         } elseif ($int_type == 3) {
             // DATE_INTERVAL_MONTH
             return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0];
         } elseif ($int_type == 4) {
             // DATE_INTERVAL_WEEK
             $dates = $this->getDatesByWeek($tm[1] + 1, $tm[0]);
             return format_shortdate(db2time($dates[0])) . ' - ' . format_shortdate(db2time($dates[1]));
         } elseif ($int_type == 5) {
             // DATE_INTERVAL_DAY
             return format_shortdate($tm);
         } elseif ($int_type == 6) {
             // DATE_INTERVAL_HOUR
             $tm[4] = 0;
             $tm[5] = 0;
             return str_format_datetime($tm);
         } elseif ($int_type == 7) {
             // DATE_INTERVAL_MINUTE
             $tm[5] = 0;
             return str_format_datetime($tm);
         } else {
             return str_format_datetime($tm);
         }
     }
 }
	$adClass = "active";

	$field=$arr['field'];
	if (is_wr_db()) 
		$field=$arr['table'].".".$field;

	if ( !empty($aSelGroupFields) && $is_crosstable_report!="true") {
		if ( in_array( $field, $aSelGroupFields ) ) {
			$disabled = "disabled";
			$class = "inactive";
			$blobClass = "";
		}
	}
	
	if (!is_wr_custom()) 
		$field_type=WRGetFieldType( $arr['table'].".".$arr['field']);
	else
		$field_type=$fields_type[$arr['field']];
		
	if(is_wr_custom())
		$arr['table']=$table_name;
	
	if ( IsBinaryType( $field_type ) )  {
		$blobDisabled = "disabled";
		$class = "";
		$blobClass = "inactive";
		$adClass = "inactive";
		$blobCheck = "";
	}

	if ( $class == "active" && $blobClass == "active" ) {