Minor refactoring for ordering js data.
This commit is contained in:
parent
f3773314a7
commit
45e0048490
2 changed files with 28 additions and 33 deletions
|
@ -56,6 +56,19 @@ class OrderingController < ApplicationController
|
||||||
i += 1
|
i += 1
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def stock_order
|
def stock_order
|
||||||
|
|
|
@ -1,27 +1,9 @@
|
||||||
<script>
|
<script>
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
$(function() {
|
$(function() {
|
||||||
<% if Foodsoft.config[:tolerance_is_costly]
|
<% for row in @add_data_to_js %>
|
||||||
for i in 0...@price.size %>
|
addData(<%= row.join(", ") %>);
|
||||||
addData(<%= @price[i] %>,
|
<% end %>
|
||||||
<%= @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%>
|
|
||||||
setGroupBalance(<%= @availableFunds %>);
|
setGroupBalance(<%= @availableFunds %>);
|
||||||
|
|
||||||
// localization
|
// localization
|
||||||
|
|
Loading…
Reference in a new issue