<?php include 'header.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>

<?php
$profilBegeni = $db->query("SELECT COUNT(*) FROM begeniler where begenilen_id = '{$myUser['user_id']}'")->fetchColumn();


if($_GET['visitor']==1){

echo '<script type="text/javascript">
    
$( document ).ready(function() {

    setTimeout(function(){ 
$("#ModalBasic").modal("show");
}, 500);



});

</script>';



}


?>



<script type="text/javascript">
    
    $(function() {

    $("#resim").change(function(ex) { //her hangi bir şey seçilirse


        var file_data = $('#resim').prop('files')[0];
        var form_data = new FormData();
        form_data.append('resim', file_data);

        if (file_data != null) {



            $.ajax({
                url: 'assets/pp.php', // point to server-side PHP script 
                dataType: 'text', // what to expect back from the PHP script, if anything
                cache: false,
                contentType: false,
                processData: false,
                data: form_data,
                type: 'post',

                success: function(result) {
                    var json = JSON.parse(result);

                    //$('#ppm').attr("src",json.resimLink);
                    //alert('yuklendi')



                    Swal.fire({
                                        type: 'success',
                                        title: 'Başarılı!',
                                        html: 'Profil Resminiz Başarıyla Güncellendi!',
                                        confirmButtonColor: 'green',
                                        showCancelButton: false,
                                        allowOutsideClick: false,
                                        confirmButtonText: 'Tamam'
                                    }).then((result) => {
                                        if (result.value) {

                                            location.reload();

                                        }
                                    })





                }
            });

        }

    });
})


    function temizlepp(){



// var myvar = '<div class="custom-file-upload">'+
// '                        <input type="file" id="resim" name="resimYukle" accept=".png, .jpg, .jpeg">'+
// '                        <label for="resim">'+
// '                            <span>'+
// '                                <strong>'+
// '                                    <ion-icon name="cloud-upload-outline"></ion-icon>'+
// '                                    <i>Dokun ve Resim Seç</i>'+
// '                                </strong>'+
// '                            </span>'+
// '                        </label>'+
// '                    </div>';
    

    



//         $("#resimgun").html(myvar)
    }

function hesapKapat(){






Swal.fire({
  title: 'Emin misiniz?',
  text: "Hesabınız kapatıldıktan sonra tekrar giriş yapamaz ve tekrar kullanamazsınız!",
  type: 'warning',
  showCancelButton: true,
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: 'Kabul Ediyorum!',
  cancelButtonText: 'Vazgeç'
}).then((result) => {
  if (result.value) {
    var url = "assets/api.php";
    var bilgi = {
        type: "hesapKapat"
    }

        $.post(url, bilgi, function(response) {
        var json = JSON.parse(response);
        if (json.result == "1") {
    Swal.fire(
      'Başarılı!',
      'Hesabınız başarıyla silindi.',
      'success'
    )

    setTimeout(function(){ 
        location.reload();
     }, 3000);
            
        }else{
            alert('hesap kapanmadı')
            location.reload();
        }
        }
        )
  }
})












}

    function bilgiGuncelle() {
        
var url = "assets/api.php";
    var bilgi = {
        type: "bilgi_guncelle",
        yas: $("#yas option:selected").val(),
        cinsiyet: $("#cinsiyet option:selected").val(),
        sehir: $("#sehir option:selected").val(),
        isimsoyisim: $("#isimsoyisim").val(),
        instagram: $("#instagram").val(),
        boy: $("#boy").val(),
        kilo: $("#kilo").val(),
        telefon: $("#telefon").val()

    }

    $.post(url, bilgi, function(response) {
        var json = JSON.parse(response);
        if (json.result == "1") {

            //window.location.href = "index.php";
// swal.fire({
// title: 'Başarılı!',
// html: "Bilgileriniz Başarıyla Güncellendi!",
// type: 'success',
// showCancelButton: false,
// confirmButtonColor: 'green',
// confirmButtonText: 'Tamam'
// }).then((result) => {
//   /* Read more about isConfirmed, isDenied below */
//   if (result.isConfirmed) {
//    // Swal.fire('Saved!', '', 'success')
 
//   }});


                                    Swal.fire({
                                        type: 'success',
                                        title: 'Başarılı!',
                                        html: 'Bilgileriniz Başarıyla Güncellendi!',
                                        allowOutsideClick: false,
                                        confirmButtonColor: 'green',
                                        showCancelButton: false,
                                        confirmButtonText: 'Tamam'
                                    }).then((result) => {
                                        if (result.value) {

                                            location.reload();

                                        }
                                    })





        } else if (json.result == "2") {

            alert('bos alan var')


        }else if (json.result == "6") {

            alert('Geçerli Bir İsim Soyisim Girin')


        } else {
            alert('hata')
        }
        $("#tamamla").html('<ion-icon name="reload-outline" role="img" class="md hydrated" aria-label="mail outline"></ion-icon> Bilgileri Güncelle')
        $('#tamamla').prop('disabled', false);
    })


    // $('#tamamla').prop('disabled', true);
    // $("#tamamla").html('<span class="spinner-border spinner-border-sm mr-05" role="status" aria-hidden="true"></span> Lütfen Bekleyin!')


    }

