JS-Code in separate Datei ausgelagert
Bernd Wurst

Bernd Wurst commited on 2018-01-17 10:21:13
Zeige 2 geänderte Dateien mit 69 Einfügungen und 74 Löschungen.

... ...
@@ -0,0 +1,68 @@
1
+function populate_bankinfo(result) {
2
+  bank = result[0];
3
+  if (bank.iban_ok == 1) {
4
+    $("#iban_feedback").html('<img src="../../images/ok.png" style="height: 16px; width: 16px;" alt="" title="" />');
5
+    if ($('#bankname').val() == "") 
6
+      $('#bankname').val(bank.bankname);
7
+    if ($('#bic').val() == "")  
8
+      $('#bic').val(bank.bic);
9
+  } else {
10
+    $("#iban_feedback").html('<img src="../../images/error.png" style="height: 16px; width: 16px;" alt="IBAN scheint nicht gültig zu sein" title="IBAN scheint nicht gültig zu sein" />');
11
+    $('#bankname').val("");
12
+    $('#bic').val("");
13
+  }
14
+    
15
+}
16
+
17
+function searchbank() 
18
+{
19
+  var iban = $('#iban').val().replace(/\s/g, '');
20
+  if (iban.substr(0,2) == "DE" && iban.length == 22) {
21
+    $("#bankname").prop("disabled", true);
22
+    $("#bic").prop("disabled", true);
23
+    $.getJSON("sepamandat_banksearch?iban="+iban, populate_bankinfo)
24
+      .always( function() {
25
+        $("#bankname").prop("disabled", false);
26
+        $("#bic").prop("disabled", false);
27
+      });
28
+  } else {
29
+    $("#iban_feedback").html("");
30
+  }
31
+}
32
+
33
+function copydata_worker( result ) {
34
+  $("#kontoinhaber").val(result.kundenname);
35
+  $("#adresse").val(result.adresse);
36
+}
37
+
38
+function copydata( event ) {
39
+  event.preventDefault();
40
+  var kunde = $.getJSON("sepamandat_copydata", copydata_worker);
41
+}
42
+
43
+function populate_iban(result) {
44
+  info = result[0];
45
+  $("#iban").val(info.iban);
46
+  populate_bankinfo(result)
47
+}
48
+
49
+function ktoblz( event ) {
50
+  event.preventDefault();
51
+  var kto = $("#kto").val();
52
+  var blz = $("#blz").val();
53
+  $.getJSON("sepamandat_banksearch?kto="+kto+"&blz="+blz, populate_iban)
54
+}
55
+
56
+function showktoblz( event ) {
57
+  event.preventDefault();
58
+  $("#ktoblz_button").hide();
59
+  $("#ktoblz_input").show();
60
+}
61
+
62
+
63
+$(function() {
64
+    $('#iban').on("change keyup paste", searchbank );
65
+    $("#copydata").click(copydata);
66
+    $("#showktoblz").click(showktoblz);
67
+    $("#ktoblz").click(ktoblz);
68
+});
... ...
@@ -18,6 +18,7 @@ require_once('inc/icons.php');
18 18
 require_once('invoice.php');
19 19
 
20 20
 require_once('inc/jquery.php');
21
+javascript();
21 22
 
22 23
 require_role(ROLE_CUSTOMER);
23 24
 $section = 'invoice_current';
... ...
@@ -79,77 +80,3 @@ $html .= '<p><input type="submit" value="Mandat erteilen" /></p>';
79 80
 
80 81
 output(html_form('sepamandat_neu', 'save', 'action=new', $html));
81 82
 
82
-output('
83
-<script type="text/javascript">
84
-
85
-function populate_bankinfo(result) {
86
-  bank = result[0];
87
-  if (bank.iban_ok == 1) {
88
-    $("#iban_feedback").html(\''.icon_ok().'\');
89
-    if ($(\'#bankname\').val() == "") 
90
-      $(\'#bankname\').val(bank.bankname);
91
-    if ($(\'#bic\').val() == "")  
92
-      $(\'#bic\').val(bank.bic);
93
-  } else {
94
-    $("#iban_feedback").html(\''.icon_error('IBAN scheint nicht gültig zu sein').'\');
95
-    $(\'#bankname\').val("");
96
-    $(\'#bic\').val("");
97
-  }
98
-    
99
-}
100
-
101
-function searchbank() 
102
-{
103
-  var iban = $(\'#iban\').val().replace(/\s/g, \'\');
104
-  if (iban.substr(0,2) == "DE" && iban.length == 22) {
105
-    $("#bankname").prop("disabled", true);
106
-    $("#bic").prop("disabled", true);
107
-    $.getJSON("sepamandat_banksearch?iban="+iban, populate_bankinfo)
108
-      .always( function() {
109
-        $("#bankname").prop("disabled", false);
110
-        $("#bic").prop("disabled", false);
111
-      });
112
-  } else {
113
-    $("#iban_feedback").html("");
114
-  }
115
-}
116
-
117
-function copydata_worker( result ) {
118
-  $("#kontoinhaber").val(result.kundenname);
119
-  $("#adresse").val(result.adresse);
120
-}
121
-
122
-function copydata( event ) {
123
-  event.preventDefault();
124
-  var kunde = $.getJSON("sepamandat_copydata", copydata_worker);
125
-}
126
-
127
-function populate_iban(result) {
128
-  info = result[0];
129
-  $("#iban").val(info.iban);
130
-  populate_bankinfo(result)
131
-}
132
-
133
-function ktoblz( event ) {
134
-  event.preventDefault();
135
-  var kto = $("#kto").val();
136
-  var blz = $("#blz").val();
137
-  $.getJSON("sepamandat_banksearch?kto="+kto+"&blz="+blz, populate_iban)
138
-}
139
-
140
-function showktoblz( event ) {
141
-  event.preventDefault();
142
-  $("#ktoblz_button").hide();
143
-  $("#ktoblz_input").show();
144
-}
145
-
146
-
147
-
148
-$(\'#iban\').on("change keyup paste", searchbank );
149
-$("#copydata").click(copydata);
150
-$("#showktoblz").click(showktoblz);
151
-$("#ktoblz").click(ktoblz);
152
-
153
-</script>
154
-');
155
-?>
156 83