Php 将完整日历从当前日期加载到18个月

Php 将完整日历从当前日期加载到18个月,php,jquery,ajax,datepicker,fullcalendar,Php,Jquery,Ajax,Datepicker,Fullcalendar,我有完整的日历要求,从当前日期起的过去15天开始,从当前日期起的18个月结束 如果当前日期为2016-02-15,日历应呈现从2016-02-01到2017-08-15,就像我们有一年视图一样,我需要一年半视图。这可能吗?如果没有,请建议其他方式。希望你能理解 我用了这个密码 <script> $('#calendar').fullCalendar({ events: JSON.parse(json_events), utc: true, theme :tr

我有完整的日历要求,从当前日期起的过去15天开始,从当前日期起的18个月结束


如果当前日期为2016-02-15,日历应呈现从2016-02-01到2017-08-15,就像我们有一年视图一样,我需要一年半视图。这可能吗?如果没有,请建议其他方式。希望你能理解

我用了这个密码

  <script>
$('#calendar').fullCalendar({
events: JSON.parse(json_events),

    utc: true,
    theme :true,
    editable: true,
    eventLimit: true, // allow "more" link when too many events

    header: {
        left: 'today prev,next',
        center: 'title',
        right: 'agendaMonths'
    },
    defaultView: 'agendaMonths',
    views: {
        agendaMonths: {
           type: 'timeline',
            duration: { months: 18},
           buttonText: '18 Months',

        }
    },
    defaultDate :dateFormat.setDate(dateFormat.getDate()-15),
    viewRender: function(view,element,currentView,cell) {
        var now = new Date();
         $("[data-date="+now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+addZero(now.getDate())+"]").css("background-color", "yellow");
                    var end = new Date();
                   var endback = new Date().setMonth(now.getMonth() - 17);
                    end.setMonth(now.getMonth() + 17); //Adjust as needed
                    //console.log(now +'---'+end+'--'+new Date(endback));
                    if ( end < view.end) {
                        $("#calendar .fc-next-button").hide();
                     }
                    else {
                        $("#calendar .fc-next-button").show();
                    }
                    if ( view.start < new Date(endback)) {
                        $("#calendar .fc-prev-button").hide();
                        return false;
                    }
                    else {
                        $("#calendar .fc-prev-button").show();
                    }
    }, 
    dayRender: function (date, cell) {
        var now = new Date();
        //now= now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate()-15);
        now.setDate(now.getDate()-15);
        now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
        date=date.format("YYYY-MM-DD");
        //console.log(now+'==='+date);
        if (now > date) {
           // cell.css("background-color", "red");
        }

   },
        eventOverlap: false, // will cause the event to take up entire resource height
    resourceAreaWidth: '30%',
    resourceColumns: [
        {
            labelText: 'Room',
            field: 'title'
        },
        {
            labelText: 'Occupancy',
            field: 'occupancy'
        }
    ],
    resourceOrder: 'title', // when occupancy tied, order by title //-occupancy,title
    resources: [
        { id: 'a', title: 'Room A', occupancy: 40 },
        { id: 'b', title: 'Room B', occupancy: 40, eventColor: 'green' },
        { id: 'c', title: 'Room C', occupancy: 40, eventColor: 'orange' },
        { id: 'd', title: 'Room D', occupancy: 40 },
        { id: 'e', title: 'Room E', occupancy: 40 },
        { id: 'f', title: 'Room F', occupancy: 40, eventColor: 'red' },
        { id: 'g', title: 'Room G', occupancy: 40 },
        { id: 'h', title: 'Room H', occupancy: 40 },
        { id: 'i', title: 'Room I', occupancy: 50 },
        { id: 'j', title: 'Room J', occupancy: 50 },
        { id: 'k', title: 'Room K', occupancy: 40 },
        { id: 'l', title: 'Room L', occupancy: 40 },
        { id: 'm', title: 'Room M', occupancy: 40 }
    ],

    selectable: true,
    selectHelper: true,

    select: function(start, end, allDay, event, resourceId) {
        var oldDay = new Date(start);
        var toDay = new Date();
        Date.prototype.sameDay = function(d) {
          return this.getFullYear() === d.getFullYear()
            && this.getDate() === d.getDate()
            && this.getMonth() === d.getMonth();
        }
        if(oldDay.sameDay(toDay)) {
            console.log('event select oldDay.sameDay');
            createEvent(start,end,resourceId.id);
        }else{
            if(oldDay > toDay){
                console.log('event select oldDay > toDay');
                createEvent(start,end,resourceId.id);
            }else{
                alert("Cannot book for past days!");
            }
        }

    },

    eventClick: function(event, delta, revertFunc, jsEvent, ui, view ) {
        console.log('eventClick');
        //modifyEvent(event,'form');
    },
    eventMouseover: function(calEvent, jsEvent) {
        var tooltip = '<div class="tooltipevent" title= "' + calEvent.title + '" style="width:100px;height:50px;background:#ccc;position:absolute;z-index:10001;">' + calEvent.title + '</div>';
        $("body").append(tooltip);
        $(this).mouseover(function(e) {
            $(this).css('z-index', 10000);
            $('.tooltipevent').fadeIn('500');
            $('.tooltipevent').fadeTo('10', 1.9);
        }).mousemove(function(e) {
            $('.tooltipevent').css('top', e.pageY + 10);
            $('.tooltipevent').css('left', e.pageX + 20);
        });
    },

    eventMouseout: function(calEvent, jsEvent) {
         $(this).css('z-index', 8);
         $('.tooltipevent').remove();
    },
    eventDragStart :  function( event,jsEvent ) { 
        console.log(jsEvent);


        $(this).addClass('somthing');
        $('.somthing').css("background-color", "yellow");
        eventDateStart  =event.start.format('YYYY-MM-DD');
        eventDateEnd  =event.end.format('YYYY-MM-DD');
        eventStatus = event.status;
    },
    eventDrop: function(event, delta, revertFunc) {
        console.log('eventDrop');

        var now = new Date();

        now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
        var todayStart = event.start;
        var todayEnd = event.end;
        console.log('eventDragStart: '+eventDateStart+'---eventDateEnd: '+eventDateEnd+'----now: '+now+'----todayStart: '+todayStart.format('YYYY-MM-DD')+'---todayEnd: '+todayEnd.format('YYYY-MM-DD'));
        if(eventStatus == 1){
            alert("Guest has checked out, can't modify'");
            revertFunc();
        }else if( todayStart.format('YYYY-MM-DD') < now ){
            alert("can't change room less than today date");
            revertFunc();
        }else if(todayEnd.format('YYYY-MM-DD') < now  ){
            alert("can't change room less than today date");
            revertFunc();
        }else{
            if (confirm("Are you sure want to modify "+event.title + "Room Details?")) {
                moveEvent(event);
            }else{
                revertFunc();
            }
        }

   },
    eventResizeStart : function (event, delta, revertFunc, jsEvent, ui, view ){
        console.log('eventResizeStart');
        eventDateStart  =event.start.format();
        eventDateEnd  =event.end.format();
        eventStatus = event.status;
    },
    eventResize: function (event, delta, revertFunc, jsEvent, ui, view  ) {
        var now = new Date();
        now=now.getFullYear()+"-"+addZero(parseInt(now.getMonth()+1))+"-"+now.getDate();
        console.log('eventResize');
        var todayStart = event.start;
        var todayEnd = event.end;

        if(eventStatus == 1){
            alert("Guest has checked out, can't modify'");
            revertFunc();
        }else if(todayStart.format("YYYY-MM-DD") < now){
            alert("can't change room less than today date");
            revertFunc();
        }else{
            if (confirm("Are you sure want to modify "+event.title + "Room Details?")) {
                modifyEvent(event,'resize');
            }else{
                revertFunc();
            }
        }
    }

});
</script>

$(“#日历”).fullCalendar({
事件:JSON.parse(JSON_事件),
utc:是的,
主题:真的,
是的,
eventLimit:true,//当事件太多时允许“更多”链接
标题:{
左:“今天上一个,下一个”,
中心:'标题',
右图:“agendaMonths”
},
defaultView:'agendaMonths',
观点:{
代理月份:{
键入:“时间线”,
持续时间:{个月:18},
按钮文字:“18个月”,
}
},
defaultDate:dateFormat.setDate(dateFormat.getDate()-15),
viewRender:函数(视图、元素、当前视图、单元格){
var now=新日期();
$(“[data date=“+now.getFullYear()+”-“+addZero(parseInt(now.getMonth()+1))+”-“+addZero(now.getDate())+”)”).css(“背景色”、“黄色”);
var end=新日期();
var endback=new Date().setMonth(now.getMonth()-17);
end.setMonth(now.getMonth()+17);//根据需要进行调整
//log(现在+'-'+end+'-'+newdate(endback));
如果(结束<视图结束){
$(“#calendar.fc下一步按钮”).hide();
}
否则{
$(“#calendar.fc下一步按钮”).show();
}
如果(view.start<新日期(endback)){
$(“#calendar.fc prev button”).hide();
返回false;
}
否则{
$(“#calendar.fc prev button”).show();
}
}, 
dayRender:函数(日期、单元格){
var now=新日期();
//now=now.getFullYear()+“-”+addZero(parseInt(now.getMonth()+1))+“-”+now.getDate()-15);
now.setDate(now.getDate()-15);
now=now.getFullYear()+“-”+addZero(parseInt(now.getMonth()+1))+“-”+now.getDate();
日期=日期格式(“YYYY-MM-DD”);
//console.log(现在+'='+日期);
如果(现在>日期){
//css(“背景色”、“红色”);
}
},
eventOverlap:false,//将导致事件占用整个资源高度
resourceAreaWidth:'30%',
资源列:[
{
labelText:“房间”,
字段:“标题”
},
{
labelText:“入住率”,
字段:“占用率”
}
],
resourceOrder:'标题',//占用率挂钩时,按标题排序//-占用率,标题
资源:[
{id:'a',标题:'a房间',入住率:40},
{id:'b',title:'Room b',入住率:40,eventColor:'green'},
{id:'c',标题:'c房间',入住率:40,eventColor:'orange'},
{id:'d',标题:'d房间',入住率:40},
{id:'e',标题:'e房间',入住率:40},
{id:'f',title:'Room f',入住率:40,eventColor:'red'},
{id:'g',标题:'g房间',入住率:40},
{id:'h',标题:'h房间',入住率:40},
{id:'i',标题:'i房间',入住率:50},
{id:'j',标题:'j房间',入住率:50},
{id:'k',标题:'k房间',入住率:40},
{id:'l',标题:'l房间',入住率:40},
{id:'m',标题:'m房间',入住率:40}
],
是的,
selectHelper:对,
选择:功能(开始、结束、全天、事件、资源ID){
var oldDay=新日期(开始);
var toDay=新日期();
Date.prototype.sameDay=函数(d){
返回此.getFullYear()==d.getFullYear()
&&this.getDate()==d.getDate()
&&this.getMonth()==d.getMonth();
}
如果(旧的星期三(今天)){
log('event select oldDay.sameDay');
createEvent(开始、结束、resourceId.id);
}否则{
如果(过去>今天){
log('event select oldDay>toDay');
createEvent(开始、结束、resourceId.id);
}否则{
警报(“过去几天无法预订!”);
}
}
},
eventClick:函数(事件、增量、回复函数、jsEvent、ui、视图){
log('eventClick');
//修改事件(事件,“形式”);
},
eventMouseover:函数(calEvent、jsEvent){
变量工具提示=“”+calEvent.title+“”;
$(“正文”).append(工具提示);
$(此).mouseover(函数(e){
$(this.css('z-index',10000);
$('.tooltipevent').fadeIn('500');
$('tooltipevent').fadeTo('10',1.9);
}).mousemove(函数(e){
$('.tooltipevent').css('top',e.pageY+10);
$('.tooltipevent').css('left',e.pageX+20);
});
},
eventMouseout:函数(calEvent、jsEvent){
$(this.css('z-index',8);
$('.tooltipevent').remove();
},
eventDragStart:函数(事件,jsEvent){
console.log(jsEvent);
$(this.addClass('somthing');
$('.somthing').css(“背景色”、“黄色”);
eventDateStart=event.start.format('YYYY-MM-DD');
eventDateEnd=event.end.format('YYYY-MM-DD');
eventStatus=event.status;
},
eventDrop:函数(事件、增量、恢复函数){
console.log('eventDrop');
var now=新日期();
now=now.getFullYear()+“-”+addZero(parseInt(now.getMonth()+1))+“-”+now.getDate();
var todayStart=event.start;
var todayEnd=event.end;
console.log('eventDragStart:'+eventDateStart+'--eventDateEnd:'+eventDateEnd+'--now:'+now+'--todayStart:'+todayStart.format('YYYY-MM-DD')+'--todayStart