{#
    mode的取值有:
      my:该模式下不显示购买者
      admin:该模式下详情无下拉菜单
      course:该模式下详情无下拉菜单
#}
{% import "common/data-dict-macro.html.twig" as dict_macro %}
{% import "macro.html.twig" as web_macro %}
{% set mode = mode|default(['my']) %}
  <thead>
    <tr>
      <th width="20%">{{'订单名称'|trans}}</th>
      <th>{{'创建时间'|trans}}</th>
      <th>{{'状态'|trans}}</th>
      <th>{{'实付(元)'|trans}}</th>
      {% if mode in ['course', 'admin'] %}
        <th width="10%">{{'购买者'|trans}}</th>
      {% endif %}
      <th>{{'支付方式'|trans}}
      <span data-toggle="popover" data-trigger="hover" data-placement="bottom" data-container="body" data-content="
       <div>站外支付为该笔订单是通过导入或者手动添加的方式产生的，故为站外支付</div>" class="glyphicon glyphicon-question-sign color-gray text-sm js-pay-way-popover"></span>
      </th>
      <th style="min-width:100px">{{'操作'|trans}}</th>
    </tr>
  </thead>
  <tbody>
    {% for order in orders %}
      {% set buyer = users[order.userId]|default(null) %}
        <tr id="order-table-{{order.id}}" style="word-break: break-all;word-wrap: break-word;">
          <td>
            {% if order.targetType == 'course' %}
              <a  class="link-primary" href="{{ path('course_show', {id:order.targetId}) }}" target="_blank"><strong>{{order.title}}</strong></a>
            {% elseif order.targetType == 'vip' %}
              <a class="link-primary" href="{{ path('vip', {id:order.targetId}) }}" target="_blank"><strong>{{order.title}}</strong></a>
            {% elseif order.targetType == 'classroom' %}
              <a class="link-primary" href="{{ path('classroom_show', {id:order.targetId}) }}" target="_blank"><strong>{{order.title}}</strong></a>
            {% else %}
              <strong>{{order.title}}</strong>
            {% endif %}
            <br>
            <span class="color-gray text-sm">{{'订单号：%sn%'|trans({'%sn%':order.sn})}}</span>
            {# {% if order.targetType == 'course' %}
              <br>
              <span class="color-gray text-sm">
                {% if courses[order.targetId]|default(false) and courseSets[courses[order.targetId].courseSetId]|default(false) %}
                  {% set courseSet = courseSets[courses[order.targetId].courseSetId] %}
                  {{'所属课程:'|trans}}<a class="link-primary" href="{{ path('course_show', {id:courseSet.defaultCourseId}) }}">{{ courseSet.title }}</a>
                {% else %}
                  该课程已被删除
                {% endif %}
              </span>
            {% endif %} #}
          </td>
          <td><span class="color-gray text-sm">{{ order.createdTime|date('Y-n-d H:i:s') }}</span></td>
          <td>{{ dict_macro.orderStatus(order.status) }}</td>
          <td><span class="color-warning">{{order.amount}}</span></td>
          {% if mode in ['admin', 'course'] %}
            <td>
              {{ web_macro.user_link(buyer) }}
            </td>
          {% endif %}
          <td>
            {% if order.paidTime > 0 %}
              {{ dict_text('payment', order.payment)|default('--') }}
              <br>
              <span class="color-gray text-sm">{{ order.paidTime |date('Y-n-d H:i:s') }}</span>
            {% else %}
              --
            {% endif %}
          </td>
          <td>
            {% if 'admin' == mode  %}
                <a class="link-primary" href="javascript:;"  data-toggle="modal" data-target="#modal" data-url="{{ path('admin_order_detail', {id:order.id}) }}">{{'详情'|trans}}</a>
              {% endif %}
            {% if 'course' == mode %}
            <a class="link-primary" href="javascript:;"  data-toggle="modal" data-target="#modal" data-url="{{ path('course_order_detail', {id:order.id}) }}">{{'详情'|trans}}</a>
            {% endif %}

            {% if 'my' == mode %}
              <div class="btn-group">
                <a href="javascript:;" class="link-primary" data-toggle="modal" data-target="#modal" data-url="{{ path('web_user_order_detail', {id:order.id}) }}">{{'详情'|trans}}</a>
                {% if order.status == 'refunding' or  order.status == 'created' %}
                  <a href="#" type="button" class="link-primary ml10 dropdown-toggle" data-toggle="dropdown">
                  <span class="caret"></span>
                  </a>
                  <ul class="dropdown-menu pull-right {# text-right #}" style="min-width: 120px;" >

                  {# <div class="actions"> #}
                    {% if order.status == 'refunding' %}
                      <li><a href="javascript:;" class="cancel-refund" data-url="{{ path('my_order_cancel_refund', {id:order.id}) }}">{{'取消退款'|trans}}</a></li>
                    {% endif %}
                    {% if order.status == 'created' %}

                      <li>
                        <a href="{{path('pay_center_show', {sn:order.sn,targetType:order.targetType})}}"  style="display:block" >{{'去支付'|trans}}</a>
                      </li>
                      <li><a href="javascript:;" class=" cancel" style="display:block" data-url="{{ path('my_order_cancel', {id:order.id}) }}">{{'取消订单'|trans}}</a></li>

                    {% endif %}
                   {#  </div> #}
                  </ul>
                {% endif %}
              </div>
            {% endif %}
          </td>
        </tr>
    {% else %}
      <tr><td colspan="20"><div class="empty">{{'暂无订单记录'|trans}}</div></td></tr>
    {% endfor %}
  </tbody>
