Merge branch 'adminbsb_material_ui' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
class Inventory::StockChecksController < BaseInventoryController
|
||||
def index
|
||||
@check = StockCheck.new
|
||||
@inventory_definitions = InventoryDefinition.active.all
|
||||
# @inventory_definitions1 = InventoryDefinition.active.all
|
||||
|
||||
@category = InventoryDefinition.select("inventory_definitions.*,"+
|
||||
"mc.name as name,mc.id as id ")
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.group("mi.menu_category_id")
|
||||
.order("mi.menu_category_id desc")
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -42,6 +50,19 @@ class Inventory::StockChecksController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
def get_menu_category ()
|
||||
if (params[:id])
|
||||
|
||||
#Pull this menu
|
||||
@menu_category = InventoryDefinition.search_by_category(params[:id])
|
||||
puts @menu_category.to_json
|
||||
# puts @menu.menu_items[1].item_attributes.to_json
|
||||
return @menu_category
|
||||
else
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
|
||||
@@ -61,4 +61,21 @@ class InventoryDefinition < ApplicationRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.search_by_category(cat_id)
|
||||
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
|
||||
mi.name as item_name,mii.item_instance_name as instance_name," +
|
||||
"mi.item_code as item_code,mii.item_instance_code as instance_code," +
|
||||
"mc.name as menu_category_name,mc.id as menu_category_id ")
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
|
||||
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
|
||||
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
|
||||
.where("mc.id=#{cat_id}")
|
||||
.group("mi.menu_category_id,inventory_definitions.item_code")
|
||||
.order("mi.menu_category_id desc")
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -45,7 +45,8 @@ class StockCheckItem < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_items_with_category(id)
|
||||
query = StockCheckItem.select("stock_check_items.*,acc.title as account_name,mi.name as item_name,
|
||||
query = StockCheckItem.select("stock_check_items.*,acc.title as account_name,
|
||||
mi.name as item_name,
|
||||
mii.item_instance_name as instance_name," +
|
||||
"mc.name as menu_category_name,mc.id as menu_category_id ")
|
||||
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = stock_check_items.item_code" +
|
||||
|
||||
@@ -73,7 +73,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="server_mode" value="<%=ENV["SERVER_MODE"]%>" id="server_mode">
|
||||
<div class="col-lg-1 col-md-1 col-sm-1" >
|
||||
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
|
||||
<i class="material-icons">reply</i>Back
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
@@ -576,5 +580,9 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/inventory';
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="page-header">
|
||||
<!-- <div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item"><a href="<%= inventory_path %>"><%= t :inventory %></a></li>
|
||||
@@ -7,6 +7,6 @@
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
</div> -->
|
||||
<br>
|
||||
<%= render 'form', inventory: @inventory_definition %>
|
||||
163
app/views/inventory/stock_checks/backup_index.html.erb
Executable file
163
app/views/inventory/stock_checks/backup_index.html.erb
Executable file
@@ -0,0 +1,163 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.stock_check") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), inventory_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><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.balance") %></th>
|
||||
<th><button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> <%= t("views.btn.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">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.detail.set_stock_check_reason") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.stock_check_reason_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.select") +" "+ t("views.right_panel.detail.product") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.product_txt") %> <br>
|
||||
3) <%= t("views.right_panel.detail.qty") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.qty_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.btn.save") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_check_txt") %> <br>
|
||||
2) <%= t("views.btn.finish") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_txt") +" "+ t("views.right_panel.detail.detail_txt") %> <br>
|
||||
</p>
|
||||
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var count = 0;
|
||||
$(document).ready(function(){
|
||||
clearFormData();
|
||||
});
|
||||
|
||||
function clearFormData(){
|
||||
$('#stock_check_reason').val("");
|
||||
$('#product_qty').val("");
|
||||
$('#product_sku').val("");
|
||||
}
|
||||
|
||||
$('#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();
|
||||
|
||||
// clearFormData();
|
||||
|
||||
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>
|
||||
@@ -0,0 +1,11 @@
|
||||
if @menu_category
|
||||
json.menu_items @menu_category do |item|
|
||||
json.id item.id
|
||||
json.item_code item.item_code
|
||||
json.item_name item.item_name
|
||||
json.instance_name item.instance_name
|
||||
json.instance_code item.instance_code
|
||||
json.category_name item.menu_category_name
|
||||
json.category_id item.menu_category_id
|
||||
end
|
||||
end
|
||||
404
app/views/inventory/stock_checks/index.html.erb
Executable file → Normal file
404
app/views/inventory/stock_checks/index.html.erb
Executable file → Normal file
@@ -1,135 +1,254 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.stock_check") %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
|
||||
<div id="oqs_loading_wrapper" style="display:none;">
|
||||
<div id="oqs_loading"></div>
|
||||
</div>
|
||||
<div class="row m-t">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2" id="">
|
||||
<div id="menu1-slimscroll" data-height="0">
|
||||
<ul class="nav nav-tabs flex-column category_list m-t-10" role="tablist" id="ul-navbar">
|
||||
|
||||
<% @category.each do |cat| %>
|
||||
|
||||
<li class="nav-item ">
|
||||
<p class="hidden cat-id"><%= cat.id %></p>
|
||||
<a class="nav-link menu_category sub_click first_<%=cat.id%>" data-toggle="tab" href="" role="tab" data-id="<%=cat.id%>" ><%= cat.name%>
|
||||
</a>
|
||||
|
||||
</li>
|
||||
|
||||
<%end %>
|
||||
</ul>
|
||||
</div>
|
||||
</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 class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
|
||||
<div class="card">
|
||||
<div class="card-block" style="">
|
||||
<div class="card-text" id="custom-slimscroll">
|
||||
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
|
||||
<!-- append data -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-lg-3 col-sm-3">
|
||||
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
|
||||
<i class="material-icons">reply</i>Back
|
||||
</button>
|
||||
<br>
|
||||
<div class="card-block">
|
||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||
<table class="table table-striped summary-items" id="order-items-table" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-qty">QTY</th>
|
||||
<th class="item-attr"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="font-13" >
|
||||
|
||||
<div class="col-md-6">
|
||||
<table class="table table-striped" id='stock_item'>
|
||||
<tr>
|
||||
<!--<th>#</th>-->
|
||||
<th><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.balance") %></th>
|
||||
<th><button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> <%= t("views.btn.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>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button type="button" class="btn btn-lg btn-block btn-primary waves-effect m-t-5" id='finish'>Finish
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog custom-modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Stock Check Reason</label>
|
||||
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Item</label>
|
||||
<input type='text' id='item' class='form-control' readonly="true" value=''/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Qty</label>
|
||||
<input type='text' class='form-control keypress_qty' placeholder="Qty" id='product_qty' value="1" />
|
||||
</div>
|
||||
<input type="hidden" id="instance_code" value="">
|
||||
<input type="hidden" id="item_code" value="">
|
||||
<input type="hidden" id="item_name" value="">
|
||||
<input type="hidden" id="instance_name" value="">
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
|
||||
<!-- <button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order<div class="ripple-container"></div></button> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</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">
|
||||
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.detail.set_stock_check_reason") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.stock_check_reason_txt") %> <br>
|
||||
2) <%= t("views.right_panel.detail.select") +" "+ t("views.right_panel.detail.product") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.product_txt") %> <br>
|
||||
3) <%= t("views.right_panel.detail.qty") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.qty_txt") %> <br>
|
||||
</p>
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.btn.save") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_check_txt") %> <br>
|
||||
2) <%= t("views.btn.finish") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_txt") +" "+ t("views.right_panel.detail.detail_txt") %> <br>
|
||||
</p>
|
||||
|
||||
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
|
||||
<p>
|
||||
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.fadeInRight{
|
||||
-webkit-animation-duration: 350ms !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
jQuery(function(){
|
||||
id = "<%=@category[0].id%>";
|
||||
console.log(id)
|
||||
jQuery('.first_'+id).click();
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
var count = 0;
|
||||
$(document).ready(function(){
|
||||
clearFormData();
|
||||
//click menu sidebar menu category
|
||||
$(document).on('click', '.menu_category', function(e){
|
||||
e.preventDefault();
|
||||
$('.sub_category_list').addClass("hidden");
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var url = "/inventory/get_menu_category/"+menu_id;
|
||||
show_menu_item_list(url,menu_id);
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
menu_items = data.menu_items;
|
||||
console.log(menu_items)
|
||||
show_menu_list(menu_items);
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
//end show list function
|
||||
function show_menu_list(items) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
for(var i in items) {
|
||||
|
||||
fa_plus = 'material-icons';
|
||||
add = 'view_list'
|
||||
menu_item_box = 'menu_item_box';
|
||||
data_target = 'sx_item_detailModal';
|
||||
data_modal = ''
|
||||
add_icon = "add_icon"
|
||||
if (items[i].image) {
|
||||
image_path = items[i].image;
|
||||
|
||||
}else{
|
||||
image_path = "image/logo.png";
|
||||
}
|
||||
|
||||
row = '<div class="col-md-3">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight card-box"'
|
||||
+'item_name="'+items[i]["item_name"]+'"'
|
||||
+'item_code="'+items[i]["item_code"]+'"'
|
||||
+'instance_name="'+items[i]["instance_name"]+'" '
|
||||
+'instance_code="'+items[i]["instance_code"]+'"'
|
||||
+'data-toggle="modal" data-target=".'+data_target+'" '
|
||||
+'style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
|
||||
+'<div class="col-md-10 " style="padding:0px !important;">'+ items[i]["item_name"] +"-" +items[i]["instance_name"]+'</div>'
|
||||
+"<div class='col-md-2 "+menu_item_box+" ' style='padding:0px 5px 0px 5px'>"
|
||||
+"<i class='m-l--5 fa "+fa_plus+" '>"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 m-r-' >"
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.card-box', function(event){
|
||||
$("#product_qty").val(1);
|
||||
$('#product_qty').empty();
|
||||
$("#stock_check_reason").val('');
|
||||
$('#item_code').val($(this).attr('item_code'));
|
||||
$('#instance_code').val($(this).attr('instance_code'));
|
||||
$('#item').val($(this).attr('item_name')+"-"+$(this).attr('instance_name'));
|
||||
$('#instance_name').val($(this).attr('instance_name'));
|
||||
$('#item_name').val($(this).attr('item_name'));
|
||||
});
|
||||
|
||||
function clearFormData(){
|
||||
$('#stock_check_reason').val("");
|
||||
$('#product_qty').val("");
|
||||
$('#product_sku').val("");
|
||||
}
|
||||
|
||||
|
||||
$('#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();
|
||||
|
||||
if ($("#product_qty").val()>0) {
|
||||
item_name = $('#item_name').val();
|
||||
instance_name = $('#instance_name').val();
|
||||
product_qty = $('#product_qty').val();
|
||||
product_name = $("#item").val();
|
||||
|
||||
// clearFormData();
|
||||
item_code = $("#item_code").val();
|
||||
instance_code = $("#instance_code").val();
|
||||
|
||||
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('');
|
||||
reason = $("#stock_check_reason").val();
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
|
||||
row ="<tr class='item_box' data-toggle='modal' data-target='#sx_itemModal' 'data-code ='"
|
||||
+item_code+ "' data-instance-code='"+instance_code+"' data-row ='"+rowCount+ "' data-reason ='"+reason+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + instance_name +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + product_qty + '</td>'
|
||||
+'<td class="" id="remove"><i class="material-icons" id="remove_row" style="cursor:pointer;">delete_forever</i></td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
}else{
|
||||
swal("Opps", "Please enter number for qty ","warning");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#remove_row', function(event){
|
||||
console.log( $(this).parent().parent())
|
||||
$($(this).parent().parent()).attr('data-active',true);
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(".keypress_qty").on('keyup change', function (){
|
||||
value = $(this).val();
|
||||
if ($.isNumeric(value)) {
|
||||
$('#product_qty').val(value);
|
||||
}else{
|
||||
swal("Opps","Please enter number for qty","warning");
|
||||
}
|
||||
});
|
||||
|
||||
$('#finish').on('click', function () {
|
||||
@@ -137,27 +256,38 @@
|
||||
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);
|
||||
}
|
||||
var jsonStr = JSON.stringify(get_order_item_rows());
|
||||
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'];
|
||||
}
|
||||
})
|
||||
if (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'];
|
||||
}
|
||||
})
|
||||
}else{
|
||||
swal("Opps","Please add item ","warning");
|
||||
}
|
||||
});
|
||||
|
||||
function remove_row(row) {
|
||||
$("#item_remove_"+row).parent().parent().remove();
|
||||
}
|
||||
|
||||
</script>
|
||||
/* Get Item rows */
|
||||
function get_order_item_rows(){
|
||||
var items = [];
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
$(item_row).each(function(i){
|
||||
var item_list = {};
|
||||
|
||||
item_list.remark = $(item_row[i]).attr('data-reason');
|
||||
item_list.sku = $(item_row[i]).attr('data-instance-code');
|
||||
item_list.qty = $(item_row[i]).children('#item_qty').text();
|
||||
|
||||
items.push(item_list);
|
||||
});
|
||||
return items;
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -520,6 +520,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
resources :stock_journals
|
||||
resources :inventory_definitions
|
||||
get ':inventory_definition_id/show' => 'inventory#show'
|
||||
|
||||
get 'get_menu_category/:id' => "stock_checks#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' }
|
||||
end
|
||||
#mount_compendium at: '/report' #, controller: 'reports'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user