Subversion Repositories wpShopGermany4

Rev

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