<%= t('plugins.ecommerce.orders') %>

<%= search_form_for @q, url: url_for(action: :index), class: 'row' do |f| %>
<%= f.label :user_email_or_slug_or_coupon_cont, t('.search_field', default: 'Email or Number or Coupon') %> <%= f.search_field :user_email_or_slug_or_coupon_cont, class: 'form-control' %>
<%= f.label :created_at_gteq, t('.created_after', default: 'Created After') %>
<%= f.text_field :created_at_gteq, class: 'form-control ' %>
<%= f.label :created_at_lteq, t('.created_before', default: 'Created Before') %>
<%= f.text_field :created_at_lteq, class: 'form-control ' %>
<%= f.label :status_eq, t('.search_status', default: 'Status') %> <%= f.select :status_eq, [[t('plugins.ecommerce.select.shipped', default: 'Shipped'), "shipped"], [t('plugins.ecommerce.select.canceled', default: 'Cancelled'), "canceled"], [t('plugins.ecommerce.select.paid', default: 'Paid'), "paid"], [t('plugins.ecommerce.messages.order_status.bank_pending', default: 'Bank Pending'), "bank_pending"], [t('plugins.ecommerce.by_on_delivery', default: 'Payment no Delivery'), "on_delivery"]], {include_blank: true}, class: 'form-control' %>
<%= f.label :user_id_eq, t('.search_user', default: 'User') %> <%= f.collection_select :user_id_eq, current_site.users.where(id: current_site.orders.pluck(:user_id)).decorate, :id, :the_name, {include_blank: true}, class: 'form-control' %>

<% end %>
<% amount = 0; @orders.each do |order| order = order.decorate; amount += order.amount %> <% end %>
<%= t('plugins.ecommerce.table.id', default: 'Id') %> <%= t('plugins.ecommerce.table.customer', default: 'Customer') %> <%= t('plugins.ecommerce.table.status', default: 'Status') %> <%= t('plugins.ecommerce.table.paid', default: 'Paid?') %> <%= t('plugins.ecommerce.table.products', default: 'Products') %> <%= t('plugins.ecommerce.table.amount', default: 'Amount') %> <%= t('plugins.ecommerce.table.created_at', default: 'Created at') %> <%= t('plugins.ecommerce.table.payment_method', default: 'Payment Method') %> <%= t('camaleon_cms.admin.table.actions', default: 'Actions') %>
<%= order.slug %> <% if order.user %> <%= order.user.fullname %> <% else %> (No user) <% end %> <%= raw order.the_status %> <%= order.paid? ? 'Yes' : 'No' %> <% order.product_items.each do |item| %> <%= item.qty %> x <%= item.cache_the_title %> (<%= item.cache_the_price %>)
<% end %>
<%= order.cache_the_total %> <%= order.the_created_at %> <%= order.payment_method.name rescue "" %> <%= link_to raw(''), {action: :show, id: order.slug}, class: "btn btn-info btn-xs", title: "#{t('camaleon_cms.admin.button.preview')}" %> <%= link_to raw(''), {action: :edit, id: order.slug}, class: "btn btn-default btn-xs", title: "#{t('camaleon_cms.admin.button.edit')}" %> <%= link_to raw(''), {action: :destroy, id: order.slug}, class: "btn btn-danger btn-xs", title: "#{t('camaleon_cms.admin.button.delete', default: 'Delete Order')}", method: :delete, 'data-confirm'=> t('plugins.ecommerce.table.confirm_delete', default: 'Are you sure to delete this order?') %>
<%= content_tag("div", raw(t('camaleon_cms.admin.message.data_found_list')), class: "alert alert-warning") if @orders.empty? %> <%= content_tag("div", "#{t('plugins.ecommerce.front.orders.index.total_amount', default: 'Total Amount')}: #{e_parse_price(amount)}".html_safe, class: "") %> <%= raw cama_do_pagination @orders %>