check qty update in edit
This commit is contained in:
@@ -59,7 +59,8 @@
|
|||||||
</td>
|
</td>
|
||||||
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
|
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
|
||||||
<td class="p-1" width="5%">
|
<td class="p-1" width="5%">
|
||||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
|
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
|
||||||
|
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="p-1" width="10%">
|
<td class="p-1" width="10%">
|
||||||
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
|
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
|
||||||
@@ -166,21 +167,27 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
var sale_item_id = $(this).attr('data-id');
|
var sale_item_id = $(this).attr('data-id');
|
||||||
var qty = $('#' + sale_item_id + "_qty").val();
|
var qty = $('#' + sale_item_id + "_qty").val();
|
||||||
var price = $('#' + sale_item_id + "_price").val();
|
var price = $('#' + sale_item_id + "_price").val();
|
||||||
console.log(qty + "|" + price)
|
console.log(qty + "|" + price);
|
||||||
var ajax_url = "/origami/item_edit";
|
if(qty > 0){
|
||||||
$.ajax({
|
$('#' + sale_item_id + "_qtyErr").html("");
|
||||||
type: "POST",
|
var ajax_url = "/origami/item_edit";
|
||||||
url: ajax_url,
|
$.ajax({
|
||||||
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
|
type: "POST",
|
||||||
success: function (result) {
|
url: ajax_url,
|
||||||
swal({
|
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
|
||||||
title: "Information!",
|
success: function (result) {
|
||||||
text: "Qty and Price was successfully Updated",
|
swal({
|
||||||
}, function () {
|
title: "Information!",
|
||||||
location.reload();
|
text: "Qty and Price was successfully Updated",
|
||||||
});
|
}, function () {
|
||||||
}
|
location.reload();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.void').on('click', function () {
|
$('.void').on('click', function () {
|
||||||
@@ -311,4 +318,20 @@ var cashier_type = "<%= @cashier_type %>";
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//check for isNumber
|
||||||
|
function isNumberKey(evt) {
|
||||||
|
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||||
|
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkQuantity(obj_value,sale_item_id) {
|
||||||
|
if(obj_value == '0'){
|
||||||
|
$("#"+sale_item_id+"_qty").val('1');
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user