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

View File

@@ -3,12 +3,13 @@ section .content{
} }
.custom-card-head{ .custom-card-head{
height: 40px; height: 40px;
background-color: #79D0F2; // background-color: #79D0F2;
background-color: #3F52B5;
color :#fff; color :#fff;
#background-color: #a1aade; #background-color: #a1aade;
opacity: 0.8; opacity: 0.8;
padding:5px; padding:5px;
font-weight:400; font-weight:600;
} }
.custom-card { .custom-card {
border: 2px solid rgba(0, 0, 0, 0.125) !important; border: 2px solid rgba(0, 0, 0, 0.125) !important;
@@ -268,7 +269,7 @@ i.logout_icon{
.list-menu > a:hover{ .list-menu > a:hover{
text-decoration: none; text-decoration: none;
} }
.cashier_number{ .cashier_number, .qty_number{
width: 33%; width: 33%;
height:58px; height:58px;
line-height:58px; line-height:58px;
@@ -320,7 +321,8 @@ i.logout_icon{
color :#273040; color :#273040;
min-height:100px; min-height:100px;
height: 150px; height: 150px;
background-color:#79D0F2; // background-color:#79D0F2;
background-color: #3F52B5;
} }
.menu_item_no_img_box{ .menu_item_no_img_box{

View File

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

View File

@@ -83,11 +83,24 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# DELETE /inventory_definitions/1 # DELETE /inventory_definitions/1
# DELETE /inventory_definitions/1.json # DELETE /inventory_definitions/1.json
def destroy def destroy
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
@inventory_definition.destroy @inventory_definition.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' } format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
format.json { head :no_content } format.json { head :no_content }
end 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 end
#Shop Name in Navbor #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}%", OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") "%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
.group("mi.menu_category_id,inventory_definitions.item_code") .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
end end

View File

@@ -2974,11 +2974,20 @@ private
end end
def update_stock_journal 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| self.sale_items.each do |item|
found, inventory_definition = InventoryDefinition.find_product_in_inventory(item) if self.sale_status == "void" && self.sale_status_was != "void"
if found found, inventory_definition = InventoryDefinition.find_product_in_inventory(item)
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first if found
stock = StockJournal.where('item_code=?', item.item_instance_code).order("id DESC").first
unless stock.nil? unless stock.nil?
check_item = StockCheckItem.where('item_code=?', item.item_instance_code).order("id DESC").first 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) 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 check_item.save
end end
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 end
end end

View File

@@ -236,6 +236,13 @@ class SaleItem < ApplicationRecord
is_void = self.status == "void" && self.status_was != "void" is_void = self.status == "void" && self.status_was != "void"
cancel_void = self.status_was == "void" && self.status.nil? cancel_void = self.status_was == "void" && self.status.nil?
is_edit = self.qty >= 0 && self.qty != self.qty_was 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 if is_void or cancel_void or is_edit
found, inventory_definition = InventoryDefinition.find_product_in_inventory(self) found, inventory_definition = InventoryDefinition.find_product_in_inventory(self)
if found if found
@@ -251,6 +258,11 @@ class SaleItem < ApplicationRecord
elsif is_edit elsif is_edit
qty = self.qty - self.qty_was qty = self.qty - self.qty_was
remark = "edit" remark = "edit"
# elsif is_foc
# logger.debug 'foc++++++++++++++++++++++++++++'
# logger.debug is_foc
# remark = "foc"
# StockJournal.update_stock_journal(self.item_instance_code, remark)
end end
StockJournal.add_to_journal(self.item_instance_code, qty, stock.balance, remark, inventory_definition, self.id, StockJournal::SALES_TRANS) 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 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") .order("acc.title desc,mi.menu_category_id desc")
return query return query
end end
def self.delete_stock_check_item(item_code)
self.where("item_code=?", item_code).delete_all
end
end end

View File

@@ -72,4 +72,14 @@ class StockJournal < ApplicationRecord
end end
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 end

View File

@@ -1,11 +1,12 @@
<table class="table table-striped"> <table class="table table-striped">
<tr> <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.product") %></th>
<th><%= t("views.right_panel.detail.min_order") %></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.max_stock") %></th>
<th><%= t("views.right_panel.detail.balance") %></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.action") %></th>
<!-- <th><%= t("views.right_panel.detail.created_by") %></th> <!-- <th><%= t("views.right_panel.detail.created_by") %></th>
<th><%= t("views.right_panel.detail.created_time") %></th> --> <th><%= t("views.right_panel.detail.created_time") %></th> -->
@@ -19,12 +20,12 @@
<tr> <tr>
<% if !cate_arr.include?(item.menu_category_id) %> <!-- <% if !cate_arr.include?(item.menu_category_id) %> -->
<td><%= item.menu_category_name %></td> <!-- <td><%= item.menu_category_name %></td> -->
<% cate_arr.push(item.menu_category_id) %> <!-- <% cate_arr.push(item.menu_category_id) %> -->
<% else %> <!-- <% else %> -->
<td>&nbsp;</td> <!-- <td>&nbsp;</td> -->
<% end %> <!-- <% end %> -->
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td> <td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
<td><%= item.min_order_level %></td> <td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td> <td><%= item.max_stock_level %></td>
@@ -35,9 +36,30 @@
<%= item.balance rescue 0 %> <%= item.balance rescue 0 %>
<% end %> <% end %>
</td> </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> <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" 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> </td>
</tr> </tr>
<!-- <tr> <!-- <tr>
<td><%= count %></td> <td><%= count %></td>

View File

@@ -7,34 +7,36 @@
</span> </span>
</ol> </ol>
</div> </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"> <!-- col-lg-4 col-md-4 col-sm-4 -->
<label class="font-14"><%= t("views.right_panel.detail.product") %></label> <!-- <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;"> <input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2 text-"> <div class="col-lg-2 col-md-2 col-sm-2 text-">
<br> <input type="submit" value="Filter" class='btn btn-primary'>
<input type="submit" value="Filter" class='btn btn-primary'> </div>
</div> <% end %>
</div> <div class="col-lg-6 col-md-6 col-sm-6" style="padding-right: 15px;">
<% end %> <!-- m-b-10 clearfix -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="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 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> -->
<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="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 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> </button>
</div>
<div class="card">
<%= render 'inventory_list' %>
</div> </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>
<!-- <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3"> <!-- <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card"> <div class="card">

View File

@@ -87,6 +87,7 @@
<th class="item-name">Items</th> <th class="item-name">Items</th>
<th class="item-qty">Min Qty</th> <th class="item-qty">Min Qty</th>
<th class="item-attr">Max Qty</th> <th class="item-attr">Max Qty</th>
<!-- <th></th> -->
</tr> </tr>
</thead> </thead>
<tbody class="font-13" > <tbody class="font-13" >
@@ -612,6 +613,7 @@
var rowCount = $('.summary-items tbody tr').length+1; var rowCount = $('.summary-items tbody tr').length+1;
row ="<tr class=''>" row ="<tr class=''>"
+'<td class="">'+rowCount+'</td>' +'<td class="">'+rowCount+'</td>'
+'<td class="hidden" id="itemCodeee">' + item_code +'</td>'
+'<td class="">' + item_name +'</td>' +'<td class="">' + item_name +'</td>'
+'<td class="">' + min_qty + '</td>' +'<td class="">' + min_qty + '</td>'
+'<td class="">' + max_qty + '</td>' +'<td class="">' + max_qty + '</td>'
@@ -623,9 +625,11 @@
} }
} }
}); });
// +'<td class="" onClick="remove()"><i class="material-icons"style="cursor: pointer;">delete_forever</i></td>'
}); });
$('#back').on('click', function () { $('#back').on('click', function () {
window.location.href = '/inventory'; window.location.href = '/inventory';
}); });
@@ -634,4 +638,36 @@
}); });
}); });
// $('.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> </script>

