diff --git a/app/views/ordering/order.rhtml b/app/views/ordering/order.rhtml index e027f8ef..0e48b163 100644 --- a/app/views/ordering/order.rhtml +++ b/app/views/ordering/order.rhtml @@ -11,9 +11,8 @@ Name - Gebinde Preis - Best + Fehlende Einheiten Menge Toleranz Summe @@ -42,14 +41,17 @@ onmouseover="$('article-info_<%= order_article.id %>').show();" onmouseout="$('article-info_<%= order_article.id %>').hide();"> <%= order_article.article.name %> <%=h order_article.article.origin %> - <%= @order.stockit? ? order_article.article.quantity_available : @unit[i] %> * <%=h order_article.article.unit %> <%= number_to_currency(@price[i]) %> - <%= order_article.units_to_order %> + <%= if @order.stockit? + order_article.article.quantity_available + else + missing_units = @unit[i] - (((@quantity[i] + @others_quantity[i]) % @unit[i]) + @tolerance[i] + @others_tolerance[i]) + missing_units < 0 ? 0 : missing_units + end%> " value="<%= @quantity[i] %>" size="2" /> <%= @used_quantity[i] %> + <%= @quantity[i] - @used_quantity[i] %> - (<%= @quantity[i] + @others_quantity[i] %>) <%= button_to_function('+', "increaseQuantity(#{i})") %> <%= button_to_function('-', "decreaseQuantity(#{i})") %> @@ -58,23 +60,32 @@ <% if (@unit[i] > 1) -%> <%= @used_tolerance[i] %> + <%= @tolerance[i] - @used_tolerance[i] %> - (<%= @tolerance[i] + @others_tolerance[i] %>) <%= button_to_function('+', "increaseTolerance(#{i})") %> <%= button_to_function('-', "decreaseTolerance(#{i})") %> <% end -%> - <%= number_to_currency(article_total, :unit => "") %> € + <%= number_to_currency(article_total, :unit => "") %> € + + - - <%- i = i + 1 - end - end -%> + + <%- i = i + 1 + end + end -%> @@ -125,7 +136,7 @@ end%> // configuration setToleranceBehaviour(<%= Foodsoft.config[:tolerance_is_costly] %>); - + // initialize javascript updateBalance(); diff --git a/public/javascripts/ordering.js b/public/javascripts/ordering.js index 5a59bfc9..e72d1abf 100644 --- a/public/javascripts/ordering.js +++ b/public/javascripts/ordering.js @@ -109,6 +109,13 @@ function update(item, quantity, tolerance) { itemTotal[item] = price[item] * (Number(quantity)); } $('price_' + item + '_display').update(asMoney(itemTotal[item])); + + // update missing units + missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item]) + if (missing_units < 0) { + missing_units = 0; + } + $('missing_units_' + item).update(String(missing_units)); // update balance updateBalance(); diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index cd3ae81a..6d951bc3 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -81,6 +81,12 @@ option { span.click-me { cursor: pointer; } +.left { + float: left; } + +.right { + float: right; } + .clear { clear: both; } @@ -413,6 +419,7 @@ table#order { padding-right: 10px; } #order-footer, .article-info { + text-align: left; z-index: 1; position: fixed; bottom: 0; @@ -435,7 +442,7 @@ table#order { .article-info { z-index: 2; - width: 30em; + width: 50em; height: 8em; border: none; left: 30px; } diff --git a/public/stylesheets/print.css b/public/stylesheets/print.css index afa3e82f..0742836c 100644 --- a/public/stylesheets/print.css +++ b/public/stylesheets/print.css @@ -81,6 +81,12 @@ option { span.click-me { cursor: pointer; } +.left { + float: left; } + +.right { + float: right; } + .clear { clear: both; } @@ -413,6 +419,7 @@ table#order { padding-right: 10px; } #order-footer, .article-info { + text-align: left; z-index: 1; position: fixed; bottom: 0; @@ -435,7 +442,7 @@ table#order { .article-info { z-index: 2; - width: 30em; + width: 50em; height: 8em; border: none; left: 30px; } diff --git a/public/stylesheets/sass/main.sass b/public/stylesheets/sass/main.sass index b35c6b60..e085bea2 100644 --- a/public/stylesheets/sass/main.sass +++ b/public/stylesheets/sass/main.sass @@ -90,7 +90,10 @@ option span.click-me cursor: pointer - +.left + float: left +.right + float: right .clear clear: both @@ -454,6 +457,7 @@ table#order td :padding-right 10px #order-footer, .article-info + text-align: left z-index: 1 position: fixed bottom: 0 @@ -475,7 +479,7 @@ table#order background-color: red .article-info z-index: 2 - width: 30em + width: 50em height: 8em border: none left: 30px