{% extends 'Master/MenuBgTemplate.html.twig' %}

{% block body %}
    <div class="container-fluid">
        <div class="row">
            <div class="col">
                <h1 class="h3">
                    <i class="fa-solid fa-cut me-2"></i> {{ fsc.title }}
                </h1>
                <p>{{ trans('copy-p') }}</p>
                <form method="post" onsubmit="animateSpinner('add')">
                    {{ formToken() }}
                    <input type="hidden" name="action" value="save"/>
                    <input type="hidden" name="code" value="{{ fsc.modelCode }}"/>
                    <input type="hidden" name="model" value="{{ fsc.modelClass }}"/>
                    <div class="card shadow mb-4">
                        <div class="card-body">
                            <div class="row g-2">
                                <div class="col-sm">
                                    <div class="mb-3">
                                        <label for="reference">{{ trans('reference') }}</label>
                                        <input type="text" name="referencia" id="reference" class="form-control"
                                               placeholder="{{ trans('optional') }}" maxlength="30"/>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-sm">
                                    <div class="mb-3">
                                        <label for="descripcion">{{ trans('description') }}</label>
                                        <textarea name="descripcion" id="descripcion" class="form-control" rows="3"
                                                  required>{{ trans('copy') }} {{ fsc.model.descripcion }}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-hover mb-0">
                                <thead>
                                <tr>
                                    <th>{{ trans('variants') }}</th>
                                    <th>{{ trans('barcode') }}</th>
                                    <th class="text-end">{{ trans('cost-price') }}</th>
                                    <th class="text-end">{{ trans('margin') }}</th>
                                    <th class="text-end">{{ trans('price') }}</th>
                                    <th class="text-end">{{ trans('stock') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for variante in fsc.model.getVariants() %}
                                    <tr>
                                        <td>{{ variante.referencia }}</td>
                                        <td>{{ variante.codbarras }}</td>
                                        <td class="text-end">{{ money(variante.coste) }}</td>
                                        <td class="text-end">{{ number(variante.margen) }}%
                                        </td>
                                        <td class="text-end">{{ money(variante.precio) }}</td>
                                        <td class="text-end">{{ number(variante.stockfis) }}</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                        <div class="card-footer">
                            <div class="row">
                                <div class="col">
                                    <a href="{{ asset(fsc.model.url()) }}" class="btn btn-spin-action btn-secondary">
                                        <i class="fa-solid fa-arrow-left me-1"></i> {{ trans('back') }}
                                    </a>
                                </div>
                                <div class="col-auto">
                                    <button type="submit" class="btn btn-spin-action btn-primary">
                                        <i class="fa-solid fa-save me-1"></i> {{ trans('save') }}
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}