{% extends "Master/MicroTemplate.html.twig" %}

{% block body %}
    {{ parent() }}
    <div class="container">
        <div class="row justify-content-md-center">
            <div class="col-md-6">
                <form action="{{ asset('login') }}" method="post" class="form">
                    {{ formToken() }}
                    <input type="hidden" name="action" value="login">
                    <div class="card mt-4">
                        <a href="{{ asset('login') }}">
                            {% set idfile = settings('default','idloginimage', 0) %}
                            {{ _self.loadLogo(idfile) }}
                        </a>
                        <div class="card-body">
                            <p class="card-text text-center">{{ trans('login-text') }}</p>
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="fas fa-user fa-fw" aria-hidden="true"></i>
                                        </span>
                                    </span>
                                    <input type="text" name="fsNick" class="form-control" maxlength="50"
                                           placeholder="{{ trans('user') }}" required autocomplete="off"
                                           autofocus/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <span class="input-group-prepend">
                                        <span class="input-group-text">
                                            <i class="fas fa-key fa-fw" aria-hidden="true"></i>
                                        </span>
                                    </span>
                                    <input type="password" name="fsPassword" class="form-control" maxlength="50"
                                           placeholder="{{ trans('password') }}" required autocomplete="off"/>
                                </div>
                                <a href="#" class="btn btn-block btn-link" data-toggle="modal"
                                   data-target="#newPasswordModal">
                                    {{ trans('i-forgot-password') }}
                                </a>
                            </div>
                            <button type="submit" class="btn btn-block btn-primary mb-4">
                                {{ trans('login') }}
                            </button>
                        </div>
                        <div class="card-footer text-center">
                            <p>
                                FacturaScripts es un software libre de contabilidad, facturación y CRM.
                                No dude en consultar la web oficial o las cuentas de facebook, twitter o youtube.
                            </p>
                            <a href="https://facturascripts.com" rel="nofollow" class="btn btn-secondary">
                                <i class="fas fa-question-circle mr-1"></i> facturascripts.com
                            </a>
                            <a href="https://www.facebook.com/facturascripts/" rel="nofollow" class="btn btn-primary"
                               title="facebook"> <i class="fab fa-facebook"></i>
                            </a>
                            <a href="https://twitter.com/facturascripts" rel="nofollow" class="btn btn-info"
                               title="twitter"> <i class="fab fa-twitter"></i>
                            </a>
                            <a href="https://www.youtube.com/channel/UCtsptMQYpW2wJZkvak6NYng" rel="nofollow"
                               class="btn btn-danger" title="youtube"> <i class="fab fa-youtube"></i>
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <form action="{{ asset('login') }}" method="post" class="form">
        {{ formToken() }}
        <input type="hidden" name="action" value="change-password">
        <div class="modal fade" id="newPasswordModal" tabindex="-1" role="dialog" aria-hidden="true">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">
                            <i class="fas fa-user-lock mr-2"></i> {{ trans('new-password') }}
                        </h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <a href="https://facturascripts.com/publicaciones/he-olvidado-mi-contrasena" rel="nofollow"
                           target="_blank" class="btn btn-block btn-link mb-3">
                            {{ trans('need-help-password') }}
                        </a>
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="fas fa-user fa-fw" aria-hidden="true"></i>
                                    </span>
                                </span>
                                <input type="text" name="fsNewUserPasswd" class="form-control" maxlength="50"
                                       placeholder="{{ trans('user') }}" required autocomplete="off"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="fas fa-key fa-fw" aria-hidden="true"></i>
                                    </span>
                                </span>
                                <input type="password" name="fsNewPasswd" class="form-control" maxlength="50"
                                       placeholder="{{ trans('new-password') }}" required autocomplete="off"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
                                    </span>
                                </span>
                                <input type="password" name="fsNewPasswd2" class="form-control" maxlength="50"
                                       placeholder="{{ trans('repeat-new-password') }}"
                                       required autocomplete="off"/>
                            </div>
                        </div>
                        <div class="form-group">
                            {{ trans('database') }}
                            <div class="input-group">
                                <span class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="fas fa-database fa-fw" aria-hidden="true"></i>
                                    </span>
                                </span>
                                <input type="password" name="fsDbPasswd" class="form-control"
                                       placeholder="{{ trans('db-password') }}" autocomplete="off"/>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">{{ trans('save') }}</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
{% endblock %}

{% block css %}
    {{ parent() }}
    <style>
        body {
            background-color: #333A40;
        }
    </style>
{% endblock %}

{% macro loadLogo(idfile) %}
    {% set url = 'Dinamic/Assets/Images/horizontal-logo.png' %}
    {% if idfile > 0 %}
        {% set attached = attachedFile(idfile) %}
        {% if attached.filename is not empty %}
            {% set url = attached.url('download-permanent') %}
        {% endif %}
    {% endif %}
    <img class="card-img-top" src="{{ asset(url) }}" alt="FacturaScripts"/>
{% endmacro loadLogo %}