fixed invetory

This commit is contained in:
NyanLinHtut
2019-09-25 11:54:54 +06:30
parent e558746e26
commit 9d330bb28c
13 changed files with 402 additions and 146 deletions

View File

@@ -781,7 +781,7 @@ $(function() {
total_price = $('#total_price').text();
qty = parseInt($('#count').val());
var item_row = $('.selected-attribute');
var item_row = $('.selected-attribute');
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
@@ -804,6 +804,8 @@ $(function() {
}
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
console.log('instances');
console.log(attrbu);
$('.add_to_order').attr('data-instance-code',instances[field].code);
$('.add_to_order').attr('data-instance',instances[field].name);
$('.add_to_order').attr('data-price',instances[field].price);

View File

@@ -3,12 +3,13 @@ section .content{
}
.custom-card-head{
height: 40px;
background-color: #79D0F2;
// background-color: #79D0F2;
background-color: #3F52B5;
color :#fff;
#background-color: #a1aade;
opacity: 0.8;
padding:5px;
font-weight:400;
font-weight:600;
}
.custom-card {
border: 2px solid rgba(0, 0, 0, 0.125) !important;
@@ -21,11 +22,11 @@ section .content{
width: 100%;
font-weight:900;
}
.custom-card-block {
padding: 0.3rem !important;
}
@media (min-width: 34em) {
.custom-card-columns {
-webkit-column-count: 2;
@@ -143,7 +144,7 @@ element.style {
margin-bottom: 5px;
margin-right: 5px;
color:#111 !important;
}
}
#logo{
margin: auto;
width: 100%;
@@ -188,7 +189,7 @@ section.content{
opacity: 1;
z-index: 101;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
-moz-opacity: 1; /* mozilla */
}
#count ,#set_count{
@@ -240,7 +241,7 @@ i.logout_icon{
.my-toggle{
padding: 15px 20px 10px 10px;
line-height:2;
}
.list-menu{
list-style: none;
@@ -268,7 +269,7 @@ i.logout_icon{
.list-menu > a:hover{
text-decoration: none;
}
.cashier_number{
.cashier_number, .qty_number{
width: 33%;
height:58px;
line-height:58px;
@@ -320,7 +321,8 @@ i.logout_icon{
color :#273040;
min-height:100px;
height: 150px;
background-color:#79D0F2;
// background-color:#79D0F2;
background-color: #3F52B5;
}
.menu_item_no_img_box{
@@ -329,7 +331,7 @@ i.logout_icon{
}
.custom-card-no-img-footer{
padding:0.35rem 1.25rem !important;
}
.custom-flex-footer{
display:flex;

View File

@@ -21,6 +21,8 @@ class Inventory::InventoryController < BaseInventoryController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail

View File

@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new
def new
@menus = Menu.all
@menus = Menu.all
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
@inventory_definition = InventoryDefinition.new
end
@@ -28,7 +28,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
def create
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new
@inventory_definition.item_code = params[:item_code]
@inventory_definition.min_order_level = params[:min_order_level]
@@ -83,11 +83,24 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# DELETE /inventory_definitions/1
# DELETE /inventory_definitions/1.json
def destroy
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
@inventory_definition.destroy
respond_to do |format|
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
format.json { head :no_content }
end
inventory = InventoryDefinition.find(params[:id])
StockJournal.delete_stock_journal(inventory.item_code)
StockCheckItem.delete_stock_check_item(inventory.item_code)
if !inventory.nil?
inventory.destroy
flash[:message] = 'Inventory was successfully destroyed.'
render :json => {:status=> "Success", :url => inventory_url }.to_json
else
flash[:error] = 'Inventory could not destroy! This record is using in somewhere.'
render :json => {:status=> "Error", :url => inventory_url }.to_json
end
end
#Shop Name in Navbor

View File

@@ -121,7 +121,7 @@ class InventoryDefinition < ApplicationRecord
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("mi.name asc,acc.title desc,mi.menu_category_id desc,balance ASC")
.order("balance asc, mi.name asc,acc.title desc,mi.menu_category_id desc")
end
end

View File

@@ -2974,11 +2974,20 @@ private
end
def update_stock_journal
if self.sale_status == "void" && self.sale_status_was != "void"
# if self.sale_status == "void"
# remark = "void"
# elsif self.sale_status == "waste"
# remark = "waste"
# elsif self.sale_status == "spoile"
# remark = "spoile"
# elsif self.payment_status == "foc"
# remark = "foc"
# end
self.sale_items.each do |item|
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
if found
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
if self.sale_status == "void" && self.sale_status_was != "void"
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
if found
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
unless stock.nil?
check_item = StockCheckItem.where('item_code=?', item.item_instance_code).order("id DESC").first
StockJournal.add_to_journal(item.item_instance_code, -item.qty, stock.balance, "void", inventory_definition, item.id, StockJournal::SALES_TRANS)
@@ -2986,6 +2995,12 @@ private
check_item.save
end
end
elsif self.sale_status == "waste"
StockJournal.update_stock_journal(item.item_instance_code, "waste")
elsif self.sale_status == "spoile"
StockJournal.update_stock_journal(item.item_instance_code, "spoile")
elsif self.payment_status == "foc" && self.payment_status_was != "foc"
StockJournal.update_stock_journal(item.item_instance_code, "foc")
end
end
end

View File

@@ -236,6 +236,13 @@ class SaleItem < ApplicationRecord
is_void = self.status == "void" && self.status_was != "void"
cancel_void = self.status_was == "void" && self.status.nil?
is_edit = self.qty >= 0 && self.qty != self.qty_was
is_foc = self.status == "foc" && self.status_was != "foc"
cancel_foc = self.status_was == "foc"
if is_foc
StockJournal.update_stock_journal(self.item_instance_code, "foc")
elsif cancel_foc
StockJournal.update_stock_journal(self.item_instance_code, "cancel_foc")
end
if is_void or cancel_void or is_edit
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
if found
@@ -251,6 +258,11 @@ class SaleItem < ApplicationRecord
elsif is_edit
qty = self.qty - self.qty_was
remark = "edit"
# elsif is_foc
# logger.debug 'foc++++++++++++++++++++++++++++'
# logger.debug is_foc
# remark = "foc"
# StockJournal.update_stock_journal(self.item_instance_code, remark)
end
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS)
check_item.different = check_item.different + qty

View File

@@ -66,4 +66,8 @@ class StockCheckItem < ApplicationRecord
.order("acc.title desc,mi.menu_category_id desc")
return query
end
def self.delete_stock_check_item(item_code)
self.where("item_code=?", item_code).delete_all
end
end

View File

@@ -72,4 +72,14 @@ class StockJournal < ApplicationRecord
end
end
def self.update_stock_journal(item_code,remark)
stock = self.where("item_code=?", item_code).order("id DESC").first
stock.remark = remark
stock.save
end
def self.delete_stock_journal(item_code)
self.where("item_code=?", item_code).delete_all
end
end

View File

@@ -1,11 +1,12 @@
<table class="table table-striped">
<tr>
<th><%= t("views.right_panel.header.menu_category") %></th>
<!-- <th><%= t("views.right_panel.header.menu_category") %></th> -->
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.min_order") %></th>
<th><%= t("views.right_panel.detail.max_stock") %></th>
<th><%= t("views.right_panel.detail.balance") %></th>
<th><%= t("views.right_panel.detail.status") %></th>
<th><%= t("views.right_panel.detail.action") %></th>
<!-- <th><%= t("views.right_panel.detail.created_by") %></th>
<th><%= t("views.right_panel.detail.created_time") %></th> -->
@@ -19,12 +20,12 @@
<tr>
<% if !cate_arr.include?(item.menu_category_id) %>
<td><%= item.menu_category_name %></td>
<% cate_arr.push(item.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<!-- <% if !cate_arr.include?(item.menu_category_id) %> -->
<!-- <td><%= item.menu_category_name %></td> -->
<!-- <% cate_arr.push(item.menu_category_id) %> -->
<!-- <% else %> -->
<!-- <td>&nbsp;</td> -->
<!-- <% end %> -->
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
<td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td>
@@ -35,9 +36,30 @@
<%= item.balance rescue 0 %>
<% end %>
</td>
<% if !item.balance.nil? %>
<% if item.balance >= 0 %>
<td>
<div class="badge badge-success">OK</div>
</td>
<% else %>
<td>
<div class="badge badge-danger">OUT OF STOCK</div>
</td>
<% end %>
<% else %>
<td><div class="badge badge-success">OK</div></td>
<% end %>
<td>
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"> <%= t("views.right_panel.detail.stock_ledger") %></button>
<button type="button" class="delete btn btn-danger btn-sm waves-effect" data-ref="<%= inventory_inventory_definition_path(item) %>" data-method="delete">
<%= t("views.btn.delete") %>
</button>
<span class="hidden" id="delete_text">
<h6>Are you sure you want to delete this row ?</h6>
<h6>This action can't be undo. </h6>
</span>
</td>
</tr>
<!-- <tr>
<td><%= count %></td>

View File

@@ -7,34 +7,36 @@
</span>
</ol>
</div>
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
<div class="row">
<div class="row ">
<div class="col-lg-4 col-md-4 col-sm-4" style="padding-left: 17px;">
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="font-14"><%= t("views.right_panel.detail.product") %></label>
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 text-">
<br>
<input type="submit" value="Filter" class='btn btn-primary'>
</div>
</div>
<% end %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="m-b-10 clearfix">
<!-- col-lg-4 col-md-4 col-sm-4 -->
<!-- <label class="font-14"><%= t("views.right_panel.detail.product") %></label> -->
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 text-">
<input type="submit" value="Filter" class='btn btn-primary'>
</div>
<% end %>
<div class="col-lg-6 col-md-6 col-sm-6" style="padding-right: 15px;">
<!-- m-b-10 clearfix -->
<!-- <button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
</button> -->
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_taking") %></button>
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " %> <%= t("views.right_panel.detail.item") %>
</button>
</div>
<div class="card">
<%= render 'inventory_list' %>
</button>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="card">
<%= render 'inventory_list' %>
</div>
</div>
<!-- <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
@@ -55,7 +57,7 @@
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %> <br>
</p>
</div>
</div>
</div>
</div> -->
</div>

View File

@@ -5,7 +5,7 @@
<div id="oqs_loading"></div>
</div>
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
<li class="list-menu">
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
@@ -22,7 +22,7 @@
</li>
<%end%>
</ul>
</li>
</li>
<div id="menu1-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list" role="tablist" id="ul-navbar">
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
@@ -34,7 +34,7 @@
<!--if type quick_service or cashier for table -->
<% if !menu.code.include? "SPL" %>
<li class="nav-item ">
<p class="hidden menu-id"><%= menu.id %></p>
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
</a>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list"></ul>
@@ -53,7 +53,7 @@
</a>
<ul class="ml-menu menu_list aria-hidden menu_cache_list" style="border-top: 1px solid #fff">
</ul>
</li>
</li>
<div id="menu-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list category_cache_list" role="tablist" id="ul-navbar">
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
@@ -87,6 +87,7 @@
<th class="item-name">Items</th>
<th class="item-qty">Min Qty</th>
<th class="item-attr">Max Qty</th>
<!-- <th></th> -->
</tr>
</thead>
<tbody class="font-13" >
@@ -118,7 +119,7 @@
<label class="control-label" for="attribute">Menu Item</label>
<input class="form-control col-md-6" type="text" value="" id="item_name" readonly="true">
</div>
<input type="hidden" name="item_code" id="instance_code">
<div class="form-group">
<label class="control-label" for="attribute">Instances</label>
@@ -134,7 +135,7 @@
<label class="control-label" for="attribute">Max Order Level</label>
<input type="text" name="max_order_level" id="max_qty" value="1" class="col-md-5 form-control">
</div>
</div>
</div>
</div>
@@ -148,7 +149,7 @@
</div>
</div>
</div>
</div>
</div>
<style type="text/css">
@@ -176,11 +177,11 @@
menu_cache_append(menus);
}else{
$("#menu_data").removeClass("hidden");
}
}
function menu_cache_append(menus){
$("#menu_cache").removeClass("hidden");
$(".menu_cache_name").text(menus[0]["name"])
$(".menu_cache_name").text(menus[0]["name"])
for(var i in menus) {
menu_list_template(menus[i]);
}
@@ -189,14 +190,14 @@
for(var ii in category) {
if (category[ii]["is_available"]== true){
if (category[ii]["valid_time"]== true){
if (category[ii]["parent_id"] == null ){
if (category[ii]["parent_id"] == null ){
if (category[ii]["code"].includes("SPL") != true) {
category_list_template(category[ii]);
}
}
}
}
}
}
}
}
$(document).on('click', '.menu_click', function(event){
@@ -207,15 +208,15 @@
var name = $(this).attr("data-name");
var menus = JSON.parse(localStorage.getItem("menus"));;
if (menus != null) {
console.log("hi")
if (menus != null) {
console.log("hi")
menu_click_cache_append(name,menus,menu_id);
}else{
console.log("sssdfdf")
var url = "/origami/addorders/get_menu/"+menu_id;
show_menu_cat_list(name, url);
show_menu_cat_list(name, url);
}
});
});
//End menu category Click
function menu_click_cache_append(name,menus,menu_id) {
@@ -227,26 +228,26 @@
$(".main_menu").text(name);
for(var i in menus) {
for(var i in menus) {
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
// menu_list_template(menus[i]);
var category = menus[i]["categories"];
for(var ii in category) {
if (category[ii]["is_available"]== true){
for(var ii in category) {
if (category[ii]["is_available"]== true){
if (category[ii]["valid_time"]== true){
if (category[ii]["parent_id"] == null ){
if (category[ii]["parent_id"] == null ){
if (category[ii]["code"].includes("SPL") != true) {
category_list_template(category[ii]);
}
}
}
}
}
}
}
}
}
}
@@ -263,7 +264,7 @@
+'</ul>'
+' </li>';
$(".category_cache_list").append(row);
$(".category_cache_list").append(row);
}
function menu_list_template(menu) {
@@ -272,11 +273,11 @@
+' <a class="nav-link" data-toggle="tab" href="" role="tab"'
+' style="text-transform: lowercase;">'+menu.name+'</a>'
+'</li>';
$(".menu_cache_list").append(row);
}
$(".menu_cache_list").append(row);
}
//show menu item list when click menu category
function show_menu_cat_list(name, url_item){
function show_menu_cat_list(name, url_item){
var menu_list = $('.menu_items_list');
menu_list.empty();
@@ -284,20 +285,20 @@
menu_cat.empty();
$(".main_menu").text(name);
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
for(var i in data) {
for(var i in data) {
if (data[i].is_available == true) {
list = '<li class="nav-item menu_category sub_click" data-id="'+ data[i].id +'">'
+'<p class="hidden menu-id">'+ data[i].id +'</p> '
+'<a class="nav-link" data-toggle="tab" href="" role="tab"> '+ data[i].name +''
+'<ul class=" sub_category_list hidden fadeInTop animated"'
+'<ul class=" sub_category_list hidden fadeInTop animated"'
+'id="sub_category_list">'
+'</ul>'
+'</a>'
@@ -307,9 +308,9 @@
}
}
});
//end Ajax
//end Ajax
}
//end show list function
//end show list function
//click menu sidebar menu category
$(document).on('click', '.menu_category', function(e){
@@ -324,7 +325,7 @@
sub_category = $(this).siblings('.sub_category_list');
show_sub_category_list(sub_url,sub_category,menu_id);
}
});
});
//End menu category Click
//click menu sidebar menu category
@@ -335,31 +336,31 @@
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){
function show_menu_item_list(url_item,menu_id){
var menu_list = $('.menu_items_list');
menu_list.empty();
menus = JSON.parse(localStorage.getItem("menus"));
if (menus != null) {
for(var i in menus) {
for(var i in menus) {
var categories = menus[i]["categories"];
for(var ii in categories) {
for(var ii in categories) {
if (categories[ii]["id"] == menu_id) {
var menu_items = categories[ii]["items"];
show_menu_list(menu_items);
}
}
}
}else{
}else{
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
@@ -369,14 +370,14 @@
show_menu_list(menu_items);
}
});
//end Ajax
//end Ajax
}
}
//end show list function
function show_menu_list(menu_items) {
var menu_list = $('.menu_items_list');
menu_list.empty();
for(var field in menu_items) {
for(var field in menu_items) {
if (menu_items[field].is_sub_item == false) {
instances = menu_items[field].instances ;
@@ -408,15 +409,15 @@
}
});
if (menu_items[field].image) {
image_path = menu_items[field].image;
if (menu_items[field].image) {
image_path = menu_items[field].image;
}else{
image_path = "image/logo.png";
}
row = '<div class="col-md-3">'
+'<div class="card custom-card testimonial-card fadeInRight card-box"'
+'<div class="card custom-card testimonial-card fadeInRight card-box"'
+'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="">'
@@ -450,7 +451,7 @@
// +"</div>"
+'</div>'
+'</div>'; ;
+'</div>'; ;
$('.menu_items_list').append(row);
}
//end instances in menu-items alest 1 instance
@@ -460,7 +461,7 @@
}
//click item row for add order
$(document).on('click', '.card-box', function(event){
$(document).on('click', '.card-box', function(event){
item_data = $(this).children().siblings('.add_icon');
@@ -478,7 +479,7 @@
instances = $(data).data('instance');
instance_attributes = []
for(var field in instances) {
for(var field in instances) {
value = instances[field].values;
$(value).each(function(i){
options = value[i];
@@ -486,7 +487,7 @@
});
}
for(var field in attributes) {
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
row = "";
@@ -504,20 +505,20 @@
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
+ status +" "+ type +" '"+ disabled +" >"
+value[i]
+"</button>";
+"</button>";
});
$(".attributes-list").append(row);
$(".attributes-list").append(row);
}
});
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
// $('.change_qty').val(1);
value = $(this).data('value');
type = $(this).data('type');
instances = $(this).data('instances');
attributes = $(".attribute_btn");
$(attributes).each(function(i){
if ($(attributes[i]).attr('data-type')==type){
@@ -525,17 +526,17 @@
}
});
$(this).addClass('selected-attribute');
var selected_attr = get_selected_attributes('selected-attribute');
for(var field in instances) {
for(var field in instances) {
item_attr = instances[field].values;
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
$('#instance_code').val(instances[field].code);
}
}
}
}); //End selecct attribute buttom
// Get Selected Class
@@ -571,9 +572,9 @@
}
break;
case 'add':
case 'del' :
case 'clr':
$('#modal-qty').val(1);
$('#modal-qty').attr('data-value',0);
@@ -586,9 +587,9 @@
return false;
}
});
// click select option icon for add
$(document).on('click', '.submit', function(event){
// click select option icon for add
$(document).on('click', '.submit', function(event){
var item_code = $("#instance_code").val();
var min_qty = $("#min_qty").val();
@@ -598,7 +599,7 @@
console.log(item_code);
console.log(min_qty);
console.log(max_qty);
var params = {'item_code': item_code,
var params = {'item_code': item_code,
'min_order_level': min_qty,
'max_stock_level': max_qty};
var ajax_url = '<%=inventory_inventory_definitions_path%>';
@@ -607,14 +608,15 @@
url: ajax_url,
data: params,
dataType: "json",
success:function(result){
success:function(result){
if (result.status) {
var rowCount = $('.summary-items tbody tr').length+1;
row ="<tr class=''>"
+'<td class="">'+rowCount+'</td>'
+'<td class="hidden" id="itemCodeee">' + item_code +'</td>'
+'<td class="">' + item_name +'</td>'
+'<td class="">' + min_qty + '</td>'
+'<td class="">' + max_qty + '</td>'
+'<td class="">' + min_qty + '</td>'
+'<td class="">' + max_qty + '</td>'
+'</tr>';
$(".summary-items tbody").append(row);
swal("Success",result.message,"success");
@@ -623,9 +625,11 @@
}
}
});
// +'<td class="" onClick="remove()"><i class="material-icons"style="cursor: pointer;">delete_forever</i></td>'
});
$('#back').on('click', function () {
window.location.href = '/inventory';
});
@@ -634,4 +638,36 @@
});
});
</script>
// $('.remove_row').on('click', function(){
// window.location.href = '/inventory';
// console.log('remove row!!!!!');
// alert('Are you suer?');
// });
// function remove(){
// var itemCode = $("#itemCodeee").text();
//
// var params = {'item_code': itemCode};
// var ajax_url = '<%=inventory_inventory_definitions_path%>';
// $.ajax({
// type: "POST",
// url: ajax_url,
// data: params,
// dataType: "json",
// success:function(result){
// if (result.status) {
// var rowCount = $('.summary-items tbody tr').length+1;
// row =
// $(".summary-items tbody").append(row);
// swal("Success",result.message,"success");
// }else{
// swal("Opps",result.message,"warning");
// }
// }
// });
//
// console.log('remove row!!!!!');
// console.log(itemCode);
// }
</script>