</script>

<div id="appCapsule">
        <div class="section-full mb-4">
           

<?php

        if($myUser['user_picture']=="assets/img/no-avatar.png"){
            if($myUser['user_cinsiyet']=="kadin"){
                $myUser['user_picture'] = "assets/img/k.png";
            }else if($myUser['user_cinsiyet']=="erkek"){
                $myUser['user_picture'] = "assets/img/e.png";
            }else{
                $myUser['user_picture'] = $myUser['user_picture'];
            }
        }

?>


        <div class="section mt-2 mb-2">
            <div class="card bg-primary comment-box">
                <img id="ppm" src="<?=$myUser['user_picture']?>" alt="avatar" class="imaged w200" style="border-radius: 5% !important;">
                <h4 class="card-title"><?=$myUser['user_fullname']?></h4> 
                <div class="card-text"><?=$myUser['user_sehir']?>, <?=$myUser['user_yas']?></div>
                <div class="text">



				<button type="button" class="btn btn-success btn-block" data-toggle="modal" data-target="#profil_duzenle">
                    <ion-icon name="cog-outline" role="img" class="md hydrated" aria-label="mail outline"></ion-icon>
                    Profilini Düzenle
                </button>
                </div>
            </div>
        </div>

<div class="listview-title mt-2">Kişisel Bilgiler (Üstteki Buton ile Düzenleyebilirsiniz)</div>
<ul class="listview image-listview">

<!-- <?php if(!empty($myUser['user_telefon'])){ ?>
<li>
<div class="item">
<div class="icon-box bg-success">
<ion-icon name="call-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Telefon Numarası</div>
<span class="badge badge-danger"><?=$myUser['user_telefon']?></span>
</div>
</div>
</li>
<?php } ?> -->


<!-- <?php if(!empty($myUser['user_instagram'])){ ?>
<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #F56040 !important;">
<ion-icon name="logo-instagram" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Instagram Profili</div>
<span class="badge badge-danger"><?=$myUser['user_instagram']?></span>
</div>
</div>
</li>
<?php } ?> -->


<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #25a0ca !important;">
<ion-icon name="location-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Şehir</div>
<span class="badge badge-danger"><?=$myUser['user_sehir']?></span>
</div>
</div>
</li>
<li>
<div class="item">
<div class="icon-box bg-primary">
<ion-icon name="calendar-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Yaş</div>
<span class="badge badge-danger"><?=$myUser['user_yas']?></span>
</div>
</div>
</li>

