<?php session_start();
ob_start();
 if(!isset($_SESSION["id"])){
  header("Location: login");
  exit;
}
if(@$_POST["islem"]=="PayTR-EFT"){
  $paytrad=htmlentities($_POST['paytrad'], ENT_QUOTES, "UTF-8");
  $paytr_no=htmlentities($_POST['paytr_no'], ENT_QUOTES, "UTF-8");
  $paytr_sifre=htmlentities($_POST['paytr_sifre'], ENT_QUOTES, "UTF-8");
  $paytr_anahtar=htmlentities($_POST['paytr_anahtar'], ENT_QUOTES, "UTF-8");
  $paytrbanka_komisyon=htmlentities($_POST['paytrbanka_komisyon'], ENT_QUOTES, "UTF-8");

  
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paytr_no'");
$settings->execute(array($paytr_no));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paytr_sifre'");
$settings->execute(array($paytr_sifre));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paytr_anahtar'");
$settings->execute(array($paytr_anahtar));
		
 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='4'");
$settings->execute(array($paytrad,$paytrbanka_komisyon));
          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='4'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay4" class="modal fade" role="dialog">
  <div class="modal-dialog modal-lg">

    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title">Ödeme methodu düzenle (Method: PayTR-EFT)</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
  <form class="form" action="" method="post">

        <div class="modal-body">

          <div class="form-group">
            <label class="form-group__service-name">Method adı</label>
            <input type="text" class="form-control" readonly="" name="islem" value="PayTR-EFT">
          </div>

          <div class="form-group">
            <label class="form-group__service-name">Görünür adı</label>
            <input type="text" class="form-control" name="paytrad" value="<?php echo $payys["gor_ad"]; ?>">
          </div>

   <hr>
            <p class="card-description">
              </p><ul>
                <li>
                  PayTR Dönüş Adresi: <code><?php echo $site; ?>?callback=PayTR</code>
                </li>
              </ul>
            <p></p>
          <hr>
          <div class="form-group">
            <label class="form-group__service-name">PayTR Mağaza No</label>
            <input type="text" class="form-control" name="paytr_no" value="<?php echo $payment["paytr_no"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">PayTR Api Şifre</label>
            <input type="text" class="form-control" name="paytr_sifre" value="<?php echo $payment["paytr_sifre"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">PayTR Api Anahtar</label>
            <input type="text" class="form-control" name="paytr_anahtar" value="<?php echo $payment["paytr_anahtar"]; ?>">
          </div>



          <div class="form-group">
            <label class="form-group__service-name">PayTR Komisyon (Banka)</label>
            <input type="text" class="form-control" pattern="[0-9.]*" required name="paytrbanka_komisyon" value="<?php echo $payys["komisyon"]; ?>">
          </div>

          <div class="modal-footer" style="display: flex; justify-content: flex-start;">
            <button type="submit" class="btn guncelle mt-0">
            Ayarları güncelle                   
            </button>
            <a href="?pasif=<?php echo $payys["id"];?>"  class="btn guncelle" style="margin: 0 0 4px 0">Pasifleştir</a>

            <button type="submit" data-dismiss="modal" class="btn guncelle guncelle-dark mt-0">
            Vazgeç                 
            </button>
          </div>
          </form>
    </div>

  </div>
</div>