<link rel="stylesheet" href="//cdn.crmplus.com.tr/tools/dist/card.css" type="text/css" />
<form style="width:100%;" name="Payment" class="payform fcontrol" id="odeme" method="post" action="<?php echo $cpath?>deppo/tools/vpos/" >
  <input type="hidden" name="Rental_Days" id="Rental_Days" value="<?php echo $_SESSION["Order_Rental_Days"]?>">
  <input type="hidden" name="Rental_Discount" id="Rental_Discount" value="<?php echo $_SESSION["Order_Rental_Discount"]?>">
  <input type="hidden" name="Payment_Method" id="Payment_Method" value="">
  <input type="hidden" name="Payment" id="Payment" value="">
  <input type="hidden" name="Currency" id="Currency" value="<?php echo $kpb;?>">
  <input type="hidden" name="Total" id="Total" value="<?php echo $_SESSION["Order_Total"];?>" tutar="<?php echo $_SESSION["Order_Total"];?>">
  <input type="hidden" name="Interest" id="Interest" value="0">
  <input type="hidden" name="Interest_Percent" id="Interest_Percent" value="0">
  <input type="hidden" name="Installment" id="Installment" value="">
  <input type="hidden" name="Installment_Price" id="Installment_Price" value="">
  <input type="hidden" name="Bank" id="Bank" value="">
  <input type="hidden" name="Bank_Id" id="Bank_Id" value="0">
  <input type="hidden" name="Oid" value="<?php echo $Oid = isset($Oid) && $Oid !== "" ? "VID-" . $Oid : "VID-" . date("ymdHis");?>">
  <input type="hidden" name="aurl" value="<?php echo $aurl = isset($aurl) && $aurl !== "" ? $aurl : uri("domain");?>">
 <input type="hidden" name="burl" value="<?php echo $burl = !empty($_POST["burl"]) ? $_POST["burl"] : uri("full") . "?eticaret/odeme/sonuc/pos/"; $_SESSION["tback"] = $burl; ?>">
  <div class="v3-panel v3-panel-default">
    <div class="v3-panel-heading v3-bg-warning">Ödeme İşlemi</div>
    <div class="v3-tab-content">
      <!-- Güvenli Ödeme -->
      <div class="v3-tab-pane active" id="pos">
        <div class="v3-alert v3-alert-success" role="alert" id="posislem" style="margin:10px 0px; font-size:16px;"><?php echo $sdil[113];?> : <?php echo wprice($_SESSION["Order_Total"]);?> <?php echo $kpb;?></div>
        <!-- Form Ödeme -->
        <div class="v3-row" style="margin-bottom:0px; border-radius:5px;">
          <?php $sqlc=mysqli_query($conn, "select * from genel where ne='card' and s1='".$_SESSION["User_ID"]."' order by t1 asc");?>
          <div class="v3-col-md-12" style="<?php if(mysqli_num_rows($sqlc)==0){echo "display:none;";}?>">
            <div class="v3-col-md-6 v3-col-xs-4" style=""><span id="saved_cards_text"><?php echo translate("Kartlarım")?></span></div>
            <div class="v3-col-md-6 v3-col-xs-8" style="text-align:right;" onclick="toggle('#Card_Form'); toggle('#Saved_Cards'); toggle('#saved_cards_text'); toggle('#taksit_ajax'); jQuery(this).text(function(i, text){ return text === '<?php echo translate("Başka Bir Kart ile Ödeme Yap")?>' ? '<?php echo translate("Kayıtlı Kartlarım")?>' : '<?php echo translate("Başka Bir Kart ile Ödeme Yap")?>';})"><?php echo translate("Başka Bir Kart ile Ödeme Yap")?></div>
          </div>
          <div id="Saved_Cards" style="<?php if(mysqli_num_rows($sqlc)==0){echo "display:none;";}?>">
            <div class="v3-col-md-12 owl-carousel orders owl-theme">
              <?php $a=0;while($cards=mysqli_fetch_assoc($sqlc)){$jsci = json_decode($cards["n1"], true); $a++;?>
              <div class="item">
                <div class="" style="padding:5px;" id="dsc<?php echo $cards["id"]?>">
                  <label for="sc<?php echo $cards["id"]?>" style="width:100%; border:1px solid #ccc; padding:10px; border-radius:10px; font-weight:100; cursor:pointer; position:relative;"> <a onclick="AjaxPResult('sale/ajax.php?ne=del_saved_card&id=<?php echo $cards["id"]?>','','','nopl',''); hide('#dsc<?php echo $cards["id"]?>')" style="position: absolute; right: 15px; top: 10px;" class="fas fa-trash cp"></a> <img src="https://cdn.<?php echo $cdnurl?>/images/banks/ib<?php echo sha($jsci["Bank_ID"],"+".$cards["t4"]."","d")?>.png" title="" style="margin-top: 11px; width: 50px; position: absolute; right: 10px; bottom: 11px;">
                    <input type="radio" name="scard_info" class="scard" id="sc<?php echo $cards["id"]?>" data-pan="<?php echo sha($jsci["Pan"],"+".$cards["t4"]."","d")?>" data-name="<?php echo sha($jsci["Name"],"+".$cards["t4"]."","d")?>" data-surname="<?php echo sha($jsci["Surname"],"+".$cards["t4"]."","d")?>" data-expire="<?php echo sha($jsci["Expire"],"+".$cards["t4"]."","d")?>" data-cv2="<?php echo sha($jsci["Cv2"],"+".$cards["t4"]."","d")?>" <?php if($a==1){echo "checked";}?> style="margin-bottom: 15px;">
                    <b><?php echo sha($jsci["Bank"],"+".$cards["t4"]."","d")?></b><br>
                    **** **** **** <?php echo substr(sha($jsci["Pan"],"+".$cards["t4"]."","d"), -4)?><br>
                    <?php echo sha($jsci["Expire"],"+".$cards["t4"]."","d")?> </label>
                </div>
              </div>
              <?php }?>
            </div>
          </div>
          <div id="Card_Form" style="<?php if(mysqli_num_rows($sqlc)>0){echo "display:none;";}?>">
            <input type="hidden" name="Card_Bank" id="Card_Bank" value="">
            <input type="hidden" name="Card_Bank_ID" id="Card_Bank_ID" value="">
            <input type="hidden" name="Card_Type" id="Card_Type" value="">
            <div class="v3-col-md-5 mdn" style="margin-top: 5px;">
              <div class="vcard-wrapper"></div>
            </div>
            <div class="v3-col-md-7" style="">
              <div class="v3-row" style="margin-top:14px; ">
                <div class="v3-col-md-12">
                  <input type="text" name="Card_Number" id="Card_Number" class="v3-form-control icontrol" data-mask="0000 0000 0000 0000" placeholder="<?php echo translate('Kart No','Card Number')?>" style="border: solid 1px #cccccc; height: 55px;" value="">
                </div>
              </div>
              <div class="v3-row" style="margin-top:10px;">
                <div class="v3-col-md-6">
                  <input type="text" name="Card_Name" id="Card_Name" class="v3-form-control icontrol" placeholder="<?php echo translate('Ad','Name On Card')?>" style="border: solid 1px #cccccc; height: 55px;"/>
                </div>
                <div class="v3-col-md-6" style="<?php if($mobile<>""){?>margin-top:10px;<?php }?>">
                  <input type="text" name="Card_Surname" id="Card_Surname" class="v3-form-control icontrol" placeholder="<?php echo translate('Soyad','Surname On Card')?>" style="border: solid 1px #cccccc; height: 55px;"/>
                </div>
              </div>
              <div class="v3-row" style="margin-top:10px;">
                <div class="v3-col-md-6" style="padding: 0px 15px;">
                  <div class="v3-row">
                    <div class="v3-col-md-6 v3-col-xs-6">
                      <select id="aksk" class="v3-form-control icontrol" style="border: solid 1px #cccccc; height: 55px;">
                        <option value=""><?php echo translate("Ay","Month");?></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 class="v3-col-md-6 v3-col-xs-6">
                      <select id="yksk" class="v3-form-control icontrol" style="border: solid 1px #cccccc; height: 55px;">
                        <option value=""><?php echo translate("Yıl","Year");?></option>
                        <?php for ($y=date("Y"); $y <= date("Y")+15; $y++) {?>
                        <option value="<?php echo $y?>"><?php echo $y?></option>
                        <?php }?>
                      </select>
                    </div>
                  </div>
                <script>
					jQuery('#aksk').on('change', function() {
						$yksk=jQuery("#yksk option:selected").val();
						$aksk=this.value;
						document.getElementById("Card_Expiry").value = ""+$aksk+" / "+$yksk+"";
						});
						jQuery('#yksk').on('change', function() {
						$aksk=jQuery("#aksk option:selected").val();
						$yksk=this.value;
						document.getElementById("Card_Expiry").value = ""+$aksk+" / "+$yksk+"";
					});
				</script>
                  <input type="hidden" name="Card_Expiry" id="Card_Expiry" class="form-control icontrol" data-mask="99 / 9999" placeholder="<?php echo translate('Son Kullanma','Expiration Date')?> - 01 / 2020" style=""/>
                </div>
                <div class="v3-col-md-6" style="<?php if($mobile<>""){?>margin-top:10px;<?php }?>">
                  <input type="text" name="Card_Cvv"  id="Card_Cvv" class="v3-form-control icontrol" placeholder="Cvv" style="border: solid 1px #cccccc; height: 55px;"/>
                </div>
                <div class="v3-col-md-12" style="<?php if($mobile<>""){?>margin-top:10px; margin-bottom:10px;<?php }?>">
                  <div style="<?php if($_SESSION["User_ID"]=="" or ($_SESSION["User_ID"]<>"" and $module["etahsilat_scard"]<>1)){echo "display:none;";}else{echo "display:flex;";}?> margin-top: 13px;">
                    <input type="checkbox" name="SaveCard" onclick="toggle('#SaveCardInput')" value="1" style="width: 20px; height: 25px;">
                    <span id="SaveCardTxt" style="margin-left: 10px; margin-top: 6px;">Kart Bilgilerimi Sakla <i class="fa fa-info-circle" aria-hidden="true" data-toggle="tooltip" data-placement="top" title="Kart Bilgilerinizi Sonraki İşlemlerinizde Kullanmak Üzere, Yüksek Güvenlik Önlemleri Aldığımız, Özel Şifreleme Teknolojileri kullandığımız alanda saklayabilirsiniz"></i></span>
                    <input class="v3-form-control mw92 w42" id="SaveCardInput" style="display:none; height: 34px; border: 1px solid silver; margin-left: 5px;" type="text" name="CardName" placeholder="<?php echo translate("Kartınıza bir isim verin")?>">
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div id="taksit_ajax" class="v3-row" style="margin-top:15px;margin-right: -8px; margin-left: -8px;"></div>
        <script src="//cdn.crmplus.com.tr/tools/dist/card.js"></script>
      </div>
		<img class="fl" src="https://cdn.crmplus.com.tr/images/hizliode_paymethod.png">		
		<button type="submit" class="v3-btn v3-btn-warning fr"><i class="fas fa-lock v3-text-success"></i> Ödeme</button>
      <!-- Güvenli Ödeme -->
    </div>
  </div>
  </div>
  </div>
  <?php if(mysqli_num_rows($sql_soz)>0){?>
  <!-- sozlesme -->
  <div class="v3-panel" style="margin-top:20px;">
    <div class="v3-panel-heading v3-panel-warning"><?php echo sabit($rs_soz["id"],"sayfa","t1");?> <a href="javascript:void(0);" onClick="divyaz('mss')" class="noprint fa fa-print" style="float: right;"></a></div>
    <div class="v3-panel-body" id="mss" style="height:250px; overflow:auto;background: white;"> <?php echo rlang(sabit($rs_soz["id"],"sayfa","n1"));?> </div>
    <div class="v3-panel-footer" style="font-size: 12px;"><?php echo translate("Siparişi tamamla butonuna basmanız halinde seçmiş olduğunuz ödeme yöntemine uygun olarak ilgili tutar tahsil edilecektir.");?></div>
  </div>
  <!-- sozlesme -->
  <?php }?>
