'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December' ); date_default_timezone_set(@date_default_timezone_get()); /** * 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 = ',') { $n = str_replace(',', '.', $n); $num = number_format($n, 2, $dec_sep, '#'); return str_replace('#', ' ', $num); } $data = file($source_csv); $parsed = array(); foreach ($data as $l) { if (trim($l) == ',,,,,,') continue; $l = str_getcsv(str_replace(array(',,,', ",\n"), '', $l)); if (substr($l[0], 0, 2) == '# ') { $tag = $l[0]; $parent = $tag; } elseif (substr($l[0], 0, 2) == '##') { $tag = $parent . ' > ' . $l[0]; } else { $parsed[$tag][] = $l; } } foreach ($parsed as $tag => $values) { $val2 = array(); $tag2 = strtolower($tag); $teststr = strlen($tag) > 12 ? substr($tag2, 0, 13) : null; foreach ($values as $v) { if ($tag2 == "# head" || $teststr == "# account bal" || $teststr == "# income stat" || $teststr == "# balance she" || $tag2 == '## expenses' || $tag2 == '## revenues' || $tag2 == '## liabilities' || $tag2 == '## assets') { $val2[$v[0]] = $v[1]; } else { $val2[] = $v; } } $parsed[$tag] = $val2; } $flow = array(); $list = array_fill(1, 12, 0); $count = array_fill(1, 12, 0); $tmp = $parsed['# Expenses details > ## More details']; array_shift($tmp); foreach ($tmp as $line) { if (count($line) < 4) continue; $month = date('n', strtotime($line[0])); $list[$month] += $line[3]; // amount $count[$month] += 1; } $expenses_monthly_summary = array($list, $count); $flow = array( 'expenses' => $list, 'expenses_op' => $count, 'revenue' => null, 'revenue_op' => null ); $list = array(); $count = array(); // FIXME take ## Other revenues lines into account. foreach ($parsed['# Income details > ## Donations monthly summary'] as $line) { if (count($line) < 3) continue; $list[] = $line[2]; $count[] = $line[1]; } unset($list[0]); unset($list[13]); unset($count[0]); unset($count[13]); $flow['revenue'] = $list; $flow['revenue_op'] = $count; include 'template_lib.php'; $R = get_revenues($parsed['# Income details > ## Donations monthly summary'], $_months); $expenses_total = array_sum($expenses_monthly_summary[0]); ?> Mageia.org <?php echo $year; ?> Financial Report

Activity Reports » Financial Report

Cash flow


Income statement

0): ?>
Revenues
Expenses
Net Income Net Loss

Expenses

## More details']); echo $E['html']; ?>

Income, donations

Return to top