<div class="contextual">
  <%= link_to l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
</div>

<h3>
  <%=l(:label_course_all)%>
</h3>

<%= form_tag({}, :method => :get) do %>
    <fieldset>
      <label for='name'>
        课程:
      </label>
      <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
      <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
      <%= link_to l(:button_clear), {:controller => 'admin', :action => 'courses'},:remote => true, :class => 'icon icon-reload' %>
    </fieldset>
<% end %>
&nbsp;

<div class="autoscroll">
  <table class="list" style="width: 100%;table-layout: fixed">
    <thead>
    <tr>
      <th style="width: 30px;">
        序号
      </th>
      <th style="width: 120px;">
        课程
      </th>
      <th style="width: 50px;">
        主讲老师
      </th>
      <th style="width: 30px;">
        学时
      </th>
      <th style="width: 20px;">
        <%=l(:field_is_public)%>
      </th>
      <th style="width: 70px;">
        <%=l(:field_created_on)%>
      </th>
    </tr>
    </thead>
    <tbody>
    <% @courses.each do |course| %>
        <tr class="<%= cycle("odd", "even") %>">
          <td style="text-align: center;">
            <%= course.id %>
          </td>
          <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=course.name%>'>
            <span>
              <%= link_to(course.name, course_path(course.id)) %>
            </span>
          </td>
          <td align="center">
            <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
          </td>
          <td align="center">
            <%= course.class_period %>
          </td>
          <td class="center">
            <%= checked_image course.is_public? %>
          </td>
          <td class="center">
            <%= format_date(course.created_at) %>
          </td>
        </tr>
    <% end %>
    </tbody>
  </table>
</div>

<div class="pagination">
  <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>

<% html_title(l(:label_course_all)) -%>
