drhenner/ror_ecommerce

View on GitHub
app/views/admin/fulfillment/shipments/index.html.erb

Summary

Maintainability
Test Coverage
<% if @order %>
  <h3>Shipments for Order # <%= @order.number %></h3>
<% else %>
  <h3>Shipments</h3>
<% end %>

<table class='hover'>
  <thead>
  <tr class='odd'>
    <th class='column1_header'>Number</th>
    <th>Order #</th>
    <th>Shipped at</th>
    <th>Tracking</th>
    <th>State</th>
    <th>Items</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>
  </thead>

<% @shipments.each do |shipment| %>
  <% if shipment.has_items? %>
      <tr class='<%= cycle("odd", "")%>'>
        <td><%= shipment.number %></td>
        <td><%= link_to shipment.order.number, edit_admin_fulfillment_order_path(shipment.order) %></td>
        <td><%= I18n.localize(shipment.shipped_at, :format => :us_time) if shipment.shipped_at %></td>
        <td><%= shipment.tracking %></td>
        <td><%= shipment.state %></td>
        <td>
          <%= raw shipment.order_items.collect {|item| item.variant.product_name }.join('<br/>')  %>

        </td>
        <td><%= link_to 'Show', admin_fulfillment_shipment_path(shipment) %></td>
        <td><%= link_to 'Edit', edit_admin_fulfillment_shipment_path(shipment) %></td>
        <td>
          <% unless shipment.shipped? %>
            <%= button_to 'Mark Shipped',
                          ship_admin_fulfillment_shipment_path(shipment, :order_id => shipment.order.number),
                          :confirm => "Are you sure?",
                          :method => :put %>
          <% end %>
        </td>
      </tr>
  <% end %>
<% end %>
</table>