Your IP : 52.14.78.246


Current Path : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/mobile/
Upload File :
Current File : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/mobile/mobile_crm.min.js

BX.namespace("BX.Mobile.Crm");BX.Mobile.Crm={loadPageBlank:function(t){if(!t)return;BXMobileApp.PageManager.loadPageBlank({url:t,bx24ModernStyle:true})},loadPageModal:function(t){if(!t)return;BXMobileApp.PageManager.loadPageModal({url:t})},showErrorAlert:function(t){if(!t)return;app.alert({title:BX.message("CRM_JS_ERROR"),text:t})},showRecursiveActionSheet:function(t){if(typeof t!=="object")return;var e=[];var i=0;for(var n in t){if(t.hasOwnProperty(n)){if(i>=5){e.push({title:BX.message("CRM_JS_MORE"),callback:BX.proxy(function(){var t=this.buttons.slice(5);BX.Mobile.Crm.showRecursiveActionSheet(t)},{buttons:t})});break}else{e.push(t[n])}i++}}new BXMobileApp.UI.ActionSheet({buttons:e},"actionSheetStatus").show()},deleteItem:function(t,e,i,n){if(!t)return;if(i!="list"&&i!="detail")return;app.confirm({title:BX.message("CRM_JS_DELETE_CONFIRM_TITLE"),text:BX.message("CRM_JS_DELETE_CONFIRM"),callback:BX.proxy(function(o){if(o==2)return false;else if(o==1){BXMobileApp.UI.Page.LoadingScreen.show();BX.ajax({url:e,method:"POST",dataType:"json",data:{itemId:t,sessid:BX.bitrix_sessid(),action:"delete"},onsuccess:function(e){BXMobileApp.UI.Page.LoadingScreen.hide();if(!BX.type.isPlainObject(e)){BX.Mobile.Crm.showErrorAlert(BX.message("CRM_JS_ERROR_DELETE"));return}if(e.ERROR){BX.Mobile.Crm.showErrorAlert(e.ERROR)}else{if(n){BXMobileApp.onCustomEvent(n,{},true)}if(i=="list"){BX.Mobile.Crm.List.onDeleteItemHandler(t)}else if(i=="detail"){BX.Mobile.Crm.Detail.onDeleteItemHandler(t)}}},onfailure:function(){BX.Mobile.Crm.showErrorAlert(BX.message("CRM_JS_ERROR_DELETE"));BXMobileApp.UI.Page.LoadingScreen.hide()}})}},this),buttons:[BX.message("CRM_JS_BUTTON_OK"),BX.message("CRM_JS_BUTTON_CANCEL")]})}};BX.namespace("BX.Mobile.Crm.List");BX.Mobile.Crm.List={init:function(t){this.ajaxPath="";this.sortPath="";this.fieldsPath="";this.filterPath="";this.filterAjaxPath="";this.contextMenuTitle="";if(typeof t==="object"&&t){this.ajaxPath=t.ajaxPath;this.sortPath=t.sortPath;this.fieldsPath=t.fieldsPath;this.filterPath=t.filterPath;this.filterAjaxPath=t.filterAjaxPath;this.contextMenuTitle=t.contextMenuTitle}},showContextMenu:function(t){var e=[];if(typeof t=="object"){for(var i=0,n=t.length;i<n;i++){e.push(t[i])}}e.push({name:BX.message("CRM_JS_GRID_FILTER"),image:"/bitrix/js/mobile/images/settings.png",action:BX.proxy(function(){BX.Mobile.Crm.loadPageModal(this.filterPath)},this)});e.push({name:BX.message("CRM_JS_GRID_FIELDS"),image:"/bitrix/js/mobile/images/fields.png",action:BX.proxy(function(){BX.Mobile.Crm.loadPageModal(this.fieldsPath)},this)});e.push({name:BX.message("CRM_JS_GRID_SORT"),image:"/bitrix/js/mobile/images/sort.png",action:BX.proxy(function(){BX.Mobile.Crm.loadPageModal(this.sortPath)},this)});var o=new BXMobileApp.UI.Menu({items:e},"crmMobileMenu");BXMobileApp.UI.Page.TopBar.title.setText(this.contextMenuTitle);BXMobileApp.UI.Page.TopBar.title.show();BXMobileApp.UI.Page.TopBar.title.setCallback(function(){o.show()})},showStatusList:function(t,e,i){if(typeof e!=="object")return;var n=[];for(var o in e){if(e.hasOwnProperty(o)){n.push({title:e[o].NAME,callback:BX.proxy(function(){params={STATUS_ID:this.status.STATUS_ID,NAME:this.status.NAME,COLOR:this.status.COLOR};BX.Mobile.Crm.List.changeStatus(t,params);if(i){BXMobileApp.addCustomEvent(i,{})}},{status:e[o]})})}}BX.Mobile.Crm.showRecursiveActionSheet(n)},applyListFilter:function(t,e){BXMobileApp.UI.Page.LoadingScreen.show();BX.ajax.post(this.filterAjaxPath,{sessid:BX.bitrix_sessid(),filterCode:t,action:"applyFilter",gridId:e},function(){BXMobileApp.UI.Page.reload();BXMobileApp.UI.Page.LoadingScreen.hide()})},changeStatus:function(t,e){if(isNaN(t)||!(typeof e==="object"))return;BXMobileApp.UI.Page.PopupLoader.show();BX.ajax({url:this.ajaxPath,method:"POST",dataType:"json",data:{itemId:t,sessid:BX.bitrix_sessid(),action:"changeStatus",statusId:e.STATUS_ID},onsuccess:function(i){BXMobileApp.UI.Page.PopupLoader.hide();if(!BX.type.isPlainObject(i))return;if(i.ERROR){BX.Mobile.Crm.showErrorAlert(i.ERROR)}else{var n=document.querySelector("[data-role='mobile-crm-status-entity-"+t+"']");if(n){var o=document.querySelector("[data-role='mobile-crm-status-name-"+t+"']");var s=BX.findChildren(n,{tagName:"span"},true);var a=false;if(s){for(var r=0;r<s.length;r++){if(a)s[r].style.background="";else s[r].style.background=e.COLOR;if(s[r].getAttribute("data-role")=="mobile-crm-status-block-"+e.STATUS_ID)a=true}}if(o){o.innerHTML=BX.util.htmlspecialchars(e.NAME)}}else{var l=document.querySelector("[data-id='mobile-grid-item-"+t+"']");if(l){var c=BX.findChild(l,{className:"mobile-grid-field-title-icon"},true,false);if(c){c.style.background=e.COLOR}}}}},onfailure:function(){BXMobileApp.UI.Page.LoadingScreen.hide()}})},onDeleteItemHandler:function(t){if(!t)return;var e=document.querySelector("[data-id='mobile-grid-item-"+t+"']");if(e){if(BX.hasClass(BX.previousSibling(e),"mobile-grid-change")&&(BX.hasClass(BX.nextSibling(e),"mobile-grid-change")||!BX.nextSibling(e)))BX.remove(BX.previousSibling(e));BX.remove(e)}}};BX.namespace("BX.Mobile.Crm.Detail");BX.Mobile.Crm.Detail={onDeleteItemHandler:function(){BXMobileApp.UI.Page.close({drop:true})},collectInterfaceFormData:function(t,e){for(var i=0;i<t.elements.length;i++){if(t[i].tagName==="SELECT"){e[t[i].name]="";var n=t[i].options;for(var o=0;o<n.length;o++){if(n[o].selected&&n[o].value){var s=t[i].name.replace("[]","["+o+"]");e[s]=n[o].value}}}else if(t[i].tagName=="INPUT"&&t[i].type=="checkbox"){if(t[i].checked)e[t[i].name]=t[i].value;else e[t[i].name]=""}else{e[t[i].name]=t[i].value}}return e}};BX.namespace("BX.Mobile.Crm.EntityEditor");BX.Mobile.Crm.EntityEditor=function(){var t=function(t){this.isRestrictedMode=false;this.isMultiEntity=false;this.entityInfo={};this.entityContainerNode="";this.curEntityId=[];this.onSelectEventName="";this.onDeleteEventName="";this.init(t)};t.prototype.init=function(t){if(typeof t==="object"){this.entityContainerNode=t.entityContainerNode||"";this.entityInfo=t.entityInfo||"";this.isRestrictedMode=t.isRestrictedMode||false;this.isMultiEntity=t.isMultiEntity||false;this.onSelectEventName=t.onSelectEventName||"";this.onDeleteEventName=t.onDeleteEventName||""}if(this.isMultiEntity){if(typeof this.entityInfo==="object"){for(var e=0;e<this.entityInfo.length;e++){this.curEntityId.push(this.entityInfo[e].id);this.generateEntityHtml(this.entityInfo[e])}}}else{if(typeof this.entityInfo==="object"){this.curEntityId=this.entityInfo.id;this.generateEntityHtml(this.entityInfo)}}if(!this.isRestrictedMode){BXMobileApp.addCustomEvent(this.onSelectEventName,BX.proxy(function(t){this.changeEntity(t)},this))}};t.prototype.delEntity=function(t,e){if(this.isMultiEntity){for(var i=0;i<this.curEntityId.length;i++){if(this.curEntityId[i]==e){this.curEntityId.splice(i,1);break}}}else{this.curEntityId=""}BX.remove(t);if(this.onDeleteEventName){BX.onCustomEvent(this.onDeleteEventName,[])}};t.prototype.generateEntityHtml=function(t){var e=BX.create("div");var i=this;var n="";if(t.image){n=BX.create("span",{attrs:{className:"avatar",style:t.image?"background-image:url("+t.image+")":""}})}else if(t.entityType){var o="";if(t.entityType=="contact")o="/bitrix/js/mobile/images/icon-contact.png";else if(t.entityType=="company")o="/bitrix/js/mobile/images/icon-company.png";else if(t.entityType=="lead")o="/bitrix/js/mobile/images/icon-lead.png";else if(t.entityType=="quote")o="/bitrix/js/mobile/images/icon-quote.png";else if(t.entityType=="deal")o="/bitrix/js/mobile/images/icon-deal.png";if(o){n=BX.create("span",{attrs:{className:"avatar",style:"background:#717e8a url("+o+") center no-repeat; background-size: 39px;"}})}}var s=BX.create("div",{attrs:{className:"mobile-grid-field-select-user-item"},children:[n,this.isRestrictedMode?"":BX.create("del",{events:{click:function(){i.delEntity(this.parentNode.parentNode,t.id)}}}),BX.create("span",{html:t.name+(t.addTitle?"<span>"+t.addTitle+"</span>":""),attrs:{className:"mobile-grid-field-user-name"},events:{click:function(){BX.Mobile.Crm.loadPageBlank(t.url)}}})]});if(!this.isMultiEntity)this.entityContainerNode.innerHTML="";e.appendChild(s);if(t.multi){var a=BX.create("div",{attrs:{style:"padding-top: 8px;"}});var r=t.multi;for(var l in r){if(r.hasOwnProperty(l)&&r[l].hasOwnProperty("type")&&r[l].hasOwnProperty("value")){var c="";if(r[l].type=="PHONE"){c=BX.create("div",{attrs:{className:"mobile-grid-block mobile-grid-data-phone-container"},children:[BX.create("img",{attrs:{className:"mobile-grid-field-icon mobile-grid-field-icon-phone",src:"/bitrix/js/mobile/images/"+"phone2x.png",srcset:"/bitrix/js/mobile/images/"+"phone2x.png"+" 2x"}}),BX.create("span",{attrs:{className:"mobile-grid-field-contact"},html:BX.util.htmlspecialchars(r[l].value)})],events:{click:BX.proxy(function(){BX.MobileTools.phoneTo(this.phone)},{phone:r[l].value})}})}else if(r[l].type=="EMAIL"){c=BX.create("div",{attrs:{className:"mobile-grid-block mobile-grid-data-mail-container"},children:[BX.create("a",{attrs:{href:"mailto:"+(r[l].value?r[l].value:""),style:"display: block;text-decoration: none"},children:[BX.create("img",{attrs:{className:"mobile-grid-field-icon",src:"/bitrix/js/mobile/images/"+"email2x.png",srcset:"/bitrix/js/mobile/images/"+"email2x.png"+" 2x"}}),BX.create("span",{attrs:{className:"mobile-grid-field-contact"},html:r[l].value?r[l].value:""})]})]})}var h=BX.create("div",{attrs:{className:"mobile-grid-section-child mobile-grid-field-phone",style:this.isRestrictedMode?"padding-right: 16px;":""},children:[BX.create("span",{attrs:{className:"mobile-grid-title"},html:r[l].name?r[l].name:""}),c]});a.appendChild(h)}}e.appendChild(a)}if(this.entityContainerNode)this.entityContainerNode.appendChild(e)};t.prototype.changeEntity=function(t){if(this.isMultiEntity){for(var e=0;e<this.curEntityId.length;e++){if(this.curEntityId[e]==t.id)return}this.curEntityId.push(t.id)}else this.curEntityId=t.id;this.generateEntityHtml(t)};return t}();BX.namespace("BX.Mobile.Crm.EntityConverterMode");BX.Mobile.Crm.EntityConverterMode={intermediate:0,schemeSetup:1,syncSetup:2,request:3};BX.namespace("BX.Mobile.Crm.EntityConverter");BX.Mobile.Crm.EntityConverter=function(){this._id="";this._entityType="";this._settings={};this._config={};this._contextData=null;this._mode=BX.Mobile.Crm.EntityConverterMode.intermediate;this._entityId=0;this._syncEditor=null;this._syncEditorClosingListener=BX.delegate(this.onSyncEditorClose,this);this._enableSync=false;this._requestIsRunning=false};BX.Mobile.Crm.EntityConverter.prototype={initialize:function(t,e,i){this._id=t;this._entityType=i;this._settings=e?e:{};this._config=this.getSetting("config",{});this._serviceUrl=this.getSetting("serviceUrl","")},getSetting:function(t,e){return typeof this._settings[t]!="undefined"?this._settings[t]:e},setSetting:function(t,e){this._settings[t]=e},getMessage:function(t){return t},getConfig:function(){return this._config},setupSynchronization:function(t){this._mode=BX.Mobile.Crm.EntityConverterMode.syncSetup;var e="convert_"+this._entityType+this._id+Math.random();BXMobileApp.addCustomEvent("onCrmConvertSynchSettings",BX.proxy(function(t){if(t.convertId==e){this._enableSync=true;this._config=t.config;this._contextData=null;this.startRequest()}},this));BXMobileApp.PageManager.loadPageBlank({url:"/mobile/crm/convert_sync/?sync_id="+e,bx24ModernStyle:true,data:{config:this._config,fields:t,convertId:e,entityType:this._entityType}})},convert:function(t,e,i){if(!BX.type.isPlainObject(e)){return}this._entityId=t;this._config=e;this._contextData=BX.type.isPlainObject(i)?i:null;this.startRequest()},startRequest:function(){if(this._requestIsRunning){return}this._requestIsRunning=true;BXMobileApp.UI.Page.LoadingScreen.show();BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{action:"convert",sessid:BX.bitrix_sessid(),MODE:"CONVERT",ENTITY_ID:this._entityId,ENABLE_SYNCHRONIZATION:this._enableSync?"Y":"N",CONFIG:this._config,CONTEXT:this._contextData},onsuccess:BX.delegate(this.onRequestSuccsess,this),onfailure:BX.delegate(this.onRequestFailure,this)});this._mode=BX.Mobile.Crm.EntityConverterMode.request},onRequestSuccsess:function(t){BXMobileApp.UI.Page.LoadingScreen.hide();if(!BX.type.isPlainObject(t))return;this._requestIsRunning=false;this._mode=BX.Mobile.Crm.EntityConverterMode.intermediate;if(t.hasOwnProperty("ERROR")){this.showError(t["ERROR"]);return}var e;if(BX.type.isPlainObject(t["REQUIRED_ACTION"])){var i=t["REQUIRED_ACTION"];var n=BX.type.isNotEmptyString(i["NAME"])?i["NAME"]:"";e=BX.type.isPlainObject(i["DATA"])?i["DATA"]:{};if(n==="SYNCHRONIZE"){if(BX.type.isPlainObject(e["CONFIG"])){this._config=e["CONFIG"]}this.setupSynchronization(BX.type.isArray(e["FIELD_NAMES"])?e["FIELD_NAMES"]:[])}return}if(BX.type.isPlainObject(t["DATA"])){e=t["DATA"];if(BX.type.isNotEmptyString(e["URL"])){if(e["MODAL_SCREEN"]){BX.Mobile.Crm.loadPageModal(e["URL"])}else{BX.Mobile.Crm.loadPageBlank(e["URL"])}}else{BXMobileApp.UI.Page.reload()}}},onRequestFailure:function(){BXMobileApp.UI.Page.LoadingScreen.hide();this._requestIsRunning=false;this._mode=BX.Mobile.Crm.EntityConverterMode.intermediate},showError:function(t){if(!t)return;BX.Mobile.Crm.showErrorAlert(BX.type.isNotEmptyString(t)?t:this.getMessage("generalError"))}};BX.Mobile.Crm.EntityConverter.create=function(t,e){var i=new BX.CrmEntityConverter;i.initialize(t,e);return i};BX.namespace("BX.Mobile.Crm.LeadConversionScheme");BX.Mobile.Crm.LeadConversionScheme=function(){var t=function(t){this.dealcontactcompany="DEAL_CONTACT_COMPANY";this.dealcontact="DEAL_CONTACT";this.dealcompany="DEAL_COMPANY";this.deal="DEAL";this.contactcompany="CONTACT_COMPANY";this.contact="CONTACT";this.company="COMPANY";this.entityId="";this.ajaxPath="";this.permissions={};this.messages={};this.contactSelectUrl="";this.companySelectUrl="";this.buttons=[];this.init(t)};t.prototype.getListItems=function(t){var e=[];for(var i=0;i<t.length;i++){var n=t[i];e.push({value:n,text:this.getDescription(n)})}return e};t.prototype.getDescription=function(t){var e=this.messages;return e.hasOwnProperty(t)?e[t]:t};t.prototype.toConfig=function(t,e){this.markEntityAsActive(e,"deal",t===this.dealcontactcompany||t===this.dealcontact||t===this.dealcompany||t===this.deal);this.markEntityAsActive(e,"contact",t===this.dealcontactcompany||t===this.dealcontact||t===this.contactcompany||t===this.contact);this.markEntityAsActive(e,"company",t===this.dealcontactcompany||t===this.dealcompany||t===this.contactcompany||t===this.company)};t.prototype.createConfig=function(t){var e={};this.toConfig(t,e);return e};t.prototype.markEntityAsActive=function(t,e,i){if(typeof t[e]==="undefined"){t[e]={}}t[e]["active"]=i?"Y":"N"};t.prototype.showActionSheet=function(){if(this.buttons){BX.Mobile.Crm.showRecursiveActionSheet(this.buttons)}};t.prototype.initConverter=function(t,e){if(!t)return;if(!e)e=null;var i=new BX.Mobile.Crm.EntityConverter;var n={serviceUrl:this.ajaxPath,config:this.createConfig(t)};i.initialize("crm_lead",n,"lead");i.convert(this.entityId,this.createConfig(t),e);BXMobileApp.addCustomEvent("onCrmContactLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmContactListUpdate",{},true)},this));BXMobileApp.addCustomEvent("onCrmCompanyLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmCompanyListUpdate",{},true)},this));BXMobileApp.addCustomEvent("onCrmDealLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmDealListUpdate",{},true)},this))};t.prototype.init=function(t){if(typeof t==="object"&&t){this.entityId=t.entityId;this.ajaxPath=t.ajaxPath;this.permissions=t.permissions||{};this.messages=t.messages||{};this.contactSelectUrl=t.contactSelectUrl||"";this.companySelectUrl=t.companySelectUrl||""}var e=t.permissions["deal"];var i=t.permissions["contact"];var n=t.permissions["company"];var o=[];if(e){if(i&&n){o.push(this.dealcontactcompany)}if(i){o.push(this.dealcontact)}if(n){o.push(this.dealcompany)}o.push(this.deal)}if(i&&n){o.push(this.contactcompany)}if(i){o.push(this.contact)}if(n){o.push(this.company)}var s=this.getListItems(o);buttons=[];if(s){for(var a=0;a<s.length;a++){buttons.push({title:s[a].text,callback:BX.proxy(function(){this.self.initConverter(this.scheme)},{scheme:s[a].value,self:this})})}}buttons.push({title:BX.message("M_CRM_LEAD_CONV_OPEN_ENTITY_SEL_CONTACT"),callback:BX.proxy(function(){BX.Mobile.Crm.loadPageModal(this.contactSelectUrl)},this)});buttons.push({title:BX.message("M_CRM_LEAD_CONV_OPEN_ENTITY_SEL_COMPANY"),callback:BX.proxy(function(){BX.Mobile.Crm.loadPageModal(this.companySelectUrl)},this)});this.buttons=buttons;this.showActionSheet();BX.addCustomEvent("onLeadConvertSelectContact",BX.proxy(function(t){if(t.id){this.initConverter(this.contact,{contact:t.id})}},this));BX.addCustomEvent("onLeadConvertSelectCompany",BX.proxy(function(t){if(t.id){this.initConverter(this.company,{company:t.id})}},this))};return t}();BX.namespace("BX.Mobile.Crm.DealConversionScheme");BX.Mobile.Crm.DealConversionScheme=function(){var t=function(t){this.invoice="INVOICE";this.quote="QUOTE";this.entityId="";this.ajaxPath="";this.permissions={};this.messages={};this.buttons=[];this.init(t)};t.prototype.getListItems=function(t){var e=[];for(var i=0;i<t.length;i++){var n=t[i];e.push({value:n,text:this.getDescription(n)})}return e};t.prototype.getDescription=function(t){var e=this.messages;return e.hasOwnProperty(t)?e[t]:t};t.prototype.toConfig=function(t,e){this.markEntityAsActive(e,"invoice",t===this.invoice);this.markEntityAsActive(e,"quote",t===this.quote)};t.prototype.createConfig=function(t){var e={};this.toConfig(t,e);return e};t.prototype.markEntityAsActive=function(t,e,i){if(typeof t[e]==="undefined"){t[e]={}}t[e]["active"]=i?"Y":"N"};t.prototype.showActionSheet=function(){if(this.buttons){BX.Mobile.Crm.showRecursiveActionSheet(this.buttons)}};t.prototype.initConverter=function(t){if(!t)return;var e=new BX.Mobile.Crm.EntityConverter;var i={serviceUrl:this.ajaxPath,config:this.createConfig(t)};e.initialize("crm_deal",i,"deal");e.convert(this.entityId,this.createConfig(t));BXMobileApp.addCustomEvent("onCrmInvoiceLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmInvoiceListUpdate",{},true)},this));BXMobileApp.addCustomEvent("onCrmQuoteLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmQuoteListUpdate",{},true)},this))};t.prototype.init=function(t){if(typeof t==="object"&&t){this.entityId=t.entityId;this.ajaxPath=t.ajaxPath;this.permissions=t.permissions||{};this.messages=t.messages||{}}var e=t.permissions["invoice"];var i=t.permissions["quote"];var n=[];if(e){n.push(this.invoice)}if(i){n.push(this.quote)}var o=this.getListItems(n);buttons=[];if(o){for(var s=0;s<o.length;s++){buttons.push({title:o[s].text,callback:BX.proxy(function(){this.self.initConverter(this.scheme)},{scheme:o[s].value,self:this})})}}this.buttons=buttons;this.showActionSheet()};return t}();BX.namespace("BX.Mobile.Crm.QuoteConversionScheme");BX.Mobile.Crm.QuoteConversionScheme=function(){var t=function(t){this.invoice="INVOICE";this.deal="DEAL";this.entityId="";this.ajaxPath="";this.permissions={};this.messages={};this.buttons=[];this.init(t)};t.prototype.getListItems=function(t){var e=[];for(var i=0;i<t.length;i++){var n=t[i];e.push({value:n,text:this.getDescription(n)})}return e};t.prototype.getDescription=function(t){var e=this.messages;return e.hasOwnProperty(t)?e[t]:t};t.prototype.toConfig=function(t,e){this.markEntityAsActive(e,"invoice",t===this.invoice);this.markEntityAsActive(e,"deal",t===this.deal)};t.prototype.createConfig=function(t){var e={};this.toConfig(t,e);return e};t.prototype.markEntityAsActive=function(t,e,i){if(typeof t[e]==="undefined"){t[e]={}}t[e]["active"]=i?"Y":"N"};t.prototype.showActionSheet=function(){if(this.buttons){BX.Mobile.Crm.showRecursiveActionSheet(this.buttons)}};t.prototype.initConverter=function(t){if(!t)return;var e=new BX.Mobile.Crm.EntityConverter;var i={serviceUrl:this.ajaxPath,config:this.createConfig(t)};e.initialize("crm_quote",i,"quote");e.convert(this.entityId,this.createConfig(t));BXMobileApp.addCustomEvent("onCrmDealLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmDealListUpdate",{},true)},this));BXMobileApp.addCustomEvent("onCrmInvoiceLoadPageBlank",BX.proxy(function(t){if(!t.type||t.type!=="convert")return;if(t.path)BX.Mobile.Crm.loadPageBlank(t.path);BXMobileApp.onCustomEvent("onCrmInvoiceListUpdate",{},true)},this))};t.prototype.init=function(t){if(typeof t==="object"&&t){this.entityId=t.entityId;this.ajaxPath=t.ajaxPath;this.permissions=t.permissions||{};this.messages=t.messages||{}}var e=t.permissions["invoice"];var i=t.permissions["deal"];var n=[];if(e){n.push(this.invoice)}if(i){n.push(this.deal)}var o=this.getListItems(n);buttons=[];if(o){for(var s=0;s<o.length;s++){buttons.push({title:o[s].text,callback:BX.proxy(function(){this.self.initConverter(this.scheme)},{scheme:o[s].value,self:this})})}}this.buttons=buttons;this.showActionSheet()};return t}();
//# sourceMappingURL=mobile_crm.map.js