{% extends 'admin/layout.html.twig' %}

{#
    {% set script_controller = 'trade/index' %}
#}

{% set menu = 'admin_' ~ targetType ~ '_order' %}

{% set script_controller = 'manage/list' %}

{% block main %}

  <form id="user-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="mbm">
      <div class="form-group">
        <label class="ptm">{{ '创建时间:'|trans }}</label>
        <input class="form-control" type="text" id="startDate" name="startDateTime" value="{{ request.get('startDateTime') }}"
          placeholder="{{ '起始时间'|trans }}">
        -
        <input class="form-control" type="text" id="endDate" name="endDateTime" value="{{ request.get('endDateTime') }}"
          placeholder="{{ '结束时间'|trans }}">
      </div>
    </div>
    <div class="mbm">
      <div class="form-group">
        <label class="ptm">{{ '筛选条件:'|trans }}</label>
        <select class="form-control" name="status">
          {{ select_options(dict('orderStatus'), request.get('status'), '订单状态'|trans) }}
        </select>

        <select class="form-control" name="payment">
          {{ select_options(dict('payment'), request.get('payment'), '支付方式'|trans) }}
        </select>
      </div>
      <div class="form-group" style="display:none;">
        <input class="form-control" type="text" name="paidTimeRange" , placeholder="{{ '付款时间段'|trans }}">
      </div>


      <div class="form-group">
        <label class="ptm">{{ '关键词:'|trans }}</label>
        <select class="form-control" name="keywordType">
          {% if targetType == 'vip' %}
            {% set options = {sn: '订单号'|trans, buyer:'购买者用户名'|trans, title: dict_text('targetName', targetType) ~ '名'|trans} %}
          {% elseif targetType == 'course' %}
            {% set options = {
            sn: '订单号'|trans,
            buyer:'购买者用户名'|trans,
            courseSetTitle:'课程名称',
            courseSetId:' 课程编号',
            title: dict_text('targetName', targetType) ~ '名'|trans,
            mobile:'购买者绑定手机号'|trans,
            email:'购买者邮箱'|trans} %}
          {% else %}
            {% set options = {sn: '订单号'|trans, buyer:'购买者用户名'|trans, targetId: dict_text('targetName', targetType) ~ '编号'|trans, title: dict_text('targetName', targetType) ~ '名'|trans, mobile:'购买者绑定手机号'|trans, email:'购买者邮箱'|trans} %}
          {% endif %}
          {{ select_options(options, request.get('keywordType')) }}
        </select>

        <input class="form-control" type="text" name="keyword" value="{{ request.get('keyword') }}" placeholder="{{ '关键词'|trans }}">
      </div>

      <button class="btn btn-primary">{{ '搜索'|trans }}</button>
      <a class="btn btn-primary btn-export-csv"
        href="{{ path('admin_order_manage_export_csv',
        {targetType:targetType,
          startTime:request.get('startDateTime'),
          endTime:request.get('endDateTime'),
          status:request.get('status'),
          payment:request.get('payment'),
          keywordType:request.get('keywordType'),
          keyword:request.get('keyword')
        }) }}"
        data-export-count="{{ paginator.getItemCount() }}"
        data-export-count-format="{{ paginator.getItemCount()|number_to_human }}"
        data-export-allow-count="{{ setting('magic.export_allow_count') }}"
        data-export-allow-count-format="{{ setting('magic.export_allow_count')|number_to_human }}"
      >{{ '导出结果'|trans }}</a>
    </div>
  </form>

  <table class="table table-striped table-hover" id="order-table">
    {% include 'order/order-table.html.twig' with {mode:'admin'} %}
  </table>
  <div class="paginator">
    {{ admin_macro.paginator(paginator) }}
  </div>

  <div class="alert alert-info">
    站外支付为该笔订单是通过导入或者手动添加的方式产生的，故为站外支付
  </div>
{% endblock %}
