inventory list and stock check
This commit is contained in:
@@ -7,17 +7,23 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''></input>
|
||||
</div>
|
||||
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-2"></div>
|
||||
<div class="col-md-2">
|
||||
Product
|
||||
Item
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<input type='text' class='form-control' placeholder="Product Name" id='product_sku' value=''></input>
|
||||
<select class='form-control' id='product_sku'>
|
||||
<option value="">Select Product</option>
|
||||
<% @inventory_definitions.each do |id| %>
|
||||
<% item_name = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
|
||||
<option value="<%= id.item_code %>"><%= item_name.item_instance_name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@@ -27,14 +33,14 @@
|
||||
Qty
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''></input>
|
||||
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''/>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4"></div>
|
||||
<div class="col-md-7">
|
||||
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save </button>
|
||||
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,6 +53,7 @@
|
||||
<th>#</th>
|
||||
<th>Product</th>
|
||||
<th>Balance</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -54,49 +61,58 @@
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="row">
|
||||
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish </button>
|
||||
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var count = 0
|
||||
$(document).ready(function () {
|
||||
$('#product_sku').select2({
|
||||
allowClear: true,
|
||||
placeholder: 'Select Product'
|
||||
})
|
||||
});
|
||||
|
||||
$('#save_to_stock_check').on('click', function(){
|
||||
count += 1;
|
||||
product_sku = $('#product_sku').val();
|
||||
product_qty = $('#product_qty').val();
|
||||
var tr = '<tr>'
|
||||
+ '<td>'+ count +'</td>'
|
||||
+ '<td><input type=text value="'+ product_sku +'" id="item_sku_'+ count +'" name='+count+'></input></td>'
|
||||
+ '<td><input type=text value="'+ product_qty +'" id="item_qty_'+ count +'" name='+count+'></input></td>'
|
||||
+ '</tr>'
|
||||
$('#stock_item').append(tr)
|
||||
$('#product_sku').val('');
|
||||
var count = 0;
|
||||
|
||||
$('#save_to_stock_check').on('click', function () {
|
||||
count += 1;
|
||||
product_sku = $('#product_sku').val();
|
||||
product_qty = $('#product_qty').val();
|
||||
product_name = $("#product_sku option:selected").text();
|
||||
var tr = '<tr>'
|
||||
+ '<td>' + count + '</td>'
|
||||
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
|
||||
+ '<input type=text value="' + product_name + '" id="item_name_' + count + '" name=' + count + ' disabled/></td>'
|
||||
+ '<td><input type=text value="' + product_qty + '" id="item_qty_' + count + '" name=' + count + '/></td>'
|
||||
+ '<td><input type=button value="Remove" id="item_qty_' + count + '" name=' + count + '/></td>'
|
||||
+ '</tr>';
|
||||
$('#stock_item').append(tr);
|
||||
// $('#product_sku').val('');
|
||||
$('#product_qty').val('');
|
||||
})
|
||||
});
|
||||
|
||||
$('#finish').on('click',function(){
|
||||
var reason = $('#stock_check_reason').val();
|
||||
var arr = [];
|
||||
var jsonStr = ''
|
||||
$('#finish').on('click', function () {
|
||||
var reason = $('#stock_check_reason').val();
|
||||
var arr = [];
|
||||
var jsonStr = '';
|
||||
|
||||
for(var i = 1; i <= count; i++){
|
||||
itemname = $('#item_sku_'+i ).val();
|
||||
itemqty = $('#item_qty_'+i ).val();
|
||||
arr.push({sku:itemname, qty:itemqty})
|
||||
jsonStr = JSON.stringify(arr)
|
||||
}
|
||||
console.log(jsonStr)
|
||||
$.ajax({
|
||||
type: 'Post',
|
||||
url: '<%= inventory_stock_check_save_path %>',
|
||||
data:'stock_item='+ jsonStr + '&reason='+ reason,
|
||||
success:function(data){
|
||||
alert(data['stock_id'])
|
||||
window.location.href = '/inventory/stock_checks/'+ data['stock_id'];
|
||||
}
|
||||
for (var i = 1; i <= count; i++) {
|
||||
itemname = $('#item_sku_' + i).val();
|
||||
itemqty = $('#item_qty_' + i).val();
|
||||
arr.push({sku: itemname, qty: itemqty});
|
||||
jsonStr = JSON.stringify(arr);
|
||||
}
|
||||
console.log(jsonStr);
|
||||
$.ajax({
|
||||
type: 'Post',
|
||||
url: '<%= inventory_stock_check_save_path %>',
|
||||
data: 'stock_item=' + jsonStr + '&reason=' + reason,
|
||||
success: function (data) {
|
||||
window.location.href = '/inventory/stock_checks/' + data['stock_id'];
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user