fixed out of stock
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -87,7 +87,7 @@ gem 'whenever', :require => false
|
||||
|
||||
# XML parser
|
||||
#gem 'nokogiri', '~> 1.6'
|
||||
|
||||
gem "select2-rails"
|
||||
# Pagination
|
||||
gem 'kaminari', '~> 1.0.1'
|
||||
|
||||
|
||||
19
Gemfile.lock
19
Gemfile.lock
@@ -65,7 +65,7 @@ GEM
|
||||
builder (3.2.4)
|
||||
byebug (11.1.1)
|
||||
cancancan (1.17.0)
|
||||
capistrano (3.12.0)
|
||||
capistrano (3.12.1)
|
||||
airbrussh (>= 1.0.0)
|
||||
i18n
|
||||
rake (>= 10.0.0)
|
||||
@@ -171,7 +171,7 @@ GEM
|
||||
net-ssh (>= 2.6.5, < 6.0.0)
|
||||
net-ssh (5.2.0)
|
||||
nio4r (2.5.2)
|
||||
nokogiri (1.10.8)
|
||||
nokogiri (1.10.9)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
pdf-core (0.7.0)
|
||||
pdfjs_viewer-rails (0.3.1)
|
||||
@@ -187,7 +187,7 @@ GEM
|
||||
rqrcode (>= 1.0.0)
|
||||
prawn-table (0.2.2)
|
||||
prawn (>= 1.3.0, < 3.0.0)
|
||||
puma (3.12.2)
|
||||
puma (3.12.4)
|
||||
rack (2.0.9)
|
||||
rack-cors (1.1.1)
|
||||
rack (>= 2.0.0)
|
||||
@@ -235,13 +235,13 @@ GEM
|
||||
rqrcode_core (0.1.1)
|
||||
rspec-core (3.9.1)
|
||||
rspec-support (~> 3.9.1)
|
||||
rspec-expectations (3.9.0)
|
||||
rspec-expectations (3.9.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
rspec-rails (3.9.1)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
@@ -265,6 +265,8 @@ GEM
|
||||
tilt (>= 1.1, < 3)
|
||||
schema_to_scaffold (0.8.0)
|
||||
activesupport (>= 3.2.1)
|
||||
select2-rails (4.0.3)
|
||||
thor (~> 0.14)
|
||||
shoulda-matchers (3.1.3)
|
||||
activesupport (>= 4.0.0)
|
||||
sidekiq (5.2.8)
|
||||
@@ -288,12 +290,12 @@ GEM
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sshkit (1.20.0)
|
||||
sshkit (1.21.0)
|
||||
net-scp (>= 1.1.2)
|
||||
net-ssh (>= 2.8.0)
|
||||
tether-rails (1.4.0)
|
||||
rails (>= 3.1)
|
||||
thor (1.0.1)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.10)
|
||||
to_xls-rails (1.3.1)
|
||||
@@ -368,6 +370,7 @@ DEPENDENCIES
|
||||
rubyzip (= 1.0.0)
|
||||
sass-rails (~> 5.0)
|
||||
schema_to_scaffold
|
||||
select2-rails
|
||||
shoulda-matchers (~> 3.1)
|
||||
sidekiq
|
||||
simple_form
|
||||
@@ -385,4 +388,4 @@ RUBY VERSION
|
||||
ruby 2.6.5p114
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
2.1.4
|
||||
|
||||
@@ -619,7 +619,7 @@ $(function() {
|
||||
|
||||
for(var field in attributes) {
|
||||
value = attributes[field]["values"];
|
||||
type = attributes[field]["type"]
|
||||
type = attributes[field]["type"];
|
||||
row = "<h5>"+attributes[field]["type"]+"</h5>";
|
||||
|
||||
$(value).each(function(i){
|
||||
@@ -830,6 +830,7 @@ $(function() {
|
||||
item = get_item(item_data,"add_to_order");
|
||||
customer_display_view(item,"add");
|
||||
}
|
||||
console.log(item_data);
|
||||
show_item_detail(item_data,"add_to_order");
|
||||
calculate_sub_total();
|
||||
code = $('#item_code').text()
|
||||
@@ -839,9 +840,10 @@ $(function() {
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
|
||||
if (window.location.pathname != '/settings/out_of_stock/new') {
|
||||
var item_data = $(this);
|
||||
code = $(this).data('item-code');
|
||||
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
|
||||
item = get_item(item_data,"add_icon");
|
||||
customer_display_view(item,"add");
|
||||
@@ -850,6 +852,8 @@ $(function() {
|
||||
show_item_detail(item_data,"add_icon");
|
||||
calculate_sub_total();
|
||||
autoScrollToItem(code)
|
||||
}
|
||||
|
||||
}); //End Add Icon Click
|
||||
|
||||
// scroll to element
|
||||
@@ -1270,6 +1274,8 @@ $(function() {
|
||||
}else{
|
||||
window.location.href = "/origami/dashboard";
|
||||
}
|
||||
}else if(window.location.href.incluses("out_of_stock")){
|
||||
window.location.href = '/settings/out_of_stock';
|
||||
}else{
|
||||
var table_type = $('#table_type').text();
|
||||
var table_id = $('#table_id').text();
|
||||
@@ -1536,7 +1542,6 @@ $(function() {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
for(var field in menu_items) {
|
||||
console.log(menu_items[field].instances);
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
|
||||
@@ -1577,6 +1582,7 @@ $(function() {
|
||||
data_target = 'sx_item_detailModal';
|
||||
data_modal = ''
|
||||
add_icon = "add_icon"
|
||||
menu_instances = [];
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
@@ -1589,6 +1595,10 @@ $(function() {
|
||||
promotion_price = instances[i].promotion_price;
|
||||
code = instances[i].code;
|
||||
out_of_stock = instances[i].out_of_stock;
|
||||
menu_insta = [code,name,item_attributes];
|
||||
}
|
||||
if(instances[i].out_of_stock === false){
|
||||
menu_instances.push(menu_insta);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1635,6 +1645,7 @@ $(function() {
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ price +'</span>'
|
||||
+ "<div class='offset-4 col-2 "+menu_item_box
|
||||
+ "' data-item-code='" + menu_items[field].code
|
||||
+ "' data-menu-instances='" + JSON.stringify(menu_instances)
|
||||
+ "' data-instance='" + JSON.stringify(menu_items[field].instances)
|
||||
+ "' data-id='" + JSON.stringify(menu_items[field].attributes)
|
||||
+ "' data-item='" + JSON.stringify(item_attributes)
|
||||
@@ -1700,6 +1711,7 @@ $(function() {
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ price + '</span>'
|
||||
+" <div class='offset-4 col-2 menu_item_no_img_box "+menu_item_box+" ' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-menu-instances = '" +JSON.stringify(menu_instances)+"' "
|
||||
+" data-instance = '" +JSON.stringify(menu_items[field].instances)+"' "
|
||||
+" data-id = '"+JSON.stringify(menu_items[field].attributes)+"' "
|
||||
+" data-item = '" +JSON.stringify(item_attributes)+"' "
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
//= require custom.js
|
||||
//= require jquery-fileupload/basic
|
||||
//= require induties/induties.js
|
||||
//= require select2
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.count-to').countTo();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
@import "BSBMaterial/themes/all-themes";
|
||||
@import "reset";
|
||||
@import "induties/assign_in_duties";
|
||||
@import "select2";
|
||||
|
||||
/*@import "bootstrap-select/css/bootstrap-select.min";*/
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ class Api::Restaurant::OutOfStockController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def index
|
||||
date = params[:date]
|
||||
@out_of_stock = OutOfStock.where("DATE(date) = ?", date)
|
||||
@out_of_stock = MenuItem.joins(:menu_item_instances).where(menu_item_instances: {is_out_of_stock: true}).select('menu_item_instances.id, menu_item_instances.item_instance_code, menu_item_instances.item_instance_name, menu_items.name, menu_item_instances.is_out_of_stock')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,6 +33,7 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
id = MenuItemInstance.findParentCategory(@item)
|
||||
@category = MenuCategory.find(id)
|
||||
@item_sets = ItemSet.all
|
||||
@menu_item_instance = MenuItemInstance.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /settings/menu_item_instances
|
||||
@@ -65,7 +66,7 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_instances.save
|
||||
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split(" ")
|
||||
@settings_menu_item_instances.item_attributes = JSON.parse params[:menu_item_instance][:item_attributes]
|
||||
@settings_menu_item_instances.save
|
||||
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item_instances }
|
||||
@@ -106,7 +107,7 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
|
||||
#@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
|
||||
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split(" ")
|
||||
@settings_menu_item_instances.item_attributes = JSON.parse params[:menu_item_instance][:item_attributes]
|
||||
@settings_menu_item_instances.save
|
||||
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item_instances }
|
||||
@@ -155,7 +156,7 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
end
|
||||
|
||||
# To Only show in Menu item selected attrs
|
||||
@item.item_attributes = MenuItemAttribute.where(id: @item.item_attributes).select("id, name").map { |e| [e.name, e.id] }
|
||||
@item.item_attributes = MenuItemAttribute.where(id: @item.item_attributes).select("id, name, attribute_type").group_by(&:attribute_type)
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Settings::OutOfStockController < ApplicationController
|
||||
def index
|
||||
@menu_items = MenuItem.joins(:menu_item_instances).where(menu_item_instances: {is_out_of_stock: true}).select('menu_item_instances.id, menu_item_instances.item_instance_code, menu_items.name, menu_item_instances.is_out_of_stock')
|
||||
@menu_items = MenuItem.joins(:menu_item_instances).where(menu_item_instances: {is_out_of_stock: true}).select('menu_item_instances.id, menu_item_instances.item_instance_code, menu_item_instances.item_instance_name, menu_items.name, menu_item_instances.is_out_of_stock, menu_item_instances.item_attributes')
|
||||
end
|
||||
|
||||
def show
|
||||
@@ -26,7 +26,7 @@ class Settings::OutOfStockController < ApplicationController
|
||||
if !item_instance.first.is_out_of_stock?
|
||||
item_instance.update(is_out_of_stock: true)
|
||||
items_arr.each do |i|
|
||||
OutOfStock.create_out_of_stock(date,i)
|
||||
# OutOfStock.create_out_of_stock(date,i)
|
||||
ActionCable.server.broadcast "out_of_stock_channel", item_instance_code: i, status: true
|
||||
end
|
||||
elsif item_instance.first.is_out_of_stock?
|
||||
@@ -43,7 +43,7 @@ class Settings::OutOfStockController < ApplicationController
|
||||
unless item_instance.nil?
|
||||
item_instance.update(is_out_of_stock: false)
|
||||
ActionCable.server.broadcast "out_of_stock_channel", item_instance_code: item_instance.item_instance_code, status: false
|
||||
OutOfStock.where(item_instance_code: item_instance.item_instance_code, created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).destroy_all
|
||||
# OutOfStock.where(item_instance_code: item_instance.item_instance_code, created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).destroy_all
|
||||
flash[:message] = 'Out of stock was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => settings_out_of_stock_index_url }.to_json
|
||||
end
|
||||
@@ -55,7 +55,7 @@ class Settings::OutOfStockController < ApplicationController
|
||||
item_instance.update(is_out_of_stock: false)
|
||||
item_instance.each do |i|
|
||||
ActionCable.server.broadcast "out_of_stock_channel", item_instance_code: i.item_instance_code, status: false
|
||||
OutOfStock.where(item_instance_code: i.item_instance_code, created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).destroy_all
|
||||
# OutOfStock.where(item_instance_code: i.item_instance_code, created_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).destroy_all
|
||||
end
|
||||
flash[:message] = 'Out of stock was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => settings_out_of_stock_index_url }.to_json
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class OutOfStock < ApplicationRecord
|
||||
def self.create_out_of_stock(date,item_instance_code)
|
||||
OutOfStock.create(
|
||||
date: date,
|
||||
item_instance_code: item_instance_code
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
out_of_stock_json = json.array! @out_of_stock do |oos|
|
||||
json.date oos.date
|
||||
json.status true
|
||||
json.data @out_of_stock do |oos|
|
||||
json.item_instance_code oos.item_instance_code
|
||||
end
|
||||
|
||||
@@ -349,7 +349,7 @@
|
||||
<h4 class="modal-title" style="color:#fff;" id="set_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" id="set-menu-item-slimscroll" data-height="50">
|
||||
<div class="modal-body" data-height="50">
|
||||
<div class="row set-item">
|
||||
<div class="col-md-4">
|
||||
<p class="set_default_option" style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
<%= f.input :item_instance_name %>
|
||||
<%= f.input :price %>
|
||||
|
||||
<%= f.input :item_attributes, collection: @item.item_attributes, include_blank: false, include_hidden: false%>
|
||||
<% @item.item_attributes.each do |type, value| %>
|
||||
<%= f.input :attributes, :label => type, :collection => value.map {|v| [v['name'], v['id']]}, :include_blank => false, :input_html => {:class => "form-control item_sets #{type}"} %>
|
||||
<% end %>
|
||||
<%= f.input :item_attributes, :as => :hidden, :input_html => { :value => '', :id => "attr_type" } %>
|
||||
|
||||
<%= f.input :is_on_promotion %>
|
||||
<%= f.input :promotion_price %>
|
||||
@@ -72,3 +75,36 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
attr_type = <%= raw @item.item_attributes.to_json %>;
|
||||
attr_id = [];
|
||||
if (window.location.pathname.includes('edit')){
|
||||
item_attributes = <%= raw @menu_item_instance.item_attributes.to_json %>
|
||||
$.each(item_attributes, function (key, value){
|
||||
$.each(attr_type, function(k, v) {
|
||||
$('.' + k + ' > option').each(function(){
|
||||
if ($(this).val() == value ) {
|
||||
$(this).prop("selected",true)
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
set_option(attr_type);
|
||||
$('.item_sets').change(function() {
|
||||
attr_id = [];
|
||||
set_option(attr_type);
|
||||
});
|
||||
|
||||
function set_option(attr_type){
|
||||
$.each(attr_type, function(k, v) {
|
||||
option = $('.' + k + ' option:selected').val();
|
||||
console.log(option);
|
||||
attr_id.push(option);
|
||||
});
|
||||
$('#attr_type').val(JSON.stringify(attr_id));
|
||||
};
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1 +1,13 @@
|
||||
<%= render 'form', settings_simple_menu_item_menu_item_instances: @settings_menu_item_instances, item_sets: @item_sets %>
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
attr_type = <%= raw @item.item_attributes.to_json %>;
|
||||
attr_id = [];
|
||||
$.each(attr_type, function(k, v) {
|
||||
option = $('.' + k + ' option:selected').val();
|
||||
attr_id.push(option);
|
||||
});
|
||||
$('#attr_type').val(JSON.stringify(attr_id));
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
<%= javascript_include_tag 'addorder', '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>
|
||||
@@ -106,7 +106,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-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
@@ -114,19 +114,24 @@
|
||||
<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="row no-set-item">
|
||||
<div class="col-md-5">
|
||||
<p style="text-align: center;" id="modal_box_img"></p>
|
||||
</div>
|
||||
<div class="col-md-7 item-detail">
|
||||
<div class="form-inputs">
|
||||
|
||||
<div class="form-group">
|
||||
<!-- <input type="hidden" name="item_code" id="instance_code">
|
||||
<input type="hidden" name="instance_name" id="instance_name"> -->
|
||||
<div class="form-group">
|
||||
<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">
|
||||
<div class='instance-label' style='margin-bottom: 8px;'>
|
||||
<label class="control-label" for="attribute">Instances</label>
|
||||
<div class="attributes-list col-md-6"></div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="attributes-list col-md-6"></div> -->
|
||||
<select class="form-control" name="item_instance" id="instance_select" multiple="multiple"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,7 +147,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<style type="text/css">
|
||||
.fadeInRight{
|
||||
-webkit-animation-duration: 350ms !important;
|
||||
@@ -155,7 +160,6 @@
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
var id = menus[0]["categories"][0]["id"];
|
||||
// console.log(id);
|
||||
}else{
|
||||
var id = 1;
|
||||
}
|
||||
@@ -202,10 +206,8 @@
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -332,6 +334,66 @@
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_sub_category_list(url,sub_category,menu_id){
|
||||
|
||||
var sub_category_list = $('.sub_category_list');
|
||||
sub_category_list.empty();
|
||||
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
if (menu_id == categories[ii]["parent_id"]) {
|
||||
$(sub_category).removeClass('hidden');
|
||||
row = '<li class="menu_sub_category fadeInTop" data-id="'+categories[ii].id+'">'
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ categories[ii].name+'</a>'
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (type != -1 && modify_order != -1) {
|
||||
var url = "../../../addorders/"+url;
|
||||
}if(modify_order== -1 && type != -1){
|
||||
var url = 'addorders/'+url;
|
||||
}
|
||||
if (type ==-1 && modify_order == -1){
|
||||
var url = url;
|
||||
}
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var sub_category_list = $('.sub_category_list');
|
||||
sub_category_list.empty();
|
||||
data = data.sub_category;
|
||||
if (data.length > 0) {
|
||||
// if ((sub_category.hasClass('hidden'))) {
|
||||
$(sub_category).removeClass('hidden');
|
||||
// }else{
|
||||
// $(sub_category).addClass('hidden');
|
||||
// }
|
||||
for(var i in data) {
|
||||
|
||||
row = '<li class="menu_sub_category fadeInTop" data-id="'+data[i].id+'">'
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ data[i].name+'</a>'
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
}
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
var menu_list = $('.menu_items_list');
|
||||
@@ -386,8 +448,9 @@
|
||||
add = 'view_list'
|
||||
menu_item_box = 'menu_item_box';
|
||||
data_target = 'sx_item_detailModal';
|
||||
data_modal = ''
|
||||
data_modal = 'modal'
|
||||
add_icon = "add_icon"
|
||||
menu_instances = [];
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
@@ -401,6 +464,7 @@
|
||||
code = instances[i].code;
|
||||
out_of_stock = instances[i].out_of_stock;
|
||||
}
|
||||
menu_instances.push(item_attributes);
|
||||
});
|
||||
|
||||
if (menu_items[field].image) {
|
||||
@@ -464,53 +528,36 @@
|
||||
}
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.card-box', function(event){
|
||||
|
||||
// item_data = $(this).children().siblings('.add_icon');
|
||||
var disable_item = $(this);
|
||||
var item_data = $(this).children().last();
|
||||
item_instance_name = item_data.attr('data-name');
|
||||
item_instance_code = item_data.attr('data-instance-code');
|
||||
|
||||
instance_attributes = []
|
||||
for(var field in instances) {
|
||||
value = instances[field].values;
|
||||
$(value).each(function(i){
|
||||
options = value[i];
|
||||
instance_attributes.push(options);
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
});
|
||||
}
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$('#instance_select').empty();
|
||||
$('#instance_select').select2({placeholder: "Select Instance"});
|
||||
$('#instance_select').on('select2:select', function(e){
|
||||
$(this).select2('open');
|
||||
});
|
||||
var instances = $(this).data('menu-instances');
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
$(item_row).each(function(i){
|
||||
item_name = $(item_row[i]).attr('data-item-name');
|
||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
|
||||
if (item_name == item_data.attr('data-name') && instance_code == item_data.attr('data-instance-code')) {
|
||||
|
||||
}else{
|
||||
|
||||
if(item_row.length > 0){
|
||||
$(instances).each(function(i){
|
||||
var append = 0;
|
||||
if (instances[i][1] != ""){ instance_name = instances[i][1]; }else{ instance_name = instances[i][2][0]; };
|
||||
$(item_row).each(function(e){
|
||||
instance_code = $(item_row[e]).attr('data-instance-code');
|
||||
if(instances[i][0] == instance_code){
|
||||
append = 1;
|
||||
}
|
||||
});
|
||||
if(append == 0){
|
||||
$('#instance_select').append('<option class="instance_name"' + 'id=' + instances[i][0] + ' value=' + instances[i][0] + '>' + instance_name + '</option>');
|
||||
}
|
||||
});
|
||||
|
||||
row ="<tr class='item_box' data-instance-code='"
|
||||
+item_data.attr('data-instance-code')+"' data-item-name='"
|
||||
+item_data.attr('data-name')+"' data-row='"
|
||||
+rowCount+"'>"
|
||||
+'<td class="">'+rowCount+'</td>'
|
||||
+'<td class="hidden" id="item_instance_code">' + item_instance_code +'</td>'
|
||||
+'<td class="">' + item_instance_name +'</td>'
|
||||
+"<td class='delete_item'> <i class='material-icons' style='cursor: pointer;'>delete</i> </td>"
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
$(disable_item).css({"pointer-events": "none", "opacity": "0.4"});
|
||||
|
||||
if ($('.summary-items tbody tr').length > 0) {
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}else{
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
$(instances).each(function(i){
|
||||
if (instances[i][1] != ""){ instance_name = instances[i][1]; }else{ instance_name = instances[i][2][0]; };
|
||||
$('#instance_select').append('<option class="instance_name"' + 'id=' + instances[i][0] + ' value=' + instances[i][0] + '>' + instance_name + '</option>');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -522,6 +569,11 @@
|
||||
tmp.appendTo(item.parent());
|
||||
enable_item = $("div:contains("+item_name+")");
|
||||
$(enable_item).css({"pointer-events": "", "opacity": ""});
|
||||
if ($('.summary-items tbody tr').length == 0) {
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
}else{
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#clear_all', function(event){
|
||||
@@ -637,7 +689,6 @@
|
||||
}else{
|
||||
$('#modal-qty').val(original_qty + input_value);
|
||||
$('#modal-qty').attr('data-value',original_qty + input_value);
|
||||
// update_total_amount();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
@@ -659,40 +710,66 @@
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.submit', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
qty = parseInt($('#count').val());
|
||||
|
||||
var item_code = $("#instance_code").val();
|
||||
var min_qty = $("#min_qty").val();
|
||||
var max_qty = $("#max_qty").val();
|
||||
var item_name = $("#item_name").val();
|
||||
var item_row = $('.selected-attribute');
|
||||
attribute_arr = get_selected_attributes('selected-attribute');
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
|
||||
data = $("#instance_select").select2('data');
|
||||
if (data != null){
|
||||
instance_code = data[0].id;
|
||||
instance_name = data[0].text;
|
||||
code_name = [instance_code,instance_name];
|
||||
}
|
||||
|
||||
$('.submit').attr('data-item-code',$('#item_code').text());
|
||||
$('.submit').attr('data-instance-arr',JSON.stringify(data));
|
||||
$('.submit').attr('data-name',$('#title_name').text());
|
||||
$('.submit').attr('data-attributes',JSON.stringify(attribute_arr));
|
||||
$('.submit').attr('data-options',JSON.stringify(option_arr));
|
||||
$('.submit').attr('data-opt',JSON.stringify(option_arr));
|
||||
var item_data = $(this);
|
||||
show_item_detail(item_data,"add_to_order");
|
||||
});
|
||||
|
||||
function show_item_detail(data,click_type){
|
||||
testqty = parseInt($('.item_box').children('data_qty').text());
|
||||
qty = parseInt(data.attr('data-qty'));
|
||||
append = 0;
|
||||
price = data.attr('data-price');
|
||||
instance_name = data.attr('data-instance');
|
||||
instance_arr = JSON.parse(data.attr('data-instance-arr'));
|
||||
|
||||
for(var i in instance_arr){
|
||||
if (instance_name == "undefined"){
|
||||
instance = '';
|
||||
}else{
|
||||
instance = "("+instance_arr[i].text+")";
|
||||
}
|
||||
|
||||
console.log(item_code);
|
||||
console.log(min_qty);
|
||||
console.log(max_qty);
|
||||
var params = {'item_code': item_code};
|
||||
var ajax_url = 'settings_update_menu_items_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 ="<tr class=''>"
|
||||
+'<td class="">'+rowCount+'</td>'
|
||||
+'<td class="hidden" id="itemCodeee">' + item_code +'</td>'
|
||||
+'<td class="">' + item_name +'</td>'
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ " 'data-toggle='modal' data-target='#sx_itemModal' data-instance ='"
|
||||
+instance+ "' data-qty='"+qty +"' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+instance_arr[i].id+"' data-attributes='"
|
||||
+data.attr('data-attributes')
|
||||
+"' data-row ='"+rowCount+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +'</td>'
|
||||
+"<td class='delete_item'> <i class='material-icons' style='cursor: pointer;'>delete</i> </td>"
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
swal("Success",result.message,"success");
|
||||
}
|
||||
if ($('.summary-items tbody tr').length == 0) {
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
// +'<td class="" onClick="remove()"><i class="material-icons"style="cursor: pointer;">delete_forever</i></td>'
|
||||
});
|
||||
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/settings/out_of_stock';
|
||||
@@ -700,38 +777,4 @@
|
||||
$('#stock_taking').on('click', function () {
|
||||
window.location.href = '/inventory/stock_checks';
|
||||
});
|
||||
|
||||
// });
|
||||
|
||||
// $('.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>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.instance_name") %></th>
|
||||
<th><%= t("views.right_panel.detail.atrribute_name") %></th>
|
||||
<th><%= t("views.right_panel.detail.status") %></th>
|
||||
<th><%= t("views.right_panel.detail.action") %></th>
|
||||
</tr>
|
||||
@@ -14,6 +16,12 @@
|
||||
|
||||
<tr>
|
||||
<td><%= item.name rescue '-' %></td>
|
||||
<% if !item.item_instance_name.blank? %>
|
||||
<td><%= item.item_instance_name rescue '-' %></td>
|
||||
<% else %>
|
||||
<td><p style="font-size: 20px;">-</p></td>
|
||||
<% end %>
|
||||
<td><%= JSON.parse(MenuItemAttribute.where(id: item.item_attributes).pluck(:name).to_s).join(', ') %></td>
|
||||
<td>
|
||||
<% if item.is_out_of_stock %>
|
||||
<div class="badge badge-success">Active</div>
|
||||
|
||||
@@ -30,8 +30,26 @@
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function (){
|
||||
getAllMenu();
|
||||
});
|
||||
|
||||
$('#new_out_of_stock').on('click',function(){
|
||||
window.location.href = '/settings/out_of_stock/new';
|
||||
});
|
||||
|
||||
function getAllMenu(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/foodcourt/get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
if (result != null ) {
|
||||
var menus = JSON.stringify(result);
|
||||
localStorage.setItem("menus", menus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
9
db/migrate/20200319113930_drop_out_of_stock_table.rb
Normal file
9
db/migrate/20200319113930_drop_out_of_stock_table.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class DropOutOfStockTable < ActiveRecord::Migration[5.1]
|
||||
def up
|
||||
drop_table :out_of_stocks
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -129,10 +129,6 @@ delete from sym_node;
|
||||
(trigger_id,source_table_name,channel_id,last_update_time,create_time)
|
||||
values('display_images','display_images','setting',current_timestamp,current_timestamp);
|
||||
|
||||
insert into sym_trigger
|
||||
(trigger_id,source_table_name,channel_id,last_update_time,create_time)
|
||||
values('out_of_stocks','out_of_stocks','setting',current_timestamp,current_timestamp);
|
||||
|
||||
# Create Trigger for Dining Channel
|
||||
|
||||
insert into sym_trigger
|
||||
@@ -401,10 +397,6 @@ delete from sym_node;
|
||||
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
|
||||
values('display_images','cloud_2_sx', 100, current_timestamp, current_timestamp);
|
||||
|
||||
insert into sym_trigger_router
|
||||
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
|
||||
values('out_of_stocks','cloud_2_sx', 100, current_timestamp, current_timestamp);
|
||||
|
||||
# Setting Channel # From Master to cloud
|
||||
|
||||
insert into sym_trigger_router
|
||||
@@ -447,10 +439,6 @@ delete from sym_node;
|
||||
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
|
||||
values('display_images','sx_2_cloud', 100, current_timestamp, current_timestamp);
|
||||
|
||||
insert into sym_trigger_router
|
||||
(trigger_id,router_id,initial_load_order,last_update_time,create_time)
|
||||
values('out_of_stocks','sx_2_cloud', 100, current_timestamp, current_timestamp);
|
||||
|
||||
#End Setting Channel
|
||||
|
||||
# Dining Channel # From cloud to SX
|
||||
|
||||
Reference in New Issue
Block a user