01d168580c1be287606910d743dc2935b31fa8aa
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

16) 
17) require_once('session/start.php');
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

18) require_once('inc/icons.php');
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

19) 
20) require_once('invoice.php');
21) 
22) require_role(ROLE_CUSTOMER);
23) 
bernd Benutze überall title() sta...

bernd authored 13 years ago

24) title('Rechnungen');
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

25) 
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

26) $show_paid = (isset($_GET['paid']) && $_GET['paid'] == '1');
27) 
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

28) $invoices = my_invoices();
29) 
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

30) $first = true;
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

31) $invoices_to_show = array();
32) foreach ($invoices as $i) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

33)     if ($first || $show_paid || $i['bezahlt'] == 0) {
34)         $first = false;
35)         array_push($invoices_to_show, $i);
36)     }
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

37) }
38) 
39) if (count($invoices_to_show) == 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

40)     $error = 'Keine aktuelle Rechnung gefunden.';
41)     if (count($invoices) == 0) {
42)         $error = 'Bisher keine Rechnungen vorhanden.';
43)     }
44)     if ($show_paid) {
45)     }
46) 
47)     output('<p><em>'.$error.'</em></p>');
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

48) } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

49)     if ($show_paid) {
50)         output('<p>Hier können Sie Ihre bisherigen Rechnungen einsehen und herunterladen.</p>');
Bernd Wurst Vorgemerkte Lastschriften a...

Bernd Wurst authored 10 years ago

51)     } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

52)         output('<p>Hier sehen Sie Ihre neueste Rechnung. Ältere, bereits bezahlte Rechnungen können sie über den untenstehenden Link einblenden.</p>');
53)     }
54)     output('<table class="nogrid"><tr><th>Nr.</th><th>Datum</th><th>Gesamtbetrag</th><th>bezahlt?</th><th>Herunterladen</th></tr>');
55) 
56)     $odd = true;
57)     foreach ($invoices_to_show as $invoice) {
58)         $bezahlt = 'Nein';
59)         $class = 'unpaid';
60)         if ($invoice['bezahlt'] == 1) {
61)             $bezahlt = 'Ja';
62)             $class = 'paid';
63)         } else {
64)             $l = get_lastschrift($invoice['id']);
65)             if ($l) {
66)                 $bezahlt = 'Wird abgebucht<br/>am '.$l['buchungsdatum'];
67)                 $class = 'paid';
68)                 if ($l['status'] == 'rejected') {
69)                     $bezahlt  = 'Abbuchung zurückgewiesen';
70)                     $class = 'unpaid';
71)                 }
72)             }
Bernd Wurst Zeige Rechnungen zu rückgeb...

Bernd Wurst authored 9 years ago

73)         }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

74)         $odd = !$odd;
75)         $class .= ($odd ? " odd" : " even");
76)         output("<tr class=\"{$class}\"><td class=\"number\">".internal_link("html", $invoice['id'], "id={$invoice['id']}")."</td><td>{$invoice['datum']}</td><td class=\"number\">{$invoice['betrag']} €</td><td>{$bezahlt}</td><td>".internal_link("pdf", "<img src=\"{$prefix}images/pdf.png\" width=\"22\" height=\"22\" alt=\"PDF\"/>", "id={$invoice['id']}")."</td></tr>\n");
Bernd Wurst Offene Rechnungen fablich h...

Bernd Wurst authored 11 years ago

77)     }
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

78) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

79)     output('</table>');
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

80) }
81) 
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

82) if (! $show_paid) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

83)     $number = count($invoices) - count($invoices_to_show);
84)     if ($number > 0) {
85)         output('<p>'.internal_link('', other_icon('control_fastforward.png')." Zeige $number ältere Rechnungen", 'paid=1').'</p>');
86)     }
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

87) }
bernd Rechnungen unterhalb von "Ü...

bernd authored 14 years ago

88) 
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

89) 
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

90) output('<h3>Bezahlung per Lastschrift</h3>');
91) 
92) output('<p>Gerne buchen wir Ihre Beiträge von Ihrem Konto ab. Bei Lastschriftzahlung werden Sie durch Zustellung einer Rechnung informiert, die Abbuchung erfolgt dann eine Woche später.</p>');
93) 
94) $mandate = get_sepamandate();
95) if ($mandate) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

96)     output('<p>Folgende Mandate sind bisher erteilt worden (momentan gültiges Mandat ist Fett dargestellt):</p>
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

97) <table>
98) <tr><th>Mandatsreferenz</th><th>IBAN</th><th>Gültigkeit</th></tr
99) ');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

100)     foreach ($mandate as $m) {
101)         $gueltig = 'ab '.$m['gueltig_ab'];
102)         if ($m['gueltig_ab'] < date('Y-m-d')) {
103)             $gueltig = 'seit '.$m['gueltig_ab'];
104)         }
105)         if ($m['gueltig_bis']) {
106)             $gueltig = $m['gueltig_ab'].' - '.$m['gueltig_bis'];
107)         }
108)         $aktiv = false;
109)         if ($m['gueltig_ab'] <= date('Y-m-d') && ($m['gueltig_bis'] == null || $m['gueltig_bis'] >= date('Y-m-d'))) {
110)             $aktiv = true;
111)         }
112)         output('<tr><td'.($aktiv ? ' style="font-weight: bold;"' : '').'>'.internal_link('sepamandat_detail', $m['mandatsreferenz'], 'ref='.$m['mandatsreferenz']).'</td><td>'.$m['iban'].'</td><td>'.$gueltig.'</td></tr>');
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