<?php if(!empty($myUser['user_boy'])){ ?>
<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #ff5a8c !important;">
<ion-icon name="man-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Boy</div>
<span class="badge badge-danger"><?=$myUser['user_boy']?></span>
</div>
</div>
</li>
<?php } ?>

<?php if(!empty($myUser['user_kilo'])){ ?>
<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #d555ff !important;">
<ion-icon name="pizza-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Kilo</div>
<span class="badge badge-danger"><?=$myUser['user_kilo']?></span>
</div>
</div>
</li>
<?php } ?>

<li>
<div class="item">
<div class="icon-box bg-danger">
<ion-icon name="heart-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
</div>
<div class="in">
<div>Profil Beğenisi</div>
<span class="badge badge-info"><?=$profilBegeni?> Beğeni Aldınız</span>
</div>
</div>
</li>

        </ul>




<br>    

        </div>

        <div class="modal fade modalbox" id="profil_duzenle" data-backdrop="static" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Profilini Düzenle</h5>
                        <a href="javascript:void(0);" data-dismiss="modal">Vazgeç</a>
                    </div>
          




         <div class="modal-body p-0">
<div class="section mt-2">






            <div class="section-title">Profil Resmini Değiştir</div>
            <div class="wide-block pb-2 pt-2">

                <form id="resimgun">
                    <div class="custom-file-upload">
                        <input type="file" id="resim" name="resimYukle" accept=".png, .jpg, .jpeg">
                        <label for="resim">
                            <span>
                                <strong>
                                    <ion-icon name="cloud-upload-outline"></ion-icon>
                                    <i>Dokun ve Resim Seç</i>
                                </strong>
                            </span>
                        </label>
                    </div>

                </form>

            </div>
    


            <div class="section-title">Kişisel Bilgiler</div>
            <div class="wide-block pb-1 pt-1">

                <form>

                    <ul class="listview image-listview no-line no-space flush">

<?php 

if($myUser['user_jeton']>0){ 

$inptype = " style='display: block;'";
}else{
$inptype = " style='display: none;'";
}

    ?>

                        <li<?=$inptype?>>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #F56040 !important;">
                                    <ion-icon name="person-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="password6">İsim Soyisim</label>
                                            <input type="text" class="form-control" id="isimsoyisim" value="<?=$myUser['user_fullname']?>">
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Doğru Bir İsim Soyisim Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li>

<!--                         <li>
                            <div class="item">
                                <div class="icon-box bg-success">
                                    <ion-icon name="call-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="email6">Telefon Numarası</label>
                                            <input type="number" class="form-control" id="telefon" value="<?=$myUser['user_telefon']?>">
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Telefon Numaranızı Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #F56040 !important;">
                                    <ion-icon name="logo-instagram"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="password6">Instagram Profili</label>
                                            <input type="text" class="form-control" id="instagram" value="<?=$myUser['user_instagram']?>">
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Instagram Kullanıcı Adınızı Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li> -->

<!--                         <li>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #F56040 !important;">
                                    <ion-icon name="logo-instagram"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                           <div class="input-wrapper">
                            <label class="label" for="city5">Cinsiyetiniz</label>
                            <select class="form-control custom-select" id="cinsiyet">
                                <option value="<?=$myUser['user_cinsiyet']?>">Seçili: <?=ucwords($myUser['user_cinsiyet'])?></option>
                                <option value="erkek">Erkek</option>
                                <option value="kadin">Kadın</option>
                            </select>
                        </div> 
                     <div class="input-info">Cinsiyetinizi Seçin</div>
                 </div>
                                </div>
                            </div>
                        </li> -->


                       <!--  <li>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #25a0ca !important;">
                                    <ion-icon name="location-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                          <label class="label" for="city5">Şehir</label>
