uawdijnntqw1x1x1
IP : 18.224.212.19
Hostname : axolotl
Kernel : Linux axolotl 4.9.0-13-amd64 #1 SMP Debian 4.9.228-1 (2020-07-05) x86_64
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
OS : Linux
PATH:
/
var
/
www
/
axolotl
/
data
/
www
/
axolotl.ru
/
www
/
bitrix
/
js
/
crm
/
activity_planner.min.js
/
/
BX.namespace("BX.Crm.Activity");(function(t){"use strict";if(typeof t.Crm.Activity.Planner!=="undefined")return;var e="data-crm-act-planner";var i="/bitrix/components/bitrix/crm.activity.planner/ajax.php?site_id="+t.message("SITE_ID");var n="/bitrix/components/bitrix/crm.activity.editor/ajax.php?siteID="+t.message("SITE_ID")+"&sessid="+t.bitrix_sessid();var a=function(t){if(typeof t==="undefined")t={};this.ajaxUrl=t.ajaxUrl||i;this.loadOffsetLeft=3;this.loadOffsetRight=10;this.PLANNER_DURATION_LIMIT=864e6;this.activityId=null;this.showError=function(t){window.alert(t)};a.Manager.put(this)};a.Manager={instances:{},listeners:{},lastId:"",put:function(t){if(!(t instanceof a))throw"activityPlanner is not instanceof Planner";var e=t.getPlannerId();this.instances[e]=t;this.lastId=e;return this},get:function(t){t=t.toString();if(typeof this.instances[t]==="undefined")return null;return this.instances[t]},getLast:function(){return this.get(this.lastId)},pop:function(t){delete this.instances[t.toString()];return this},findByChild:function(i){var n=t.findParent(i,{attr:e});if(n){return this.get(n.getAttribute(e))}return null},setCallback:function(t,e){this.listeners[t]=e;return this},fireEvent:function(t,e,i){var n=this.listeners[t];if(typeof n==="function"){n.call(i,e)}},fireGlobalEvent:function(t,e,i){this.fireEvent(t,e,i);if(window!==top&&top.BX.Crm&&top.BX.Crm.Activity&&top.BX.Crm.Activity.Planner&&top.BX.Crm.Activity.Planner.Manager){top.BX.Crm.Activity.Planner.Manager.fireEvent(t,e,i)}}};a.util={unFormatTime:function(t){var e=t.split(/[\s:]+/);if(e.length==3){var i=e[2];if(i=="pm"&&e[0]<12)e[0]=parseInt(e[0],10)+12;if(i=="am"&&e[0]==12)e[0]=0}return parseInt(e[0],10)*3600+parseInt(e[1],10)*60},formatTime:function(e){var i=t.date.convertBitrixFormat(t.message("FORMAT_DATE")).replace(/:?\s*s/,""),n=t.date.convertBitrixFormat(t.message("FORMAT_DATETIME")).replace(/:?\s*s/,""),a=t.date.format(i,e),o=t.date.format(n,e);return t.util.trim(o.replace(a,""))},convertDateTime:function(e){var i=t.message("FORMAT_DATETIME");var n=t.date.convertBitrixFormat(t.type.isNotEmptyString(i)?i:"DD.MM.YYYY HH:MI:SS");return t.date.format(n,e)},storageType:{File:1,Webdav:2,Disk:3},periodType:{min:1,hour:2,day:3},getPeriodLabels:function(e){var i=[];if(e===1)i=[t.message("CRM_ACTIVITY_PLANNER_MIN1"),t.message("CRM_ACTIVITY_PLANNER_MIN2"),t.message("CRM_ACTIVITY_PLANNER_MIN3")];else if(e===2)i=[t.message("CRM_ACTIVITY_PLANNER_HOUR1"),t.message("CRM_ACTIVITY_PLANNER_HOUR2"),t.message("CRM_ACTIVITY_PLANNER_HOUR3")];else if(e===3)i=[t.message("CRM_ACTIVITY_PLANNER_DAY1"),t.message("CRM_ACTIVITY_PLANNER_DAY2"),t.message("CRM_ACTIVITY_PLANNER_DAY3")];return i}};a.prototype.getPlannerId=function(){if(typeof this.plannerId==="undefined")this.plannerId="crm-act-planner-"+Math.round(Math.random()*1e5);return this.plannerId};a.prototype.setPopup=function(t){this.popup=t;return this};a.prototype.getPopup=function(){return this.popup};a.prototype.setPlannerNode=function(t){this.scopeNode=t;return this};a.prototype.getPlannerNode=function(){return this.scopeNode};a.prototype.setActivityId=function(t){this.activityId=t||null};a.prototype.getActivityId=function(){return this.activityId};a.prototype.getNode=function(t,e){if(!e)e=this.getPlannerNode();return e?e.querySelector('[data-role="'+t+'"]'):null};a.prototype.getNodeValue=function(t,e){var i=this.getNode(t,e);return i?i.value:null};a.prototype._createAjaxPopup=function(i,n){i["sessid"]=t.bitrix_sessid();i["PLANNER_ID"]=this.getPlannerId();var a=this;t.ajax({method:"POST",dataType:"html",url:this.ajaxUrl,data:i,onsuccess:function(i){var o=t.create("div",{style:{"min-width":"660px"}});o.innerHTML=i;o.setAttribute(e,a.getPlannerId());var r="",s=a.getNode("wrapper-container",o);if(s){r=s.getAttribute("data-title")}if(!r)r=t.message("CRM_ACTIVITY_PLANNER_PLANNING_TITLE");var l=[];if(s){l.push(new t.PopupWindowButton({text:t.message("CRM_ACTIVITY_PLANNER_SAVE"),className:"popup-window-button-accept",events:{click:function(){a.saveActivity()}}}))}l.push(new t.PopupWindowButtonLink({text:t.message("CRM_ACTIVITY_PLANNER_CANCEL"),className:"popup-window-button-link-cancel",events:{click:function(){this.popupWindow.close()}}}));var d=new t.PopupWindow(a.getPlannerId(),null,{titleBar:r,content:o,closeIcon:true,contentNoPaddings:true,zIndex:-100,offsetLeft:0,offsetTop:0,closeByEsc:true,draggable:{restrict:false},overlay:{backgroundColor:"black",opacity:30},events:{onPopupClose:function(e){a.onPopupClose();e.destroy();t.onCustomEvent(window,"onActivityEditorClose",[])}},buttons:l});a.setPlannerNode(o);a.setPopup(d);n(s)}})};a.prototype._createEditSlider=function(i,n){var a=this;i["PLANNER_ID"]=this.getPlannerId();i.ajax_action="ACTIVITY_EDIT";i.activity_id=i["ID"]||0;top.BX.SidePanel.Instance.open("/bitrix/components/bitrix/crm.activity.planner/slider.php?site_id="+t.message("SITE_ID")+"&"+t.ajax.prepareData(i),{compatibleEvents:true,allowChangeHistory:false,events:{onOpen:function(t){var n=t.iframe.contentWindow.BX;if(!n){return}n.namespace("BX.Crm.Activity");if(!n.Crm.Activity.Planner){return}var o=t.iframe.contentDocument.body;var r=new n.Crm.Activity.Planner;r.setActivityId(i.activity_id);r.plannerId=a.getPlannerId();o.setAttribute(e,r.getPlannerId());r.setPlannerNode(o);r.prepareEditLayout(o);n.addCustomEvent("onAfterActivitySave",(function(e){top.BX.onCustomEvent(a,"onAfterActivitySave",e);n.Crm.Activity.Planner.Manager.fireGlobalEvent("onAfterActivitySave",{},a);t.close()}));var s=r.getNode("button-save");if(s){n.bind(s,"click",(function(t){t.preventDefault();r.saveActivity()}))}var l=r.getNode("button-cancel");if(l){n.bind(l,"click",(function(){t.close()}))}var d=r.getNode("error-block"),c=r.getNode("error-block-text");if(d&&c){r.showError=function(t){c.textContent=t;n.style(d,"height","auto");n.style(d,"opacity","1");setTimeout((function(){n.style(d,"height","0");n.style(d,"opacity","0")}),1500)}}}}})};a.prototype.onNotifyActivatorChange=function(e){var i=e.checked;var n=this.getNode("notify-switcher");var a=this.getNode("notify-activator-label");t[i?"addClass":"removeClass"](n,"crm-activity-popup-container-open");a.innerHTML=a.getAttribute("data-label-"+(i?"y":"n"));this.setNotify(i?15:0,i?1:0)};a.prototype.onNotifyChangeClick=function(e){var i=this;var n=t.clone(i.getNode("template-notify"));var a=i.getNode("notify-value",n);var o=i.getNode("notify-value-type",n);var r=i.getNode("field-notify-value");var s=i.getNode("field-notify-type");a.value=r.value;o.value=s.value;var l=new t.PopupWindow("crm-act-win-notify-"+Math.round(Math.random()*1e5),e,{lightShadow:true,autoHide:true,closeByEsc:true,bindOptions:{position:"bottom"},angle:{position:"top"},closeIcon:false,events:{onPopupClose:function(t){t.destroy()}},content:n});var d=i.getNode("notify-menu-save",n);t.bind(d,"click",(function(){i.setNotify(a.value,o.value);l.close()}));l.show();return false};a.prototype.synchronizeViewModeState=function(){var t=this.getNode("view-mode-switcher");if(t.getAttribute("data-state")==="open"){var e=this.getNode("detail-container");t.innerHTML=t.getAttribute("data-label-short");e.style.maxHeight="60px";e.style.paddingTop="30px";e.style.paddingBottom="15px";e.style.opacity=1}};a.prototype.onViewModeClick=function(e){var i=e.getAttribute("data-state")=="open"?1:0;var n=parseInt(e.getAttribute("data-animation-duration"))||250;var a=this.getNode("detail-container");var o={dateMaxHeight:i*60,datePaddingTop:i*30,datePaddingBottom:i*15,dateOpacity:i*100};var r={dateMaxHeight:60-i*60,datePaddingTop:30-i*30,datePaddingBottom:15-i*15,dateOpacity:100-i*100};new t.easing({duration:n,start:o,finish:r,transition:t.easing.makeEaseInOut(t.easing.transitions.quad),step:t.delegate((function(t){a.style.maxHeight=t.dateMaxHeight+"px";a.style.paddingTop=t.datePaddingTop+"px";a.style.paddingBottom=t.datePaddingBottom+"px";a.style.opacity=t.dateOpacity/100}),e)}).animate();e.innerHTML=e.getAttribute("data-label-"+(i==0?"short":"detail"));e.setAttribute("data-state",i==0?"open":"");t.userOptions.save("crm.activity.planner","edit","view_mode",i==1?"short":"detail",false);return false};a.prototype.onAdditionalModeClick=function(e){var i=this.getNode("additional-container");t.toggleClass(i,"crm-activity-person-detail-open");t.toggleClass(e,"crm-activity-popup-info-person-link-triangle-up");t.userOptions.save("crm.activity.planner","edit","additional_mode",t.hasClass(i,"crm-activity-person-detail-open")?"open":"",false);return false};a.prototype.onDaySwitchClick=function(e){var i=new Date;var n=parseInt(e.getAttribute("data-day"));if(n>0)i.setTime(i.getTime()+n*864e5);var a=this.getNode("calendar-start-time");a.value=t.formatDate(i,t.message("FORMAT_DATE"));t.fireEvent(a,"change")};a.prototype.selectDayFromDate=function(e){var i=new Date(e.getTime());i.setHours(0,0,0,0);var n=new Date;n.setHours(0,0,0,0);var a=(i.getTime()-n.getTime())/864e5;var o=t.findChildren(this.getNode("day-switcher"),{attr:"data-day"});for(var r=0,s=o.length;r<s;++r){var l=parseInt(o[r].getAttribute("data-day"));if(l==a)t.addClass(o[r],"select-date-active");else t.removeClass(o[r],"select-date-active")}};a.prototype.onTimeSwitchClick=function(e){var i=this;if(!i.clockInstance){i.clockInstance=new t.CClockSelector({start_time:a.util.unFormatTime(e.value),node:e,callback:t.doNothing})}i.clockInstance.setNode(e);i.clockInstance.setTime(a.util.unFormatTime(e.value));i.clockInstance.setCallback((function(n){e.value=n;t.fireEvent(e,"change");i.clockInstance.closeWnd()}));i.clockInstance.Show()};a.prototype.setNotify=function(t,e){t=parseInt(t);e=parseInt(e);var i=this.getNode("notify-switcher");var n=this.getNode("field-notify-value");var a=this.getNode("field-notify-type");if(t>0)i.innerHTML=this.getFormattedPeriodLabel(t,e);n.value=t;a.value=e};a.prototype.getFormattedPeriodLabel=function(t,e){var i=t+" ";var n=0;if(t>20)t=t%10;if(t==1)n=0;else if(t>1&&t<5)n=1;else n=2;var o=a.util.getPeriodLabels(e);return i+(o?o[n]:"")};a.prototype.showEdit=function(t){var e=this;if(top.BX.SidePanel){this._createEditSlider(t,e.prepareEditLayout.bind(this))}else{t["ajax_action"]="activity_edit";this._createAjaxPopup(t,e.prepareEditLayout.bind(this))}return false};a.prototype.prepareEditLayout=function(e){var i=this,n=i.getPopup();if(!e){if(n){n.show()}return}var o=this.getNodeValue("field-provider-id");i.synchronizeViewModeState();t.bind(i.getNode("view-mode-switcher"),"click",(function(){i.onViewModeClick(this)}));t.bind(i.getNode("additional-mode-switcher"),"click",(function(){i.onAdditionalModeClick(this)}));t.bind(i.getNode("priority-switcher"),"click",(function(){t.toggleClass(i.getNode("priority-flame"),"crm-activity-popup-container-open");return false}));var l,d,c=i.getNode("day-switcher");for(l=0,d=c.childNodes.length;l<d;++l){t.bind(c.childNodes[l],"click",(function(){i.onDaySwitchClick(this)}))}t.bind(i.getNode("notify-activator"),"change",(function(){i.onNotifyActivatorChange(this)}));t.bind(i.getNode("notify-switcher"),"click",(function(){i.onNotifyChangeClick(this)}));i.setNotify(i.getNode("field-notify-value").value,i.getNode("field-notify-type").value);var u=function(){t.calendar({node:this,field:this,bTime:false});return false};t.bind(i.getNode("calendar-start-time"),"click",u);t.bind(i.getNode("calendar-end-time"),"click",u);t.bind(i.getNode("clock-start-time"),"click",(function(){i.onTimeSwitchClick(this)}));t.bind(i.getNode("clock-end-time"),"click",(function(){i.onTimeSwitchClick(this)}));t.bind(i.getNode("calendar-start-time"),"change",(function(){i.updateStartTime()}));t.bind(i.getNode("clock-start-time"),"change",(function(){i.updateStartTime()}));t.bind(i.getNode("calendar-end-time"),"change",(function(){i.updateEndTime()}));t.bind(i.getNode("clock-end-time"),"change",(function(){i.updateEndTime()}));t.bind(i.getNode("duration-value"),"change",(function(){i.recalculateEndTime()}));t.bind(i.getNode("duration-type"),"change",(function(){i.recalculateEndTime()}));var p=i.getNode("storage-switcher");if(p){var h=parseInt(p.getAttribute("data-storage-type"));var m=JSON.parse(p.getAttribute("data-values"));if(h===a.util.storageType.Disk){i.createDiskUploader(m,i.getNode("storage-container"))}else{t.hide(p);t.hide(i.getNode("storage-container"))}}var g=JSON.parse(i.getNode("destination-entities").value);var f=i.getNode("template-destination-container");var v=i.getNode("template-destination-item");var y=i.getNode("deal-container");if(y){i.dealDestination=new r(y,"deal",{containerTpl:f,itemTpl:v,valueInputName:"dealId",selected:g.deal,selectOne:true})}var T=i.getNode("order-container");if(T){i.orderDestination=new r(T,"order",{containerTpl:f,itemTpl:v,valueInputName:"orderId",selected:g.order,selectOne:true})}var C=i.getNode("responsible-container");if(C){i.responsibleDestination=new r(i.getNode("responsible-container"),"responsible",{containerTpl:f,itemTpl:v,valueInputName:"responsibleId",selected:g.responsible,selectOne:true,required:true,events:{select:function(t){i.checkPlannerState(t)}}})}var _=i.getNode("communications-container");if(_){i.communications=new s(_,{entityType:i.getNodeValue("field-owner-type"),entityId:i.getNodeValue("field-owner-id"),containerTpl:f,itemTpl:v,selected:JSON.parse(i.getNode("communications-data").value),selectOne:true,communicationType:i.getNode("communications-container").getAttribute("data-communication-type")})}if(n){n.show()}var I=i.getNode("focus-on-show");if(I)t.defer(t.focus)(I);i.refreshDateTimeView()};a.prototype.onPopupClose=function(){if(this.communications){this.communications.onPlannerClose()}if(this.dealDestination){this.dealDestination.onPlannerClose()}if(this.orderDestination){this.orderDestination.onPlannerClose()}if(this.responsibleDestination){this.responsibleDestination.onPlannerClose()}};a.prototype.saveActivity=function(){var e,i=this;var n=i.getStartTime();var o=i.getEndTime();var r=this.getNodeValue("field-provider-type-id");if(n&&o&&n.getTime()>o.getTime()){this.showError(t.message("CRM_ACTIVITY_PLANNER_DATES_ERR"));return}if(this.saveInProgress)return;this.saveInProgress=true;var s=t.ajax.prepareForm(this.getNode("form")).data;var l=i.getNode("storage-switcher");if(l){var d=parseInt(l.getAttribute("data-storage-type"));if(d===a.util.storageType.Disk&&this.diskUploader){s["storageTypeID"]=a.util.storageType.Disk;s["diskfiles"]=this.diskUploader.getFileIds()}else{s["disableStorageEdit"]="Y"}}s["communications"]=i.communications?i.communications.items:[];var c=s["dealId"]||s["ownerId"]&&s["ownerType"];if(!c){for(e=0;e<s["communications"].length;++e){if(s["communications"][e]["entityId"]>0){c=true;break}}}if(!c&&r!=="CALL_LIST"){this.showError(t.message("CRM_ACTIVITY_PLANNER_NO_OWNER"));i.saveInProgress=false;return}t.ajax({method:"POST",dataType:"json",url:this.ajaxUrl,data:{ajax_action:"ACTIVITY_SAVE",data:s,sessid:t.bitrix_sessid()},onsuccess:function(e){i.saveInProgress=false;if(e.SUCCESS){if(i.getPopup()){i.getPopup().close()}t.onCustomEvent(i,"onAfterActivitySave",[e.DATA.ACTIVITY]);a.Manager.fireEvent("onAfterActivitySave",{},i)}else{i.showError(e.ERRORS[0])}}})};a.prototype.getDurationValue=function(){var t=parseInt(this.getNode("duration-value").value);var e=parseInt(this.getNode("duration-type").value);if(isNaN(t))t=0;if(isNaN(e))e=1;if(e===2)t*=60;if(e===3)t*=60*24;return t*60*1e3};a.prototype.setStartTime=function(e,i){e.setSeconds(0);var n=this.getNode("field-start-time");n.value=a.util.convertDateTime(e);t.fireEvent(n,"change");if(!i){this.recalculateEndTime()}};a.prototype.getStartTime=function(){return t.parseDate(this.getNode("field-start-time").value)};a.prototype.updateStartTime=function(){var e=t.parseDate(this.getNode("calendar-start-time").value);e.setTime(e.getTime()+a.util.unFormatTime(this.getNode("clock-start-time").value)*1e3);this.setStartTime(e);this.selectDayFromDate(e)};a.prototype.setEndTime=function(e,i){e.setSeconds(0);var n=this.getNode("field-end-time");n.value=a.util.convertDateTime(e);t.fireEvent(n,"change");if(!i){this.recalculateDuration()}};a.prototype.getEndTime=function(){return t.parseDate(this.getNode("field-end-time").value)};a.prototype.updateEndTime=function(){var e=t.parseDate(this.getNode("calendar-end-time").value);e.setTime(e.getTime()+a.util.unFormatTime(this.getNode("clock-end-time").value)*1e3);this.setEndTime(e)};a.prototype.recalculateEndTime=function(t){var e=this.getStartTime();e.setTime(e.getTime()+this.getDurationValue());this.setEndTime(e,true);if(!t){this.refreshEndTimeView();this.refreshPlannerState({refreshIfShown:true})}return e};a.prototype.recalculateDuration=function(t){var e=this.getEndTime();var i=this.getStartTime();var n=Math.floor((e.getTime()-i.getTime())/6e4);var a=1;if(n%1440==0){n=n/1440;a=3}else if(n%60===0){n=n/60;a=2}if(!t){this.refreshPlannerState({refreshIfShown:true})}this.getNode("duration-value").value=n>0?n:"";this.getNode("duration-type").value=a};a.prototype.refreshStartTimeView=function(){var e=this.getStartTime();if(!e){e=new Date;var i=e.getMinutes(),n=i%5;if(n>0){e.setMinutes(i-n+(n>2?5:0))}this.setStartTime(e)}var o=this.getNode("calendar-start-time");o.value=t.formatDate(e,t.message("FORMAT_DATE"));var r=this.getNode("clock-start-time");r.value=a.util.formatTime(e);this.selectDayFromDate(e)};a.prototype.refreshEndTimeView=function(){var e=this.getEndTime();if(!e){e=this.recalculateEndTime(true)}var i=this.getNode("calendar-end-time");i.value=t.formatDate(e,t.message("FORMAT_DATE"));var n=this.getNode("clock-end-time");n.value=a.util.formatTime(e)};a.prototype.refreshDateTimeView=function(){this.refreshStartTimeView();this.refreshEndTimeView();this.recalculateDuration()};a.prototype.getPlannerContainer=function(e){return t("calendar-planner-outer"+this.getPlannerId(),true)};a.prototype.checkPlannerState=function(e){var i=864e5,n={users:[]},a=this.getStartTime(),o=this.getEndTime();if(this.checkPlannerTimeout){this.checkPlannerTimeout=!!clearTimeout(this.checkPlannerTimeout)}if(!a&&!o){this.checkPlannerTimeout=setTimeout(function(){this.checkPlannerState(e)}.bind(this),100);return}if(e.item&&e.item.entityId>0&&e.item.entityType==="users"){n.users.push(e.item.entityId)}if(n.users.length){this.lastUserList=n.users}if(a&&o&&n.users.length){n.from=t.formatDate(new Date(a.getTime()-i*this.loadOffsetLeft),t.message("FORMAT_DATE"));n.to=t.formatDate(new Date(a.getTime()+i*this.loadOffsetRight),t.message("FORMAT_DATE"));this.updatePlanner(n)}};a.prototype.updatePlanner=function(e){var i=this;i.ajaxProgress=true;t.ajax({method:"POST",dataType:"json",url:i.ajaxUrl,data:{sessid:t.bitrix_sessid(),ajax_action:"PLANNER_UPDATE",from:e.from,to:e.to,entries:e.users||this.lastUserList,activity_id:this.getActivityId()||0},onsuccess:function(n){var a=n.DATA||{};var o=true;var r=t.hasClass(i.getPlannerContainer(),"crm-activity-popup-calendar-planner-wrap-shown");if(o){var s={show:o&&!r};if(e.entries){a.entries=e.entries;s.scaleFrom=e.from;s.scaleTo=e.to}s.loadedDataFrom=e.from;s.loadedDataTo=e.to;s.data=a;s.focusSelector=s.show?true:e.focusSelector==undefined?false:e.focusSelector;i.refreshPlannerState(s);if(i.calendarPlanner){i.calendarPlanner.hideLoader()}}i.ajaxProgress=false}})};a.prototype.refreshPlannerState=function(e){e=t.Type.isObject(e)?e:{};var i=this;if(!window.CalendarPlanner){if(this.refreshPlannerStateTimeout){this.refreshPlannerStateTimeout=!!clearTimeout(this.refreshPlannerStateTimeout)}this.refreshPlannerStateTimeout=setTimeout(function(){this.refreshPlannerState(e)}.bind(this),200)}var n=this.getPlannerContainer();var a=t.hasClass(n,"crm-activity-popup-calendar-planner-wrap-shown");if(!a&&e.refreshIfShown||this.skipPlannerRefresh===true){return}if(!a&&e.show){t.addClass(i.getPlannerContainer(),"crm-activity-popup-calendar-planner-wrap-shown")}var o=this.getStartTime();var r=this.getEndTime();if(r.getTime()-o.getTime()>this.PLANNER_DURATION_LIMIT){this.showPlannerWarning()}if(o&&r&&o.getTime&&r.getTime&&o.getTime()<=r.getTime()&&r.getTime()-o.getTime()<=this.PLANNER_DURATION_LIMIT){if(!a&&!e.data){this.checkPlannerState()}else{if(e.data?.dayOfWeekMonthFormat){this.dayOfWeekMonthFormat=e.data.dayOfWeekMonthFormat}if(e.show){this.initPlanner()}if(e.data){this.calendarPlanner.update(e.data.entries,e.data.accessibility)}this.calendarPlanner.updateSelector(o,r,false,{focus:e.focusSelector!==false})}}};a.prototype.initPlanner=function(){var e=this.getPlannerContainer();this.calendarPlanner=new t.Calendar.Planner({wrap:e,compactMode:true,minWidth:600,minHeight:104,height:104,width:e.clientWidth-20,dayOfWeekMonthFormat:this.dayOfWeekMonthFormat});this.calendarPlanner.subscribe("onDateChange",this.handlePlannerSelectorChanges.bind(this));this.calendarPlanner.subscribe("onExpandTimeline",this.handleExpandPlannerTimeline.bind(this));this.calendarPlanner.show();this.calendarPlanner.showLoader()};a.prototype.handlePlannerSelectorChanges=function(t){if(t&&t.getData){var e=t.getData();this.skipPlannerRefresh=true;this.setStartTime(e.dateFrom);if(e.dateTo){this.setEndTime(e.dateTo)}else{this.recalculateEndTime(true)}this.refreshDateTimeView();this.skipPlannerRefresh=false}};a.prototype.handleExpandPlannerTimeline=function(e){if(e&&e.getData){var i=e.getData();this.updatePlanner({from:t.formatDate(i.dateFrom,t.message("FORMAT_DATE")),to:t.formatDate(i.dateTo,t.message("FORMAT_DATE"))})}};a.prototype.showPlannerWarning=function(e){this.warningNode=this.getPlannerContainer().appendChild(t.create("DIV",{props:{className:"crm-activity-planner-warning-wrap"},html:'<div class="ui-alert ui-alert-xs ui-alert-warning"><span class="ui-alert-message">'+t.message("CRM_ACTIVITY_PLANNER_DURATION_ERR")+"</span></div>"}));setTimeout(t.proxy((function(){if(this.warningNode){t.addClass(this.warningNode,"show")}}),this),100);setTimeout(t.proxy((function(){if(this.warningNode){t.removeClass(this.warningNode,"show")}}),this),4e3)};a.prototype.createDiskUploader=function(e,i){var n=this;if(!t.CrmDiskUploader){if(this.diskUploaderTimeout)this.diskUploaderTimeout=!!clearTimeout(this.diskUploaderTimeout);this.diskUploaderTimeout=setTimeout((function(){n.createDiskUploader(e,i)}),100);return}n.diskUploader=t.CrmDiskUploader.create("",{msg:{diskAttachFiles:t.message("CRM_ACTIVITY_PLANNER_DISK_ATTACH_FILE"),diskAttachedFiles:t.message("CRM_ACTIVITY_PLANNER_DISK_ATTACHED_FILES"),diskSelectFile:t.message("CRM_ACTIVITY_PLANNER_DISK_SELECT_FILE"),diskSelectFileLegend:t.message("CRM_ACTIVITY_PLANNER_DISK_SELECT_FILE_LEGEND"),diskUploadFile:t.message("CRM_ACTIVITY_PLANNER_DISK_UPLOAD_FILE"),diskUploadFileLegend:t.message("CRM_ACTIVITY_PLANNER_DISK_UPLOAD_FILE_LEGEND")}});n.diskUploader.setMode(1);n.diskUploader.setValues(e);n.diskUploader.layout(i)};var o={menuId:"crm-act-pltlb",actions:[],actionNode:null,openerNode:null,setActions:function(t){if(t&&t instanceof Array){this.actions=t}},bindActionNode:function(e){this.actionNode=e;t.bind(e,"click",t.delegate(this.onDefaultActionClick,this))},bindOpenerNode:function(e){this.openerNode=e;t.bind(e,"click",t.delegate(this.onOpenerClick,this))},bindNodes:function(t){if(!t)t={};if(t.action)this.bindActionNode(t.action);if(t.opener)this.bindOpenerNode(t.opener)},onDefaultActionClick:function(e){this.executeActionById(this.getDefaultActionId());return t.PreventDefault(e)},onOpenerClick:function(e){var i=this,n,a=[];for(n=0;n<this.actions.length;++n){a.push({text:this.actions[n].text,actionId:this.actions[n].id,onclick:function(e,n){i.executeActionById(n.actionId);if(i.actionNode&&t.type.isString(n.text))i.actionNode.innerHTML=t.util.htmlspecialchars(n.text);return t.PreventDefault(e)}})}t.PopupMenu.show(this.menuId,this.openerNode,a,{autoHide:true,offsetLeft:t.pos(this.openerNode)["width"]/2,angle:{position:"top",offset:0}});return t.PreventDefault(e)},executeActionById:function(e){var i,n;e=e.toString();for(i=0;i<this.actions.length;++i){if(this.actions[i].id===e){n=this.actions[i];break}}if(n){(new t.Crm.Activity.Planner).showEdit(n.params);t.PopupMenu.destroy(this.menuId);this.setDefaultActionId(e)}},getDefaultActionId:function(){var t="";if(this.actionNode){t=this.actionNode.getAttribute("data-action-id").toString()}return t},setDefaultActionId:function(e){e=e.toString();var i=false;if(this.actionNode){var n=this.actionNode.getAttribute("data-action-id");this.actionNode.setAttribute("data-action-id",e);if(n!==e)i=true}if(i){t.userOptions.save("crm.interface.toolbar","activity_planner","default_action_id",e,false)}return this}};t.Crm.Activity.Planner=a;t.Crm.Activity.PlannerToolbar=o;var r=function(e,n,a){var o=this,r;if(!a)a={};this.bindContainer=e;this.ajaxUrl=a.ajaxUrl||i;this.itemTpl=a.itemTpl;this.data=null;this.type=n;this.dialogId="crm-aw-dest-"+n+(""+(new Date).getTime()).substr(6);this.valueInputName=a.valueInputName||"";this.selected=a.selected?t.clone(a.selected):[];this.crmTypes=a.crmTypes;this.selectOne=a.selectOne||false;this.required=a.required||false;this.events=a.events||{};this.bindContainer.appendChild(t.clone(a.containerTpl));r=this.getNode("destination-tag");t.bind(r,"focus",(function(e){o.openDialog({bByFocusEvent:true});return t.PreventDefault(e)}));t.bind(this.bindContainer,"click",(function(e){o.openDialog();return t.PreventDefault(e)}));this.addItems(this.selected);r.innerHTML=this.selected.length<=0?t.message("CRM_ACTIVITY_PLANNER_DEST_1"):t.message("CRM_ACTIVITY_PLANNER_DEST_2")};r.prototype.getNode=function(t,e){if(!e)e=this.bindContainer;return e?e.querySelector('[data-role="'+t+'"]'):null};r.prototype.getData=function(e){var i=this;if(i.ajaxProgress)return;i.ajaxProgress=true;t.ajax({method:"POST",dataType:"json",url:i.ajaxUrl,data:{sessid:t.bitrix_sessid(),ajax_action:"get_destination_data",type:i.type},onsuccess:function(t){i.data=t.DATA||{};i.ajaxProgress=false;i.initDialog(e)}})};r.prototype.initDialog=function(e){var n=this,a=this.data;if(!a){n.getData(e);return}var o={};for(var r=0;r<n.selected.length;++r){o[n.selected[r].id]=n.selected[r].entityType}var s={},l={},d=a.DEST_SORT||{};if(this.type==="responsible"){s={users:a.USERS||{},department:a.DEPARTMENT||{},departmentRelation:a.DEPARTMENT_RELATION||{}};l={users:a.LAST.USERS||{}};if(!s["departmentRelation"]){s["departmentRelation"]=t.SocNetLogDestination.buildDepartmentRelation(s["department"])}}var c=false;var u=null;if(this.type==="deal"){c=true;s={deals:a.DEALS||{}};l={deals:a.LAST.DEALS||{},crm:[]};u=i+"&ajax_action=SEARCH_DESTINATION_DEALS"}if(this.type==="order"){c=true;s={orders:a.ORDERS||{}};l={orders:a.LAST.ORDERS||{},crm:[]};u=i+"&ajax_action=SEARCH_DESTINATION_ORDERS"}if(!n.inited){n.inited=true;var p=n.getNode("destination-input");p.id=n.dialogId+"input";var h=n.getNode("destination-input-box");h.id=n.dialogId+"input-box";var m=this.getNode("destination-tag");m.id=this.dialogId+"tag";var g=n.getNode("destination-items");t.SocNetLogDestination.init({pathToAjax:u,name:n.dialogId,searchInput:n.getNode("destination-input"),extranetUser:false,bindMainPopup:{node:n.bindContainer,offsetTop:"5px",offsetLeft:"15px"},bindSearchPopup:{node:n.bindContainer,offsetTop:"5px",offsetLeft:"15px"},departmentSelectDisable:true,sendAjaxSearch:true,callback:{select:function(e,i,a,o){var r=Object.assign({},e);if(t.type.isString(r.name)){r.name=t.util.htmlspecialcharsback(r.name)}n.addItem(r,i);if(n.selectOne)t.SocNetLogDestination.closeDialog()},unSelect:t.delegate(t.SocNetLogDestination.BXfpUnSelectCallback,{formName:n.dialogId,inputContainerName:g,inputName:p.id,tagInputName:m.id,tagLink1:t.message("CRM_ACTIVITY_PLANNER_DEST_1"),tagLink2:t.message("CRM_ACTIVITY_PLANNER_DEST_2")}),openDialog:t.delegate(t.SocNetLogDestination.BXfpOpenDialogCallback,{inputBoxName:h.id,inputName:p.id,tagInputName:m.id}),closeDialog:t.delegate(t.SocNetLogDestination.BXfpCloseDialogCallback,{inputBoxName:h.id,inputName:p.id,tagInputName:m.id}),openSearch:t.delegate(t.SocNetLogDestination.BXfpOpenDialogCallback,{inputBoxName:h.id,inputName:p.id,tagInputName:m.id}),closeSearch:t.delegate(t.SocNetLogDestination.BXfpCloseSearchCallback,{inputBoxName:h.id,inputName:p.id,tagInputName:m.id})},items:s,itemsLast:l,itemsSelected:o,isCrmFeed:c,useClientDatabase:false,destSort:d,allowAddUser:false});t.bind(p,"keyup",t.delegate(t.SocNetLogDestination.BXfpSearch,{formName:n.dialogId,inputName:p.id,tagInputName:m.id}));t.bind(p,"keydown",t.delegate(t.SocNetLogDestination.BXfpSearchBefore,{formName:n.dialogId,inputName:p.id}));t.SocNetLogDestination.BXfpSetLinkName({formName:n.dialogId,tagInputName:m.id,tagLink1:t.message("CRM_ACTIVITY_PLANNER_DEST_1"),tagLink2:t.message("CRM_ACTIVITY_PLANNER_DEST_2")})}e()};r.prototype.addItem=function(e,i){var n=this;var a=this.getNode("destination-input");var o=this.getNode("destination-tag");var r=this.getNode("destination-items");var s=t.clone(this.itemTpl);if(!t.findChild(r,{attr:{"data-id":e.id}},false,false)){if(n.selectOne&&n.inited){var l=[];for(var d=0;d<r.childNodes.length;++d){l.push({itemId:r.childNodes[d].getAttribute("data-id"),itemType:r.childNodes[d].getAttribute("data-type")})}n.initDialog((function(){for(var e=0;e<l.length;++e){t.SocNetLogDestination.deleteItem(l[e].itemId,l[e].itemType,n.dialogId)}}));t.cleanNode(r)}s.setAttribute("data-id",e.id);s.setAttribute("data-type",i);t.addClass(s,s.getAttribute("data-class-prefix")+(n.type=="responsible"?"users":"crm"));var c=this.getNode("text",s);var u=this.getNode("delete",s);var p=this.getNode("value",s);c.innerHTML=t.type.isString(e.name)?t.util.htmlspecialchars(e.name):"";t.bind(u,"click",(function(a){if(n.selectOne&&n.required){n.openDialog()}else{n.initDialog((function(){t.SocNetLogDestination.deleteItem(e.id,i,n.dialogId);t.remove(s)}))}t.PreventDefault(a)}));t.bind(u,"mouseover",(function(){t.addClass(this.parentNode,this.getAttribute("data-hover-class"))}));t.bind(u,"mouseout",(function(){t.removeClass(this.parentNode,this.getAttribute("data-hover-class"))}));p.name=n.valueInputName;p.value=e.entityId;r.appendChild(s);if(!e.entityType)e.entityType=i;this.fireEvent("select",{item:e})}a.value="";o.innerHTML=t.message("CRM_ACTIVITY_PLANNER_DEST_2")};r.prototype.addItems=function(t){for(var e=0;e<t.length;++e){this.addItem(t[e],t[e].entityType)}};r.prototype.openDialog=function(e){var i=this;this.initDialog((function(){t.SocNetLogDestination.openDialog(i.dialogId,e)}))};r.prototype.fireEvent=function(t,e){if(typeof this.events[t]==="function"){this.events[t].call(this,e)}};r.prototype.onPlannerClose=function(){if(this.inited){if(t.SocNetLogDestination.isOpenDialog()){t.SocNetLogDestination.closeDialog()}t.SocNetLogDestination.closeSearch()}};var s=function(e,i){this.id="crm-actpl-comm-"+(""+(new Date).getTime()).substr(6);this.items=[];var a=this;if(!i)i={};this.bindContainer=e;this.ajaxUrl=i.ajaxUrl||n;this.itemTpl=i.itemTpl;this.selectOne=i.selectOne||false;this.bindContainer.appendChild(t.clone(i.containerTpl));var o=this.getNode("destination-tag");t.bind(o,"focus",(function(e){a.openDialog();return t.PreventDefault(e)}));t.bind(this.bindContainer,"click",(function(e){a.openDialog();return t.PreventDefault(e)}));var r=t.CrmCommunicationType.undefined;if(i.communicationType==="PHONE")r=t.CrmCommunicationType.phone;if(i.communicationType==="EMAIL")r=t.CrmCommunicationType.email;if(typeof t.CrmCommunicationSearch.messages==="undefined"){t.CrmCommunicationSearch.messages={SearchTab:t.message("CRM_ACTIVITY_PLANNER_COMMUNICATION_SEARCH_TAB"),NoData:t.message("CRM_ACTIVITY_PLANNER_COMMUNICATION_SEARCH_NO_DATA")}}this._communicationSearch=t.CrmCommunicationSearch.create(this.id,{entityType:i.entityType,entityId:i.entityId,serviceUrl:a.ajaxUrl,communicationType:r,selectCallback:t.delegate(this.selectCommunication,this),enableSearch:true,enableDataLoading:true,dialogAutoHide:true});if(r===t.CrmCommunicationType.phone){var s=this.getNode("destination-input");t.bind(s,"keypress",t.delegate(this.inputKeypress,this))}this.addItems(i.selected?t.clone(i.selected):[])};s.prototype.inputKeypress=function(e){if(!e)e=window.event;if(e.keyCode!==13)return;var i=this.getNode("destination-input");if(t.type.isNotEmptyString(i.value)){var n=/^\s*\+?[\d-\s\(\)]+\s*$/;if(n.test(i.value)){this.addItem({entityId:"0",entityTitle:"",entityType:"CONTACT",type:"PHONE",value:i.value},true)}}};s.prototype.getNode=function(t,e){if(!e)e=this.bindContainer;return e?e.querySelector('[data-role="'+t+'"]'):null};s.prototype.selectCommunication=function(t){this.addItem(t.getSettings(),true)};s.prototype.addItem=function(e,i){if(e.type===null)e.type="";if(e.type===""&&e.value===null)e.value="";e.entityId=parseInt(e.entityId);for(var n=0;n<this.items.length;++n){if(this.items[n].type===e.type&&this.items[n].value===e.value&&this.items[n].entityId===e.entityId&&this.items[n].entityType===e.entityType)return}var a=this,o=this.getNode("destination-items");if(this.selectOne){this.items=[];t.cleanNode(o)}this.items.push(e);var r=t.clone(this.itemTpl);t.addClass(r,r.getAttribute("data-class-prefix")+"crm");var s=this.getNode("text",r);var l=this.getNode("delete",r);s.innerHTML=[t.type.isString(e.entityTitle)?t.util.htmlspecialchars(e.entityTitle):"",t.type.isString(e.value)?t.util.htmlspecialchars(e.value):""].join(" ");t.bind(l,"click",(function(i){a.deleteItem(e);t.remove(r);t.PreventDefault(i)}));t.bind(l,"mouseover",(function(){t.addClass(this.parentNode,this.getAttribute("data-hover-class"))}));t.bind(l,"mouseout",(function(){t.removeClass(this.parentNode,this.getAttribute("data-hover-class"))}));o.appendChild(r);var d=this.getNode("destination-tag");d.innerHTML=t.message("CRM_ACTIVITY_PLANNER_DEST_2");if(i)this._communicationSearch.closeDialog()};s.prototype.addItems=function(e){for(var i=0;i<e.length;++i){this.addItem(e[i],e[i].entityType)}var n=this.getNode("destination-tag");n.innerHTML=e.length<=0?t.message("CRM_ACTIVITY_PLANNER_DEST_1"):t.message("CRM_ACTIVITY_PLANNER_DEST_2")};s.prototype.deleteItem=function(t){for(var e=0;e<this.items.length;++e){if(this.items[e]===t)this.items.splice(e,1)}return this};s.prototype.openDialog=function(){var e=this.getNode("destination-input-box");var i=this.getNode("destination-input");var n=this.getNode("destination-tag");t.style(e,"display","inline-block");t.style(n,"display","none");if(!this._communicationSearchController){this._communicationSearchController=t.CrmCommunicationSearchController.create(this._communicationSearch,i);this._communicationSearchController.start()}this._communicationSearch.openDialog(this.bindContainer,t.delegate(this.closeDialog,this),{zIndex:999});t.defer(t.focus)(i)};s.prototype.closeDialog=function(){var e=this.getNode("destination-input-box");var i=this.getNode("destination-input");var n=this.getNode("destination-tag");if(this._communicationSearchController){this._communicationSearchController.stop();this._communicationSearchController=null}t.style(n,"display","inline-block");t.style(e,"display","none");i.value=""};s.prototype.onPlannerClose=function(){this._communicationSearch.closeDialog()};if(typeof t.CrmActivityProvider=="undefined"){t.addCustomEvent("Bitrix24.Slider:onMessage",(function(e,i){if(!t.CrmActivityEditor||!i){return}var n=null;if(i.action&&(n=i.action.match(/^ACTIVITY_(CREATE|DELETE)$/)))t.CrmActivityEditor.notifyActivityChange(null,n[1],{})}));t.CrmActivityProvider=function(){this._settings={};this._options={};this._ttlWrapper=null;this._dlg=null;this._dlgMode=t.CrmDialogMode.view;this._dlgCfg={};this._onSaveHandlers=[];this._onDlgCloseHandlers=[];this._editor=null;this._isChanged=false;this._buttonId=t.CrmActivityDialogButton.undefined;this._owner=null;this._salt="";this._callCreationHandler=t.delegate(this._handleCallCreation,this);this._meetingCreationHandler=t.delegate(this._handleMeetingCreation,this);this._emailCreationHandler=t.delegate(this._handleEmailCreation,this);this._taskCreationHandler=t.delegate(this._handleTaskCreation,this);this._titleMenu=null;this._contentNode=null;this._activityOptions={};this._parentActivity=null};t.CrmActivityProvider.prototype={initialize:function(t,e,i,n){this._settings=t?t:{};this._editor=e;this._options=i?i:{};this._isChanged=this.getOption("markChanged",false);var a=this.getSetting("ownerType","");var o=this.getSetting("ownerID","");this._salt=Math.random().toString().substring(2);this._parentActivity=n},getMode:function(){return this._dlgMode},getSetting:function(t,e){return typeof this._settings[t]!="undefined"?this._settings[t]:e},setSetting:function(t,e){this._settings[t]=e},getOption:function(t,e){return typeof this._options[t]!="undefined"?this._options[t]:e},getMessage:function(e){return t.CrmActivityProvider.messages&&t.CrmActivityProvider.messages[e]?t.CrmActivityProvider.messages[e]:""},getType:function(){return this.getSetting("typeID",t.CrmActivityType.provider)},getId:function(){return parseInt(this.getSetting("ID","0"))},getMessageType:function(){return this.getSetting("messageType","")},getOwnerType:function(){return this.getSetting("ownerType","")},getOwnerId:function(){return this.getSetting("ownerID","")},getOriginalMessageId:function(){return this.getSetting("originalMessageID",0)},openDialog:function(e){var i=this;var n=i.getId();var o="CrmActivityProviderView"+n;i._dlgMode=e;var r={sessid:t.bitrix_sessid()};if(e==t.CrmDialogMode.edit){if(top.BX.SidePanel&&i.getType()==t.CrmActivityType.email){try{r.context=t.Crm.Page.context}catch(t){}r.ajax_action="ACTIVITY_EDIT";r.activity_id=n;r.TYPE_ID=i.getType();r.OWNER_ID=i.getOwnerId();r.OWNER_TYPE=i.getOwnerType();r.OWNER_PSID=this.getSetting("ownerPSID",0);r.FROM_ACTIVITY_ID=i.getOriginalMessageId();r.MESSAGE_TYPE=i.getMessageType();var s={COMMUNICATIONS:{}};var l=this.getSetting("communications",[]);for(var d=0;d<l.length;d++){if(l[d].entityType&&l[d].entityId){s.COMMUNICATIONS[d]={OWNER_TYPE:l[d].entityType,OWNER_ID:l[d].entityId};if(l[d].type&&l[d].value){s.COMMUNICATIONS[d].TYPE=l[d].type;s.COMMUNICATIONS[d].VALUE=l[d].value}}}r.__post_data_hash=t.util.hashCode(t.ajax.prepareData(s));var c={allowChangeHistory:false,requestMethod:"post",requestParams:s};if(i.getType()==t.CrmActivityType.email){c.typeLoader="create-mail-loader";c.width=1080}var u=this.getSetting("defaultStorageTypeId");if(u===a.util.storageType.Disk){var p=this.getSetting("diskfiles");if(t.type.isArray(p)){r["STORAGE_TYPE_ID"]=u;r["STORAGE_ELEMENT_IDS"]=p}}top.BX.SidePanel.Instance.open("/bitrix/components/bitrix/crm.activity.planner/slider.php?site_id="+t.message("SITE_ID")+"&"+t.ajax.prepareData(r),c);return}else{(new t.Crm.Activity.Planner).showEdit({ID:n})}return true}r.ajax_action="ACTIVITY_VIEW";r.activity_id=n;if(top.BX.SidePanel){var c={compatibleEvents:true,allowChangeHistory:false,events:{onOpen:function(t){var e=t.iframe.contentDocument.body;i._contentNode=e;var n=i._getNode("options");if(n){i._activityOptions=JSON.parse(n.getAttribute("data-options"));if(!i._activityOptions||typeof i._activityOptions!=="object")i._activityOptions={}}i._prepareSliderContent(t)}}};if(i.getType()==t.CrmActivityType.email){c.typeLoader="view-mail-loader";c.width=1080}top.BX.SidePanel.Instance.open("/bitrix/components/bitrix/crm.activity.planner/slider.php?site_id="+t.message("SITE_ID")+"&"+t.ajax.prepareData(r),c);return}if(t.CrmActivityProvider.dialogs[o])return;t.ajax({method:"POST",dataType:"html",url:"/bitrix/components/bitrix/crm.activity.planner/ajax.php?site_id="+t.message("SITE_ID"),data:r,onsuccess:function(e){if(t.CrmActivityProvider.dialogs[o])return;var n=t.create("div");n.innerHTML=e;i._contentNode=n;var a=i._getNode("options");if(a){i._activityOptions=JSON.parse(a.getAttribute("data-options"));if(!i._activityOptions||typeof i._activityOptions!=="object")i._activityOptions={}}i._dlg=new t.PopupWindow(o,null,{autoHide:false,draggable:true,offsetLeft:0,offsetTop:0,bindOptions:{forceBindPosition:false},closeByEsc:true,closeIcon:true,zIndex:-12,contentNoPaddings:true,titleBar:{content:i._prepareViewDlgTitle()},events:{onPopupClose:t.delegate((function(){t.CrmActivityEditor.hideUploader(i.getSetting("uploadID",""),i.getSetting("uploadControlID",""));t.CrmActivityEditor.hideLhe(i.getSetting("lheContainerID",""));i._dlg.destroy();t.onCustomEvent(window,"onActivityEditorClose",[])}),i),onPopupDestroy:t.proxy((function(){i._dlg=null;i._wrapper=null;i._ttlWrapper=null;delete t.CrmActivityProvider.dialogs[o]}),i)},content:n,buttons:i._prepareViewDlgButtons()});i._prepareDialogContent();t.CrmActivityProvider.dialogs[o]=i._dlg;i._dlg.show()}})},_getNode:function(t){return this._contentNode?this._contentNode.querySelector('[data-role="'+t+'"]'):null},_prepareFieldCompleted:function(){var e=this;var i=this._getNode("field-completed");if(i){var n=this.getOption("enableInstantEdit",true);if(n){t.bind(i,"click",(function(){i.disabled=true;e._editor.setActivityCompleted(e.getId(),i.checked,(function(t){e._settings["completed"]=!!t["COMPLETED"];i.checked=!!t["COMPLETED"];i.disabled=false}))}))}else{i.disabled=true}}},_prepareCommunicationsSlider:function(){var e=this,i=this._getNode("com-slider-left");if(i){t.bind(i,"click",(function(){e._changeCommunicationSlide(-1)}))}var n=this._getNode("com-slider-right");if(n){t.bind(n,"click",(function(){e._changeCommunicationSlide(1)}))}},_prepareDialogContent:function(){var e=this._getNode("additional-switcher");var i=this._getNode("additional-fields");if(e&&i){t.bind(e,"click",(function(){t.toggleClass(i,"active")}))}this._prepareCommunicationsSlider();this._prepareFieldCompleted()},_prepareSliderContent:function(e){var i=this;var n=this._getNode("additional-switcher");var a=this._getNode("additional-fields");if(n&&a){t.bind(n,"click",(function(){if(a.offsetHeight>0&&!t.hasClass(a,"crm-activity-email-close-animation")){a.style.maxHeight=a.offsetHeight*1.5+"px";a.style.transition="max-height .12s ease-in";setTimeout((function(){a.style.display="none"}),120);a.offsetHeight;a.style.maxHeight="0px";t.removeClass(a,"crm-activity-email-show-animation");t.addClass(a,"crm-activity-email-close-animation")}else{t.removeClass(a,"crm-activity-email-close-animation");t.addClass(a,"crm-activity-email-show-animation");a.style.display="";a.style.transition="";a.style.maxHeight=""}}))}this._prepareCommunicationsSlider();this._prepareFieldCompleted();var o=this._getNode("field-important");if(o){var r=this.getOption("enableInstantEdit",true);if(r){var s=function(e){if(e<t.CrmActivityPriority.high){t.addClass(o,"crm-activity-planner-slider-header-icon-flame");t.removeClass(o,"crm-activity-planner-slider-header-icon-flame-active")}else{t.addClass(o,"crm-activity-planner-slider-header-icon-flame-active");t.removeClass(o,"crm-activity-planner-slider-header-icon-flame")}};t.bind(o,"click",(function(){var e=t.hasClass(o,"crm-activity-planner-slider-header-icon-flame-active")?t.CrmActivityPriority.medium:t.CrmActivityPriority.high;s(e);i._editor.setActivityPriority(i.getId(),e,(function(t){i._settings["priority"]=t["PRIORITY"];s(t["PRIORITY"])}))}))}else{o.style.cursor="default"}}var l=this._getNode("button-edit");if(l){t.bind(l,"click",(function(){e.close(true,(function(){(new t.Crm.Activity.Planner).showEdit({ID:i.getId()})}))}))}var d=this._getNode("button-close");if(d){t.bind(d,"click",(function(){e.close()}))}},_changeCommunicationSlide:function(t){var e=this._getNode("com-slider-nav");var i=this._getNode("com-slider-slides");if(!e||!i)return false;var n=parseInt(e.getAttribute("data-current"));var a=parseInt(e.getAttribute("data-cnt"));if(isNaN(a)||a<1)return false;if(isNaN(n)||n<1)n=1;n+=t<0?-1:1;if(n>a)n=a;if(n<1)n=1;e.setAttribute("data-current",n.toString());e.innerHTML=n.toString()+" / "+a.toString();i.style.marginLeft=((n-1)*-269).toString()+"px"},closeDialog:function(){if(this._titleMenu){this._titleMenu.removeCreateTaskListener(this._taskCreationHandler);this._titleMenu.removeCreateCallListener(this._callCreationHandler);this._titleMenu.removeCreateMeetingListener(this._meetingCreationHandler);this._titleMenu.cleanLayout()}if(!this._dlg){return}this._notifyDialogClose();this._dlg.close()},addOnSave:function(e){if(!t.type.isFunction(e)){return}for(var i=0;i<this._onSaveHandlers.length;i++){if(this._onSaveHandlers[i]==e){return}}this._onSaveHandlers.push(e)},removeOnSave:function(e){if(!t.type.isFunction(e)){return}for(var i=0;i<this._onSaveHandlers.length;i++){if(this._onSaveHandlers[i]==e){this._onSaveHandlers.splice(i,1);return}}},addOnDialogClose:function(e){if(!t.type.isFunction(e)){return}for(var i=0;i<this._onDlgCloseHandlers.length;i++){if(this._onDlgCloseHandlers[i]==e){return}}this._onDlgCloseHandlers.push(e)},removeOnDialogClose:function(e){if(!t.type.isFunction(e)){return}for(var i=0;i<this._onDlgCloseHandlers.length;i++){if(this._onDlgCloseHandlers[i]==e){this._onDlgCloseHandlers.splice(i,1);return}}},isChanged:function(){return this._isChanged},getButtonId:function(){return this._buttonId},_prepareViewDlgTitle:function(){var e=this._activityOptions.title||this.getSetting("subject","");this._titleMenu=t.CrmActivityMenu.create("",{enableTasks:this._editor.isTasksEnabled(),enableCalendarEvents:this._editor.isCalendarEventsEnabled(),enableEmails:this._editor.isEmailsEnabled()&&this.getType()!==t.CrmActivityType.email},{createTask:this._taskCreationHandler,createCall:this._callCreationHandler,createMeeting:this._meetingCreationHandler,createEmail:this._emailCreationHandler});var i=t.create("DIV",{attrs:{className:"crm-task-list-head"},children:[t.create("SPAN",{attrs:{className:"crm-task-list-head-item-left"},children:[t.create("SPAN",{text:e,props:{className:"crm-task-list-head-item-left-element"}})]})]});this._titleMenu.layout(i);if(this._activityOptions.important){i.appendChild(t.create("SPAN",{attrs:{className:"crm-task-list-head-item-right-wrap"},children:[t.create("SPAN",{attrs:{className:"crm-task-list-head-item-right"},text:t.message("CRM_ACTIVITY_PLANNER_IMPORTANT")}),t.create("SPAN",{attrs:{className:"crm-task-list-head-item-right-icon"}})]}))}return i},_notifyDialogClose:function(){for(var t=0;t<this._onDlgCloseHandlers.length;t++){try{this._onDlgCloseHandlers[t](this)}catch(t){}}},_prepareViewDlgButtons:function(){var e=[],i=this;if(this.getType()===t.CrmActivityType.email&&this._parentActivity){var n=parseInt(this.getSetting("direction",t.CrmActivityDirection.outgoing));if(n===t.CrmActivityDirection.incoming){e.push({type:"button",settings:{text:t.CrmActivityEditor.getMessage("replyDlgButton"),className:"popup-window-button-accept",events:{click:function(){i.closeDialog();i._parentActivity._handleReplyBtnClick()}}}})}e.push({type:"button",settings:{text:t.CrmActivityEditor.getMessage("forwardDlgButton"),className:"popup-window-button-accept",events:{click:function(){i.closeDialog();i._parentActivity._handleForwardBtnClick()}}}});e.push({type:"link",settings:{text:t.CrmActivityEditor.getMessage("closeDlgButton"),className:"popup-window-button-link-cancel",events:{click:t.delegate(this._handleCloseBtnClick,this)}}})}else{e.push({type:"button",settings:{text:t.CrmActivityEditor.getMessage("closeDlgButton"),className:"popup-window-button-accept",events:{click:t.delegate(this._handleCloseBtnClick,this)}}});if(this.getOption("enableEditButton",true)&&(this.getType()===t.CrmActivityType.call||this.getType()===t.CrmActivityType.meeting||this._activityOptions.isEditable===true)){e.push({type:"link",settings:{text:t.CrmActivityEditor.getMessage("editDlgButton"),className:"popup-window-button-link-cancel",events:{click:function(){(new t.Crm.Activity.Planner).showEdit({ID:i.getId()});i.closeDialog()}}}})}}return t.CrmActivityEditor.prepareDialogButtons(e)},_handleCallCreation:function(e){var i=this.getSetting("ownerType","");var n=parseInt(this.getSetting("ownerID",0));if(typeof t.Crm.Activity.Planner!=="undefined"){(new t.Crm.Activity.Planner).showEdit({TYPE_ID:t.CrmActivityType.call,OWNER_TYPE:i,OWNER_ID:n,FROM_ACTIVITY_ID:this.getId()})}},_handleMeetingCreation:function(e){var i=this.getSetting("ownerType","");var n=parseInt(this.getSetting("ownerID",0));if(typeof t.Crm.Activity.Planner!=="undefined"){(new t.Crm.Activity.Planner).showEdit({TYPE_ID:t.CrmActivityType.meeting,OWNER_TYPE:i,OWNER_ID:n,FROM_ACTIVITY_ID:this.getId()})}},_handleEmailCreation:function(e){var i={};var n=this.getSetting("ownerType","");var a=parseInt(this.getSetting("ownerID",0));if(n!==""&&a>0){i["ownerType"]=n;i["ownerID"]=a;i["ownerTitle"]=this.getSetting("ownerTitle","");i["ownerUrl"]=this.getSetting("ownerUrl","")}if(this.getSetting("ownerType","")==="DEAL"){var o=this.getSetting("communications",[]);var r=t.type.isArray(o)&&o.length>0?o[0]:null;if(r){var s=r["entityType"];if(!t.type.isNotEmptyString(s)){s=n}var l=parseInt(r["entityId"]);if(isNaN(l)||l<=0){l=a}var d=t.CrmActivityEditor.getDefaultCommunication(s,l,t.CrmCommunicationType.email,this.getSetting("serviceUrl",""));if(d){i["communications"]=[d.getSettings()]}}}this._editor.addEmail(i)},_handleTaskCreation:function(t){var e={};var i=this.getSetting("ownerType","");var n=parseInt(this.getSetting("ownerID",0));if(i!==""&&n>0){e["ownerType"]=i;e["ownerID"]=n}this._editor.addTask(e)},_handleCloseBtnClick:function(e){this._buttonId=t.CrmActivityDialogButton.cancel;this.closeDialog()}};t.CrmActivityProvider.dialogs={};t.CrmActivityProvider.sliders={};t.CrmActivityProvider.create=function(e,i,n,a){var o=new t.CrmActivityProvider;o.initialize(e,i,n,a);return o}}if(typeof t.CrmCustomActivityType=="undefined"){t.CrmCustomActivityType=function(){};t.CrmCustomActivityType.getListItems=function(e){if(!t.type.isArray(e)){e=t.CrmCustomActivityType.infos}var i=[];for(var n=0,a=e.length;n<a;n++){var o=e[n];i.push({value:o["id"],text:o["name"]})}return i};t.CrmCustomActivityType.prepareEditorParams=function(t,e){var i=this.getInfo(t);if(i!==null){e["PROVIDER_ID"]="CUST";e["PROVIDER_TYPE_ID"]=i["id"];e["NAME"]=i["name"];e["TYPE_ID"]=6}};t.CrmCustomActivityType.getInfo=function(e){for(var i=0,n=t.CrmCustomActivityType.infos.length;i<n;i++){var a=t.CrmCustomActivityType.infos[i];if(a["id"]==e){return a}}return null};if(typeof t.CrmCustomActivityType.infos==="undefined"){t.CrmCustomActivityType.infos=[]}}if(typeof t.CrmCustomActivityTypeSelector=="undefined"){t.CrmCustomActivityTypeSelector=function(){this._id="";this._settings={};this._ownerTypeId=0;this._ownerId=0;this._selectorMenu=null;this._menuItemSelectHandler=t.delegate(this.onMenuItemSelect,this)};t.CrmCustomActivityTypeSelector.prototype={initialize:function(t,e){this._id=t;this._settings=e?e:{};this._ownerTypeId=this.getSetting("ownerTypeId",0);this._ownerId=this.getSetting("ownerId",0)},getId:function(){return this._id},getSetting:function(t,e){return this._settings.hasOwnProperty(t)?this._settings[t]:e},getMessage:function(e){var i=t.CrmCustomActivityTypeSelector.messages;return i.hasOwnProperty(e)?i[e]:e},openCreationDialog:function(e){var i={OWNER_TYPE_ID:this._ownerTypeId,OWNER_ID:this._ownerId};t.CrmCustomActivityType.prepareEditorParams(e,i);var n=new t.Crm.Activity.Planner;n.showEdit(i)},openMenu:function(e){if(!this._selectorMenu){var i=t.CrmCustomActivityType.getListItems();this._selectorMenu=t.CmrSelectorMenu.create(this._id,{items:i});this._selectorMenu.addOnSelectListener(this._menuItemSelectHandler)}if(!this._selectorMenu.isOpened()){this._selectorMenu.open(e)}},onMenuItemSelect:function(t,e){var i=e.getValue();if(this._selectorMenu.isOpened()){this._selectorMenu.close()}this.openCreationDialog(parseInt(i))}};if(typeof t.CrmCustomActivityTypeSelector.messages==="undefined"){t.CrmCustomActivityTypeSelector.messages={}}t.CrmCustomActivityTypeSelector.items={};t.CrmCustomActivityTypeSelector.create=function(e,i){var n=new t.CrmCustomActivityTypeSelector;n.initialize(e,i);this.items[n.getId()]=n;return n}}if(typeof t.CrmCallListHelper=="undefined"){t.CrmCallListHelper=function(){};t.CrmCallListHelper.createCallList=function(e,n){t.ajax({url:i,method:"POST",dataType:"json",data:{ajax_action:"CREATE_CALL_LIST",sessid:t.bitrix_sessid(),ENTITY_TYPE:e.entityType,ENTITY_IDS:e.entityIds,GRID_ID:e.gridId,CREATE_ACTIVITY:e.createActivity?"Y":"N"},onsuccess:function(t){if(t&&n){n(t)}},onfailure:function(t){}})};t.CrmCallListHelper.addToCallList=function(e){var n=e.context||"";var a=e.callListId||0;var o=e.entityIds?e.entityIds:[e.id];if(n==""||a==0)return;t.ajax({url:i,method:"POST",dataType:"json",data:{ajax_action:"ADD_TO_CALL_LIST",sessid:t.bitrix_sessid(),CALL_LIST_ID:a,ENTITY_TYPE:e.entityType,ENTITY_IDS:o,GRID_ID:e.gridId},onsuccess:function(e){if(e&&!e.SUCCESS&&e.ERRORS){var i=e.ERRORS.join(". \n");window.alert(i)}else if(e&&e.SUCCESS&&e.DATA){var a=e.DATA.ID;if(e.DATA&&e.DATA.MESSAGE){window.alert(e.DATA.MESSAGE)}t.localStorage.set("onCrmCallListUpdate",{callListId:a,context:n},10)}}})}}})(window.BX||window.top.BX); //# sourceMappingURL=activity_planner.map.js
/var/www/axolotl/data/www/axolotl.ru/www/bitrix/js/crm/activity_planner.min.js