354c05a4ddd678c49bcbba458bffa7d13482139a
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 7 years ago

1) <?php
2) 
3) require_role(ROLE_SYSADMIN);
4) 
5) $title = 'Report';
6) 
7) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

8) $year = date("Y") - 1;
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 7 years ago

9) 
10) $typeresult = db_query("SELECT id, description FROM buchhaltung.types");
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

11) $dataresult = db_query("SELECT id, date, description, invoice_id, direction, type, amount, tax_rate, gross FROM buchhaltung.transactions WHERE date BETWEEN :from and :to ORDER BY date", [":from" => $year . "-01-01", ":to" => $year . "-12-31"]);
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 7 years ago

12) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

13) $types = [];
14) $data = [];
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 7 years ago

15) while ($t = $typeresult->fetch()) {
16)     $types[$t['id']] = $t['description'];
17) }
18) 
19) while ($line = $dataresult->fetch()) {
20)     $data[] = $line;
21) }
22) 
23) 
24) output("Journal für $year (01.01.$year-31.12.$year, sortiert nach Datum)");
25) output("<h3>$t</h3>");
26) output("<table>");
27) 
28) foreach ($data as $line) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

29)     $net = $line['amount'];
30)     if ($line['gross'] == 1 && $line['tax_rate'] > 0) {
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

31)         $net = $net / (1.0 + ($line['tax_rate'] / 100));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

32)     }
33)     if ($line['direction'] == 'out') {
34)         $net = -$net;
35)     }
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

36)     $ust = $net * ($line['tax_rate'] / 100);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

37)     $gross = $net + $ust;
38)     $net = str_replace('.', ',', sprintf('%.2f €', $net));
39)     $ust = str_replace('.', ',', sprintf('%.2f €', $ust));
40)     $gross = str_replace('.', ',', sprintf('%.2f €', $gross));
41)     $typetext = $types[$line['type']];
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

42)     output("<tr><td>" . $line['date'] . "</td><td>" . $typetext . "</td><td>" . $line['description'] . "</td><td style=\"text-align: right;\">" . $net . "</td><td style=\"text-align: right;\">" . $ust . "</td><td style=\"text-align: right;\">" . $gross . "</td></tr>\n");