-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.php
37 lines (33 loc) · 866 Bytes
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// zaumbaun der posts nach monat
function buildColumn($posts, $id) {
$res = array();
foreach ($posts as $post) {
$month = date("F Y", strtotime ($post['date']));
if (!key_exists($month, $res))
$res[$month] = array();
$res[$month][] = $post;
}
// calculate sums
$sums = array();
foreach($res as $m => $vals) {
$sums[$m] = 0;
foreach($vals as $val) {
if ($val['both'])
$sums[$m] += $val['value'] / 2;
else
$sums[$m] += $val['value'];
}
$sums[$m] = sprintf("%.2f", $sums[$m]);
}
// build view
$columnTemplate = new View();
$columnTemplate->id = $id;
if ($id == 1) $other = "Sarah";
else $other = "Vielieb";
$columnTemplate->other = $other;
$columnTemplate->posts = $res;
$columnTemplate->sums = $sums;
return $columnTemplate->render('templates/column.php');
}
?>