</form>
<script>
	jQuery(document).ready(function(){
		jQuery(".payment li").first().addClass('active');
		jQuery(".v3-tab-content .v3-tab-pane").first().addClass('active');
		payment();
		
		scard(); thesap();
		var card = new Card({
			form: '.payform',
			container: '.vcard-wrapper',
			formSelectors: {
				nameInput: 'input[name="Card_Name"], input[name="Card_Surname"]'
			}
		});
		
		jQuery(".scard").change(function(){
			scard(); thesap();
		});
		jQuery('#Card_Number, #Total').keyup(delay(thesap, 1000));
		function thesap(){
			vtutar=jQuery('#Total').attr("tutar");
			kno=jQuery('#Card_Number').val().replaceAll(/\s/g,'');
			if(kno.substr(0, 4)=='0000'){
				jQuery('#Card_Name').val('test'); jQuery('#uad').val('test');
				jQuery('#Card_Surname').val('test'); jQuery('#usoyad').val('test');
				jQuery("#aksk").val("01");
				jQuery("#yksk").val("2030");
				jQuery("#Card_Expiry").val("01 / 2030");
				jQuery('#Card_Cvv').val('000');
				jQuery('#Card_Bank_ID').val('16');
				jQuery("#Card_Bank").val('Test Card');
				jQuery('#Card_Type').val('visa');
				jQuery('#uacik').val('test işlem');
			}
			setTimeout(function(){
				if(jQuery('#Bank').val().length === 0){
					 jQuery(".order_complate_btn").attr("disabled", true);
				}else{
					jQuery(".order_complate_btn").removeAttr("disabled");
				}
			}, 1000);
			if(kno.length > 5){
				show('#taksit_ajax');
				jQuery('#taksit_ajax').load('<?php echo $cpath?>deppo/tools/vpos/installment.php?tutar='+vtutar+'&kno='+kno+'');
			}
		}
		if(document.getElementById("ksk")!=undefined){
			jQuery(document).ready(function () {
				jQuery("#Card_Expiry").mask("99 / 9999");
			});
		}
		function clear_form(selector){
			jQuery(selector).each(function() {
				jQuery(this).val('');
			});
		}
		function scard(e){
			jQuery('.scard:radio').each(function(index) {
				if(jQuery(this).is(':checked')) {
					var pan = jQuery(this).attr("data-pan");
					var expire = jQuery(this).attr("data-expire");
					var name = jQuery(this).attr("data-name");
					var surname = jQuery(this).attr("data-surname");
					var cv2 = jQuery(this).attr("data-cv2");
					jQuery('#Card_Number').val(pan);
					jQuery('#Card_Name').val(name);
					jQuery('#Card_Surname').val(surname);
					jQuery('#Card_Cvv').val(cv2);
					jQuery('#Card_Expiry').val(expire);
				}
			});
		}
		jQuery('.payment>li').on('click',delay(function(){
			payment();
		},500));
		function payment() {
			var type = jQuery(".payment li.active").attr("payment_type");
			var text = jQuery(".payment li.active").attr("payment_text");
			jQuery('#Payment_Method').val(type);
			jQuery('#Payment').val(text);
			jQuery('#Bank').val('');
			jQuery('#Bank_Id').val('');
			jQuery('#Total').val('');
			jQuery('#Card_Number').val('');
			jQuery('#Card_Name').val('');
			jQuery('#Card_Surname').val('');
			jQuery('#Card_Cvv').val('');
			jQuery('#Card_Expiry').val('');
			jQuery(".order_complate_btn").removeAttr("disabled");
			jQuery(".payform").attr("action","<?php echo $cpath?>deppo/tools/vpos/");
			jQuery('#Total').val('<?php echo wprice($_SESSION["Order_Total"]);?>');
			jQuery('.order_total_price').html('<?php echo wprice($_SESSION["Order_Total"]);?>');
			jQuery('.order_total_prices').html('<?php echo wprice($_SESSION["Order_Total"]);?>');
			jQuery('#order_sum_item').html('');
			setTimeout(function(){
				if(jQuery('#Bank').val().length === 0){
					 jQuery(".order_complate_btn").attr("disabled", true);
				}
			}, 1000);
		} 
	});
</script>
<?php echo $footer;?>