Bernd Wurst commited on 2013-12-27 11:04:38
Zeige 3 geänderte Dateien mit 99 Einfügungen und 0 Löschungen.
... | ... |
@@ -223,4 +223,32 @@ function sepamandat($name, $adresse, $iban, $bankname, $bic, $gueltig_ab) |
223 | 223 |
|
224 | 224 |
|
225 | 225 |
|
226 |
+function get_bank_info($iban) |
|
227 |
+{ |
|
228 |
+ if (strlen($iban) != 22 || substr($iban, 0, 2) != 'DE') { |
|
229 |
+ // Geht nur bei deutschen IBANs |
|
230 |
+ echo 'Fehler!'; |
|
231 |
+ echo '$iban = '.$iban; |
|
232 |
+ echo 'strlen($iban): '.strlen($iban); |
|
233 |
+ echo 'substr($iban, 0, 2): '.substr($iban, 0, 2); |
|
234 |
+ return NULL; |
|
235 |
+ } |
|
236 |
+ $blz = substr($iban, 4, 8); |
|
237 |
+ // FIXME: Liste der BLZs muss vorhanden sein! |
|
238 |
+ $bankinfofile = dirname(__FILE__).'/bankinfo.txt'; |
|
239 |
+ $f = file($bankinfofile); |
|
240 |
+ $match = ''; |
|
241 |
+ foreach ($f as $line) { |
|
242 |
+ if (substr($line, 0, 9) == $blz.'1') { |
|
243 |
+ $match = $line; |
|
244 |
+ break; |
|
245 |
+ } |
|
246 |
+ } |
|
247 |
+ $bank = array(); |
|
248 |
+ $bank['name'] = iconv('latin1', 'utf8', chop(substr($match, 9,58))); |
|
249 |
+ $bank['bic'] = chop(substr($match, 139,11)); |
|
250 |
+ return $bank; |
|
251 |
+} |
|
252 |
+ |
|
253 |
+ |
|
226 | 254 |
?> |
... | ... |
@@ -19,6 +19,15 @@ require_once('invoice.php'); |
19 | 19 |
require_role(ROLE_CUSTOMER); |
20 | 20 |
$section = 'invoice_current'; |
21 | 21 |
|
22 |
+$path = config('jquery_ui_path'); |
|
23 |
+ |
|
24 |
+html_header(' |
|
25 |
+<link rel="stylesheet" href="'.$path.'/themes/base/jquery-ui.css" /> |
|
26 |
+<script type="text/javascript" src="'.$path.'/jquery-1.9.0.js" ></script> |
|
27 |
+<script type="text/javascript" src="'.$path.'/ui/jquery-ui.js" ></script> |
|
28 |
+ |
|
29 |
+'); |
|
30 |
+ |
|
22 | 31 |
title('Erteilung eines Mandats zur SEPA-Basis-Lastschrift'); |
23 | 32 |
|
24 | 33 |
output('<p>Ich ermächtige die Firma schokokeks.org GbR, Zahlungen von meinem Konto mittels Lastschrift |
... | ... |
@@ -71,5 +80,33 @@ $html .= '<p><input type="submit" value="Mandat erteilen" /></p>'; |
71 | 80 |
|
72 | 81 |
output(html_form('sepamandat_neu', 'save', 'action=new', $html)); |
73 | 82 |
|
83 |
+output(' |
|
84 |
+<script type="text/javascript"> |
|
85 |
+ |
|
86 |
+function populate_bankinfo(result) { |
|
87 |
+ bank = result[0]; |
|
88 |
+ $(\'#bankname\').val(bank.bankname); |
|
89 |
+ $(\'#bic\').val(bank.bic); |
|
90 |
+ |
|
91 |
+} |
|
92 |
+ |
|
93 |
+function searchbank() |
|
94 |
+{ |
|
95 |
+ var iban = $(\'#iban\').val(); |
|
96 |
+ if (iban.substr(0,2) == "DE" && iban.length == 22) { |
|
97 |
+ $("#bankname").prop("disabled", true); |
|
98 |
+ $("#bic").prop("disabled", true); |
|
99 |
+ $.getJSON("sepamandat_banksearch?iban="+iban, populate_bankinfo) |
|
100 |
+ .always( function() { |
|
101 |
+ $("#bankname").prop("disabled", false); |
|
102 |
+ $("#bic").prop("disabled", false); |
|
103 |
+ }); |
|
104 |
+ |
|
105 |
+ } |
|
106 |
+} |
|
107 |
+ |
|
108 |
+$(\'#iban\').on("change keyup paste", searchbank ); |
|
74 | 109 |
|
110 |
+</script> |
|
111 |
+'); |
|
75 | 112 |
?> |
... | ... |
@@ -0,0 +1,34 @@ |
1 |
+<?php |
|
2 |
+/* |
|
3 |
+This file belongs to the Webinterface of schokokeks.org Hosting |
|
4 |
+ |
|
5 |
+Written 2008-2013 by schokokeks.org Hosting, namely |
|
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 |
+*/ |
|
16 |
+ |
|
17 |
+require_once('inc/base.php'); |
|
18 |
+require_once('inc/debug.php'); |
|
19 |
+ |
|
20 |
+require_once('invoice.php'); |
|
21 |
+ |
|
22 |
+ |
|
23 |
+$iban = $_GET['iban']; |
|
24 |
+ |
|
25 |
+$bank = get_bank_info($iban); |
|
26 |
+ |
|
27 |
+header("Content-Type: text/javascript"); |
|
28 |
+echo "[\n"; |
|
29 |
+echo ' { "bic": "'.$bank['bic'].'", "bankname" : "'.$bank['name'].'" } '; |
|
30 |
+echo ' |
|
31 |
+]'; |
|
32 |
+die(); |
|
33 |
+ |
|
34 |
+ |
|
0 | 35 |