var isIOS = navigator.userAgent.match(/Android|webOS|iPhone|iPod|Blackberry/i); var myDown = isIOS ? "touchstart" : "mousedown"; var myUp = isIOS ? "touchend" : "mouseup"; var myDate = new Date(); var dd = ('00'+myDate.getDate()).slice(-2); var mm = ('00'+(myDate.getMonth()+1)).slice(-2); var displayDate = dd + '/' + mm + '/' + myDate.getFullYear(); var saerchDate = dd + '-' + mm + '-' + myDate.getFullYear() ; var time_now = myDate.getHours()+':'+('00'+myDate.getMinutes()).slice(-2);//+':'+myDate.getSeconds(); var maxW=($(window).width() >800)?800:$(window).width()-20; $(window).resize(function() { var width = $(document).width(); maxW=(width >1000)?1000:width-10; }); function clock(clock_name,h,m) { var now = new Date(); var timeStr,countdown, dateStr; // time var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); var diff = (hours * 60 + minutes) - (parseInt(h) * 60 + parseInt(m)); hours = Math.floor(diff / 60); minutes = diff % 60; timeStr = ' '+hours; timeStr += ((minutes < 10 && minutes > 0) ? ":0" : ":") + minutes; // timeStr += ((seconds < 10) ? ":0" : ":") + seconds; countdown = ((hours > 0 ) ? "-" : "")+( 1 + hours); countdown += ((minutes > -9 && minutes < 10) ? ":0" : ":") +( 0 - minutes); // countdown += ((seconds > 49) ? ":0" : ":") + (59 - seconds); timeStr = (hours < 0)?countdown:timeStr; $("input[name="+clock_name+"]").val(timeStr);//.after(''+h+':'+m+''); /* // date date = now.getDate(); month = now.getMonth()+ 1; year = now.getYear(); dateStr = "" + month; dateStr += ((date < 10) ? "/0" : "/") + date; dateStr += "/" + (1900+year); document.clock.date.value = dateStr; setTimeout("clock()", 1000); */ } function tempAlert(msg,duration) { var el = document.createElement("div"); el.className = "tempAlert"; // el.setAttribute("style","position:fixed;top:40%;margin-right:auto;margin-left:auto;max-width:800px;width:90%;text-align:center;background-color:white;z-index:9999;font-size:3em;"); el.innerHTML = msg; setTimeout(function(){ el.parentNode.removeChild(el); },duration); document.body.appendChild(el); } function count_item(){ var count_item = 0; $("#my_order_list tbody tr").each(function(){ count_item += parseInt($(this).find('td:eq(5)').text()); }); return count_item; } function sum_total(){ var sum_total = 0; $("#my_order_list tbody tr").each(function(){ sum_total += parseInt($(this).find('td:eq(5)').text()) * parseFloat($(this).find('td:eq(4)').text()); }); return parseFloat(sum_total).toFixed(1); } function sum_calorie(){ var s = 0; $("#my_order_list tbody tr").each(function(){ s += parseInt($(this).find('td:eq(5)').text()) * parseFloat($(this).find('li[title="calorie"]').text()); }); return s; } function sum_weight(){ var s = 0; $("#my_order_list tbody tr").each(function(){ s += parseInt($(this).find('td:eq(5)').text()) * parseFloat($(this).find('li[title="weight"]').text()); }); return s; } function clock_now() { let day = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; //let month=["January","February","March","April","May","June","July","August","September","October","November","December"]; let month=["Jan.","Feb.","Mar.","Apr.","May","June","July","Aug.","Sept.","Oct.","Nov.","Dec."]; var now = new Date(); var timeStr; var weekday=now.getDay(); var year=now.getFullYear(); var month_now=now.getMonth(); var date=now.getDate(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); if(hours<10){hours='0'+hours} if(minutes<10){minutes='0'+minutes} // timeStr = date+'/'+month[month_now]+'/'+year+' '+hours; timeStr = "Opens "+month[month_now]+' '+date+' '+hours; timeStr += ((minutes < 10 && minutes > 0) ? ":0" : ":") + minutes; timeStr += ((seconds < 10) ? ":0" : ":") + seconds; timeStr +=" ("+day[weekday]+")"; $("#clock_now").text(timeStr); } $(document).ready(function() { //alert(location.href); //$('#menu_day').datepicker({startDate: new Date(),selectWeek:true,closeOnSelect:false,dateFormat: 'dd-mm-yy', minDate:'+0d', maxDate: "+60D"}); //$('#menu_day').datepicker('setDate', new Date()); //$('#menu_day').html(today); //var d = new Date(); //var zone_time = d.getTimezoneOffset(); //alert(n); //window.alert(new Date().getTimezoneOffset() / 60); //. setInterval(function(){clock_now()}, 1000); $.get('lname.php',function(x){ if(x=='Guest'){ $('#OLD_ORDER').hide(); $('#stb').hide(); $('#select_table').hide(); }else{ $('#SEARCH_MY_ORDER').hide(); } $('#Operator').text(x); }); /* TABLE FUNCTION*/ $('.after_take').live(myDown,function(){ //alert($(this).attr('title')); var s = $(this).attr('title').split(' '); var rs = s[1].split('-'); rs = rs[2]+'-'+rs[1]+'-'+rs[0]; if(rs!=saerchDate){ $("#select_reservation").trigger('click'); } $('#select_table').val(s[0]); $('#reservation_time').val(rs+' '+s[2]); $("#table_free").dialog('close'); }); $("#search_button").click(function(){ var si=$("#search_item").val(); var k=$("#session_key").val(); //alert(si); location.href="/?s="+si+"&k="+k; }); $("#search_reset").click(function(){ //alert(si); location.href="/"; }); $("#Login").bind(myDown,function(){ $(this).hide(); $("#Logout").show(); }); $("#Logout").bind(myDown,function(){ //$("#Login").text('Login'); location.reload(); }); $("#copy_upp").click(function(){ $("input[name=receive_fname]").val($("input[name=fname]").val()); $("input[name=receive_lname]").val($("input[name=lname]").val()); $("input[name=receive_phone]").val($("input[name=phone]").val()); }); $("#toggle_pay_info").click(function(){ $("#pay_info").toggle(); }); /* $('#show_order').bind("mouseover",function(){ $('.order_list').show(); }).bind("mouseout",function(){ $('.order_list').hide(); }); $('.order_list').hide(); $('.order_list').draggable(); */ $('.change_operator').live('change',function(){ var O = $(this).attr('OID'); var OP = $(this).find('option:selected').val(); $.post("load_order.php", {type:'change_operator',OID:O,Operator:OP}); $('#item'+O).find('td:last-child').text(OP); alert('Order '+O+' Changed operator '+OP); }); $('#reset_table').live('click',function(){ var tarr = []; var O = $(this).attr('OID'); $('#reselect_table').find('input[name="table"]:checked').each(function(){ tarr.push($(this).val()); }); tarr = tarr.join(','); $.post("load_order.php", {type:'change_table',OID:O,table:tarr}); $('#selected_table').text(tarr); $('#item'+O).find('.item_list').text(tarr); //alert('Order '+O+' Changed Table '+tarr); }); $('#set_table').live('change',function(){ var O = $(this).attr('OID'); var tb=$(this).val(); $.post("load_order.php", {type:'set_table',OID:O,table:tb}); $("#order_table_"+O).text(tb); }); $('#set_status').live('change',function(){ var O = $(this).attr('OID'); var st=$(this).val(); $.post("load_order.php", {type:'set_status',OID:O,status:st}); $("#order_status_"+O).text(st); }); $("#loading").show(); /* 讀取xml 開始 ------------------------------------------------------------------------------ */ var path_image=''; $.ajax({ url:'./xml/store-zen-oasis.xml',//公司資料 type: 'GET', dataType: 'xml',//資料型態可以不設定,且此型態不可是text或html cache:false, timeout:10000, error: function(xml){ alert('Reading xml error, reload company page ./xml/store-zen-oasis.xml'); //當xml讀取失敗 //location.reload(); }, success: function(xml){ var store = $(xml).find("store"); $('title').text(store.find('MenuTitle').text()); $('#Business').html(store.find('Business').text()); $('meta[name=Description]').attr("content",store.find('Description').text()); //$('#Shopkeeper').html(store.find('Shopkeeper').text()); $('#Address').html(store.find('Address').text()); $('#Telephone').html(store.find('Telephone').text()); $('#pay_info').html(''+store.find('pay_info').html()+''); //$('#Fax').html(store.find('Fax').text()); $('#Email').html(store.find('Email').text()); $('#paypal_business').val(store.find('paypaloption').find('business').text()); $('#store').show(); //檢查假日 店休日 var now = new Date(); var weekday=now.getDay(); var hours = now.getHours(); var minutes = now.getMinutes(); if(hours<10){hours='0'+hours} if(minutes<10){minutes='0'+minutes} var ss=false; var close_day=store.find("weekday_close").text().split(","); $.each(close_day,function(k,v){ if(v==weekday){ ss=true; } }); if(ss){ var open_t=store.find("business_time").find("open").text(); var close_t=store.find("business_time").find("close").text(); let ttt=hours+":"+minutes; if (ttt >= open_t && close_t > ttt) { } else { //alert("non-business time "+open_t+" "+close_t+" "+ttt); } //alert(ot+" "+now+" "+ct); }else{ // alert("non-business day");//+store.find("weekday_close").text().split(",")+' '+weekday); //比較1. 還有例假日 2 }//比較3 開, 4 關 }}); $.ajax({ url:'./xml/menu-zen-oasis.xml',//菜單 type: 'GET', dataType: 'xml',//資料型態可以不設定,且此型態不可是text或html cache:false, timeout:10000, error: function(xml){ alert('Reading xml error, reload menu page ./xml/menu-zen-oasis.xml'); //當xml讀取失敗 //location.reload(); }, success: function(xml){ $("#loading").hide(); $(xml).find("menu").each(function(ii){ //取得xml父節點 var menu_total = $(xml).find("menu").length;//xml的總筆數 var menu = $(this).attr("title"); var menu_id = "menu"+ii;//menu.replace(' ','-'); var menu_id2 = '#'+menu_id; var menu_note=$(this).attr('note'); var menu_content = $(this).find('content').html(); var path_image="zen-oasis.webp";//$(this).find('path_image').text(); //alert(i); let service_weekday=$(this).attr("service_weekday"); let service_start_time=$(this).attr("service_start_time"); let service_end_time=$(this).attr("service_end_time"); let url=($(this).attr("url")==undefined)?'':$(this).attr("url"); //口味 var spice=['NO','MILD','MEDIUM','HOT','VERY HOT']; //檢查假日 店休日 var now = new Date(); var weekday=now.getDay(); var hours = now.getHours(); var minutes = now.getMinutes(); if(hours<10){hours='0'+hours} if(minutes<10){minutes='0'+minutes} if(service_weekday!=undefined){ var ss=false; var service_day=service_weekday.split(","); $.each(service_day,function(k,v){ if(v==weekday){ ss=true; } }); if(ss){ // alert(menu+" is service"); }else{ } } // var photosrc=$(this).find("title").text(); //取得子節點中的src //alert(menu_note); if(url!=''){ $('#menulist > ul').append('
  • '+menu+'
  • '); }else{ $('#menulist > ul').append('
  • '+menu+'
  • '); } var put_content=''; if(menu_content){ put_content=''; } var put_note=''; if(menu_note!=undefined){ //put_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('

    '+catalogue+'

    '); if(display!='off'){ $(menu_id2+' > ul').append('
  • '+catalogue+'
  • '); $(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 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 allowMultiple = $(this).find("allowMultiple").text(); var description = ''; $(this).find("description").each(function(){ if($(this).attr("lang")==undefined){ description += ($(this).text()=='')?'':'
    '+ $(this).text()+'
    ' }else{ description += ($(this).text()=='')?'':'
    '+ $(this).text()+'
    ' } });//多國注解 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=='')?'':''; /* */ 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)?'':'
  • C
  • '; //show_button = (ll <= 0)?'
    SOLD OUT
    ':show_button+''+show_extra; //呼叫資料庫統計數量 物件 call MAX //'+$(this).children("price").attr("currency")+' /* var show_item = '' +'' +'' +'' +'' +'' +'' +'' +'
    '+other+ophoto+''+name+''+description+' $'+price+' / '+show_button+''+show_extra+'
    '; 菜單物件 var show_item_old = ''; */ let font_size=(name.length>=30)?"font-size:1.1em;white-space:nowrap;":""; var show_item2 = ''; 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 = '
    Order Info
    '+place+'
    Date: '+date+'
    Note:'+note+'
    '; //$('#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); $(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()+'

    '; //WeightCalorieTotal'+$("#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; 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 = ''+code+'' +'
    '+name+'
    '+note_textarea.join("
    ")+''+(parseFloat(unit_price)+parseFloat(opt_price))+''+qty+''+sub_price+'' +''; $("#my_order_list tbody").append(SD);//編輯窗 $(this).parents('ul').find('.item_count').text("0"); $(this).parents('ul').find('.item_note_area').hide(); $(this).parents('ul').find('.item_count').hide(); $(this).parents('ul').find('.cut').hide(); let ss_note=(note_textarea)?'
    '+note_textarea.join("
    ")+'
    ':''; let add_info="Added to order

    "+name+'
    '+ss_note+' $'+unit_price+' * '+qty+' = $'+sub_price+'

    '; tempAlert(add_info,1250); //alert(add_info); // $(".add_item_fade").remove(); /* $("body").append('
    '+add_info+'
    '); $("#add_item_fade").fadeOut(3000, function(){ $(this).remove(); });*/ $("#count_item,#count_item2,#total_qty").html(count_item()); }else{ alert("Maximum quantity : '"+cc+"'"); } }); $(".Order_Item").bind(myUp,function(){ //$('.order_list').show().delay(10000).slideUp(800); $('#add_to_order').show(); $("#show_order").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 note_textarea=$(this).parents('ul').find('.item_memo').text()+' '+$(this).parents('ul').find('.item_type').text(); var item_count=$(this).parents('ul').find('.item_count'); var note_textarea=$(this).parents('ul').find('.item_note').val();; //alert(note_textarea); //var allowMultiple = $(this).attr('allowMultiple'); var pc=$('#c'+catalog).text(); var ic =item_count.text(); if($(this).hasClass('cut')){ quantity = 0 - quantity; //alert(pc); ic=(ic=='')?1:parseInt(ic)-1; if(ic>0){ item_count.text(ic); //$('#c'+catalog).text(parseInt(pc)-1); }else{ item_count.text("0"); $(this).parents('ul').find('.item_note_area').hide(); } } var cc = $(this).parents('ul').find('.item_supply').text(); var ss = cc - quantity; if($(this).hasClass('add')){ $(this).parent().find('.cut').show(); item_count.show(); $(this).parents('ul').find('.item_note_area').show(); ic=(ic=='')?1:parseInt(ic)+1; item_count.text(ic); //pc=(pc=='')?1:parseInt(pc)+1; //$('#c'+catalog).show().text(pc); } //var ss2 = cc - ic; // $(this).parents('ul').find('.item_supply').text(ss2); //alert(ss2); $.post("load_stock.php",{type:"get_items_stock_qty",code:code},function(re){ // alert(re); if(ic > re){ item_count.text(re); alert("Max Order:"+re); } }); $(this).parents('ul').find('.item_price').find('.qty_price').show(); }); $('.item_note').bind("focusout",function(){ var code=$(this).parents('ul').attr('code'); $("#item_list_"+code).find('td:eq(3)').text($(this).val()); $("#pv_"+code).find('td:eq(2)').text($(this).val()); }); //$("#datepicker").datepicker({startDate: new Date(),selectWeek:true,closeOnSelect:false,dateFormat: 'dd-mm-yy', minDate:'+0d', maxDate: "+60D"}); //, stepMinute: 30,ampm: true,separator: ' @ ', //$('#selector').datetimepicker() //$(".extra_item").draggable(); $('.toggle_extra').bind(myDown,function(){ $(this).prev('.extra_item').toggle(); var zi = parseInt($(this).parents('ul').css("z-index")) + 2; //$(this).append(zi); $(this).parents('ul').css("z-index", zi); //alert($(this).parent().css("z-index")); //$(this).next('.extra_item').find('p').eq(0).html($(this).parents('table').find('.item_name').html()); /* $(this).next('.extra_item').dialog({ show: "blind", position: ['center',120], width: 400, height: 400, modal: true, title:'My Order List', overlay:{opacity: 0.7, background: "#FF8899" }, buttons: { "Close": function() {$(this).dialog('close').destroy();}} }); */ }); $('#inside').show(); $('#outside').hide(); $('#person_contact_data1').show(); $('#person_contact_data2').hide(); $("input[name='place']").change(function () { var ss=$(this).val(); if(ss == 'Dine in payment'){ $('#inside').show(); $('#outside').hide(); if($("input[name='when']:checked").val()=='Dine_in'){ $('#person_contact_data1').show(); $('#person_contact_data2').hide(); } }else{ $('#inside').hide(); $('#outside').show(); $('#card_info').show(); //$('#person_contact_data').show(); } }); $("input[name='when']").change(function () { var ss=$(this).val(); if(ss == 'Dine_in'){ $('#person_contact_data1').show(); $('#person_contact_data2').hide(); var set_minDate="+0d"; $("input[name=pick_date]").val(''); }else{ $('#person_contact_data1').hide(); $('#person_contact_data2').show(); var set_minDate="+3d"; $("input[name=pick_date]").val(''); } $('#pick_date').datepicker( "option",$.datepicker.regional["en-AU"]); $('#pick_date').datepicker( "option", "minDate", set_minDate ); //alert(set_minDate); }); $('#pick_date').datepicker({dateFormat: "yy-mm-dd",minDate:"+0d", maxDate: "+30D",showWeeks: true,beforeShowDay: function(date) { var day = date.getDay(); return [(day != 0), '']; }}); $("input[name='pay_type']").change(function () { var ss=$(this).val(); if(ss == 'card'){ $('#card_info').show(); }else{ $('#card_info').hide(); } }); /* $('#person_contact_data').hide(); $("input[name='pay_type']").change(function () { if($(this).val()=="PAYPAL"){ $('#person_contact_data').show(); }else{ $('#person_contact_data').hide(); } }); */ //$('#timeside').hide(); //$('#timeside').append(''); //.val(saerchDate); /* $('#reservation_time').datetimepicker({dateFormat: "yy-mm-dd",timeFormat: 'hh:mm',minDate:'+0d', maxDate: "+0D",hourMin: 17,hourMax: 21}).datetimepicker('setDate', new Date()); $("input[name='when']").change(function () { $('#timeside').empty(); $('#timeside').append(''); $('#reservation_time').empty(); if($(this).val() == 'reservation'){ $('#person_contact_data').show(); $('#reservation_time').datetimepicker({dateFormat: "yy-mm-dd",timeFormat: 'hh:mm',hourMin: 17,hourMax: 21,minDate:'+0d', maxDate: "+30D",showWeeks: true, firstDay: 1, changeFirstDay: false }).focus(); }else if($(this).val() == 'in-store'){ if($("input[name='place']:checked").val()=='Dine in'){ $('#person_contact_data').hide(); } $('#reservation_time').datetimepicker({dateFormat: "yy-mm-dd",timeFormat: 'hh:mm',minDate:'+0d', maxDate: "+0d",hourMin: 17,hourMax: 21}).datetimepicker('setDate', new Date()); } }); */ $('#OLD_ORDER').bind(myDown,function(){ //var yourword=prompt('Please input back house password',''); //$.cookie("password",yourword); $('#show_status').tabs().tabs('load', 0).show(); //alert("Data Loaded: " + data); $("#list_server_order").dialog({ autoOpen: true, // show: "blind", position: ['center',40], width: "90%", height: $(window).height() - 60, modal: true, draggable: true, title:'' }); }); $("#item_info").dialog({ autoOpen: false, // show: "blind", position: { my: "center center", at: "center center"}, width: maxW, height: $(window).height() - 30, modal: true, draggable: true, buttons: { Close: function() { $( this ).dialog( "close" ); } } }); function nl2br (str, is_xhtml) { if (typeof str === 'undefined' || str === null) { return ''; } var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
    ' : '
    '; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); } $(".item_info").live(myDown,function(){ var code=$(this).parents("ul").attr("code"); var name=$(this).parents("ul").find(".item_name_name").text(); var image=$(this).parents("ul").find(".item_image").find("img").first().attr("src"); var ophoto=$(this).parents("ul").find(".item_ophoto").html(); var imemo=$(this).parents("ul").find(".item_memo").text(); var itype=$(this).parents("ul").find(".item_type").text(); var xml_desc=$(this).parents("ul").find(".xml_desc").text(); //alert(code); $.ajax({ url:'./load_table.php?type=XML&code='+code, type: 'GET', dataType: 'xml',//資料型態可以不設定,且此型態不可是text或html cache:false, timeout:3000, error: function(xml){ // alert('Not find XML '+code+' !'); //當xml讀取失敗 var data=''; data+='

    '+name+' '+imemo+' '+itype+'

    '; data+='
    '; data+=(ophoto==null)?'':''; $("#item_info").html(data+xml_desc).dialog({title:code+' '+name}).dialog('open'); }, success: function(xml){ // alert(xml); var data=''; data+='

    '+name+' '+imemo+' '+itype+'

    '; data+='
    '; data+=(ophoto==null)?'':''; $(xml).find("title").each(function(){ // data+="

    "+$(this).attr("name1")+"

    "; data+=($(this).attr("name1")!=undefined)?"

    "+$(this).attr("name1")+"

    ":""; data+=($(this).attr("name2")!=undefined)?"

    "+$(this).attr("name2")+"

    ":""; data+=($(this).attr("name3")!=undefined)?"

    "+$(this).attr("name3")+"

    ":""; data+=($(this).attr("name4")!=undefined)?"

    "+$(this).attr("name4")+"

    ":""; if($(this).attr("type")=='table'){ data+=''; var tt=$(this).html().split(/\r?\n/); $.each(tt, function(k,s){ //var ss=s.split(/\t/); var col=''; var cc=s.split(/\t/).length; if(cc <=2){ col='colspan="4"'; } data+=""; data+="" data+=""; }); data+="
    "+s.replace(/\t/g,"")+"
    "; }else if($(this).attr("type")=='html'){ data+=$(this).html(); }else{ data+='
    '+$(this).html().trim().replace(/\r?\n/g,"
    ")+"
    "; } }); $("#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+='
    '+sss+''+name+'' ccc+=''+get_qty+' / '+qty+'' ccc+='
    '; */ tot_item+=parseInt(get_qty); ccc+=''; }); if($(".add_to").length==0){ $("#change_info").htm("Please choice Item!"); $("#obj_order").hide(); $("#confirm_change").css("display","none"); }else{ //$("#change_info").html('
    '+ccc+'
    "); $("#change_info").html(ccc+'
    Select Items:'+tot_item+"
    "); $("#obj_order").show(); $("#confirm_change").css("display","block"); //alert(ccc); } }); $("#confirm_change").on(myDown,function(){ let zzz=$("#change_qty").serialize(); //alert(OID); /* let all={}; let sqty=[]; let obj_order=$("input[name=obj_name]:checked").val(); $("input[class=change_qty]").each(function(){ let iid=$(this).attr("iid"); let set_qty=$(this).val(); let max_qty=$(this).attr("max"); sqty.push({iid:iid,set_qty:set_qty,max_qty:max_qty}); }); */ // all={"obj_order":obj_order,"qty":sqty}; //alert(zzz); $.post("load_order.php",zzz,function(dd){ $(".add_to").each(function(){ let ptr=$(this).parent().prev('tr'); let qty=ptr.find(".item_qty").text(); let get_qty=$(this).text(); if(qty==get_qty){ ptr.find(".item_qty").text("0"); }else{ ptr.find(".item_qty").text(qty-get_qty); } $(this).text(""); $(this).removeClass("add_to"); }); //alert(dd); //$("#item"+OID).trigger(myDown); // alert(dd); }); }); }); //alert($(this).attr('title')) }); $('.close_extra').bind(myDown,function(){ $(this).parents('ul').css("z-index", '0'); $(this).parent().hide(); }); $('#menulist').tabs({ cookie: { expires: 3600 } });//.addClass( "ui-tabs-vertical ui-helper-clearfix" ); //$( "#menulist li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" ); $('.catalogue').tabs(); $('#show_status').hide(); $("#New_Order").click(function(){ if(confirm('Start a new order!')){ location.reload();} }); $("#SEARCH_MY_ORDER").click(function(){ $("#search_order_box").dialog({ autoOpen: true, show: "blind", position: ['center',100], width: $(window).width() - 10, height: $(window).height() - 200, modal: true, draggable: true, title:'My Order' ,buttons: { "VIEW":function(){ }}}); //alert('ENTER YOUR EMAIL………(TEST) NEED EMAIL OR PHONE'); }); /* $('input[name="select_reservation"]').change(function(){ if($(this).is(":checked")){ alert('Early booking, Your order quantities will be prepared'); $('#Current').attr("disabled",true); $('#Reservation').attr('checked',true) $('#timeside').html('Date: '); $('#datepicker').empty(); $('#person_contact_data').show(); $('#datepicker').datetimepicker({dateFormat: "dd-mm-yy",timeFormat: 'hh:mm',hourMin: 17,hourMax: 21,minDate:'+1d', maxDate: "+30D",showWeeks: true, firstDay: 1, changeFirstDay: false }); $('.item_quantity').show(); $('.item_supply').text('999'); $('.item_buy').find('a').show(); $('.item_custom').find('a').show(); $('.SOLD_OUT').remove(); }else{ alert('Loading avaliable qty'); location.reload(); } }); */ $(".check_status").live(myDown,function () { var istatus = false; let iid=$(this).attr("iid"); var j=''; //alert(iid); $.post("load_table.php", {type:'get_item_status',iid:$(this).attr('iid')},function(data){ //alert(data); var j = jQuery.parseJSON(data); $("#item_"+iid).find(".istatus").removeClass().addClass("istatus").addClass(j.istatus).text(j.status_name); $("#item_"+iid).find(".utime").text('@['+j.utime+']'); $("#item_"+iid).find(".opter").text('['+j.opter+']'); }); // $(this).html(''+j.status_name+''+j.opter); }); $(".Service_item").live(myDown,function () { var istatus = false; let iid=$(this).attr("iid"); if($(this).hasClass('Leaves')){ $(this).removeClass("Leaves").addClass("Sending"); istatus = 'Sending'; $(this).html('Sendng'); }else if($(this).hasClass('Sending')){ $(this).removeClass("Sending").addClass("Served"); istatus = 'Served'; $(this).html('Served'); }else if($(this).hasClass('Served')){ $(this).removeClass("Served").addClass("Leaves"); istatus = 'Leaves'; $(this).html('Ready'); } //console.log(istatus+' '+code+' '+iqty); if(istatus){ $.post("load_table.php", {type:'update_istatus',iid:$(this).attr('iid'),status:istatus}); } }); $("#select_reservation").click(function(){ //alert('1. Click "Booking" for reserve sets \n\n 2. You can also pre-order, your meal will be ready on time'); $('#add_to_order').text('Booking '+$('#table_date').val()).show(); $('#Current').attr("disabled",true); $('#Reservation').attr('checked',true); $('#timeside').html(''); //$('#reservation_time').empty(); $('#person_contact_data').show(); $('#reservation_time').datetimepicker({dateFormat: "yy-mm-dd",timeFormat: 'hh:mm',hourMin: 17,hourMax: 21,minDate:'+0d', maxDate: "+30D",showWeeks: true, firstDay: 1, changeFirstDay: false}); $('.item_quantity').show(); $('.item_supply').text('999'); //$('.item_buy').find('a').show(); $('.item_custom').find('a').show(); $('.SOLD_OUT').remove(); // $("#my_order_list tbody").append('xxx' +'Booking100' +''); $(this).hide(); }); $('.zoom_image').bind(myDown,function(){ var pp = $(this).parents('ul'); if(pp.css("z-index") == '1'){ var zi = parseInt(pp.css("z-index")) + 2; //$(this).text('Info'); pp.css("z-index", zi); //pp.css("background-color","#fff"); pp.find('.item_other').show(); pp.find('.item_ophoto').show(); pp.find(".item_image_info").css({overflow:'visible'}); pp.find('.item_name').css('background-color','#f0e8e8'); //pp.find('.item_image').css({width: "150%"}); pp.find('.item_count').css({right: "-=100%"}); pp.find('.item_desc').show(); //var t = setTimeout($('.zoom_image').trigger(myDown), 2000 ); }else{ pp.css("z-index", 1); pp.css("background-color",""); pp.find('.item_other').hide(); //pp.find('.item_ophoto').hide(); pp.find(".item_image_info").css({overflow:'hidden'}); pp.find('.item_name').css('background-color',''); //pp.find('.item_image').css({ width: "96%"}); pp.find('.item_count').css({right: "+=100%"}); pp.find('.item_desc').hide(); }}); /* $(".item_image_info").hover(function() { var zi = parseInt($(this).parents('ul').css("z-index")) + 2; $(this).parents('ul').css("z-index", zi); $(this).find('.item_other').show(); $(this).find('.item_ophoto').show(); $(this).css('overflow','visible'); $(this).parent().find('.item_name').css('background-color','#f0e8e8'); //find('.item_image') $(this).find('.item_image').css({width: "150%", left: "-=25%", top: "-=25%"}); /*.animate({ // height: "250", width: "150%", left: "-=30px", top: "-=30px" }, "fast"); * }, function() { // hover out $(this).parent().css("z-index", 0); $(this).find('.item_other').hide(); $(this).find('.item_ophoto').hide(); $(this).css('overflow','hidden'); $(this).parent().find('.item_name').css('background-color',''); $(this).find('.item_image').css({ width: "100%", left: "+=25%", top: "+=25%"});/*.animate({ // height: "150", width: "100%", left: "+=30px", top: "+=30px" }, "fast");* }); */ /* if($('#table_icon').hasClass('bbg')==true){ $(".item_buy").hover(function() { $(this).parents('ul').find('.item_desc').show(); }, function() { // hover out $(this).parents('ul').find('.item_desc').hide(); }); } */ $(".item").live(myDown,function () { if($(this).hasClass('click_item')){ $(this).removeClass("click_item"); $(this).addClass("dbclick_item"); }else if($(this).hasClass('dbclick_item')){ $(this).removeClass("dbclick_item"); $(this).removeClass("click_item"); }else{ $(this).addClass("click_item"); } $.post("load_order.php", {type:'update_content',OID:$(this).parents('.content').attr('OID'),content:$(this).parents('.content').html()}, function(data){ //alert(data); //alert('Update Order '+$('#OID').text()); }); }); $.post("load_table.php",{type:"get_items_qty"},function(stock){ var item_qty = jQuery.parseJSON(stock); //alert(stock); $('.item_supply').each(function(){ var code = $(this).attr('code'); var ccc = 0; if(item_qty[code] !== undefined){ ccc=parseInt(item_qty[code].stock_qty)-parseInt(item_qty[code].safe_qty); var price=item_qty[code].price*100; if(item_qty[code].price!='' && item_qty[code].price!==undefined && item_qty[code].price!==NaN){ $(this).parent().find(".uprice").text(item_qty[code].price); } //$(this).parents('ul').find(".item_name").find(".item_name_name").text(item_qty[code].name); } if(ccc <= 0){ //$(this).parent().parent().html('www'); //$(this).prev('.item_quantity').hide(); $(this).parents('ul').find('.item_buy').html('
    SOLD OUT
    '); }else{ $(this).text(ccc);} }); }); }//end xml }); /* $( "#my_order_list tbody" ).sortable({ delay: 300 }); $( "#my_order_list tbody" ).disableSelection(); var eoid=$.url.param("edit_order"); if(eoid != undefined){ //$('#OLD_ORDER').trigger(myDown); alert('EDIT ORDER '+eoid); } */ });