Subversion Repositories wpShopGermany4

Rev

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