Overhaul the Receiving Form to account for "product not found" etc.
Also shows ordered/received/etc. quantities
This commit is contained in:
parent
acbb3d289c
commit
ed252c6465
2 changed files with 245 additions and 53 deletions
|
@ -23,16 +23,37 @@
|
|||
function invalid_product(msg) {
|
||||
$('#received-product-info p').text(msg);
|
||||
$('#received-product-info img').hide();
|
||||
$('#received-product-info .rogue-item-warning').hide();
|
||||
$('#product-textbox').focus().select();
|
||||
$('#upc').focus().select();
|
||||
$('.field-wrapper.cases input').prop('disabled', true);
|
||||
$('.field-wrapper.units input').prop('disabled', true);
|
||||
$('.buttons button').button('disable');
|
||||
}
|
||||
|
||||
function pretty_quantity(cases, units) {
|
||||
if (cases && units) {
|
||||
return cases + " cases, " + units + " units";
|
||||
} else if (cases) {
|
||||
return cases + " cases";
|
||||
} else if (units) {
|
||||
return units + " units";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function show_quantity(name, cases, units) {
|
||||
var quantity = pretty_quantity(cases, units);
|
||||
var field = $('.field-wrapper.quantity_' + name);
|
||||
field.find('.field').text(quantity);
|
||||
if (quantity || name == 'ordered') {
|
||||
field.show();
|
||||
} else {
|
||||
field.hide();
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#product-textbox').keydown(function(event) {
|
||||
$('#upc').keydown(function(event) {
|
||||
|
||||
if (key_allowed(event)) {
|
||||
return true;
|
||||
|
@ -41,35 +62,75 @@
|
|||
$('#product').val('');
|
||||
$('#received-product-info p').html("please ENTER a scancode");
|
||||
$('#received-product-info img').hide();
|
||||
$('#received-product-info .rogue-item-warning').hide();
|
||||
$('#received-product-info .warning').hide();
|
||||
$('.product-fields').hide();
|
||||
$('.receiving-fields').hide();
|
||||
$('.field-wrapper.cases input').prop('disabled', true);
|
||||
$('.field-wrapper.units input').prop('disabled', true);
|
||||
$('.buttons button').button('disable');
|
||||
return true;
|
||||
}
|
||||
|
||||
// when user presses ENTER, do product lookup
|
||||
if (event.which == 13) {
|
||||
var input = $(this);
|
||||
var data = {upc: input.val()};
|
||||
var upc = $(this).val();
|
||||
var data = {'upc': upc};
|
||||
$.get('${url('purchases.batch.receiving_lookup', uuid=batch.uuid)}', data, function(data) {
|
||||
|
||||
if (data.error) {
|
||||
alert(data.error);
|
||||
if (data.redirect) {
|
||||
$('#receiving-form').mask("Redirecting...");
|
||||
location.href = data.redirect;
|
||||
}
|
||||
|
||||
} else if (data.product) {
|
||||
input.val(data.product.upc_pretty);
|
||||
$('#upc').val(data.product.upc_pretty);
|
||||
$('#product').val(data.product.uuid);
|
||||
$('#brand_name').val(data.product.brand_name);
|
||||
$('#description').val(data.product.description);
|
||||
$('#size').val(data.product.size);
|
||||
$('#case_quantity').val(data.product.case_quantity);
|
||||
|
||||
$('#received-product-info p').text(data.product.full_description);
|
||||
$('#received-product-info img').attr('src', data.product.image_url).show();
|
||||
$('#received-product-info .rogue-item-warning').hide();
|
||||
if (! data.product.found_in_batch) {
|
||||
$('#received-product-info .rogue-item-warning').show();
|
||||
if (! data.product.uuid) {
|
||||
// $('#received-product-info .warning.notfound').show();
|
||||
$('.product-fields').show();
|
||||
}
|
||||
if (data.product.found_in_batch) {
|
||||
show_quantity('ordered', data.product.cases_ordered, data.product.units_ordered);
|
||||
show_quantity('received', data.product.cases_received, data.product.units_received);
|
||||
show_quantity('damaged', data.product.cases_damaged, data.product.units_damaged);
|
||||
show_quantity('expired', data.product.cases_expired, data.product.units_expired);
|
||||
show_quantity('mispick', data.product.cases_mispick, data.product.units_mispick);
|
||||
$('.receiving-fields').show();
|
||||
} else {
|
||||
$('#received-product-info .warning.notordered').show();
|
||||
}
|
||||
$('.field-wrapper.cases input').prop('disabled', false);
|
||||
$('.field-wrapper.units input').prop('disabled', false);
|
||||
$('.buttons button').button('enable');
|
||||
$('#cases').focus().select();
|
||||
|
||||
} else if (data.upc) {
|
||||
$('#upc').val(data.upc_pretty);
|
||||
$('#received-product-info p').text("product not found in our system");
|
||||
$('#received-product-info img').attr('src', data.image_url).show();
|
||||
|
||||
$('#product').val('');
|
||||
$('#brand_name').val('');
|
||||
$('#description').val('');
|
||||
$('#size').val('');
|
||||
$('#case_quantity').val('');
|
||||
|
||||
$('#received-product-info .warning.notfound').show();
|
||||
$('.product-fields').show();
|
||||
$('#brand_name').focus();
|
||||
$('.field-wrapper.cases input').prop('disabled', false);
|
||||
$('.field-wrapper.units input').prop('disabled', false);
|
||||
$('.buttons button').button('enable');
|
||||
|
||||
} else {
|
||||
invalid_product('product not found');
|
||||
}
|
||||
|
@ -212,7 +273,7 @@
|
|||
$(this).mask("Working...");
|
||||
});
|
||||
|
||||
$('#product-textbox').focus();
|
||||
$('#upc').focus();
|
||||
$('.field-wrapper.cases input').prop('disabled', true);
|
||||
$('.field-wrapper.units input').prop('disabled', true);
|
||||
$('.buttons button').button('disable');
|
||||
|
@ -235,7 +296,7 @@
|
|||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
.product-info .rogue-item-warning {
|
||||
#received-product-info .warning {
|
||||
background: #f66;
|
||||
display: none;
|
||||
}
|
||||
|
@ -270,18 +331,72 @@
|
|||
${h.hidden('ordered_product')}
|
||||
|
||||
<div class="field-wrapper">
|
||||
<label for="product-textbox">Product</label>
|
||||
<label for="upc">Product UPC</label>
|
||||
<div class="field">
|
||||
${h.hidden('product')}
|
||||
<div>${h.text('product-textbox', autocomplete='off')}</div>
|
||||
<div>${h.text('upc', autocomplete='off')}</div>
|
||||
<div id="received-product-info" class="product-info">
|
||||
<p>please ENTER a scancode</p>
|
||||
<div class="img-wrapper"><img /></div>
|
||||
<div class="rogue-item-warning">warning: product not found on current purchase</div>
|
||||
<div class="warning notfound">please confirm UPC and provide more details</div>
|
||||
<div class="warning notordered">warning: product not found on current purchase</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="product-fields" style="display: none;">
|
||||
|
||||
<div class="field-wrapper brand_name">
|
||||
<label for="brand_name">Brand Name</label>
|
||||
<div class="field">${h.text('brand_name')}</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper description">
|
||||
<label for="description">Description</label>
|
||||
<div class="field">${h.text('description')}</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper size">
|
||||
<label for="size">Size</label>
|
||||
<div class="field">${h.text('size')}</div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper case_quantity">
|
||||
<label for="case_quantity">Units in Case</label>
|
||||
<div class="field">${h.text('case_quantity')}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="receiving-fields" style="display: none;">
|
||||
|
||||
<div class="field-wrapper quantity_ordered">
|
||||
<label for="quantity_ordered">Ordered</label>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper quantity_received">
|
||||
<label for="quantity_received">Received</label>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper quantity_damaged">
|
||||
<label for="quantity_damaged">Damaged</label>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper quantity_expired">
|
||||
<label for="quantity_expired">Expired</label>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper quantity_mispick">
|
||||
<label for="quantity_mispick">Mispick</label>
|
||||
<div class="field"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="field-wrapper cases">
|
||||
<label for="cases">Cases</label>
|
||||
<div class="field">${h.text('cases', autocomplete='off')}</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue