Updated order and line item display
authorNeil Smith <neil.git@njae.me.uk>
Wed, 11 Mar 2009 21:01:35 +0000 (21:01 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Wed, 11 Mar 2009 21:01:35 +0000 (21:01 +0000)
app/views/layouts/line_items.html.erb [deleted file]
app/views/orders/index.html.erb

diff --git a/app/views/layouts/line_items.html.erb b/app/views/layouts/line_items.html.erb
deleted file mode 100644 (file)
index 78d24cc..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
-  <title>LineItems: <%= controller.action_name %></title>
-  <%= stylesheet_link_tag 'scaffold' %>
-</head>
-<body>
-
-<p style="color: green"><%= flash[:notice] %></p>
-
-<%= yield  %>
-
-</body>
-</html>
index 39e117ecda9b3a5ac7514eb0116bac0f57f0bf10..640e77e3bea4078a5276769b9bdb2afc8f469eea 100644 (file)
@@ -6,6 +6,7 @@
     <th>Address</th>
     <th>Email</th>
     <th>Pay type</th>
+    <th>Total value</th>
   </tr>
 
 <% for order in @orders %>
     <td><%=h order.address %></td>
     <td><%=h order.email %></td>
     <td><%=h order.pay_type %></td>
+    <td><%= number_to_currency (order.line_items.inject(0) {|sum,item| sum + item.total_price}), :unit => "£" %></td>
     <td><%= link_to 'Show', order %></td>
     <td><%= link_to 'Edit', edit_order_path(order) %></td>
     <td><%= link_to 'Destroy', order, :confirm => 'Are you sure?', :method => :delete %></td>
   </tr>
+  <% for li in order.line_items %>
+    <tr>
+      <td> </td>
+      <td colspan="3"><i><%= li.quantity%> &times;
+        <%= h li.product.title %> =
+        <%= number_to_currency li.total_price, :unit => "£" %>
+      </i></td>
+    </tr>
+  <% end %>
+
 <% end %>
 </table>