<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php

if(!empty($_POST)){

  $username = $_POST['username'];  
  $password = $_POST['password'];  
  $header = $_POST['header'];
  $sip_alindi = $_POST['alindi'];
  $gonderimde = $_POST['gonderimde'];
  $saglayici = $_POST['saglayici'];
  if($sip_alindi){$sip_alindi=1;}else{$sip_alindi=0;}
  if($gonderimde){$gonderimde=1;}else{$gonderimde=0;}


  $update = $dbh->prepare("UPDATE sms_setting SET 
   username = '".$username."',
   password = '".$password."',
   header = '".$header."',
   sip_alindi = '".$sip_alindi."',
   sip_gonderimde = '".$gonderimde."',
   saglayici = '".$saglayici."'
   WHERE id = 1 " );

  $update->execute();

}
?>

<?php
$ayar = $dbh->query("SELECT * FROM sms_setting WHERE id = 1 ", PDO::FETCH_ASSOC);
if ($ayar->rowCount()) {
  foreach ($ayar as $ayar) {
  }
}
?>
<!-- Page Content-->
<div class="page-content">
  <div class="container-fluid">
    <!-- Page-Title -->

    <form method="post" action="" enctype="multipart/form-data">

      <div class="row">
        <div class="col-sm-12">
          <div class="page-title-box">
            <div class="row">
              <div class="col">
                <h4 class="page-title">SMS Ayarları</h4>
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li> 
                  <li class="breadcrumb-item active">SMS Ayarları</li>
                </ol>
              </div><!--end col-->
              <div class="col-auto align-self-center">
                <button class="btn btn-primary" type="submit">
                  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  GÜNCELLE
                </button> 
              </div><!--end col-->  
            </div><!--end row-->                                                              
          </div><!--end page-title-box-->
        </div><!--end col-->
      </div><!--end row-->
      <!-- end page title end breadcrumb -->


      <div class="row">
        <div class="col-lg-12">
          <div class="card">
            <div class="card-header">
              <h4 class="card-title">SMS Ayarları</h4>
              <p class="text-muted mb-0">Değerli kullanıcı, bu alanda Sms modülünü kullanmanız için gerekli ayar bilgilerini girmeniz gerekmektedir.</p> 
            </div><!--end card-header-->
            <div class="card-body">
              <div class="row">


               <div class="col-xl-3"> 
                <div class="form-group">
                  <label for="exampleInputEmail1">Sms Sağlayıcı </label>
                  <select class="form-control" name="saglayici" >
                    <option value="1sms" <?php if($ayar['saglayici']=="1sms"){echo "selected";} ?>>1sms</option>
                    <option value="netgsm" <?php if($ayar['saglayici']=="netgsm"){echo "selected";} ?>>Netgsm</option>
                  </select>
                </div>
              </div>

              <div class="col-xl-3"> 
                <div class="form-group">
                  <label for="exampleInputEmail1">Kullanıcı adı </label>
                  <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="username" value="<?=$ayar['username'];?>" required=""> 
                </div>
              </div>

              <div class="col-xl-3"> 
                <div class="form-group">
                  <label for="exampleInputEmail1">Şifre </label>
                  <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="password" value="<?=$ayar['password'];?>" required=""> 
                </div>
              </div>

              <div class="col-xl-3"> 
                <div class="form-group">
                  <label for="exampleInputEmail1">Başlık </label>
                  <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="header" value="<?=$ayar['header'];?>" required=""> 
                </div>
              </div>


              <div class="col-xl-6"> 
                <center>
                  <div class="form-group">
                   <div class="custom-control custom-switch switch-primary">
                    <input type="checkbox" class="custom-control-input" name="alindi" id="customSwitchPrimary" <?php if($ayar['sip_alindi']==1){echo "checked";} ?>>
                    <label class="custom-control-label" for="customSwitchPrimary">Sipariş Alındı Sms Gönder</label>
                  </div>
                </div>
              </center>
            </div>

            <div class="col-xl-6"> 
              <center>

                <div class="form-group">
                 <div class="custom-control custom-switch switch-primary">
                  <input type="checkbox" class="custom-control-input" name="gonderimde" id="as" <?php if($ayar['sip_gonderimde']==1){echo "checked";} ?>>
                  <label class="custom-control-label" for="as">Sipariş Gönderimde Sms Gönder</label>
                </div>
              </div>
            </center>

          </div>


        </div>


        <br>    
        <button class="btn btn-primary btn-block" type="submit">
          <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
          GÜNCELLE
        </button>
      </form>                                           
    </div><!--end card-body-->
  </div><!--end card-->
</div><!--end col-->


</div><!--end row-->



</div><!-- container -->

<?php include 'inc/footer.php';?>

