avrj/eventTicketing

View on GitHub
app/views/admin/orders/show.html.erb

Summary

Maintainability
Test Coverage
<%= render partial: "breadcrumb", locals: {current_page: "show"} %>

<h1 class="page-header">
  <span>Order by  <%= link_to @order.customer.firstname + " " + @order.customer.lastname, admin_customer_path(@order.customer) %></span>
  <div class="btn-group pull-right" role="group" aria-label="...">
    <%= link_to 'Edit', edit_admin_order_path(@order), class: "btn btn-primary" %>
    <%= link_to 'Destroy', admin_order_path(@order), method: :delete, data: {confirm: 'Are you sure?'}, class: "btn btn-danger" %>
  </div>
</h1>

<p>
  <strong>Status:</strong>
  <% if @order.paid %><span class="label label-success">paid</span>
  <% else %><span class="label label-danger">unpaid</span>
  <% end %>
</p>

<p>
  <strong>Created at:</strong>
  <%= @order.created_at %>
</p>
<% if @tickets.count > 0 %>
    <div>
      <h2>Tickets</h2>

      <table class="table table-striped">
        <thead>
        <tr>
          <th>Type</th>
          <th>Price</th>
          <th>Reservation code</th>
        </tr>
        </thead>
        <tbody>
        <% @tickets.each do |ticket| %>
            <tr>
              <td><%= ticket.ticket_type.name %></td>
              <td><%= number_to_currency(ticket.ticket_type.price) %></td>
                  <td><%= ticket.code %></td>
            </tr>
        <% end %>
        </tbody>
      </table>
    </div>
<% end %>
<% if @seats.count > 0 %>
    <div>
      <h2>Seats</h2>

      <table class="table table-striped">
        <thead>
        <tr>
          <th>Table</th>
          <th>Seat</th>
          <th>Type</th>
          <th>Price</th>
          <th>Reservation code</th>
        </tr>
        </thead>

        <tbody>
        <% @seats.each do |seat| %>
            <tr>
              <td><%= seat.ticket.ticket_type.name %></td>
              <td><%= seat.table %></td>
              <td><%= seat.seat %></td>
              <td><%= number_to_currency(seat.ticket.ticket_type.price) %></td>
              <td><%= seat.ticket.code %></td>
            </tr>
        <% end %>
        </tbody>
      </table>
    </div>
<% end %>
<div>
  <p><strong>Total price:</strong> <%= number_to_currency @order.total %></p>
</div>