validate quantity when printing labels
This commit is contained in:
parent
6212932f74
commit
9a8c647b25
|
@ -40,16 +40,25 @@
|
|||
$(function() {
|
||||
$('div.grid.Product a.print-label').live('click', function() {
|
||||
var quantity = $('#label-quantity').val();
|
||||
// TODO: Validate quantity as integer etc.
|
||||
$.ajax({
|
||||
url: '${url('products.print_label')}',
|
||||
data: {
|
||||
'uuid': get_uuid(this),
|
||||
'profile': $('#label-profile').val(),
|
||||
'quantity': quantity,
|
||||
},
|
||||
});
|
||||
alert("Label has been printed.");
|
||||
if (isNaN(quantity)) {
|
||||
alert("You must provide a valid label quantity.");
|
||||
$('#label-quantity').select();
|
||||
$('#label-quantity').focus();
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '${url('products.print_label')}',
|
||||
data: {
|
||||
'uuid': get_uuid(this),
|
||||
'profile': $('#label-profile').val(),
|
||||
'quantity': quantity,
|
||||
},
|
||||
});
|
||||
if (quantity == '1') {
|
||||
alert("1 label has been printed.");
|
||||
} else {
|
||||
alert(quantity + " labels have been printed.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue