Files
sx-fc/app/views/inventory/stock_checks/show.html.erb
2017-10-23 11:38:10 +06:30

99 lines
2.9 KiB
Plaintext
Executable File

<div class="row">
<input type='hidden' id='stock_check_id' value='<%= @check.id %>'/>
<div class="col-md-10">
<div class="row">
<div class="col-md-2">
Check by
</div>
<div class="col-md-8">
<%= Employee.find(@check.check_by).name rescue '' %>
</div>
</div>
<div class="row">
<div class="col-md-2">
Check At
</div>
<div class="col-md-8">
<%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></div>
</div>
<div class="row">
<div class="col-md-2">
Reason
</div>
<div class="col-md-8">
<%= @check.reason %>
</div>
</div>
<br>
<div class="row">
<table class="table table-striped col-md-12">
<tr>
<th>#</th>
<th>Product</th>
<th>Stock Count</th>
<th>Stock Balance</th>
<th>Different</th>
<th>Remark</th>
</tr>
<%
count = 0
@check.stock_check_items.each do |item|
count += 1
%>
<tr>
<td><%= count %></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% end %>
</td>
<td><%= item.stock_count %></td>
<td><%= item.stock_balance %></td>
<td><%= item.different %></td>
<td><%= item.remark %></td>
</tr>
<% end %>
</table>
</div>
</div>
<div class="col-md-2">
<button id="back" type="button" class="btn btn-block btn-primary"> Back</button>
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> Save to Journal</button>
<button id="print" type="button" class="btn btn-block btn-primary"> Print</button>
</div>
</div>
<script>
$('#save_to_journal').on('click', function () {
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_save_to_journal_path %>',
data: 'data=' + check_id,
success: function () {
alert('Successfully saved to journal.');
window.location.href = '/inventory';
}
})
});
$('#print').on('click', function () {
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_print_stock_check_path %>',
data: 'stock_check_id=' + check_id
})
});
$('#back').on('click', function () {
window.location.href = '/inventory';
});
</script>