<?php
    if($_GET['route'] == '/login/index'){
        $v->layout("_theme");
    }else{
        $v->layout("_themesis");
    }
?>
<div class="container-fluid nav-hidden" id="content">
    <div id="">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12">
                    <div class="box">
                        <div class="box-title">
                            <h3>
                                Login
                            </h3>
                        </div>
                        <div class="box-content">
                            <form class="wc_form" action="" method="POST">
                                <fieldset>
                                    <div class="row">
                                        <div class="form-group col-lg-12">
                                            <label>Email</label>
                                            <input type="text" class="form-control" name="user_email" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-lg-12">
                                            <label>Senha</label>
                                            <input type="password" class="form-control" name="user_senha" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="form-group col-lg-12" align="right">

                                            <a href="<?php echo url('login/create')?>" class="btn btn-blue">QUERO ME CADASTRAR</a>

                                            <button class="btn btn-primary">EFETUAR LOGIN</button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $v->start("scripts"); ?>
    <script type="text/javascript">
        $('.wc_form').submit(function () {
            var Form = $(this);
            var Data = Form.serialize();

            $.ajax({
                url: "<?= $router->route("login.send"); ?>",
                data: Data,
                type: 'POST',
                dataType: 'json',
                beforeSend: load_in(),
                success: function (data) {
                    if(data[0].type === 'error'){
                        notify(data[0].title, data[0].message);
                    }else{
                        notify(data[0].title, data[0].message);
                        setTimeOutPage('<?php echo url('');?>');
                    }
                    load_out();
                },
                error: function (request, status, error) {
                    notify('Opss', 'Operação não pode ser finalizada!!');
                }
            });
            return false;
        });
    </script>
<?php $v->end(); ?>
