{#
/**
 * 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 codimpuesto = settings('default', 'codimpuesto') %}

    <div class="container" style="margin-top: -100px;">
        <form action="#" method="post" enctype="multipart/form-data" class="form" id="formWizard">
            {{ formToken() }}
            <input type="hidden" name="action" value="step2"/>
            <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-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleSelect('tipoidfiscal', 'tipoidfiscal', fsc.empresa.tipoidfiscal ?: settings('default', 'tipoidfiscal'),
                                    fsc.getSelectValues('IdentificadorFiscal', true), trans('fiscal-id')) }}
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('cifnif', 'cifnif', fsc.empresa.cifnif, 'text', trans('fiscal-number'),
                                    '', {'maxlength': '30'}) }}
                            </div>
                        </div>
                    </div>
                    <div class="row gx-2">
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleSelect('regimeniva', 'regimeniva', fsc.empresa.regimeniva,
                                    fsc.getRegimenIva(), trans('vat-regime')) }}
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleSelect('codimpuesto', 'codimpuesto', codimpuesto,
                                    fsc.getSelectValues('Impuesto', true), trans('default-tax')) }}
                            </div>
                        </div>
                    </div>
                    <div class="row gx-2">
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('invoice_start_number', 'invoice_start_number', '1', 'number',
                                    trans('invoice-start-number'), '', {'min': '1'}) }}
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleSelect('codpago', 'codpago', settings('default', 'codpago'),
                                    fsc.getSelectValues('FormaPago', false), trans('default-payment-method')) }}
                            </div>
                        </div>
                    </div>
                    <div class="row gx-2">
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('bank_name', 'bank_name', '', 'text', trans('bank-name'),
                                    'fa-solid fa-building-columns', {'maxlength': '100', 'placeholder': trans('optional')}) }}
                            </div>
                        </div>
                        <div class="col-lg-6 col-md-6">
                            <div class="mb-3">
                                {{ forms.simpleInput('iban', 'iban', '', 'text', trans('iban'),
                                    'fa-solid fa-university', {'maxlength': '34', 'placeholder': trans('optional')}) }}
                                <small class="form-text text-muted">{{ trans('wizard-iban-help') }}</small>
                            </div>
                        </div>
                    </div>
                    <div class="row gx-2">
                        <div class="col-auto">
                            <div class="mb-3 form-check pe-3">
                                <input type="checkbox" name="defaultplan" value="1" id="checkboxPlan"
                                       class="form-check-input" checked/>
                                <label for="checkboxPlan">{{ trans('load-def-acc-plan') }}</label>
                            </div>
                        </div>
                        <div class="col-auto">
                            <div class="mb-3 form-check pe-3">
                                {% if settings('default', 'ventasinstock', true) %}
                                    <input type="checkbox" name="ventasinstock" value="1" id="cbNoStock"
                                           class="form-check-input" checked/>
                                {% else %}
                                    <input type="checkbox" name="ventasinstock" value="1" id="cbNoStock"
                                           class="form-check-input"/>
                                {% endif %}
                                <label for="cbNoStock">{{ trans('allow-sale-without-stock-n') }}</label>
                            </div>
                        </div>
                    </div>
                </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 %}
