public function showDBValue(&$data, $keylink) { $result = str_format_currency($data[$this->field]); if(!$this->container->forExport || $this->container->forExport && $this->container->forExport != "excel" && $this->container->forExport != "csv") { $result = runner_htmlspecialchars($result); } if($this->searchHighlight) { $result = $this->highlightSearchWord($result, false, $data[$this->field]); } return $result; }
function format_currency($val) { return str_format_currency($val); }
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 GetTotals($field, $value, $stype, $iNumberOfRows, $sFormat, $ptype) { global $strTableName; $pSet = new ProjectSettings($strTableName, $ptype); $days = 0; if ($stype == "AVERAGE") { if ($iNumberOfRows) { if ($sFormat == FORMAT_TIME) { if ($value) { $value = round($value / $iNumberOfRows, 0); $s = $value % 60; $value -= $s; $value /= 60; $m = $value % 60; $value -= $m; $value /= 60; $h = $value % 24; $value -= $h; $value /= 24; $d = $value; $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s)); } } else { $value = round($value / $iNumberOfRows, 2); } } else { return ""; } } if ($stype == "TOTAL") { if ($sFormat == FORMAT_TIME) { if ($value) { $s = $value % 60; $value -= $s; $value /= 60; $m = $value % 60; $value -= $m; $value /= 60; $h = $value % 24; $value -= $h; $value /= 24; $d = $value; $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s)); } } } $sValue = ""; $data = array($field => $value); if ($sFormat == FORMAT_CURRENCY) { $sValue = str_format_currency($value); } else { if ($sFormat == FORMAT_PERCENT) { $sValue = str_format_number($value * 100) . "%"; } else { if ($sFormat == FORMAT_NUMBER) { $sValue = str_format_number($value, $pSet->isDecimalDigits($field)); } else { if ($sFormat == FORMAT_CUSTOM && $stype != "COUNT") { include_once getabspath('classes/controls/ViewControlsContainer.php'); $viewControls = new ViewControlsContainer($pSet, $ptype); $sValue = $viewControls->showDBValue($field, $data); } else { $sValue = $value; } } } } if ($stype == "COUNT") { return $value; } if ($stype == "TOTAL") { return $sValue; } if ($stype == "AVERAGE") { return $sValue; } return ""; }
/** * @param &Array data * @return String */ public function getTextValue(&$data) { return str_format_currency($data[$this->field]); }
/** * Get axes displyed values * @param Number index * @param String value * @return String */ protected function getAxisDisplayValue($index, $value) { global $locale_info; if ($value == "" || is_null($value)) { return ""; } $groupFieldsData = $this->xml_array["group_fields"]; $field = $groupFieldsData[$index]["name"]; $int_type = $groupFieldsData[$index]["int_type"]; if ($this->fromWizard) { $control = $this->viewControls->getControl($field); } if ($int_type == 0) { // The 'Normal' interval is set if ($this->fromWizard) { $data = array($field => $value); return $control->showDBValue($data, ""); } if ($this->table_type != "db") { $fieldIdentifier = $this->xml_array["tables"][0] . "_" . $field; } else { $fieldIdentifier = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$fieldIdentifier]['curr'] == true) { return str_format_currency($value); } return xmlencode($value); } $ftype = $this->getFieldType($field); if (IsNumberType($ftype)) { $start = $value - $value % $int_type; $end = $start + $int_type; if ($this->fromWizard) { $dataStart = array($field => $start); $dataEnd = array($field => $end); return $control->showDBValue($dataStart, "") . " - " . $control->showDBValue($dataEnd, ""); } if ($this->table_type != "db") { $fieldIdentifier = $this->xml_array["tables"][0] . "_" . $field; } else { $fieldIdentifier = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$fieldIdentifier]['curr'] == true) { return str_format_currency($start) . " - " . str_format_currency($end); } return $start . " - " . $end; } if (IsCharType($ftype)) { return xmlencode(substr($value, 0, $int_type)); } if (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 ""; } switch ($int_type) { case 1: // DATE_INTERVAL_YEAR return $tm[0]; case 2: // DATE_INTERVAL_QUARTER return $tm[0] . "/Q" . $tm[1]; case 3: // DATE_INTERVAL_MONTH return @$locale_info["LOCALE_SABBREVMONTHNAME" . $tm[1]] . " " . $tm[0]; case 4: // DATE_INTERVAL_WEEK $dates = $this->getDatesByWeek($tm[1] + 1, $tm[0]); return format_shortdate(db2time($dates[0])) . ' - ' . format_shortdate(db2time($dates[1])); case 5: // DATE_INTERVAL_DAY return format_shortdate($tm); case 6: // DATE_INTERVAL_HOUR $tm[4] = 0; $tm[5] = 0; return str_format_datetime($tm); case 7: // DATE_INTERVAL_MINUTE $tm[5] = 0; return str_format_datetime($tm); default: return str_format_datetime($tm); } } return ""; }
function getDisplayValue($index, $value) { global $locale_info; $field = $this->xml_array["group_fields"][$index]["name"]; if ($value == "" || is_null($value)) { return ""; } $ftype = $this->getFieldType($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) { $prefix = ""; if ($this->table_type != "db") { if (!$this->fromWizard) { $prefix = $this->xml_array["tables"][0] . "_"; } } else { $field = $this->CrossGoodFieldName($field); } if ($this->xml_array['totals'][$prefix . $field]['curr'] == true) { return str_format_currency($value); } else { return $value; } } elseif (IsNumberType($ftype)) { $start = $value - $value % $int_type; $end = $start + $int_type; $prefix = ""; if ($this->table_type != "db") { if (!$this->fromWizard) { $prefix = $this->xml_array["tables"][0] . "_"; } } else { $field = $this->CrossGoodFieldName($field); } if ($this->xml_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, $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); } } }
public function showDBValue(&$data, $keylink) { return $this->checkForEncoding(str_format_currency($data[$this->field]), $keylink); }
function GetTotals($field, $value, $stype, $iNumberOfRows, $sFormat) { global $strTableName; $days = 0; if ($stype == "AVERAGE") { if ($iNumberOfRows) { if ($sFormat == FORMAT_TIME) { if ($value) { $value = round($value / $iNumberOfRows, 0); $s = $value % 60; $value -= $s; $value /= 60; $m = $value % 60; $value -= $m; $value /= 60; $h = $value % 24; $value -= $h; $value /= 24; $d = $value; $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s)); } } else { $value = round($value / $iNumberOfRows, 2); } } else { return ""; } } if ($stype == "TOTAL") { if ($sFormat == FORMAT_TIME) { if ($value) { $s = $value % 60; $value -= $s; $value /= 60; $m = $value % 60; $value -= $m; $value /= 60; $h = $value % 24; $value -= $h; $value /= 24; $d = $value; $value = ($d != 0 ? $d . 'd ' : '') . mysprintf("%02d:%02d:%02d", array($h, $m, $s)); } } } $sValue = ""; $data = array($field => $value); if ($sFormat == FORMAT_CURRENCY) { $sValue = str_format_currency($value); } else { if ($sFormat == FORMAT_PERCENT) { $sValue = str_format_number($value * 100) . "%"; } else { if ($sFormat == FORMAT_NUMBER) { $sValue = str_format_number($value, GetFieldData($strTableName, $field, "DecimalDigits", false)); } else { if ($sFormat == FORMAT_CUSTOM && $stype != "COUNT") { $sValue = GetData($data, $field, $sFormat); } else { $sValue = $value; } } } } if ($stype == "COUNT") { return $value; } if ($stype == "TOTAL") { return $sValue; } if ($stype == "AVERAGE") { return $sValue; } return ""; }