Minor refactoring for ordering js data.

This commit is contained in:
benni 2011-06-13 16:45:16 +02:00
parent f3773314a7
commit 45e0048490
2 changed files with 28 additions and 33 deletions

View file

@ -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

View file

@ -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