{#
/**
 * This file is part of FacturaScripts
 * Copyright (C) 2017-2024 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="fas fa-magic" aria-hidden="true"></i> {{ trans('wizard') }}
                        <a href="{{ fsc.url() }}" class="btn btn-sm btn-outline-secondary" title="{{ trans('refresh') }}">
                            <i class="fas fa-redo" aria-hidden="true"></i>
                        </a>
                    </h1>
                    <p>{{ trans('wizard-p') }}</p>
                    <hr/>
                    <div class="form-row">
                        <div class="col-sm-3">
                            <div class="form-group">
                                {{ forms.simpleInput('empresa', 'empresa', fsc.empresa.nombre, 'text',
                                    trans('company-name'), '', {'autofocus': '', 'maxlength': '100', 'required': ''}) }}
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <label class="mb-1">{{ trans('type') }}</label>
                                <select name="personafisica" class="form-control">
                                    {% 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-sm-3">
                            <div class="form-group">
                                {{ forms.simpleSelect('tipoidfiscal', 'tipoidfiscal', fsc.empresa.tipoidfiscal,
                                    fsc.getSelectValues('IdentificadorFiscal', true), trans('fiscal-id')) }}
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                {{ forms.simpleInput('cifnif', 'cifnif', fsc.empresa.cifnif, 'text', trans('fiscal-number'),
                                    '', {'maxlength': '30'}) }}
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                {{ forms.simpleInput('direccion', 'direccion', fsc.empresa.direccion, 'text', trans('address'),
                                    'fas fa-map-marked', {'maxlength': '100'}) }}
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                {{ forms.simpleInput('apartado', 'apartado', fsc.empresa.apartado, 'text', trans('post-office-box'),
                                    NULL, {'maxlength': '10', 'placeholder': trans('optional')}) }}
                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                {{ forms.simpleInput('codpostal', 'codpostal', fsc.empresa.codpostal, 'text', trans('zip-code'),
                                    NULL, {'maxlength': '10'}) }}
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                {{ forms.simpleInput('ciudad', 'ciudad', ciudad, 'text', trans('city'), '',
                                    {'maxlength': '100'}) }}
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                {{ forms.simpleInput('provincia', 'provincia', provincia, 'text', trans('province'),
                                    '', {'maxlength': '100'}) }}
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                {% if constant('FS_INITIAL_CODPAIS') is defined %}
                                    {{ forms.simpleSelect('codpais', 'codpais', codpais, fsc.getSelectValues('Pais'),
                                        trans('country'), 'fas fa-globe-americas', {'disabled': ''}) }}
                                {% else %}
                                    {{ forms.simpleSelect('codpais', 'codpais', codpais, fsc.getSelectValues('Pais'),
                                        trans('country'), 'fas fa-globe-americas') }}
                                {% endif %}
                            </div>
                        </div>
                        {% if fsc.empresa.email is empty or fsc.user.email is empty %}
                            <div class="col-sm-4">
                                <div class="form-group">
                                    {{ forms.simpleInput('email', 'email', fsc.empresa.email, 'email', trans('email'),
                                        'fas fa-envelope', {'required': '', 'class': 'form-control'}) }}
                                </div>
                            </div>
                        {% endif %}
                        <div class="col-sm-4">
                            <div class="form-group">
                                {{ forms.simpleInput('telefono1', 'telefono1', fsc.empresa.telefono1, 'text', trans('phone'),
                                    'fas fa-phone', {'maxlength': '30'}) }}
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <div class="form-group">
                                {{ forms.simpleInput('telefono2', 'telefono2', fsc.empresa.telefono2, 'text', trans('phone2'),
                                    'fas fa-mobile-alt', {'maxlength': '30'}) }}
                            </div>
                        </div>
                    </div>
                    {% if fsc.user.verifyPassword('admin') %}
                        <div class="form-row">
                            <div class="col mt-3">
                                <h3 class="h4 text-info">
                                    <i class="fas fa-key" aria-hidden="true"></i>
                                    {{ trans('you-should-change-passwd') }}
                                </h3>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="col-sm-4">
                                {{ forms.simpleInput('user', 'user', fsc.user.nick, 'text', trans('user'), 'fas fa-user', {'readonly': ''}) }}
                            </div>
                            <div class="col-sm-4">
                                <div class="form-group">
                                    {{ forms.simpleInput('password', 'password', '', 'password', trans('new-password'), 'fas fa-key',
                                        {'class': 'form-control', 'placeholder': trans('optional')}) }}
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="form-group">
                                    {{ forms.simpleInput('repassword', 'repassword', '', 'password', trans('repeat-new-password'),
                                        'fas fa-key', {'class': 'form-control', 'placeholder': trans('optional')}) }}
                                </div>
                            </div>
                        </div>
                    {% endif %}
                </div>
                <div class="card-footer text-right">
                    <button type="submit" class="btn btn-primary" id="btnWizard">
                        {{ 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="fas fa-circle-notch fa-spin"></i>');
            });
        });
    </script>
{% endblock %}