<?php session_start();
ob_start();
 if(!isset($_SESSION["id"])){
  header("Location: login");
  exit;
}
if(@$_POST["islem"]=="Paymax"){
  $paymaxad=htmlentities($_POST['paymaxad'], ENT_QUOTES, "UTF-8");
  $paymax_user=htmlentities($_POST['paymax_user'], ENT_QUOTES, "UTF-8");
  $paymax_key=htmlentities($_POST['paymax_key'], ENT_QUOTES, "UTF-8");
  $paymax_magaza=htmlentities($_POST['paymax_magaza'], ENT_QUOTES, "UTF-8");
  $paymax_hash=htmlentities($_POST['paymax_hash'], ENT_QUOTES, "UTF-8");
  $paymaxkomisyon=htmlentities($_POST['paymaxkomisyon'], ENT_QUOTES, "UTF-8");


 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paymax_user'");
$settings->execute(array($paymax_user));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paymax_key'");
$settings->execute(array($paymax_key));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paymax_magaza'");
$settings->execute(array($paymax_magaza));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='paymax_hash'");
$settings->execute(array($paymax_hash));
   
		
 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='5'");
$settings->execute(array($paymaxad,$paymaxkomisyon));
	
          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='5'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay5" 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: Paymax)</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="Paymax">
          </div>

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

   <hr>
            <p class="card-description">
              </p><ul>
                <li>
                  Paymax Dönüş Adresi: <code><?php echo $site; ?>?callback=Paymax</code>
                </li>
              </ul>
            <p></p>
          <hr>
          <div class="form-group">
            <label class="form-group__service-name">Apı User</label>
            <input type="text" class="form-control" name="paymax_user" value="<?php echo $payment["paymax_user"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Api Key</label>
            <input type="text" class="form-control" name="paymax_key" value="<?php echo $payment["paymax_key"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Api Mağaza Kodu</label>
            <input type="text" class="form-control" name="paymax_magaza" value="<?php echo $payment["paymax_magaza"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Api Hash Anahtarı</label>
            <input type="text" class="form-control" name="paymax_hash" value="<?php echo $payment["paymax_hash"]; ?>">
          </div>



          <div class="form-group">
            <label class="form-group__service-name">Paymax Komisyon</label>
            <input type="text" class="form-control" pattern="[0-9.]*" required name="paymaxkomisyon" 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>