<div class="row steps-data">
  
  <div class="columns alpha four">
    <h6><%= t(:shipping_address) %> <%= link_to "(#{t(:edit)})", checkout_state_path(:address) unless @order.completed? %></h6>
    <div class="address">
      <%= order.ship_address %>
    </div>
  </div>

  <div class="columns alpha four">
    <h6><%= t(:billing_address) %> <%= link_to "(#{t(:edit)})", checkout_state_path(:address) unless @order.completed? %></h6>
    <div class="address">
      <%= order.bill_address %>
    </div>
  </div>

  <div class="columns alpha four">
    <h6><%= t(:shipping_method) %> <%= link_to "(#{t(:edit)})", checkout_state_path(:delivery) unless @order.completed? %></h6>
    <div class="delivery">
      <%= order.shipping_method.name %>
    </div>
  </div>

  <div class="columns omega four">
    <h6><%= t(:payment_information) %> <%= link_to "(#{t(:edit)})", checkout_state_path(:payment) unless @order.completed? %></h6>
    <div class="payment-info">
      <% unless order.creditcards.empty? %>
        <span class="cc-type">
          <%= image_tag "creditcards/icons/#{order.creditcards.first.cc_type}.png" %>
          <%= t(:ending_in)%> <%= order.creditcards.first.last_digits %>
        </span>
        <br />
        <span class="full-name">
          <%= order.creditcards.first.first_name %>
          <%= order.creditcards.first.last_name %>
        </span>
      <% end %>
    </div>
  </div>

</div>

<hr />

<table class="index columns alpha omega sixteen" data-hook="order_details">
  <col width="15%" valign="middle" halign="center">
  <col width="70%" valign="middle">
  <col width="5%" valign="middle" halign="center">
  <col width="5%" valign="middle" halign="center">
  <col width="5%" valign="middle" halign="center">

  <thead id="line-items" data-hook>
    <tr data-hook="order_details_line_items_headers">
      <th colspan="2"><%= t(:item) %></th>
      <th class="price"><%= t(:price) %></th>
      <th class="qty"><%= t(:qty) %></th>
      <th class="total"><span><%= t(:total) %></span></th>
    </tr>
  </thead>

  <tbody id="line-items" data-hook>
    <% @order.line_items.each do |item| %>
      <tr data-hook="order_details_line_item_row">
        <td data-hook="order_item_image">
          <% if item.variant.images.length == 0 %>
            <%= link_to small_image(item.variant.product), item.variant.product %>
          <% else %>
            <%= link_to image_tag(item.variant.images.first.attachment.url(:small)), item.variant.product %>
          <% end %>
        </td>
        <td data-hook="order_item_description">
          <h4><%= item.variant.product.name %></h4>
          <%= truncate(item.variant.product.description, :length => 100, :omission => "...") %>
          <%= "(" + variant_options(item.variant) + ")" unless item.variant .option_values.empty? %>
        </td>
        <td data-hook="order_item_price" class="price"><span><%= number_to_currency item.price %></span></td>
        <td data-hook="order_item_qty"><%= item.quantity %></td>
        <td data-hook="order_item_total" class="total"><span><%= number_to_currency (item.price * item.quantity) %></span></td>
      </tr>
    <% end %>
  </tbody>
  <tfoot id="order-total" data-hook="order_details_total">
    <tr class="total">
      <td colspan="4"><b><%= t(:order_total) %>:</b></td>
      <td class="total"><span id="order_total"><%= number_to_currency @order.total %></span></td>
    </tr>
  </tfoot>
  <% if order.price_adjustment_totals.present? %>
    <tfoot id="price-adjustments" data-hook="order_details_price_adjustments">
      <% @order.price_adjustment_totals.keys.each do |key| %>
        <tr class="total">
          <td colspan="4"><strong><%= key %></strong></td>
          <td class="total"><span><%= number_to_currency @order.price_adjustment_totals[key] %></span></td>
        </tr>
      <% end %>
    </tfoot>
  <% end %>
  <tfoot id="subtotal" data-hook="order_details_subtotal">
    <tr class="total" id="subtotal-row">
      <td colspan="4"><b><%= t(:subtotal) %>:</b></td>
      <td class="total"><span><%= number_to_currency @order.item_total %></span></td>
    </tr>
  </tfoot>
  <tfoot id="order-charges" data-hook="order_details_adjustments">
    <% @order.adjustments.eligible.each do |adjustment| %>
    <% next if (adjustment.originator_type == 'Spree::TaxRate') and (adjustment.amount == 0) %>
      <tr class="total">
        <td colspan="4"><strong><%= adjustment.label %></strong></td>
        <td class="total"><span><%= number_to_currency adjustment.amount %></span></td>
      </tr>
    <% end %>
  </tfoot>
</table>