<select class="form-control custom-select" id="sehir"> -->
                                <?php
                       /*          $iller = array('Adana', 'Adıyaman', 'Afyon', 'Ağrı', 'Amasya', 'Ankara', 'Antalya', 'Artvin',
'Aydın', 'Balıkesir', 'Bilecik', 'Bingöl', 'Bitlis', 'Bolu', 'Burdur', 'Bursa', 'Çanakkale',
'Çankırı', 'Çorum', 'Denizli', 'Diyarbakır', 'Edirne', 'Elazığ', 'Erzincan', 'Erzurum', 'Eskişehir',
'Gaziantep', 'Giresun', 'Gümüşhane', 'Hakkari', 'Hatay', 'Isparta', 'Mersin', 'İstanbul', 'İzmir', 
'Kars', 'Kastamonu', 'Kayseri', 'Kırklareli', 'Kırşehir', 'Kocaeli', 'Konya', 'Kütahya', 'Malatya', 
'Manisa', 'Kahramanmaraş', 'Mardin', 'Muğla', 'Muş', 'Nevşehir', 'Niğde', 'Ordu', 'Rize', 'Sakarya',
'Samsun', 'Siirt', 'Sinop', 'Sivas', 'Tekirdağ', 'Tokat', 'Trabzon', 'Tunceli', 'Şanlıurfa', 'Uşak',
'Van', 'Yozgat', 'Zonguldak', 'Aksaray', 'Bayburt', 'Karaman', 'Kırıkkale', 'Batman', 'Şırnak',
'Bartın', 'Ardahan', 'Iğdır', 'Yalova', 'Karabük', 'Kilis', 'Osmaniye', 'Düzce'); 

?>
                                <option value="<?=$myUser['user_sehir']?>">Seçili: <?=$myUser['user_sehir']?></option>
<?php

foreach($iller as $veri){ ?>

                                <option value="<?=$veri?>"><?=$veri?></option>
<?php
} */
?>
<!--                             </select>
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Yaşadığınız Şehri Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li> -->
                        <li>
                            <div class="item">
                                <div class="icon-box bg-primary">
                                    <ion-icon name="calendar-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="password6">Yaş</label>
                                            <select class="form-control custom-select" id="yas">
                                <option value="<?=$myUser['user_yas']?>">Seçili: <?=$myUser['user_yas']?></option>
<?php 
for ($i=18; $i < 91; $i++) { 
    echo '<option value="'.$i.'">'.$i.' Yaşındayım</option>';
}
?>
                            </select>
                                        </div>
                                        <div class="input-info">Yaşınızı Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #ff5a8c !important;">
                                    <ion-icon name="man-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="password6">Boy</label>
                                            <input type="number" class="form-control" id="boy" value="<?=$myUser['user_boy']?>">
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Boyunuzu Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="item">
                                <div class="icon-box bg-primary" style="background-color: #d555ff !important;">
                                    <ion-icon name="pizza-outline"></ion-icon>
                                </div>
                                <div class="in">
                                    <div class="form-group boxed">
                                        <div class="input-wrapper">
                                            <label class="label" for="password6">Kilo</label>
                                            <input type="number" class="form-control" id="kilo" value="<?=$myUser['user_kilo']?>">
                                            <i class="clear-input">
                                                <ion-icon name="close-circle"></ion-icon>
                                            </i>
                                        </div>
                                        <div class="input-info">Kilonuzu Girin</div>
                                    </div>
                                </div>
                            </div>
                        </li>
                    </ul>

                <button type="button" id="tamamla" onclick="bilgiGuncelle();" class="btn btn-success btn-block mt-2 mb-4">
                    <ion-icon name="reload-outline" role="img" class="md hydrated" aria-label="mail outline"></ion-icon>
                    Bilgileri Güncelle
                </button>

               <center> <button type="button" id="hesapkapat" onclick="hesapKapat();" class="btn btn-danger btn-sm mb-4">
                    <ion-icon name="ban-outline" role="img" class="md hydrated" aria-label="close-circle-outline"></ion-icon>
                    Hesabımı Sil (Geri Döndürülemez)
                </button></center>

                </form>

            </div>
        </div>









                </div> </div>
            </div>
        </div>

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