inventory list and stock check

This commit is contained in:
Zin Lin Phyo
2017-09-05 16:47:50 +06:30
parent 6c94ba5457
commit 31021813b0
10 changed files with 1038 additions and 503 deletions

997
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,272 @@
// Place all the styles related to the inventory_definitions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
@import "select2";
@import "jquery.datetimepicker";
/* Show it is fixed to the top */
// body {
// min-height: 75rem;
// padding-top: 4.5rem;
// }
.card-columns {
font-size: 18px !important;
}
.others-payment{
line-height:100px;
text-align:center;
color:white;
width:300px;
height:100px;
font-size:18px;
}
.orders-table {
cursor: pointer;
}
.cashier_number{
width: 33%;
height:70px;
line-height:70px;
text-align:center;
background:#54A5AF;
// float:left;
// margin:2px;
font-size:20px;
color:white;
// cursor:pointer;
}
.del_cashier_number{
opacity:0.6,
}
.pay{
width: 98%;
height:211px;
line-height:211px;
text-align:center;
font-size:20px;
color:white;
}
.payment{
height:70px;line-height:70px;
align:center;
color:white;
font-size:16px;
margin-top:5px;
}
.cash-color{
background-color:#80CBC4;
}
.credit-color{
background-color:#FFCCBC;
}
.other-payment-color{
background-color:#E1BEE7;
}
.cashier_number:hover{
background:#A9F5F2;
}
.action-btn {
white-space: normal !important;
height: 60px;
margin-bottom: 5px;
}
.bottom-5 {
margin-bottom: 5px;
}
.fluid {
width: 100%;
}
.style2 {
border-top: 3px double #8c8b8b;
}
.long{
width:49%;
}
.sold {
background-color: red;
}
.paid {
background-color: green;
}
.selected-item {
color: #fff !important;
background-color: blue !important;
}
.selected-account {
color: #fff !important;
background-color: blue !important;
}
/* Reciept Style */
#order-charges-table td {
border-top: none !important;
}
.charges-name {
width: 80%;
text-align: left;
}
.item-name {
width: 60%;
text-align: left;
}
.item-attr {
width: 20%;
text-align: right;
}
.item-attr-edit{
width: 10%;
text-align: left;
}
.display-none{
display: none;
}
.text-white{
color: #fff;
}
/* Colors */
.purple {
background-color:#7a62d3;
}
.orange{
background-color:#FF7F50;
}
.red {
background-color:#ff0000;
}
.green{
background-color: #009900;
}
.orange{
background-color: #FF8C00;
}
.blue{
background-color: blue;
}
/* End Colors */
.left{
margin-left:1px;
}
.bottom{
margin-bottom: 1px;
}
/*----- Reset -----*/
select.form-control {
height: inherit !important;
}
.form-horizontal .form-group {
margin-right: 0px !important;
}
/* Discount */
.discount-item-row {
cursor: pointer;
}
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
}
.required abbr{
color: red !important;
}
/* Jquery Confirm */
.jconfirm-box-container{
margin-left:-40px !important;
margin-top:-40px !important;
}
#sxModal {
display: none;
overflow: auto;
width: 100%;
height: 100%;
background-color: #000;
background-color: rgba(0,0,0,0.4);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1100;
}
#sxModal-Content {
position: relative;
left: 42%;
top: 30%;
background-color: #d9534f;
color: #fff;
text-align: center;
width: 200px;
height: 200px;
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
}
/*Loading gif for payment*/
#loading_wrapper{
position: fixed;
background-color: #C8C8C8 ;
height: 100%;
width: 100%;
left: 0;
opacity: 0.6;
top: 0;
z-index: 9999999;
}
#loading{
position: relative;
height: 100%;
width: 100%;
background-image: url('../../../image/loading-ajax.gif');
background-position: center center;
background-repeat: no-repeat;
opacity: 1;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
}

View File

@@ -25,7 +25,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions.json
def create
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
@inventory_definition.created_by = current_user.id
respond_to do |format|
if @inventory_definition.save
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }

View File

@@ -2,6 +2,7 @@ class Inventory::StockChecksController < BaseInventoryController
def index
@check = StockCheck.new
@inventory_definitions = InventoryDefinition.active.all
end
def create

View File

@@ -25,7 +25,7 @@
<td><%= item.item_code rescue ""%></td>
<td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td>
<td><%= item.created_by%></td>
<td><%= item.created_by %></td>
<td><%= item.created_at%></td>
</tr>
<% end %>

View File

