var workok2 = { '2025-12-31':'0000000000000000000011111111111111111111111111111111', '2026-01-01':'1111111111111111111111111111111111111111111111111111', '2026-01-02':'1111111111111111111111111111111111111111111111111111', '2026-01-03':'1111111111111111111111111111111111111111111111111111', '2026-01-04':'1111111111111111111111111111111111111111111111111111', '2026-01-05':'1111111111111111111111111111111111111111111111111111', '2026-01-06':'1111111111111111111111111111111111111111111111111111', }; $(document).ready(function(){ $.datepicker.setDefaults( $.datepicker.regional[ "ja" ] ); $("#mdc").datepicker({ showOn: "button", buttonText: "calendar_month", buttonImageOnly: true, onSelect: function(dateText) { // alert(dateText + 'ok'); location.href="schedule_staff.php?staff=2&d="+dateText; }, beforeShowDay: function(date) { const holiday = holiday_jp.between(date, date); if (holiday.length > 0) { return [true, "custom-calendar-holiday", ""]; } else if (date.getDay() === 0) { return [true, "custom-calendar-sunday", ""]; } else if (date.getDay() === 6) { return [true, "custom-calendar-saturday", ""]; } return [true, "custom-calendar-weekday", ""]; } }); $( "#mdc" ).datepicker("option", "dateFormat", 'yy-mm-dd' ); $( "#mdc" ).datepicker("setDate", "2025-12-31"); }); $(function(){ $("#logs").append(''); var isDraggable = false; var isResizable = "true"; var $sc = $("#schedule").timeSchedule({ startTime: "10:00", // schedule start time(HH:ii) endTime: "23:00", // schedule end time(HH:ii) widthTime: 60*15, // cell timestamp example 10 minutes widthTimeX:30, timeLineY: 75, // height(px) verticalScrollbar: 10, // scrollbar (px) timeLineBorder: 2, // border(top and bottom) bundleMoveWidth: 2, // width to move all schedules to the right of the clicked time line cell draggable: isDraggable, rows : { '2025-12-31' : { title : '12月31日(水)', schedule:[ { start: '11:00', end: '12:45', text: '', data: { 'class': "", 'id': 2884, 'status':0, pstart: '11:00', pend: '12:45', name:'イタハシ 様', kaikei:'会計', menu:'新規', route:'あわじの森', biko:'', biko2:'' } }, { start: '13:00', end: '15:00', text: '', data: { 'class': "done", 'id': 2885, 'status':5, pstart: '13:00', pend: '15:00', name:'休憩', kaikei:'', menu:'休憩', route:'あわじの森', biko:'', biko2:'' } }, ]/// },///// '2026-01-01' : { title : '1月1日(木)', schedule:[ ]/// },///// '2026-01-02' : { title : '1月2日(金)', schedule:[ ]/// },///// '2026-01-03' : { title : '1月3日(土)', schedule:[ ]/// },///// '2026-01-04' : { title : '1月4日(日)', schedule:[ ]/// },///// '2026-01-05' : { title : '1月5日(月)', schedule:[ ]/// },///// '2026-01-06' : { title : '1月6日(火)', schedule:[ ]/// },///// }, onChange: function(node, data){ addLog('onChange', data.id); }, onClick: function(node, data){ if(data.data.status==5){ modalResize(); node.find('.scheduleReservationInner').addClass("red"); // alert(data.data.id); changesc(data.data.id,data.start,data.end); ; }else{ if(data.data.status==2){ $('#bt_cancel').hide(); $('#bt_info').hide(); }else{ $('#bt_cancel').show(); $('#bt_info').hide(); } let p_left = node.position().left+ node.parent().position().left + 20; if(p_left > mainwidth-524){ p_left=mainwidth-524; } $('#orderdetail').css({'top':node.parent().position().top + 30,'left':p_left}); $('#orderdetail').show(); $('#order_id').val(data.data.id); $('#namearea').text(data.data.name); $('#kaikei').html(data.data.kaikei); $('#menuarea').text(data.data.menu); $('#timearea').text(data.data.pstart + ' - ' + data.data.pend); $('#routearea').text(data.data.route); $('#bikoarea').text(data.data.biko); $('#bikoarea2').text(data.data.biko2); } }, onAppendSchedule: function(node, data){ if(data.data.class){ node.addClass(data.data.class); } }, onScheduleClick: function(node, time, timeline){ var start = time; var end = $(this).timeSchedule('formatTime', $(this).timeSchedule('calcStringTime', time) + 3600); addsc( time,timeline); modalResize(); }, }); $sc.timeSchedule('setResizable', "true"); $('#bt_close').click(function() { $('#namearea').text(''); $('#menuarea').text(''); $('#timearea').text(''); $('#routearea').text(''); $('#bikoarea').text(''); $('#bikoarea2').text(''); $('#orderdetail').hide(); }); $('#bt_detail').click(function() { window.location.href ='order_detail.php?id=' + $('#order_id').val(); }); $('#bt_update').click(function() { window.location.href ='order_update.php?id=' + $('#order_id').val(); }); $('#bt_info').click(function() { window.location.href ='customer_info.php?id=' + $('#order_id').val(); }); $('#bt_cancel').click(function() { $('#cancel_id').val($('#order_id').val()) $("body").append("
"); $(".overlay").fadeIn(300); $("body").addClass("is-active"); modalResize(); $('#cancelwindow').show(); return false; }); $('#bt_close2').click(function() { $(".overlay").fadeOut(300); $('#cancelwindow').hide(); $('.overlay').remove(); $("body").removeClass("is-active"); }); $('#bt_close3').click(function() { $(".overlay").fadeOut(300); $('#addsc').hide(); $('.overlay').remove(); $("body").removeClass("is-active"); }); $('#bt_close4').click(function() { $(".scheduleReservationInner").removeClass("red") $(".overlay").fadeOut(300); $('#changesc').hide(); $('.overlay').remove(); $("body").removeClass("is-active"); }); $('#ret3').on('click', function(){ let maxm_n=$("#start_time_m3").children('option').length; let mn=$("#start_time_m3").prop("selectedIndex"); let maxh_n=$("#start_time_h3").children('option').length; let hn=$("#start_time_h3").prop("selectedIndex"); if(mn ==0){ $("#start_time_m3").prop("selectedIndex",maxm_n-1 ); if(hn ==0){ $("#start_time_h3").prop("selectedIndex",maxh_n-1); }else{ $("#start_time_h3").prop("selectedIndex",hn-1); } }else{ $("#start_time_m3").prop("selectedIndex",mn-1); } }); $('#go3').on('click', function(){ let maxm_n=$("#start_time_m3").children('option').length; let mn=$("#start_time_m3").prop("selectedIndex"); let maxh_n=$("#start_time_h3").children('option').length; let hn=$("#start_time_h3").prop("selectedIndex"); if(maxm_n - mn ==1){ $("#start_time_m3").prop("selectedIndex",0); if(maxh_n - hn ==1){ $("#start_time_h3").prop("selectedIndex",0); }else{ $("#start_time_h3").prop("selectedIndex",hn+1); } }else{ $("#start_time_m3").prop("selectedIndex",mn+1); } }); $('#ret4').on('click', function(){ let maxm_n=$("#end_time_m4").children('option').length; let mn=$("#end_time_m4").prop("selectedIndex"); let maxh_n=$("#end_time_h4").children('option').length; let hn=$("#end_time_h4").prop("selectedIndex"); if(mn ==0){ $("#end_time_m4").prop("selectedIndex",maxm_n-1 ); if(hn ==0){ $("#end_time_h4").prop("selectedIndex",maxh_n-1); }else{ $("#end_time_h4").prop("selectedIndex",hn-1); } }else{ $("#end_time_m4").prop("selectedIndex",mn-1); } }); $('#go4').on('click', function(){ let maxm_n=$("#end_time_m4").children('option').length; let mn=$("#end_time_m4").prop("selectedIndex"); let maxh_n=$("#end_time_h3").children('option').length; let hn=$("#end_time_h4").prop("selectedIndex"); if(maxm_n - mn ==1){ $("#end_time_m4").prop("selectedIndex",0); if(maxh_n - hn ==1){ $("#end_time_h4").prop("selectedIndex",0); }else{ $("#end_time_h4").prop("selectedIndex",hn+1); } }else{ $("#end_time_m4").prop("selectedIndex",mn+1); } }); $(window).resize(modalResize); function modalResize(){ var w = $(window).width(); var h = $(window).height(); var cw = $("#cancelwindow").outerWidth(); var ch = $("#cancelwindow").outerHeight(); $("#cancelwindow").css({ "left": ((w - cw)/2) + "px", "top": ((h - ch)/2) + "px" }); var cw2 = $("#addsc").outerWidth(); var ch2 = $("#addsc").outerHeight(); $("#addsc").css({ "left": ((w - cw2)/2) + "px", "top": ((h - ch2)/2) + "px" }); var cw3 = $("#changesc").outerWidth(); var ch3 = $("#changesc").outerHeight(); $("#changesc").css({ "left": ((w - cw3)/2) + "px", "top": ((h - ch3)/2) + "px" }); } $('.addyoyaku').click(function() { $('#errmsg').text(''); $.ajax({ url: "addscajax.php", type: "POST", dataType: "text", data: { "kind" : $(this).data('id'), "staff_id" : 2, "scname" : $('#addsc_name').val(), "st_h" : $('#start_time_h').val(), "en_h" : $('#end_time_h').val(), "st_m" : $('#start_time_m').val(), "en_m" : $('#end_time_m').val(), "sc_date" : $('#addsc_date').val(), } }).done(function (data) { if(data=="ok"){ location.reload(); }else if(data=="ng1"){ $('#errmsg').text("※入っている予約と時間が重なってる部分があります。"); }else if(data=="ng2"){ $('#errmsg').text("※送信エラー。再度お試しください"); }else{ $('#errmsg').text(data); } }).fail(function (data) { $('#errmsg').text("※送信エラー。再度お試しください"); }); }); $('.changeyoyaku').click(function() { $('#errmsg2').text(''); $.ajax({ url: "changescajax.php", type: "POST", dataType: "text", data: { "kind" : $(this).data('id'), "id" : $('#changesc_id').val(), "st_h" : $('#start_time_h3').val(), "en_h" : $('#end_time_h4').val(), "st_m" : $('#start_time_m3').val(), "en_m" : $('#end_time_m4').val(), } }).done(function (data) { if(data=="ok"){ location.reload(); }else{ $('#errmsg2').text("※送信エラー。" +data); } }).fail(function (data) { $('#errmsg2').text("※送信エラー。再度お試しください"); }); }); $('.yoyakucancel').click(function() { $('#errmsg3').text(''); $.ajax({ url: "cancelajax.php", type: "POST", dataType: "text", data: { "kind" : $(this).data('id'), "id" : $('#cancel_id').val(), } }).done(function (data) { if(data=="ok"){ location.reload(); }else{ $('#errmsg3').text("※送信エラー。" +data); } }).fail(function (data) { $('#errmsg3').text("※送信エラー。再度お試しください"); }); }); });//$function function addsc(time,id){ $('#errmsg').text(''); var st=time.split(':'); $('#addsc_date').val(id); $('#start_time_h').val(Number(st[0])); $('#end_time_h').val(Number(st[0])+1); $('#start_time_m').val(st[1]); $('#end_time_m').val(st[1]); $("body").append("
"); $(".overlay").fadeIn(300); $("body").addClass("is-active"); $('#addsc').show(); return false; } function changesc(id,start,end){ let st=start.split(':'); let en=end.split(':'); $('#changesc_id').val(id); $('#start_time_h3').val(Number(st[0])); $('#end_time_h4').val(Number(en[0])); $('#start_time_m3').val(st[1]); $('#end_time_m4').val(en[1]); $("body").append("
"); $(".overlay").fadeIn(300); $("body").addClass("is-active"); $('#changesc').show(); return false; } /* $(document).on('click touchend', function(event) { if (!$(event.target).closest('#cancelwindow').length) { $('#cancelwindow').fadeOut(); $(".overlay").fadeOut(300); $('.overlay').remove(); $("body").removeClass("is-active"); } if (!$(event.target).closest('#addsc').length) { $('#addsc').fadeOut(); $(".overlay").fadeOut(300); $('.overlay').remove(); $("body").removeClass("is-active"); } }); */