'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_fill(1, 12, 0);
$count = array_fill(1, 12, 0);
$tmp = $parsed['# Expenses details > ## More details'];
array_shift($tmp);
foreach ($tmp as $line) {
$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();
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;
include 'template_lib.php';
$R = get_revenues($parsed['# Income details > ## Donations monthly summary']);
$expenses_total = array_sum($expenses_monthly_summary[0]);
?>
Mageia.org Financial Report
Income statement
TODO: full income statement. For now, check details below.
Revenues |
|
|
Expenses |
|
|
0):
?>
Net Income |
|
|
Net Loss |
|
|
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
## More details']); echo $E['html']; ?>
Return to top