Minor refactoring for ordering js data.
This commit is contained in:
parent
f3773314a7
commit
45e0048490
2 changed files with 28 additions and 33 deletions
|
@ -18,7 +18,7 @@ class OrderingController < ApplicationController
|
|||
# save results of earlier orders in array
|
||||
ordered_articles = Array.new
|
||||
@group_order = @order.group_orders.find(:first,
|
||||
:conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
:conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
|
||||
if @group_order
|
||||
# Group has already ordered, so get the results...
|
||||
|
@ -56,6 +56,19 @@ class OrderingController < ApplicationController
|
|||
i += 1
|
||||
end
|
||||
end
|
||||
|
||||
@add_data_to_js = []
|
||||
if Foodsoft.config[:tolerance_is_costly]
|
||||
for i in 0...@price.size
|
||||
@add_data_to_js << [@price[i], @unit[i], @price[i] * (@tolerance[i] + @quantity[i]), @others_quantity[i],
|
||||
@others_tolerance[i], @used_quantity[i], 0]
|
||||
end
|
||||
else
|
||||
for j in 0...@price.size
|
||||
@add_data_to_js << [@price[j], @unit[j], @price[j] * @quantity[j], @others_quantity[j],
|
||||
@others_tolerance[j], @used_quantity[j], 0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def stock_order
|
||||
|
@ -64,7 +77,7 @@ class OrderingController < ApplicationController
|
|||
# save results of earlier orders in array
|
||||
ordered_articles = Array.new
|
||||
@group_order = @order.group_orders.find(:first,
|
||||
:conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
:conditions => "ordergroup_id = #{@ordergroup.id}", :include => :group_order_articles)
|
||||
|
||||
if @group_order
|
||||
# Group has already ordered, so get the results...
|
||||
|
@ -147,7 +160,7 @@ class OrderingController < ApplicationController
|
|||
logger.error('Failed to update order: ' + exception.message)
|
||||
flash[:error] = 'Die Bestellung konnte nicht aktualisiert werden, da ein Fehler auftrat.'
|
||||
end
|
||||
redirect_to :action => 'my_order_result', :id => @order
|
||||
redirect_to :action => 'my_order_result', :id => @order
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -163,7 +176,7 @@ class OrderingController < ApplicationController
|
|||
def myOrders
|
||||
# get only orders belonging to the ordergroup
|
||||
@closed_orders = Order.paginate :page => params[:page], :per_page => 10,
|
||||
:conditions => { :state => 'closed' }, :order => "orders.ends DESC"
|
||||
:conditions => { :state => 'closed' }, :order => "orders.ends DESC"
|
||||
|
||||
respond_to do |format|
|
||||
format.html # myOrders.haml
|
||||
|
|
|
@ -1,27 +1,9 @@
|
|||
<script>
|
||||
//<![CDATA[
|
||||
$(function() {
|
||||
<% if Foodsoft.config[:tolerance_is_costly]
|
||||
for i in 0...@price.size %>
|
||||
addData(<%= @price[i] %>,
|
||||
<%= @unit[i] %>,
|
||||
<%= @price[i] * (@tolerance[i] + @quantity[i])%>,
|
||||
<%= @others_quantity[i] %>,
|
||||
<%= @others_tolerance[i] %>,
|
||||
<%= @used_quantity[i] %>,
|
||||
0);
|
||||
<% end
|
||||
else
|
||||
for j in 0...@price.size -%>
|
||||
addData(<%= @price[j] %>,
|
||||
<%= @unit[j] %>,
|
||||
<%= @price[j] * @quantity[j]%>,
|
||||
<%= @others_quantity[j] %>,
|
||||
<%= @others_tolerance[j] %>,
|
||||
<%= @used_quantity[j] %>,
|
||||
0);
|
||||
<% end
|
||||
end%>
|
||||
<% for row in @add_data_to_js %>
|
||||
addData(<%= row.join(", ") %>);
|
||||
<% end %>
|
||||
setGroupBalance(<%= @availableFunds %>);
|
||||
|
||||
// localization
|
||||
|
|
Loading…
Reference in a new issue