summaryrefslogtreecommitdiff
path: root/views/mods/mod_autodebit/paymenthint.phtml
blob: 6f172604cc9493bf3a807810b92a35087839ddaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

	/**
	 * Template für die Integration der Kundeneingaben für das Modul "Bankeinzug" in den Checkout2
	 */
 
?>
<br /><br />
<div class="wpsg_mod_autodebit">
	
	<div class="wpsg_mod_autodebit_inhaber wpsg_mod_autodebit_field">
		<label>
			<?php echo __('Inhaber', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_inhaber", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[inhaber]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['inhaber']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	
	<?php if ($this->get_option('wpsg_mod_autodebit_iban') == '1') { ?>
	<div class="wpsg_mod_autodebit_bic wpsg_mod_autodebit_field">
		<label>
			<?php echo __('BIC', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_bic", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[bic]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['bic']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	<?php } else { ?>
	<div class="wpsg_mod_autodebit_blz wpsg_mod_autodebit_field">
		<label>
			<?php echo __('Bankleitzahl', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_blz", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[blz]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['blz']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	<?php } ?>
	
	<?php if ($this->get_option('wpsg_mod_autodebit_iban') == '1') { ?>
	<div class="wpsg_mod_autodebit_iban wpsg_mod_autodebit_field">
		<label>
			<?php echo __('IBAN', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_iban", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[iban]" id="wpsg_mod_autodebit_iban" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['iban']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	<?php } else { ?>
	<div class="wpsg_mod_autodebit_knr wpsg_mod_autodebit_field">
		<label>
			<?php echo __('Kontonummer', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_knr", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[knr]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['knr']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	<?php } ?>	

	<div class="wpsg_mod_autodebit_name wpsg_mod_autodebit_field">
		<label>
			<?php echo __('Name der Bank', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<input class="<?php echo ((in_array("mod_autodebit_name", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_autodebit[name]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_autodebit']['name']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	
	<div class="wpsg_mandatoryfield_hint">
		<?php echo wpsg_translate(__('Mit #1# gekennzeichnete Felder sind Pflichtfelder.', 'wpsg'), '<span class="wpsg_required">*</span>'); ?>
	</div>
	
</div>

<script>

//id="wpsg_mod_autodebit_iban"
jQuery("#wpsg_mod_autodebit_iban").on("input", function () {
	var
		iban,
		a1,
		bb = true,
		sum = 0,
		csum,
		i;

	//alert("oninput");
	iban = jQuery('#wpsg_mod_autodebit_iban').val();
	iban = iban.replace(/ /g, "");
	// 2 + 2 + 8 + 10
	// DE 22 Zeichen
	// AT 20 Zeichen
	// CH 21 Zeichen
	// Ersetze alle Buchstaben durch Zahlen, wobei A = 10, B = 11, …, Z = 35.
    // Berechne den ganzzahligen Rest, der bei Division durch 97 bleibt.
    // Subtrahiere den Rest von 98, das Ergebnis sind die beiden Prüfziffern. 
    // Falls das Ergebnis einstellig ist, wird es mit einer führenden Null ergänzt.
	// DE80500105175408332501 --> 500105175408332501DE80 --> 500105175408332501131480
	// Zahl modulo 97 muss 1 ergeben

	if (iban.length < 16) { return; }

	sum = iban.substr(4);

	a1 = parseInt(iban.charCodeAt(0, 1) - 64, 10) + 9;
	sum = sum + a1.toString();
	a1 = parseInt(iban.charCodeAt(1, 1) - 64, 10) + 9;
	sum = sum + a1.toString();
	sum = sum + iban.substr(2, 2);
	
	//sum = sum % 97;
    // Calculate checksum
    csum = parseInt(sum.substr(0, 1), 10);
    for (i = 1; i < sum.length; i++) {
        csum = csum * 10;
        csum = csum + parseInt(sum.substr(i, 1), 10);
        csum = csum % 97;
    }
	
	if (csum !== 1) { bb = false; }

	jQuery('#wpsg_mod_autodebit_iban').removeClass('wpsg_error');
	if (bb === false) {
		//alert('IBAN fehlerhaft');
		jQuery('#wpsg_mod_autodebit_iban').addClass('wpsg_error');
	}

});





</script>