Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/calendar/new/ |
Upload File : |
(function(t){function e(t){this.calendar=t;this.pulledEntriesIndex={};this.entriesRaw=[];this.userIndex={};this.loadedEntriesIndex={};this.externalEntryIndex={};this.movedEntries=[];this.sentRequests=[];this.REQUEST_GET_LIST="getList";this.REQUEST_MOVE_EVENT="moveEvent"}e.prototype={isAwaitingAnyResponses:function(){return this.sentRequests.length>0},getList:function(t){return new Promise((async e=>{if(this.calendar.isExternalMode()){const i=await this.getExternalLoadedList(t);e(i)}else if(this.doesDateRangeContainUnloadedEvents(t.startDate,t.finishDate)){const i=await this.getLoadedList(t);e(i)}else{const i=this.getCachedList(t);e(i)}}))},getExternalLoadedList:async function(t){let e;this.sentRequests.push(this.REQUEST_GET_LIST);await this.loadExternalEntries(t).then((()=>{this.sentRequests.pop();e=this.getEntriesFromEntriesRaw(t.viewRange)}));return e},getLoadedList:async function(t){let e;this.sentRequests.push(this.REQUEST_GET_LIST);await BX.Calendar.EntryManager.doDelayedActions().then((()=>this.loadEntries(t))).then((i=>{this.sentRequests.pop();if(i.newYearFrom!==undefined&&i.newMonthFrom!==undefined){const e=t.viewRange.start;t.viewRange.start=new Date(i.newYearFrom,i.newMonthFrom-1,e.getDate())}if(i.newYearTo!==undefined&&i.newMonthTo!==undefined){const e=t.viewRange.end;t.viewRange.end=new Date(i.newYearTo,i.newMonthTo-1,e.getDate())}e=this.getEntriesFromEntriesRaw(t.viewRange)}));return e},getCachedList:function(t){return this.getEntriesFromEntriesRaw(t.viewRange)},canDo:function(t,e){if(typeof t!=="object"&&e==="add_event"){if(this.calendar.util.type==="location"){return true}return!this.calendar.util.readOnlyMode()}if((e==="edit"||e==="delete")&&!this.calendar.util.readOnlyMode()){if(t.isMeeting()&&t.id!==t.parentId||t.isResourcebooking()){return false}var i=this.calendar.sectionManager.getSection(t.sectionId);return i&&i.canDo&&i.canDo("edit")}return false},getUsableDateTime:function(t,e){if(typeof t=="object"&&t.getTime)t=t.getTime();var i=(e||10)*60*1e3;t=Math.ceil(t/i)*i;return new Date(t)},getTimeForNewEntry:function(t){t=this.getUsableDateTime(t);return{from:t,to:new Date(t.getTime()+36e5)}},getDefaultEntryName:function(){return this.calendar.newEntryName||BX.message("EC_DEFAULT_ENTRY_NAME")},moveEventToNewDate:function(t,e,i,n={}){t=this.setDateRangeToEntry(t,e,i);this.addMovedEntry(t);if(this.calendar.isExternalMode()){this.calendar.triggerEvent("entryOnDragEnd",{entry:t,dateFrom:t.from,dateTo:t.to});return new Promise((t=>{t(false)}))}if(t.isMeeting()&&n.sendInvitesAgain===undefined&&t.getAttendees().find((t=>t.STATUS==="N"))){return new Promise((n=>{BX.Calendar.EntryManager.showReInviteUsersDialog({callback:a=>{this.moveEventToNewDate(t,e,i,{sendInvitesAgain:a.sendInvitesAgain}).then((t=>{n(t)}))}})}))}this.sentRequests.push(this.REQUEST_MOVE_EVENT);return new Promise((e=>{BX.ajax.runAction("calendar.api.calendarentryajax.moveEvent",{data:{id:t.id,current_date_from:t.data.DATE_FROM,date_from:t.isFullDay()?this.calendar.util.formatDate(t.from):this.calendar.util.formatDateTime(t.from),date_to:t.isFullDay()?this.calendar.util.formatDate(t.to):this.calendar.util.formatDateTime(t.to),skip_time:t.isFullDay()?"Y":"N",attendees:this.getEntryAttendeesIds(t),location:t.location||"",recursive:t.isRecursive()?"Y":"N",is_meeting:t.isMeeting()?"Y":"N",section:t.sectionId,timezone:this.calendar.util.getUserOption("timezoneName"),set_timezone:"Y",sendInvitesAgain:n.sendInvitesAgain?"Y":"N",requestUid:BX.Calendar.Util.registerRequestId()}}).then((i=>{this.sentRequests.pop();let n=true;if(t.isMeeting()&&i.data.busy_warning){alert(BX.message("EC_BUSY_ALERT"));n=false}if(i.data.location_busy_warning){alert(BX.message("EC_LOCATION_RESERVE_ERROR"));n=false}if(!n){this.removeMovedEntry(t)}this.calendar.reload();e(n)}))}))},setDateRangeToEntry:function(t,e,i){t.from.setFullYear(e.getFullYear(),e.getMonth(),e.getDate());if(t.fullDay){t.from.setHours(e.getHours(),e.getMinutes(),0,0)}if(i&&BX.type.isDate(i)){t.to.setFullYear(i.getFullYear(),i.getMonth(),i.getDate());if(t.fullDay){t.to.setHours(i.getHours(),i.getMinutes(),0,0)}}else{t.to=new Date(t.from.getTime()+(t.data.DT_LENGTH-(t.fullDay?1:0))*1e3)}return t},getEntryAttendeesIds:function(t){const e=[];if(t.isMeeting()){t.data["ATTENDEE_LIST"].forEach((t=>{e.push(t["id"])}))}return e},viewEntry:function(t){this.calendar.getView().showViewSlider(t)},editEntry:function(t){this.calendar.getView().showEditSlider(t)},doesDateRangeContainUnloadedEvents:function(t,e){if(this.calendar.isExternalMode()){return this.externalEntryIndex[this.getChunkIdByDate(t)]&&this.externalEntryIndex[this.getChunkIdByDate(e)]}const i=this.getSections().allActive;for(const n of i){if(!this.pulledEntriesIndex[n]||!this.pulledEntriesIndex[n][this.getChunkIdByDate(t)]||!this.pulledEntriesIndex[n][this.getChunkIdByDate(e)]){return true}}return false},fillChunkIndex:function(t,e,i){i=BX.Type.isObjectLike(i)?i:{};if(!this.loadedStartDate)this.loadedStartDate=t;else if(t.getTime()<this.loadedStartDate.getTime())this.loadedStartDate=t;if(!this.loadedFinishDate)this.loadedFinishDate=e;else if(e.getTime()>this.loadedFinishDate.getTime())this.loadedFinishDate=e;var n=new Date;var a=0;n.setFullYear(t.getFullYear(),t.getMonth(),1);var s=this.getChunkIdByDate(e);var r=this.getChunkIdByDate(n);var o=i.value===undefined?true:i.value;if(this.calendar.isExternalMode()){this.externalEntryIndex[r]=o;this.externalEntryIndex[s]=o;while(r!==s&&a<100){this.externalEntryIndex[r]=o;n.setMonth(n.getMonth()+1);r=this.getChunkIdByDate(n);a++}}else{if(this.calendar.util.type==="location"){i.sections=i.sections||this.calendar.roomsManager.getRoomsInfo().allActive}else{i.sections=i.sections||this.calendar.sectionManager.getSectionsInfo().allActive}i.index=i.index||this.pulledEntriesIndex;var d=i.index;i.sections.forEach((function(t){if(!d[t]){d[t]={}}d[t][r]=o;d[t][s]=o}));while(r!==s&&a<100){i.sections.forEach((function(t){d[t][r]=o}));n.setMonth(n.getMonth()+1);r=this.getChunkIdByDate(n);a++}}},getChunkIdByDate:function(t){return t.getFullYear()+"-"+(t.getMonth()+1)},getLoadedEntiesLimits:function(){return{start:this.loadedStartDate,end:this.loadedFinishDate}},loadEntries:function(t){return new Promise((e=>{const i=this.getSections();BX.ajax.runAction("calendar.api.calendarentryajax.loadEntries",{data:{ownerId:this.calendar.util.ownerId,type:this.calendar.util.type,month_from:t.startDate?t.startDate.getMonth()+1:"",year_from:t.startDate?t.startDate.getFullYear():"",month_to:t.finishDate?t.finishDate.getMonth()+1:"",year_to:t.finishDate?t.finishDate.getFullYear():"",active_sect:i.active,sup_sect:i.superposed,direction:t.direction??""}}).then((n=>{this.appendToEntriesRaw(n.data.entries);this.updateUserIndex(n.data.userIndex);if(n.data.newYearFrom!==undefined&&n.data.newMonthFrom!==undefined){const e=t.startDate;t.startDate=new Date(n.data.newYearFrom,n.data.newMonthFrom-1,e.getDate())}if(n.data.newYearTo!==undefined&&n.data.newMonthTo!==undefined){const e=t.finishDate;t.finishDate=new Date(n.data.newYearTo,n.data.newMonthTo-1,e.getDate())}this.fillChunkIndex(t.startDate,t.finishDate,{sections:i.allActive});BX.Event.EventEmitter.emit("BX.Calendar:onEntryListReload",{isBoundaryOfPastReached:n.data.isBoundaryOfPastReached,isBoundaryOfFutureReached:n.data.isBoundaryOfFutureReached});e(n.data)}))}))},loadExternalEntries:function(t){if(t.showLoader){this.calendar.showLoader()}return new Promise((e=>{this.calendar.triggerEvent("loadEntries",{params:t,onLoadCallback:function(i){this.calendar.hideLoader();this.appendToEntriesRaw(i.entries);if(!t.finishDate&&this.entriesRaw.length>0){var n=this.entriesRaw[this.entriesRaw.length-1].DATE_FROM;n=BX.parseDate(n);if(n){n.setFullYear(n.getFullYear(),n.getMonth(),0);t.finishDate=n}}if(t.startDate&&t.finishDate){this.fillChunkIndex(t.startDate,t.finishDate)}if(BX.type.isFunction(t.finishCallback)){t.finishCallback(i)}e()}.bind(this),onErrorCallback:function(t){this.calendar.hideLoader()}.bind(this)})}))},appendToEntriesRaw:function(t){const e=this.calendar.util.getUserOption("showDeclined");for(const i of t){if((!e||parseInt(i.CREATED_BY)!==this.calendar.util.userId)&&i.MEETING_STATUS==="N"){continue}const t=this.getUniqueId(i);if(this.loadedEntriesIndex[t]===undefined){this.entriesRaw.push(i);this.loadedEntriesIndex[t]=this.entriesRaw.length-1}else if(i.CAL_TYPE===this.calendar.util.type&&parseInt(i.OWNER_ID)===parseInt(this.calendar.util.ownerId)){this.entriesRaw[this.loadedEntriesIndex[t]]=i}}},updateUserIndex:function(t){if(!BX.type.isNotEmptyObject(t)){return}for(const e in t){if(t.hasOwnProperty(e)){this.userIndex[e]=t[e]}}BX.Calendar.EntryManager.setUserIndex(this.userIndex)},getEntriesFromEntriesRaw:function(t){const e=[];const n=this.getActiveSectionsIndex();const a={};this.entriesRaw.forEach((t=>{if(!t.COLOR){return}a[t.ID]??={};a[t.ID][t.COLOR]??=0;a[t.ID][t.COLOR]++}));this.entriesRaw.forEach((t=>{if(!t.COLOR){return}const e=a[t.ID];t.COLOR=Object.keys(e).reduce(((t,i)=>e[t]<e[i]?t:i))}));for(const a of this.entriesRaw){if(a["~TYPE"]==="tasks"&&!n["tasks"]||a["~TYPE"]!=="tasks"&&a["SECT_ID"]&&!n[parseInt(a["SECT_ID"])]){if(a["CAL_TYPE"]!=="open_event"){continue}}const s=this.findMovedEntry(a);if(s){if(a.DATE_FROM===s.DATE_FROM&&a.DATE_TO===s.DATE_TO&&parseInt(a.DT_LENGTH)===s.DT_LENGTH){this.movedEntries=this.movedEntries.filter((t=>t.ID!==s.ID))}else{a.DATE_FROM=s.DATE_FROM;a.DATE_TO=s.DATE_TO;a.DT_LENGTH=s.DT_LENGTH}}const r=new i(this.calendar,a);if(!t||t&&r.applyViewRange(t)){e.push(r)}}return e},addMovedEntry:function(t){const e=t.isFullDay()?this.calendar.util.formatDate(t.from):this.calendar.util.formatDateTime(t.from);const i=t.isFullDay()?this.calendar.util.formatDate(t.to):this.calendar.util.formatDateTime(t.to);let n=(t.to.getTime()-t.from.getTime())/1e3;if(t.fullDay){n+=86400}this.movedEntries=this.movedEntries.filter((e=>e.ID!==t.uid));this.movedEntries.push({ID:t.uid,RECURRENCE_ID:t.parentId,ORIGINAL_DATE_FROM:this.calendar.util.formatDateTime(BX.parseDate(t.data.DATE_FROM)),DATE_FROM:e,DATE_TO:i,DT_LENGTH:n})},removeMovedEntry:function(t){this.movedEntries=this.movedEntries.filter((e=>e.ID!==t.uid))},findMovedEntry:function(t){return this.movedEntries.filter((e=>{const i=!!t.RRULE;if(i){return t.RECURRENCE_ID===e.RECURRENCE_ID&&t.ORIGINAL_DATE_FROM===e.ORIGINAL_DATE_FROM}return t.ID===e.ID}))[0]},findMovedEntryById:function(t){return this.movedEntries.filter((e=>t===e.ID))[0]},getActiveSectionsIndex:function(){const t={};this.getSections().allActive.forEach((e=>{t[e==="tasks"?e:parseInt(e)]=true}));return t},getSections(){if(this.calendar.util.type==="location"){return this.calendar.roomsManager.getRoomsInfo()}return this.calendar.sectionManager.getSectionsInfo()},getUniqueId:function(t,e){var i=t.PARENT_ID||t.ID;if(t.RRULE){i+="|"+(e?this.calendar.util.formatDate(e.from):this.calendar.util.formatDate(BX.parseDate(t.DATE_FROM)))}if(t["~TYPE"]==="tasks"){i+="|"+"task"}return i},sort:function(t,e){if(t.entry.isTask()&&!e.entry.isTask()){return 1}if(!t.entry.isTask()&&e.entry.isTask()){return-1}if(t.part.daysCount===e.part.daysCount){return t.entry.from.getTime()-e.entry.from.getTime()}return e.part.daysCount-t.part.daysCount},clearLoadIndexCache:function(){this.pulledEntriesIndex={};this.entriesRaw=[];this.loadedEntriesIndex={};this.externalEntryIndex={}},checkMeetingByCodes:function(t){var e,i=0;if(t){for(e in t){if(t.hasOwnProperty(e)){if(t[e]!="users"||i>0){return true}i++}}}return false},getUserIndex:function(){return this.userIndex}};function i(t,e){this.calendar=t;this.data=e;this.id=e.ID||0;if(!this.data.DT_SKIP_TIME){this.data.DT_SKIP_TIME=this.data.SKIP_TIME?"Y":"N"}if(!BX.Type.isString(this.data.NAME)){this.data.NAME=BX.message("EC_DEFAULT_ENTRY_NAME")}else{this.data.NAME=this.data.NAME.replaceAll(/\r\n|\r|\n/g," ")}this.fullDay=e.DT_SKIP_TIME==="Y";this.parentId=e.PARENT_ID||0;this.accessibility=e.ACCESSIBILITY;this.important=e.IMPORTANCE==="high";this.private=!!e.PRIVATE_EVENT;this.sectionId=this.isTask()?"tasks":parseInt(e.SECT_ID);this.name=this.isLocation()?this.calendar.roomsManager.getRoomName(e.SECT_ID)+": "+e.NAME:e.NAME;this.parts=[];var i=this,n=this.calendar.util,a,s,r=e.COLOR||(this.isLocation()?this.calendar.roomsManager.getRoom(this.sectionId).color:this.calendar.sectionManager.getSection(this.sectionId).color);Object.defineProperties(this,{startDayCode:{get:function(){return a},set:function(t){a=n.getDayCode(t)}},endDayCode:{get:function(){return s},set:function(t){s=n.getDayCode(t)}},color:{get:function(){return r},set:function(t){r=t}},location:{value:e.LOCATION,writable:true,enumerable:true}});this.prepareData();this.uid=this.calendar.entryController.getUniqueId(e,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)}if(this.fullDay){this.to=new Date(this.from.getTime()+(this.data.DT_LENGTH-3601)*1e3);this.to.setHours(0,0,0,0)}else{this.to=new Date(this.from.getTime()+this.data.DT_LENGTH*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(){if(!this.attendeeList&&BX.type.isArray(this.data["ATTENDEE_LIST"])){this.attendeeList=[];var t=this.calendar.entryController.getUserIndex();this.data["ATTENDEE_LIST"].forEach((function(e){if(t[e.id]){var i=BX.clone(t[e.id]);i.STATUS=e.status;i.ENTRY_ID=e.entryId;this.attendeeList.push(i)}}),this)}return this.attendeeList||[]},cleanParts:function(){this.parts=[]},startPart:function(t){t.partIndex=this.parts.length;this.parts.push(t);return this.parts[t.partIndex]},registerPartNode:function(t,e){t.params=e},checkPartIsRegistered:function(t){return BX.type.isPlainObject(t.params)},getPart:function(t){return this.parts[t]||false},getWrap:function(t){return this.parts[t||0].params.wrapNode},getSectionName:function(){return this.calendar.sectionManager.getSection(this.sectionId).name||""},getDescription:function(){return this.data.DESCRIPTION||""},applyViewRange:function(t){var e=t.start.getTime(),i=t.end.getTime(),n=this.from.getTime(),a=this.to.getTime();if(a<e||n>i){return false}if(n<e){this.displayFrom=t.start;this.startDayCode=this.displayFrom}if(a>i){this.displayTo=t.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"},isSharingEvent:function(){return this.data["EVENT_TYPE"]==="#shared#"||this.data["EVENT_TYPE"]==="#shared_crm#"},isCollabEvent:function(){return this.data["EVENT_TYPE"]==="#collab#"},isSharingCollabEvent:function(){return this.data["EVENT_TYPE"]==="#shared_collab#"},getCollabId:function(){return this.data["COLLAB_ID"]||null},isInvited:function(){return this.getCurrentStatus()==="Q"},isLocation:function(){return this.data.CAL_TYPE==="location"},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()},hasEmailAttendees:function(){if(this.emailAttendeesCache===undefined&&BX.type.isArray(this.data["ATTENDEE_LIST"])){var t=BX.Calendar.EntryManager.getUserIndex();var e;for(var i=0;i<this.data["ATTENDEE_LIST"].length;i++){e=this.data["ATTENDEE_LIST"][i];if((e.status==="Y"||e.status==="Q")&&t[e.id]&&t[e.id].EMAIL_USER){this.emailAttendeesCache=true;break}}}return this.emailAttendeesCache},ownerIsEmailUser:function(){if(this.ownerIsEmailUserCache===undefined){var t=BX.Calendar.EntryManager.getUserIndex();this.ownerIsEmailUserCache=t[parseInt(this.data.MEETING_HOST)]&&t[parseInt(this.data.MEETING_HOST)].EMAIL_USER}return this.ownerIsEmailUserCache},isSelected:function(){return!!this.selected},isCrm:function(){return!!this.data.UF_CRM_CAL_EVENT},isFirstReccurentEntry:function(){return(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},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},getUniqueId:function(){var t=this.data.PARENT_ID||this.data.PARENT_ID;if(this.isRecursive())t+="|"+this.data.DT_FROM_TS;if(this.data["~TYPE"]=="tasks")t+="|"+"task";return t},getCurrentStatus:function(){var t,e,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(BX.type.isArray(this.data["ATTENDEE_LIST"])){for(t=0;t<this.data["ATTENDEE_LIST"].length;t++){e=this.data["ATTENDEE_LIST"][t];if(this.data["ATTENDEE_LIST"][t].id==this.calendar.util.userId){i=this.data["ATTENDEE_LIST"][t].status;break}}}}return i},getReminders:function(){var t=[];if(this.data&&this.data.REMIND){this.data.REMIND.forEach((function(e){if(e.type==="min"){t.push(e.count)}else if(e.type==="hour"){t.push(Number(e.count)*60)}if(e.type==="day"){t.push(Number(e.count)*60*24)}}))}return t},getLengthInDays:function(){var t=new Date(this.from.getFullYear(),this.from.getMonth(),this.from.getDate(),0,0,0),e=new Date(this.to.getFullYear(),this.to.getMonth(),this.to.getDate(),0,0,0);return Math.round((e.getTime()-t.getTime())/this.calendar.util.dayLength)+1},getColor:function(){return this.color},isOpenEvent:function(){return this.data.CAL_TYPE==="open_event"}};if(t.BXEventCalendar){t.BXEventCalendar.Entry=i;t.BXEventCalendar.EntryController=e}else{BX.addCustomEvent(t,"onBXEventCalendarInit",(function(){t.BXEventCalendar.Entry=i;t.BXEventCalendar.EntryController=e}))}})(window); //# sourceMappingURL=calendar-entry.map.js