113)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

114)     output('</table>');
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

115) }
116) 
117) 
Bernd Wurst Typo / Schönheitskorrektur

Bernd Wurst authored 10 years ago

118) if ($mandate) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

119)     addnew('sepamandat', 'Hat sich Ihre Bankverbindung geändert? Erteilen Sie uns ein neues Lastschrift-Mandat');
Bernd Wurst Typo / Schönheitskorrektur

Bernd Wurst authored 10 years ago

120) } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

121)     addnew('sepamandat', 'Erteilen Sie uns ein Lastschrift-Mandat');
Bernd Wurst Typo / Schönheitskorrektur

Bernd Wurst authored 10 years ago

122) }
Bernd Wurst Erste Version des SEPA-Mand...

Bernd Wurst authored 10 years ago

123) 
124) output('<p>Sie können Ihr Mandat jederzeit widerrufen. Senden Sie uns dazu bitte eine entsprechende E-Mail.</p>');
125) 
126) 
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

127) 
Bernd Wurst changed caption of invoice...

Bernd Wurst authored 3 years ago

128) output("<h3>Rechnungs-Vorschau</h3>");
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

129) output('<p>Hier sehen Sie einen Überblick über Posten die in den nächsten 3 Monaten fällig werden.</p>');
130) 
131) 
132) output('<p style="margin: 1em; padding: 1em; border: 2px solid red; background: white;"><strong>Hinweis:</strong> Die hier aufgeführten Posten dienen nur Ihrer Information und erheben keinen Anspruch auf Vollständigkeit. Aus technischen Gründen sind manche Posten hier nicht aufgeführt, die dennoch berechnet werden. Zudem können, bedingt durch Rundungsfehler, die Beträge auf dieser Seite falsch dargestellt sein. Wiederkehrende Beträge werden grundsätzlich nur für den nächsten Abrechnungszeitraum angezeigt.</p>');
133) 
134) $items = upcoming_items();
135) $summe = 0;
136) 
137) $flip = true;
138) $today = date('Y-m-d');
139) $max_date = date('Y-m-d', strtotime('+3 months'));
140) output('<table><tr><th>Anzahl</th><th>Beschreibung</th><th>Zeitraum</th><th>Einzelpreis</th><th>Gesamtbetrag</th></tr>');
141) 
142) $counter = 0;
143) 
144) $more = false;
145) $odd = false;
146) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

147) foreach ($items as $item) {
148)     if ($item['startdatum'] > $max_date) {
149)         $more = true;
150)         break;
151)     }
152)     if ($flip && $item['startdatum'] > $today) {
153)         if ($counter == 0) {
154)             output("<tr class=\"even\"><td colspan=\"5\"><em>Aktuell keine fälligen Posten</em></td></tr>");
155)         }
156)         $flip = false;
157)         $odd = false;
158)         output("<tr class=\"even\"><td colspan=\"4\" style=\"text-align: right; font-weight: bold; border: none;\">Summe bisher fällige Posten:</td>");
159)         output("<td class=\"number\" style=\"font-weight: bold;\">{$summe} €</td></tr>\n");
160)         output("<tr><td colspan=\"5\" style=\"border: none;\"> </td></tr>\n");
161)     }
162)     $counter++;
163)     $desc = $item['startdatum'];
164)     if ($item['enddatum'] != null) {
165)         $desc = $item['startdatum'].' - '.$item['enddatum'];
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

166)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

167)     $epreis = $item['betrag'];
168)     if ($item['brutto'] == 0) {
169)         $epreis = $epreis * (1 + ($item['mwst'] / 100));
170)     }
171)     $gesamt = round($epreis * $item['anzahl'], 2);
172)     $epreis = round($epreis, 2);
173)     $summe += $gesamt;
174)     $einheit = ($item['einheit'] ? $item['einheit'] : '');
175)     $class = ($odd ? "odd" : "even");
176)     $odd = !$odd;
177)     output("<tr class=\"$class\"><td class=\"number\">{$item['anzahl']} {$einheit}</td>");
178)     output("<td>{$item['beschreibung']}</td><td>{$desc}</td>");
179)     output("<td class=\"number\">{$epreis} €</td><td class=\"number\">{$gesamt} €</td></tr>\n");
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

180) }
181) 
182) if ($counter) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

183)     output("<tr class=\"even\"><td colspan=\"4\" style=\"text-align: right; font-weight: bold; border: none;\">Summe aller Posten:</td>");
184)     output("<td style=\"font-weight: bold;\" class=\"number\">{$summe} €</td></tr>\n");
185)     output('</table>');
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

186) } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

187)     output("<tr class=\"even\"><td colspan=\"5\"><em>Es sind keine Posten hinterlegt, die in den nächsten 3 Monaten fällig werden.</em></td></tr></table>");
Bernd Wurst Neues Layout der Rechnungs-...

Bernd Wurst authored 9 years ago

188) }
189) 
190) if ($more) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

191)     output('<p>'.internal_link('upcoming', other_icon('control_fastforward.png').' Alle zukünftigen Rechnungsposten anzeigen').'</p>');