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); } } } } } } }
function cached_getweekstart($strtime) { global $cache_getweekstart; if (!isset($cache_getweekstart[$strtime])) { $date = cached_db2time($strtime); $res = getweekstart($date); $cache_getweekstart[$strtime] = $res; return $res; } else { return $cache_getweekstart[$strtime]; } }