
	
	<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>Yeni Müşteri Oluştur</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">Yeni Müşteri Oluştur</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"]) && ctype_digit($_POST["sifre"]) && !empty($_POST["postakodu"]) && !empty($_POST["client_type"]))
          {
            $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"]);
            $sifre=md5($VT->filter($_POST["sifre"]));
            $tipi=$VT->filter($_POST["client_type"]);
            $postakodu=$VT->filter($_POST["postakodu"]);
            if($tipi=="company")
            {
              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("INSERT INTO uyeler","SET ad=?, soyad=?, telefon=?, mail=?, adres=?, ilce=?, ilID=?, firmaadi=?, vergidairesi=?, vergino=?, postakodu=?, sifre=?, tipi=?, durum=?, tarih=?",array($ad,$soyad,$telefon,$mail,$adres,$ilce,$ilID,$firmaadi,$vergidairesi,$vergino,$postakodu,$sifre,2,1,date("Y-m-d")));
                if($guncelle!=false)
                {
                  ?>
                  <div class="alert alert-success">Müşteri bilgileriniz başarıyla güncellendi.</div>
                  <?php
                }
                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("INSERT INTO uyeler","SET ad=?, soyad=?, telefon=?, mail=?, adres=?, ilce=?, ilID=?, postakodu=?, sifre=?, tipi=?, durum=?, tarih=?",array($ad,$soyad,$telefon,$mail,$adres,$ilce,$ilID,$postakodu,$sifre,1,1,date("Y-m-d")));
            if($guncelle!=false)
            {
              ?>
              <div class="alert alert-success">Müşteri bilgileriniz başarıyla güncellendi.</div>
              <?php
            }
            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 Oluştur</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" placeholder="İsim">
              </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" placeholder="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" placeholder="E-posta Adresi">
              </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" placeholder="Telefon">
              </div>
            </div> 

            <div class="form-group row">
              <label for="inputPassword3" class="col-sm-2 col-form-label">Şifre</label>
              <div class="col-sm-8">
                <input type="Password" class="form-control" name="sifre" placeholder="Şifre">
              </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" placeholder="Fatura 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" placeholder="Fatura İlçesi">
              </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-2">
                <select name="ilID" class="form-control">
                  <?php
                  $iller=$VT->VeriGetir("il");
                  if($iller!=false)
                  {
                    for ($i=0; $i < count($iller); $i++) { 

                      ?>
                      <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-2">
                <input type="text" class="form-control" name="postakodu" placeholder="Posta Kodu">
              </div>
            </div> 
            <div class="form-group">
              <label class="container_radio" style="display: inline-block; margin-right: 15px;">Bireysel
                <input type="radio" name="client_type" class="uyelikSecim" checked value="private">
                <span class="checkmark"></span>
              </label>
              <label class="container_radio" style="display: inline-block;">Kurumsal
                <input type="radio" name="client_type" class="uyelikSecim" value="company">
                <span class="checkmark"></span>
              </label>
            </div>
            <div class="gizliAlan" style="display: none;">
             <div class="form-group row">
              <label for="inputPassword3" class="col-sm-2 col-form-label">Firma Adı</label>
              <div class="col-sm-3">
                <input type="text" class="form-control" name="firmaadi" placeholder="Firma Adı">
              </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-3">
                <input type="text" class="form-control" name="vergidairesi" placeholder="Firma Vergi Dairesi">
              </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-3">
                <input type="text" class="form-control" name="vergino" placeholder="Vergi Numarası">
              </div>
            </div>
          </div>

        </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>
