MiraitSystems/enju_trunk

View on GitHub
app/views/items/_show_book.html.erb

Summary

Maintainability
Test Coverage
<%= render 'manifestations/prepare_book_jacket' %>

<div id="content_detail" class="ui-corner-all">
<h1 class="title"><%= t('page.showing', :model => t('activerecord.models.item')) -%></h1>
<div id="content_list">
<div style="color: red"><%= raw flash[:message] -%></div>
<p id="notice"><%= raw notice %></p>
  <%- if @item.manifestation -%>
    <%= render 'manifestations/title', :manifestation => @item.manifestation -%>
  <%- end -%>

<%- if @item.bookbinder_id -%>
  <p>
    <strong><%= t('bookbinding.binded') %>:</strong>
    <%= link_to @item.try(:binder_item).try(:manifestation).try(:original_title), manifestation_path(@item.try(:binder_item).try(:manifestation)) %>
    (<%= link_to @item.binder_item.item_identifier || t('activerecord.attributes.item.item_identifier'), item_path(@item.binder_item) %>)
  </p>
<%- elsif @item.bookbinder -%>
  <p>
    <strong><%= t('bookbinding.binder') %>: </strong>
    <%= link_to t('bookbinding.binding_items'), {:controller => 'manifestations', :action => 'index', :bookbinder_id => @item.id} %>
  </p>
<%- end -%>

<p>
  <strong><%= t('activerecord.models.shelf') -%>:</strong>
  <%= link_to @item.shelf_display_name.localize, @item.shelf -%>
  <%= render 'items/shelf_picture', :item => @item -%>
  (<%= link_to @item.shelf.library.display_name.localize, @item.shelf.library -%>)
</p>

<% if SystemConfiguration.get('manifestation.manage_item_rank') %>
<% if user_signed_in? and current_user.has_role?('Librarian') %>
  <p>
    <strong><%= t('activerecord.attributes.item.rank') -%>:</strong>
    <%= i18n_rank(@item.rank) if @item.rank %>
  </p>
<% end %>
<% end %>

<p>
  <strong><%= t('activerecord.attributes.item.checkout_type') -%>:</strong>
  <%= link_to @item.checkout_type.display_name.localize, @item.checkout_type -%>
</p>

<p>
  <strong><%= t('activerecord.models.accept_type') -%>:</strong>
  <%= link_to @item.accept_type.display_name.localize, @item.accept_type if @item.accept_type%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.retention_period') -%>:</strong>
  <%= link_to @item.retention_period.display_name.localize, @item.retention_period if @item.retention_period -%>
</p>

<p>
  <strong><%= t('activerecord.models.circulation_status') -%>:</strong>
  <%#= link_to @item.circulation_status.display_name.localize, @item.circulation_status -%>
  <% if @item.circulation_status.name != 'Available On Shelf' %>
    <span class="not_rent_item">
      <%= @item.circulation_status.display_name.localize if @item.circulation_status %>
      <% if @item.try(:use_restriction).try(:name) == 'Not For Loan' %>
        (<%= t('activerecord.attributes.checkout.not_available') %>)
      <% end %>
    </span>
  <% else %>
    <% if @item.circulation_status %>
      <% if @item.try(:use_restriction).try(:name) != 'Not For Loan' %>
        <%= @item.circulation_status.display_name.localize %>
      <% else %>
        <span class="not_rent_item"><%= t('activerecord.attributes.checkout.not_for_loan') %></span>
      <% end %>
    <% end %>
  <% end %>
  <% if @item.rent? %>
    <% if user_signed_in? and current_user.has_role?('Librarian') %>
      (
      <%= t('activerecord.attributes.checkout.due_date') %>:
      <%= l(@item.checkout.due_date, :format => :only_date) %>
      <% if Time.zone.parse(@item.checkout.due_date.to_s) < Time.now %>
        <span class="not_rent_item"><%= t('activerecord.attributes.checkout.past_due') -%></span>
      <% end %>
      )
    <% end %>
  <% end %>

  <%- if @item.manifestation.series_statement && @item.manifestation.series_statement.last_issues.include?(@item.manifestation) -%>
    <%= t('item.new_serial') -%>
  <%- end -%>
  <%- if user_signed_in? && Setting.operation -%>
    <%- if current_user.has_role?('Librarian') -%>
      <%- unless @item.checkouts.not_returned.blank? -%>
        (<%= link_to t('item.current_checkout'), user_checkout_path(@item.checkouts.not_returned.first.user, @item.checkouts.not_returned.first) -%>)
      <%- end -%>
    <%- end -%>
  <%- end -%>
</p>

