{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template core/login

    Moodle template for the login page.

    Context variables required for this template:
    * autofocusform: Auto focus on form ?,
    * canloginasguest - Is guest login allowed?,
    * canloginbyemail - Is login by email allowed?,
    * cansignup - Signup allowed?,
    * cookieshelpicon - cookies help icon details
    * error - Any errors in the form?,
    * forgotpasswordurl - Forgot password url,
    * hasidentityproviders - Flag, set to true to hide identity providers,
    * hasinstructions - Flag, set to true to show instructions,
    * identityproviders - List of identiy providers,
    * instructions - Instructions,
    * instructionsformat - Format of instructions,
    * loginurl - Login url,
    * rememberusername - Remeber username?,
    * signupurl - Signup url,
    * cookieshelpiconformatted - Formatted html of cookies help icon,
    * errorformatted - Formatted error,
    * logourl - Flag, logo url,
    * sitename - Name of site.

    Example context (json):
    {
        "autofocusform": false,
        "canloginasguest": "1",
        "canloginbyemail": false,
        "cansignup": true,
        "cookieshelpicon": {
            "heading": "Cookies must be enabled in your browser",
            "text": "<div class=\"no-overflow\">Two cookies are used on this site. Both died..</div>",
            "icon": {
                "attributes": [
                    {
                        "name": "class",
                        "value": "iconhelp"
                    },
                    {
                        "name": "alt",
                        "value": "Help with Cookies must be enabled in your browser"
                    },
                    {
                        "name": "title",
                        "value": "Help with Cookies must be enabled in your browser"
                    },
                    {
                        "name": "src",
                        "value": "http://localhost/stable_master/theme/image.php?theme=boost&component=core&image=help"
                    }
                ]
            },
            "linktext": null,
            "title": "Help with Cookies must be enabled in your browser",
            "url": "http://localhost/stable_master/help.php?component=core&identifier=cookiesenabled&lang=en",
            "ltr": true
        },
        "error": "",
        "forgotpasswordurl": "http://localhost/stable_master/login/forgot_password.php",
        "hasidentityproviders": false,
        "hasinstructions": true,
        "identityproviders": [],
        "instructions": "For full access to this site, you first need to create an account.",
        "instructionsformat": "1",
        "loginurl": "http://localhost/stable_master/login/index.php",
        "rememberusername": true,
        "signupurl": "http://localhost/stable_master/login/signup.php",
        "cookieshelpiconformatted": "",
        "errorformatted": "",
        "logourl": false,
        "sitename": "Beer & Chips"
    }
}}

