Your IP : 3.142.201.243
(function(e){function t(e,t){this.calendar=e;this.pulledEntriesIndex={};this.requestedEntriesIndex={};this.entriesRaw=[];this.loadedEntriesIndex={}}t.prototype={getList:function(e){if(e.startDate&&e.finishDate&&!this.checkDateRange(e.startDate,e.finishDate)||e.loadNext||e.loadPrevious){this.loadEntries(e);return false}var t={},a,n=[],s=this.entriesRaw;this.calendar.sectionController.getSectionsInfo().allActive.forEach(function(e){t[e=="tasks"?e:parseInt(e)]=true});for(var r=0;r<s.length;r++){if(s[r]){if(s[r]["~TYPE"]=="tasks"&&!t["tasks"]||s[r]["~TYPE"]!="tasks"&&s[r]["SECT_ID"]&&!t[parseInt(s[r]["SECT_ID"])]){continue}a=new i(this.calendar,s[r]);if(e.viewRange){if(a.applyViewRange(e.viewRange)){n.push(a)}}else{n.push(a)}}}return n},canDo:function(e,t){if(typeof e!=="object"&&t=="add_event")return!this.calendar.util.readOnlyMode();if((t=="edit"||t=="delete")&&!this.calendar.util.readOnlyMode()){if(e.isMeeting()&&e.id!==e.parentId||e.isResourcebooking()){return false}var i=this.calendar.sectionController.getSection(e.sectionId);return i&&i.canDo&&i.canDo("edit")}return false},getUsableDateTime:function(e,t){if(typeof e=="object"&&e.getTime)e=e.getTime();var i=(t||10)*60*1e3;e=Math.ceil(e/i)*i;return new Date(e)},getTimeForNewEntry:function(e){e=this.getUsableDateTime(e);return{from:e,to:new Date(e.getTime()+36e5)}},getDefaultEntryName:function(){return BX.message("EC_DEFAULT_ENTRY_NAME")},saveEntry:function(e){var t=this.calendar.util.getActionUrl();t+=t.indexOf("?")==-1?"?":"&";t+="markAction=newEvent";t+="&markType="+this.calendar.util.type;t+="&markMeeting="+(this.checkMeetingByCodes(e.attendeesCodes)?"Y":"N");t+="&markRrule=NONE&markCrm=N";this.calendar.request({url:t,type:"post",data:{action:"simple_save_entry",name:e.name,date_from:e.dateFrom,date_to:e.dateTo,default_tz:e.defaultTz,section:e.section,location:e.location||"",skip_time:"N",remind:e.remind||false,attendees:e.attendees||"",access_codes:e.attendeesCodesList||"",meeting_notify:e.meetingNotify?"Y":"N",meeting_allow_invite:e.allowInvite?"Y":"N",exclude_users:e.excludeUsers||""},handler:BX.delegate(function(t){if(t.location_busy_warning){alert(BX.message("EC_LOCATION_RESERVE_ERROR"));this.handleEntriesList(t.entries);this.calendar.getView().displayEntries();var i=true,a=t.entries.find(function(e){return e.ID==t.id});if(a){var n=this.getUniqueId(a);if(n){a=this.calendar.getView().getEntryById(n);if(a){this.calendar.entryController.editEntry({entry:a,tryLocation:e.location});i=false}}}if(i){this.calendar.reload()}}else{this.handleEntriesList(t.entries);this.calendar.getView().displayEntries()}},this)})},moveEventToNewDate:function(e,t,i){e.from.setFullYear(t.getFullYear(),t.getMonth(),t.getDate());if(e.fullDay){e.from.setHours(t.getHours(),t.getMinutes(),0,0)}if(i&&BX.type.isDate(i)){e.to.setFullYear(i.getFullYear(),i.getMonth(),i.getDate());if(e.fullDay){e.to.setHours(i.getHours(),i.getMinutes(),0,0)}}else{e.to=new Date(e.from.getTime()+(e.data.DT_LENGTH-(e.fullDay?1:0))*1e3)}var a=[];if(e.isMeeting())e.data["~ATTENDEES"].forEach(function(e){a.push(e["USER_ID"])});this.calendar.request({type:"post",data:{id:e.id,action:"move_event_to_date",current_date_from:e.data.DATE_FROM,date_from:e.isFullDay()?this.calendar.util.formatDate(e.from):this.calendar.util.formatDateTime(e.from),date_to:e.isFullDay()?this.calendar.util.formatDate(e.to):this.calendar.util.formatDateTime(e.to),skip_time:e.isFullDay()?"Y":"N",attendees:a,location:e.location||"",recursive:e.isRecursive()?"Y":"N",is_meeting:e.isMeeting()?"Y":"N",section:e.sectionId,timezone:this.calendar.util.getUserOption("timezoneName"),set_timezone:"Y"},handler:BX.delegate(function(t){if(e.isMeeting()&&t.busy_warning){alert(BX.message("EC_BUSY_ALERT"))}if(t.location_busy_warning){alert(BX.message("EC_LOCATION_RESERVE_ERROR"))}this.calendar.reload()},this)})},deleteEntry:function(e,t){if(!t)t={};if(!this.calendar.entryController.canDo(e,"delete")||e.isTask())return false;if(e.wasEverRecursive()&&!t.confirmed){this.showConfirmDeleteDialog(e);return false}else{if(!t.confirmed&&!confirm(BX.message("EC_DELETE_EVENT_CONFIRM"))){return false}e.deleteParts();if(BX.SidePanel.Instance)BX.SidePanel.Instance.close();if(this.calendar.getView().simpleViewPopup)this.calendar.getView().simpleViewPopup.close();this.calendar.request({type:"post",data:{action:"delete_entry",entry_id:e.id,recursion_mode:t.recursionMode||false},handler:BX.delegate(function(i){if(t.recursionMode&&t.recursionMode!=="all"){this.calendar.reload()}else{this.clientSideDeleteEntry(e.id);this.calendar.getView().displayEntries()}},this)});this.clientSideDeleteEntry(e.id);this.calendar.getView().displayEntries({reloadEntries:false})}},excludeRecursionDate:function(e){if(BX.SidePanel.Instance)BX.SidePanel.Instance.close();this.calendar.request({type:"post",data:{action:"exclude_recursion_date",event_id:e.id,exclude_date:e.data.DATE_FROM},handler:BX.delegate(function(e){this.calendar.reload()},this)})},cutOffRecursiveEvent:function(e){if(BX.SidePanel.Instance)BX.SidePanel.Instance.close();this.calendar.request({type:"post",data:{action:"change_recurcive_event_until",event_id:e.id,until_date:this.calendar.util.formatDate(e.from.getTime()-this.calendar.util.dayLength)},handler:BX.delegate(function(e){this.calendar.reload()},this)})},deleteAllReccurent:function(e){return this.deleteEntry(e,{confirmed:true,recursionMode:"all"})},viewEntry:function(e){this.calendar.getView().showViewSlider(e)},editEntry:function(e){this.calendar.getView().showEditSlider(e)},checkDateRange:function(e,t,i){if(!i)i={};if(!i.sections)i.sections=this.calendar.sectionController.getSectionsInfo().allActive;if(!i.index)i.index=this.pulledEntriesIndex;var a,n;for(a=0;a<i.sections.length;a++){n=i.sections[a];if(!i.index[n]||!i.index[n][this.getChunkIdByDate(e)]||!i.index[n][this.getChunkIdByDate(t)]){return false}}return true},getChunkIdByDate:function(e){return e.getFullYear()+"-"+(e.getMonth()+1)},fillChunkIndex:function(e,t,i){if(!this.loadedStartDate)this.loadedStartDate=e;else if(e.getTime()<this.loadedStartDate.getTime())this.loadedStartDate=e;if(!this.loadedFinishDate)this.loadedFinishDate=t;else if(t.getTime()>this.loadedFinishDate.getTime())this.loadedFinishDate=t;if(!i)i={};if(!i.sections)i.sections=this.calendar.sectionController.getSectionsInfo().allActive;if(!i.index)i.index=this.pulledEntriesIndex;var a=0,n=new Date,s=i.index,r=i.sections,o=i.value==undefined?true:i.value;n.setFullYear(e.getFullYear(),e.getMonth(),1);var l=this.getChunkIdByDate(t),d=this.getChunkIdByDate(n);r.forEach(function(e){if(!s[e])s[e]={};s[e][d]=o;s[e][l]=o});while(d!=l&&a<100){r.forEach(function(e){s[e][d]=o});n.setMonth(n.getMonth()+1);d=this.getChunkIdByDate(n);a++}},getLoadedEntiesLimits:function(){return{start:this.loadedStartDate,end:this.loadedFinishDate}},loadEntries:function(e){if(this.calendar.currentViewName!=="list"){this.calendar.showLoader()}var t=this.calendar.sectionController.getSectionsInfo();if(this.calendar.isExternalMode()){this.calendar.triggerEvent("loadEntries",{params:e,onLoadCallback:BX.delegate(function(i){this.calendar.hideLoader();this.handleEntriesList(i.entries);if(!e.finishDate&&this.entriesRaw.length>0){var a=this.entriesRaw[this.entriesRaw.length-1].DATE_FROM;a=BX.parseDate(a);if(a){a.setFullYear(a.getFullYear(),a.getMonth(),0);e.finishDate=a}}if(e.startDate&&e.finishDate){this.fillChunkIndex(e.startDate,e.finishDate,{index:this.pulledEntriesIndex,sections:t.allActive})}if(e.finishCallback&&typeof e.finishCallback=="function"){e.finishCallback(i)}},this),onErrorCallback:BX.delegate(function(e){this.calendar.hideLoader()},this)})}else{this.calendar.request({type:"post",data:{action:"load_entries",month_from:e.startDate?e.startDate.getMonth()+1:"",year_from:e.startDate?e.startDate.getFullYear():"",month_to:e.finishDate?e.finishDate.getMonth()+1:"",year_to:e.finishDate?e.finishDate.getFullYear():"",active_sect:t.active,hidden_sect:t.hidden,sup_sect:t.superposed,loadNext:e.loadNext?"Y":"N",loadPrevious:e.loadPrevious?"Y":"N",loadLimit:e.loadLimit||0,cal_dav_data_sync:this.calendar.reloadGoogle?"Y":"N"},handler:BX.delegate(function(i){this.calendar.hideLoader();this.handleEntriesList(i.entries);if(!e.finishDate&&this.entriesRaw.length>0){var a=this.entriesRaw[this.entriesRaw.length-1].DATE_FROM;a=BX.parseDate(a);if(a){a.setFullYear(a.getFullYear(),a.getMonth(),0);e.finishDate=a}}if(e.startDate&&e.finishDate){this.fillChunkIndex(e.startDate,e.finishDate,{index:this.pulledEntriesIndex,sections:t.allActive})}if(e.finishCallback&&typeof e.finishCallback=="function"){e.finishCallback(i)}this.calendar.reloadGoogle=false},this)})}},handleEntriesList:function(e){if(e&&e.length){var t,i,a=this.calendar.util.getUserOption("showDeclined");for(t=0;t<e.length;t++){if((!a||parseInt(e[t].CREATED_BY)!==this.calendar.util.userId)&&e[t].MEETING_STATUS=="N"){continue}i=this.getUniqueId(e[t]);if(this.loadedEntriesIndex[i]===undefined){this.entriesRaw.push(e[t]);this.loadedEntriesIndex[i]=this.entriesRaw.length-1}else{if(e[t].CAL_TYPE==this.calendar.util.type&&e[t].OWNER_ID==this.calendar.util.ownerId){this.entriesRaw[this.loadedEntriesIndex[i]]=e[t]}}}}},getUniqueId:function(e,t){var i=e.PARENT_ID||e.ID;if(e.RRULE){i+="|"+(t?this.calendar.util.formatDate(t.from):this.calendar.util.formatDate(BX.parseDate(e.DATE_FROM)))}if(e["~TYPE"]=="tasks"){i+="|"+"task"}return i},sort:function(e,t){if(e.entry.isTask()!==t.entry.isTask()){if(e.entry.isTask())return 1;if(t.entry.isTask())return-1}if(e.part.daysCount==t.part.daysCount&&e.part.daysCount==1){return e.entry.from.getTime()-t.entry.from.getTime()}else{if(e.part.daysCount==t.part.daysCount)return e.entry.from.getTime()-t.entry.from.getTime();else return e.part.daysCount-t.part.daysCount}},clearLoadIndexCache:function(){this.pulledEntriesIndex={};this.requestedEntriesIndex={};this.entriesRaw=[];this.loadedEntriesIndex={}},setMeetingStatus:function(e,t,i){if(typeof i=="undefined")i={};if(t=="N"&&!i.confirmed){if(e.isRecursive()){this.showConfirmDeclineDialog(e);return false}else if(!confirm(BX.message("EC_DECLINE_MEETING_CONFIRM"))){return false}}this.calendar.request({type:"post",data:{action:"set_meeting_status",event_id:e.id,parent_id:e.parentId,status:t,reccurent_mode:i.recursionMode||false,current_date_from:this.calendar.util.formatDate(e.from)},handler:BX.delegate(function(e){this.calendar.reload()},this)});return true},showConfirmDeleteDialog:function(t){if(!this.confirmDeleteDialog)this.confirmDeleteDialog=new e.BXEventCalendar.ConfirmDeleteDialog(this.calendar);this.confirmDeleteDialog.show(t)},showConfirmEditDialog:function(t){if(!this.confirmEditDialog)this.confirmEditDialog=new e.BXEventCalendar.ConfirmEditDialog(this.calendar);this.confirmEditDialog.show(t)},showConfirmDeclineDialog:function(t){if(!this.confirmDeclineDialog)this.confirmDeclineDialog=new e.BXEventCalendar.ConfirmDeclineDialog(this.calendar);this.confirmDeclineDialog.show(t)},clientSideDeleteEntry:function(e){var t=[],i;for(i=0;i<this.calendar.getView().entries.length;i++){if(this.calendar.getView().entries[i].id!==e&&this.calendar.getView().entries[i].data.RECURRENCE_ID!==e){t.push(this.calendar.getView().entries[i])}}this.calendar.getView().entries=t;var a=[];for(i=0;i<this.entriesRaw.length;i++){if(this.entriesRaw[i].ID!==e&&this.entriesRaw[i].RECURRENCE_ID!==e){a.push(this.entriesRaw[i])}}this.entriesRaw=a},checkMeetingByCodes:function(e){var t,i=0;if(e){for(t in e){if(e.hasOwnProperty(t)){if(e[t]!="users"||i>0){return true}i++}}}return false}};function i(e,t){this.calendar=e;this.data=t;this.id=t.ID||0;if(!this.data.DT_SKIP_TIME){this.data.DT_SKIP_TIME=this.data.SKIP_TIME?"Y":"N"}this.fullDay=t.DT_SKIP_TIME=="Y";this.parentId=t.PARENT_ID||0;this.textColor=t.TEXT_COLOR;this.accessibility=t.ACCESSIBILITY;this.important=t.IMPORTANCE=="high";this.private=!!t.PRIVATE_EVENT;this.sectionId=this.isTask()?"tasks":parseInt(t.SECT_ID);this.name=t.NAME;this.parts=[];var i=this,a=this.calendar.util,n,s,r=t.COLOR||i.calendar.sectionController.getSection(this.sectionId).color;Object.defineProperties(this,{startDayCode:{get:function(){return n},set:function(e){n=a.getDayCode(e)}},endDayCode:{get:function(){return s},set:function(e){s=a.getDayCode(e)}},color:{get:function(){return r},set:function(e){r=e}},textColor:{value:t.TEXT_COLOR,writable:true,enumerable:true},location:{value:t.LOCATION,writable:true,enumerable:true}});this.prepareData();this.uid=this.calendar.entryController.getUniqueId(t,this)}i.prototype={prepareData:function(){if(!this.data.DT_LENGTH){this.data.DT_LENGTH=this.data.DURATION||0}if(this.fullDay&&!this.data.DT_LENGTH){this.data.DT_LENGTH=86400}if(this.isTask()){this.from=BX.parseDate(this.data.DATE_FROM)||new Date;this.to=BX.parseDate(this.data.DATE_TO)||this.from}else{this.from=BX.parseDate(this.data.DATE_FROM)||new Date;if(this.fullDay){this.from.setHours(0,0,0,0)}if(this.data.DT_SKIP_TIME!=="Y"){this.from=new Date(this.from.getTime()-(parseInt(this.data["~USER_OFFSET_FROM"])||0)*1e3)}this.to=new Date(this.from.getTime()+(this.data.DT_LENGTH-(this.fullDay?1:0))*1e3)}if(!this.data.ATTENDEES_CODES&&!this.isTask()){if(this.data.CAL_TYPE=="user"){this.data.ATTENDEES_CODES=["U"+this.data.OWNER_ID]}else{this.data.ATTENDEES_CODES=["U"+this.data.CREATED_BY]}}this.startDayCode=this.from;this.endDayCode=this.to},getAttendeesCodes:function(){return this.data.ATTENDEES_CODES},getAttendees:function(){return this.data["~ATTENDEES"]||[]},cleanParts:function(){this.parts=[]},startPart:function(e){e.partIndex=this.parts.length;this.parts.push(e);return this.parts[e.partIndex]},registerPartNode:function(e,t){e.params=t},checkPartIsRegistered:function(e){return BX.type.isPlainObject(e.params)},getPart:function(e){return this.parts[e]||false},getWrap:function(e){return this.parts[e||0].params.wrapNode},getSectionName:function(){return this.calendar.sectionController.getSection(this.sectionId).name||""},getDescription:function(e){if(this.data.DESCRIPTION&&this.data["~DESCRIPTION"]&&BX.type.isFunction(e)){setTimeout(BX.delegate(function(){e(this.data["~DESCRIPTION"])},this),50)}},applyViewRange:function(e){var t=e.start.getTime(),i=e.end.getTime(),a=this.from.getTime(),n=this.to.getTime();if(n<t||a>i)return false;if(a<t){this.displayFrom=e.start;this.startDayCode=this.displayFrom}if(n>i){this.displayTo=e.end;this.endDayCode=this.displayTo}return true},isPersonal:function(){return this.data.CAL_TYPE=="user"&&this.data.OWNER_ID==this.calendar.util.userId},isMeeting:function(){return!!this.data.IS_MEETING},isResourcebooking:function(){return this.data.EVENT_TYPE==="#resourcebooking#"},isTask:function(){return this.data["~TYPE"]=="tasks"},isFullDay:function(){return this.fullDay},isLongWithTime:function(){return!this.fullDay&&this.calendar.util.getDayCode(this.from)!=this.calendar.util.getDayCode(this.to)},isExpired:function(){return this.to.getTime()<(new Date).getTime()},isExternal:function(){return false},isSelected:function(){return!!this.selected},isCrm:function(){return this.data.UF_CRM_CAL_EVENT&&this.data.UF_CRM_CAL_EVENT!=""},isFirstReccurentEntry:function(){var e=(this.data.DATE_FROM_TS_UTC===Math.floor(BX.parseDate(this.data["~DATE_FROM"]).getTime()/1e3)*1e3||BX.parseDate(this.data["DATE_FROM"]).getTime()===BX.parseDate(this.data["~DATE_FROM"]).getTime())&&!this.data.RECURRENCE_ID;return e},isRecursive:function(){return!!this.data.RRULE},getMeetingHost:function(){return parseInt(this.data.MEETING_HOST)},getRrule:function(){return this.data.RRULE},hasRecurrenceId:function(){return this.data.RECURRENCE_ID},wasEverRecursive:function(){return this.data.RRULE||this.data.RECURRENCE_ID},deselect:function(){this.selected=false},select:function(){this.selected=true},deleteParts:function(){this.parts.forEach(function(e){if(e.params){if(e.params.wrapNode){e.params.wrapNode.style.opacity=0}}},this);setTimeout(BX.delegate(function(){this.parts.forEach(function(e){if(e.params){if(e.params.wrapNode){BX.remove(e.params.wrapNode)}}},this)},this),300)},getUniqueId:function(){var e=this.data.PARENT_ID||this.data.PARENT_ID;if(this.isRecursive())e+="|"+this.data.DT_FROM_TS;if(this.data["~TYPE"]=="tasks")e+="|"+"task";return e},getCurrentStatus:function(){var e,t,i=false;if(this.isMeeting()){if(this.calendar.util.userId==this.data.CREATED_BY||this.calendar.util.userId==this.data.MEETING_HOST){i=this.data.MEETING_STATUS}else if(this.calendar.util.userId==this.data.MEETING_HOST){i=this.data.MEETING_STATUS}else if(this.data["~ATTENDEES"]){for(e=0;e<this.data["~ATTENDEES"].length;e++){t=this.data["~ATTENDEES"][e];if(t.USER_ID==this.calendar.util.userId){i=t.STATUS;break}}}}return i},getReminders:function(){var e=[];if(this.data&&this.data.REMIND){this.data.REMIND.forEach(function(t){if(t.type=="min"){e.push(t.count)}else if(t.type=="hour"){e.push(parseInt(t.count)*60)}if(t.type=="day"){e.push(parseInt(t.count)*60*24)}})}return e},getLengthInDays:function(){var e=new Date(this.from.getFullYear(),this.from.getMonth(),this.from.getDate(),0,0,0),t=new Date(this.to.getFullYear(),this.to.getMonth(),this.to.getDate(),0,0,0);return Math.round((t.getTime()-e.getTime())/this.calendar.util.dayLength)+1}};if(e.BXEventCalendar){e.BXEventCalendar.Entry=i;e.BXEventCalendar.EntryController=t}else{BX.addCustomEvent(e,"onBXEventCalendarInit",function(){e.BXEventCalendar.Entry=i;e.BXEventCalendar.EntryController=t})}})(window);