<% if @item.remove_reason %>
  <p>
    <strong><%= t('activerecord.models.remove_reason') %>:</strong>
    <%= link_to @item.remove_reason.display_name.localize, @item.remove_reason %>
  </p>
  <p>
    <strong><%= t('activerecord.attributes.item.removed_at') %>:</strong>
    <%= l(@item.removed_at) %>
  </p>
<% end %>

<p>
  <strong><%= t('activerecord.attributes.item.call_number') -%>:</strong>
  <%= call_numberformat(@item) -%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.location_category') -%>:</strong>
  <% if @item.location_category_id %>
   <%= @item.location_category.keyname -%>
  <% end %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.location_symbol') -%>:</strong>
  <% if @item.location_symbol_id %>
  <%= @item.location_symbol.keyname -%>
  <% end %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.statistical_class') -%>:</strong>
  <% if @item.statistical_class_id %>
  <%= @item.statistical_class.keyname -%>
  <% end %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.budget_category') -%>:</strong>
  <%- if @item.budget_category -%>
    <%= budget_category_group(@item.budget_category.group_id) if @item.budget_category.group_id %>
    <%= @item.budget_category.display_name -%>
  <%- end -%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.circulation_restriction') -%>:</strong>
  <% if @item.circulation_restriction_id %>
  <%= @item.circulation_restriction.keyname -%>
  <% end %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.item_identifier') -%>:</strong>
  <%= @item.item_identifier -%>
</p>

<%- if SystemConfiguration.get('item.use_different_identifier') %>
  <p>
    <strong><%= t('activerecord.attributes.item.identifier') -%>:</strong>
    <%= @item.identifier -%>
  </p>
<%- end -%>

<%- if @item.nacsis_identifier %>
  <p>
    <strong><%= t('activerecord.attributes.item.nacsis_identifier') -%>:</strong>
    <%= @item.nacsis_identifier -%>
  </p>
<%- end -%>

<p>
  <strong><%= t('activerecord.models.bookstore') -%>:</strong>
  <%= @item.bookstore.try(:name) -%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.price') -%>:</strong>
  <%= @item.price -%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.excluding_tax') %>:</strong>
  <%= @item.excluding_tax %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.tax') %>:</strong>
  <%= @item.tax %>
</p>

<p>
  <strong><%= t('activerecord.models.tax_rate') %>:</strong>
  <%= @item.try(:tax_rate).try(:display_name) %>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.url') -%>:</strong>
  <%= @item.url -%>
</p>

<p>
  <strong><%= t('activerecord.attributes.item.include_supplements') -%>:</strong>
  <%= localized_boolean(@item.include_supplements) -%>
</p>

<p>
  <strong><%= t('activerecord.models.use_restriction') -%>:</strong>
  <% if @item.use_restriction %>
    <ul>
      <li><%= @item.use_restriction.display_name.localize %></li>
    </ul>
  <% end %>
</p>

<% if user_signed_in? and current_user.has_role?('Librarian') %>
  <p>
    <strong><%= t('activerecord.attributes.item.non_searchable') %>:</strong>
    <%= localized_boolean(@item.non_searchable) %>
  </p>
<% end %>

<%- if SystemConfiguration.get('attributes.item.acquired_at') %>
  <p>
    <strong><%= t('activerecord.attributes.item.acquired_at') %>:</strong>
    <%= l(@item.acquired_at) %>
  </p>
<%- end -%>
<%- if SystemConfiguration.get('attributes.item.acquired_at_string') %>
  <p>
    <strong><%= t('activerecord.attributes.item.acquired_at_string') %>:</strong>
    <%= @item.acquired_at_string %>
  </p>
<%- end -%>

<p>
  <strong><%= t('activerecord.attributes.item.note') -%>:</strong>
  <%= simple_format(hbr @item.note) %>
</p>

<% if @item.claim %>
  <p>
    <strong><%= t('activerecord.attributes.claim.claim_type_id') -%>:</strong>
    <%= @item.claim.claim_type.display_name if @item.claim %>
  </p>

  <p>
    <strong><%= t('activerecord.attributes.claim.note') -%>:</strong>
    <%= @item.claim.note if @item.claim %>
  </p>
<% end %>

<p>
  <strong><%= t('page.created_at') -%>:</strong>
  <%= l(@item.created_at) -%>
</p>

<p>
  <strong><%= t('page.updated_at') -%>:</strong>
  <%= l(@item.updated_at) -%>
</p>

<%- if Setting.operation && @item.reserve -%>
  <%- if @item.reserve.user == current_user or (user_signed_in? and current_user.has_role?('Librarian')) -%>
    <%- if @item.reserve.can_checkout? -%>
      <%= form_tag ({:controller => 'reserves', :action => 'output'}) do -%>
        <%= hidden_field_tag :reserve_id, @item.reserve.id -%>
        <%= submit_tag t('page.output', :model => t('activerecord.attributes.reserve.reserve_list')) -%>
      <%- end -%>
    <%- end -%>
  <%- end -%>
