
	
	
	<?php
if(!empty($_GET["ID"]))
{
  $ID=$VT->filter($_GET["ID"]);
    $veri=$VT->VeriGetir("uyeler","WHERE ID=?",array($ID),"ORDER BY ID ASC",1);
    if($veri!=false)
    {
      ?>
 <div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-sm-6">
          <h1>Müşteri Hesap Düzenle</h1>
        </div>
        <div class="col-sm-6">
          <ol class="breadcrumb float-sm-right">
            <li class="breadcrumb-item"><a href="<?=SITE?>">Anasayfa</a></li>
            <li class="breadcrumb-item"><a href="<?=SITE?>uyeler">Müşteri Liste</a></li>
            <li class="breadcrumb-item active">Müşteri Düzenle</li>
          </ol>
        </div>
      </div>
    </div><!-- /.container-fluid -->
  </section>
  <!-- Main content -->
  <section class="content">
    <div class="container-fluid">
     <div class="row">
      <div class="col-md-8">
      <?php
      if($_POST)
      {
        if(!empty($_POST["ad"]) && !empty($_POST["soyad"]) && !empty($_POST["mail"]) && !empty($_POST["telefon"]) && !empty($_POST["adres"]) && !empty($_POST["ilce"]) && !empty($_POST["ilID"]) && ctype_digit($_POST["ilID"]) && !empty($_POST["postakodu"]))
        {
            $ad=$VT->filter($_POST["ad"]);
            $soyad=$VT->filter($_POST["soyad"]);
            $mail=$VT->filter($_POST["mail"]);
            $telefon=$VT->filter($_POST["telefon"]);
            $adres=$VT->filter($_POST["adres"]);
            $ilce=$VT->filter($_POST["ilce"]);
            $ilID=$VT->filter($_POST["ilID"]);
            $postakodu=$VT->filter($_POST["postakodu"]);
            if($veri[0]["tipi"]==2)
            {
              if(!empty($_POST["firmaadi"]) && !empty($_POST["vergidairesi"]) && !empty($_POST["vergino"]))
              {
                  /*Kurumsal bir üye ise*/
                  $firmaadi=$VT->filter($_POST["firmaadi"]);
                  $vergidairesi=$VT->filter($_POST["vergidairesi"]);
                  $vergino=$VT->filter($_POST["vergino"]);
                   $guncelle=$VT->SorguCalistir("UPDATE uyeler","SET ad=?, soyad=?, telefon=?, mail=?, adres=?, ilce=?, ilID=?, firmaadi=?, vergidairesi=?, vergino=?, postakodu=? WHERE ID=?",array($ad,$soyad,$telefon,$mail,$adres,$ilce,$ilID,$firmaadi,$vergidairesi,$vergino,$postakodu,$veri[0]["ID"]),1);
                if($guncelle!=false)
                {
                  ?>
                  <div class="alert alert-success">Müşteri bilgileriniz başarıyla güncellendi.</div>
                  <?php
                  $veri=$VT->VeriGetir("uyeler","WHERE ID=?",array($veri[0]["ID"]),"ORDER BY ID ASC",1);
                }
                else
                {
                  ?>
                <div class="alert alert-danger">İşleminiz sırasında bir sorunla karşılaşıldı. Lütfen daha sonra tekrar deneyiniz.</div>
                <?php
                }
              }
              else
              {
                 ?>
                  <div class="alert alert-danger">Boş bıraktığınız alanları doldurunuz.</div>
                  <?php
              }
            }
            else
            {
                /*Bireysel üye bilgisinin güncellenmesi*/
                $guncelle=$VT->SorguCalistir("UPDATE uyeler","SET ad=?, soyad=?, telefon=?, mail=?, adres=?, ilce=?, ilID=?, postakodu=? WHERE ID=?",array($ad,$soyad,$telefon,$mail,$adres,$ilce,$ilID,$postakodu,$veri[0]["ID"]),1);
                if($guncelle!=false)
                {
                  ?>
                  <div class="alert alert-success">Müşteri bilgileriniz başarıyla güncellendi.</div>
                  <?php
                  $veri=$VT->VeriGetir("uyeler","WHERE ID=?",array($veri[0]["ID"]),"ORDER BY ID ASC",1);
                }
                else
                {
                  ?>
                <div class="alert alert-danger">İşleminiz sırasında bir sorunla karşılaşıldı. Lütfen daha sonra tekrar deneyiniz.</div>
                <?php
                }
            }

        }
        else
        {
          ?>
          <div class="alert alert-danger">Boş bıraktığınız alanları doldurunuz.</div>
          <?php
        }
      }
      ?>
    </div>
      <!-- left column -->
      <div class="col-md-12">
        <!-- Horizontal Form -->
        <div class="card card-info">
          <div class="card-header">
            <h3 class="card-title">Müşteri Hesap Düzenle</h3>
          </div>
          <!-- /.card-header -->

          <form action="#" method="post">
            <div class="card-body">

              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">İsim</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="ad" value="<?=$veri[0]["ad"]?>">
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Soyad</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="soyad" value="<?=$veri[0]["soyad"]?>">
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">E-posta Adresi</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="mail" value="<?=$veri[0]["mail"]?>">
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Telefon</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="telefon" value="<?=$veri[0]["telefon"]?>">
                </div>
              </div>  
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Fatura Adresi</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="adres" value="<?=stripslashes($veri[0]["adres"])?>">
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Fatura İlçesi</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="ilce" value="<?=$veri[0]["ilce"]?>">
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Fatura İl Bilgisi</label>
                <div class="col-sm-8">
                  <select name="ilID" class="form-control">
                    <?php
                    $iller=$VT->VeriGetir("il");
                    if($iller!=false)
                    {
                      for ($i=0; $i < count($iller); $i++) { 
                        if($veri[0]["ilID"]==$iller[$i]["ID"])
                        {
                            ?>
                        <option value="<?=$iller[$i]["ID"]?>" selected><?=$iller[$i]["ADI"]?></option>
                        <?php
                        }
                        else
                        {
                          ?>
                        <option value="<?=$iller[$i]["ID"]?>"><?=$iller[$i]["ADI"]?></option>
                        <?php
                        }
                        
                      }
                    }
                    ?>

                  </select>
                </div>
              </div> 
              <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Fatura Posta Kodu</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="postakodu" value="<?=$veri[0]["postakodu"]?>">
                </div>
              </div> 


              <?php
              if($veri[0]["tipi"]==2)
              {
                /*Kurumsal bir üye ise*/
                ?>
                 <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Firma Adı</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="firmaadi" value="<?=stripslashes($veri[0]["firmaadi"])?>">
                </div>
              </div>
               <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Firma Vergi Dairesi</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="vergidairesi" value="<?=stripslashes($veri[0]["vergidairesi"])?>">
                </div>
              </div>
               <div class="form-group row">
                <label for="inputPassword3" class="col-sm-2 col-form-label">Firma Vergi Numarası</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" name="vergino" value="<?=stripslashes($veri[0]["vergino"])?>">
                </div>
              </div>
                <?php
              }

              ?>

            </div>
            <!-- /.card-body -->
            <div class="card-footer">
              <button type="submit" name="ekle" class="btn btn-info">Kaydet</button> 
              <!-- /.card-footer -->
            </form>
          </div>
        </div>
      </div> 
    </section>
    <!-- /.content -->
  </div>
<?php
}
}
?>