View File

@@ -62,7 +62,7 @@
</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="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-dialog custom-modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;"> <div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
@@ -74,7 +74,7 @@
<div class="form-group"> <div class="form-group">
<label class="control-label" for="attribute">Item</label> <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>
<div class="form-group"> <div class="form-group">
<label class="control-label" for="attribute">Qty</label> <label class="control-label" for="attribute">Qty</label>
@@ -92,14 +92,88 @@
<div class="form-actions"> <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" 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>
</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 --> <!-- Modal -->
<div class=" modal" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style=""> <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> <button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@@ -250,8 +322,7 @@
+'</div>'; +'</div>';
$('.menu_items_list').append(row); $('.menu_items_list').append(row);
} }
}
}
//click item row for add order //click item row for add order
$(document).on('click', '.card-box', function(event){ $(document).on('click', '.card-box', function(event){
@@ -260,35 +331,64 @@
$("#stock_check_reason").val(''); $("#stock_check_reason").val('');
$('#item_code').val($(this).attr('item_code')); $('#item_code').val($(this).attr('item_code'));
$('#instance_code').val($(this).attr('instance_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')); $('#instance_name').val($(this).attr('instance_name'));
$('#item_name').val($(this).attr('item_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) { if ($("#product_qty").val()>0) {
item_name = $('#item_name').val(); item_name = $('#item_name').val();
instance_name = $('#instance_name').val(); instance_name = $('#instance_name').val();
product_qty = $('#product_qty').val(); qty = $('#product_qty').val();
product_name = $("#item").val(); product_name = $("#item").val();
item_code = $("#item_code").val(); append = 0;
instance_code = $("#instance_code").val(); itemCode = $("#item_code").val();
instanceCode = $("#instance_code").val();
reason = $("#stock_check_reason").val(); reason = $("#stock_check_reason").val();
var rowCount = $('.summary-items tbody tr').length+1; 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+ "'>" $(item_row).each(function(i){
+'<td class="item-cell-no">'+rowCount+'</td>' item_code = $(item_row[i]).attr('data-code');
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + instance_name +'</td>' instance_code = $(item_row[i]).attr('data-instance-code');
+'<td class="item-cell-qty" id="item_qty">' + product_qty + '</td>' r_option = $(item_row[i]).attr('data-opt');
+'<td class="" id="remove"><i class="material-icons" id="remove_row" style="cursor:pointer;">delete_forever</i></td>'
+'</tr>'; if (item_code == itemCode && instance_code == instanceCode) {
$(".summary-items tbody").append(row); 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{ }else{
swal("Opps", "Please enter number for qty ","warning"); 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(){ $("#back").on("click", function(){
window.location.href = "/inventory"; window.location.href = "/inventory";
}); });