stock_check report template

This commit is contained in:
Zin Lin Phyo
2017-09-06 18:27:58 +06:30
parent 784e740da3
commit 5e1e0cd5b9
16 changed files with 940 additions and 814 deletions

View File

@@ -20,8 +20,14 @@
<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>
<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>
@@ -50,7 +56,7 @@
<div class="col-md-12">
<table class="table table-striped" id='stock_item'>
<tr>
<th>#</th>
<!--<th>#</th>-->
<th>Product</th>
<th>Balance</th>
<th></th>
@@ -61,6 +67,7 @@
</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>
@@ -80,13 +87,13 @@
count += 1;
product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val();
product_name = $("#product_sku option:selected").text();
product_name = $("#product_sku").find("option:selected").text();
var tr = '<tr>'
+ '<td>' + count + '</td>'
//+ '<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>'
+ product_name + '</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>'
+ '<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('');
@@ -101,7 +108,9 @@
for (var i = 1; i <= count; i++) {
itemname = $('#item_sku_' + i).val();
itemqty = $('#item_qty_' + i).val();
arr.push({sku: itemname, qty: itemqty});
if(itemname !== undefined){
arr.push({sku: itemname, qty: itemqty});
}
jsonStr = JSON.stringify(arr);
}
console.log(jsonStr);
@@ -113,6 +122,14 @@
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>

View File

@@ -3,81 +3,96 @@
<div class="col-md-10">
<div class="row">
<div class="col-md-2">
Check by
Check by
</div>
<div class="col-md-8">
<%= @check.check_by %>
<%= Employee.find(@check.check_by).name rescue '' %>
</div>
</div>
<div class="row">
<div class="col-md-2">
Check At
Check At
</div>
<div class="col-md-8">
<%= @check.created_at %></div>
<%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></div>
</div>
<div class="row">
<div class="col-md-2">
Reason
Reason
</div>
<div class="col-md-8">
<%= @check.reason %>
<%= @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
%>
<table class="table table-striped col-md-12">
<tr>
<td><%= count %></td>
<td><%= item.item_code %></td>
<td><%= item.stock_count %></td>
<td><%= item.stock_balance %></td>
<td><%= item.different %></td>
<td><%= item.remark %></td>
<th>#</th>
<th>Product</th>
<th>Stock Count</th>
<th>Stock Balance</th>
<th>Different</th>
<th>Remark</th>
</tr>
<% end %>
</table>
<%
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>
<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>
<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('success')
}
})
})
$('#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
})
})
$('#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>