add oos to set items
This commit is contained in:
@@ -62,7 +62,7 @@ $(function() {
|
||||
|
||||
+'</div>'
|
||||
|
||||
+"<div class='add_icon p-t-65 p-b-65' data-item-code='"
|
||||
+"<div class='add_icon product_item p-t-65 p-b-65' data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instances = '"
|
||||
@@ -72,7 +72,7 @@ $(function() {
|
||||
+ JSON.stringify(options) +"' data-image='"+image_path+"' data-toggle='modal' data-target='.sx_item_detailModal'>"
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer custom-flex-footer">'
|
||||
+'<span style="font-weight:900;flex-grow:1;"></span>'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ product[field].unit_price +'</span>'
|
||||
+"<div class='offset-4 col-2 menu_item_box' data-item-code='"
|
||||
+ product[field].item_code +"' data-instance = '"
|
||||
+JSON.stringify(item_attributes)+"' data-id = '"
|
||||
@@ -93,7 +93,7 @@ $(function() {
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-1">'
|
||||
+'<div class="card custom-card testimonial-card fadeInRight" style="height:100%;">'
|
||||
+'<div class="custom-card-head custom-card-no-img-head card-head row" style="margin:0px;display:flex;!important">'
|
||||
+"<div class='col-12 add_icon p-t-65 p-b-65' data-item-code='"
|
||||
+"<div class='col-12 add_icon product_item p-t-65 p-b-65' data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
|
||||
@@ -107,7 +107,7 @@ $(function() {
|
||||
|
||||
+'</div>'
|
||||
|
||||
+"<div class='add_icon' data-item-code='"
|
||||
+"<div class='add_icon' product_item data-item-code='"
|
||||
+ product[field].item_code +"' data-name='"
|
||||
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
|
||||
@@ -119,7 +119,7 @@ $(function() {
|
||||
+'</div>'
|
||||
|
||||
+'<div class="card-footer custom-card-no-img-footer custom-flex-footer">'
|
||||
+'<span style="font-weight:900;flex-grow:1;"></span>'
|
||||
+'<span style="font-weight:900;flex-grow:1;">'+ product[field].unit_price +'</span>'
|
||||
+"<div class='offset-4 col-2 menu_item_box menu_item_no_img_box' data-item-code='"
|
||||
+ product[field].item_code +"' data-instance = '"
|
||||
+JSON.stringify(item_attributes)+"' data-id = '"
|
||||
@@ -231,12 +231,12 @@ $(function() {
|
||||
instances = $(this).data('instances');
|
||||
item_options = $(this).data('options');
|
||||
|
||||
|
||||
for(var field in item_sets) {
|
||||
|
||||
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
|
||||
|
||||
value = item_sets[field]["instances"];
|
||||
|
||||
$(value).each(function(i){
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
@@ -247,10 +247,19 @@ $(function() {
|
||||
for(var iii in items) {
|
||||
var result = items[iii]["instances"];
|
||||
for(var v in result) {
|
||||
|
||||
if (value[i]["id"] == result[v]["id"]) {
|
||||
if (result[v].out_of_stock) {
|
||||
price_tag = '<span class="text-danger">out of stock</span>'
|
||||
pointer_event = 'none'
|
||||
opacity = '0.5'
|
||||
}
|
||||
else {
|
||||
price_tag = '<span>'+result[v]["price"]+'</span>'
|
||||
pointer_event = 'cursor'
|
||||
opacity = ''
|
||||
}
|
||||
|
||||
row = '<div class="col-md-4 " >'
|
||||
row = '<div class="col-md-4 " style="pointer-events: '+pointer_event+'; opacity: '+opacity+'">'
|
||||
+"<div class='card custom-card instance_box' data-name='"+result[v]["name"]
|
||||
+"' data-code='"+result[v]["code"]
|
||||
+"' data-price='"+result[v]["price"]
|
||||
@@ -269,7 +278,7 @@ $(function() {
|
||||
+' <small style="float:" id="instance_option"></small>'
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer">'
|
||||
+' <span>'+result[v]["price"]+'</span>'
|
||||
+price_tag
|
||||
// +' <small style="float:right" id="instance_option"></small>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
@@ -362,6 +371,7 @@ $(function() {
|
||||
rowCount = $('.selected-instance');
|
||||
setCount = $('.selected-set');
|
||||
item_options = $(this).data('option');
|
||||
console.log(item_options);
|
||||
|
||||
min_qty = $(this).data('min-qty');
|
||||
max_qty = $(this).data('max-qty');
|
||||
@@ -374,7 +384,7 @@ $(function() {
|
||||
type = item_options[field]["type"];
|
||||
row = "<p style='font-size:16px;margin-bottom:3px'>"+type+"</p>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn-default btn-sm check_option_btn"+ type +"' data-type='"
|
||||
row +="<button class='btn btn-default btn-sm check_option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
|
||||
+value[i]+"</button>";
|
||||
});
|
||||
@@ -553,7 +563,7 @@ $(function() {
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
|
||||
if($(this).find('.product_box')) {
|
||||
if($(this).hasClass('product_item')) {
|
||||
$('.sx_item_detailModal').modal('hide');
|
||||
|
||||
var item_data = $(this);
|
||||
@@ -590,6 +600,28 @@ $(function() {
|
||||
return
|
||||
|
||||
} else {
|
||||
count = 0
|
||||
for (var i in $(this).data('instances')) {
|
||||
if(!$(this).data('instances')[i].out_of_stock) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (count === 1) {
|
||||
$('.sx_item_detailModal').modal('hide');
|
||||
|
||||
var item_data = $(this);
|
||||
code = $(this).data('instance-code');
|
||||
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
|
||||
item = get_item(item_data,"add_icon");
|
||||
customer_display_view(item,"add");
|
||||
}
|
||||
show_item_detail(item_data,"add_icon");
|
||||
calculate_sub_total();
|
||||
autoScrollToItem(code)
|
||||
return
|
||||
}
|
||||
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('attributes');
|
||||
@@ -648,12 +680,17 @@ $(function() {
|
||||
total_price = 0
|
||||
|
||||
for(var field in instances) {
|
||||
if (instances[field].out_of_stock && instances[field].is_default) {
|
||||
if (instances[field].out_of_stock) {
|
||||
oos_values = instances[field].values;
|
||||
$('#add_to_order').attr('disabled', true);
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
$('#count').attr('readonly', true)
|
||||
} else {
|
||||
$('.add_to_order').removeAttr('disabled');
|
||||
$('#minus').removeAttr('disabled');
|
||||
$('#plus').removeAttr('disabled');
|
||||
$('#count').removeAttr('readonly');
|
||||
}
|
||||
|
||||
value = instances[field].values;
|
||||
@@ -669,6 +706,10 @@ $(function() {
|
||||
oos_values = oos_values.sort()
|
||||
}
|
||||
|
||||
if (attributes.length === 0) { // for product_box
|
||||
total_price = data.attr('data-price');
|
||||
}
|
||||
|
||||
for(var field in attributes) {
|
||||
value = attributes[field]["values"];
|
||||
type = attributes[field]["type"]
|
||||
@@ -691,7 +732,9 @@ $(function() {
|
||||
|
||||
row +="<button id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||
+ status +" "+ type +" '"+ disabled +" >"
|
||||
+ status +" "+ type +" '"
|
||||
+ "data-attributes = '"+ JSON.stringify(attributes) +"'"
|
||||
+ disabled +" >"
|
||||
+value[i]
|
||||
+"</button>";
|
||||
});
|
||||
@@ -724,10 +767,14 @@ $(function() {
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
|
||||
$('.attributes-list button').removeClass('bg-gray box-shadow-none');
|
||||
|
||||
// $('.change_qty').val(1);
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
item_attributes = $(this).data('attributes');
|
||||
selected_values = []
|
||||
|
||||
attributes = $(".attribute_btn");
|
||||
$(attributes).each(function(i){
|
||||
@@ -737,10 +784,44 @@ $(function() {
|
||||
});
|
||||
$(this).addClass('selected-attribute');
|
||||
|
||||
// if ($(".attribute_btn").attr("data-type")==type){
|
||||
// $('.'+type).removeClass("selected-attribute");
|
||||
// }
|
||||
// $(this).addClass('selected-attribute');
|
||||
$('button.selected-attribute').each(function(i) {
|
||||
selected_values.push($(this).data('value'));
|
||||
})
|
||||
|
||||
for(var sv in selected_values) {
|
||||
current_type = $('.attributes-list').find(`button[data-value='${selected_values[sv]}']`).data('type')
|
||||
for (var i in item_attributes) {
|
||||
available_btn = []
|
||||
if (item_attributes[i].type != current_type) {
|
||||
for(var j in instances) {
|
||||
if (instances[j].values.includes(selected_values[sv]) && instances[j].out_of_stock == false) {
|
||||
$.map(instances[j].values, function(v) {
|
||||
if (v != selected_values[sv]) {
|
||||
available_btn.push(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if (available_btn.length == 0) {
|
||||
element = $('.attributes-list').find(`button[data-type!='${current_type}']`)
|
||||
$.map(element, function(elem) {
|
||||
if (!$(elem).hasClass('bg-gray')) {
|
||||
$(elem).addClass('bg-gray box-shadow-none');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.map(available_btn, function(btn) {
|
||||
element = $('.attributes-list').find(`button[data-type !='${current_type}'][data-value!='${btn}']`)
|
||||
$.map(element, function(elem) {
|
||||
if (!$(elem).hasClass('bg-gray') && !available_btn.includes($(elem).data('value'))) {
|
||||
$(elem).addClass('bg-gray box-shadow-none')
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var selected_attr = get_selected_attributes('selected-attribute');
|
||||
|
||||
@@ -770,7 +851,7 @@ $(function() {
|
||||
}
|
||||
}
|
||||
$('#wanring_text').text('')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is sold out.')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is out of stock.')
|
||||
$('#add_to_order').attr('disabled', true)
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
@@ -823,7 +904,6 @@ $(function() {
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
console.log(group);
|
||||
options = $(".option_btn");
|
||||
$(options).each(function(i){
|
||||
if ($(options[i]).attr('data-type')==type){
|
||||
@@ -919,8 +999,6 @@ $(function() {
|
||||
attribute_arr = attribute_arr.sort()
|
||||
instance_arr = instances[field].values.sort()
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instance_arr)) {
|
||||
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);
|
||||
@@ -954,7 +1032,6 @@ $(function() {
|
||||
|
||||
// scroll to element
|
||||
function autoScrollToItem(code) {
|
||||
console.log(code)
|
||||
element = $('.summary-items').find(`[data-instance-code='${code}']`);
|
||||
item_qty = element.find('#item_qty').text()
|
||||
parent = element.parents('.card-text')
|
||||
@@ -991,12 +1068,10 @@ $(function() {
|
||||
function isNotInView(elem, parent){
|
||||
// for scroll up | for scroll down
|
||||
result = (($(elem).offset().top - 100) < $(elem).height() || $(parent).height() < (elem.position().top + elem.outerHeight(true)));
|
||||
console.log(result)
|
||||
return result // reutn boolean
|
||||
}
|
||||
|
||||
function scrollToELement(elem) {
|
||||
console.log('Scroll into view')
|
||||
elem[0].scrollIntoView();
|
||||
}
|
||||
|
||||
@@ -1649,8 +1724,8 @@ $(function() {
|
||||
function show_menu_list(menu_items) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
console.log(menu_items);
|
||||
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 ;
|
||||
|
||||
@@ -1693,7 +1768,7 @@ $(function() {
|
||||
add_icon = "add_icon"
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
if (instances[i].is_default === true && !instances[i].out_of_stock) {
|
||||
code = instances[i].code;
|
||||
name = instances[i].name;
|
||||
price = parseFloat(instances[i].price).toFixed(2);
|
||||
@@ -1710,26 +1785,55 @@ $(function() {
|
||||
pointer_event = 'cursor'
|
||||
opacity = ''
|
||||
status = ''
|
||||
if (instances.length == 1) {
|
||||
if (instances[0].out_of_stock == true) {
|
||||
pointer_event = 'none'
|
||||
opacity = '0.5'
|
||||
status = 'out of stock'
|
||||
}
|
||||
} else {
|
||||
count = 0;
|
||||
$(instances).each(function(i) {
|
||||
if (instances[i].out_of_stock == true) {
|
||||
count += 1
|
||||
count = 0;
|
||||
$(instances).each(function(i) {
|
||||
if (instances[i].out_of_stock == true) {
|
||||
count += 1
|
||||
if (instances.length == count) { // all attributes out of stock
|
||||
pointer_event = 'none'
|
||||
status = 'out of stock'
|
||||
|
||||
if (instances.length == count) { // all attributes out of stock
|
||||
pointer_event = 'none'
|
||||
opacity = '0.5'
|
||||
}
|
||||
|
||||
opacity = '0.5'
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
if (JSON.stringify(menu_items[field].item_sets)!='[]') { // check all item_sets out of stock??
|
||||
item_sets = menu_items[field].item_sets
|
||||
oos_count = 0
|
||||
available_count = 0
|
||||
for(var f in item_sets) {
|
||||
value = item_sets[f]["instances"];
|
||||
$(value).each(function(i){
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
var items = categories[ii]["items"];
|
||||
for(var iii in items) {
|
||||
var result = items[iii]["instances"];
|
||||
for(var v in result) {
|
||||
if (value[i]["id"] == result[v]["id"]) {
|
||||
if (result[v].is_available) {
|
||||
available_count += 1
|
||||
if (result[v].out_of_stock) {
|
||||
oos_count += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
if(available_count == oos_count) {
|
||||
pointer_event = 'none'
|
||||
opacity = '0.5'
|
||||
status = 'out of stock'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status) {
|
||||
@@ -1744,7 +1848,7 @@ $(function() {
|
||||
}else{
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height: 100%; pointer-envents: '+pointer_event+';">'
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height: 100%; pointer-events: '+pointer_event+';">'
|
||||
name = menu_items[field].name
|
||||
short_name = truncateString(name, 30)
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 m-t-2">'
|
||||
@@ -1768,9 +1872,10 @@ $(function() {
|
||||
+" data-image='"+image_path+"' "
|
||||
+" data-toggle='modal' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+""
|
||||
+" 'data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+ '<img src = "../../'+image_path+'" class="img-fluid" style="opacity: '+opacity+';"/>'
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'"
|
||||
+" style='height: 80px;'>"
|
||||
+ '<img src = "../../'+image_path+'" class="img-fluid" style="opacity: '+opacity+'; height: 100%; width: 100%;"/>'
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer custom-flex-footer" style="height: 40px;">'
|
||||
+ price_tag
|
||||
|
||||
@@ -27,6 +27,14 @@ table.fixed-header {
|
||||
}
|
||||
}
|
||||
|
||||
.bg-gray {
|
||||
background-color: #D7D7D7;
|
||||
}
|
||||
|
||||
.box-shadow-none {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
font-family: 'Material Icons';
|
||||
font-weight: normal;
|
||||
|
||||
Reference in New Issue
Block a user