@@ -1,56 +1,83 @@
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
<%= f.error_notification %>
<%= simple_form_for([:inventory,@inventory_definition]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :item_code %>
<div class="row">
<% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %>
<% Product.order("name desc").pluck(:name,:item_code).each do |p| %>
<% arr.push(p) %>
<% end %>
<div class="col-md-3">
<label class="control-label"><abbr title="required">*</abbr> Item</label>
<select class="form-control item_code_place">
<% if !@inventory_definition.item_code.nil? %>
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
<% if menuiteminstance.nil?%>
<% code = @inventory_definition.item_code %>
<% else %>
<% code = menuiteminstance.menu_item.item_code %>
<% end %>
<% end %>
<% arr.each do |a| %>
<% if a[1] == code %>
<option value="<%= a[1]%>" selected><%= a[0] %></option>
<% else %>
<option value="<%= a[1]%>"><%= a[0] %></option>
<% end %>
<% end %>
</select>
<div class="form-inputs">
<div class="row">
<% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %>
<% Product.order("name desc").pluck(:name, :item_code).each do |p| %>
<% arr.push(p) %>
<% end %>
<div class="col-md-3">
<label class="control-label"><abbr title="required">*</abbr> Item</label>
<select class="form-control item_code_place" id="item">
<% if !@inventory_definition.item_code.nil? %>
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
<% if menuiteminstance.nil? %>
<% code = @inventory_definition.item_code %>
<% else %>
<% code = menuiteminstance.menu_item.item_code %>
<% end %>
<% end %>
<option value=""></option>
<% arr.each do |a| %>
<% if a[1] == code %>
<option value="<%= a[1] %>" selected><%= a[0] %></option>
<% else %>
<option value="<%= a[1] %>"><%= a[0] %></option>
<% end %>
<% end %>
</select>
</div>
<% sample = [] %>
<% if @inventory_definition.item_code.nil? %>
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
<% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %>
<% else %>
<% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %>
<% end %>
<% end %>
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
</div>
<% sample = [] %>
<% if @inventory_definition.item_code.nil? %>
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
<% sample = MenuItemInstance.where("item_instance_code=?",@inventory_definition.item_code).pluck(:item_instance_name,:item_instance_code)%>
<% else %>
<% sample = Product.where("item_code=?",@inventory_definition.item_code).pluck(:name,:item_code)%>
<% end %>
<% end %>
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
<!-- <div class="col-md-6"><%= f.input :item_code, collection: MenuItemInstance.order("item_instance_name desc").pluck(:item_instance_name,:item_instance_code),input_html: { selected: 2 } %></div> -->
<div class="col-md-6"><%= f.input :min_qty %></div>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>
<script>
$(document).ready(function () {
$(".item_code_place").select2({
placeholder: 'Select Item'
});
$("select#inventory_definition_item_code").select2();
$(".item_code_place").on('change', function (event) {
var ajax_url = "<%= settings_find_item_instance_path %>";
var item_code = this.value;
$.ajax({
type: "GET",
url: ajax_url,
data: 'item_code=' + item_code,
success: function (result) {
$("#inventory_definition_item_code").empty();
var itemlist;
for (var i = 0; i < result.length; i++) {
itemlist = "<option value ='" + result[i][1] + "'>" + result[i][0] + "</option>";
$("select#inventory_definition_item_code").append(itemlist);
}
// $("select#inventory_definition_item_code").append(itemlist);
$("select#inventory_definition_item_code").select2();
}
});
});
});
</script>

View File

@@ -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>

View File

@@ -0,0 +1,38 @@
<div class="container-fluid" style="min-height:30px; padding-left:0px !important; padding-right:0px !important; background:#54A5AF; margin-bottom:5px">
<div style="padding-top:5px;padding-bottom:5px;margin-left:15px; margin-right:15px;">
<div style="float:left;margin-top:3px;text-align:left;color:#ffffff">
<strong>Inventory - <span id="clockbox"></span></strong>
</div>
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">
<% if current_login_employee %>
<%= current_login_employee.name %> | <%= link_to 'Logout', logout_path, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
tday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
tmonth=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function GetClock(){
var d=new Date();
var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getFullYear();
var nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;
if(nhour==0){ap=" AM";nhour=12;}
else if(nhour<12){ap=" AM";}
else if(nhour==12){ap=" PM";}
else if(nhour>12){ap=" PM";nhour-=12;}
if(nmin<=9) nmin="0"+nmin;
if(nsec<=9) nsec="0"+nsec;
document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
}
window.onload=function(){
GetClock();
setInterval(GetClock,1000);
}
</script>
<div id="clockbox"></div>

View File

@@ -9,14 +9,14 @@
<title>SmartSales : Restaurant</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'inventory_definitions', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/header_orgiami' %>
<%= render 'layouts/header_inventory' %>
<div class="container-fluid">
<% flash.each do |type, message| %>
<% if !flash["errors"]%>

View File

@@ -32,3 +32,6 @@ Rails.application.config.assets.precompile += %w( jquery-confirm.js )
# --- Image Uploader ----
Rails.application.config.assets.precompile += %w( fileinput.min.js )
# --- Inventory Definition ----
Rails.application.config.assets.precompile += %w( inventory_definitions.css )