<%
  @filter = params[:filter]
  new_filter = params[:new_filter]
  
  if @filter && params[:clear]
    @filter.delete(params[:type])
  elsif @filter && new_filter
    if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
      @filter[new_filter[:type]].delete(new_filter[:id].to_s)
    elsif @filter.has_key?(new_filter[:type])
      @filter[new_filter[:type]] << new_filter[:id].to_s
    else
      @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
    end
  elsif new_filter
    @filter = {new_filter[:type] => [new_filter[:id].to_s]}
  end


  if @user
    @diplomas = Diploma.where(:create_user_id => @user.id).page(params[:page]).per(10)
  else
    @diplomas = Diploma.all.page(params[:page]).per(10)
  end

%>

<table class="table main-list">
	<thead>
		<tr>
			<th class="span1"><%= t('diploma.date') %></th>
			<th class="span3"><%= t('diploma.school_name') %></th>
		</tr>
	</thead>
	<tbody id="tbody_diplomas" class="sort-holder">
		
		
	<% @diplomas.each do |diploma| %>	
			
	<tr id="<%= dom_id diploma %>" class="with_action">
		<td><%= diploma.start_date.strftime("%Y.%m") %> ~ <%= diploma.end_date.strftime("%Y.%m") %></td>
		<td>
		<%= link_to diploma.school_name, panel_personal_diploma_front_end_diploma_path(diploma) %>
		</td>
	</tr>		
		
	<% end %>	
		
		
	</tbody>
</table>

<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_personal_diploma_back_end_diploma_path(:user_id => @user.id), :class => 'btn btn-primary pull-right' %>


<div class="form-actions form-fixed pagination-right">
	<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_personal_diploma_plugin_diploma_path, :class => 'btn btn-primary pull-right' %>
	<div id="diploma_pagination" class="paginationFixed">
	<%= paginate @diplomas, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
	</div>
</div>
