{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}

{% block main %}
    <div class="ec-role">
        <div class="ec-pageHeader">
            <h1>{{ 'お届け先の指定'|trans }}</h1>
        </div>
    </div>

    <div class="ec-registerRole">
        <div class="ec-off1Grid">
            <div class="ec-off1Grid__cell">
                <div class="ec-addressRole">
                    {% if Customer.CustomerAddresses|length < eccube_config.eccube_deliv_addr_max %}
                        <div class="ec-addressRole__actions"><a class="ec-inlineBtn" href="{{ url('shopping_shipping_edit', {'id': shippingId}) }}">{{ '新規お届け先を追加する'|trans }}</a></div>
                    {% else %}
                        <div class="ec-alert-warning">
                            <div class="ec-alert-warning__text">
                                <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
                                {{ 'お届け先登録の上限の%count%件に達しています。お届け先を入力したい場合は、削除か変更を行ってください。'|trans({ '%count%': eccube_config.eccube_deliv_addr_max }) }}
                            </div>
                        </div>
                    {% endif %}
                    {% if has_errors(form.addresses) %}
                        <div class="ec-alert-warning">
                            <div class="ec-alert-warning__text">
                                <div class="ec-alert-warning__icon"><img src="{{ asset('assets/icon/exclamation-white.svg') }}"/></div>
                                {{ 'お届け先を指定してください'|trans }}
                            </div>
                        </div>
                    {% endif %}
                </div>

                <form method="post" action="{{ url('shopping_shipping', {'id': shippingId}) }}">
                    {{ form_widget(form._token) }}
                    <div class="ec-addressList">
                        {% for choice in form.addresses.vars.choices %}
                            {% set Address = choice.data %}
                        <div class="ec-addressList__item">
                            <div class="ec-addressList__remove">
                                {% set checked = choice is selectedchoice(form.addresses.vars.value) ? 'checked="checked"' : '' %}
                                <input type="radio" id="address{{ choice.value }}" name="{{ form.addresses.vars.full_name }}" value="{{ choice.value }}" {{ checked }} />
                            </div>
                            <div class="ec-addressList__address">
                                <div>{{ Address.name01 }}&nbsp;{{ Address.name02 }}</div>
                                <div>〒{{ Address.postal_code }} {{ Address.Pref }}{{ Address.addr01 }}{{ Address.addr02 }}</div>
                                <div>{{ Address.phone_number }}</div>
                            </div>
                        </div>
                        {% endfor %}
                    </div>

                    <div class="ec-registerRole__actions">
                        <div class="ec-off4Grid">
                            <div class="ec-off4Grid__cell">
                                <button type="submit" class="ec-blockBtn--action">{{ '選択したお届け先に送る'|trans }}</button>
                                <a class="ec-blockBtn--cancel" href="{{ url('shopping') }}">{{ '戻る'|trans }}</a>
                            </div>
                        </div>
                    </div>

                </form>
            </div>
        </div>

    </div>
{% endblock %}
