<%inherit file="base.html"/>

<%block name="media">
    <script src="/static/js/ui/login.js" type="text/javascript" ></script>
</%block>

<%block name="content">

<div id="form_login"></div>

<script type="text/javascript" charset="utf-8">

function validate_login(){
    var form = this.getFormView();

    if (!form.validate()) {
        webix.message({ type:"error", text:"Valores inválidos" });
        return
    }

    var values = form.getValues()

    webix.ajax().post("/", values, function(text, data, xhr) {
        var values = data.json();
        if (values.login) {
            if (values.super) {
                window.location = "/admin"
            }else{
                window.location = "/main"
            }
        } else {
            webix.message({ type:"error", text: values.msg })
        }
    });
};

webix.ready(function(){
    webix.ui(ui_login);
    webix.ajax().get("/values/titlelogin", function(text, data, xhr){
        var value = data.json();
        $$("title_login").setHTML(value);
    })
    $$("txt_rfc").focus();
});

</script>

</%block>
