This topic is locked

two decimals in report

6/18/2012 8:00:04 AM
PHPRunner General questions
D
droogers author

Hello, In phprunner I have made a crosstab report. The field total has now a lot of decimals. I want it to have two decimals. How do I do this ? The field total in my query has already two decimals.

C
cgphp 6/19/2012

In the "Before display" of the report, enter this code:

$xt->assign("total_field_name", number_format($xt->getvar("total_field_name"),2,'.',''));


Replace total_field_name with the real name of the total field.

J
Jane 6/20/2012

Hi,
you can do the following:

  • open generated classes\crosstab_report.php file,
  • find this code:

if(array_key_exists($key_x,$arrdata[$key_y]) && !$this->is_value_empty && !is_null($arrdata[$key_y][$key_x]))

if($group_func=="avg")

$this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"]=round($arrdata[$key_y][$key_x],2);

else

$this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"]=$arrdata[$key_y][$key_x];



and replace it with this one:

if(array_key_exists($key_x,$arrdata[$key_y]) && !$this->is_value_empty && !is_null($arrdata[$key_y][$key_x]))

if($group_func=="avg")

$this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"]=round($arrdata[$key_y][$key_x],2);

else

$this->rowinfo[$key_y]["row_record"]["data"][$key_x]["row_value"]=round($arrdata[$key_y][$key_x],2);