Subversion Repositories wpShopGermany4

Rev

Rev 7715 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5866 hartmut 1
<?php
2
 
3
	/**
4
	 * Template für die Integration der Kundeneingaben für das Modul "Kreditkarte" in den Checkout2
5
	 */
7949 karl 6
 
7
 	if (!isset($this->view['error'])) $this->view['error'] = [];
8
 
5866 hartmut 9
?>
10
<br /><br />
11
<div class="wpsg_mod_creditcard">
12
 
13
	<div class="wpsg_mod_creditcard_name wpsg_mod_creditcard_field">
14
		<label>
7715 daniel 15
 
16
            <?php echo __('Typ der Kreditkarte', 'wpsg'); ?><span class="wpsg_required">*</span>:
17
 
5866 hartmut 18
			<select name="wpsg_mod_creditcard[typ]" id="wpsg_mod_creditcard_typ"
19
			class="<?php echo ((in_array('mod_creditcard_typ', (array)$this->view['error']))?'wpsg_error':''); ?>" >
7440 daniel 20
				<option value="VISA" <?php echo (($this->view['wpsg_mod_creditcard']['typ'] === 'VISA')?'selected="selected"':''); ?>>VISA</option>
21
				<option value="MasterCard" <?php echo (($this->view['wpsg_mod_creditcard']['typ'] === 'MasterCard')?'selected="selected"':''); ?>>MasterCard</option>
5866 hartmut 22
			</select>
23
 
24
		</label>
25
	</div>
26
	<div class="wpsg_clear"></div>
27
 
28
	<div class="wpsg_mod_creditcard_inhaber wpsg_mod_creditcard_field">
29
		<label>
30
			<?php echo __('Inhaber', 'wpsg'); ?><span class="wpsg_required">*</span>:
31
			<input class="<?php echo ((in_array("mod_creditcard_inhaber", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[inhaber]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['inhaber']); ?>" />
32
		</label>
33
	</div>
34
	<div class="wpsg_clear"></div>
35
 
36
	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
37
		<label>
38
			<?php echo __('Kartennummer', 'wpsg'); ?><span class="wpsg_required">*</span>:
39
			<input class="<?php echo ((in_array("mod_creditcard_knr", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" id="wpsg_mod_creditcard_knr" name="wpsg_mod_creditcard[knr]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['knr']); ?>" />
40
		</label>
41
	</div>
42
	<div class="wpsg_clear"></div>
43
 
44
	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
45
		<label>
46
			<?php echo __('Prüfziffer', 'wpsg'); ?><span class="wpsg_required">*</span>:
47
			<input class="<?php echo ((in_array("mod_creditcard_pruefz", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[pruefz]" value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['pruefz']); ?>" />
48
		</label>
49
	</div>
50
	<div class="wpsg_clear"></div>
51
 
52
	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
53
		<label>
54
			<?php echo __('Gültigkeit', 'wpsg'); ?><span class="wpsg_required">*</span>:
6142 hartmut 55
			<!-- <input class="<?php echo ((in_array("mod_creditcard_gueltig", (array)$this->view['error']))?'wpsg_error':''); ?>" type="text" name="wpsg_mod_creditcard[gueltig]" value="<?php echo wpsg_hspc(wpsg_getStr($this->view['wpsg_mod_creditcard']['gueltig'])); ?>" /> -->
5866 hartmut 56
 
57
			<select name="wpsg_mod_creditcard[gueltigm]" id="wpsg_mod_creditcard_gueltigm"
58
			class="<?php echo ((in_array('mod_creditcard_gueltigm', (array)$this->view['error']))?'wpsg_error':''); ?>" >
59
				<option value="01">01</option>
60
				<option value="02">02</option>
61
				<option value="03">03</option>
62
				<option value="04">04</option>
63
				<option value="05">05</option>
64
				<option value="06">06</option>
65
				<option value="07">07</option>
66
				<option value="08">08</option>
67
				<option value="09">09</option>
68
				<option value="10">10</option>
69
				<option value="11">11</option>
70
				<option value="12" selected="selected">12</option>
71
			</select>
72
			<select name="wpsg_mod_creditcard[gueltigj]" id="wpsg_mod_creditcard_gueltigj"
73
			class="<?php echo ((in_array('mod_creditcard_gueltigj', (array)$this->view['error']))?'wpsg_error':''); ?>" >
74
 
75
			</select>
76
		</label>
77
	</div>
78
	<div class="wpsg_clear"></div>
79
 
80
 
81
	<div class="wpsg_mandatoryfield_hint">
82
		<?php echo wpsg_translate(__('Mit #1# gekennzeichnete Felder sind Pflichtfelder.', 'wpsg'), '<span class="wpsg_required">*</span>'); ?>
83
	</div>
84
 
85
</div>
86
 
87
<script>
88
 
89
jQuery(document).ready(function() {
90
	var gm,
91
		gj,
92
		sel1,
93
		i,
94
		dt,
95
		garr;
96
 
97
	gm="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigm']); ?>";
98
	gj="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigj']); ?>";
99
 
100
	dt = new Date();
101
	dt = dt.getFullYear();
102
    sel1 = document.getElementById("wpsg_mod_creditcard_gueltigj");
103
    for (i = 0; i < 6; i++) {
104
        newopt = new Option(dt + i, dt + i, false, false);
105
        sel1.options[i] = newopt;
106
    }
107
    //gm = '06';
108
    //gj = '2018';
109
    jQuery('#wpsg_mod_creditcard_gueltigm').val(gm);
110
    jQuery('#wpsg_mod_creditcard_gueltigj').val(gj);
111
 
112
 
113
});
114
 
115
//alert(jQuery("#wpsg_mod_creditcard_knr").length);
116
//$(document).on("input", "#wpsg_mod_creditcard_knr", function () {
117
jQuery("#wpsg_mod_creditcard_knr").on("input", function () {
118
	var
119
		knr,
120
		typ,
121
		a1,
122
		ai,
123
		isANumber,
124
		bb = true,
125
		sum = 0,
126
		k = 2,
127
		i;
128
	//alert("onchange");
129
	knr = jQuery('#wpsg_mod_creditcard_knr').val();
130
	typ = jQuery('#wpsg_mod_creditcard_typ').val();
131
	knr = knr.replace(/ /g, "");
132
	if (knr.length < 16) { return; }
133
 
134
	isANumber = (isNaN(knr) === false);
135
	if (isANumber === false) { bb = false; }
136
	a1 = knr.substr(0, 1);
137
	ai = parseInt(knr.substr(15, 1), 10);
138
	if (!(((a1 === "4") && (typ === "VISA")) || ((a1 === "5") && (typ === "MasterCard")))) { bb = false; }
139
	for (i = 14; i >= 0; i--) {
6030 hartmut 140
        dig = k * parseInt(knr.substr(i, 1), 10);
141
        if (dig > 9) { dig = dig - 9;}
142
		sum = sum + dig;
143
		//sum = sum + k * parseInt(knr.substr(i, 1), 10);
5866 hartmut 144
		if (k === 2) { k = 1; } else { k = 2; }
145
	}
146
	sum = sum % 10;
147
	if (sum > 0) { sum = 10 - sum; }
148
	if (sum !== ai) { bb = false; }
149
 
150
	if (bb === false) {
151
		alert('Kartennummer fehlerhaft');
152
	}
153
 
154
});
155
 
156
 
157
</script>