diff options
author | Romain d'Alverny <rda@mageia.org> | 2013-03-05 11:15:36 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2013-03-05 11:15:36 +0000 |
commit | 602282aaf63b8649bf01a87785f2b1afa9cbdacd (patch) | |
tree | 213aa168c292c4336e7903d4c27be1c1932641a5 /en | |
parent | c3041735fa0921e1a78d9f5045aba58edcff87b8 (diff) | |
download | www-602282aaf63b8649bf01a87785f2b1afa9cbdacd.tar www-602282aaf63b8649bf01a87785f2b1afa9cbdacd.tar.gz www-602282aaf63b8649bf01a87785f2b1afa9cbdacd.tar.bz2 www-602282aaf63b8649bf01a87785f2b1afa9cbdacd.tar.xz www-602282aaf63b8649bf01a87785f2b1afa9cbdacd.zip |
numbers are displayed using ISO_31 format reco
Diffstat (limited to 'en')
-rw-r--r-- | en/about/reports/template.php | 29 | ||||
-rw-r--r-- | en/about/reports/template_lib.php | 28 |
2 files changed, 36 insertions, 21 deletions
diff --git a/en/about/reports/template.php b/en/about/reports/template.php index 24c2e5e53..5c0c04994 100644 --- a/en/about/reports/template.php +++ b/en/about/reports/template.php @@ -12,6 +12,21 @@ $_months = array( 10 => 'October', 11 => 'November', 12 => 'December' ); +/** + * Format numbers after ISO_31 recommandation, + * using the comma as decimal sep. + * See http://en.wikipedia.org/wiki/ISO_31-0#Numbers + * + * @param float $n decimal number + * @param char $dec_sep + * + * @return string +*/ +function _report_number_format($n, $dec_sep = ',') +{ + return str_replace('#', ' ', number_format($n, 2, $dec_sep, '#')); +} + $data = file($source_csv); $parsed = array(); @@ -213,7 +228,7 @@ $expenses_total = array_sum($expenses_monthly_summary[0]); $s .= sprintf('<tr class="%s"><td>%s</td><td class="money">%s</td></tr>', str_replace(' ', '-', $k), $k, - number_format(str_replace(',', '.', $w), 2, '.', ',')); + _report_number_format($w)); } $s .= '</table>'; echo $s; @@ -241,11 +256,11 @@ $expenses_total = array_sum($expenses_monthly_summary[0]); <tr> <th>Revenues</th> <td></td> - <td class="money"><?php echo number_format(str_replace(',', '.', $R['data']['total']), 2, '.', ',');?></td> + <td class="money"><?php echo _report_number_format($R['data']['total']);?></td> </tr> <tr> <th>Expenses</th> - <td class="money"><?php echo number_format(str_replace(',', '.', $expenses_total), 2, '.', ',');?></td> + <td class="money"><?php echo _report_number_format($expenses_total);?></td> <td></td> </tr> </tbody> @@ -257,10 +272,10 @@ $expenses_total = array_sum($expenses_monthly_summary[0]); ?> <td>Net Income</td> <td></td> - <td class="money"><?php echo number_format(str_replace(',', '.', $result), 2, '.', ','); ?></td> + <td class="money"><?php echo _report_number_format($result); ?></td> <?php else: ?> <td>Net Loss</td> - <td class="money"><?php echo number_format(str_replace(',', '.', -$result), 2, '.', ','); ?></td> + <td class="money"><?php echo _report_number_format(-$result); ?></td> <td></td> <?php endif; ?> </tr> @@ -280,7 +295,7 @@ $expenses_total = array_sum($expenses_monthly_summary[0]); $s = ''; foreach ($parsed['# Balance Sheet (incomplete) > ## Assets'] as $k => $v) { $v = str_replace(',', '.', $v); - $v = is_numeric($v) ? number_format($v, 2, '.', ',') : $v; + $v = is_numeric($v) ? _report_number_format($v) : $v; $s .= sprintf('<tr><td>%s</td><td class="money">%s</td></tr>', $k, $v); } echo $s; @@ -292,7 +307,7 @@ $expenses_total = array_sum($expenses_monthly_summary[0]); $s = ''; foreach ($parsed['# Balance Sheet (incomplete) > ## Liabilities'] as $k => $v) { $v = str_replace(',', '.', $v); - $v = is_numeric($v) ? number_format($v, 2, '.', ',') : $v; + $v = is_numeric($v) ? _report_number_format($v) : $v; $s .= sprintf('<tr><td>%s</td><td class="money">%s</td></tr>', $k, $v); } echo $s; diff --git a/en/about/reports/template_lib.php b/en/about/reports/template_lib.php index e2f749e50..37c101971 100644 --- a/en/about/reports/template_lib.php +++ b/en/about/reports/template_lib.php @@ -22,7 +22,7 @@ function get_expenses($v) $html .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td><td class="money">%s</td></tr>', date('Y-M-d', strtotime($line[0])), $line[1], $line[2], - number_format(str_replace(',', '.', $line[3]), 2, '.', ',')); + _report_number_format($line[3])); $cat = explode(':', $line[1]); $sums[$cat[0]] += $line[3]; @@ -32,7 +32,7 @@ function get_expenses($v) $html .= '</tbody> <tfoot><tr> <td colspan="3">Total:</td> - <td class="money">' . number_format(str_replace(',', '.', $sums['total']), 2, '.', ',') . '</td> + <td class="money">' . _report_number_format($sums['total']) . '</td> </tr></tfoot> </table>'; @@ -103,12 +103,12 @@ function get_revenues($v, $_months) <td class="money">%s</td></tr>', $_months[$line[0]], $line[1], - number_format(str_replace(',', '.', $line[2]), 2, '.', ','), - number_format(str_replace(',', '.', $line[3]), 2, '.', ','), - number_format(str_replace(',', '.', $line[4]), 2, '.', ','), - number_format(str_replace(',', '.', $line[5]), 2, '.', ','), - number_format(str_replace(',', '.', $line[6]), 2, '.', ','), - $line[1] > 0 ? number_format(str_replace(',', '.', $line[2] / $line[1]), 2, '.', ',') : '' + _report_number_format($line[2]), + _report_number_format($line[3]), + _report_number_format($line[4]), + _report_number_format($line[5]), + _report_number_format($line[6]), + $line[1] > 0 ? _report_number_format($line[2] / $line[1]) : '' ); $sums['count'] += $line[1]; @@ -128,12 +128,12 @@ function get_revenues($v, $_months) <td class="money">%s</td> <td class="money">%s</td></tr>', $sums['count'], - number_format(str_replace(',', '.', $sums['total']), 2, '.', ','), - number_format(str_replace(',', '.', $sums['check']), 2, '.', ','), - number_format(str_replace(',', '.', $sums['xfer']), 2, '.', ','), - number_format(str_replace(',', '.', $sums['paypal']), 2, '.', ','), - number_format(str_replace(',', '.', $sums['cash']), 2, '.', ','), - $sums['count'] > 0 ? number_format(str_replace(',', '.', $sums['total'] / $sums['count']), 2, '.', ',') : '' + _report_number_format($sums['total']), + _report_number_format($sums['check']), + _report_number_format($sums['xfer']), + _report_number_format($sums['paypal']), + _report_number_format($sums['cash']), + $sums['count'] > 0 ? _report_number_format($sums['total'] / $sums['count']) : '' ); $total_revenues = $sums['total']; $html .= '</tfoot></table>'; |