'));if(n.type=="listFull"){if($("#planning_datepicker").length>0&&"_flatpickr"in $("#planning_datepicker")[0]){$("#planning_datepicker")[0]._flatpickr.destroy()}$("#planning_datepicker").hide();$("#planning .fc-left .fc-button-group").hide()}else{$("#planning_datepicker").show();GLPIPlanning.initFCDatePicker(new Date(n.currentStart));$("#planning .fc-left .fc-button-group").show()}GLPIPlanning.setEndofDays(e.view)},viewSkeletonRender:function(e){var n=e.view.type;GLPIPlanning.last_view=n;$.ajax({url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",data:{action:"view_changed",view:n}});GLPIPlanning.setEndofDays(e.view)},events:{url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",extraParams:function(){var e=GLPIPlanning.calendar?GLPIPlanning.calendar.state.viewType:n.default_view;var t=1;if(e.indexOf("list")>=0){t=0}return{action:"get_events",display_done_events:t,view_name:e}},success:function(e){if(!n.full_view&&e.length==0){GLPIPlanning.calendar.setOption("height",0)}},failure:function(e){console.error("there was an error while fetching events!",e)}},eventResize:function(e){var n=e.event;var t=n.extendedProps;var i=t.is_recurrent||false;if(i){$("
").dialog({modal:true,title:__("Recurring event resized"),width:"auto",height:"auto",buttons:[{text:__("Serie"),click:function(){$(this).remove();GLPIPlanning.editEventTimes(e)}},{text:__("Instance"),click:function(){$(this).remove();GLPIPlanning.editEventTimes(e,true)}}]}).text(__("The resized event is a recurring event. Do you want to change the serie or instance ?"))}else{GLPIPlanning.editEventTimes(e)}},eventResizeStart:function(){l=true;r=true},eventResizeStop:function(){setTimeout((function(){l=false;r=false}),300)},eventDragStart:function(){r=true},eventDrop:function(e){r=false;var n=e.event;var t=n.extendedProps;var i=t.is_recurrent||false;if(i){$("
").dialog({modal:true,title:__("Recurring event dragged"),width:"auto",height:"auto",buttons:[{text:__("Serie"),click:function(){$(this).remove();GLPIPlanning.editEventTimes(e)}},{text:__("Instance"),click:function(){$(this).remove();GLPIPlanning.editEventTimes(e,true)}}]}).text(__("The dragged event is a recurring event. Do you want to move the serie or instance ?"))}else{GLPIPlanning.editEventTimes(e)}},eventClick:function(e){var n=e.event;var t=n.start;var i=n.extendedProps.ajaxurl+"&start="+t.toISOString();var a=n.extendedProps._editable;if(i&&a&&!l){e.jsEvent.preventDefault();$("
").dialog({modal:true,width:"auto",height:"auto",close:function(){GLPIPlanning.refresh()}}).load(i,(function(){$(this).dialog("option","position",["center","center"])}))}},selectable:true,select:function(e){var n=((((e||{}).resource||{})._resource||{}).extendedProps||{}).itemtype||"";var t=((((e||{}).resource||{})._resource||{}).extendedProps||{}).items_id||0;if(n==="Group_User"){GLPIPlanning.calendar.unselect();return false}var i=e.start;var a=e.end;$("
").dialog({modal:true,width:"auto",height:"auto",open:function(){$(this).load(CFG_GLPI.root_doc+"/ajax/planning.php",{action:"add_event_fromselect",begin:i.toISOString(),end:a.toISOString(),res_itemtype:n,res_items_id:t},(function(){$(this).dialog("option","position",["center","center"])}))},close:function(){$(this).dialog("close");$(this).remove()},position:{my:"center",at:"top",viewport:$(window),of:$("#page")}});GLPIPlanning.calendar.unselect()}});var o=Object.keys(FullCalendarLocales);if(o.length===1){GLPIPlanning.calendar.setOption("locale",o[0])}$(".planning_on_central a").mousedown((function(){r=true;$(".qtip").hide()})).mouseup((function(){r=false}));window.onblur=function(){i=false};window.onfocus=function(){i=true};GLPIPlanning.calendar.render();$("#refresh_planning").click((function(){GLPIPlanning.refresh()}));GLPIPlanning.initFCDatePicker();$(window).focus();$(document).click((function(){$(".planning-context-menu").remove()}))},refresh:function(){if(typeof GLPIPlanning.calendar.refetchResources=="function"){GLPIPlanning.calendar.refetchResources()}GLPIPlanning.calendar.refetchEvents();GLPIPlanning.calendar.rerenderEvents();window.displayAjaxMessageAfterRedirect()},toggleResource:function(e,n){var t=GLPIPlanning.all_resources.findIndex((function(n){return n.id==e}));if(t!==-1){if(n&&GLPIPlanning.visible_res.indexOf(t.toString())===-1){GLPIPlanning.visible_res.push(t.toString())}else if(!n){GLPIPlanning.visible_res.splice(GLPIPlanning.visible_res.indexOf(t.toString()),1)}}},setEndofDays:function(e){if(e.constructor.name==="ResourceTimelineView"){var n=CFG_GLPI.planning_begin.split(":");var t=CFG_GLPI.planning_end.split(":");var i=parseInt(n[0])*60+parseInt(n[1]);var a=parseInt(t[0])*60+parseInt(t[1]);var r=a-i;var l=Math.ceil(r/60);$("#planning .fc-time-area.fc-widget-header table tr:nth-child(2) th").addClass("end-of-day");$("#planning .fc-time-area.fc-widget-header table tr:nth-child(3) th:nth-child("+l+"n)").addClass("end-of-day");$("#planning .fc-time-area.fc-widget-content table td:nth-child("+l+"n)").addClass("end-of-day")}},planningFilters:function(){$("#planning_filter a.planning_add_filter").on("click",(function(e){e.preventDefault();var n=$(this).attr("href");$("
").dialog({modal:true,open:function(){$(this).load(n)},position:{my:"top",at:"center",of:$("#planning_filter")}})}));$("#planning_filter .filter_option").on("click",(function(){$(this).children("ul").toggle()}));$(document).click((function(e){if($(e.target).closest("#planning_filter .filter_option").length===0){$("#planning_filter .filter_option ul").hide()}}));$("#planning_filter .delete_planning").on("click",(function(){var e=$(this);var n=e.closest("ul.filters > li");$.ajax({url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",data:{action:"delete_filter",filter:e.attr("value"),type:n.attr("event_type")},success:function(){n.remove();GLPIPlanning.refresh()}})}));var e=function(e,n){var t=e.parents("li");var i=null;if(t.parent("ul.group_listofusers").length==1){i=t.parent("ul.group_listofusers").parent("li").attr("event_name")}var a=t.attr("event_name");var r=t.attr("event_type");var l=e.is(":checked");return $.ajax({url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",data:{action:"toggle_filter",name:a,type:r,parent:i,display:l},success:function(){GLPIPlanning.toggleResource(a,l);if(n){GLPIPlanning.refresh()}}})};$('#planning_filter li:not(li.group_users) input[type="checkbox"]').on("click",(function(){e($(this),true)}));$('#planning_filter li.group_users > span > input[type="checkbox"]').on("change",(function(){var n=$(this);var t=n.parents("li");var i=n.prop("checked");var a=t.attr("event_name");var r=n.parents("li.group_users").find('ul.group_listofusers input[type="checkbox"]');r.prop("checked",i);var l=[];r.each((function(){l.push(e($(this),false))}));GLPIPlanning.toggleResource(a,i);$.when.apply($,l).then((function(){GLPIPlanning.refresh()}))}));$("#planning_filter .color_input input").on("change",(function(){var e=$(this).parents("li");var n=null;if(e.length>=1){n=e.eq(1).attr("event_name");e=e.eq(0)}$.ajax({url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",data:{action:"color_filter",name:e.attr("event_name"),type:e.attr("event_type"),parent:n,color:$(this).val()},success:function(){GLPIPlanning.refresh()}})}));$("#planning_filter li.group_users .toggle").on("click",(function(){$(this).parent().toggleClass("expanded")}));$("#planning_filter_toggle > a.toggle").on("click",(function(){$("#planning_filter_content").animate({width:"toggle"},300,"swing",(function(){$("#planning_filter").toggleClass("folded");$("#planning_container").toggleClass("folded")}))}))},editEventTimes:function(e,n){n=n||false;var t=e.event;var i=e.revert;var a=t.extendedProps;var r=null;var l=null;var o=null;var s=null;if("newResource"in e&&e.newResource!==null){var c=e.newResource._resource.extendedProps;o=c.itemtype;s=c.items_id}if("oldResource"in e&&e.oldResource!==null){var d=e.oldResource._resource.extendedProps;r=d.itemtype;l=d.items_id}var u=t.start;var f=t.end;if(typeof f==="undefined"||f===null){f=new Date(u.getTime());if(t.allDay){f.setDate(f.getDate()+1)}else{f.setHours(f.getHours()+2)}}var p=e.oldEvent||{};var g=p.start||u;$.ajax({url:CFG_GLPI.root_doc+"/ajax/planning.php",type:"POST",data:{action:"update_event_times",start:u.toISOString(),end:f.toISOString(),itemtype:a.itemtype,items_id:a.items_id,move_instance:n,old_start:g.toISOString(),new_actor_itemtype:o,new_actor_items_id:s,old_actor_itemtype:r,old_actor_items_id:l},success:function(e){if(!e){i()}GLPIPlanning.refresh()},error:function(){i()}})},initFCDatePicker:function(e){$("#planning_datepicker").flatpickr({defaultDate:e,onChange:function(e){var n=new Date(Date.UTC(e[0].getFullYear(),e[0].getMonth(),e[0].getDate()));GLPIPlanning.calendar.gotoDate(n)}})},getHeight:function(){var e=$(window).height()-272;if($("#debugajax").length>0){e-=$("#debugajax").height()}if(CFG_GLPI.glpilayout=="vsplit"){e=$(".ui-tabs-panel").height()-30}var n=300;if(e