Add initial support for expiration date for mobile receiving

This commit is contained in:
Lance Edgar 2017-07-03 21:07:57 -05:00
parent 4aa91414a5
commit a03083efdd
3 changed files with 34 additions and 4 deletions

View file

@ -149,19 +149,39 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func
$(document).on('click', '.receiving-actions button', function() { $(document).on('click', '.receiving-actions button', function() {
var action = $(this).data('action'); var action = $(this).data('action');
var form = $('form.receiving-update'); var form = $('form.receiving-update');
var uom = form.find('[name="receiving-uom"]').val(); var uom = form.find('[name="receiving-uom"]:selected').val();
var mode = form.find('[name="mode"]:checked').val();
var qty = form.find('.receiving-quantity').text(); var qty = form.find('.receiving-quantity').text();
if (action == 'add' || action == 'subtract') { if (action == 'add' || action == 'subtract') {
if (qty != '0') { if (qty != '0') {
if (action == 'subtract') { if (action == 'subtract') {
qty = '-' + qty; qty = '-' + qty;
} }
if (uom == 'CS') { if (uom == 'CS') {
form.find('[name="cases"]').val(qty); form.find('[name="cases"]').val(qty);
} else { // units } else { // units
form.find('[name="units"]').val(qty); form.find('[name="units"]').val(qty);
} }
form.submit();
if (action == 'add' && mode == 'expired') {
$('#popup-receiving-expiration').popup('open');
} else {
form.submit();
}
} }
} }
}); });
// TODO: something's wrong.. we can't close the popup or else the form will
// be "posted" via GET. but then we still have to click the button twice??
// handle Submit button from receiving expiration date popup
$(document).on('click', '#popup-receiving-expiration button', function() {
var popup = $('#popup-receiving-expiration');
var date = popup.find('input').val();
var form = $('form.receiving-update');
form.find('[name="expiration_date"]').val(date);
form.submit();
});

View file

@ -68,6 +68,7 @@ ${h.csrf_token(request)}
${h.hidden('row', value=row.uuid)} ${h.hidden('row', value=row.uuid)}
${h.hidden('cases')} ${h.hidden('cases')}
${h.hidden('units')} ${h.hidden('units')}
${h.hidden('expiration_date')}
<% <%
uom = 'CS' uom = 'CS'
@ -104,4 +105,13 @@ ${h.hidden('units')}
</tbody> </tbody>
</table> </table>
<div data-role="popup" id="popup-receiving-expiration" data-dismissible="false" data-overlay-theme="b" class="ui-corner-all">
<div style="padding:10px 20px;">
<h3>Please provide expiration date</h3>
<input name="expiration-date" type="date" value="" placeholder="Expiration Date" />
<a href="#" class="ui-btn ui-btn-inline ui-corner-all" data-rel="back">Cancel</a>
<button type="button" class="ui-btn ui-btn-inline ui-corner-all">Submit</button>
</div>
</div>
${h.end_form()} ${h.end_form()}

View file

@ -205,7 +205,7 @@ class ReceivingBatchView(PurchasingBatchView):
# if mode in ('damaged', 'expired', 'mispick'): # if mode in ('damaged', 'expired', 'mispick'):
if mode in ('damaged', 'expired'): if mode in ('damaged', 'expired'):
self.attach_credit(row, mode, cases, units, self.attach_credit(row, mode, cases, units,
# expiration_date=update_form.data['expiration_date'], expiration_date=update_form.data['expiration_date'],
# discarded=update_form.data['trash'], # discarded=update_form.data['trash'],
# mispick_product=shipped_product) # mispick_product=shipped_product)
) )
@ -313,7 +313,7 @@ class ReceivingForm(forms.Schema):
# case_quantity = fe.validators.Number() # case_quantity = fe.validators.Number()
cases = fe.validators.Number() cases = fe.validators.Number()
units = fe.validators.Number() units = fe.validators.Number()
# expiration_date = fe.validators.DateValidator() expiration_date = fe.validators.DateValidator()
# trash = fe.validators.Bool() # trash = fe.validators.Bool()
# ordered_product = forms.validators.ValidProduct() # ordered_product = forms.validators.ValidProduct()