{% set oHeidelPaySettings = oHeidelpayViewConfig.getSettings() %}
{% set oHeidelPayment = oHeidelPaySettings.getPayment(paymentmethod) %}
{% set blShowPaymentMethod = true %}
{% set sImageUrl = oViewConf.getModuleUrl('d3unzer', 'out/img/') %}
{% if get_class(oHeidelPayment) === "D3\Unzer\Application\Model\Payment\Invoice\Secured" %}
    {% set blShowPaymentMethod = blD3HeidelpayAllowInvoiceSecured %}
{% endif %}

{% block heidelpay_invoice %}
    {% set iBirthdayMonth = 0 %}
    {% set iBirthdayDay = 0 %}
    {% set iBirthdayYear = 0 %}

    {% if oxcmp_user.oxuser__oxbirthdate.value and oxcmp_user.oxuser__oxbirthdate.value != "0000-00 - 00" %}
        {% set iBirthdayMonth = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4)})[-]/":""|regex_replace('/[-]([0-9]{1,) 2})$/':"" %}
        {% set iBirthdayDay = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4)})[-]([0-9]{1, 2})[-]/":"" %}
        {% set iBirthdayYear = oxcmp_user.oxuser__oxbirthdate.value|regex_replace('/[-]([0-9]{1,) 2})[-]([0-9]{1, 2})$/':"" %}
    {% endif %}
    <div class="well well-sm">
        <dl>
            <dt>
                <input type="radio"
                        {% if blShowPaymentMethod %}
                            id="payment_{{ sPaymentID }}"
                            name="paymentid"
                            value="{{ sPaymentID }}"
                            {% if oView.getCheckedPaymentId() == paymentmethod.oxpayments__oxid.value %}checked{% endif %}
                        {% else %}
                            disabled
                        {% endif %}
                >
                <label for="payment_{{ sPaymentID }}">
                    <b>{{ paymentmethod.oxpayments__oxdesc.value }}</b>
                    <img src="{{ sImageUrl }}unzer_invoice.png" alt="{{ paymentmethod.oxpayments__oxdesc.value }}" style="vertical-align: middle;">
                </label>
                {% if false == blShowPaymentMethod %}
                    <dfn id="d3HeidelayInvoiceSecuredNotice"
                         class="alert alert-danger desc">{{ translate({ ident: "D3UNZER_PAYMENT_INVOICESECURED_NOTICE", args: iD3HeidelpayInvoiceSecuredLimits }) }}</dfn>
                {% endif %}
                {% if false == blD3HeidelpayHasSameAdresses %}
                    <dfn class="alert alert-danger d3HeidelaySameAddressNotice">{{ translate({ ident: "D3UNZER_PAYMENT_NOTSAMEADDRESS_NOTICE" }) }}</dfn>
                {% endif %}
            </dt>
            <dd class="payment-option {% if oView.getCheckedPaymentId() == paymentmethod.oxpayments__oxid.value %}activePayment{% endif %}">
                {% set oPaymentPrice = paymentmethod.getPrice() %}
                {% if oPaymentPrice.getPrice() %}
                    {% if oViewConf.isFunctionalityEnabled('blShowVATForPayCharge') %}
                        ({{ format_price(oPaymentPrice.getNettoPrice(), { currency: currency }) }}
                        {% if oPaymentPrice.getVatValue() > 0 %}
                            {{ translate({ ident: "PLUS_VAT" }) }} {{ format_price(oPaymentPrice.getVatValue(), { currency: currency }) }}
                        {% endif %})
                    {% else %}
                        ({{ format_price(oPaymentPrice.getBruttoPrice(), { currency: currency }) }})
                    {% endif %}
                {% endif %}
                {% if blShowPaymentMethod %}
                    <div class="form-group oxDate">
                        <label class="col-xs-12 col-lg-3 req">
                            {{ translate({ ident: "BIRTHDATE" }) }}
                            {% if oView.getPaymentError() == 1 %}*{% endif %}
                        </label>
                        <div class="col-sm-3 col-lg-3">
                            <input class="oxDay form-control" name="d3birthdate[{{ sPaymentID }}][day]" type="text"
                                   maxlength="2" value="{% if iBirthdayDay > 0 %}{{ iBirthdayDay }}{% endif %}"
                                   placeholder="{{ translate({ ident: "DAY" }) }}" required="">
                        </div>
                        <div class="col-sm-6 col-lg-3">
                            <select class="oxMonth form-control" name="d3birthdate[{{ sPaymentID }}][month]"
                                    required="">
                                <option value="" label="-">-</option>
                                {% for month in 1..13 %}
                                    <option value="{{ loop.index0 }}"
                                            label="{{ loop.index0 }}"
                                            {% if iBirthdayMonth == loop.index %} selected="selected" {% endif %}>
                                        {{ translate({ ident: "MONTH_NAME_" ~ loop.index }) }}
                                    </option>
                                {% endfor %}
                            </select>
                        </div>
                        <div class="col-sm-3 col-lg-3">
                            <input class="oxYear form-control" name="d3birthdate[{{ sPaymentID }}][year]" type="text"
                                   maxlength="4" value="{% if iBirthdayYear %}{{ iBirthdayYear }}{% endif %}"
                                   placeholder="{{ translate({ ident: "YEAR" }) }}" required="">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12 col-lg-9 offset-lg-3">
                            <div class="alert alert-info">{{ translate({ ident: "COMPLETE_MARKED_FIELDS" }) }}</div>
                        </div>
                    </div>
                {% endif %}
                {% block checkout_payment_longdesc %}
                    {% if paymentmethod.oxpayments__oxlongdesc.value %}
                        <div class="row">
                            <div class="col-xs-12 col-lg-9 offset-lg-3">
                                <div class="alert alert-info desc">
                                    {{ paymentmethod.oxpayments__oxlongdesc.getRawValue() }}
                                </div>
                            </div>
                        </div>
                    {% endif %}
                {% endblock %}
            </dd>
        </dl>
    </div>
{% endblock %}
