');
}
var put_content='';
if(menu_content){
put_content='
'+menu_content+'
';
}
var put_note='';
if(menu_note!=undefined){
//put_note='
'+menu_note+'
';
}
$('#menulist').append('
'+put_note+put_content+'
');
//
'+menu+'
//alert(menu+' SSS');
$(this).find("catalogue").each(function(cc){
var catalogue = $(this).attr("title");
var display=$(this).attr('display');//on | off
var catalogue_id = "cata"+cc;//catalogue.replace(' ','-');
var cid = menu_id+'_'+catalogue_id;
var ii=0;
// $('#'+menu_id+'').append('
');
$(menu_id2).append(''); // Adair class="catalogue_table">'+catalogue+''
$(this).find("item").each(function(){
var display=$(this).attr('display');//on | off
if(display=='on' || display==undefined){
var code = $(this).attr('code');
var name = $(this).find("name").text();
var additional=$(this).find("additional");
var xml_desc_type = $(this).find("description").attr("type");
var xml_desc_spice = $(this).find("description").attr("spice");
var xml_desc =$(this).find("description").text();
var calorie = $(this).find("calorie").text();
var weight = $(this).find("weight").text();
var calorie_unit = $(this).find("calorie").attr('unit');
var weight_unit = $(this).find("weight").attr('unit');
var price = $(this).find("price").eq(0).text();
var ffimg=$(this).find("photo").find('image').eq(0).text().trim();
if(ffimg!=''){
var photo = path_image+'/'+$(this).find("photo").find('image').eq(0).text();//第一張照片
}else{
var photo = "empty.webp";//第一張照片
}
var memo = $(this).find("memo").text();
var type = $(this).children("type").text();
var mu_price = $(this).find("price").length;
var qty_price='';
if(mu_price > 1){
qty_price='
'
}
});//多國注解
var ophoto='';
if($(this).find("photo").find('image').length > 1){
//ophoto='';//'
';
$(this).find("photo").find('image').each(function(i){
ophoto += ($(this).text()=='' || i == 0)?'':'
';
});
}
ophoto = (ophoto=='')?'':'
'+ophoto+'
';
var additional='';
if($(this).find("additional").length > 1){
//ophoto='';//'
';
$(this).find("additional").each(function(i){
additional += ($(this).text()=='')?'':''+$(this).text()+'';
});
}
additional = (additional=='')?'':''+additional+'';
/*
*/
var ext_option=[];
$(this).find("option").each(function(i,k){
let option_title=$(this).attr("title");
let option_type=$(this).attr("type");
if(option_type=='radio'){
let opt=$(this).text().split(",");
let def=$(this).attr("def");
let add_price=$(this).attr("price").split(",");
let out='';
$.each(opt,function(index,val){
let checked=(def==val)?' checked="checked"':'';
let addp=(add_price[index]==0 || add_price[index]===undefined || add_price[index]===NaN)?0:add_price[index];
let addp_title=(addp==0)?"":'(+$'+addp+')';
out+=' ';
});
let option_title1=(option_title)?""+option_title+":":"";
ext_option.push('
'+option_title1+''+out+'
');
}
if(option_type=='checkbox'){
let opt=$(this).text().split(",");
let def=$(this).attr("def").split(",");
let out='';
let add_price=$(this).attr("price").split(",");
//+'(+$'+add_price+')
$.each(opt,function(index,val){
let addp=(add_price[index]==0 || add_price[index]===undefined || add_price[index]===NaN)?0:add_price[index];
let addp_title=(addp==0)?"":'(+$'+addp+')';
let def_checked=(def[index]!=undefined)?' checked="checked"':'';
// '+checked+' let checked=(def===val)?' checked="checked"':'';
out+=' ';
});
let option_title1=(option_title)?""+option_title+":":"";
ext_option.push('
'+option_title1+''+out+'
');
}
//console.log(code+' '+name+' '+option_type+' '+$(this).text());
});
var extra = [];
var note='';
var default_qty = 1;
var other ='';
var order_button_add = '';
var order_button_cut = '';
var order_button_submit = 'Please scan your table QR code.';
var show_extra = (extra.length==0)?'':'
';
ii+=1;
$('#'+cid).append(show_item2);
}//display
});
}
if(ii==0){
$("#"+cid).remove();
$("#title_"+cid).remove();
//alert("#"+cid);
}
});
});
$(".item_ophoto li").live("click",function(){
// alert($(this).find('img').attr('src'));
$(this).parent().parent().find('.item_image').find('img').attr('src',$(this).find('img').attr('src'));
});
$("#show_order").show();
$("#add_to_order,#show_order").live(myDown,function(){
$(".order_list").hide();
$(this).hide();
var date = $("#order_info input[name=date]").val();
var time = $("#order_info select[name='time'] option:selected").val();
var note = $("#order_info textarea[name='note']").val().replace(/\r\n|\r|\n/g," ");
var place = $("#order_info input[name='place']:checked").val();
var table_number = $("#order_info input[name='table_number']").val();
var people_number = $("#order_info input[name='people_number']").val();
//var old = is($(this).attr('id') == 'OLD_ORDER');
var xitem = count_item();
var pass = 1;
if(xitem == 0 && pass == 0){
alert('Please select the product you want to buy');
}else{
place = (place != undefined)?place:'T:'+table_number+' P:'+people_number;
// Time:'+time+'
//var order_info = '';
//$('#show_order_info').html(order_info);
//$('#my_order').empty();
//$("#table_list").clone().appendTo('#my_order');
//$('#my_order_total').empty();
//$("#table_total").clone().appendTo('#my_order_total');
//$("#table_total").empty();
$('#table_list tbody').empty();
$("#my_order").dialog('open');
//$("#show_order").css("z-index","11");
//$(".ui-dialog-buttonpane button:contains('Load from cookie')").attr("disabled", true).addClass("ui-state-disabled");
$('#xitem').html(xitem);
$("#price").html(sum_total());
if($('#OID').text()=='New Order'){
$(".ui-dialog-buttonpane button:contains('Update order')").hide();
}else{
$(".ui-dialog-buttonpane button:contains('Update order')").show();
}
if(xitem == 0){
$(".ui-dialog-buttonpane button:contains('Confirm')").hide();
}else{
$(".ui-dialog-buttonpane button:contains('Confirm')").show();
}
/*
$(".ui-dialog-buttonpane button:contains('Save to cookie')").hide();
$(".ui-dialog-buttonpane button:contains('Load from cookie')").hide();
if($.cookie("rented_car").length == 0){
$(".ui-dialog-buttonpane button:contains('Save to cookie')").hide();
$(".ui-dialog-buttonpane button:contains('Load from cookie')").hide();
}
if(confirm("("+$("#order_list .order_title span").html()+") Item has been added to order list \n\n" )){
$.cookie("scart",null);
//$.cookie("svar",null);
alert(oo);
//window.open("&o="+oo,"_self");
return false;}
*/
}
});
$(".RI").live(myDown,function(){
//var quantity = $(this).attr('quantity');
/*
var calorie = $(this).attr('calorie');
var weight = $(this).attr('weight');
var sub_price = $(this).attr('sub_price');
var code = $(this).parents('tr').find('td:eq(0)').text();
var supply = $('.item_supply[code="'+code+'"]').text();
var buy = $(this).parents('tr').find('td:eq(4)').text()
var recode = parseInt(supply) + parseInt(buy);
$('.item_supply[code="'+code+'"]').text(recode);
*/
//var sub_price = quantity * price;
/*
calorie = parseFloat($("#calorie").text()) - parseFloat(calorie);
$("#calorie").html(calorie);
weight = parseFloat($("#weight").text()) - parseFloat(weight);
$("#weight").html(weight);
*/
//sub_price = parseFloat($("#price").text()) - parseFloat(sub_price);
//alert($("#price").text() );
//$("#price").html(parseFloat(sub_price).toFixed(0));
var code = $(this).parents('tr').find('td:eq(0)').text();
var supply = $('.item_supply[code="'+code+'"]').text();
var buy = $(this).parents('tr').find('td:eq(5)').text()
var recode = parseInt(supply) + parseInt(buy);
//alert(recode);
$('.item_table[code="'+code+'"]').find('.item_supply').text(recode);
$('.item_table[code="'+code+'"]').find('.cut').hide();
//var ic = $('.item_table[code="'+code+'"]').find('.item_count').text();
//ic =(ic=='')?0:parseInt(ic);
//$('.item_table[code="'+code+'"]').find('.item_count').text(ic - parseInt(buy));
//var pc = $('#c'+$('.item_table[code="'+code+'"]').parents('div').attr('id')).text();
//pc =(pc=='')?0:parseInt(pc);
//$('#c'+$('.item_table[code="'+code+'"]').parents('div').attr('id')).text(pc - parseInt(buy));
//alert(pc+' '+buy);
$(".group_"+code).each(function(i){
//alert(i+' '+$(this).attr())
$(this).remove();
});
$(this).parents('tr').remove();
$("#count_item,#count_item2,#total_qty").html(count_item());
$("#price").html(sum_total());
//$("#calorie").html(sum_calorie());
//$("#weight").html(sum_weight());
var item_title = '';
$("#my_order_list tbody tr").each(function(){
item_title+='
'+$(this).find('td:eq(0)').text()+'
'+$(this).find('td:eq(2)').text()+'
'+$(this).find('td:eq(5)').text()+'
';
});
//
-
名稱
數量
var ptable = '
'
+item_title
+'
'
+'
$'+$("#price").html()+'
';
//
Weight
Calorie
Total
'+$("#weight").html()+'g
'+$("#calorie").html()+'
$('#perview_total').html(ptable);
/*
olen=$("#order_list .order_title span").html();
olen= olen - 1;
$("#order_list .order_title span").html(olen);
$.cookie("scart", null);
$.cookie("scart", $("#table_list").html(), { path: '/' });
*/
});
$(".submit_note").bind(myUp,function(){
$("#show_order").show();
$("#my_order_list").show();
var code = $(this).parents('ul').attr('code');
var catalog = $(this).parents('ul').parents('div').attr('id');
var menu = $(this).parents('ul').parents('div').attr('menu');
var catalogue = $(this).parents('ul').parents('div').attr('catalogue');
var pimg = $(this).parents('ul').find('.item_image').find('img').eq(0).attr('src');
var name = $(this).parents('ul').find('.item_name').find('.item_name_name').text();
var quantity = parseFloat($(this).parents('ul').find('.item_quantity').find('input:eq(0)').val());
var xml_desc_type = $(this).parents('ul').find(".xml_desc_type").text();
var unit_price = $(this).parents('ul').find('.uprice').text();
var note_textarea=[];
var qty =$(this).parents('ul').find('.item_count').text();
var cc = $(this).parents('ul').find('.item_supply').text();
var ss=parseInt(cc)-qty;
var additional = $(this).parents('ul').find(".item_additional");
if( qty>0 && ss >=0){
$(this).parents('ul').find('.item_supply').text(ss);
var opt_val='';
if(xml_desc_type){
note_textarea.push(xml_desc_type);
}
//var unit_price=parseFloat(unit_price);
var opt_price=0;
$(this).parents('ul').find('.item_opt').each(function(i,k){
var opt_title=($(this).attr("title")!='')?$(this).attr("title")+':':'';
var opt_value=[];
$(this).find(".opt"+i+":checked").each(function(){
var price_a=($(this).attr('price')!=undefined)?parseFloat($(this).attr('price')):0;
if(price_a=="0"){
opt_value.push($(this).val());
}else{
opt_value.push($(this).val()+'(+$'+price_a+')');
}
opt_price=opt_price + price_a;
});
if(opt_value.length){
note_textarea.push(opt_title+''+opt_value.join(", "));
}
});
//alert(unit_price+' '+opt_price);
if($(this).parents('ul').find('.item_note').val().trim()!=''){
note_textarea.push($(this).parents('ul').find('.item_note').val());
}
var sub_price =(parseFloat(unit_price)+parseFloat(opt_price)) * parseInt(qty);
sub_price = parseFloat(sub_price).toFixed(1);
var SD = '
";
}
});
$("#item_info").html(data).dialog({title:code+' '+name}).dialog('open');
}});
});
$(".item_list,.table_view").live(myDown,function(){
if($(this).hasClass('table_view')){
var yourword=prompt('Please input back house password','');
$.cookie("password",yourword);
}
//$("#OID").after(' '+$(this).find('span').eq(0).text()+'');
var OID = $(this).attr('title');
$.post("load_order.php", {type:'load_order_table',OID:OID},
function(data){
$("#perview_server_order").html(data);
var www=($(window).width() <600)?($(window).width()-20):($(window).width() - 160);
$("#perview_server_order").dialog({
autoOpen: true,
// show: "blind",
position: { my: 'center top', at: '0 top+50'},
width: www,
height: $(window).height() - 50,
modal: true,
draggable: true, title:' Order '+OID
,buttons: {/*
"EDIT":function(){
//檢查用PAYPAL付錢了就不給改
$("#OID").html(OID);
$("#my_order_menu").html($(this).find('.content').html());
//alert($("#my_order table:eq(0) tbody").find('tr').length);
//$(".ui-dialog-buttonpane button:contains('Update to Server')").attr("enable", true).addClass("ui-state-enable");
$('#xitem').html(count_item());
$(".ui-dialog-buttonpane button:contains('更新訂單')").show();
$(".ui-dialog-buttonpane button:contains('Confirmed')").hide();
//$("#my_order").dialog('open');
//$("#order_info textarea[name=note]").val($('#my_note').text());
//alert($('#show_order_info span').eq(0).text());
//alert('LOAD DATE TO (ORDER NOW)');
$("input[name='place']").each(function(){
if($(this).val()==$(".order_place:eq(0)").text()){
$(this).attr('checked','checked');
}
});
$("input[name='pay_type']").each(function(){
if($(this).val()==$(".order_pay_type:eq(0)").text()){
$(this).attr('checked','checked');
}
});
$("input[name=when]").each(function(){
if($(this).val()===$(this).find(".order_when").text()){
$(this).attr('checked',true);
}
});
$("#people_number").val($(this).find(".order_people").text());
$("#select_table").val($(this).find(".order_table").text());
$("#reservation_time").val($(this).find(".order_time:eq(0)").text());
$("#order_info textarea[name='note']").val($(this).find(".order_note:eq(0)").text());
//alert($(this).html());
$(this).empty();
$(this).dialog('close');
$("#list_server_order").dialog('close');
$("#my_order").dialog('open');
//$(".order_info_history").empty().hide();
},*/
"Reload":
{text: 'Reload',
class: 'reload',
click:function(){
$("#item"+OID).trigger(myDown);
}},
"Print_qr":
{text: 'Print QR-CODE',
class: 'print',
click:function(){
alert("SETTING......");
}},
"Print":
{text: 'Print Order',
class: 'print',
click:function(){
var items=[];
$(this).find(".content table tbody tr").each(function(){
item={"item":$(this).find('td:eq(1)').text()+' '+$(this).find('td:eq(2)').text(),"count":$(this).find('td:eq(5)').text(),"price_s":$(this).find('td:eq(4)').text(),"price":$(this).find('td:eq(6)').text(),"note":$(this).find('td:eq(3)').text()};
items.push(item);
});
var operator=$(this).find('.change_operator').val();
var table=$(this).find('.order_table').text();
var people=$(this).find('.order_people').text();
var place=$(this).find('.order_place').text();
var note=$(this).find('.order_note').text();
var bookat=$(this).find('.bookat').text();
var pass=$(this).find('.pass').attr('pass');
$.post("./pos/print_receipt.php",{OID:OID,operator:operator,table:table,people:people,place:place,pass:pass,note:note,bookat:bookat,items:items},function(dd){
alert(dd);
});
//$.post("load_order.php", {type:'print_receipt',OID:OID});
}},
"Close": function() {$(this).dialog('close');}}});
//alert(data);
//alert('已儲存到SERVER');
$(".reject_item").live(myDown,function(){
//alert('ss');
let item=$(this).parents('tr').prev("tr");
let q1=item.find("td").eq(0).text();
let q2=item.find("td").eq(2).text();
let qty=item.find(".item_qty").text();
let price=item.find(".item_p").text();
if(confirm('Reject\n '+q1+' - '+q2)){
$.post("load_order.php", {type:'reject_item',OID:$(this).attr('oid'),IID:$(this).attr('iid')},function(ddd){
//alert(ddd)
});
//alert( +' - '+ parseFloat(price));
$("#order_qty").text((parseFloat($("#order_qty").text()) - parseFloat(qty)));
$("#order_total").text("Reload");
//$("#order_total").text((parseFloat($("#order_total").text()) - parseFloat(price)));
$(this).parents('tr').fadeOut(500);
item.fadeOut(100);
}
});
$(".change_order").on(myDown,function(){
// $(this).find('input[type=checkbox]').eq(0).click();
// alert("xxx");
let qty=$(this).parent().prev('tr').find(".item_qty").text();
let get_qty=($(this).text()=="")?0:parseInt($(this).text());
if(get_qty < qty){
$(this).text(get_qty+1);
$(this).addClass("add_to");
}else{
$(this).text("");
$(this).removeClass("add_to");
}
$("#change_order").trigger(myDown);
});
$(".c_obj").on(myDown,function(){
$(this).find("input[name=obj_order]").attr("checked","checked");
});
$("#change_order").on(myDown,function(){
//let ccc="
項次/List產品名稱/Name數量/Qty
";
let ccc="";
let tot_item=0;
$("#change_info").html('');
$(".add_to").each(function(){
let ptr=$(this).parent().prev('tr');
let iid=ptr.attr("iid");
let sss=ptr.find(".sss").text();
let name=ptr.find(".item_n").text();
let extra=ptr.find(".item_extra").html();
let sip=ptr.find(".sip").text();
let qty=ptr.find(".item_qty").text();
let get_qty=$(this).text();
/*
ccc+='