Add "Receive 1 CS" button for better efficiency in mobile receiving

This commit is contained in:
Lance Edgar 2018-05-21 16:16:12 -05:00
parent db25a5bfd0
commit 210508480e
3 changed files with 44 additions and 34 deletions

View file

@ -185,40 +185,6 @@ $(document).on('change', 'fieldset.receiving-mode input[name="mode"]', function(
}); });
// handle receiving action buttons
$(document).on('click', '.receiving-actions button', function() {
var action = $(this).data('action');
var form = $(this).parents('form:first');
var uom = form.find('[name="keypad-uom"]:checked').val();
var mode = form.find('[name="mode"]:checked').val();
var qty = form.find('.keypad-quantity').text();
if (action == 'add' || action == 'subtract') {
if (qty != '0') {
if (action == 'subtract') {
qty = '-' + qty;
}
if (uom == 'CS') {
form.find('[name="cases"]').val(qty);
} else { // units
form.find('[name="units"]').val(qty);
}
if (action == 'add' && mode == 'expired') {
var expiry = form.find('input[name="expiration_date"]');
if (! /^\d{4}-\d{2}-\d{2}$/.test(expiry.val())) {
alert("Please enter a valid expiration date.");
expiry.focus();
return;
}
}
form.submit();
}
}
});
// handle inventory save button // handle inventory save button
$(document).on('click', '.inventory-actions button.save', function() { $(document).on('click', '.inventory-actions button.save', function() {
var form = $(this).parents('form:first'); var form = $(this).parents('form:first');

View file

@ -32,3 +32,45 @@ $(document).on('click', 'form.receiving-update #delete-receiving-row', function(
form.find('input[name="delete_row"]').val('true'); form.find('input[name="delete_row"]').val('true');
form.submit(); form.submit();
}); });
// handle receiving action buttons
$(document).on('click', 'form.receiving-update .receiving-actions button', function() {
var action = $(this).data('action');
var form = $(this).parents('form:first');
var uom = form.find('[name="keypad-uom"]:checked').val();
var mode = form.find('[name="mode"]:checked').val();
var qty = form.find('.keypad-quantity').text();
if (action == 'add' || action == 'subtract') {
if (qty != '0') {
if (action == 'subtract') {
qty = '-' + qty;
}
if (uom == 'CS') {
form.find('[name="cases"]').val(qty);
} else { // units
form.find('[name="units"]').val(qty);
}
if (action == 'add' && mode == 'expired') {
var expiry = form.find('input[name="expiration_date"]');
if (! /^\d{4}-\d{2}-\d{2}$/.test(expiry.val())) {
alert("Please enter a valid expiration date.");
expiry.focus();
return;
}
}
form.submit();
}
}
});
$(document).on('click', 'form.receiving-update .receive-one-case', function() {
var form = $(this).parents('form:first');
form.find('[name="mode"]').val('received');
form.find('[name="cases"]').val('1');
form.submit();
});

View file

@ -67,6 +67,8 @@
${h.hidden('cases')} ${h.hidden('cases')}
${h.hidden('units')} ${h.hidden('units')}
<button type="button" class="receive-one-case">Receive 1 CS</button>
${keypad(unit_uom, uom)} ${keypad(unit_uom, uom)}
<table> <table>