Newer
Older
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
class bilanz{
private $db;
public function __construct(){
global $datenbank;
$this->db = $datenbank;
}
private function TCSS($row){
if($row < 0){
return 'table-danger';
}else{
return 'table-success';
}
}
public function ShowTable(){
$i = 1;
$aus = '
<table class="table" id="BilanzTable">
<thead>
<tr>
<th>#</th>
<th>Datum</th>
<th class="text-right">Einnahmen</th>
<th class="text-right">Ausgaben</th>
<th class="text-right">Bilanz</th>
<th></th>
</tr>
</thead>
<tbody>
';
foreach($this->db->get_results("SELECT SUM(ein) AS ges_ein, SUM(aus) AS ges_aus, datum FROM ". PREFIX . BILANZ ." GROUP BY datum ORDER BY datum DESC") AS $res){
$bilanz = $res->ges_ein-$res->ges_aus;
$aus .= '
<tr class="'. $this->TCSS($bilanz) .'">
<td>'. $i .'</td>
<td>'. date("d.m.Y", $res->datum) .'</td>
<td class="text-right">'. number_format($res->ges_ein,2,',','.') .'</td>
<td class="text-right">'. number_format($res->ges_aus,2,',','.') .'</td>
<td class="text-right">'. number_format($bilanz,2,',','.') .'</td>
<td class="text-center"><a href="?page=/bilanzsystem&TID='. $res->datum .'" class="btn btn-info btn-sm">Details</a></td>
</tr>
';
$i++;
}
$aus .= '</tbody></table>';
return $aus;
}
private function ShowDetails($gruppe,$date){
$aus = '
<table class="table table-hover">
<tr>
<th>Typ</th>
<th class="text-right">Einnahmen</th>
<th class="text-right">Ausgaben</th>
</tr>
';
foreach($this->db->get_results("SELECT * FROM ". PREFIX . BILANZ ." WHERE gruppe = '$gruppe' AND datum = '$date'") AS $res){
if($res->ein < $res->aus){ $css = 'table-danger';}else{ $css = 'table-success';}
$aus .= '
<tr class="'. $css .'">
<td>'. $res->name .'</td>
<td class="text-right">'. number_format($res->ein,2,',','.') .'</td>
<td class="text-right">'. number_format($res->aus,2,',','.') .'</td>
</tr>
';
}
return $aus.'</table>';
}
public function ShowDate($date){
if((int)$date){
$aus = array("head" => '', "body" => '');
$i = 1;
foreach($this->db->get_results("SELECT * FROM ". PREFIX . BILANZ ." WHERE datum = '". $date ."' GROUP BY gruppe") AS $res){
if($i == 1){ $aktive = 'active'; $show = 'show';}else{$aktive = ''; $show = '';}
$aus['head'] .= '
<a class="nav-link '. $aktive .'" id="nav-'. $res->id .'-tab" data-toggle="tab" href="#nav-'. $res->id .'" role="tab" aria-controls="nav-'. $res->id .'" aria-selected="true">'. $res->gruppe .'</a>
';
$aus['body'] .= '
<div class="tab-pane fade '. $show .' '. $aktive .'" id="nav-'. $res->id .'" role="tabpanel" aria-labelledby="nav-'. $res->id .'-tab">
'. $this->ShowDetails($res->gruppe,$date) .'
</div>
';
$i++;
}
return '
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
'. $aus['head'] .'
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
'. $aus['body'] .'
</div>
<a href="'. $_SERVER['HTTP_REFERER'] .'" class="btn btn-warning">Zurück</a>
';
}else{
return 'Falsche Zeitangabe';
}
}
}