Subversion Repositories wpShopGermany4

Rev

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