{% extends 'TopxiaWebBundle:MyOrder:layout.html.twig' %}

{% set script_controller = 'my/orders' %}

{% set main_nav = 'orders' %}

{% block main_body %}
  <table class="table table-striped table-hover" id="orders-table">
    <thead>
      <th>名称</th>
      <th>成交时间</th>
      <th>价格</th>
      <th>状态</th>
      <th>操作</th>
    </thead>
    <tbody>
      {% for order in orders %}
        <tr>
          <td>
            {% if order.targetType == 'course' %}
              <a href="{{ path('course_show', {id:order.targetId}) }}" target="_blank">{{ order.title }}</a>
            {% elseif order.targetType == 'vip' %}
              <a href="{{ path('vip', {id:order.targetId}) }}" target="_blank">{{ order.title }}</a>
            {% else %}
              {{ order.title }}
            {% endif %}
            <div class="text-sm text-muted">
              订单号：{{ order.sn }}
              {% if order.payment == 'coin'%}
            <span style="color:#428bca;">
              虚拟币订单
              </span>
              {% endif %}
            </div>
          </td>
          <td>{{ order.createdTime|date('Y-n-d H:i') }}</td>
          {% if order.payment == 'coin'%}
            <td>{{ order.amount }} {{setting('coin.coin_name')}}</td>
              {% else %}
          <td>{{ order.amount }}元</td>
              {% endif %}
          <td>
            {{ dict_text('orderStatus:html', order.status) }}
          </td>
          <td>
             <div class="actions">
              {% if order.status == 'refunding' %}
                <a href="javascript:;" class="text-sm cancel-refund" data-url="{{ path('my_order_cancel_refund', {id:order.id}) }}">取消退款</a>
              {% endif %}
              {% if order.status == 'created' %}

               <a href="javascript:;" class="text-sm pay"  style="display:block" data-url="{{ path('course_order_repay') }}" data-order-id="{{order.id}}">去支付</a>

                <a href="javascript:;" class="text-sm cancel" style="display:block" data-url="{{ path('my_order_cancel', {id:order.id}) }}">取消订单</a>

              {% endif %}
            </div>
          </td>
        </tr>
      {% else %}
        <tr>
          <td colspan="20" class="empty">无订单记录</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>

{% endblock %}