
<?php include 'loader.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Arso Group | Fiyat Listesi | Price List</title>
    <meta name="description" content="">
    <link href="<?php echo SITE; ?>assets/css/style.css" rel="stylesheet">
</head>
<body id="page-top">
<?php
/**
 * Created by DDAWEBDIZAYN.
 * User: HUS
 * Date: 17.04.2017
 * Time: 12:09
 */

//print_r($_SERVER);die();
if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST'){
    //echo "metodda";

    $login = $customer->login($_POST['email'],$_POST['password']);
    //echo '<pre>';print_r($login);echo '</pre>'; die();
    if($customer->isLogged()){
        //$func->prnt($_POST,1);
        $error->uset();
        $session->set('success',"Başarı ile giriş yaptınız.");
        $location->redirect('index');
    }else{
        $success->uset();
        $session->set('error',"Yanlış Kullanıcı Adı Veya Şifre!");
        //$location->redirect('login');
    }
}else{
    $error->uset();
}

?>

<!-- Login Container -->
<div id="login-container" class="container">

    <!-- Login Block -->
    <div id="login" class="login-block pages">

        <img src="assets/img/logo.svg" alt="Login Full Background" style="max-width: 300px" class="login-logo">
        <!-- Login Form -->
        <div id="response-alert"></div>
        <form action="" method="post" id="form-login" class="form-horizontal form-bordered form-control-borderless">
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="email" required name="email" id="email" placeholder="E-Mail" class="form-control">
                </div>
            </div>
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="password" required name="password" id="password" placeholder="Password" class="form-control">
                </div>
            </div>
            <div class="form-group form-actions">
                <button type="submit" class="btn btn-sm btn-submit" id="qSendLogin"><i class="fa fa-angle-right"></i> LOGIN</button>
            </div>
            <button type="button" class="another-button" onclick="openPage('#register');">REGISTER</button>
        </form>
        <!-- END Login Form -->
    </div>

    <div id="register" class="login-block pages" style="display: none">

        <img src="assets/img/logo.svg" alt="Login Full Background" style="max-width: 300px" class="login-logo">
        <!-- Login Form -->
        <div id="response-alert"></div>
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="text" required name="name" id="name" placeholder="Name/Surname" class="form-control">
                </div>
            </div>
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="text" required name="telephone" id="telephone" placeholder="Phone Number" class="form-control">
                </div>
            </div>
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="email" required name="email" id="email" placeholder="E-Mail" class="form-control">
                </div>
            </div>
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="password" required name="password" id="password" placeholder="Password" class="form-control">
                </div>
            </div>
            <div class="form-group form-actions">
                <button type="button" class="btn btn-sm btn-submit" id="qSend"><i class="fa fa-angle-right"></i> REGISTER</button>
            </div>
            <button type="button" class="another-button" onclick="openPage('#login');">LOGIN</button>

        <!-- END Login Form -->
    </div>

    <div id="dogrula" class="login-block pages" style="display: none">

        <img src="assets/img/arso-group-logo.png" alt="Login Full Background" class="login-logo">
        <!-- Login Form -->
        <div id="response-alert"></div>
        <form action="index.php" method="get" id="form-login" class="form-horizontal form-bordered form-control-borderless">
            <div class="form-row mb-1">
                <div class="col-sm-12">
                    <input type="text" required name="dogrula" id="dogrula" placeholder="Doğrulama Kodu" class="form-control">
                </div>
            </div>

            <div class="form-group form-actions">
                <button type="button" class="btn btn-sm btn-submit" id="qSendDgorula"><i class="fa fa-angle-right"></i>DOĞRULA</button>
            </div>
        </form>
        <!-- END Login Form -->
    </div>




    <!-- END Login Block -->
</div>
<!-- END Login Container -->
<link href="<?php echo SITE; ?>assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700&amp;subset=latin-ext" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<link href="<?php echo SITE; ?>assets/css/grayscale.min.css" rel="stylesheet">
<script src="assets/datetimepicker-master/jquery.js"  crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="assets/datetimepicker-master/jquery.datetimepicker.css"/>
<script src="assets/datetimepicker-master/build/jquery.datetimepicker.full.js"></script>

<script>
    /*jslint browser:true*/
    /*global jQuery, document*/

    jQuery(document).ready(function () {
        'use strict';

        jQuery('#filter-date, #search-from-date, #search-to-date').datetimepicker({
            format: 'Y/m/d H:00'
        });
    });

    function openPage(id){
        $('.pages').hide();
        $(id).show();
    }
</script>
<script>
    jQuery('#register #name,#register #telephone, #register #email, #register #password').on('keyup',function () {
        $(this).css('border-color','#dadce0');
    });

    jQuery('#qSend').on('click',function () {
        name = jQuery('#register #name').val();
        if(!name){
            jQuery('#register #name').css('border-color','red');
            //alert('Lütfen isminizi giriniz!');
            return false;
        }

        telephone = jQuery('#register #telephone').val();
        if(!telephone){
            jQuery('#register #telephone').css('border-color','red');
            //alert('Lütfen telefon numaranızı giriniz!');
            return false;
        }
        email = jQuery('#register #email').val();
        if(!email){
            jQuery('#register #email').css('border-color','red');
            //alert('Lütfen telefon numaranızı giriniz!');
            return false;
        }

        password = jQuery('#register #password').val();
        if(!password){
            jQuery('#register #password').css('border-color','red');
            //alert('Lütfen telefon numaranızı giriniz!');
            return false;
        }

        $.ajax({
            url: 'ajax.php?type=users',
            type: "POST",
            data: 'name='+name+'&telephone='+telephone+'&email='+email+'&password='+password,
            dataType: 'json',
            beforeSend: function () {
                //$('#button-cart').button('loading');
            },
            complete: function () {
                //$('#button-cart').button('reset');
            },
            success: function (json) {
                if(json.status){
                    location = '/pro/index.php';
                    /*
                    if(json.status>0) {

                        $.ajax({
                            url: 'ajax.php?type=code',
                            type: "POST",
                            data: 'id=' + json.status,
                            dataType: 'json',
                            beforeSend: function () {
                                //$('#button-cart').button('loading');
                            },
                            complete: function () {
                                //$('#button-cart').button('reset');
                            },
                            success: function (json) {
                                openPage('#dogrula');
                            }
                        });

                    }else{
                        alert(json.error)
                    }
                    */

                }else{
                    alert(json.error);
                    jQuery('#register #response-alert').html(json.error);
                    jQuery('#register #response-alert').addClass('danger');
                    jQuery('#register #response-alert').show();
                    setTimeout(function(){
                        jQuery('#register #response-alert').hide();
                        jQuery('#register #response-alert').removeClass('danger');
                        jQuery('#register #response-alert').html('');
                       // jQuery('#name,#telephone,#email').val('');
                    }, 1115000);
                }
            }
        });
    })

</script>
</body>
</html>