avrj/eventTicketing

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

Summary

Maintainability
Test Coverage
<h1 class="page-header">Orders</h1>

<% if !@orders.any? %>
    <p>Looks like there are no orders yet.</p>
<% else %>
    <p>Total of <%= pluralize(@orders.count, "order") %>.</p>
    <%= form_tag admin_orders_path, :method => :delete do %>
    <table class="table table-striped">
      <thead>
      <tr>
        <th></th>
        <th>Created at</th>
        <th>Customer</th>
        <th>Status</th>
        <th>Tickets</th>
        <th>Total price</th>
        <th></th>
      </tr>
      </thead>

      <tbody>
      <% @orders.each do |order| %>
          <tr>
            <td><%= check_box_tag 'order_ids[]', order.id %></td>
            <td><%= order.created_at %></td>
            <td><%= link_to order.customer.firstname + " " + order.customer.lastname, admin_customer_path(order.customer) %></td>
            <td>
              <% if order.paid %><span class="label label-success">paid</span>
              <% else %><span class="label label-danger">unpaid</span>
              <% end %></td>

            <td><%= order.tickets.count %></td>
            <td><%= number_to_currency(order.total) %></td>
            <td>
              <!-- Split button -->
              <div class="btn-group pull-right">
                <%= link_to 'Show', admin_order_path(order), class: "btn btn-primary" %>
                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                  <span class="caret"></span>
                  <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu" role="menu">
                  <li>
                    <%= link_to edit_admin_order_path(order) do %>
                        <span class="glyphicon glyphicon-edit"></span> Edit
                    <% end %>
                  </li>
                  <li>
                    <%= link_to admin_order_path(order), method: :delete, data: {confirm: 'Are you sure?'} do %>
                        <span class="glyphicon glyphicon-remove"></span> Remove
                    <% end %>
                  </li>
                </ul>
              </div>
            </td>
          </tr>
      <% end %>
      </tbody>
    </table>
        <%= submit_tag "Delete selected", class: "btn btn-danger", data: { confirm: "Are you sure?" } %>
        <% end %>
<% end %>