<% content_for :page_title do %> <%= Spree.t(:promotions) %> <% end %> <% content_for :page_actions do %> <% if can? :create, Spree::Promotion %>
  • <%= button_link_to Spree.t(:new_promotion), spree.new_admin_promotion_path, :icon => 'plus' %>
  • <% end %> <% end %> <% content_for :table_filter_title do %> <%= Spree.t(:search) %> <% end %> <% content_for :table_filter do %>
    <%= search_form_for [:admin, @search] do |f| %>
    <%= label_tag :q_name_cont, Spree.t(:name) %> <%= f.text_field :name_cont, tabindex: 1 %>
    <%= label_tag :q_codes_value_cont, Spree.t(:code) %> <%= f.text_field :codes_value_cont, tabindex: 1 %>
    <%= label_tag :q_path_cont, Spree.t(:path) %> <%= f.text_field :path_cont, tabindex: 1 %>
    <%= label_tag :q_promotion_category_id_eq, 'promotion category' %>
    <%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { :include_blank => Spree.t('match_choices.all') }, { :class => 'select2 fullwidth' }) %>
    <%= button Spree.t(:filter_results), 'search' %>
    <% end %>
    <% end %> <%= paginate @promotions %> <% if @promotions.any? %> <% @promotions.each do |promotion| %> <% end %>
    <%= Spree.t(:name) %> <%= Spree.t(:code) %> <%= Spree.t(:description) %> <%= Spree.t(:usage_limit) %> <%= Spree.t(:promotion_uses) %> <%= Spree.t(:expiration) %>
    <%= promotion.name %> <%= (promotion.codes.size == 1) ? promotion.codes.first.try!(:value) : Spree.t(:number_of_codes, count: promotion.codes.size) %> <%= promotion.description %> <%= promotion.usage_limit.nil? ? "∞" : promotion.usage_limit %> <%= Spree.t(:current_promotion_usage, :count => promotion.usage_count) %> <%= promotion.expires_at.to_date.to_s(:short_date) if promotion.expires_at %> <% if can?(:edit, promotion) %> <%= link_to_edit promotion, :no_text => true %> <% end %> <% if can?(:destroy, promotion) %> <%= link_to_delete promotion, :no_text => true %> <% end %>
    <% else %>
    <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/promotion')) %> <% if can? :create, Spree::Promotion %> <%= link_to Spree.t(:add_one), spree.new_admin_promotion_path %>! <% end %>
    <% end %>