ec5ed2ed870b5374ab2c05502621d0c161c3c2d8
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 6 years ago

1) <?php
2) 
3) require_role(ROLE_SYSADMIN);
4) 
5) $title = 'Report';
6) 
7) 
8) $year = date("Y")-1;
9) 
10) $typeresult = db_query("SELECT id, description FROM buchhaltung.types");
Bernd Wurst Korrekte Dortierung der Rep...

Bernd Wurst authored 6 years 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", array(":from" => $year."-01-01", ":to" => $year."-12-31"));
Bernd Wurst Neues Modul für unsere Buch...

Bernd Wurst authored 6 years ago

12) 
13) $types = array();
14) $data = array();
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 5 years ago

29)     $net = $line['amount'];
30)     if ($line['gross'] == 1 && $line['tax_rate'] > 0) {
31)         $net = $net / (1.0+($line['tax_rate']/100));
32)     }
33)     if ($line['direction'] == 'out') {
34)         $net = -$net;
35)     }
36)     $ust = $net * ($line['tax_rate']/100);
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']];
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");