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

<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: 120px;">
        课程名称
      </th>
      <th style="width: 50px;">
        作者
      </th>
      <th style="width: 50px;">
        申请者
      </th>
      <th style="width: 50px;">
        申请状态
      </th>
      <th style="width: 70px;">
        申请日期
      </th>
    </tr>
    </thead>
    <tbody>
    <%@count=@page*30 %>
    <% for homework in @homework do %>
        <% unless homework.nil? %>
            <% @count+=1 %>
            <tr>
              <td align="center">
                <%=@count %>
              </td>
              <% c_h = HomeworkCommon.find homework.homework_common_id %>
              <% if c_h %>
                  <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=c_h.name%>'>
                    <%=link_to(c_h.try(:name), student_work_index_path(:homework => c_h.id))%>
                  </td>
                  <% if c_h.course %>
                      <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=c_h.course.name%>'>
                        <%= link_to(c_h.course.name, course_path(c_h.course.id)) %>
                      </td>
                  <% end %>
                  <td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if c_h.try(:user).try(:realname) == ' '%><%= c_h.try(:user)%><% else %><%=c_h.try(:user).try(:realname) %><% end %>'>
                    <% if c_h.try(:user).try(:realname) == ' '%>
                        <%= link_to(c_h.try(:user), user_path(c_h.user_id)) %>
                    <% else %>
                        <%= link_to(c_h.try(:user).try(:realname), user_path(c_h.user_id)) %>
                    <% end %>
                  </td>
              <% end %>
              <td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if homework.try(:user).try(:realname) == ' '%><%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'>
                <% if homework.try(:user).try(:realname) == ' '%>
                    <%= link_to(homework.try(:user), user_path(homework.user_id)) %>
                <% else %>
                    <%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %>
                <% end %>
              </td>
              <td align="center">
                <% if homework.status == 1 %>
                    等待回复
                <% elsif homework.status == 2 %>
                    已通过
                <% else %>
                    已拒绝
                <% end %>
              </td>
              <td align="center">
                <%=format_date( homework.created_at ) %>
              </td>
            </tr>
        <% end %>
    <% end %>
    </tbody>
  </table>
</div>

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

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