<% content_for :page_title do %> <%= plural_resource_name(Spree::Order) %> <% end %> <% content_for :page_actions do %> <%= button_link_to Spree.t(:new_order), new_admin_order_url, :class => "btn-success", :icon => 'add', :id => 'admin_new_order' %> <% end if can? :create, Spree::Order %> <% content_for :table_filter do %>
<%= search_form_for [:admin, @search] do |f| %>
<%= label_tag :q_created_at_gt, Spree.t(:date_range) %>
<%= f.text_field :created_at_gt, :class => 'datepicker datepicker-from form-control', :value => params[:q][:created_at_gt], :placeholder => Spree.t(:start) %>
<%= f.text_field :created_at_lt, :class => 'datepicker datepicker-to form-control', :value => params[:q][:created_at_lt], :placeholder => Spree.t(:stop) %>
<%= label_tag :q_number_cont, Spree.t(:order_number, :number => '') %> <%= f.text_field :number_cont, class: 'form-control js-quick-search-target' %>
<%= label_tag :q_state_eq, Spree.t(:status) %> <%= f.select :state_eq, Spree::Order.state_machines[:state].states.map {|s| [Spree.t("order_state.#{s.name}"), s.value]}, {:include_blank => true}, :class => 'select2 js-filterable' %>
<%= label_tag :q_payment_state_eq, Spree.t(:payment_state) %> <%= f.select :payment_state_eq, Spree::Order::PAYMENT_STATES.map {|s| [Spree.t("payment_states.#{s}"), s]}, {:include_blank => true}, :class => 'select2 js-filterable' %>
<%= label_tag :q_shipment_state_eq, Spree.t(:shipment_state) %> <%= f.select :shipment_state_eq, Spree::Order::SHIPMENT_STATES.map {|s| [Spree.t("shipment_states.#{s}"), s]}, {:include_blank => true}, :class => 'select2 js-filterable' %>
<%= label_tag :q_bill_address_firstname_start, Spree.t(:first_name_begins_with) %> <%= f.text_field :bill_address_firstname_start, class: 'form-control' %>
<%= label_tag :q_bill_address_lastname_start, Spree.t(:last_name_begins_with) %> <%= f.text_field :bill_address_lastname_start, class: 'form-control' %>
<%= label_tag :q_email_cont, Spree.t(:email) %> <%= f.text_field :email_cont, class: 'form-control js-filterable' %>
<%= label_tag :q_line_items_variant_id_in, Spree.t(:sku) %> <%= f.select :line_items_variant_id_in, Spree::Variant.having_orders.order(:sku).pluck(:sku, :id), {:include_blank => true}, :class => 'select2' %>
<%= label_tag :q_promotions_id_in, Spree.t(:promotion) %> <%= f.select :promotions_id_in, Spree::Promotion.applied.pluck(:name, :id), {:include_blank => true}, :class => 'select2' %>
<%= label_tag 'q_completed_at_not_null' do %> <%= f.check_box :completed_at_not_null, {:checked => @show_only_completed}, '1', '0' %> <%= Spree.t(:show_only_complete_orders) %> <% end %>
<%= label_tag 'q_considered_risky_eq' do %> <%= f.check_box :considered_risky_eq, {:checked => (params[:q][:considered_risky_eq] == '1')}, '1', '' %> <%= Spree.t(:show_only_considered_risky) %> <% end %>
<%= button Spree.t(:filter_results), 'search' %>
<% end %>
<% end %> <%= render :partial => 'spree/admin/shared/index_table_options', :locals => { :collection => @orders } %> <% if @orders.any? %> <% if @show_only_completed %> <% else %> <% end %> <% if Spree::Order.checkout_step_names.include?(:delivery) %> <% end %> <% @orders.each do |order| %> <% if Spree::Order.checkout_step_names.include?(:delivery) %> <% end %> <% end %>
<%= sort_link @search, :completed_at, I18n.t(:completed_at, :scope => 'activerecord.attributes.spree/order') %><%= sort_link @search, :created_at, I18n.t(:created_at, :scope => 'activerecord.attributes.spree/order') %><%= sort_link @search, :number, I18n.t(:number, :scope => 'activerecord.attributes.spree/order') %> <%= sort_link @search, :considered_risky, I18n.t(:considered_risky, :scope => 'activerecord.attributes.spree/order') %> <%= sort_link @search, :state, I18n.t(:state, :scope => 'activerecord.attributes.spree/order') %> <%= sort_link @search, :payment_state, I18n.t(:payment_state, :scope => 'activerecord.attributes.spree/order') %><%= sort_link @search, :shipment_state, I18n.t(:shipment_state, :scope => 'activerecord.attributes.spree/order') %><%= sort_link @search, :email, I18n.t(:email, :scope => 'activerecord.attributes.spree/order') %> <%= sort_link @search, :total, I18n.t(:total, :scope => 'activerecord.attributes.spree/order') %>
<%= l (@show_only_completed ? order.completed_at : order.created_at).try(&:to_date) %> <%= link_to order.number, edit_admin_order_path(order) %> <%= order.considered_risky ? Spree.t("risky") : Spree.t("safe") %> <%= Spree.t("order_state.#{order.state.downcase}") %> <% if order.payment_state %> <%= link_to Spree.t("payment_states.#{order.payment_state}"), admin_order_payments_path(order) %> <% end %> <% if order.shipment_state %> <%= Spree.t("shipment_states.#{order.shipment_state}") %> <% end %> <% if order.user %> <%= link_to order.email, edit_admin_user_path(order.user) %> <% else %> <%= mail_to order.email %> <% end %> <% if order.user || order.email %> <% end %> <%= order.display_total.to_html %> <%= link_to_edit_url edit_admin_order_path(order), :title => "admin_edit_#{dom_id(order)}", :no_text => true %>
<% else %>
<%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Order)) %>, <%= link_to(Spree.t(:add_one), new_admin_order_url) if can? :create, Spree::Order %>!
<% end %> <%= render :partial => 'spree/admin/shared/index_table_options', :locals => { :collection => @orders, :simple => true } %>