View File

@@ -62,7 +62,7 @@
</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="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;">
@@ -74,7 +74,7 @@
<div class="form-group">
<label class="control-label" for="attribute">Item</label>
<input type='text' id='item' class='form-control' readonly="true" value=''/>
<input type='text' id='item' class='form-control' readonly="true" value=''/>
</div>
<div class="form-group">
<label class="control-label" for="attribute">Qty</label>
@@ -92,14 +92,88 @@
<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> -->
<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=" modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
<div class="modal-dialog custom-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<!-- <td type='text' id='item' class='form-control' readonly="true" value=''></td> -->
<td class="item_name" id="item"></td>
<!-- <td> -->
<div class="form-group">
<!-- <label class="control-label" for="attribute">Item</label> -->
<!-- <input type='text' id='item' class='form-control' readonly="true" value=''/> -->
</div>
<!-- </td> -->
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number keypress_qty" placeholder="Qty" data-value="0" id="product_qty" value="" min="1" max="10000">
<!-- <input type='text' class='form-control keypress_qty' placeholder="Qty" id='product_qty' value="1" /> -->
<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="">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
<div class="row bottom p-l-15 p-r-15 m-t-10">
<div class="col-md-3 qty_number border-top border-left" data-value="1" data-type="num">1</div>
<div class="col-md-3 qty_number border-top border-left" data-value="2" data-type="num">2</div>
<div class="col-md-3 qty_number border-top border-left" data-value="3" data-type="num">3</div>
<div class="col-md-3 qty_number border-top border-left" data-value="4" data-type="num">4</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 qty_number border-top border-left" data-value="5" data-type="num">5</div>
<div class="col-md-3 qty_number border-top border-left" data-value="6" data-type="num">6</div>
<div class="col-md-3 qty_number border-top border-left" data-value="7" data-type="num">7</div>
<div class="col-md-3 qty_number border-top border-left" data-value="8" data-type="num">8</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 qty_number border-top border-left" data-value="9" data-type="num">9</div>
<div class="col-md-3 qty_number border-top border-left" data-value="0" data-type="num">0</div>
<div class="col-md-3 qty_number border-top border-left" data-value="00" data-type="num">00</div>
<div class="col-md-3 qty_number border-top border-left bg-orange" data-type="clr">Clr</div>
</div>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-5">
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">Close</button>
</div>
<div class="col-md-5">
<!-- <button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button> -->
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class=" modal" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
@@ -155,8 +229,6 @@
<button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button>
</div>
</div>
</div>
</div>
</div>
@@ -250,8 +322,7 @@
+'</div>';
$('.menu_items_list').append(row);
}
}
}
//click item row for add order
$(document).on('click', '.card-box', function(event){
@@ -260,35 +331,64 @@
$("#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'));
// $('#item').val($(this).attr('item_name')+"-"+$(this).attr('instance_name'));
$('#item').text($(this).attr('item_name'));
$('#instance_name').val($(this).attr('instance_name'));
$('#item_name').val($(this).attr('item_name'));
});
$('#save_to_stock_check').on('click', function () {
$('#save_to_stock_check').on('click', function() {
if ($("#product_qty").val()>0) {
item_name = $('#item_name').val();
instance_name = $('#instance_name').val();
product_qty = $('#product_qty').val();
qty = $('#product_qty').val();
product_name = $("#item").val();
item_code = $("#item_code").val();
instance_code = $("#instance_code").val();
append = 0;
itemCode = $("#item_code").val();
instanceCode = $("#instance_code").val();
reason = $("#stock_check_reason").val();
var rowCount = $('.summary-items tbody tr').length+1;
var item_row = $('.summary-items tbody tr');
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);
$(item_row).each(function(i){
item_code = $(item_row[i]).attr('data-code');
instance_code = $(item_row[i]).attr('data-instance-code');
r_option = $(item_row[i]).attr('data-opt');
if (item_code == itemCode && instance_code == instanceCode) {
if (qty > 1) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) + parseInt(qty);
test_qty = parseInt($(item_row[i]).children('#item_qty').text());
}else{
qty = parseInt($(item_row[i]).children('#item_qty').text()) + 1;
}
$(item_row[i]).children('#item_qty').text(qty);
// parseFloat($(item_row[i]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
append =1;
}else{
if (qty > 1) {
qty = qty;
}else{
qty = 1;
}
}
});
if (append===0) {
row ="<tr class='item_box' data-toggle='modal' data-target='#sx_itemModal' data-code ='"
+itemCode+ "' data-instance-code='"+instanceCode+"' 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">' + 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");
}
@@ -424,6 +524,42 @@
}
});
$(document).on('click', '.qty_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = $('#product_qty').attr('data-value');
original_qty = $('#product_qty').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#product_qty').val(input_value);
$('#product_qty').attr('data-value',input_value);
// update_total_amount();
}else{
$('#product_qty').val(original_qty + input_value);
$('#product_qty').attr('data-value',original_qty + input_value);
// update_total_amount();
}
break;
case 'add':
case 'del' :
case 'clr':
$('#product_qty').val(1);
$('#product_qty').attr('data-value',0);
// update_total_amount();
break;
}
event.handled = true;
} else {
return false;
}
});
$("#back").on("click", function(){
window.location.href = "/inventory";
});