MiraitSystems/enju_trunk

View on GitHub
app/views/manifestations/_show_holding.mobile.erb

Summary

Maintainability
Test Coverage
<% if manifestation.items.exists? %>
<% items = manifestation.items = SystemConfiguration.get('manifestation.manage_item_rank') ? manifestation.items.sort_rank : manifestation.items %>
<% items = items.select{|i| i.has_view_role?(current_user.try(:role).try(:id)) && !hide_item?(params[:all_manifestation], i)} %>
<% unless items.blank? %>
  <div class="holding">
    <ol data-role="listview">
      <% items.each do |item| %>
        <hr class="dash_line">
        <table>
        <% if item.shelf %>
          <% if item.shelf.library %>
            <tr>
              <td class="label"><%= t('activerecord.models.library') %>:</td>
              <td><%= item.shelf.library.display_name.localize %></td>
            </tr>
          <% end %>
          <tr>
            <td class="label"><%= t('activerecord.models.shelf') %>:</td>
            <td>
              <%= item.shelf.display_name.localize %>
              <%= render 'items/shelf_picture', :item => item if item.shelf %>
            </td>
          </tr>
        <% end %>
        <% if item.call_number.present? %>
          <tr>
            <td class="label"><%= t('activerecord.attributes.item.call_number') %>:</td>
            <td>
              <%= call_numberformat(item) %>
            </td>
          </tr>
        <% end %>
        <tr>
          <td class="label"><%= t('activerecord.attributes.item.item_identifier') %>:</td>
          <td>
            <% if item.item_identifier? %>
              <%= item.item_identifier %>
            <% else %>
              (<%= t('item.no_number') %>)
            <% end %>
          </td>
        </tr>
        <tr>
          <% unless manifestation.article? %>
            <td class="label"><%= t('activerecord.models.circulation_status') %>:</td>
            <td>
              <% 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.use_restriction.try(:name) == 'Not For Loan' %>
                    (<%= t('activerecord.attributes.checkout.not_available') %>)
                  <% end %>
                </span>
              <% else %>
                <% if item.circulation_status %>
                  <% if item.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') || current_user.id == item.checkout.user_id) %>
                  <br />
                  (
                  <%= 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') -%>
                      <%= t('checkout.days_overdue', :days => item.checkout.day_of_overdue) %>
                    </span>
                  <% end %>
                  )
                <% end %>
              <% end %>
            </td>
          <% end %>
        </tr>
        </table>
      <% end %>
    </ol> 
  </div>
  <hr>
<% end %>
<% end %>