{#
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 '@admin/default_frame.twig' %}
{% set menus = ['order', 'order_master'] %}

{% block title %}{{ 'admin.order.order_list'|trans }}{% endblock %}
{% block sub_title %}{{ 'admin.order.order_management'|trans }}{% endblock %}

{% form_theme searchForm '@admin/Form/bootstrap_4_layout.html.twig' %}

{% block stylesheet %}
    <link rel="stylesheet" href="{{ asset('assets/css/tempusdominus-bootstrap-4.min.css', 'admin') }}">
    <style type="text/css">
        .datepicker-days th.dow:first-child,
        .datepicker-days td:first-child {
            color: #f00;
        }

        .datepicker-days th.dow:last-child,
        .datepicker-days td:last-child {
            color: #00f;
        }
    </style>
{% endblock stylesheet %}

{% block javascript %}
    <script>
        $(function() {
            if ($('[type="date"]').prop('type') != 'date') {
                // input type属性でdateが利用できるかどうか(カレンダー表示できないブラウザ対応)
                $.when(
                    $.getScript("{{ asset('assets/js/vendor/moment.min.js', 'admin') }}"),
                    $.getScript("{{ asset('assets/js/vendor/moment-with-locales.min.js', 'admin') }}"),
                    $.getScript("{{ asset('assets/js/vendor/tempusdominus-bootstrap-4.min.js', 'admin') }}")
                ).done(function() {
                    $('input[id$=_date_start]').datetimepicker({
                        locale: '{{ eccube_config.locale }}',
                        format: 'YYYY-MM-DD',
                        useCurrent: false,
                        buttons: {
                            showToday: true,
                            showClose: true
                        }
                    });

                    $('input[id$=_date_end]').datetimepicker({
                        locale: '{{ eccube_config.locale }}',
                        format: 'YYYY-MM-DD',
                        useCurrent: false,
                        buttons: {
                            showToday: true,
                            showClose: true
                        }
                    });
                });
            }

            toggleBtnBulk('input[id^="check_"]', '.btn-bulk-wrapper');
            $('input[id^="check_"]').on('change', function() {
                $('#toggle_check_all').prop('checked', false);
                toggleBtnBulk('input[id^="check_"]', '.btn-bulk-wrapper');
            });

            // 登録チェックボックス
            $('#toggle_check_all').on('change', function() {
                var checked = $(this).prop('checked');
                if (checked) {
                    $('input[id^="check_"]').prop('checked', true);
                } else {
                    $('input[id^="check_"]').prop('checked', false);
                }
                toggleBtnBulk('input[id^="check_"]', '.btn-bulk-wrapper');
            });

            $('#btn_bulk_delete').on('click', function(event) {
                event.preventDefault();
                $('#form_bulk').attr('action', "{{ url('admin_order_bulk_delete') }}").submit();
                return false;
            });

            // PDF出力(複数)
            $('#bulkExportPdf').on('click', function(event) {
                window.open('', 'newwin', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=700');
                $('#form_bulk').attr('action', "{{ url('admin_order_export_pdf') }}");
                $('#form_bulk').attr('target', 'newwin');
                $('#form_bulk').submit();
                return false;
            });

            // PDF出力(単一)
            $('.pdf-print').click(function() {
                window.open(this.href, 'newwin', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=700, height=700');
                return false;
            });

            // 送り状番号
            var updateTrackingNumber = function(id, url, tracking_number, callback) {
                $.ajax({
                    type: 'PUT',
                    url: url,
                    data: {'tracking_number': tracking_number}
                }).done(function(data, textStatus, jqXHR) {
                    if (data['status'] == 'OK') {
                        $('#tracking_number_' + id).val(data['tracking_number']);
                        if (typeof callback == 'function') {
                            callback();
                        }
                    } else {
                        alert('Update failed.');
                    }
                    return true;
                }).fail(function(jqXHR, textStatus, errorThrown) {
                    var response = JSON.parse(jqXHR.responseText);
                    var messages = '';
                    for (var i = 0; i < response.messages.length; i++) {
                        messages += response.messages[i] + "\n";
                    }
                    alert(messages);
                    return false;
                });
            };

            $('button.update_tracking_number').prop('disabled', true);
            // フォームに変更があったら更新ボタンを有効にする
            $('input.update_tracking_number').on('keyup', function(event) {
                var $tracking_number = $(this);
                var $button = $("button[data-target='#" + $tracking_number.attr('id') + "']");
                $button.prop('disabled', false);
                $button.children('i')
                    .removeClass('text-secondary')
                    .addClass('text-success');
            });
            // enter キーで更新し、次のフォームへフォーカスを移動する
            $('input.update_tracking_number').on('keypress', function(event) {
                var $tracking_number = $(this);
                var $button = $("button[data-target='#" + $tracking_number.attr('id') + "']");

                var code = event.which ? event.which : event.keyCode;

                if (code == 13) { // on press to enter
                    var index = $('input.update_tracking_number').index(this);
                    var callback = function() {
                        $button.prop('disabled', true);
                        $button.children('i')
                            .removeClass('text-success')
                            .addClass('text-secondary');
                        $('input.update_tracking_number:gt(' + index + '):first').focus();
                    };
                    updateTrackingNumber($tracking_number.data('shipping_id'), $tracking_number.data('url'), $tracking_number.val(), callback);
                    event.preventDefault();
                }
            });
            // 更新ボタンの制御
            $('button.update_tracking_number').on('click', function(event) {
                event.preventDefault();
                var $button = $(this);
                var $target = $($(this).data('target'));
                var tracking_number = $target.val();
                var callback = function() {
                    $button.prop('disabled', true);
                    $button.children('i')
                        .removeClass('text-success')
                        .addClass('text-secondary');
                };

        updateTrackingNumber($target.data('shipping_id'), $target.data('url'), tracking_number, callback);
    });

    // 完了ボタン
    $('#bulkChangeComplete').on('click', function() {
        location.href = '{{ url('admin_order', { 'resume': 1 }) }}';
    });

});
</script>

{{ include('@admin/Order/confirmationModal_js.twig') }}
{% endblock javascript %}

{% block main %}
    <!--検索条件設定テーブルここから-->
    <div class="c-outsideBlock">
        <form name="search_form" id="search_form" method="POST" action="{{ url('admin_order') }}">
            <div class="c-outsideBlock__contents">
                <div class="row">
                    <div class="col-12">
                        {{ form_widget(searchForm._token) }}
                        <div>
                            <label class="col-form-label" data-tooltip="true" data-placement="top" title="{{ 'tooltip.order.multi_search_label'|trans }}">{{ 'admin.order.multi_search_label'|trans }}<i class="fa fa-question-circle fa-lg ml-1"></i></label>
                            {{ form_widget(searchForm.multi) }}
                            {{ form_errors(searchForm.multi) }}
                        </div>
                        <div class="form-row">
                            <div class="form-group col-12">
                                <label class="col-form-label"  data-tooltip="true" data-placement="top" title="{{ 'tooltip.order.order_search_status'|trans }}">{{ 'admin.order.order_status'|trans }}<i class="fa fa-question-circle fa-lg ml-1"></i></label>
                                <div id="admin_search_order_status">
                                    {% set statusForm = searchForm.status %}
                                    <!-- 各対応状況の件数を表示する -->
                                    {% for status_id, child in statusForm.children %}
                                        <div class="form-check form-check-inline">
                                            <input type="checkbox"
                                                   id="{{ child.vars.id }}"
                                                   name="{{ child.vars.full_name }}"
                                                   class="form-check-input"
                                                   value="{{ child.vars.value }}"{{ child.vars.checked ? ' checked="checked"' }}>
                                            <label class="form-check-label" for="{{ child.vars.id }}">{{ child.vars.label }}</label>
                                            {%- if statusForm.vars.order_count[status_id].display -%}
                                                (<a href="{{ url('admin_order', { 'order_status_id': status_id }) }}">{{ statusForm.vars.order_count[status_id].count }}</a>)
                                            {%- endif %}
                                        </div>
                                    {% endfor %}
                                </div>
                                {{ form_errors(searchForm.status) }}
                            </div>
                        </div>
                        <div class="d-inline-block mb-3 collapsed" data-toggle="collapse" href="#searchDetail" aria-expanded="false" aria-controls="searchDetail">
                            <a>
                                <i class="fa font-weight-bold mr-1 fa-plus-square-o">
                                    <span class="font-weight-bold">{{ 'admin.common.search_detail'|trans }}</span>
                                </i>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="c-subContents ec-collapse collapse{{ has_errors ? ' show' }}" id="searchDetail">
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.orderer_name'|trans }}</label>
                        {{ form_widget(searchForm.name) }}
                        {{ form_errors(searchForm.name) }}
                    </div>
                    <div class="col">
                        <div class="form-row">
                            <div class="col-12">
                                <p class="col-form-label">{{ 'admin.common.payment_method'|trans }}</p>
                                {{ form_widget(searchForm.payment, { 'label_attr': { 'class': 'checkbox-inline'}}) }}
                                {{ form_errors(searchForm.payment) }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.orderer_kana'|trans }}</label>
                        {{ form_widget(searchForm.kana) }}
                        {{ form_errors(searchForm.kana) }}
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.order_date'|trans }}</label>
                        <div class="form-row align-items-center">
                            <div class="col">
                                {{ form_widget(searchForm.order_date_start) }}
                                {{ form_errors(searchForm.order_date_start) }}
                            </div>
                            <div class="col-auto text-center">{{ 'admin.common.separator__range'|trans }}</div>
                            <div class="col">
                                {{ form_widget(searchForm.order_date_end) }}
                                {{ form_errors(searchForm.order_date_end) }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.orderer_company_name'|trans }}</label>
                        {{ form_widget(searchForm.company_name) }}
                        {{ form_errors(searchForm.company_name) }}
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.payment_date'|trans }}</label>
                        <div class="form-row align-items-center">
                            <div class="col">
                                {{ form_widget(searchForm.payment_date_start) }}
                                {{ form_errors(searchForm.payment_date_start) }}
                            </div>
                            <div class="col-auto text-center">{{ 'admin.common.separator__range'|trans }}</div>
                            <div class="col">
                                {{ form_widget(searchForm.payment_date_end) }}
                                {{ form_errors(searchForm.payment_date_end) }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.common.mail_address'|trans }}</label>
                        {{ form_widget(searchForm.email) }}
                        {{ form_errors(searchForm.email) }}
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.common.update_date'|trans }}</label>
                        <div class="form-row align-items-center">
                            <div class="col">
                                {{ form_widget(searchForm.update_date_start) }}
                                {{ form_errors(searchForm.update_date_start) }}
                            </div>
                            <div class="col-auto text-center">{{ 'admin.common.separator__range'|trans }}</div>
                            <div class="col">
                                {{ form_widget(searchForm.update_date_end) }}
                                {{ form_errors(searchForm.update_date_end) }}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.common.phone_number'|trans }}</label>
                        {{ form_widget(searchForm.phone_number) }}
                        {{ form_errors(searchForm.phone_number) }}
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.delivery_date'|trans }}</label>
                        <div class="form-row align-items-center">
                            <div class="col">
                                <div class="input-group">
                                    {{ form_widget(searchForm.shipping_delivery_date_start) }}
                                    {{ form_errors(searchForm.shipping_delivery_date_start) }}
                                </div>
                            </div>
                            <div class="col-auto text-center">{{ 'admin.common.separator__range'|trans }}</div>
                            <div class="col">
                                <div class="input-group">
                                    {{ form_widget(searchForm.shipping_delivery_date_end) }}
                                    {{ form_errors(searchForm.shipping_delivery_date_end) }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.order_no'|trans }}</label>
                        {{ form_widget(searchForm.order_no) }}
                        {{ form_errors(searchForm.order_no) }}
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.purchase_price'|trans }}</label>
                        <div class="form-row align-items-center">
                            <div class="col">
                                <div class="input-group">
                                    {{ form_widget(searchForm.payment_total_start) }}
                                    {{ form_errors(searchForm.payment_total_start) }}
                                </div>
                            </div>
                            <div class="col-auto text-center">{{ 'admin.common.separator__range'|trans }}</div>
                            <div class="col">
                                <div class="input-group">
                                    {{ form_widget(searchForm.payment_total_end) }}
                                    {{ form_errors(searchForm.payment_total_end) }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col">
                        <div class="form-row">
                            <div class="col-12">
                                <p class="col-form-label">{{ 'admin.order.tracking_number'|trans }}</p>
                                {{ form_widget(searchForm.tracking_number) }}
                                {{ form_errors(searchForm.tracking_number) }}
                            </div>
                        </div>
                    </div>
                    <div class="col">
                        <label class="col-form-label">{{ 'admin.order.purchase_product'|trans }}</label>
                        {{ form_widget(searchForm.buy_product_name) }}
                        {{ form_errors(searchForm.buy_product_name) }}
                    </div>
                </div>

                <div class="row mb-2">
                    <div class="col">
                        <div class="form-row">
                            <div class="col-12">
                                <p class="col-form-label">{{ 'admin.order.shipping_mail'|trans }}</p>
                                {{ form_widget(searchForm.shipping_mail,  { 'label_attr': { 'class': 'checkbox-inline' }}) }}
                                {{ form_errors(searchForm.shipping_mail) }}
                            </div>
                        </div>
                    </div>
                    <div class="col"></div>
                </div>

                {# エンティティ拡張の自動出力 #}
                {% for f in searchForm if f.vars.eccube_form_options.auto_render %}
                    {# TODO 1項目1行になるのを改善 #}
                    <div class="row mb-2">
                        {% if f.vars.eccube_form_options.form_theme %}
                            {% form_theme f f.vars.eccube_form_options.form_theme %}
                            {{ form_row(f) }}
                        {% else %}
                            <div class="col">
                                <div class="mb-3">
                                    <label>{{ f.vars.label|trans }}</label>
                                    {{ form_widget(f) }}
                                    {{ form_errors(f) }}
                                </div>
                            </div>
                        {% endif %}
                    </div>
                {% endfor %}
            </div>
            
            <div class="row searchDetail__append">{# 2020.11 追加 #}
                <div class="col mt-3 mb-3">
                    <label class="col-form-label">通常/定期</label>
                    <div class="form-row align-items-center">
                        <div class="col">
                            {{ form_widget(searchForm.sale_type, { 'label_attr': { 'class': 'checkbox-inline'}}) }}
                            {{ form_errors(searchForm.sale_type) }}
                        </div>
                    </div>
                </div>
                <div class="col mt-3 mb-3">
                    <label class="col-form-label">定期購入継続状況</label>
                    <div class="form-row align-items-center">
                        <div class="col">
                            {{ form_widget(searchForm.periodical_status, { 'label_attr': { 'class': 'checkbox-inline'}}) }}
                            {{ form_errors(searchForm.periodical_status) }}
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="c-outsideBlock__contents">
                <div class="row">
                    <div class="mb-4">
                        <div class="col-12">
                            <button class="btn btn-ec-conversion px-5" type="submit" id="search_submit">{{ 'admin.common.search'|trans }}</button>
                            {% if pagination %}
                                <span class="font-weight-bold ml-2" id="search_total_count">{{ 'admin.common.search_result'|trans({"%count%":pagination.totalItemCount})|raw }}</span>
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            <div class="c-outsideBlock__contents mb-5">
                {{ include('@admin/search_items.twig', { 'form': searchForm }, ignore_missing = true) }}
            </div>
        </form>
    </div>
    <!--検索条件設定テーブルここまで-->

<h2>どうーー？</h2>

    <div class="c-contentsArea__cols">
        <div class="c-contentsArea__primaryCol">
            <div class="c-primaryCol">
                {% if pagination and pagination.totalItemCount %}

                    <form id="form_bulk" method="POST" action="">
                        <input type="hidden" name="{{ constant('Eccube\\Common\\Constant::TOKEN_NAME') }}" value="{{ csrf_token(constant('Eccube\\Common\\Constant::TOKEN_NAME')) }}">
                        <div class="row justify-content-between mb-2">
                            <div class="col-7">
                                <div class="row justify-content-between">
                                    <div class="col-auto d-none btn-bulk-wrapper">
                                        <label class="mr-2" data-tooltip="true" data-placement="top" title="{{ 'tooltip.order.bulk_actions'|trans }}">{{ 'admin.common.bulk_actions'|trans }}<i class="fa fa-question-circle fa-lg ml-1"></i></label>
                                        <button id="bulkSendMail" type="button" class="btn btn-ec-regular mr-2" data-type="mail" data-bulk-update="true">
                                            {{ 'admin.order.send_mail'|trans }}
                                        </button>
                                        <button type="button" id="bulkExportPdf" class="btn btn-ec-regular mr-2">{{ 'admin.order.output_delivery_note_short'|trans }}</button>
                                        {# TODO 削除処理は将来バージョンで対応 <button type="button" class="btn btn-ec-delete" data-toggle="modal" data-target="#bulkDeleteModal">{{ 'admin.common.delete'|trans }}</button> #}
                                    </div>
                                    <div class="col d-none btn-bulk-wrapper">
                                        <div class="d-inline-block mr-2">
                                            <select class="custom-select" id="option_bulk_status">
                                                <option value="" selected>{{ 'admin.order.change_status'|trans }}</option>
                                                {% for status in OrderStatuses %}
                                                    <option value="{{ status.id }}">{{ status.name }}</option>
                                                {% endfor %}
                                            </select>
                                        </div>
                                        <button type="button" id="btn_bulk_status" class="btn btn-ec-regular mr-2 progressModal" data-type="status" data-bulk-update="true" data-submit="bulk">
                                            {{ 'admin.common.decision'|trans }}
                                        </button>
                                    </div>
                                </div>
                            </div>
                            <div class="col-5 text-right">
                                <div class="d-inline-block">
                                    <select class="custom-select" onchange="location = this.value;">
                                        {% for pageMax in pageMaxis %}
                                            <option {% if pageMax.name == page_count %} selected {% endif %}
                                                    value="{{ path('admin_order_page', {'page_no': 1, 'page_count': pageMax.name}) }}">
                                                {{ 'admin.common.count'|trans({ '%count%': pageMax.name }) }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                                <div class="d-inline-block">
                                    <div class="btn-group" role="group">
                                        <div class="btn-group" role="group">
                                            <button type="button" class="btn btn-ec-regular" data-toggle="dropdown" id="csvDownloadDropDown">
                                                <i class="fa fa-cloud-download mr-1 text-secondary"></i>
                                                <span>{{ 'admin.common.csv_download'|trans }}</span>
                                            </button>
                                            <div class="dropdown-menu">
                                                <a class="dropdown-item" href="{{ url('admin_order_export_order') }}" id="orderCsvDownload">
                                                    {{ 'admin.order.order_csv'|trans }}
                                                </a>
                                                <a class="dropdown-item" href="{{ url('admin_order_export_shipping') }}" id="shippingCsvDownload">
                                                    {{ 'admin.order.shipping_csv'|trans }}
                                                </a>
                                            </div>
                                        </div>

                                        <div class="btn-group" role="group">
                                            <button type="button" class="btn btn-ec-regular" data-toggle="dropdown" id="csvSettingDropDown">
                                                <i class="fa fa-cog mr-1 text-secondary"></i>
                                                <span>{{ 'admin.setting.shop.csv_setting'|trans }}</span>
                                            </button>
                                            <div class="dropdown-menu">
                                                <a class="dropdown-item" href="{{ url('admin_setting_shop_csv', { id : constant('\\Eccube\\Entity\\Master\\CsvType::CSV_TYPE_ORDER') }) }}" id="orderCsvSetting">
                                                    {{ 'admin.order.order_csv'|trans }}
                                                </a>
                                                <a class="dropdown-item" href="{{ url('admin_setting_shop_csv', { id : constant('\\Eccube\\Entity\\Master\\CsvType::CSV_TYPE_SHIPPING') }) }}" id="shippingCsvSetting">
                                                    {{ 'admin.order.shipping_csv'|trans }}
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="card rounded border-0 mb-4 d-block">
                            <div class="card-body p-0">
                                <table class="table table-sm" id="search_result">
                                    <thead>
                                    <tr>
                                        <th class="border-top-0 pt-2 pb-2 text-center pl-3">
                                            <input type="checkbox" id="toggle_check_all" name="filter" value="open">
                                        </th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.orderer'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center text-nowrap">{{ 'admin.common.payment_method'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.order_status'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.purchase_price'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.message_short'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center text-nowrap">{{ 'admin.order.shipping_status'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.tracking_number'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center">{{ 'admin.order.delivery'|trans }}</th>
                                        <th class="border-top-0 pt-2 pb-2 text-center pr-3"></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {% for Order in pagination %}
                                        {% for Shipping in Order.Shippings %}
                                            <tr>
                                                <td class="align-middle text-center pl-3">
                                                    <input type="checkbox" id="check_{{ Shipping.id }}" data-id="{{ Shipping.id }}" name="ids[]" value="{{ Shipping.id }}"
                                                           data-preview-notify-mail-url="{{ url('admin_shipping_preview_notify_mail', { id: Shipping.id}) }}"
                                                           data-notify-mail-url="{{ url('admin_shipping_notify_mail', { id: Shipping.id}) }}"
                                                           data-update-status-url="{{ url('admin_shipping_update_order_status', { id: Shipping.id}) }}"
                                                    />
                                                </td>
                                                <td class="align-middle text-left">
                                                    <a class="action-edit" href="{{ url('admin_order_edit', { id : Order.id }) }}">{{ Order.order_no }}<br>{{ Order.name01 ~ Order.name02 }}<br>{{ Order.order_date|date_min }}</a>
                                                </td>
                                                <td class="align-middle text-center">
                                                    {{ Order.payment_method }}
                                                </td>
                                                <td class="align-middle text-center">
                                                    <span class="badge badge-ec-blue" style="background-color: #fff; color: {{ Order.OrderStatusColor }}; border-color: {{ Order.OrderStatusColor }}">{{ Order.OrderStatus }}</span>
                                                </td>
                                                <td class="align-middle text-right">
                                                    {{ Order.payment_total|price }}<br>
                                                    {{ Order.payment_date ? Order.payment_date|date_day : 'admin.order.not_payment'|trans }}
                                                </td>
                                                <td class="align-middle text-center">
                                                    {% if Order.message is not empty %}
                                                        <a class="btn btn-ec-actionIcon" href="{{ url('admin_order_edit', { id : Order.id }) }}#order_message" data-tooltip="true" data-placement="top" title="" data-original-title="{{ Order.message }}" aria-describedby="tooltip819464">
                                                            <i class="fa fa-commenting fa-lg text-secondary" aria-hidden="true"></i>
                                                        </a>
                                                    {% elseif Order.note is not empty %}
                                                        <a class="btn btn-ec-actionIcon" href="{{ url('admin_order_edit', { id : Order.id }) }}#order_note" data-tooltip="true" data-placement="top" title="" data-original-title="{{ Order.note }}" aria-describedby="tooltip819464">
                                                            <i class="fa fa-commenting fa-lg text-secondary" aria-hidden="true"></i>
                                                        </a>
                                                    {% endif %}
                                                </td>
                                                <td class="align-middle text-center">
                                                    {% if Order.is_multiple %}
                                                        <a href="{{ url('admin_shipping_edit', { id: Order.id }) }}">
                                                            {% if Shipping.shipping_date %}
                                                                {{ Shipping.shipping_date|date_day }}
                                                            {% else %}
                                                                {{ 'admin.order.unshipped'|trans }}
                                                            {% endif %}
                                                        </a>
                                                    {% else %}
                                                        {{ Shipping.shipping_date ? Shipping.shipping_date|date_day : 'admin.order.unshipped'|trans }}
                                                    {% endif %}
                                                    {% if Shipping.mail_send_date %}
                                                        {% set send_mail_date = Shipping.mail_send_date|date_min %}
                                                        <i class="fa fa-envelope fa-lg text-secondary" aria-hidden="true" data-tooltip="true" data-placement="top" data-original-title="{{ 'admin.order.shipping_mail__completed'|trans({'%date%': send_mail_date}) }}"></i>
                                                    {% endif %}
                                                </td>
                                                <td class="align-middle text-center">
                                                    <div class="input-group input-group-sm">
                                                        <input type="text" id="tracking_number_{{ Shipping.id }}" class="form-control update_tracking_number" placeholder="{{ 'admin.order.tracking_number'|trans }}" value="{{ Shipping.trackingNumber }}" data-shipping_id="{{ Shipping.id }}" data-url="{{ url('admin_shipping_update_tracking_number', { id : Shipping.id }) }}" tabindex="{{ loop.index }}"/>
                                                        <span class="input-group-btn">
                                                    <button type="button" class="btn btn-default update_tracking_number" data-target="#tracking_number_{{ Shipping.id }}">
                                                        <i class="fa fa-check fa-lg text-secondary" aria-hidden="true"></i>
                                                    </button>
                                                </span>
                                                    </div>
                                                </td>
                                                <td class="align-middle text-center">
                                                    {{ Shipping.name01 ~ Shipping.name02 }}<br>
                                                    {{ Shipping.Pref.name }}
                                                </td>
                                                <td class="align-middle pr-3">
                                                    <div class="text-right">
                                                        <div class="px-1 d-inline-block">
                                                            <a class="btn btn-ec-actionIcon confirmationModal"
                                                               data-type="mail" data-bulk-update="false"
                                                               data-preview-notify-mail-url="{{ url('admin_shipping_preview_notify_mail', { id: Shipping.id}) }}"
                                                               data-notify-mail-url="{{ url('admin_shipping_notify_mail', { id: Shipping.id}) }}"
                                                               data-tooltip="true" data-placement="top" title="{{ 'admin.order.shipping_mail_send'|trans }}">
                                                                <i class="fa fa-send fa-lg text-secondary" aria-hidden="true"></i>
                                                            </a>
                                                        </div>
                                                        <div class="px-1 d-inline-block">
                                                            <a class="btn btn-ec-actionIcon pdf-print" href="{{ url('admin_order_export_pdf') }}?ids[]={{ Shipping.id }}" data-tooltip="true" data-placement="top" title="{{ 'admin.order.output_delivery_note_short'|trans }}">
                                                                <i class="fa fa-table fa-lg text-secondary" aria-hidden="true"></i>
                                                            </a>
                                                        </div>
                                                        <div class="px-1 d-inline-block">
                                                            <a class="btn btn-ec-actionIcon confirmationModal" href="javascript:;"
                                                               data-id="{{ Shipping.id }}" data-type="status" data-bulk-update="false"
                                                               data-update-status-id="{{ constant('Eccube\\Entity\\Master\\OrderStatus::DELIVERED') }}"
                                                               data-update-status-url="{{ url('admin_shipping_update_order_status', { id: Shipping.id}) }}"
                                                               data-preview-notify-mail-url="{{ url('admin_shipping_preview_notify_mail', { id: Shipping.id}) }}"
                                                               data-tooltip="true" data-placement="top" title data-original-title="{{ 'admin.order.to_shipped'|trans }}">
                                                                <i class="fa fa-check fa-lg text-secondary" aria-hidden="true"></i>
                                                            </a>
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                        {% endfor %}
                                    {% endfor %}
                                    </tbody>
                                </table>
                                <div class="row justify-content-md-center mb-4"></div>
                            </div>
                            <div class="row justify-content-md-center mb-4">
                                {% if pagination.totalItemCount > 0 %}
                                    {% include "@admin/pager.twig" with { 'pages' : pagination.paginationData, 'routes' : 'admin_order_page' } %}
                                {% endif %}
                            </div>
                        </div>
                    </form>
                    {# 検索条件エラー時 #}
                {% elseif has_errors %}
                    <div class="card rounded border-0">
                        <div class="card-body p-4">
                            <div class="text-center text-muted mb-4 h5">{{ 'admin.common.search_invalid_condition'|trans }}</div>
                            <div class="text-center text-muted">{{ 'admin.common.search_try_change_condition'|trans }}</div>
                        </div>
                    </div>
                    {# 検索結果なし #}
                {% else %}
                    <div class="card rounded border-0">
                        <div class="card-body p-4">
                            <div class="text-center text-muted mb-4 h5">{{ 'admin.common.search_no_result'|trans }}</div>
                            <div class="text-center text-muted">{{ 'admin.common.search_try_change_condition'|trans }}</div>
                            <div class="text-center text-muted">{{ 'admin.common.search_try_advanced_search'|trans }}</div>
                        </div>
                    </div>
                {% endif %}

                <!-- 出荷済にする確認モーダル -->
                <div class="modal fade" id="sentUpdateModal" tabindex="-1" role="dialog" aria-labelledby="sentUpdateModal" aria-hidden="true" data-keyboard="false" data-backdrop="static">
                    <div class="modal-dialog modal-lg" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title font-weight-bold"><!--confirmationModal_js.twig--></h5>
                                <button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                            </div>
                            <div class="modal-body">
                                <p class="modal-message"></p>
                                <ul id="bulkErrors"></ul>
                                <div id="bulk-options">
                                    <div class="font-weight-bold mb-2 notificationMail">{{ 'admin.order.to_shipped__confirm_send_mail'|trans }}</div>
                                    <div class="form-check form-check-inline">
                                        <input class="form-check-input" type="checkbox" id="notificationMail">
                                        <label class="form-check-label notificationMail">
                                            {{ 'admin.order.to_shipped__confirm_send_mail_in_same_time'|trans }}
                                        </label>
                                    </div>
                                    <div>
                                        <div class="d-inline-block" data-toggle="collapse" href="#viewEmail" aria-expanded="false" aria-controls="viewEmail"><a><i class="fa fa-plus-square-o font-weight-bold mr-1"></i><span class="font-weight-bold">{{ 'admin.order.bulk_action__confirm_view_mail_body'|trans }}</span></a></div>
                                        <div class="collapse bg-light p-4 ec-collapse bg-ec-formGray" id="viewEmail" style="word-wrap: break-word; word-break:break-all">
                                            <pre></pre>
                                        </div>
                                    </div>
                                </div>
                                <div class="progress" style="display: none">
                                    <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button class="btn btn-ec-sub" type="button" data-dismiss="modal">{{ 'admin.common.cancel'|trans }}</button>
                                <button id="bulkChange" class="btn btn-ec-conversion" type="button"><!--confirmationModal_js.twig--></button>
                                <button id="bulkChangeComplete" class="btn btn-ec-regular" style="display: none" type="button">{{ 'admin.common.close'|trans }}</button>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 一括削除の確認モーダル -->
                <div class="modal fade" id="bulkDeleteModal" tabindex="-1" role="dialog" aria-labelledby="discontinuance" aria-hidden="true" data-keyboard="false" data-backdrop="static">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title font-weight-bold">{{ 'admin.order.delete__confirm_title'|trans }}</h5>
                                <button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                            </div>
                            <div class="modal-body text-left">
                                <p class="text-left">{{ 'admin.order.delete__confirm_message'|trans }}</p>
                                <ul id="bulkErrors"></ul>
                                <div class="progress" style="display: none">
                                    <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button class="btn btn-ec-sub" type="button" data-dismiss="modal">{{ 'admin.common.cancel'|trans }}</button>
                                <button class="btn btn-ec-delete" type="button" id="btn_bulk_delete">{{ 'admin.common.delete' | trans }}</button>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
{% endblock %}