-
Notifications
You must be signed in to change notification settings - Fork 0
/
costs_tenant.php
71 lines (66 loc) · 3.11 KB
/
costs_tenant.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
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
<?php
include 'inc/dbconnect.inc.php';
include 'inc/html_functions.inc.php';
PrintHtmlHeader("Nebenkostenabrechnung - Kosten pro Mieter");
PrintHtmlTopNavigation();
?>
<div class="inhalt">
<h2>Verwalten - Kosten pro Mieter</h2>
<?php
$query_tenant = 'SELECT
tenant.id, tenant.name, tenant.persons,
DATE_FORMAT(tenant.entry, \'%d.%m.%Y\') AS entry,
DATE_FORMAT(tenant.extract, \'%d.%m.%Y\') AS extract,
apartment.name AS apartment_name
FROM
tenant
INNER JOIN
apartment ON apartment.id = tenant.apartment_id
ORDER BY tenant.extract DESC';
$result_tenant = mysqli_query($db, $query_tenant);
while($row_tenant = mysqli_fetch_object($result_tenant)) {
echo '<table>
<caption>' . $row_tenant->name . ' - ' .
$row_tenant->persons . ' Personen - ' .
$row_tenant->entry . ' - ' . $row_tenant->extract . ' - ' .
$row_tenant->apartment_name . '</caption>
<thead>
<tr>
<th id="year">Jahr</th>
<th id="usage">Zweck</th>
<th id="amount">Kosten</th>
<th id="change">Ändern</th>
<th id="change">Löschen</th>
</tr>
</thead>
<tfoot>
<tr>
<td headers="name" colspan="5">
<a href="#" onclick="fenster_param(\'costs_tenant_new\',\'' . $row_tenant->id . '\')">Neue Kosten pro Mieter erfassen</a>
</td>
</tr>
</tfoot>
<tbody>';
$query_costs = 'SELECT
costs_tenant.id, costs_tenant.year, costs_tenant.usage, costs_tenant.amount
FROM
costs_tenant
WHERE costs_tenant.tenant_id = ' . $row_tenant->id . '
ORDER BY costs_tenant.year DESC, costs_tenant.usage ASC';
$result_costs = mysqli_query($db, $query_costs);
while($row_costs = mysqli_fetch_object($result_costs)) {
echo "<tr>\n";
echo '<td headers="year">' . $row_costs->year . "</td>\n";
echo '<td headers="usage">' . $row_costs->usage . "</td>\n";
echo '<td headers="amount" class="right">' . number_format($row_costs->amount, 2, ',', '') . "€</td>\n";
echo '<td headers="change"><a href="#" onclick="fenster_param(\'costs_tenant_change\', \'' . $row_costs->id . "')\">Ändern</a></td>\n";
echo '<td headers="delete"><a href="#" onclick="fenster_param(\'costs_tenant_delete\', \'' . $row_costs->id . "')\">Löschen</a></td>\n</tr>\n";
}
echo '</tbody>
</table>';
}
mysqli_close($db);
?>
</div>
</body>
</html>