<%
  if @user
    @bulletins = Bulletin.where(:create_user_id => @user.id).page(params[:page]).per(10)
  else
    @bulletins = Bulletin.all.page(params[:page]).per(10)
  end

%>

<table class="table main-list">
  <thead>
    <tr>
      <th class="span1"><%= t('category') %></th>
      <th class="span3"><%= t('title') %></th>
      <th class="span1"><%= t('start_date') %></th>
      <th class="span1"><%= t('end_date') %></th>
      <th class="span1"><%= t('tags') %></th>
      <% if not @user%>
        <th class="span1"><%= t('last_modified') %></th>
      <% end %>
    </tr>
  </thead>
  <tbody id="tbody_bulletin" class="sort-holder">
    <% @bulletins.each do |bulletin| %> 
      <tr id="<%= dom_id bulletin%>" class="with_action">
        <td><%= bulletin.bulletin_category.title%></td>
        <td>
          <% if bulletin.is_checked? %>
            <%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
          <% else %>
             <%= bulletin.title%>
          <% end %>
        </td>
        <td><%= display_date_time(bulletin.postdate) %></td>
        <% if not bulletin.deadline.nil?%>
          <td><%= display_date_time(bulletin.deadline) %></td>
        <%else%>
          <td><%= t('no_deadline') %></td>
        <% end %>
        <td>
          <div class="label-group">
          <% bulletin.sorted_tags.each do |tag| %>
            <span class="label label-tags"><%= tag[I18n.locale] %></span>
          <% end %>
          </div>
        </td>
        <% if not @user%>
          <td><%= User.find(bulletin.create_user_id).name %></td>
        <% end %>
      </tr>
    <% end %> 
  </tbody>
</table>
