142 lines
5.8 KiB
Plaintext
Executable File
142 lines
5.8 KiB
Plaintext
Executable File
<div class="page-header">
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
|
|
<li class="breadcrumb-item active">Stock Check</li>
|
|
<span class="float-right">
|
|
<%= link_to t('.back', :default => t("views.btn.back")), dashboard_path %>
|
|
</span>
|
|
</ol>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
|
|
<!-- <div class="m-b-10 clearfix">
|
|
<%= link_to t("views.btn.new"),new_settings_account_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
|
|
</div -->
|
|
<div class="card">
|
|
<div class="p-l-15 p-r-15 p-t-10">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
|
|
<!-- <label for="remark">Remark</label> -->
|
|
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
|
|
<!-- <label for="password_2">Item</label> -->
|
|
<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>
|
|
<div class="form-group">
|
|
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
|
|
<!-- <label for="email_address_2">Qty</label> -->
|
|
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<div class="col-md-4">
|
|
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<table class="table table-striped" id='stock_item'>
|
|
<tr>
|
|
<!--<th>#</th>-->
|
|
<th>Product</th>
|
|
<th>Balance</th>
|
|
<th><button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button></th>
|
|
</tr>
|
|
<!-- <tr>
|
|
<td colspan="3">
|
|
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button></td>
|
|
</tr> -->
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
|
|
<div class="card">
|
|
<div class="body">
|
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
|
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
|
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
|
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
|
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
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 + '" class="form-control col-md-9" id="item_qty_' + count + '" name=' + count + '/></td>'
|
|
+ '<td><input type=button value="X" class="btn btn-danger p-l-15 p-r-15" 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'];
|
|
}
|
|
})
|
|
});
|
|
|
|
function remove_row(row) {
|
|
$("#item_remove_"+row).parent().parent().remove();
|
|
}
|
|
|
|
</script>
|