640e77e3bea4078a5276769b9bdb2afc8f469eea
[depot.git] / app / views / orders / index.html.erb
1 <h1>Listing orders</h1>
2
3 <table>
4 <tr>
5 <th>Name</th>
6 <th>Address</th>
7 <th>Email</th>
8 <th>Pay type</th>
9 <th>Total value</th>
10 </tr>
11
12 <% for order in @orders %>
13 <tr>
14 <td><%=h order.name %></td>
15 <td><%=h order.address %></td>
16 <td><%=h order.email %></td>
17 <td><%=h order.pay_type %></td>
18 <td><%= number_to_currency (order.line_items.inject(0) {|sum,item| sum + item.total_price}), :unit => "£" %></td>
19 <td><%= link_to 'Show', order %></td>
20 <td><%= link_to 'Edit', edit_order_path(order) %></td>
21 <td><%= link_to 'Destroy', order, :confirm => 'Are you sure?', :method => :delete %></td>
22 </tr>
23 <% for li in order.line_items %>
24 <tr>
25 <td> </td>
26 <td colspan="3"><i><%= li.quantity%> &times;
27 <%= h li.product.title %> =
28 <%= number_to_currency li.total_price, :unit => "£" %>
29 </i></td>
30 </tr>
31 <% end %>
32
33 <% end %>
34 </table>
35
36 <br />
37
38 <%= link_to 'New order', new_order_path %>