{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% set modal_class = 'modal-lg' %}
{% block title %}{{ '指定班级'|trans }}{% endblock %}
{% block body %}

<form id="message-search-form" class="form-inline well well-sm" action="{{ path('admin_classroom_chooser') }}" method="get" novalidate>
	<div class="form-group">
	  <select class="form-control" name="categoryId">
	    {{ select_options(category_choices('course'), app.request.query.get('categoryId'), '班级分类'|trans) }}
	  </select>
	</div>
	<div class="form-group">
	  <select class="form-control" name="status">
	    {{ select_options(dict('courseStatus'), app.request.query.get('status'), '班级状态'|trans) }}
	  </select>
	</div>
	<div class="form-group">
	  <input class="form-control" type="text" placeholder="{{ '标题'|trans }}" name="title" value="{{ app.request.get('title') }}">
	</div>
	<button class="btn btn-primary">{{ '搜索'|trans }}</button>
</form>

<table class="table table-striped table-hover" id="classroom-table">
	<thead>
		<tr>
		 <th>{{ '编号'|trans }}</th>
	     <th width="30%">{{ '名称'|trans }}</th>
	     <th>{% if setting('default.user_name') %}{{setting('default.user_name')|default('学员'|trans)}}{% else %}{{ '学员'|trans }}{% endif %}{{ '数'|trans }}</th>
	     <th>{{ '价格'|trans }}</th>
	     <th>{{ '状态'|trans }}</th>
	     <th>{{ '操作'|trans }}</th>
		</tr>
	</thead>
	<tbody>
	  {% for classroom in classrooms %}
	    {% set category = categories[classroom.categoryId]|default(null) %}
		{% import "admin/macro.html.twig" as admin_macro %}
		<tr id="course-tr-{{ classroom.id }}">
		  <td>{{ classroom.id }}</td>
		  <td>
		    <a href="{{ path('classroom_show', {id:classroom.id}) }}" target="_blank"><strong>{{ classroom.title }}</strong></a>
		    <br>
		    <span class="text-muted text-sm">{{ '分类：'|trans }}{{ category.name|default('--') }}</span>
		    {% if classroom.recommended %}
		      <span class="label label-default">{{ '荐:'|trans }}{{ classroom.recommendedTime|date('Y-m-d') }}</span>
		    {% endif %}
		  </td>
		  <td>{{ classroom.studentNum }}</td>
		  <td class="text-danger">
		   	{% if setting('coin.coin_enabled') and setting('coin.price_type') == 'Coin' %}
            	{% if classroom.price > 0 %}
                    {{classroom.price * setting('coin.cash_rate') }} {{setting('coin.coin_name')}}
                {% else %}
                     {{ '免费'|trans }}
                {% endif %}
            {% else %}
                {% if classroom.price > 0 %}
                 	{{ classroom.price }}元
                {% else %}
                    {{ '免费'|trans }}
                {% endif %}
            {% endif %}
		  </td>
		  <td>{{ dict_text('courseStatus:html', classroom.status) }}</td>
		  
		  <td>
		 	<button type="button" class="btn btn-primary btn-sm choose-classroom" data-target="{{ classroom.id }}" data-name="{{ classroom.title}}">{{ '选择'|trans }}</button>
		  </td>
		</tr>
	  {% else %}
	    <tr><td colspan="20"><div class="empty">{{ '暂无%classroomName%记录'|trans({'%classroomName%':setting('classroom.name','班级'|trans)}) }}</div></td></tr>
	  {% endfor %}
	</tbody>
</table>

{{ web_macro.paginator(paginator) }}

{% endblock %}
{% block footer %}
  <button type="button" class="btn btn-default pull-right" data-dismiss="modal">{{ '关闭'|trans }}</button>
  
  <script>app.load('topxiaadminbundle/controller/classroom/chooser');</script>
{% endblock %}