second display
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
$(function() {
|
||||
$(function() {
|
||||
var role = $('#role').val();
|
||||
var second_display_lookup = $("#display_type").val();
|
||||
console.log(second_display_lookup);
|
||||
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
|
||||
modify_order = window.location.href.indexOf("modify_order");
|
||||
|
||||
|
||||
//click menu sidebar menu category
|
||||
$(".product").on("click", function(){
|
||||
var url = $(this).attr('data-ref');
|
||||
show_product_list(url);
|
||||
});
|
||||
show_product_list(url);
|
||||
});
|
||||
//show menu item list when click menu category
|
||||
function show_product_list(url_item){
|
||||
function show_product_list(url_item){
|
||||
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
@@ -25,20 +24,19 @@ $(function() {
|
||||
if (type ==-1 && modify_order == -1){
|
||||
url_item = url_item
|
||||
}
|
||||
console.log(url_item)
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
product = data;
|
||||
|
||||
for(var field in product) {
|
||||
for(var field in product) {
|
||||
if (product[field].unit_price > 0) {
|
||||
qty = 1;
|
||||
options = [];
|
||||
@@ -92,13 +90,13 @@ $(function() {
|
||||
+'<span>'+ product[field].unit_price +'</span>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'</div>';
|
||||
+'</div>';
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
//end Ajax
|
||||
}
|
||||
//end show list function
|
||||
//click menu sidebar menu category
|
||||
@@ -114,7 +112,7 @@ $(function() {
|
||||
sub_category = $(this).siblings('.sub_category_list');
|
||||
show_sub_category_list(sub_url,sub_category,menu_id);
|
||||
}
|
||||
});
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//click menu sidebar menu category
|
||||
@@ -125,19 +123,19 @@ $(function() {
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var url = "get_menu_category/"+menu_id;
|
||||
show_menu_item_list(url,menu_id);
|
||||
});
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var i in menus) {
|
||||
for(var i in menus) {
|
||||
var categories = menus[i]["categories"];
|
||||
for(var ii in categories) {
|
||||
for(var ii in categories) {
|
||||
if (categories[ii]["id"] == menu_id) {
|
||||
var menu_items = categories[ii]["items"];
|
||||
show_menu_list(menu_items);
|
||||
@@ -148,7 +146,7 @@ $(function() {
|
||||
|
||||
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
|
||||
modify_order = window.location.href.indexOf("modify_order");
|
||||
|
||||
|
||||
if (type != -1 && modify_order != -1) {
|
||||
url_item = '../../../addorders/'+url_item;
|
||||
}if(modify_order == -1 && type != -1){
|
||||
@@ -159,9 +157,9 @@ $(function() {
|
||||
}
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
@@ -171,12 +169,12 @@ $(function() {
|
||||
show_menu_list(menu_items);
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
//end Ajax
|
||||
}
|
||||
}
|
||||
//end show list function
|
||||
//click item row for item set
|
||||
$(document).on('click', '.set_item_box', function(event){
|
||||
$(document).on('click', '.set_item_box', function(event){
|
||||
$(".instance-list").empty();
|
||||
$(".options-list").empty();
|
||||
$(".selected-set-list").empty();
|
||||
@@ -189,8 +187,8 @@ $(function() {
|
||||
instances = $(this).data('instances');
|
||||
item_options = $(this).data('options');
|
||||
|
||||
for(var field in item_sets) {
|
||||
|
||||
for(var field in item_sets) {
|
||||
|
||||
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
|
||||
|
||||
value = item_sets[field]["instances"];
|
||||
@@ -198,9 +196,9 @@ $(function() {
|
||||
$(value).each(function(i){
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var j in menus) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
for(var ii in categories) {
|
||||
var items = categories[ii]["items"];
|
||||
for(var iii in items) {
|
||||
var result = items[iii]["instances"];
|
||||
@@ -232,7 +230,7 @@ $(function() {
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+' </div>'
|
||||
$(".instance-list").append(row);
|
||||
$(".instance-list").append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,22 +279,22 @@ $(function() {
|
||||
+'</div>'
|
||||
+' </div>'
|
||||
|
||||
$(".instance-list").append(row);
|
||||
$(".instance-list").append(row);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for(var j in item_options) {
|
||||
for(var j in item_options) {
|
||||
value = item_options[j]["values"];
|
||||
type = item_options[j]["type"];
|
||||
row = "<h4>"+type+"</h4>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+"</button>";
|
||||
+type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
$('.set-item').attr('data-code',instances[0]['code']);
|
||||
$('.set-item').attr('data-name',instances[0]['name']);
|
||||
@@ -313,8 +311,8 @@ $(function() {
|
||||
$('#set_unit_price').text($(this).attr('data-price'));
|
||||
// $('#set_unit_price').text(0);
|
||||
});
|
||||
// click instance for add item set
|
||||
$(document).on('click', '.instance_box', function(event){
|
||||
// click instance for add item set
|
||||
$(document).on('click', '.instance_box', function(event){
|
||||
|
||||
$(".options-list").empty();
|
||||
|
||||
@@ -326,18 +324,18 @@ $(function() {
|
||||
max_qty = $(this).data('max-qty');
|
||||
|
||||
code = $(this).data('code');
|
||||
|
||||
|
||||
if (rowCount.length+1 <= max_qty) {
|
||||
for(var field in item_options) {
|
||||
for(var field in item_options) {
|
||||
value = item_options[field]["values"];
|
||||
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 option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
|
||||
+value[i]+"</button>";
|
||||
+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
}
|
||||
// if($(this).hasClass('selected-instance') == true){
|
||||
@@ -364,7 +362,7 @@ $(function() {
|
||||
var total_price = +sub_total + +total;
|
||||
$(this).addClass('selected-instance');
|
||||
|
||||
set = "<div class='selected-set card custom-card' style='margin-bottom:10px !important'"
|
||||
set = "<div class='selected-set card custom-card' style='margin-bottom:10px !important'"
|
||||
+"' data-name='"+$(this).data('name')
|
||||
+"' data-code='"+code
|
||||
+"' data-price='"+$(this).data('price')
|
||||
@@ -382,7 +380,7 @@ $(function() {
|
||||
+'<span style="color:#fff">'+$(this).data('name')+'</span>'
|
||||
+'</div>'
|
||||
+'<div class="card-block custom-card-block">'
|
||||
|
||||
|
||||
+' <small style="float:" id="instance_option"></small>'
|
||||
+'</div>'
|
||||
// +'<div class="card-footer custom-card-footer">'
|
||||
@@ -397,11 +395,11 @@ $(function() {
|
||||
// }
|
||||
$('#set_unit_price').text(price);
|
||||
$('#set_total_price').text(total_price);
|
||||
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '#remove_set', function(event){
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '#remove_set', function(event){
|
||||
code = $(this).parent().parent('.selected-set').attr('data-code');
|
||||
instance = $(".selected-instance");
|
||||
$(instance).each(function(i){
|
||||
@@ -412,8 +410,8 @@ $(function() {
|
||||
$(this).parent().parent('.selected-set').remove();
|
||||
});
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '.set_order', function(event){
|
||||
// click add order
|
||||
$(document).on('click', '.set_order', function(event){
|
||||
total_price = $('#set_total_price').text();
|
||||
qty = parseInt($('#set_count').val());
|
||||
item_code = $('#set_item_code').text();
|
||||
@@ -448,9 +446,9 @@ $(function() {
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + option_name +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(total).toFixed(2)
|
||||
+'</td>'
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
@@ -473,9 +471,9 @@ $(function() {
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + set_option_name +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(total).toFixed(2)
|
||||
+'</td>'
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
rowCount = rowCount + 1;
|
||||
@@ -494,11 +492,11 @@ $(function() {
|
||||
// btnClass: 'btn-danger',
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
}); //End add order Click
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
|
||||
$('.attributes-list').empty();
|
||||
$('.options-list').empty();
|
||||
@@ -532,20 +530,20 @@ $(function() {
|
||||
}else{
|
||||
image = "<img id='' width='200px' src='"+data.attr('data-image')+"'>";
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
if (modify_order) {
|
||||
image = "<img id='' width='200px' src='../../image/logo.png'>";
|
||||
}else{
|
||||
image = "<img id='' width='200px' src='/image/logo.png'>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#modal_box_img').append(image);
|
||||
|
||||
instance_attributes = []
|
||||
for(var field in instances) {
|
||||
for(var field in instances) {
|
||||
value = instances[field].values;
|
||||
$(value).each(function(i){
|
||||
options = value[i];
|
||||
@@ -556,7 +554,7 @@ $(function() {
|
||||
// data: {id:value[i]},
|
||||
// success:function(result){
|
||||
|
||||
// options = result["name"];
|
||||
// options = result["name"];
|
||||
// instance_attributes.push(options);
|
||||
// }
|
||||
// });
|
||||
@@ -570,14 +568,14 @@ $(function() {
|
||||
// url: '../../api/restaurant/menu_item_attributes/'+selected_item[i],
|
||||
// data: {id:selected_item[i]},
|
||||
// success:function(result){
|
||||
// name = result["name"];
|
||||
// name = result["name"];
|
||||
// selected_arr.push(name);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
for(var field in attributes) {
|
||||
for(var field in attributes) {
|
||||
value = attributes[field]["values"];
|
||||
type = attributes[field]["type"]
|
||||
row = "<h5>"+attributes[field]["type"]+"</h5>";
|
||||
@@ -595,20 +593,20 @@ $(function() {
|
||||
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||
+ status +" "+ type +" '"+ disabled +" >"
|
||||
+value[i]
|
||||
+"</button>";
|
||||
+"</button>";
|
||||
});
|
||||
$(".attributes-list").append(row);
|
||||
$(".attributes-list").append(row);
|
||||
}
|
||||
|
||||
for(var field in item_options) {
|
||||
for(var field in item_options) {
|
||||
value = item_options[field]["values"];
|
||||
type = item_options[field]["type"];
|
||||
row = "<h4>"+type+"</h4>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-group='simple_menu'>"+value[i]+"</button>";
|
||||
+type+"' data-value='"+value[i]+"' data-group='simple_menu'>"+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
|
||||
// $('#count').val(1);
|
||||
@@ -622,14 +620,14 @@ $(function() {
|
||||
$('#unit_price').text(data.attr('data-price'));
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
|
||||
// $('.change_qty').val(1);
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
|
||||
|
||||
attributes = $(".attribute_btn");
|
||||
$(attributes).each(function(i){
|
||||
if ($(attributes[i]).attr('data-type')==type){
|
||||
@@ -642,29 +640,29 @@ $(function() {
|
||||
// $('.'+type).removeClass("selected-attribute");
|
||||
// }
|
||||
// $(this).addClass('selected-attribute');
|
||||
|
||||
|
||||
var selected_attr = get_selected_attributes('selected-attribute');
|
||||
|
||||
qty = $('.change_qty').val();
|
||||
|
||||
for(var field in instances) {
|
||||
for(var field in instances) {
|
||||
item_attr = instances[field].values;
|
||||
|
||||
|
||||
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
||||
unit_price = instances[field].price ;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.option_btn', function(event){
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.option_btn', function(event){
|
||||
active =$(this).hasClass('selected-option');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
@@ -680,7 +678,7 @@ $(function() {
|
||||
}else{
|
||||
$(this).addClass('selected-option');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(group == "set_menu"){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
@@ -699,13 +697,13 @@ $(function() {
|
||||
if(group == "set_menu_default"){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$('.set-item').attr('data-options',JSON.stringify(option_arr));
|
||||
$('.set_default_option').text(option_arr);
|
||||
$('.set_default_option').text(option_arr);
|
||||
}
|
||||
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '.add_to_order', function(event){
|
||||
// click add order
|
||||
$(document).on('click', '.add_to_order', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
qty = parseInt($('#count').val());
|
||||
|
||||
@@ -715,16 +713,16 @@ $(function() {
|
||||
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) {
|
||||
|
||||
|
||||
for(var field in instances) {
|
||||
|
||||
attrbu = JSON.stringify(attribute_arr);
|
||||
instan = JSON.stringify(instances[field].values);
|
||||
instan = JSON.stringify(instances[field].values);
|
||||
var newarr = new Set(instan);
|
||||
|
||||
result = false;
|
||||
for(var i in attrbu) {
|
||||
for(var i in attrbu) {
|
||||
if (newarr.has(attrbu[i])) {
|
||||
result = true;
|
||||
break;
|
||||
@@ -758,22 +756,22 @@ $(function() {
|
||||
}
|
||||
show_item_detail(item_data,"add_to_order");
|
||||
calculate_sub_total();
|
||||
|
||||
|
||||
}); //End add order Click
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
var item_data = $(this);
|
||||
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();
|
||||
calculate_sub_total();
|
||||
}); //End Add Icon Click
|
||||
|
||||
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');
|
||||
@@ -786,42 +784,42 @@ $(function() {
|
||||
}
|
||||
d_option = data.attr('data-opt');
|
||||
if (click_type != "add_icon"){
|
||||
option_name = "-"+data.attr('data-options');
|
||||
data_option = data.attr('data-options') ;
|
||||
option_name = "-"+data.attr('data-options');
|
||||
data_option = data.attr('data-options') ;
|
||||
}else{
|
||||
option_name = ' ';
|
||||
data_option = '[]';
|
||||
}
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
|
||||
$(item_row).each(function(i){
|
||||
item_code = $(item_row[i]).attr('data-code');
|
||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
r_option = $(item_row[i]).attr('data-opt');
|
||||
|
||||
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
|
||||
if (qty > 1) {
|
||||
if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
|
||||
if (qty > 1) {
|
||||
qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
|
||||
}else{
|
||||
}else{
|
||||
qty = parseInt($(item_row[i]).children('#item_qty').text()) + 1;
|
||||
}
|
||||
|
||||
|
||||
$(item_row[i]).children('#item_qty').text(qty);
|
||||
parseFloat($(item_row[i]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
|
||||
append =1;
|
||||
}else{
|
||||
if (qty > 1) {
|
||||
}else{
|
||||
if (qty > 1) {
|
||||
qty = qty;
|
||||
}else{
|
||||
}else{
|
||||
qty = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (append===0) {
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||
+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+price+ " 'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||
+instance+ "' data-qty='"+qty +"' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+data.attr('data-instance-code')+"' data-attributes='"
|
||||
+data.attr('data-attributes')+"' data-options ='"
|
||||
+data_option+"' data-opt ='"
|
||||
@@ -829,9 +827,9 @@ $(function() {
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<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">'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
+'</td>'
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
@@ -863,15 +861,15 @@ $(function() {
|
||||
}
|
||||
var order_items = JSON.stringify(get_order_item_rows());
|
||||
if (booking_id.length > 0) {
|
||||
|
||||
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
|
||||
'table_id': table_id,
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'create_type' : "create_only" };
|
||||
}else{
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",
|
||||
'table_id': table_id,
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'create_type' : "create_only" };
|
||||
}
|
||||
|
||||
@@ -881,7 +879,7 @@ $(function() {
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
if (type == "quick_service" || type=="food_court") {
|
||||
window.location.href = "/origami/"+type;
|
||||
}else{
|
||||
@@ -890,7 +888,7 @@ $(function() {
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + table_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
|
||||
customer_display_view(null,"reload");
|
||||
@@ -930,18 +928,18 @@ $(function() {
|
||||
}
|
||||
var order_items = JSON.stringify(get_order_item_rows());
|
||||
if (booking_id.length > 0) {
|
||||
|
||||
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
|
||||
'table_id': table_id,
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
|
||||
}else{
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",
|
||||
'table_id': table_id,
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
@@ -967,7 +965,7 @@ $(function() {
|
||||
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -985,6 +983,7 @@ $(function() {
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
|
||||
var item_data = $(this);
|
||||
item = get_item(item_data,"remove_icon");
|
||||
customer_display_view(item,"remove");
|
||||
}
|
||||
@@ -995,26 +994,27 @@ $(function() {
|
||||
});
|
||||
|
||||
//click close
|
||||
$('#sx_itemModal').on('click','#close', function(){
|
||||
$('#sx_itemModal').on('click','#close', function(){
|
||||
$(".item_box").removeAttr("data-active");
|
||||
});
|
||||
|
||||
$('#sx_item_set_detailModal').on('click','#close', function(){
|
||||
$('#sx_item_set_detailModal').on('click','#close', function(){
|
||||
$("#sx_item_set_detailModal").css({ 'display': "none" });
|
||||
});
|
||||
//click save buttom after change qty
|
||||
$('#sx_itemModal').on('click','#save', function(){
|
||||
$('#sx_itemModal').on('click','#save', function(){
|
||||
if ($('#modal-qty').val()>0) {
|
||||
summary_items_filter();
|
||||
summary_items_filter();
|
||||
calculate_sub_total();
|
||||
|
||||
}else{
|
||||
swal("Opps", "Please enter number for qty ","warning");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
//calculate subtotal
|
||||
function calculate_sub_total(){
|
||||
function calculate_sub_total(){
|
||||
var total_price = 0;
|
||||
var total_qty = 0;
|
||||
var taxable_amount = 0;
|
||||
@@ -1023,16 +1023,16 @@ $(function() {
|
||||
$(item_row).each(function(i){
|
||||
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
||||
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
||||
total_qty += qty;
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
total_qty += qty;
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
var fixed_total_price = parseFloat(total_price).toFixed(2);
|
||||
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
|
||||
|
||||
$('#sub_total').empty();
|
||||
$('#sub_total').empty();
|
||||
$('#sub_total').append(fixed_total_price);
|
||||
|
||||
$('#total_qty').empty();
|
||||
$('#total_qty').empty();
|
||||
$('#total_qty').append(total_qty);
|
||||
|
||||
if (item_row.length > 0) {
|
||||
@@ -1046,16 +1046,17 @@ $(function() {
|
||||
$('.summary-items tr').filter(function(){
|
||||
if ($(this).attr('data-active') == 'true'){
|
||||
qty = $('#modal-qty').val();
|
||||
$(this).attr('data-qty',qty);
|
||||
price = parseFloat($(this).attr('data-price'));
|
||||
total_price = parseFloat(price*qty).toFixed(2);
|
||||
|
||||
$(this).find('#item_qty').text(qty);
|
||||
$(this).find('.item-cell-price').text(total_price);
|
||||
|
||||
$(this).find('.item-cell-price').text(total_price);
|
||||
|
||||
$(this).removeAttr('data-active');
|
||||
|
||||
|
||||
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
|
||||
var item_data = $(this);
|
||||
var item_data = $(this);
|
||||
item = get_item(item_data,"update_icon");
|
||||
customer_display_view(item,"update_qty");
|
||||
}
|
||||
@@ -1065,17 +1066,17 @@ $(function() {
|
||||
|
||||
/* Get Item rows */
|
||||
function get_order_item_rows(){
|
||||
var order_items = [];
|
||||
var order_items = [];
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
$(item_row).each(function(i){
|
||||
var order_item = {};
|
||||
|
||||
|
||||
order_item.order_item_id = $(item_row[i]).attr('data-row');
|
||||
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
order_item.quantity = $(item_row[i]).children('#item_qty').text();
|
||||
//parent id
|
||||
if ($(item_row[i]).attr('data-parent')=="true") {
|
||||
parent_id = $(item_row[i]).attr('data-row');
|
||||
parent_id = $(item_row[i]).attr('data-row');
|
||||
}
|
||||
if ($(item_row[i]).attr('data-sub-item')=="true") {
|
||||
order_item.parent_order_item_id = parent_id
|
||||
@@ -1083,7 +1084,7 @@ $(function() {
|
||||
//end parent id
|
||||
order_item.options = $(item_row[i]).attr('data-options');
|
||||
order_items.push(order_item);
|
||||
});
|
||||
});
|
||||
return order_items;
|
||||
}
|
||||
// Get Selected Class
|
||||
@@ -1123,14 +1124,14 @@ $(function() {
|
||||
window.location.href = "/origami/room/" + table_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Get Selected Class
|
||||
function change_qty_plus_minus(id,plus,minus) {
|
||||
var count = parseInt($('#'+id).val());
|
||||
var count = parseInt($('#'+id).val());
|
||||
|
||||
$('#'+plus).on("click", function(){
|
||||
count++;
|
||||
$('#'+plus).on("click", function(){
|
||||
count++;
|
||||
$('#'+id).val(count);
|
||||
|
||||
if (id == "count") {
|
||||
@@ -1150,7 +1151,7 @@ $(function() {
|
||||
}else{
|
||||
total_price = count*price;
|
||||
}
|
||||
|
||||
|
||||
$("#set_total_price").text(total_price);
|
||||
}
|
||||
});
|
||||
@@ -1159,7 +1160,7 @@ $(function() {
|
||||
|
||||
// var count = parseInt($('#'+id).val());
|
||||
// var countEl = document.getElementById(id);
|
||||
|
||||
|
||||
if (count > 1) {
|
||||
count--;
|
||||
$('#'+id).val(count);
|
||||
@@ -1183,7 +1184,7 @@ $(function() {
|
||||
}
|
||||
$("#set_total_price").text(total_price);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1221,31 +1222,31 @@ $(function() {
|
||||
|
||||
//click menu sidebar menu category
|
||||
|
||||
$(document).on('click', '.sub_clickssss', function(event){
|
||||
$(document).on('click', '.sub_clickssss', function(event){
|
||||
event.preventDefault();
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var url = "get_menu_sub_category/"+menu_id;
|
||||
sub_category = $(this).find('.sub_category_list');
|
||||
show_sub_category_list(url,sub_category,menu_id);
|
||||
});
|
||||
show_sub_category_list(url,sub_category,menu_id);
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_sub_category_list(url,sub_category,menu_id){
|
||||
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) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
if (menu_id == categories[ii]["parent_id"]) {
|
||||
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>' ;
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
}
|
||||
}
|
||||
@@ -1260,9 +1261,9 @@ $(function() {
|
||||
var url = url;
|
||||
}
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
@@ -1275,27 +1276,27 @@ $(function() {
|
||||
// }else{
|
||||
// $(sub_category).addClass('hidden');
|
||||
// }
|
||||
for(var i in data) {
|
||||
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>' ;
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
//end Ajax
|
||||
}
|
||||
}
|
||||
|
||||
/* Get Item rows */
|
||||
function get_item(data,click_type){
|
||||
var sale_items = [];
|
||||
|
||||
function get_item(data,click_type){
|
||||
var sale_items = [];
|
||||
|
||||
var sale_item = {};
|
||||
sale_item.qty = parseInt(data.attr('data-qty'))
|
||||
sale_item.qty = parseInt(data.attr('data-qty'));
|
||||
sale_item.name = data.attr('data-name');
|
||||
sale_item.price = data.attr('data-price');
|
||||
sale_item.item_code = data.attr('data-item-code')
|
||||
@@ -1306,13 +1307,13 @@ $(function() {
|
||||
sale_item.click_type = click_type
|
||||
sale_item.instance = data.attr('data-instance')
|
||||
sale_items.push(sale_item);
|
||||
|
||||
return sale_items;
|
||||
|
||||
}
|
||||
|
||||
/* Get Item rows */
|
||||
function get_set_item(items){
|
||||
var sale_items = [];
|
||||
var sale_items = [];
|
||||
var item = {};
|
||||
item.code = $('.set-item').attr('data-code');
|
||||
item.name = $('.set-item').attr('data-name');
|
||||
@@ -1326,7 +1327,7 @@ $(function() {
|
||||
sale_items.push(item);
|
||||
|
||||
$(items).each(function(i){
|
||||
var sale_item = {};
|
||||
var sale_item = {};
|
||||
sale_item.code = $(items[i]).attr('data-code');
|
||||
sale_item.name = $(items[i]).attr('data-name');
|
||||
sale_item.item_name = $('#set_name').text();
|
||||
@@ -1338,7 +1339,7 @@ $(function() {
|
||||
sale_items.push(sale_item);
|
||||
});
|
||||
|
||||
|
||||
|
||||
return sale_items;
|
||||
}
|
||||
|
||||
@@ -1347,7 +1348,7 @@ $(function() {
|
||||
url = '../../../../origami/customer_view';
|
||||
}
|
||||
if(modify_order == -1 && type != -1){
|
||||
url = '../../origami/customer_view';
|
||||
url = '../../origami/customer_view';
|
||||
}
|
||||
if (type ==-1 && modify_order == -1){
|
||||
url = '../../origami/customer_view';
|
||||
@@ -1357,7 +1358,7 @@ $(function() {
|
||||
url: url,
|
||||
data: {"data":data,"status":status},
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
success:function(result){
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1368,7 +1369,7 @@ $(function() {
|
||||
// qty = $(this).val();
|
||||
// price = $("#set_total_price").text();
|
||||
// $("#set_total_price").text(qty*price);
|
||||
// });
|
||||
// });
|
||||
|
||||
// $(".change_qty").change(function(){
|
||||
// qty = $(this).val();
|
||||
@@ -1378,7 +1379,7 @@ $(function() {
|
||||
function show_menu_list(menu_items) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
for(var field in menu_items) {
|
||||
for(var field in menu_items) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
|
||||
@@ -1439,7 +1440,7 @@ $(function() {
|
||||
}else{
|
||||
image_path = menu_items[field].image;
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
if (modify_order) {
|
||||
image_path = "../../image/logo.png";
|
||||
@@ -1484,7 +1485,7 @@ $(function() {
|
||||
+'<span>'+ price +'</span>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
+'</div>'; ;
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
//end instances in menu-items alest 1 instance
|
||||
@@ -1492,4 +1493,4 @@ $(function() {
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user