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 >800)?800:width-20; }); 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 count_item(){ var count_item = 0; $("#my_order_list tbody tr").each(function(){ count_item += parseInt($(this).find('td:eq(4)').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(4)').text()) * parseFloat($(this).find('td:eq(5)').text()); }); return parseFloat(sum_total).toFixed(0); } function sum_calorie(){ var s = 0; $("#my_order_list tbody tr").each(function(){ s += parseInt($(this).find('td:eq(4)').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(4)').text()) * parseFloat($(this).find('li[title="weight"]').text()); }); return s; } function clock_now() { var now = new Date(); var timeStr; var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); timeStr = ' '+hours; timeStr += ((minutes < 10 && minutes > 0) ? ":0" : ":") + minutes; timeStr += ((seconds < 10) ? ":0" : ":") + seconds; $("#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(); //alert(si); location.href="/?s="+si; }); $("#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); }); $("#loading").show(); /* 讀取xml 開始 ------------------------------------------------------------------------------ */ var path_image=''; $.ajax({ url:'./xml/store-崇華食品.xml?2023',//公司資料 type: 'GET', dataType: 'xml',//資料型態可以不設定,且此型態不可是text或html cache:true, timeout:10000, error: function(xml){ alert('Reading xml error, reload company page'); //當xml讀取失敗 location.reload(); }, success: function(xml){ //var SUPPLY = all_qty.qty;//alert(SUPPLY['E001']); //var SOLD = all_qty.sold; // SSSSS@ddd.dd //$("#loading").hide(); 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(); //alert($('#Operator').text()); }}); $.ajax({ url:'../xml/menu-崇華食品.xml',//菜單 type: 'GET', dataType: 'xml',//資料型態可以不設定,且此型態不可是text或html cache:false, timeout:10000, error: function(xml){ alert('Reading xml error, reload menu page'); //當xml讀取失敗 location.reload(); }, success: function(xml){ //var SUPPLY = all_qty.qty;//alert(SUPPLY['E001']); //var SOLD = all_qty.sold; // SSSSS@ddd.dd $("#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_content = $(this).find('content').html(); var path_image="崇華食品圖片.webp";//$(this).find('path_image').text(); //alert(i); // var photosrc=$(this).find("title").text(); //取得子節點中的src //alert(menu_note); $('#menulist > ul').append('
  • '+menu+'
  • '); var put_content=''; if(menu_content){ put_content=''; } $('#menulist').append('
    '+put_content+'
    '); //

    '+menu+'

    //alert(menu+' SSS'); $(this).find("catalogue").each(function(cc){ var catalogue = $(this).attr("title"); var catalogue_id = "cata"+cc;//catalogue.replace(' ','-'); var cid = menu_id+'_'+catalogue_id; var ii=0; // $('#'+menu_id+'').append('

    '+catalogue+'

    '); $(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 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(); 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 extra = []; var note=''; var default_qty = 1; var other =''; var order_button_add = '+'; var order_button_cut = ''; 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 = ''; 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')); }); $("#add_to_order,#show_order").live(myDown,function(){ $(".order_list").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(); if(xitem == 0){ alert('請挑選您要購買的產品'); }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('更新訂單')").hide(); }else{ $(".ui-dialog-buttonpane button:contains('更新訂單')").show(); } if(xitem == 0){ $(".ui-dialog-buttonpane button:contains('確認購買')").hide(); }else{ $(".ui-dialog-buttonpane button:contains('確認購買')").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(4)').text() var recode = parseInt(supply) + parseInt(buy); $.post("session_cart.php", {act:'cut',code:code,qty:'0'}); $.post("session_cart.php", {act:'save_list',list:$("#my_order_list tbody").html()}); $('.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(4)').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: '/' }); */ }); $(".Order_Item").bind(myUp,function(){ //$('.order_list').show().delay(10000).slideUp(800); $('#add_to_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 note_textarea=$(this).parents('ul').find('textarea[name=note]').val(); //alert(note_textarea); //var allowMultiple = $(this).attr('allowMultiple'); var pc=$('#c'+catalog).text(); var ic =$(this).parents('ul').find('.item_count').text(); if($(this).hasClass('cut')){ quantity = 0 - quantity; //alert(pc); ic=(ic=='')?1:parseInt(ic)-1; if(ic!=0){ $(this).parents('ul').find('.item_count').text(ic); $('#c'+catalog).text(parseInt(pc)-1); } $.post("session_cart.php", {act:'cut',code:code,qty:ic}); $.post("session_cart.php", {act:'save_list',list:$("#my_order_list tbody").html()}); } var cc = $(this).parents('ul').find('.item_supply').text(); var ss = cc - quantity; $(this).parents('ul').find('.item_price').find('.qty_price').show(); if(ss >= 0){ if($(this).hasClass('add')){ $(this).parent().find('.cut').show(); ic=(ic=='')?1:parseInt(ic)+1; $(this).parents('ul').find('.item_count').text(ic); pc=(pc=='')?1:parseInt(pc)+1; $('#c'+catalog).show().text(pc); $.post("session_cart.php", {act:'add',code:code,qty:pc}); $.post("session_cart.php", {act:'save_list',list:$("#my_order_list tbody").html()}); } //change_uprice(code,ic); var oprice=$(this).parents("ul").find(".uprice").text(); var new_price=''; if($(this).parents("ul").find(".qty_price")!=undefined){ $(this).parents("ul").find(".qty_price").find("li").each(function(x){ var more=parseInt($(this).attr("more")); if(ic >= more){ new_price=parseInt($(this).attr("price")); } }); } if(new_price!=''){ $(this).parents("ul").find(".uprice").text(new_price); $("#my_order_list tbody tr").each(function(){ var title=$(this).attr("title"); if(code==title){ $(this).find('td:eq(5)').text(new_price); } }); } //console.log(code+' '+ic+' '+oprice+' '+new_price); /* if($(this).hasClass('no_extra')){ alert(name+' Without Custom Options !'); } */ if($(this).parent().hasClass('extra_item')){ $(this).parent().hide(); $(this).parents('ul').css("z-index", '0'); } //收集外加清單內的資訊 textarea,option,radio var extra = []; if($(this).next('ul').find('li').length != 0 ){ //var note ='YES'; $(this).next('ul').find('li').each(function() { //alert($(this).get(0).tagName); //extra = extra +" , "+ $(this).attr('name'); var type=$(this).attr('class'); /* switch (type) { case 'select': extra.push('
  • '+ $(this).find('select').eq(0).attr('name') + ':' +$(this).find('select option:selected').eq(0).text()+'
  • '); break; case 'radio': var vv =$(this).find('input:checked').val(); var rr = (vv == undefined)?'':"
  • "+$(this).find('input').eq(0).attr('name') + ':' +$(this).find('input:checked').eq(0).val()+'
  • '; extra.push(rr) ; break; case 'textarea': rr = ($(this).find('textarea').eq(0).val()=='')?'':"
  • "+ $(this).find('textarea').eq(0).attr('name') + ':' +$(this).find('textarea').eq(0).val()+'
  • '; extra.push(rr) ; break; default: } */ switch (type) { case 'select': extra.push('
  • '+$(this).find('select option:selected').eq(0).text()+',
  • '); break; case 'radio': var vv =$(this).find('input:checked').val(); var rr = (vv == undefined)?'':"
  • "+$(this).find('input:checked').eq(0).val()+',
  • '; extra.push(rr) ; break; case 'textarea': rr = ($(this).find('textarea').eq(0).val()=='')?'':"
  • "+$(this).find('textarea').eq(0).val()+',
  • '; extra.push(rr) ; break; default: } }); } //var SC = ""+$('#item_name_'+$(this).attr('title')).html() + " "+ $('#item_name_'+$(this).attr('title')).next().html()+" "+ $('#item_name_'+$(this).attr('title')).next().next().html()+""; //var SC = ''+name+''+quantity+''; //$("#table_list tbody").append(SC);//預覽窗 /* if($("#table_list tr").length > 5){ $("#table_list tr:first-child").fadeOut(300, function(){ $(this).remove();}); } */ //var quantity = (allowMultiple=='true')?'':''; //菜名 時間 var vc=''; var match_quantity='test'; var calorie = $(this).parents('ul').find('.calorie').text(); var weight = $(this).parents('ul').find('.weight').text(); var unit_price = $(this).parents('ul').find('.uprice').text(); //console.log(unit_price); $("#my_order_list tbody tr").find('td:eq(0)').each(function(i){ vc = $("#my_order_list tbody tr:eq("+i+")").find('td:eq(3)').text(); //&& extra.length==0 && vc =='' if($(this).text()==code ){ //vc='1'; match_quantity = parseInt($("#my_order_list tbody tr:eq("+i+")").find('td:eq(4)').text()) + quantity; //alert($("#my_order_list tbody tr:eq("+i+")").find('td:eq(4)').text()+'+'+quantity ); if(match_quantity == 0 ){ $("#my_order_list tbody tr:eq("+i+")").find('.RI').trigger(myDown); //alert('Item Clean!'); }else if(match_quantity < 0 ){ alert('ERROR!'); }else{ var sub_p = match_quantity * unit_price; $("#my_order_list tbody tr:eq("+i+")").find('td:eq(4)').text(match_quantity); $("#my_order_list tbody tr:eq("+i+")").find('td:eq(6)').text(parseFloat(sub_p).toFixed(0)); //alert(match_quantity); //console.log(sub_p); } //alert(i); } }); if(match_quantity == 'test' && quantity > 0){ var sub_price = unit_price * quantity; sub_price = parseFloat(sub_price).toFixed(0); var custom = (extra.length!=0)?'':'';//客製化加註 var mark = (catalogue == 'Entree')?'*':''; //
  • '+calorie+'
  • '+weight+'
  • var SD = ''+code+'' +'
    '+mark+name+custom+'
    '+note_textarea+' '+extra.join(' ')+''+quantity+''+unit_price+''+sub_price+'' +''; $("#my_order_list tbody").append(SD);//編輯窗 //console.log(unit_price); $(this).parents('ul').find('.item_supply').text(ss); }else if(match_quantity >= 0){ $(this).parents('ul').find('.item_supply').text(ss); if(match_quantity == 0){ $(this).hide();} } $("#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(3)').text()+''+$(this).find('td:eq(4)').text()+''; }); //-名稱數量 var ptable = '
    ' +item_title +'

    ' +'
    小計 : $'+$("#price").text()+'.-

    '; $('#perview_total').html(ptable); /* calorie = parseFloat($("#calorie").text()) + parseFloat(calorie); $("#calorie").html(calorie); weight = parseFloat($("#weight").text()) + parseFloat(weight); $("#weight").html(weight); total_price = parseFloat($("#price").text()) + parseFloat(sub_price); $("#price").html(parseFloat(total_price).toFixed(0)); $('#perview_total').html('
    WeightCaloriePrice
    '+weight+''+calorie+''+parseFloat(total_price).toFixed(0)+'
    '); */ //$("#order_list").fadeIn(); //olen= olen+1; //var SCC=($.cookie("scart") == null)?"":$.cookie("scart"); //$.cookie("scart", SCC + SC, { path: '/' }); /* var SVC=($.cookie("svar") == null)?"":$.cookie("svar"); SV = (SVC == "")?SV:','+SV; $.cookie("svar", SVC + SV, { path: '/' }); window.open("?func=ORDER&o="+$(this).attr('title'),"_self"); */ }else if(cc !=0){ alert('('+name+') 存貨短缺。'); }else{ //alert('('+name+') 銷 售 完 畢'); //$(this).parents('ul').find('.SOLD_OUT').addClass('.SOLD_OUT_BIG'); } }); //$("#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 == '店內付款'){ $('#inside').show(); $('#outside').hide(); if($("input[name='when']:checked").val()=='自取'){ //$('#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 == '自取'){ $('#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["zh-TW"]); $('#pick_date').datepicker( "option", "minDate", set_minDate ); //alert(set_minDate); }); $('#pick_date').datepicker({dateFormat: "yy-mm-dd",minDate:"+0d", maxDate: "+90D",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() == '自取'){ 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: maxW, height: $(window).height() - 40, 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: { 關閉: 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(); //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('找不到XML '+code+' !'); //當xml讀取失敗 }, 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); $("#perview_server_order").dialog({ autoOpen: true, // show: "blind", position: ['center',60], width: $(window).width() - 10, height: $(window).height() - 100, 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(); },*/ "Print": {text: '列印訂單', class: 'print', click:function(){ var items=[]; $(this).find(".content table tbody tr").each(function(){ item={"item":$(this).find('td:eq(2)').text(),"count":$(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(); $.post("./pos/print_receipt.php",{OID:OID,operator:operator,table:table,people:people,place:place,note:note,bookat:bookat,items:items},function(dd){ alert(dd); }); //$.post("load_order.php", {type:'print_receipt',OID:OID}); }}, "關閉": function() {$(this).dialog('close');}}}); //alert(data); //alert('已儲存到SERVER'); }); //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(); } }); */ $("#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); $('.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); $(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('
    售完
    '); }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); } });