<?php 

require_once('inc/vt.php');

?>
<!DOCTYPE html>
<html lang="tr">

<head>
    <meta charset="utf-8" />
    <title>Yönetim Paneli</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta content="parstech" name="author" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- App favicon -->
    <link rel="shortcut icon" href="assets/images/favicon.ico">

    <!-- jvectormap -->
    <link href="../plugins/jvectormap/jquery-jvectormap-2.0.2.css" rel="stylesheet">

    <!-- App css -->
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/metisMenu.min.css" rel="stylesheet" type="text/css" />
    <link href="../plugins/daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css" />
    <link href="assets/css/app.min.css" rel="stylesheet" type="text/css" />

    <!-- sonradan dahil edilenler -->
    <script src="ckeditor/ckeditor.js"></script>
    <!-- DataTables -->
    <link href="../plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <link href="../plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
    <!-- Responsive datatable examples -->
    <link href="../plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> 

    <link href="../plugins/dropify/css/dropify.min.css" rel="stylesheet">

</head>
<?php
if($_SESSION['musteri'] != ''){
    header("location: index.php");
}  



if(!empty($_POST)){
    $_SESSION['deneme'] = "asdasd";

    $email = $_POST['email'];
    $password = $_POST['password'];

    $ksorgu     =   $dbh->prepare("SELECT * FROM admin WHERE email=? && password=?");
    $ksorgu     ->  execute(array($email,$password));
    $kbilgi     =   $ksorgu     ->fetch(PDO::FETCH_ASSOC);

    if(!$ksorgu->rowCount()){
       $hata = "* Giriş bilgileri hatalı";

   }else{
    $_SESSION['yonetici'] = $kbilgi;
    $_SESSION['musteri'] = $kbilgi['id'];
    $_SESSION['musteriadi'] = $kbilgi['email'];
    $_SESSION['musteriname'] = $kbilgi['name_surname'];
    $yonetici['isim']=$kbilgi['email'];
    $_SESSION["b"] = array(
       "email"=>$kbilgi["email"]
   );
            header("location: index.php");
   

}


}


    /*    $sorgu = $baglanti->prepare("SELECT * FROM admin WHERE username = :username AND password = :password ");
        $sorgu->execute(array(
         "username"=>$username,
         "password"=>$password

        ));
        if($sorgu->rowCount()){
            foreach($sorgu as $sonuc){}
      
            $_SESSION['musteri'] = $sonuc['id'];
            $_SESSION['musteriadi'] = $sonuc['username'];
            $yonetici['isim']=$sonuc['username'];
            $_SESSION["b"] = array(
               "name_username"=>$sonuc["name_username"]
            );
            header("location: index.php");
        }
        else {
            $hata = "* Giriş bilgileri hatalı";
        }*/

$ayarx = $dbh->query("SELECT * FROM general_settings WHERE id = 1 ", PDO::FETCH_ASSOC);
if ($ayarx->rowCount()) {
  foreach ($ayarx as $ayarx) {
  }
}

        ?>
        <body class="account-body accountbg">

            <!-- Log In page -->
            <div class="container">
                <div class="row vh-100 d-flex justify-content-center">
                    <div class="col-12 align-self-center">
                        <div class="row">
                            <div class="col-lg-5 mx-auto">
                                <div class="card">
                                    <div class="card-body p-0 auth-header-box">
                                        <div class="text-center p-3"> 
                                                <img src="../img/<?=$ayarx['foto'];?>" height="50" alt="logo" class="auth-logo"> 
                                            <h4 class="mt-3 mb-1 font-weight-semibold text-white font-18">Yönetici Paneli</h4>   
                                            <p class="text-muted  mb-0">Oturum açmak için lütfen bilgilerini giriniz</p>  
                                        </div>
                                    </div>
                                    <div class="card-body p-0">
                                        <ul class="nav-border nav nav-pills" role="tablist">
                                            <li class="nav-item">
                                                <a class="nav-link active font-weight-semibold" data-toggle="tab" href="#LogIn_Tab" role="tab">Oturum Aç</a>
                                            </li>

                                        </ul>
                                        <!-- Tab panes -->
                                        <div class="tab-content">
                                            <div class="tab-pane active p-3" id="LogIn_Tab" role="tabpanel">                                        
                                                <form class="form-horizontal auth-form" method="post">

                                                    <div class="form-group mb-2">
                                                        <label for="username">Mail Adresiniz</label>
                                                        <div class="input-group">                                                                                         
                                                            <input type="text" class="form-control" name="email" placeholder="example@example.com">
                                                        </div>                                    
                                                    </div><!--end form-group--> 

                                                    <div class="form-group mb-2">
                                                        <label for="userpassword">Oturum Şifresi</label>                                            
                                                        <div class="input-group">                                  
                                                            <input type="password" class="form-control" name="password" placeholder="*****">
                                                        </div>                               
                                                    </div><!--end form-group--> 

                                                    <div class="form-group row my-3">
                                                        <div class="col-sm-6">
                                                            <div class="custom-control custom-switch switch-success">
                                                                <input type="checkbox" class="custom-control-input" id="customSwitchSuccess">
                                                                <label class="custom-control-label text-muted" for="customSwitchSuccess">Beni Hatırla</label>
                                                            </div>
                                                        </div><!--end col--> 
                                                        <div class="col-sm-6 text-right">

                                                        </div><!--end col--> 
                                                    </div><!--end form-group--> 

                                                    <div class="form-group mb-0 row">
                                                        <div class="col-12">
                                                            <button class="btn btn-primary btn-block waves-effect waves-light" type="submit"><i class="fas fa-sign-in-alt ml-1"></i> Oturumu Başlat  </button>
                                                        </div><!--end col--> 
                                                    </div> <!--end form-group-->                           
                                                </form><!--end form-->

                                                <?php
                                                if($hata!=""){
                                                 echo '<p class="tx-center" style="color:red;">'.$hata.'</p>';
                                             }
                                             ?>
                                         </div> 
                                     </div>
                                 </div><!--end card-body-->
                                 <div class="card-body bg-light-alt text-center">
                                    <span class="text-muted d-none d-sm-inline-block"><?=$ayarx['copyright'];?></span>                                            
                                </div>
                            </div><!--end card-->
                        </div><!--end col-->
                    </div><!--end row-->
                </div><!--end col-->
            </div><!--end row-->
        </div><!--end container-->
        <!-- End Log In page -->




        <!-- jQuery  -->
        <script src="assets/js/jquery.min.js"></script>
        <script src="assets/js/bootstrap.bundle.min.js"></script>
        <script src="assets/js/waves.js"></script>
        <script src="assets/js/feather.min.js"></script>
        <script src="assets/js/simplebar.min.js"></script>


    </body>

    </html>