
<?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>Gökdemir Group | Kayıt Olun | e-bülten</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 = $user->plogin($_POST['email'],$_POST['password']);
        //echo '<pre>';print_r($login);echo '</pre>'; die();
        if($user->isLogged('frontend')){
            //$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 class="login-block">

            <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="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">
                        <?php
                        $projeler = $db->query("SELECT * FROM " . DBPREFIX . "projeler WHERE 1");
                        ?>
                        <select  required name="proje_id" id="proje_id" class="form-control">
                            <option value="">-- Proje Seç --</option>
                            <?php foreach ($projeler->rows as $row) { ?>
                                <option value="<?php echo $row['id']; ?>"><?php echo $row['adi']; ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-row mb-1">
                    <div class="col-sm-12">
                        <select  required name="sale_channel" id="sale_channel" class="form-control">
                            <option value="">-- Satış Kanalı Seç --</option>
                            <option value="instagram">Instagram</option>
                            <option value="ofis">Ofis</option>
                            <option value="facebook">Facebook</option>
                            <option value="whatsapp">Whatsapp</option>
                            <option value="billboard">Billboard</option>
                        </select>
                    </div>
                </div>
                <div class="form-row mb-1">
                    <div class="col-sm-12">
                        <input type="text" required name="name" id="name" placeholder="İsim/Soyisim" 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="Telefon Numarası" 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">
                        <textarea placeholder="Açıklama" name="message" id="message" class="form-control"></textarea>
                    </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> KAYDET</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'
            });
        });
    </script>
    <script>
        jQuery('#name,#telephone').on('keyup',function () {
            $(this).css('border-color','#dadce0');
        });

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

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

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

            sale_channel = jQuery('#sale_channel').val();
            message = jQuery('#message').val();


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

                            jQuery('#response-alert').html('KAYIT ALINMIŞTIR!');
                            jQuery('#response-alert').addClass('success');
                            jQuery('#response-alert').show();
                            setTimeout(function(){
                                jQuery('#response-alert').hide();
                                jQuery('#response-alert').removeClass('success');
                                jQuery('#response-alert').html('');
                                jQuery('input,select,textarea').val('');
                                $("html, body").animate({ scrollTop: 0 }, "slow");
                            }, 4000);
                        }else{
                            alert('Malesef seçtiğiniz tarihlerde müsait personel bulunmamaktadır.')
                        }
                    }else{
                        aler('Silme işleminde bir hata ile karşılaşıldı!');
                    }
                }
            });
        })

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