fixed confilt
This commit is contained in:
@@ -62,14 +62,14 @@ $(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-instance = '"
|
||||
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instances = '"
|
||||
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(options) +"' data-opt = '"
|
||||
+ JSON.stringify(options) +"' data-image='"+image_path+"'>"
|
||||
+ JSON.stringify(options) +"' data-id = '"+ JSON.stringify(item_attributes) +"' data-opt = '"
|
||||
+ 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;">'+ product[field].unit_price +'</span>'
|
||||
@@ -93,21 +93,21 @@ $(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 = '"
|
||||
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-id = '"+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(options) +"' data-opt = '"
|
||||
+ JSON.stringify(options) +"' data-image=''>"
|
||||
+ JSON.stringify(options) +"' data-image='' data-toggle='modal' data-target='.sx_item_detailModal'>"
|
||||
+'<div class="product_box">'+ product[field].name +'</div>'
|
||||
+'</div>'
|
||||
|
||||
|
||||
+'</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 = '"
|
||||
@@ -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>";
|
||||
});
|
||||
@@ -540,6 +550,90 @@ $(function() {
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('item');
|
||||
instances = $(this).data('instance');
|
||||
item_options = $(this).data('option');
|
||||
data = $(this).parent().siblings('.add_icon');
|
||||
|
||||
show_attribute_selection_modal(attributes, selected_item, instances, item_options, data)
|
||||
|
||||
});
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
|
||||
if($(this).hasClass('product_item')) {
|
||||
$('.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
|
||||
}
|
||||
|
||||
if ($(this).data('instances').length == 1) {
|
||||
|
||||
$('.sx_item_detailModal').modal('hide');
|
||||
|
||||
if ($(this).data('instances')[0].out_of_stock == false ) {
|
||||
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
|
||||
|
||||
} 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');
|
||||
instances = $(this).data('instances');
|
||||
item_options = $(this).data('options');
|
||||
data = $(this)
|
||||
|
||||
show_attribute_selection_modal(attributes, selected_item, instances, item_options, data)
|
||||
}
|
||||
}); //End Add Icon Click
|
||||
|
||||
function show_attribute_selection_modal(attributes, selected_item, instances, item_options, data) {
|
||||
$('.attributes-list').empty();
|
||||
$('.options-list').empty();
|
||||
$('#modal_box_img').empty();
|
||||
@@ -553,19 +647,16 @@ $(function() {
|
||||
$('.add_to_order').removeAttr('data-name');
|
||||
$('.add_to_order').removeAttr('data-attributes');
|
||||
$('.add_to_order').removeAttr('data-options');
|
||||
$('.add_to_order').removeAttr('disabled');
|
||||
$('#minus').removeAttr('disabled');
|
||||
$('#plus').removeAttr('disabled');
|
||||
$('#count').removeAttr('readonly');
|
||||
$('#wanring_text').text('');
|
||||
$('#total_price').text(0.0);
|
||||
|
||||
$('#count').val(1);
|
||||
$('#count').val(1);
|
||||
change_qty_plus_minus("count","plus","minus");
|
||||
|
||||
// data = $(this).parent().children().children('.add_icon');
|
||||
data = $(this).parent().siblings('.add_icon');
|
||||
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
attributes = $(this).data('id');
|
||||
selected_item = $(this).data('item');
|
||||
instances = $(this).data('instance');
|
||||
item_options = $(this).data('option');
|
||||
|
||||
if (data.attr('data-image')) {
|
||||
if (modify_order) {
|
||||
image = "<img id='' width='200px' src='../../"+data.attr('data-image')+"'>";
|
||||
@@ -585,37 +676,39 @@ $(function() {
|
||||
$('#modal_box_img').append(image);
|
||||
|
||||
instance_attributes = []
|
||||
oos_values = ''
|
||||
total_price = 0
|
||||
|
||||
for(var field in instances) {
|
||||
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;
|
||||
$(value).each(function(i){
|
||||
options = value[i];
|
||||
instance_attributes.push(options);
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: '../../api/restaurant/menu_item_attributes/'+value[i],
|
||||
// data: {id:value[i]},
|
||||
// success:function(result){
|
||||
|
||||
// options = result["name"];
|
||||
// instance_attributes.push(options);
|
||||
// }
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
// selected_arr = []
|
||||
// $(selected_item).each(function(i){
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: '../../api/restaurant/menu_item_attributes/'+selected_item[i],
|
||||
// data: {id:selected_item[i]},
|
||||
// success:function(result){
|
||||
// name = result["name"];
|
||||
// selected_arr.push(name);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
selected_item = selected_item.sort()
|
||||
|
||||
if(oos_values) {
|
||||
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"];
|
||||
@@ -625,18 +718,27 @@ $(function() {
|
||||
$(value).each(function(i){
|
||||
disabled = "false";
|
||||
status ="";
|
||||
|
||||
if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
|
||||
status = "selected-attribute";
|
||||
if(JSON.stringify(oos_values) != JSON.stringify(selected_item)) {
|
||||
status = "selected-attribute";
|
||||
total_price = data.attr('data-price')
|
||||
}
|
||||
}
|
||||
|
||||
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||
// disabled = "disabled";
|
||||
}
|
||||
|
||||
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>";
|
||||
});
|
||||
|
||||
$(".attributes-list").append(row);
|
||||
}
|
||||
|
||||
@@ -658,17 +760,21 @@ $(function() {
|
||||
$('#instance_name').text(data.attr('data-instance'));
|
||||
$('#instance_code').text(data.attr('data-instance-code'));
|
||||
$('#promotion_price').text(data.attr('data-promotion-price'));
|
||||
$('#total_price').text(data.attr('data-price'));
|
||||
$('#total_price').text(total_price);
|
||||
$('#unit_price').text(data.attr('data-price'));
|
||||
});
|
||||
}
|
||||
|
||||
// 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){
|
||||
@@ -678,29 +784,118 @@ $(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');
|
||||
|
||||
qty = $('.change_qty').val();
|
||||
|
||||
if($('#total_price').text() > 0) {
|
||||
$('#add_to_order').removeAttr('disabled')
|
||||
$('#total_price').text(0.0)
|
||||
}
|
||||
|
||||
var equal = false;
|
||||
for(var field in instances) {
|
||||
item_attr = instances[field].values;
|
||||
|
||||
item_attr = item_attr.sort()
|
||||
selected_attr = selected_attr.sort()
|
||||
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
||||
unit_price = instances[field].price ;
|
||||
total_price = qty * unit_price ;
|
||||
$('#instance_name').text(instances[field].name);
|
||||
$('#instance_code').text(instances[field].code);
|
||||
$('#promotion_price').text(instances[field].promotion_price);
|
||||
$('#total_price').text(total_price);
|
||||
$('#unit_price').text(unit_price);
|
||||
if (instances[field].out_of_stock) {
|
||||
var text = ''
|
||||
var length = 0
|
||||
for (var i in selected_attr) {
|
||||
length += 1;
|
||||
if (length == selected_attr.length) {
|
||||
text += selected_attr[i]
|
||||
}
|
||||
else {
|
||||
text += selected_attr[i]+'-'
|
||||
}
|
||||
}
|
||||
$('#wanring_text').text('')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is out of stock.')
|
||||
$('#add_to_order').attr('disabled', true)
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
$('#count').attr('readonly', true)
|
||||
return
|
||||
} else {
|
||||
equal = true
|
||||
unit_price = instances[field].price ;
|
||||
total_price = qty * unit_price ;
|
||||
$('#instance_name').text(instances[field].name);
|
||||
$('#instance_code').text(instances[field].code);
|
||||
$('#promotion_price').text(instances[field].promotion_price);
|
||||
$('#total_price').text(total_price);
|
||||
$('#unit_price').text(unit_price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (equal) {
|
||||
$('#wanring_text').text('');
|
||||
$('#add_to_order').removeAttr('disabled');
|
||||
$('#minus').removeAttr('disabled');
|
||||
$('#plus').removeAttr('disabled');
|
||||
$('#count').removeAttr('readonly')
|
||||
} else {
|
||||
var text = ''
|
||||
var length = 0
|
||||
for (var i in selected_attr) {
|
||||
length += 1;
|
||||
if (length == selected_attr.length) {
|
||||
text += selected_attr[i]
|
||||
}
|
||||
else {
|
||||
text += selected_attr[i]+'-'
|
||||
}
|
||||
}
|
||||
$('#wanring_text').text('')
|
||||
$('#wanring_text').append('<strong>' + text + '</strong> is not available.')
|
||||
$('#add_to_order').attr('disabled', true)
|
||||
$('#minus').attr('disabled', true);
|
||||
$('#plus').attr('disabled', true);
|
||||
$('#count').attr('readonly', true)
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click select option icon for add
|
||||
@@ -709,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){
|
||||
@@ -781,14 +975,13 @@ $(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');
|
||||
if (item_row.length>0) {
|
||||
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
|
||||
|
||||
|
||||
for(var field in instances) {
|
||||
|
||||
attrbu = JSON.stringify(attribute_arr);
|
||||
@@ -803,9 +996,9 @@ $(function() {
|
||||
}
|
||||
|
||||
}
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
|
||||
console.log('instances');
|
||||
console.log(attrbu);
|
||||
attribute_arr = attribute_arr.sort()
|
||||
instance_arr = instances[field].values.sort()
|
||||
if (JSON.stringify(attribute_arr) === JSON.stringify(instance_arr)) {
|
||||
$('.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);
|
||||
@@ -833,33 +1026,14 @@ $(function() {
|
||||
console.log(item_data);
|
||||
show_item_detail(item_data,"add_to_order");
|
||||
calculate_sub_total();
|
||||
code = $('#item_code').text()
|
||||
code = $('#instance_code').text()
|
||||
autoScrollToItem(code);
|
||||
|
||||
}); //End add order Click
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
show_item_detail(item_data,"add_icon");
|
||||
calculate_sub_total();
|
||||
autoScrollToItem(code)
|
||||
}
|
||||
|
||||
}); //End Add Icon Click
|
||||
|
||||
// scroll to element
|
||||
function autoScrollToItem(code) {
|
||||
console.log(code)
|
||||
element = $('.summary-items').find(`[data-code='${code}']`);
|
||||
element = $('.summary-items').find(`[data-instance-code='${code}']`);
|
||||
item_qty = element.find('#item_qty').text()
|
||||
parent = element.parents('.card-text')
|
||||
|
||||
@@ -895,12 +1069,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();
|
||||
}
|
||||
|
||||
@@ -962,7 +1134,7 @@ $(function() {
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +''+option_name+'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
+ parseFloat(price * qty).toFixed(2)
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
@@ -1018,7 +1190,8 @@ $(function() {
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (type == "quick_service" || type=="food_court") {
|
||||
window.location.href = "/origami/"+type;
|
||||
module_name = window.location.href.includes('foodcourt') ? 'foodcourt' : 'origami'
|
||||
window.location.href = "/"+module_name+"/"+type;
|
||||
}else{
|
||||
if(table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + table_id;
|
||||
@@ -1097,7 +1270,13 @@ $(function() {
|
||||
});
|
||||
|
||||
}else if(result.data == 'OK'){
|
||||
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
|
||||
if (window.location.pathname.includes('foodcourt')) {
|
||||
order_id = $('#order_id').val()
|
||||
window.location.href = '/foodcourt/food_court/'+order_id+'/request_bill'
|
||||
}
|
||||
else {
|
||||
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
|
||||
}
|
||||
}else{
|
||||
if(result.current_user_role == 'cashier'){
|
||||
window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
@@ -1538,9 +1717,17 @@ $(function() {
|
||||
// price = $("#unit_price").text();
|
||||
// $("#total_price").text(qty*price);
|
||||
// });
|
||||
function truncateString(str, num) {
|
||||
if (str.length <= num) {
|
||||
return str
|
||||
} else {
|
||||
return str.slice(0, num) + '...'
|
||||
}
|
||||
}
|
||||
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) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
@@ -1585,7 +1772,7 @@ $(function() {
|
||||
menu_instances = [];
|
||||
|
||||
$(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);
|
||||
@@ -1603,6 +1790,65 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
pointer_event = 'cursor'
|
||||
opacity = ''
|
||||
status = ''
|
||||
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'
|
||||
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) {
|
||||
price_tag = '<span class="text-danger" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
||||
} else {
|
||||
price_tag ='<span style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
||||
}
|
||||
|
||||
if (menu_items[field].image) {
|
||||
if (modify_order) {
|
||||
@@ -1610,134 +1856,127 @@ $(function() {
|
||||
}else{
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
if (out_of_stock === true) {
|
||||
oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div class="head'+code+'" style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
}else{
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
oos_header = ''
|
||||
}
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3">'
|
||||
+ oos_item + oos_header
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" >'
|
||||
+'<div class="col-md-10 " style="padding:0px !important;">'+ menu_items[field].name +'</div>'
|
||||
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">'
|
||||
+ oos_item
|
||||
+'<div class="custom-card-head card-head row" style="margin:0px; height: 40px; font-size: 0.9em; opacity: '+opacity+'" >'
|
||||
+'<div class="col-md-10 " style="padding:0px !important;">'+ short_name +'</div>'
|
||||
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+"' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='"+ menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-id= '" + JSON.stringify(menu_items[field].attributes) +"'"
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '" + JSON.stringify(menu_items[field].options) +"' "
|
||||
+" 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)+"'"
|
||||
+" 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
|
||||
+ "<div class='offset-4 col-2 "+menu_item_box
|
||||
+ "' data-item-code='" + menu_items[field].code
|
||||
+ "' data-instance='" + JSON.stringify(menu_items[field].instances)
|
||||
+ "' data-id='" + JSON.stringify(menu_items[field].attributes)
|
||||
+ "' data-item='" + JSON.stringify(item_attributes)
|
||||
+ "' data-option='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-opt='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-item-sets='" + JSON.stringify(menu_items[field].item_sets)
|
||||
+ "' data-toggle='modal'"
|
||||
+ " data-target='." + data_target +"'"
|
||||
+ " style='padding:0px 5px 0px 5px; opacity: "+opacity+"; pointer-events: "+pointer_event+";'>"
|
||||
+ "<i class='m-l--5 fa " + fa_plus + "'>"
|
||||
+ add
|
||||
+ "</i>"
|
||||
+'</div>'
|
||||
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
}else{
|
||||
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, 50)
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 m-t-2">'
|
||||
+ oos_item
|
||||
+'<div class="custom-card-no-img-head card-head h-100 '+add_icon+' " id="oos'+ code +'" style="margin:0px;display:flex; opacity: '+opacity+';"'
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+ "data-id= '" + JSON.stringify(menu_items[field].attributes)+"'"
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' 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)+"'>"
|
||||
|
||||
+'<div class="product_box" style="width:100%;"><span>'+ short_name +'<span></div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+"' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 p-b-65 m-r-' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='"+ menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '" + JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='"+image_path+"' "
|
||||
+" data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+""
|
||||
+" 'data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+'<div class="card-footer custom-card-no-img-footer custom-flex-footer" style="height: 50px;">'
|
||||
+ price_tag
|
||||
+" <div class='offset-4 col-2 menu_item_no_img_box "+menu_item_box+" ' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-instance = '" +JSON.stringify(menu_items[field].instances)+"' "
|
||||
+" data-id = '"+JSON.stringify(menu_items[field].attributes)+"' "
|
||||
+" data-item = '" +JSON.stringify(item_attributes)+"' "
|
||||
+" data-option = '"+JSON.stringify(menu_items[field].options)+"'"
|
||||
+" data-opt = '"+JSON.stringify(menu_items[field].options)+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"' "
|
||||
+" data-toggle='modal' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" style='padding:0px 5px 0px 5px; opacity: "+opacity+"; pointer-envents: "+pointer_event+";'>"
|
||||
+"<i class='m-l--5 fa "+fa_plus+"' >"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-footer custom-flex-footer" style="opacity:0.7">'
|
||||
+'<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)
|
||||
+ "' data-option='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-opt='" + JSON.stringify(menu_items[field].options)
|
||||
+ "' data-item-sets='" + JSON.stringify(menu_items[field].item_sets)
|
||||
+ "' data-toggle='modal'"
|
||||
+ " data-target='." + data_target +"'"
|
||||
+ " style='padding:0px 5px 0px 5px' >"
|
||||
+ "<i class='m-l--5 fa " + fa_plus + "'>"
|
||||
+ add
|
||||
+ "</i>"
|
||||
+'</div>'
|
||||
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
}else{
|
||||
if (out_of_stock === true) {
|
||||
// oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%; pointer-events: none;opacity: 0.4;">'
|
||||
oos_header = '<div class="head'+code+'" style="position: absolute;z-index: 5;top: 0;left: 0;right: 0;text-align: center;background: #fb483a;margin: auto;color: #fff;padding: 8px;font-weight: bolder;">OUT OF STOCK</div>'
|
||||
}else{
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight" id="'+ code +'" style="height:100%;">'
|
||||
oos_header = ''
|
||||
}
|
||||
row = '<div class="col-md-6 col-sm-6 col-lg-3 mt-1">'
|
||||
+ oos_item + oos_header
|
||||
+'<div class="custom-card-no-img-head card-head '+add_icon+' " id="oos'+ code +'" style="margin:0px;display:flex;!important "'
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
|
||||
+'<div class="product_box" style="width:100%;"><span>'+ menu_items[field].name +'<span></div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+"' "
|
||||
+" data-item-code='"+ menu_items[field].code +"' "
|
||||
+" data-name='" + menu_items[field].name +"' "
|
||||
+" data-qty = '"+ qty +"' "
|
||||
+" data-price = '" + price +"' "
|
||||
+" data-instance-code = '"+ code +"' "
|
||||
+" data-instance = '" + name +"' "
|
||||
+" data-promotion-price = '"+ promotion_price +"' "
|
||||
+" data-attributes = '" + JSON.stringify(item_attributes) +"' "
|
||||
+" data-options = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-opt = '"+ JSON.stringify(menu_items[field].options) +"' "
|
||||
+" data-image='' data-toggle='"+data_modal+"' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"'"
|
||||
+" data-instances = '"+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
+'</div>'
|
||||
+'<div class="card-footer custom-card-no-img-footer custom-flex-footer">'
|
||||
+'<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)+"' "
|
||||
+" data-option = '"+JSON.stringify(menu_items[field].options)+"'"
|
||||
+" data-opt = '"+JSON.stringify(menu_items[field].options)+"' "
|
||||
+" data-item-sets = '"+JSON.stringify(menu_items[field].item_sets)+"' "
|
||||
+" data-toggle='modal' "
|
||||
+" data-target='."+data_target+"' "
|
||||
+" style='padding:0px 5px 0px 5px'>"
|
||||
+"<i class='m-l--5 fa "+fa_plus+" '>"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
|
||||
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
//end instances in menu-items alest 1 instance
|
||||
}
|
||||
//end is_sub_item false
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
//end instances in menu-items alest 1 instance
|
||||
}
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
$("#add_to_existing_order").on('click', function(e){
|
||||
$(this).attr('disabled', 'disabled');
|
||||
|
||||
@@ -23,6 +23,16 @@ $(document).ready(function() {
|
||||
touchScrollStep : 50
|
||||
});
|
||||
|
||||
$('#foodcourt-table-slimscroll').slimScroll({
|
||||
height: '100%',
|
||||
size: '5px',
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
alwaysVisible: false,
|
||||
borderRadius: '0',
|
||||
railBorderRadius: '0',
|
||||
touchScrollStep : 50
|
||||
});
|
||||
|
||||
$('#foodcourt-order-slimscroll').slimScroll({
|
||||
height: '100%',
|
||||
size: '5px',
|
||||
|
||||
Reference in New Issue
Block a user