<?php session_start();
ob_start();
 if(!isset($_SESSION["id"])){
  header("Location: login");
  exit;
}
if(@$_POST["islem"]=="Shopier"){
  $shopierad=htmlentities($_POST['shopierad'], ENT_QUOTES, "UTF-8");
  $shopier_api=htmlentities($_POST['shopier_api'], ENT_QUOTES, "UTF-8");
  $shopier_sifre=htmlentities($_POST['shopier_sifre'], ENT_QUOTES, "UTF-8");
  $shopier_obs=htmlentities($_POST['shopier_obs'], ENT_QUOTES, "UTF-8");
  $shopier_obssifre=htmlentities($_POST['shopier_obssifre'], ENT_QUOTES, "UTF-8");
  $shopierkomisyon=htmlentities($_POST['shopierkomisyon'], ENT_QUOTES, "UTF-8");


 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='shopier_api'");
$settings->execute(array($shopier_api));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='shopier_sifre'");
$settings->execute(array($shopier_sifre));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='shopier_obs'");
$settings->execute(array($shopier_obs));
 $settings = $db->prepare("UPDATE payment SET deger=? WHERE ad='shopier_obssifre'");
$settings->execute(array($shopier_obssifre));
		
 $settings = $db->prepare("UPDATE pay SET gor_ad=? , komisyon=? WHERE id='2'");
$settings->execute(array($shopierad,$shopierkomisyon));
          header("Location: ?islem=basarili");
      exit;
    
}
			$payys = $db->prepare("select * from pay where id='2'");
    $payys->execute(array());
    $payys = $payys->fetch(PDO::FETCH_ASSOC);
?>
<div id="pay2" 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: Shopier)</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="Shopier">
          </div>

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


          <div class="form-group">
            <label class="form-group__service-name">Shopier Api</label>
            <input type="text" class="form-control" name="shopier_api" value="<?php echo $payment["shopier_api"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Shopier Api Şifre</label>
            <input type="text" class="form-control" name="shopier_sifre" value="<?php echo $payment["shopier_sifre"]; ?>">
          </div>
   <hr>
            <p class="card-description">
              </p><ul>
                <li>
                  Shopier Dönüş Adresi: <code><?php echo $site.$siparisbasarili["url"]; ?>?sip=1</code>
                </li>
                <li>
                  OSB Bildirim Adresi: <code><?php echo $site; ?>?callback=Shopier</code>
                </li>
              </ul>
            <p></p>
          <hr>
        
          <div class="form-group">
            <label class="form-group__service-name">Shopier OSB Api</label>
            <input type="text" class="form-control" name="shopier_obs" value="<?php echo $payment["shopier_obs"]; ?>">
          </div>
          <div class="form-group">
            <label class="form-group__service-name">Shopier OSB Şifre</label>
            <input type="text" class="form-control" name="shopier_obssifre" value="<?php echo $payment["shopier_obssifre"]; ?>">
          </div>

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