Commit 269bdeca8dfbdf20307a63a2f4e7472c4f088b00
1 parent
2c7248fa
Exists in
staging
and in
42 other branches
[purchase-order] Adding products list on the report
Showing
5 changed files
with
109 additions
and
61 deletions
Show diff stats
plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb
... | ... | @@ -30,6 +30,14 @@ class ShoppingCartPluginMyprofileController < MyProfileController |
30 | 30 | |
31 | 31 | conditions = [condition] + condition_parameters |
32 | 32 | @orders = profile.orders.find(:all, :conditions => conditions) |
33 | + | |
34 | + @products = {} | |
35 | + @orders.each do |order| | |
36 | + order.products_list.each do |id, qp| | |
37 | + @products[id] ||= 0 | |
38 | + @products[id] += qp[:quantity] | |
39 | + end | |
40 | + end | |
33 | 41 | end |
34 | 42 | |
35 | 43 | def update_order_status | ... | ... |
plugins/shopping_cart/public/style.css
... | ... | @@ -196,3 +196,19 @@ label.error { |
196 | 196 | .action-shopping_cart_plugin_myprofile-reports .order-products li { |
197 | 197 | padding-left: 5px; |
198 | 198 | } |
199 | + | |
200 | +#order-filter { | |
201 | + background-color: #ccc; | |
202 | + border: 1px solid #aaa; | |
203 | + border-radius: 5px; | |
204 | + padding: 3px 8px; | |
205 | + margin-bottom: 10px; | |
206 | +} | |
207 | + | |
208 | +th { | |
209 | + text-align: center; | |
210 | +} | |
211 | + | |
212 | +td { | |
213 | + text-align: left; | |
214 | +} | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_orders_list.html.erb
0 → 100644
... | ... | @@ -0,0 +1,60 @@ |
1 | +<% if @orders.empty? %> | |
2 | + <p><i><%= _("No results.") %></i></p> | |
3 | +<% else %> | |
4 | + <table> | |
5 | + <tr> | |
6 | + <th><%= _('Date') %></th> | |
7 | + <th><%= _('Customer') %></th> | |
8 | + <th><%= _('Purchase value') %></th> | |
9 | + <th><%= _('Status')%></th> | |
10 | + <th> </th> | |
11 | + </tr> | |
12 | + <% status_collection.delete_at(0) %> | |
13 | + <% @orders.each do |order|%> | |
14 | + <tr> | |
15 | + <td><%= order.created_at.strftime("%Y-%m-%d")%></td> | |
16 | + <td><%= order.customer_name %></td> | |
17 | + <td style="text-align: right"><%= float_to_currency_cart(order.products_list.sum {|id, qp| qp[:price]*qp[:quantity]}, environment) %></td> | |
18 | + <td> | |
19 | + <% form_tag :action => 'update_order_status' do %> | |
20 | + <%= hidden_field_tag(:order_id, order.id) + | |
21 | + hidden_field_tag(:context_from, @from) + | |
22 | + hidden_field_tag(:context_to, @to) + | |
23 | + hidden_field_tag(:context_status, @status) + | |
24 | + select_tag( :order_status, options_from_collection_for_select(status_collection, :first, :last, order.status), | |
25 | + :onchange => "if(confirm(#{_('Are you sure about changing this order status?').to_json}))" + | |
26 | + " this.form.submit(); else this.selectedIndex = #{order.status}" ) | |
27 | + %> | |
28 | + <% end %> | |
29 | + </td> | |
30 | + <td><button class="view-order-details" data-order="<%=order.id%>"><%=_('View details')%></button></td> | |
31 | + </tr> | |
32 | + <tr id="order-details-<%=order.id%>" style="display:none"> | |
33 | + <td class="order-info" colspan="5"> | |
34 | + <div style="display:none"> | |
35 | + <ul class="customer-details"> | |
36 | + <% { 'name' =>_('Name'), 'email' => _('E-mail'), 'contact_phone' => _('Contact phone'), 'address' => _('Address'), 'city' => _('City'), 'zip_code' => _('Zip code')}.each do |attribute, name| %> | |
37 | + <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if order.send('customer_'+attribute) %> | |
38 | + <% end %> | |
39 | + </ul> | |
40 | + <ul class="order-products"> | |
41 | + <% order.products_list.each do |id, qp| %> | |
42 | + <% | |
43 | + begin | |
44 | + product = Product.find(id) | |
45 | + rescue | |
46 | + product = nil | |
47 | + end | |
48 | + %> | |
49 | + <li><%= product ? link_to(product.name, product.url) : _("Pruduct unavailable")%> | |
50 | + × <%= qp[:quantity] %> = <%= float_to_currency_cart( qp[:quantity] * qp[:price], environment ) %></li> | |
51 | + <% end %> | |
52 | + </ul> | |
53 | + <br style="clear:both"/> | |
54 | + </div> | |
55 | + </td> | |
56 | + </tr> | |
57 | + <% end %> | |
58 | + </table> | |
59 | +<% end %> | |
60 | + | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/_products_list.html.erb
0 → 100644
... | ... | @@ -0,0 +1,17 @@ |
1 | +<% if @products.empty? %> | |
2 | + <p><i><%= _("No results.") %></i></p> | |
3 | +<% else %> | |
4 | + <table> | |
5 | + <tr> | |
6 | + <th><%= _('Product') %></th> | |
7 | + <th><%= _('Quantity') %></th> | |
8 | + </tr> | |
9 | + <% @products.each do |id, quantity|%> | |
10 | + <tr> | |
11 | + <td><%= Product.find(id).name %></td> | |
12 | + <td style="text-align: center"><%= quantity %></td> | |
13 | + </tr> | |
14 | + <% end %> | |
15 | + </table> | |
16 | +<% end %> | |
17 | + | ... | ... |
plugins/shopping_cart/views/shopping_cart_plugin_myprofile/reports.html.erb
1 | 1 | <h1> <%= _('Purchase Reports') %> </h1> |
2 | 2 | |
3 | +<% extend ProfileHelper %> | |
4 | + | |
3 | 5 | <% status = ShoppingCartPlugin::PurchaseOrder::Status.name; pos=-1 %> |
4 | 6 | <% status_collection = [[nil, _('All')]] %> |
5 | 7 | <% status_collection += status.map{|s| [pos+=1, s] } %> |
6 | 8 | |
7 | -<% form_tag do %> | |
9 | +<% form_tag({}, {:id => 'order-filter'}) do %> | |
8 | 10 | <%= labelled_text_field(_('From')+' ', :from, @from.strftime("%Y-%m-%d"), :id => 'from', :size => 9) %> |
9 | 11 | <%= labelled_text_field(_('to')+' ', :to, @to.strftime("%Y-%m-%d"), :id => 'to', :size => 9) %> |
10 | - <%= labelled_select(_('Status')+' ', :filter_status, :first, :last, @status, status_collection)%> | |
12 | + <span style="white-space:nowrap"><%= labelled_select(_('Status')+' ', :filter_status, :first, :last, @status, status_collection)%></span> | |
11 | 13 | |
12 | 14 | <%= submit_button('save', _('Filter')) %> |
13 | 15 | <% end %> |
14 | 16 | |
15 | -<% if @orders.empty? %> | |
16 | - <p><i><%= _("No results.") %></i></p> | |
17 | -<% else %> | |
18 | - <table> | |
19 | - <tr> | |
20 | - <th><%= _('Date') %></th> | |
21 | - <th><%= _('Customer') %></th> | |
22 | - <th><%= _('Purchase value') %></th> | |
23 | - <th><%= _('Status')%></th> | |
24 | - <th> </th> | |
25 | - </tr> | |
26 | - <% status_collection.delete_at(0) %> | |
27 | - <% @orders.each do |order|%> | |
28 | - <tr> | |
29 | - <td><%= order.created_at.strftime("%Y-%m-%d")%></td> | |
30 | - <td><%= order.customer_name %></td> | |
31 | - <td><%= float_to_currency_cart(order.products_list.sum {|id, qp| qp[:price]*qp[:quantity]}, environment) %></td> | |
32 | - <td> | |
33 | - <% form_tag :action => 'update_order_status' do %> | |
34 | - <%= hidden_field_tag(:order_id, order.id) + | |
35 | - hidden_field_tag(:context_from, @from) + | |
36 | - hidden_field_tag(:context_to, @to) + | |
37 | - hidden_field_tag(:context_status, @status) + | |
38 | - select_tag( :order_status, options_from_collection_for_select(status_collection, :first, :last, order.status), | |
39 | - :onchange => "if(confirm(#{_('Are you sure about changing this order status?').to_json}))" + | |
40 | - " this.form.submit(); else this.selectedIndex = #{order.status}" ) | |
41 | - %> | |
42 | - <% end %> | |
43 | - </td> | |
44 | - <td><button class="view-order-details" data-order="<%=order.id%>"><%=_('View details')%></button></td> | |
45 | - </tr> | |
46 | - <tr id="order-details-<%=order.id%>" style="display:none"> | |
47 | - <td class="order-info" colspan="5"> | |
48 | - <div style="display:none"> | |
49 | - <ul class="customer-details"> | |
50 | - <% { 'name' =>_('Name'), 'email' => _('E-mail'), 'contact_phone' => _('Contact phone'), 'address' => _('Address'), 'city' => _('City'), 'zip_code' => _('Zip code')}.each do |attribute, name| %> | |
51 | - <%= content_tag('li', content_tag('strong', name+': ') + order.send('customer_'+attribute)) if order.send('customer_'+attribute) %> | |
52 | - <% end %> | |
53 | - </ul> | |
54 | - <ul class="order-products"> | |
55 | - <% order.products_list.each do |id, qp| %> | |
56 | - <% | |
57 | - begin | |
58 | - product = Product.find(id) | |
59 | - rescue | |
60 | - product = nil | |
61 | - end | |
62 | - %> | |
63 | - <li><%= product ? link_to(product.name, product.url) : _("Pruduct unavailable")%> | |
64 | - × <%= qp[:quantity] %> = <%= float_to_currency_cart( qp[:quantity] * qp[:price], environment ) %></li> | |
65 | - <% end %> | |
66 | - </ul> | |
67 | - <br style="clear:both"/> | |
68 | - </div> | |
69 | - </td> | |
70 | - </tr> | |
71 | - <% end %> | |
72 | - </table> | |
73 | -<% end %> | |
17 | +<% tabs = [] %> | |
18 | +<% tabs << {:title => _('Products list'), :id => 'products_list', :content => (render :partial => 'products_list')} %> | |
19 | +<% tabs << {:title => _('Orders list'), :id => 'orders_list', :content => (render :partial => 'orders_list', :locals => {:status_collection => status_collection})} %> | |
20 | +<%= render_tabs(tabs) %> | |
74 | 21 | |
75 | 22 | <script> |
76 | 23 | var dates = jQuery( "#from, #to" ).datepicker({ | ... | ... |