Zeige gleich an, ob eine (deutsch) IBAN gültig ist
Bernd Wurst

Bernd Wurst commited on 2013-12-27 11:46:26
Zeige 2 geänderte Dateien mit 16 Einfügungen und 3 Löschungen.

... ...
@@ -14,6 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
14 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 15
 */
16 16
 
17
+require_once('inc/icons.php');
17 18
 require_once('invoice.php');
18 19
 
19 20
 require_role(ROLE_CUSTOMER);
... ...
@@ -70,7 +71,7 @@ $html .= '<h4>Ihre Bankverbindung</h4>';
70 71
 $html .= '<table>
71 72
 <tr><td><label for="kontoinhaber">Name des Kontoinhabers:</label></td><td><input type="text" name="kontoinhaber" id="kontoinhaber" value="'.$_SESSION['customerinfo']['name'].'" /></td></tr>
72 73
 <tr><td><label for="adresse">Adresse des Kontoinhabers:</label></td><td><textarea cols="50" lines="2" name="adresse" id="adresse"></textarea></td></tr>
73
-<tr><td><label for="iban">IBAN:</label></td><td><input type="text" name="iban" id="iban" /></td></tr>
74
+<tr><td><label for="iban">IBAN:</label></td><td><input type="text" name="iban" id="iban" /><span id="iban_feedback"></span></td></tr>
74 75
 <tr><td><label for="bankname">Name der Bank:</label></td><td><input type="text" name="bankname" id="bankname" /></td></tr>
75 76
 <tr><td><label for="bic">BIC:</label></td><td><input type="text" name="bic" id="bic" /></td></tr>
76 77
 </table>';
... ...
@@ -85,8 +86,17 @@ output('
85 86
 
86 87
 function populate_bankinfo(result) {
87 88
   bank = result[0];
89
+  if (bank.iban_ok == 1) {
90
+    $("#iban_feedback").html(\''.icon_ok().'\');
91
+    if ($(\'#bankname\').val() == "") 
88 92
       $(\'#bankname\').val(bank.bankname);
93
+    if ($(\'#bic\').val() == "")  
89 94
       $(\'#bic\').val(bank.bic);
95
+  } else {
96
+    $("#iban_feedback").html(\''.icon_error('IBAN scheint nicht gültig zu sein').'\');
97
+    $(\'#bankname\').val("");
98
+    $(\'#bic\').val("");
99
+  }
90 100
     
91 101
 }
92 102
 
... ...
@@ -101,7 +111,8 @@ function searchbank()
101 111
         $("#bankname").prop("disabled", false);
102 112
         $("#bic").prop("disabled", false);
103 113
       });
104
-
114
+  } else {
115
+    $("#iban_feedback").html("");
105 116
   }
106 117
 }
107 118
 
... ...
@@ -22,11 +22,13 @@ require_once('invoice.php');
22 22
 
23 23
 $iban = $_GET['iban'];
24 24
 
25
+$iban_ok = (verify_iban($iban) ? '1' : '0');
26
+
25 27
 $bank = get_bank_info($iban);
26 28
 
27 29
 header("Content-Type: text/javascript");
28 30
 echo "[\n";
29
-echo ' { "bic": "'.$bank['bic'].'", "bankname" : "'.$bank['name'].'" } ';
31
+echo ' { "iban_ok": "'.$iban_ok.'", "bic": "'.$bank['bic'].'", "bankname" : "'.$bank['name'].'" } ';
30 32
 echo '
31 33
 ]';
32 34
 die();
33 35