136 lines
4.2 KiB
Plaintext
136 lines
4.2 KiB
Plaintext
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
|
|
</div>
|
|
</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=''/>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<div class="row">
|
|
<div class="col-md-2"></div>
|
|
<div class="col-md-2">
|
|
Item
|
|
</div>
|
|
<div class="col-md-7">
|
|
<select class='form-control' id='product_sku'>
|
|
<option value="">Select Product</option>
|
|
<% @inventory_definitions.each do |id| %>
|
|
<option value="<%= id.item_code %>">
|
|
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
|
|
<% if menu_item.nil? %>
|
|
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
|
|
<% else %>
|
|
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
|
|
<% end %>
|
|
</option>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<div class="row">
|
|
<div class="col-md-2"></div>
|
|
<div class="col-md-2">
|
|
Qty
|
|
</div>
|
|
<div class="col-md-7">
|
|
<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>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-5">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<table class="table table-striped" id='stock_item'>
|
|
<tr>
|
|
<!--<th>#</th>-->
|
|
<th>Product</th>
|
|
<th>Balance</th>
|
|
<th></th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-1">
|
|
<div class="row">
|
|
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='back'> Back</button>
|
|
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
$('#product_sku').select2({
|
|
allowClear: true,
|
|
placeholder: 'Select Product'
|
|
})
|
|
});
|
|
|
|
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").find("option:selected").text();
|
|
var tr = '<tr>'
|
|
//+ '<td>' + count + '</td>'
|
|
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
|
|
+ product_name + '</td>'
|
|
+ '<td><input type=text value="' + product_qty + '" id="item_qty_' + count + '" name=' + count + '/></td>'
|
|
+ '<td><input type=button value="X" id="item_remove_' + count + '" name=' + count + ' onclick="remove_row('+ 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 = '';
|
|
|
|
for (var i = 1; i <= count; i++) {
|
|
itemname = $('#item_sku_' + i).val();
|
|
itemqty = $('#item_qty_' + i).val();
|
|
if(itemname !== undefined){
|
|
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'];
|
|
}
|
|
})
|
|
});
|
|
|
|
$('#back').on('click', function () {
|
|
window.location.href = '/inventory';
|
|
});
|
|
|
|
function remove_row(row) {
|
|
$("#item_remove_"+row).parent().parent().remove();
|
|
}
|
|
|
|
</script>
|