diff --git a/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb b/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb index dd96ea3..34fe00d 100644 --- a/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb +++ b/plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb @@ -30,6 +30,14 @@ class ShoppingCartPluginMyprofileController < MyProfileController conditions = [condition] + condition_parameters @orders = profile.orders.find(:all, :conditions => conditions) + + @products = {} + @orders.each do |order| + order.products_list.each do |id, qp| + @products[id] ||= 0 + @products[id] += qp[:quantity] + end + end end def update_order_status diff --git a/plugins/shopping_cart/public/style.css b/plugins/shopping_cart/public/style.css index 4b79273..7d77e88 100644 --- a/plugins/shopping_cart/public/style.css +++ b/plugins/shopping_cart/public/style.css @@ -196,3 +196,19 @@ label.error { .action-shopping_cart_plugin_myprofile-reports .order-products li { padding-left: 5px; } + +#order-filter { + background-color: #ccc; + border: 1px solid #aaa; + border-radius: 5px; + padding: 3px 8px; + margin-bottom: 10px; +} + +th { + text-align: center; +} + +td { + text-align: left; +} diff --git a/plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb new file mode 100644 index 0000000..c2cda44 --- /dev/null +++ b/plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb @@ -0,0 +1,60 @@ +<% if @orders.empty? %> +
<%= _("No results.") %>
+<% else %> +<%= _('Date') %> | +<%= _('Customer') %> | +<%= _('Purchase value') %> | +<%= _('Status')%> | ++ |
---|---|---|---|---|
<%= order.created_at.strftime("%Y-%m-%d")%> | +<%= order.customer_name %> | +<%= float_to_currency_cart(order.products_list.sum {|id, qp| qp[:price]*qp[:quantity]}, environment) %> | ++ <% form_tag :action => 'update_order_status' do %> + <%= hidden_field_tag(:order_id, order.id) + + hidden_field_tag(:context_from, @from) + + hidden_field_tag(:context_to, @to) + + hidden_field_tag(:context_status, @status) + + select_tag( :order_status, options_from_collection_for_select(status_collection, :first, :last, order.status), + :onchange => "if(confirm(#{_('Are you sure about changing this order status?').to_json}))" + + " this.form.submit(); else this.selectedIndex = #{order.status}" ) + %> + <% end %> + | ++ |
<%= _("No results.") %>
+<% else %> +<%= _('Product') %> | +<%= _('Quantity') %> | +
---|---|
<%= Product.find(id).name %> | +<%= quantity %> | +
<%= _("No results.") %>
-<% else %> -<%= _('Date') %> | -<%= _('Customer') %> | -<%= _('Purchase value') %> | -<%= _('Status')%> | -- |
---|---|---|---|---|
<%= order.created_at.strftime("%Y-%m-%d")%> | -<%= order.customer_name %> | -<%= float_to_currency_cart(order.products_list.sum {|id, qp| qp[:price]*qp[:quantity]}, environment) %> | -- <% form_tag :action => 'update_order_status' do %> - <%= hidden_field_tag(:order_id, order.id) + - hidden_field_tag(:context_from, @from) + - hidden_field_tag(:context_to, @to) + - hidden_field_tag(:context_status, @status) + - select_tag( :order_status, options_from_collection_for_select(status_collection, :first, :last, order.status), - :onchange => "if(confirm(#{_('Are you sure about changing this order status?').to_json}))" + - " this.form.submit(); else this.selectedIndex = #{order.status}" ) - %> - <% end %> - | -- |