Add color marking to items in group orders that have missing items

This commit is contained in:
Alexander Kirk 2015-05-03 20:05:39 +02:00
parent f049da7573
commit 75967bad22
5 changed files with 40 additions and 4 deletions

View file

@ -118,11 +118,25 @@ function update(item, quantity, tolerance) {
$('#price_' + item + '_display').html(I18n.l("currency", itemTotal[item]));
// update missing units
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item])
if (missing_units < 0 || missing_units == unit[item]) {
var missing_units = unit[item] - (((quantityOthers[item] + Number(quantity)) % unit[item]) + Number(tolerance) + toleranceOthers[item]),
missing_units_css = '';
if (missing_units < 0) {
missing_units = 0;
missing_units_css = '';
} else if (missing_units == unit[item]) {
missing_units = 0;
missing_units_css = 'missing-none';
} else if (missing_units == 1) {
missing_units_css = 'missing-few';
} else {
missing_units_css = 'missing-many';
}
$('#missing_units_' + item).html(String(missing_units));
$('#missing_units_' + item)
.html(String(missing_units))
.closest('tr')
.removeClass('missing-many missing-few missing-none')
.addClass(missing_units_css);
// update balance
updateBalance();

View file

@ -4,5 +4,6 @@
*= require token-input-bootstrappy
*= require bootstrap-datepicker
*= require list.unlist
*= require list.missing
*= require recurring_select
*/

View file

@ -0,0 +1,11 @@
.list .missing-many td, .list .missing-many:hover td {
background-color: #ebbebe;
}
.list .missing-few td, .list .missing-few:hover td {
background-color: #ffee75;
}
.list .missing-none td, .list .missing-none:hover td {
background-color: #cff5be;
}

View file

@ -43,4 +43,14 @@ module GroupOrdersHelper
{group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total}
end
def get_missing_units_css_class(quantity_missing)
if ( quantity_missing == 1 )
return 'missing-few';
elsif ( quantity_missing == 0 )
return ''
else
return 'missing-many'
end
end
end

View file

@ -88,7 +88,7 @@
%i.icon-tag
%td{colspan: "9"}
- order_articles.each do |order_article|
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article", valign: "top"}
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article #{get_missing_units_css_class(@ordering_data[:order_articles][order_article.id][:missing_units])}", valign: "top"}
%td.name= order_article.article.name
- if @order.stockit?
%td= truncate order_article.article.supplier.name, length: 15