Add initial support for expiration date for mobile receiving
This commit is contained in:
parent
4aa91414a5
commit
a03083efdd
|
@ -149,19 +149,39 @@ $(document).on('click', '#receiving-quantity-keypad-thingy .keypad-button', func
|
|||
$(document).on('click', '.receiving-actions button', function() {
|
||||
var action = $(this).data('action');
|
||||
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();
|
||||
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') {
|
||||
$('#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();
|
||||
});
|
||||
|
|
|
@ -68,6 +68,7 @@ ${h.csrf_token(request)}
|
|||
${h.hidden('row', value=row.uuid)}
|
||||
${h.hidden('cases')}
|
||||
${h.hidden('units')}
|
||||
${h.hidden('expiration_date')}
|
||||
|
||||
<%
|
||||
uom = 'CS'
|
||||
|
@ -104,4 +105,13 @@ ${h.hidden('units')}
|
|||
</tbody>
|
||||
</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()}
|
||||
|
|
|
@ -205,7 +205,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
# if mode in ('damaged', 'expired', 'mispick'):
|
||||
if mode in ('damaged', 'expired'):
|
||||
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'],
|
||||
# mispick_product=shipped_product)
|
||||
)
|
||||
|
@ -313,7 +313,7 @@ class ReceivingForm(forms.Schema):
|
|||
# case_quantity = fe.validators.Number()
|
||||
cases = fe.validators.Number()
|
||||
units = fe.validators.Number()
|
||||
# expiration_date = fe.validators.DateValidator()
|
||||
expiration_date = fe.validators.DateValidator()
|
||||
# trash = fe.validators.Bool()
|
||||
# ordered_product = forms.validators.ValidProduct()
|
||||
|
||||
|
|
Loading…
Reference in a new issue