<%- end -%>
<% if user_signed_in? and current_user.has_role?('Librarian') %>
  <%= render(:partial => 'show_item_has_operator', :locals => {:item => @item}) if SystemConfiguration.get('manifestation.use_item_has_operator') %>
<% end %>

</div>
</div>

<div id="submenu" class="ui-corner-all">
  <%= render 'manifestations/book_jacket', :manifestation => @item.manifestation -%>
  <ul>
    <%- if @item.circulation_status.name != "Removed" -%>
      <%- if @shelf -%>
        <li><%= link_to t('page.edit'), edit_library_shelf_item_path(@shelf.library, @shelf, @item) -%></li>
      <%- else -%>
        <li><%= link_to t('page.edit'), edit_item_path(@item) -%></li>
      <%- end -%>
    <%- end -%>
    <li><%= link_to t('page.back'), items_path -%></li>
    <%- if @item.circulation_status.name != "Removed" -%>
      <li><%= link_to t('page.remove'), remove_item_path(@item) -%></li>
    <%- else -%>
      <li><%= link_to t('page.restore'), restore_item_path(@item) -%></li>
    <%- end -%>
    <% if can? :destroy, @item %>
      <li><%= link_to t('page.destroy'), @item, :confirm => t('page.are_you_sure'), :method => :delete -%></li>
    <% end %>
    <% if defined? EnjuTrunkIll %>
      <%- if @item.inter_library_loans.empty? -%>
        <%- if user_signed_in? and current_user.has_role?('Librarian') -%>
          <li><%= link_to t('item.add_new_copy'), new_manifestation_item_path(@item.manifestation, :item_id => @item) -%></li>
        <%- end -%>
      <%- end -%>
    <% end %>
    <%- if @item.manifestation.bookbinder -%>
      <li><%= link_to(t('manifestation.undo_binding'), {:controller => 'bookbindings', :action => 'bind_undo', :item_id => @item.id}, :confirm => t('page.undo_binding')) -%></li>
    <%- end -%>
    <% if @item.available_order? %>
      <li><%= link_to t('item.add_to_order_list'), new_item_order_path(@item) %></li>
    <% end %>
  </ul>

  <%#- if @item.manifestation.nacsis_identifier || @item.manifestation.series_statement.nacsis_series_statementid -%>
  <%#- if @item.manifestation.nacsis_identifier || (@item.manifestation.series_statement and @item.manifestation.series_statement.nacsis_series_statementid) -%>
  <%- if @item.manifestation.nacsis_identifier && @item.id == (@item.manifestation.items.where('nacsis_identifier is not null').first.try(:id) || @item.id) -%>
    <br /><strong>&nbsp;
    <%= t('external_catalog.nacsis') + ' ' + t('page.edit') %>
    <%- if @item.manifestation.series_statement && @item.manifestation.series_statement.periodical %>
      <%= " (#{t('page.nacsis_serial')}) " %>
      <%- nacsis_db_type = 'SHOLD' %>
    <%- else %>
      <%= " (#{t('page.nacsis_book')}) " %>
      <%- nacsis_db_type = 'BHOLD' %>
    <%- end %>
    </strong>
    <%- if @item.nacsis_identifier %>
      <%= form_tag upload_to_nacsis_items_path, method: 'post' do %>
        <%= hidden_field_tag 'item_id', @item.id %>
        <%= hidden_field_tag 'command', 'update' %>
        <%= hidden_field_tag 'db_type', nacsis_db_type %>
        <%- option_hash = {:confirm => t('page.roles_confirm')} %><%= " " %>
        <%= submit_tag t('activerecord.models.item') + ' ' + t('page.update'), option_hash %>
      <% end %>
      <%= form_tag upload_to_nacsis_items_path, method: 'post' do %>
        <%= hidden_field_tag 'item_id', @item.id %>
        <%= hidden_field_tag 'command', 'delete' %>
        <%= hidden_field_tag 'db_type', nacsis_db_type %>
        <%- option_hash = {:confirm => t('page.are_you_sure')} %><%= " " %>
        <%= submit_tag t('activerecord.models.item') + ' ' + t('page.delete'), option_hash %>
      <% end %>
    <%- else -%>
      <%= form_tag upload_to_nacsis_items_path, method: 'post' do %>
        <%= hidden_field_tag 'item_id', @item.id %>
        <%= hidden_field_tag 'command', 'insert' %>
        <%= hidden_field_tag 'db_type', nacsis_db_type %>
        <%- option_hash = {:confirm => t('page.roles_confirm')} %><%= " " %>
        <%= submit_tag t('activerecord.models.item') + ' ' + t('page.create'), option_hash %>
      <% end %>
    <% end %>
  <%- end -%>
</div>