summaryrefslogtreecommitdiff
path: root/views/mods/mod_creditcard/paymenthint.phtml
blob: 5ffda9298841b2aa9e0b2c480c381de24c481d24 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php

	/**
	 * Template für die Integration der Kundeneingaben für das Modul "Kreditkarte" in den Checkout2
	 */
 
?>
<br /><br />
<div class="wpsg_mod_creditcard">
	
	<div class="wpsg_mod_creditcard_name wpsg_mod_creditcard_field">
		<label>
			<?php echo __('Typ der Kreditkarte', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<!-- <input class="<?php echo ((in_array("mod_creditcard_typ", 
				(array)$this->view['error']))?'wpsg_error':''); ?>" 
				type="text" name="wpsg_mod_creditcard[typ]" 
				value="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['typ']); ?>" />
			-->
			<select name="wpsg_mod_creditcard[typ]" id="wpsg_mod_creditcard_typ" 
			class="<?php echo ((in_array('mod_creditcard_typ', (array)$this->view['error']))?'wpsg_error':''); ?>" >
				<option value="VISA" selected="selected">VISA</option>
				<option value="MasterCard" >MasterCard</option>
			</select>
			
		</label>
	</div>
	<div class="wpsg_clear"></div>

	<div class="wpsg_mod_creditcard_inhaber wpsg_mod_creditcard_field">
		<label>
			<?php echo __('Inhaber', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<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']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>
	
	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
		<label>
			<?php echo __('Kartennummer', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<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']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>

	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
		<label>
			<?php echo __('Prüfziffer', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<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']); ?>" />
		</label>
	</div>
	<div class="wpsg_clear"></div>

	<div class="wpsg_mod_creditcard_knr wpsg_mod_creditcard_field">
		<label>
			<?php echo __('Gültigkeit', 'wpsg'); ?><span class="wpsg_required">*</span>:
			<!-- <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($this->view['wpsg_mod_creditcard']['gueltig']); ?>" /> -->
			
			<select name="wpsg_mod_creditcard[gueltigm]" id="wpsg_mod_creditcard_gueltigm" 
			class="<?php echo ((in_array('mod_creditcard_gueltigm', (array)$this->view['error']))?'wpsg_error':''); ?>" >
				<option value="01">01</option>
				<option value="02">02</option>
				<option value="03">03</option>
				<option value="04">04</option>
				<option value="05">05</option>
				<option value="06">06</option>
				<option value="07">07</option>
				<option value="08">08</option>
				<option value="09">09</option>
				<option value="10">10</option>
				<option value="11">11</option>
				<option value="12" selected="selected">12</option>
			</select>
			<select name="wpsg_mod_creditcard[gueltigj]" id="wpsg_mod_creditcard_gueltigj" 
			class="<?php echo ((in_array('mod_creditcard_gueltigj', (array)$this->view['error']))?'wpsg_error':''); ?>" >

			</select>			
		</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>

jQuery(document).ready(function() { 
	var gm,
		gj,
		sel1,
		i,
		dt,
		garr;

	gm="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigm']); ?>";
	gj="<?php echo wpsg_hspc($this->view['wpsg_mod_creditcard']['gueltigj']); ?>";

	dt = new Date();
	dt = dt.getFullYear();
    sel1 = document.getElementById("wpsg_mod_creditcard_gueltigj");
    for (i = 0; i < 6; i++) {
        newopt = new Option(dt + i, dt + i, false, false);
        sel1.options[i] = newopt;
    }
    //gm = '06';
    //gj = '2018';
    jQuery('#wpsg_mod_creditcard_gueltigm').val(gm);
    jQuery('#wpsg_mod_creditcard_gueltigj').val(gj);

	
});

//alert(jQuery("#wpsg_mod_creditcard_knr").length);
//$(document).on("input", "#wpsg_mod_creditcard_knr", function () {
jQuery("#wpsg_mod_creditcard_knr").on("input", function () {
	var
		knr,
		typ,
		a1,
		ai,
		isANumber,
		bb = true,
		sum = 0,
		k = 2,
		i;
	//alert("onchange");
	knr = jQuery('#wpsg_mod_creditcard_knr').val();
	typ = jQuery('#wpsg_mod_creditcard_typ').val();
	knr = knr.replace(/ /g, "");
	if (knr.length < 16) { return; }

	isANumber = (isNaN(knr) === false);
	if (isANumber === false) { bb = false; }
	a1 = knr.substr(0, 1);
	ai = parseInt(knr.substr(15, 1), 10);
	if (!(((a1 === "4") && (typ === "VISA")) || ((a1 === "5") && (typ === "MasterCard")))) { bb = false; }
	for (i = 14; i >= 0; i--) {
		sum = sum + k * parseInt(knr.substr(i, 1), 10);
		if (k === 2) { k = 1; } else { k = 2; }
	}
	sum = sum % 10;
	if (sum > 0) { sum = 10 - sum; }
	if (sum !== ai) { bb = false; }

	if (bb === false) {
		alert('Kartennummer fehlerhaft');
	}

});


</script>