{#
/**
 * This file is part of FacturaScripts
 * Copyright (C) 2017-2025 Carlos Garcia Gomez <carlos@facturascripts.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */
#}
{% extends "Master/MicroTemplate.html.twig" %}

{% block messages %}
    <div class="bg-primary pt-5 pb-5">
        <div class="container">
            <div class="row">
                <div class="col">{{ parent() }}</div>
            </div>
        </div>
        <br/>
        <br/>
        <br/>
    </div>
{% endblock %}

{% block body %}
    <!-- Macros Template Imports -->
    {% import 'Macro/Forms.html.twig' as forms %}
    {% set ciudad = fsc.empresa ? fsc.empresa.ciudad : '' %}
    {% set codpais = fsc.empresa ? fsc.empresa.codpais : settings('default', 'codpais', 'ESP') %}
    {% set provincia = fsc.empresa ? fsc.empresa.provincia : '' %}

    <div class="container" style="margin-top: -100px;">
        <form method="post" enctype="multipart/form-data" class="form" id="formWizard">
            {{ formToken() }}
            <input type="hidden" name="action" value="step1"/>
            <div class="card shadow mb-5">
                <div class="card-body">
                    <h1 class="h3">
                        <i class="fa-solid fa-wand-magic-sparkles me-2"></i> {{ trans('wizard') }}
                        <a href="{{ fsc.url() }}" class="btn btn-sm btn-outline-secondary float-end"
                           title="{{ trans('refresh') }}">
                            <i class="fa-solid fa-redo" aria-hidden="true"></i>
                        </a>
                    </h1>
                    <p>{{ trans('wizard-p') }}</p>
                    <hr/>
                    <div class="row gx-2">
                        <div class="col-12">
                            <h2 class="h6 text-uppercase text-muted mb-3">{{ trans('company') }}</h2>
                        </div>
                        <div class="col-lg-6 col-md-12">
                            <div class="mb-3">
                                {{ forms.simpleInput('empresa', 'empresa', fsc.empresa.nombre, 'text',
                                    trans('company-name'), '', {'autofocus': '', 'maxlength': '100', 'required': ''}) }}
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-12">
                            <div class="mb-3">
                                <label class="mb-1">{{ trans('type') }}</label>
                                <div class="d-flex flex-wrap gap-2">
                                    <input type="radio" class="btn-check" name="personafisica" id="personafisica-company"
                                           value="0" autocomplete="off"{% if not fsc.empresa.personafisica %} checked{% endif %}>
                                    <label class="btn btn-outline-secondary" for="personafisica-company">
                                        {{ trans('company') }}
                                    </label>
                                    <input type="radio" class="btn-check" name="personafisica" id="personafisica-person"
                                           value="1" autocomplete="off"{% if fsc.empresa.personafisica %} checked{% endif %}>
                                    <label class="btn btn-outline-secondary" for="personafisica-person">
                                        {{ trans('is-person') }}
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-12">
                            <div class="mb-3">
                                <label class="mb-1" for="logo">{{ trans('logo') }}</label>
                                <input type="file" name="logo" id="logo" class="form-control"
                                       accept=".gif,.jpg,.jpeg,.png"/>
                            </div>
                        </div>
                        <div class="col-12 mt-2">
                            <h2 class="h6 text-uppercase text-muted mb-3">{{ trans('address') }}</h2>
                        </div>
                        <div class="col-lg-6 col-md-12">
                            <div class="mb-3">
                                {{ forms.simpleInput('direccion', 'direccion', fsc.empresa.direccion, 'text', trans('address'),
                                    'fa-solid fa-map-marked', {'maxlength': '200'}) }}
                            </div>
                        </div>
                        <div class="col-lg-2 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('codpostal', 'codpostal', fsc.empresa.codpostal, 'text', trans('zip-code'),
                                    NULL, {'maxlength': '10'}) }}
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('ciudad', 'ciudad', ciudad, 'text', trans('city'), '',
                                    {'maxlength': '100'}) }}
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('provincia', 'provincia', provincia, 'text', trans('province'),
                                    '', {'maxlength': '100'}) }}
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {% if constant('FS_INITIAL_CODPAIS') is defined %}
                                    {{ forms.simpleSelect('codpais', 'codpais', codpais, fsc.getSelectValues('Pais'),
                                        trans('country'), 'fa-solid fa-globe-americas', {'disabled': ''}) }}
                                {% else %}
                                    {{ forms.simpleSelect('codpais', 'codpais', codpais, fsc.getSelectValues('Pais'),
                                        trans('country'), 'fa-solid fa-globe-americas') }}
                                {% endif %}
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('apartado', 'apartado', fsc.empresa.apartado, 'text', trans('post-office-box'),
                                    NULL, {'maxlength': '10', 'placeholder': trans('optional')}) }}
                            </div>
                        </div>
                        <div class="col-12 mt-2">
                            <h2 class="h6 text-uppercase text-muted mb-3">{{ trans('contact') }}</h2>
                        </div>
                        {% if fsc.empresa.email is empty or fsc.user.email is empty %}
                            <div class="col-lg-4 col-md-6">
                                <div class="mb-3">
                                    {{ forms.simpleInput('email', 'email', fsc.empresa.email, 'email', trans('email'),
                                        'fa-solid fa-envelope', {'required': '', 'class': 'form-control'}) }}
                                </div>
                            </div>
                        {% endif %}
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('telefono1', 'telefono1', fsc.empresa.telefono1, 'text', trans('phone'),
                                    'fa-solid fa-phone', {'maxlength': '30'}) }}
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('telefono2', 'telefono2', fsc.empresa.telefono2, 'text', trans('phone2'),
                                    'fa-solid fa-mobile-alt', {'maxlength': '30'}) }}
                            </div>
                        </div>
                    </div>
                    {% if fsc.user.verifyPassword('admin') %}
                        <div class="row gx-2">
                            <div class="col-12 mt-2">
                                <h2 class="h6 text-uppercase text-muted mb-3">{{ trans('password') }}</h2>
                            </div>
                            <div class="col mt-3">
                                <div class="alert alert-warning" role="alert">
                                    <h4 class="alert-heading">
                                        <i class="fa-solid fa-exclamation-triangle me-2" aria-hidden="true"></i>
                                        {{ trans('you-should-change-passwd') }}
                                    </h4>
                                    <p class="mb-0">
                                        <strong>{{ trans('security-warning') }}:</strong>
                                        {{ trans('change-password-online-warning') }}
                                    </p>
                                </div>
                            </div>
                        </div>
                        <div class="row gx-2">
                            <div class="col-lg-4 col-md-6">
                                {{ forms.simpleInput('user', 'user', fsc.user.nick, 'text', trans('user'), 'fa-solid fa-user', {'readonly': ''}) }}
                            </div>
                            <div class="col-lg-4 col-md-6">
                                <div class="mb-3">
                                    {{ forms.simpleInput('password', 'password', '', 'password', trans('new-password'), 'fa-solid fa-key',
                                        {'class': 'form-control', 'placeholder': trans('optional')}) }}
                                </div>
                            </div>
                            <div class="col-lg-4 col-md-6">
                                <div class="mb-3">
                                    {{ forms.simpleInput('repassword', 'repassword', '', 'password', trans('repeat-new-password'),
                                        'fa-solid fa-key', {'class': 'form-control', 'placeholder': trans('optional')}) }}
                                </div>
                            </div>
                        </div>
                    {% endif %}
                </div>
                <div class="card-footer text-end">
                    <button type="submit" class="btn btn-primary" id="btnWizard">
                        <i class="fa-solid fa-arrow-right fa-beat me-1"></i> {{ trans('continue') }}
                    </button>
                </div>
            </div>
        </form>
        <br/>
    </div>
{% endblock %}

{% block css %}
    {{ parent() }}
    <link rel="stylesheet" href="{{ asset('Dinamic/Assets/CSS/custom.css') }}"/>
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    <script src="{{ asset('node_modules/pace-js/pace.min.js') }}"></script>
    <script src="{{ asset('Dinamic/Assets/JS/Custom.js') }}"></script>
    <script>
        $(document).ready(function () {
            $("#formWizard").submit(function () {
                $("#btnWizard").prop('disabled', true);
                $("#btnWizard").html('<i class="fa-solid fa-circle-notch fa-spin"></i>');
            });
        });
    </script>
{% endblock %}
