modify out of stock channel
This commit is contained in:
@@ -562,51 +562,9 @@ $(function() {
|
||||
// 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) {
|
||||
if (window.location.pathname.includes('out_of_stock') == false) {
|
||||
|
||||
if($(this).hasClass('product_item')) {
|
||||
$('.sx_item_detailModal').modal('hide');
|
||||
|
||||
var item_data = $(this);
|
||||
@@ -619,16 +577,61 @@ $(function() {
|
||||
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)
|
||||
if ($(this).data('instances').length == 1) {
|
||||
|
||||
show_attribute_selection_modal(attributes, selected_item, instances, item_options, data)
|
||||
$('.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
|
||||
|
||||
@@ -1082,9 +1085,45 @@ $(function() {
|
||||
|
||||
// Create Order
|
||||
$("#create_order").on('click', function(e){
|
||||
|
||||
$(this).attr('disabled', 'disabled');
|
||||
e.preventDefault();
|
||||
name_list = ''
|
||||
count = 0;
|
||||
$('.summary-items').find(`tr[data-oos='true']`).each(function() {
|
||||
count += 1;
|
||||
name = $(this).data('name')
|
||||
name += $(this).data('instance').replace(/['"]+/g, '')
|
||||
if ((count + 1) == $('.summary-items').find(`tr[data-oos='true']`).length) {
|
||||
name += ' and '
|
||||
} else if(count != $('.summary-items').find(`tr[data-oos='true']`).length){
|
||||
name += ', '
|
||||
}
|
||||
name_list += name
|
||||
});
|
||||
wanring_text = name_list + 'are out of stock.'
|
||||
if (name_list) {
|
||||
|
||||
swal({
|
||||
title: "Out Of Stock Warning!",
|
||||
text: wanring_text,
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Confrim",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
create_order($(this))
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
create_order($(this))
|
||||
}
|
||||
});
|
||||
|
||||
function create_order(data) {
|
||||
data.attr('disabled', 'disabled');
|
||||
$("#oqs_loading_wrapper").show();
|
||||
var cashier_type = $("#link_type").val();
|
||||
localStorage.setItem('cashier_type',cashier_type);
|
||||
@@ -1121,36 +1160,29 @@ $(function() {
|
||||
'order_items': order_items,'create_type' : "create_only" };
|
||||
}
|
||||
|
||||
// if (table_id.length>0 || role == 'waiter') {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (type == "quick_service" || type=="food_court") {
|
||||
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;
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + table_id;
|
||||
}
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
// $(this).removeAttr('disabled', '');
|
||||
// $("#oqs_loading_wrapper").hide();
|
||||
|
||||
// swal("Opps","Please Select Table or Room","warning");
|
||||
// }
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (type == "quick_service" || type=="food_court") {
|
||||
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;
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + table_id;
|
||||
}
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Pay Discount for Payment
|
||||
@@ -1685,7 +1717,12 @@ $(function() {
|
||||
data_target = 'sx_item_set_detailModal';
|
||||
data_modal = 'modal'
|
||||
add_icon = "set_item_box"
|
||||
code = menu_items[field].code;
|
||||
code = ''
|
||||
menu_items[field].instances.forEach(ins => function (){
|
||||
if (ins.out_of_stock == false) {
|
||||
code = ins.code;
|
||||
}
|
||||
})
|
||||
name = menu_items[field].name;
|
||||
instances = menu_items[field].instances;
|
||||
$(instances).each(function(i){
|
||||
@@ -1709,8 +1746,18 @@ $(function() {
|
||||
add_icon = "add_icon"
|
||||
menu_instances = [];
|
||||
|
||||
code = '';
|
||||
name = '';
|
||||
price = '';
|
||||
is_available = '';
|
||||
is_on_promotion = '';
|
||||
item_attributes = '';
|
||||
promotion_price = '';
|
||||
out_of_stock = '';
|
||||
menu_insta = '';
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true && !instances[i].out_of_stock) {
|
||||
if (!instances[i].out_of_stock) { //instances[i].is_default === true &&
|
||||
code = instances[i].code;
|
||||
name = instances[i].name;
|
||||
price = parseFloat(instances[i].price).toFixed(2);
|
||||
@@ -1718,13 +1765,10 @@ $(function() {
|
||||
is_on_promotion = instances[i].is_on_promotion;
|
||||
item_attributes = instances[i].values;
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1745,9 +1789,9 @@ $(function() {
|
||||
})
|
||||
|
||||
if (status) {
|
||||
price_tag = '<span class="text-danger" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
||||
price_tag = '<span class="text-danger price_tag" style="font-weight:900;flex-grow:1;">'+status+'</span>'
|
||||
} else {
|
||||
price_tag ='<span style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
||||
price_tag ='<span class="price_tag" style="font-weight:900;flex-grow:1;">'+price+'</span>'
|
||||
}
|
||||
|
||||
image_path = '';
|
||||
|
||||
Reference in New Issue
Block a user