{#
/**
 * 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" 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-lg-3 col-md-6">
                            <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-3 col-md-6">
                            <div class="mb-3">
                                <label class="mb-1">{{ trans('type') }}</label>
                                <select name="personafisica" class="form-select">
                                    {% if fsc.empresa.personafisica %}
                                        <option value="1" selected>{{ trans('is-person') }}</option>
                                        <option value="0">{{ trans('company') }}</option>
                                    {% else %}
                                        <option value="1">{{ trans('is-person') }}</option>
                                        <option value="0" selected>{{ trans('company') }}</option>
                                    {% endif %}
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleSelect('tipoidfiscal', 'tipoidfiscal', fsc.empresa.tipoidfiscal,
                                    fsc.getSelectValues('IdentificadorFiscal', true), trans('fiscal-id')) }}
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('cifnif', 'cifnif', fsc.empresa.cifnif, 'text', trans('fiscal-number'),
                                    '', {'maxlength': '30'}) }}
                            </div>
                        </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-3 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-lg-3 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>
                        {% 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 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">
                        {{ trans('continue') }} <i class="fa-solid fa-arrow-right ms-1"></i>
                    </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 %}