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


 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paypal_business'");
$settings->execute(array($paypal_business));
		
 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='8'");
$settings->execute(array($paytrad,$paytrkomisyon));
	
          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='8'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay8" 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: Paypal)</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="Paypal">
          </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>
                  Paypal Dönüş Adresi: <code><?php echo $site; ?>?callback=Paypal</code>
                </li>
              </ul>
            <p></p>
          <hr>
          <div class="form-group">
            <label class="form-group__service-name">Business Mail</label>
            <input type="text" class="form-control" name="paypal_business" value="<?php echo $payment["paypal_business"]; ?>">
          </div>


          <div class="form-group">
            <label class="form-group__service-name">Paypal Komisyon</label>
            <input type="text" class="form-control" pattern="[0-9.]*" required name="paytrkomisyon" value="<?php echo $payys["komisyon"]; ?>">
          </div>
 
        </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>