{% if data.user is defined %}
{% set user = data.user %}
{% else %}
    {% set user = {
        id: "-1",
        email: "",
        firstname: "",
        lastname: "",
        phoneNo: "",
        maxWorksheets: "5",
        company: "",
        department: "",
        occupation: "",
        industry: "",
        organisationUnit: "",
        invoiceRecipient: "",
        invoiceDepartment: "",
        invoiceStreet: "",
        invoiceZip: "",
        invoiceCity: "",
        orderNo: "",
        costCenter: "",
        active: false,
        validUntilDate: dateInThreeYears
    } %}
{% endif %}
<form method="post" class="form">
    <div class="form--row">
        <div class="form--wrapper mandatory">
            <label for="inputEmail{{ user.id }}">E-Mail Adresse *</label>
            <input type="email" value="{{ user.email }}" name="email" id="inputEmail{{ user.id }}" required />
        </div>
        <div class="form--wrapper mandatory">
            <label for="inputFirstname{{ user.id }}">Vorname *</label>
            <input type="text" value="{{ user.firstname }}" name="firstname" id="inputFirstname{{ user.id }}" required />
        </div>
        <div class="form--wrapper mandatory">
            <label for="inputLastname{{ user.id }}">Nachname *</label>
            <input type="text" value="{{ user.lastname }}" name="lastname" id="inputLastname{{ user.id }}" required />
        </div>
        <div class="form--wrapper">
            <label for="inputPhonenumber{{ user.id }}">Telefonnummer</label>
            <input type="text" value="{{ user.phoneNo }}" name="phoneNo" id="inputPhonenumber{{ user.id }}" />
        </div>
        <div class="form--wrapper mandatory">
            <label for="inputMaxWorksheets{{ user.id }}">Max. Anzahl Durchgänge *</label>
            <input type="number" step="1" value="{{ user.maxWorksheets }}" name="maxWorksheets" id="inputMaxWorksheets{{ user.id }}" required />
        </div>
        <div class="form--wrapper">
            <label for="inputValidUntilDate{{ user.id }}">Lizenz gültig bis</label>
            <input type="date" value="{% if user.validUntilDate is not null %}{{ user.validUntilDate | date('Y-m-d') }}{% endif %}" name="validUntilDate" id="inputValidUntilDate{{ user.id }}" />
        </div>
    </div>
    <div class="form--row">
        <div class="form--wrapper">
            <label for="inputCompany{{ user.id }}">Firma</label>
            <input type="text" value="{{ user.company }}" name="company" id="inputCompany{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputDepartment{{ user.id }}">Abteilung</label>
            <input type="text" value="{{ user.department }}" name="department" id="inputDepartment{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputOccupation{{ user.id }}">Tätigkeitsbezeichnung</label>
            <input type="text" value="{{ user.occupation }}" name="occupation" id="inputOccupation{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputIndustry{{ user.id }}">Branche/ Bereich</label>
            <input type="text" value="{{ user.industry }}" name="industry" id="inputIndustry{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputOrganisationunit{{ user.id }}">vorhandene OE</label>
            <input type="text" value="{{ user.organisationUnit }}" name="organisationUnit" id="inputOrganisationunit{{ user.id }}" />
        </div>
    </div>
    <div class="form--row">
        <div class="form--wrapper">
            <label for="inputInvoiceRecipient{{ user.id }}">Rechnungsempfänger</label>
            <input type="text" value="{{ user.invoiceRecipient }}" name="invoiceRecipient" id="inputInvoiceRecipient{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputInvoiceDepartment{{ user.id }}">Rechnung: Abteilung</label>
            <input type="text" value="{{ user.invoiceDepartment }}" name="invoiceDepartment" id="inputInvoiceDepartment{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputInvoiceStreet{{ user.id }}">Rechnung: Anschrift (Str./Postfach)</label>
            <input type="text" value="{{ user.invoiceStreet }}" name="invoiceStreet" id="inputInvoiceStreet{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputInvoiceZip{{ user.id }}">Rechnung: PLZ</label>
            <input type="text" value="{{ user.invoiceZip }}" name="invoiceZip" id="inputInvoiceZip{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputInvoiceCity{{ user.id }}">Rechnung: Ort</label>
            <input type="text" value="{{ user.invoiceCity }}" name="invoiceCity" id="inputInvoiceCity{{ user.id }}" />
        </div>
    </div>
    <div class="form--row">
        <div class="form--wrapper">
            <label for="inputOrderNo{{ user.id }}">Bestellnummer</label>
            <input type="text" value="{{ user.orderNo }}" name="orderNo" id="inputOrderNo{{ user.id }}" />
        </div>
        <div class="form--wrapper">
            <label for="inputCostCenter{{ user.id }}">Kostenstelle</label>
            <input type="text" value="{{ user.costCenter }}" name="costCenter" id="inputCostCenter{{ user.id }}" />
        </div>
        <div class="form--wrapper"></div>
        <div class="form--wrapper"></div>
        <div class="form--wrapper mandatory">
            <label for="inputActive{{ user.id }}">User aktiv</label>
            <input type="checkbox" name="active" id="inputActive{{ user.id }}" {% if user.active %}checked{% endif%} />
        </div>
    </div>
    <div class="form--row">
        {% if data.user is defined %}
            <input type="hidden" name="id" value="{{ user.id }}" />
        {% endif %}
        <button class="btn" data-js="listing--details">User speichern</button>
    </div>
</form>