You are here

public function FrxControls::number in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 plugins/FrxControls.inc \FrxControls::number()
  2. 7 plugins/FrxControls.inc \FrxControls::number()
  3. 7.2 plugins/FrxControls.inc \FrxControls::number()
  4. 7.3 plugins/FrxControls.inc \FrxControls::number()
  5. 7.4 plugins/FrxControls.inc \FrxControls::number()

File

plugins/FrxControls.inc, line 93
contains various methods for extending report formating, layout, transformation and design.

Class

FrxControls
@file contains various methods for extending report formating, layout, transformation and design.

Code

public function number($value, $format_str, $teng) {
  $dec = 2;
  $dec_sep = '.';
  $th_sep = ',';
  if ($format_str && !trim($format_str, '9.,$')) {

    // Determine the decimal places.
    $dec_pos = strrpos($format_str, $dec_sep);
    if ($dec_pos) {
      $dec = strlen($format_str) - $dec_pos - 1;
    }
    else {
      $dec = 0;
      $dec_sep = '';
    }
  }
  if ($value && $this
    ->is_number($value)) {
    $value = number_format($value, $dec, $dec_sep, $th_sep);
  }
  return $value;
}