fixed out of stock
This commit is contained in:
@@ -23,16 +23,13 @@ class Settings::OutOfStockController < ApplicationController
|
|||||||
date = DateTime.now
|
date = DateTime.now
|
||||||
|
|
||||||
unless item_instance.nil?
|
unless item_instance.nil?
|
||||||
item_instance.each do |i|
|
if !item_instance.first.is_out_of_stock?
|
||||||
if i.is_out_of_stock.nil?
|
item_instance.update(is_out_of_stock: true)
|
||||||
item_instance.update(is_out_of_stock: true)
|
items_arr.each do |i|
|
||||||
OutOfStock.create_out_of_stock(date,params[:item_code])
|
OutOfStock.create_out_of_stock(date,i)
|
||||||
elsif i.is_out_of_stock?
|
|
||||||
item_instance.update(is_out_of_stock: false)
|
|
||||||
elsif !i.is_out_of_stock?
|
|
||||||
item_instance.update(is_out_of_stock: true)
|
|
||||||
OutOfStock.create_out_of_stock(date,params[:item_code])
|
|
||||||
end
|
end
|
||||||
|
elsif item_instance.first.is_out_of_stock?
|
||||||
|
item_instance.update(is_out_of_stock: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-3 col-md-3 col-sm-3" >
|
<div class="col-lg-3 col-md-3 col-sm-3 item-wrapper" >
|
||||||
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
|
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back' style="width: 75%;">
|
||||||
<i class="material-icons">reply</i>Back
|
<i class="material-icons">reply</i>Back
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="btn btn-xs btn-danger waves-effect" id='clear_all' style="width: 23%; padding: 10px; margin-top: 5px;">Clear</button>
|
||||||
|
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||||
@@ -87,7 +88,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> -->
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="font-13" >
|
<tbody class="font-13" >
|
||||||
@@ -162,6 +163,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$("#add_out_of_stock").attr("disabled","disabled");
|
||||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||||
if (menus != null) {
|
if (menus != null) {
|
||||||
menu_cache_append(menus);
|
menu_cache_append(menus);
|
||||||
@@ -470,19 +472,6 @@
|
|||||||
item_instance_name = item_data.attr('data-name');
|
item_instance_name = item_data.attr('data-name');
|
||||||
item_instance_code = item_data.attr('data-instance-code');
|
item_instance_code = item_data.attr('data-instance-code');
|
||||||
|
|
||||||
// $('#item_code').val(item_data.attr('data-item-code'));
|
|
||||||
// $('#item_name').val(item_data.attr('data-name'));
|
|
||||||
// $('#instance_code').val(item_data.attr('data-instance-code'));
|
|
||||||
|
|
||||||
// $('.attributes-list').empty();
|
|
||||||
|
|
||||||
// data = $(this).children().children('.menu_item_box');
|
|
||||||
// data = $(this).parent().siblings('.add_icon');
|
|
||||||
|
|
||||||
// attributes = $(data).data('id');
|
|
||||||
// selected_item = $(data).data('item');
|
|
||||||
// instances = $(data).data('instance');
|
|
||||||
|
|
||||||
instance_attributes = []
|
instance_attributes = []
|
||||||
for(var field in instances) {
|
for(var field in instances) {
|
||||||
value = instances[field].values;
|
value = instances[field].values;
|
||||||
@@ -498,7 +487,6 @@
|
|||||||
$(item_row).each(function(i){
|
$(item_row).each(function(i){
|
||||||
item_name = $(item_row[i]).attr('data-item-name');
|
item_name = $(item_row[i]).attr('data-item-name');
|
||||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||||
r_option = $(item_row[i]).attr('data-opt');
|
|
||||||
|
|
||||||
if (item_name == item_data.attr('data-name') && instance_code == item_data.attr('data-instance-code')) {
|
if (item_name == item_data.attr('data-name') && instance_code == item_data.attr('data-instance-code')) {
|
||||||
|
|
||||||
@@ -514,39 +502,37 @@
|
|||||||
+'<td class="">'+rowCount+'</td>'
|
+'<td class="">'+rowCount+'</td>'
|
||||||
+'<td class="hidden" id="item_instance_code">' + item_instance_code +'</td>'
|
+'<td class="hidden" id="item_instance_code">' + item_instance_code +'</td>'
|
||||||
+'<td class="">' + item_instance_name +'</td>'
|
+'<td class="">' + item_instance_name +'</td>'
|
||||||
|
+"<td class='delete_item'> <i class='material-icons' style='cursor: pointer;'>delete</i> </td>"
|
||||||
+'</tr>';
|
+'</tr>';
|
||||||
$(".summary-items tbody").append(row);
|
$(".summary-items tbody").append(row);
|
||||||
$(disable_item).css({"pointer-events": "none", "opacity": "0.4"});
|
$(disable_item).css({"pointer-events": "none", "opacity": "0.4"});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($('.summary-items tbody tr').length > 0) {
|
if ($('.summary-items tbody tr').length > 0) {
|
||||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||||
}else{
|
}else{
|
||||||
$('#add_out_of_stock').attr("disabled", true);
|
$('#add_out_of_stock').attr("disabled", true);
|
||||||
}
|
}
|
||||||
// for(var field in attributes) {
|
});
|
||||||
// value = attributes[field]["values"];
|
|
||||||
// type = attributes[field]["type"]
|
$(document).on('click', '.delete_item', function(event){
|
||||||
// row = "";
|
item = $(this).parent('.item_box');
|
||||||
//
|
item_name = item.attr('data-item-name');
|
||||||
// $(value).each(function(i){
|
tmp = item.children().clone();
|
||||||
// disabled = ""
|
item.remove();
|
||||||
// status ="";
|
tmp.appendTo(item.parent());
|
||||||
// if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
|
enable_item = $("div:contains("+item_name+")");
|
||||||
// status = "selected-attribute";
|
$(enable_item).css({"pointer-events": "", "opacity": ""});
|
||||||
// }
|
});
|
||||||
// if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
|
||||||
// disabled = "disabled";
|
$(document).on('click', '#clear_all', function(event){
|
||||||
// }
|
item_row = $(".summary-items tbody tr");
|
||||||
// row +="<button type='button' id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
$(item_row).each(function(i){
|
||||||
// +type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
item_name = $(item_row[i]).attr('data-item-name');
|
||||||
// + status +" "+ type +" '"+ disabled +" >"
|
enable_item = $("div:contains("+item_name+")");
|
||||||
// +value[i]
|
$(enable_item).css({"pointer-events": "", "opacity": ""});
|
||||||
// +"</button>";
|
});
|
||||||
// });
|
$(".summary-items tbody").empty();
|
||||||
// $(".attributes-list").append(row);
|
$("#add_out_of_stock").attr("disabled","disabled");
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#add_out_of_stock').on('click', function () {
|
$('#add_out_of_stock').on('click', function () {
|
||||||
@@ -564,11 +550,20 @@
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
success:function(result){
|
success:function(result){
|
||||||
if (result.status) {
|
if (result.status) {
|
||||||
swal("Success",result.message,"success");
|
setTimeout(function() {
|
||||||
|
swal({
|
||||||
|
title: "Success",
|
||||||
|
text: result.message,
|
||||||
|
type: "success"
|
||||||
|
}, function() {
|
||||||
|
window.location = "/settings/out_of_stock";
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
}else{
|
}else{
|
||||||
swal("Opps",result.message,"warning");
|
swal("Opps",result.message,"warning");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function get_order_item_rows(){
|
function get_order_item_rows(){
|
||||||
@@ -706,7 +701,7 @@
|
|||||||
window.location.href = '/inventory/stock_checks';
|
window.location.href = '/inventory/stock_checks';
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
// });
|
||||||
|
|
||||||
// $('.remove_row').on('click', function(){
|
// $('.remove_row').on('click', function(){
|
||||||
// window.location.href = '/inventory';
|
// window.location.href = '/inventory';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6" style="padding-right: 15px;">
|
<div class="col-lg-6 col-md-6 col-sm-6" style="padding-right: 15px;">
|
||||||
<button type="button" class="delete btn btn-danger btn-sm float-right waves-effect" style='margin-left:5px;' data-ref="<%= settings_reset_all_path %>" data-method="delete">
|
<button type="button" id="reset_all" class="delete btn btn-danger btn-sm float-right waves-effect" style='margin-left:5px;' data-ref="<%= settings_reset_all_path %>" data-method="delete">
|
||||||
<%= t("views.btn.reset_all") %>
|
<%= t("views.btn.reset_all") %>
|
||||||
</button>
|
</button>
|
||||||
<button id='new_out_of_stock' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :new_out_of_stock) +" " %> <%= t("views.right_panel.detail.item") %></button>
|
<button id='new_out_of_stock' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :new_out_of_stock) +" " %> <%= t("views.right_panel.detail.item") %></button>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1]
|
class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1]
|
||||||
def change
|
def change
|
||||||
add_column :menu_item_instances, :is_out_of_stock, :boolean
|
add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user