'January', 2 => 'February', 3 => 'March',
4 => 'April', 5 => 'May', 6 => 'June',
7 => 'July', 8 => 'August', 9 => 'September',
10 => 'October', 11 => 'November', 12 => 'December'
);
$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();
$count = array();
foreach ($parsed['# Expenses details > ## Monthly summary'] as $line) {
$list[] = $line[2];
$count[] = $line[1];
}
unset($list[0]);
unset($list[13]);
unset($count[0]);
unset($count[13]);
$flow = array(
'expenses' => $list,
'expenses_op' => $count,
'revenue' => null,
'revenue_op' => null
);
$list = array();
$count = array();
foreach ($parsed['# Income details > ## Donations monthly summary'] as $line) {
$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;
?>
Mageia.org Financial Report
Last updated on .
All amounts are in EURO.
';
foreach ($v as $k => $w) {
$s .= sprintf('
%s | %s |
',
$k, number_format(str_replace(',', '.', $w), 2, '.', ','));
}
$s .= '';
echo $s;
?>
Cash flow
Income statement
Revenues |
Expenses |
## Revenues'] as $k => $v) {
if (in_array($k, array('Total of revenues', 'Net Loss')))
continue;
$s .= sprintf('%s | %s | ',
$k, number_format(str_replace(',', '.', $v), 2, '.', ','));
}
echo $s;
?>
|
## Expenses'] as $k => $v) {
if (in_array($k, array('Total of expenses', 'Net Income')))
continue;
$s .= sprintf('%s | %s | ',
$k, number_format(str_replace(',', '.', $v), 2, '.', ','));
}
echo $s;
?>
|
Total of revenues |
## Revenues']['Total of revenues']), 2, '.', ','); ?> |
Total of expenses |
## Expenses']['Total of expenses']), 2, '.', ','); ?> |
|
Net Income |
## Expenses']['Net Income']), 2, '.', ','); ?> |
Balance sheet
Assets |
Liabilities |
## Assets'] as $k => $v) {
$v = str_replace(',', '.', $v);
$v = is_numeric($v) ? number_format($v, 2, '.', ',') : $v;
$s .= sprintf('%s | %s | ', $k, $v);
}
echo $s;
?>
|
## Liabilities'] as $k => $v) {
$v = str_replace(',', '.', $v);
$v = is_numeric($v) ? number_format($v, 2, '.', ',') : $v;
$s .= sprintf('%s | %s | ', $k, $v);
}
echo $s;
?>
|
Total Assets | |
Total Liabilities | |
Expenses
## Monthly summary'];
echo '
';
array_shift($v);
foreach ($v as $line) {
if ($line[0] == 'total')
continue;
echo sprintf('%s | %s | %s |
',
$_months[$line[0]], $line[1],
number_format(str_replace(',', '.', $line[2]), 2, '.', ','));
}
echo '
';
?>
Details
## More details'];
$line = array_shift($v);
echo sprintf('%s | %s | %s | %s | %s | %s |
',
$line[0], $line[1],
$line[2], $line[3],
$line[4],
$line[5]);
foreach ($v as $line) {
if (count($line) < 2)
continue;
echo sprintf('%s | %s | %s | %s | %s | %s |
',
$line[0], $line[1],
$line[2], $line[3],
$line[4],
number_format(str_replace(',', '.', $line[5]), 2, '.', ','));
}
?>
Income, donations
## Donations monthly summary'];
echo '
';
$line = array_shift($v);
echo sprintf('%s | %s |
%s | %s | %s | %s |
%s |
',
$line[0], $line[1], $line[2],
$line[3],
$line[4],
$line[5], $line[6]);
foreach ($v as $line) {
echo sprintf('%s | %s |
%s |
%s |
%s |
%s |
%s |
',
$_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, '.', ','));
}
echo '
';
?>
Feel free to contact us regarding this report.