87ecb513a98b35ea6b6b19c0f4c9b51518465a9d
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 Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 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) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
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('inc/base.php');
18) require_once('inc/security.php');
19) 
20) function my_invoices()
21) {
22)   $c = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Zeige zunächst nur unbezahl...

Bernd Wurst authored 11 years ago

23)   $result = db_query("SELECT id,datum,betrag,bezahlt,abbuchung FROM kundendaten.ausgestellte_rechnungen WHERE kunde={$c} ORDER BY id DESC");
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

24)   $ret = array();
25)   while($line = mysql_fetch_assoc($result))
26)   	array_push($ret, $line);
27)   return $ret;
28) }
29) 
30) 
31) function get_pdf($id)
32) {
33)   $c = (int) $_SESSION['customerinfo']['customerno'];
34)   $id = (int) $id;
35)   $result = db_query("SELECT pdfdata FROM kundendaten.ausgestellte_rechnungen WHERE kunde={$c} AND id={$id}");
36)   if (mysql_num_rows($result) == 0)
37) 	system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
38)   return mysql_fetch_object($result)->pdfdata;
39) 
40) }
41) 
42) 
43) function invoice_details($id)
44) {
45)   $c = (int) $_SESSION['customerinfo']['customerno'];
46)   $id = (int) $id;
47)   $result = db_query("SELECT kunde,datum,betrag,bezahlt,abbuchung FROM kundendaten.ausgestellte_rechnungen WHERE kunde={$c} AND id={$id}");
48)   if (mysql_num_rows($result) == 0)
Bernd Wurst QR-Codes für Überweisung be...

Bernd Wurst authored 10 years ago

49)   	system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

50)   return mysql_fetch_assoc($result);
51) }
52) 
53) function invoice_items($id)
54) {
55)   $c = (int) $_SESSION['customerinfo']['customerno'];
56)   $id = (int) $id;
Bernd Wurst Einheit bei Rechnungsposten...

Bernd Wurst authored 12 years ago

57)   $result = db_query("SELECT id, beschreibung, datum, enddatum, betrag, einheit, brutto, mwst, anzahl FROM kundendaten.rechnungsposten WHERE rechnungsnummer={$id} AND kunde={$c}");
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

58)   if (mysql_num_rows($result) == 0)
Bernd Wurst QR-Codes für Überweisung be...

Bernd Wurst authored 10 years ago

59)   	system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

60)   $ret = array();
61)   while($line = mysql_fetch_assoc($result))
62)   array_push($ret, $line);
63)   return $ret;
64) }
65) 
66) 
67) function upcoming_items()
68) {
69)   $c = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Einheit bei Rechnungsposten...

Bernd Wurst authored 12 years ago

70)   $result = db_query("SELECT anzahl, beschreibung, startdatum, enddatum, betrag, einheit, brutto, mwst FROM kundendaten.upcoming_items WHERE kunde={$c} ORDER BY startdatum ASC");
bernd Kunden können Ihre Rechnung...

bernd authored 16 years ago

71)   $ret = array();
72)   while($line = mysql_fetch_assoc($result))
73) 	  array_push($ret, $line);
74)   return $ret;
75) }
76) 
77) 
Bernd Wurst QR-Codes für Überweisung be...

Bernd Wurst authored 10 years ago

78) function generate_qrcode_image($id) 
79) {
80)   $invoice = invoice_details($id);
81)   $customerno = $invoice['kunde'];
82)   $amount = 'EUR'.sprintf('%.2f', $invoice['betrag']);
83)   $datum = $invoice['datum'];
84)   $data = 'BCD
85) 001
86) 1
87) SCT
88) GENODES1VBK
89) schokokeks.org GbR
90) DE91602911200041512006
91) '.$amount.'
92) 
93) 
Bernd Wurst Beschreibung entfernt, mach...

Bernd Wurst authored 10 years ago

94) RE '.$id.' KD '.$customerno.' vom '.$datum;
Bernd Wurst QR-Codes für Überweisung be...

Bernd Wurst authored 10 years ago

95)   
96)   $descriptorspec = array(
97)     0 => array("pipe", "r"),  // STDIN ist eine Pipe, von der das Child liest
98)     1 => array("pipe", "w"),  // STDOUT ist eine Pipe, in die das Child schreibt
99)     2 => array("pipe", "w") 
100)   );
101) 
102)   $process = proc_open('qrencode -t PNG -o - -l M', $descriptorspec, $pipes);
103) 
104)   if (is_resource($process)) {
105)     // $pipes sieht nun so aus:
106)     // 0 => Schreibhandle, das auf das Child STDIN verbunden ist
107)     // 1 => Lesehandle, das auf das Child STDOUT verbunden ist
108) 
109)     fwrite($pipes[0], $data);
110)     fclose($pipes[0]);
111) 
112)     $pngdata = stream_get_contents($pipes[1]);
113)     fclose($pipes[1]);
114) 
115)     // Es ist wichtig, dass Sie alle Pipes schließen bevor Sie
116)     // proc_close aufrufen, um Deadlocks zu vermeiden
117)     $return_value = proc_close($process);
118)   
119)     return $pngdata;
120)   } else {
121)     warning('Es ist ein interner Fehler im Webinterface aufgetreten, aufgrund dessen kein QR-Code erstellt werden kann. Sollte dieser Fehler mehrfach auftreten, kontaktieren Sie bitte die Administratoren.');
122)   }
123) }
124) 
125) 
126) function generate_bezahlcode_image($id) 
127) {
128)   $invoice = invoice_details($id);
129)   $customerno = $invoice['kunde'];
130)   $amount = str_replace('.', '%2C', sprintf('%.2f', $invoice['betrag']));
131)   $datum = $invoice['datum'];
132)   $data = 'bank://singlepaymentsepa?name=schokokeks.org%20GbR&reason=RE%20'.$id.'%20KD%20'.$customerno.'%20vom%20'.$datum.'&iban=DE91602911200041512006&bic=GENODES1VBK&amount='.$amount;
133)   
134)   $descriptorspec = array(
135)     0 => array("pipe", "r"),  // STDIN ist eine Pipe, von der das Child liest
136)     1 => array("pipe", "w"),  // STDOUT ist eine Pipe, in die das Child schreibt
137)     2 => array("pipe", "w") 
138)   );
139) 
140)   $process = proc_open('qrencode -t PNG -o -', $descriptorspec, $pipes);
141) 
142)   if (is_resource($process)) {
143)     // $pipes sieht nun so aus:
144)     // 0 => Schreibhandle, das auf das Child STDIN verbunden ist
145)     // 1 => Lesehandle, das auf das Child STDOUT verbunden ist
146) 
147)     fwrite($pipes[0], $data);
148)     fclose($pipes[0]);
149) 
150)     $pngdata = stream_get_contents($pipes[1]);
151)     fclose($pipes[1]);
152) 
153)     // Es ist wichtig, dass Sie alle Pipes schließen bevor Sie
154)     // proc_close aufrufen, um Deadlocks zu vermeiden
155)     $return_value = proc_close($process);
156)   
157)     return $pngdata;
158)   } else {
159)     warning('Es ist ein interner Fehler im Webinterface aufgetreten, aufgrund dessen kein QR-Code erstellt werden kann. Sollte dieser Fehler mehrfach auftreten, kontaktieren Sie bitte die Administratoren.');
160)   }
161) }
162) 
163) 
164) 
165) # bank://singlepaymentsepa?name=SCHOKOKEKS.ORG%20GBR&reason=RE%20256%20KD%2032%20vom%202008-03-01&iban=DE91602911200041512006&bic=GENODES1VBK&amount=45%2C00