<% content_for :page_specific_css do %>
  <%= stylesheet_link_tag "lib/list-check" %>
<% end %>
<% content_for :page_specific_javascript do %>
  <%= javascript_include_tag "lib/list-check" %>
<% end %>

<%
  if has_access?
    @books = Book.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
  else
    @books = Book.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
  end
%>

<% if has_access? %>
  <div class="list-active">
    <div class="btn-group">
      <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_books_path(member_profile_id: @member.id.to_s, disable: 'true') ) %>
      <%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_books_path(member_profile_id: @member.id.to_s, disable: 'false') ) %>
    </div>
  </div>
<% end -%>

<table class="table table-condensed table-striped main-list">
  <thead>
    <tr>
      <% if has_access? %>
      <th><input type="checkbox" /></th>
      <% end -%>
      <th class="span1"><%= t('personal_journal.year') %></th>
      <th><%= t('module_name.book') %></th>
      <% if not @user%>
        <th><%= t('personal_journal.authors') %></th>
      <% end %>
    </tr>
  </thead>
  <tbody>
    
  <% @books.each do |book| %> 
      
    <tr id="<%= dom_id book %>" class="<%= book.is_hidden ? "checkHide" : "" %>">
      <% if has_access? %>
      <td>
        <%= check_box_tag 'to_change[]', book.id.to_s, false, :class => "list-check" %>
      </td>
      <% end -%>
      <td><%= book.year %></td>
      <td>
      <%= link_to book.create_link, OrbitHelper.url_to_plugin_show(book.to_param,'personal_book'), target: "blank"%>
      <% if has_access? %>
        <div class="quick-edit">
          <ul class="nav nav-pills hide">
            <li><%= link_to t('edit'), edit_admin_book_path(book, member_profile_id: @member.id) %></li>
            <li><%= link_to t(:delete_), admin_book_path(id: book.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
          </ul>
        </div>
      <% end %>

      </td>
      <td><%= book.authors %></td>
    </tr>   
    
  <% end %> 

  </tbody>
</table>


<div class="bottomnav clearfix">
  <% if has_access? %>
    <div class="action pull-right">
      <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/books/frontend_setting', :class => 'btn btn-primary' %>
      <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), 
          '/admin/members/'+@member.to_param+'/books/new', :class => 'btn btn-primary' %>
    </div>
  <% end %>
  <div class="pagination pagination-centered">
    <%= paginate @books, :params => {:direction => params[:direction], :sort => params[:sort] } %>
  </div>
</div>

<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3><%= t(:sure?) %></h3>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
    <button class="delete-item btn btn-danger"><%= t(:submit) %></button>
  </div>
</div>