<%= paginate @orders, params: {controller: '/ps_admin/order', action: :index}, theme: 'admin' %>
<% if @orders.blank? %>
<div class="callout callout-warning">
  <h4>Brak zamówień</h4>
</div>
<% else %>
  <table class="table table-bordered">
    <tbody>
      <tr>
        <th>ID</th>
        <th>Składający</th>
        <th>Kwota zamówienia</th>
        <th>Status</th>
        <th>Data utworzenia</th>
        <th style="width: 240px">Akcje</th>
      </tr>
      <% @orders.each do |order| %>
      <tr>
        <td><%= link_to order.beauty_id, {controller: '/ps_admin/order', action: 'show', id: order.id} %></td>
        <td><%= order.full_name %></td>
        <td><%= format('%.2f', order.order_summary) %></td>
        <td><%= raw(Order::ORDER_STATUSES_HTML[order.status]) %></td>
        <td><%= order.created_at %></td>
        <td>
          <%= link_to raw('<i class="fa fa-edit"></i> Edycja'), {controller: '/ps_admin/order', action: 'edit', id: order.id}, class: 'btn btn-xs btn-info', remote: true %>
          <%= link_to raw('<i class="fa fa-trash"></i> Usuń'), {controller: '/ps_admin/order', action: 'destroy', id: order.id, page: params[:page]}, class: "btn btn-danger btn-xs", remote: true, method: :delete, data: { confirm: 'Czy na pewno usunąć?' } %>
          <%= link_to raw('<i class="fa fa-trash"></i> Anonimizuj'), {controller: '/ps_admin/order', action: 'anonimize', id: order.id, page: params[:page]}, class: "btn bg-maroon btn-xs", remote: true, data: { confirm: 'Czy na pewno zanonimizować dane?' } %>
        </td>
      </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
<%= paginate @orders, params: {controller: '/ps_admin/order', action: :index}, theme: 'admin' %>