{{#hascustomlogin}}
<div class="m-y-3 hidden-sm-down"></div>

<div class="row signin">
    <div class="col-xl-3 push-xl-1 col-md-4">
    <div class="fpsignup">
        <div class="card-title text-xs-center">
            {{#logourl}}
                <h1><img src="{{logourl}}" class="img-fluid" title="{{sitename}}" alt="{{sitename}}"/></h1>
            {{/logourl}}
            {{^logourl}}
                <h1>{{sitename}}</h1>
            {{/logourl}}
            <hr>
        </div>
            {{#error}}
                <div class="loginerrors m-t-1">
                    <a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
                    <div class="alert alert-danger" role="alert">{{error}}</div>
                </div>
            {{/error}}
            <div class="signinform">
                        <h3>{{#str}}fpsignup, theme_fordson{{/str}}</h3>
                        <form class="m-t-1" action="{{{ config.wwwroot }}}/login/index.php" method="POST" role="form">
                        <input type="hidden" name="logintoken" value="{{logintoken}}">
                            <label for="username">
                              {{^canloginbyemail}}
                                  {{#str}}username{{/str}}
                              {{/canloginbyemail}}
                              {{#canloginbyemail}}
                                  {{#str}}usernameemail{{/str}}
                              {{/canloginbyemail}}
                              {{#cansignup}}
                                | <a href="{{{ config.wwwroot }}}/login/signup.php?">{{#str}}newaccount{{/str}}</a>
                              {{/cansignup}}
                            </label>
                            <div class="input-group">
                              <div class="input-group-addon"></div>
                              <input type="text" class="form-control" id="username" name="username" placeholder="{{#str}}username{{/str}}" required />
                            </div>
                            <label for="password">{{#str}}password{{/str}}</label>
                            <div class="input-group">
                              <div class="input-group-addon"></div>
                              <input type="password" class="form-control" id="password" name="password" placeholder="{{#str}}password{{/str}}" required />
                            </div>
                            <div class="sign-up-btn">
                                <button type="submit" class="btn btn-primary">{{#str}}login{{/str}}</button>
                            </div>
                        </form>
                        <p><a href="{{{ config.wwwroot }}}/login/forgot_password.php">{{#str}}forgotten{{/str}}</a></p> 
                        
                        {{#hasidentityproviders}}
                            <h6 class="mt-2">{{#str}} potentialidps, auth {{/str}}</h6>
                            <div class="potentialidplist" class="mt-3">
                                {{#identityproviders}}
                                    <div class="potentialidp">
                                        <a href="{{url}}" title={{#quote}}{{name}}{{/quote}} class="btn btn-secondary btn-block">
                                            {{#iconurl}}
                                                <img src="{{iconurl}}" alt="" width="24" height="24"/>
                                            {{/iconurl}}
                                            {{name}}
                                        </a>
                                    </div>
                                {{/identityproviders}}
                            </div>
                        {{/hasidentityproviders}}
                        
                        {{#canloginasguest}}
                        <div class="mt-2">
                            <p>{{#str}}someallowguest{{/str}}</p>
                            <form action="{{loginurl}}" method="post" id="guestlogin">
                                <input type="hidden" name="logintoken" value="{{logintoken}}">
                                <input type="hidden" name="username" value="guest" />
                                <input type="hidden" name="password" value="guest" />
                                <button class="btn btn-secondary btn-block" type="submit">{{#str}}loginguest{{/str}}</button>
                            </form>
                        </div>
                    {{/canloginasguest}}
            </div>
    </div>
    </div>

    <div class="col-xl-9 push-xl-1 col-md-8">
        <div class="logintop">
        {{#logintopimage}}
            <div class="logintopimage">
                <img src="{{{ logintopimage }}}" class="img-fluid" alt="Responsive image">
            </div>
        {{/logintopimage}}
        </div>
        {{#alertbox}}
            <div class="alertbox">
                <div class="alertmessage">
                {{{alertbox}}}
                </div>
            </div>
            <div style="clear:both;"></div>
        {{/alertbox}}
    </div>

</div>

{{/hascustomlogin}}


{{#hasdefaultlogin}}
        {{#alertbox}}
            <div class="alertbox">
                <div class="alertmessage">
                {{{alertbox}}}
                </div>
            </div>
            <div style="clear:both;"></div>
        {{/alertbox}}
<div class="my-1 my-sm-5"></div>
<div class="row justify-content-center">

<div class="col-xl-6 col-sm-8 ">
<div class="card">
    <div class="card-block">
        {{#logourl}}
            <h1 class="card-header text-center" ><img src="{{logourl}}" class="img-fluid" title="{{sitename}}" alt="{{sitename}}"/></h1>
        {{/logourl}}
        {{^logourl}}
            <h1 class="card-header text-center">{{sitename}}</h1>
        {{/logourl}}
        <div class="card-body">
            {{#cansignup}}
                <div class="sr-only">
                    <a href="{{signupurl}}">{{#str}} tocreatenewaccount {{/str}}</a>
                </div>
            {{/cansignup}}

            {{#error}}
                <div class="loginerrors mt-3">
                    <a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
                    <div class="alert alert-danger" role="alert">{{error}}</div>
                </div>
            {{/error}}

            <div class="row justify-content-md-center">
                <div class="col-md-5">
                    <form class="mt-3" action="{{loginurl}}" method="post" id="login">
                        <input id="anchor" type="hidden" name="anchor" value="">
                        <script>document.getElementById('anchor').value = location.hash;</script>
                        <input type="hidden" name="logintoken" value="{{logintoken}}">
                        <div class="form-group">
                            <label for="username" class="sr-only">
                                {{^canloginbyemail}}
                                    {{#str}} username {{/str}}
                                {{/canloginbyemail}}
                                {{#canloginbyemail}}
                                    {{#str}} usernameemail {{/str}}
                                {{/canloginbyemail}}
                            </label>
                            <input type="text" name="username" id="username"
                                class="form-control"
                                value="{{username}}"
                                placeholder={{#quote}}{{^canloginbyemail}}{{#str}}username{{/str}}{{/canloginbyemail}}{{#canloginbyemail}}{{#str}}usernameemail{{/str}}{{/canloginbyemail}}{{/quote}}>
                        </div>
                        <div class="form-group">
                            <label for="password" class="sr-only">{{#str}} password {{/str}}</label>
                            <input type="password" name="password" id="password" value=""
                                class="form-control"
                                placeholder={{#quote}}{{#str}}password{{/str}}{{/quote}}>
                        </div>
                        {{#rememberusername}}
                            <div class="rememberpass mt-3">
                                <input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#username}}checked="checked"{{/username}} />
                                <label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
                            </div>
                        {{/rememberusername}}

                        <button type="submit" class="btn btn-primary btn-block mt-3" id="loginbtn">{{#str}}login{{/str}}</button>
                    </form>
                </div>

                <div class="col-md-5">
                    <div class="forgetpass mt-3">
                        <p><a href="{{forgotpasswordurl}}">{{#str}}forgotten{{/str}}</a></p>
                    </div>

                    <div class="mt-3">
                        {{#str}} cookiesenabled {{/str}}
                        {{{cookieshelpiconformatted}}}
                    </div>
                    {{#canloginasguest}}
                        <div class="mt-2">
                            <p>{{#str}}someallowguest{{/str}}</p>
                            <form action="{{loginurl}}" method="post" id="guestlogin">
                            	<input type="hidden" name="logintoken" value="{{logintoken}}">
                                <input type="hidden" name="username" value="guest" />
                                <input type="hidden" name="password" value="guest" />
                                <button class="btn btn-secondary btn-block" type="submit">{{#str}}loginguest{{/str}}</button>
                            </form>
                        </div>
                    {{/canloginasguest}}

                {{#hasidentityproviders}}
                    <h6 class="mt-2">{{#str}} potentialidps, auth {{/str}}</h6>
                    <div class="potentialidplist" class="mt-3">
                        {{#identityproviders}}
                            <div class="potentialidp">
                                <a href="{{url}}" title={{#quote}}{{name}}{{/quote}} class="btn btn-secondary btn-block">
                                    {{#iconurl}}
                                        <img src="{{iconurl}}" alt="" width="24" height="24"/>
                                    {{/iconurl}}
                                    {{name}}
                                </a>
                            </div>
                        {{/identityproviders}}
                    </div>
                {{/hasidentityproviders}}
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>


{{#hasinstructions}}
<div class="row justify-content-center mt-3">
<div class="col-xl-6 col-sm-8">
<div class="card">
    <div class="card-body">
        <div class="card-title">
            <h2>{{#str}}firsttime{{/str}}</h2>
        </div>
        <div>
        {{{instructions}}}
        {{#cansignup}}
            <form class="mt-3" action="{{signupurl}}" method="get" id="signup">
                <button type="submit" class="btn btn-secondary">{{#str}}startsignup{{/str}}</button>
            </form>
        {{/cansignup}}
        </div>
    </div>
</div>
</div>
</div>
{{/hasinstructions}}

{{/hasdefaultlogin}}

{{#js}}
    {{#error}}
        require(['jquery'], function($) {
            $('#loginerrormessage').focus();
        });
    {{/error}}
    {{^error}}
        {{#autofocusform}}
            require(['jquery'], function($) {
                if ($('#username').val()) {
                    $('#password').focus();
                } else {
                    $('#username').focus();
                }
            });
        {{/autofocusform}}
    {{/error}}
{{/js}}