Current Path : /var/www/axolotl/data/www/axolotl.ru/www/bitrix/js/crm/entity-editor/js/ |
Current File : /var/www/axolotl/data/www/axolotl.ru/www/bitrix/js/crm/entity-editor/js/order.min.js |
BX.namespace("BX.Crm");if(typeof BX.Crm.EntityEditorOrderController==="undefined"){BX.Crm.EntityEditorOrderController=function(){BX.Crm.EntityEditorOrderController.superclass.constructor.apply(this);this._loaderController=BX.Crm.EntityEditorOrderLoaderController.create();this._productList=null;this._isRequesting=false;this._isCreateMode=false;this._editorModeChangeHandler=BX.delegate(this.onEditorModeChange,this);this._editorControlChangeHandler=BX.delegate(this.onEditorControlChange,this);this._ajaxOptsPreset={needFormData:true,needProductComponentParams:true,needToolPanel:true}};BX.extend(BX.Crm.EntityEditorOrderController,BX.UI.EntityEditorController);BX.Crm.EntityEditorOrderController.prototype.isProductListLoaded=function(){return this._productList!==null};BX.Crm.EntityEditorOrderController.prototype.setProductList=function(t){this._productList=t};BX.Crm.EntityEditorOrderController.prototype.doInitialize=function(){BX.Crm.EntityEditorOrderController.superclass.doInitialize.apply(this);BX.onCustomEvent(window,"EntityEditorOrderController",[this]);BX.addCustomEvent(window,BX.Crm.EntityEvent.names.create,BX.delegate(this.onAfterCreate,this));BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterUpdate,this));BX.addCustomEvent("onPullEvent-crm",BX.delegate(this.onPullEvent,this));this._editor.addModeChangeListener(this._editorModeChangeHandler);window["ConnectedEntityController"]=this;this._model.lockField("PRICE");this._isCreateMode=this._model.getField("ID")<=0;if(!this._isCreateMode){this._model.lockField("CURRENCY")}else{BX.addCustomEvent(window,"onDeliveryExtraServiceValueChange",BX.delegate(this.onDeliveryExtraServiceValueChange,this))}if(this.getConfigStringParam("isSalesCenterOrder","")==="Y"){this._model.lockField("USER_ID");this._model.lockField("TRADING_PLATFORM")}};BX.Crm.EntityEditorOrderController.prototype.onPullEvent=function(t,e){if(t!=="onOrderSave"&&t!=="onOrderPaymentSave"&&t!=="onOrderShipmentSave"){return}if(this._editor.isRequestRunning()){return}if(!e.FIELDS||!e.FIELDS.ID||e.FIELDS.ID!==this._model.getField("ID")){return}if(t==="onOrderSave"){var r=new Date(BX.parseDate(this._model.getField("DATE_UPDATE")));var i=new Date(e.FIELDS.DATE_UPDATE);if(!r||!i||typeof r!=="object"||typeof i!=="object"||r.getTime()===i.getTime()){return}}if(!this._editor.isChanged()){this.loadOrder()}else{}};BX.Crm.EntityEditorOrderController.prototype.onDeliveryExtraServiceValueChange=function(){this.onDataChanged()};BX.Crm.EntityEditorOrderController.prototype.onEditorModeChange=function(t){if(this._editor.getMode()===BX.UI.EntityEditorMode.edit){this._editor.addControlChangeListener(this._editorControlChangeHandler)}else{this._editor.removeControlChangeListener(this._editorControlChangeHandler)}};BX.Crm.EntityEditorOrderController.prototype.onEditorControlChange=function(t,e){var r=BX.prop.getString(e,"fieldName","");if(r!=="CURRENCY"){return}var i=BX.prop.getString(e,"fieldValue","");if(i!==""){this._editor._model.setField("CURRENCY",i,{enableNotification:false});this.onDataChanged()}};BX.Crm.EntityEditorOrderController.prototype.onAfterCreate=function(t){if(BX.prop.getInteger(t,"entityTypeId",0)!==BX.CrmEntityType.enumeration.order){return}if(t&&t.entityData&&this._productList){this._productList.setFormData(t.entityData)}};BX.Crm.EntityEditorOrderController.prototype.onAfterUpdate=function(t){if(BX.prop.getInteger(t,"entityTypeId",0)!==BX.CrmEntityType.enumeration.order){return}if(t&&t.entityData&&this._productList){this._productList.setFormData(t.entityData)}};BX.Crm.EntityEditorOrderController.prototype.hideLoader=function(){this._loaderController.hideLoader()};BX.Crm.EntityEditorOrderController.prototype.showLoader=function(){this._loaderController.showLoader()};BX.Crm.EntityEditorOrderController.prototype.onProductAdd=function(t,e,r){this.ajax("addProduct",{data:{PRODUCT_ID:t,QUANTITY:e,USE_MERGE:r||"Y"}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onProductCreate=function(t){if(BX.type.isNotEmptyObject(t)){this.ajax("createProduct",{data:{PRODUCT_DATA:t}},this._ajaxOptsPreset)}};BX.Crm.EntityEditorOrderController.prototype.onProductUpdate=function(t,e){if(BX.type.isNotEmptyObject(e)){this.ajax("updateProduct",{data:{PRODUCT_DATA:e,BASKET_ID:t}},this._ajaxOptsPreset)}};BX.Crm.EntityEditorOrderController.prototype.onChangeDelivery=function(t){this.ajax("changeDelivery",{data:{INDEX:t}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onProductDelete=function(t){this.ajax("deleteProduct",{data:{BASKET_CODE:t}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onProductGroupAction=function(t,e,r){this.ajax("productGroup",{data:{BASKET_CODES:t,GROUP_ACTION:e,FOR_ALL:r}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.innerCancel=function(){BX.onCustomEvent(window,"EntityEditorOrderController:onInnerCancel",[this]);var t=[];for(var e=0,r=this._editor._activeControls.length;e<r;e++){var i=this._editor._activeControls[e];if(i.isChanged()){var n=this.getControlValue(i);for(var o in n){if(n.hasOwnProperty(o)){t[o]=n[o]}}}}var s=this._ajaxOptsPreset;s.skipMarkAsChanged=true;this.ajax("rollback",{data:{CHANGED_DATA:t}},s)};BX.Crm.EntityEditorOrderController.prototype.onCouponDelete=function(t){this.ajax("deleteCoupon",{data:{COUPON:t}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onCouponAdd=function(t){this.ajax("addCoupon",{data:{COUPON:t}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onRefreshOrderDataAndSave=function(){this._editor.getFormElement().appendChild(BX.create("input",{attrs:{type:"hidden",name:"REFRESH_ORDER_DATA_AND_SAVE",value:"Y"}}));this._editor.save()};BX.Crm.EntityEditorOrderController.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorOrderController.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorOrderController.prototype.openDetailSlider=function(t){if(this._editor.isChanged()){BX.UI.EditorAuxiliaryDialog.create("order_save_confirmation",{title:this.getMessage("saveChanges"),content:this.getMessage("saveConfirm"),buttons:[{id:"save",type:BX.Crm.DialogButtonType.accept,text:this.getMessage("save"),callback:BX.proxy((function(e){this._editor.saveChanged();BX.Crm.Page.openSlider(t);e.getDialog().close()}),this)},{id:"cancel",type:BX.Crm.DialogButtonType.cancel,text:this.getMessage("notSave"),callback:function(e){BX.Crm.Page.openSlider(t);e.getDialog().close()}}]}).open()}else{BX.Crm.Page.openSlider(t)}};BX.Crm.EntityEditorOrderController.prototype.ajax=function(t,e,r){if(!t){throw"action must be defined!"}if(this.isLockedSending()){return}this.lockSending();r=r||{};if(typeof r.showLoader==="undefined"){r.showLoader=true}if(r.showLoader){this._loaderController.showLoader()}var i={ACTION:t,sessid:BX.bitrix_sessid()};if(r.needFormData){i.FORM_DATA=this.demandFormData()}if(r.needProductComponentParams){var n=this._editor.getContext();if(n.PRODUCT_COMPONENT_DATA){i["PRODUCT_COMPONENT_DATA"]=n.PRODUCT_COMPONENT_DATA}}if(typeof e.data==="object"){for(var o in e.data){if(e.data.hasOwnProperty(o)){i[o]=e.data[o]}}}BX.ajax({url:this.getConfigStringParam("serviceUrl",""),method:"POST",dataType:"json",data:i,onsuccess:e.onsuccess?e.onsuccess:BX.proxy((function(t){this.onSendDataSuccess(t,r)}),this),onfailure:e.onfailure?e.onfailure:BX.delegate(this.onSendDataFailure,this)});if(r.needToolPanel){this._editor.showToolPanel()}};BX.Crm.EntityEditorOrderController.prototype.isLockedSending=function(){return this._isRequesting};BX.Crm.EntityEditorOrderController.prototype.lockSending=function(){this._isRequesting=true};BX.Crm.EntityEditorOrderController.prototype.unlockSending=function(){this._isRequesting=false};BX.Crm.EntityEditorOrderController.prototype.loadOrder=function(){this.ajax("loadOrder",{data:{ORDER_ID:this._model.getField("ID")}},{showLoader:false,needToolPanel:false,skipMarkAsChanged:true,needFormData:false,needProductComponentParams:true})};BX.Crm.EntityEditorOrderController.prototype.onSkuSelect=function(t){this.ajax("skuSelect",{data:{SKU_PROPS:t.SKU_PROPS,PRODUCT_ID:t.PRODUCT_ID,SKU_ORDER:t.SKU_ORDER,CHANGED_SKU_ID:t.CHANGED_SKU_ID,BASKET_CODE:t.BASKET_CODE}},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.demandFormData=function(){var t=BX.clone(this._editor._model.getData()),e=this._editor.getControls(),r,i={DELIVERY_SERVICES_LIST:true,EXTRA_SERVICES_HTML:true,STATUS_CONTROL:true};for(r=0;r<e.length;r++){var n=this.getControlValue(e[r]);for(var o in n){if(n.hasOwnProperty(o)){if(!i[o]){t[o]=n[o]}}}}var s=this._editor.getFormElement();var a=BX.ajax.prepareForm(s);if(this._isCreateMode){if(s){if(a&&a.data){if(a.data.SHIPMENT&&a.data.SHIPMENT[0]&&a.data.SHIPMENT[0].EXTRA_SERVICES){t.SHIPMENT[0].EXTRA_SERVICES=a.data.SHIPMENT[0].EXTRA_SERVICES}}}}else{if(typeof t.PAYMENT!=="undefined"){for(r in t.PAYMENT){if(t.PAYMENT[r]["SUM"]){delete t.PAYMENT[r]["SUM"]}}}}if(s){if(a.data.DISCOUNTS&&a.data.DISCOUNTS.DELIVERY){if(!t.DISCOUNTS){t.DISCOUNTS={}}t.DISCOUNTS.DELIVERY=a.data.DISCOUNTS.DELIVERY}}t["SITE_ID"]=this.getSiteId();var d={};if(this._productList){d=BX.mergeEx(d,this._productList.getFormData())}t=BX.mergeEx(d,t);return t};BX.Crm.EntityEditorOrderController.prototype.getControlValue=function(t){var e=[];if(!t instanceof BX.Crm.EntityEditorControl)return e;var r=[];if(t instanceof BX.Crm.EntityEditorSection||t instanceof BX.UI.EntityEditorColumn){var i=t.getChildren();for(var n=0;n<t.getChildCount();n++){r=this.getControlValue(i[n]);for(var o in r){if(r.hasOwnProperty(o)){e[o]=r[o]}}}}else if(t.isChanged()){e[t.getName()]=t.getRuntimeValue()}return e};BX.Crm.EntityEditorOrderController.prototype.getSiteId=function(){var t=this._editor.getContext();return t.SITE_ID?t.SITE_ID:""};BX.Crm.EntityEditorOrderController.prototype.onDataChanged=function(t){var e={};if(BX.type.isNotEmptyObject(t)){if(t.actionBefore){e["ACTION_BEFORE"]=t.actionBefore}if(t.actionAfter){e["ACTION_AFTER"]=t.actionAfter}if(t.data){e["ADDITIONAL_DATA"]=t.data}}this.ajax("refreshOrderData",{data:e,onsuccess:BX.proxy((function(e){if(BX.type.isNotEmptyObject(t)&&t.callbackBefore&&typeof t.callbackBefore==="function"){t.callbackBefore.call(null,e)}this.onSendDataSuccess(e);if(BX.type.isNotEmptyObject(t)&&t.callbackAfter&&typeof t.callbackAfter==="function"){t.callbackAfter.call(null,e)}}),this)},this._ajaxOptsPreset)};BX.Crm.EntityEditorOrderController.prototype.onSendDataSuccess=function(t,e){var r=e&&e.skipMarkAsChanged||false;this.unlockSending();this._loaderController.hideLoader();this._editor._toolPanel.clearErrors();if(t){if(t.ERROR){if(!this._editor._toolPanel.isVisible()){this._editor._toolPanel.setVisible(true)}this._editor._toolPanel.addError(t.ERROR)}if(t.ORDER_DATA){this._model.setData(t.ORDER_DATA);if(!r){this.markAsChanged()}if(t.ORDER_DATA.PROPERTIES_SCHEME){setTimeout(BX.delegate((function(){BX.onCustomEvent(window,"Crm.OrderModel.ChangePropertyScheme",[t.ORDER_DATA.PROPERTIES_SCHEME])}),this),0)}if(t.ORDER_DATA.SHIPMENT_PROPERTIES_SCHEME){setTimeout(BX.delegate((function(){BX.onCustomEvent(window,"Crm.ShipmentModel.ChangePropertyScheme",[t.ORDER_DATA.SHIPMENT_PROPERTIES_SCHEME])}),this),0)}if(t.ORDER_DATA.USER_PROFILE_LIST){var i=BX.prop.getArray(t.ORDER_DATA,"USER_PROFILE_LIST");var n=this._editor.getControls();for(var o=0;o<n.length;o++){var s=n[o].getChildById("USER_PROFILE");if(s){s._items=null;s._schemeElement.setData({items:i});if(BX.type.isNotEmptyString(t.ORDER_DATA.USER_PROFILE)){this._model.setField("USER_PROFILE",t.ORDER_DATA.USER_PROFILE,{enableNotification:false})}s.refreshLayout()}}}if(this._productList){this._productList.setFormData(t)}}}};BX.Crm.EntityEditorOrderController.prototype.onSendDataFailure=function(t,e){this.unlockSending();this._loaderController.hideLoader();BX.debug(e.message)};BX.Crm.EntityEditorOrderController.prototype.onBeforeSubmit=function(){this.setFormField(this.getConfigStringParam("dataFieldName",""),"["+JSON.stringify(this.demandFormData())+"]");if(this.getConfigStringParam("isSalesCenterOrder","")==="Y"){this.setFormField("SALES_CENTER_SESSION_ID",this.getConfigStringParam("salesCenterSessionId",""))}};BX.Crm.EntityEditorOrderController.prototype.setFormField=function(t,e){var r=this._editor.getFormElement();if(r.elements[t]){r.elements[t].value=e}else{r.appendChild(BX.create("input",{attrs:{type:"hidden",name:t,value:e}}))}};BX.Crm.EntityEditorOrderController.prototype.onBeforesSaveControl=function(t){t[this.getConfigStringParam("dataFieldName","")]=JSON.stringify([this.demandFormData()]);return t};BX.Crm.EntityEditorOrderController.create=function(t,e){var r=new BX.Crm.EntityEditorOrderController;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderShipmentController==="undefined"){BX.Crm.EntityEditorOrderShipmentController=function(){BX.Crm.EntityEditorOrderShipmentController.superclass.constructor.apply(this);this._loaderController=BX.Crm.EntityEditorOrderLoaderController.create();this._productList=null;this._isRequesting=false};BX.extend(BX.Crm.EntityEditorOrderShipmentController,BX.UI.EntityEditorController);BX.Crm.EntityEditorOrderShipmentController.prototype.setProductList=function(t){this._productList=t;this._editor.getFormElement().appendChild(BX.create("input",{props:{name:"IS_PRODUCT_LIST_LOADED",value:"Y",type:"hidden"}}))};BX.Crm.EntityEditorOrderShipmentController.prototype.doInitialize=function(){BX.onCustomEvent(window,"onEntityEditorOrderShipmentControllerInit",[this]);BX.addCustomEvent(window,"onDeliveryExtraServiceValueChange",BX.delegate(this.onDeliveryExtraServiceValueChange,this));BX.addCustomEvent(window,"onDeliveryPriceRecalculateClicked",BX.delegate(this.onDeliveryPriceRecalculateClicked,this));BX.addCustomEvent(window,BX.Crm.EntityEvent.names.create,BX.delegate(this.onAfterCreate,this));BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterUpdate,this));window["EntityEditorOrderShipmentController"]=this;if(this.isLockCurrency()){this.lockCurrency()}};BX.Crm.EntityEditorOrderShipmentController.prototype.isLockCurrency=function(){return true};BX.Crm.EntityEditorOrderShipmentController.prototype.lockCurrency=function(){this._model.lockField("CURRENCY")};BX.Crm.EntityEditorOrderShipmentController.prototype.onAfterCreate=function(t){if(BX.prop.getInteger(t,"entityTypeId",0)!==BX.CrmEntityType.enumeration.ordershipment){return}if(t&&t.entityData&&this._productList){this._productList.setFormData(t.entityData)}};BX.Crm.EntityEditorOrderShipmentController.prototype.onAfterUpdate=function(t){if(BX.prop.getInteger(t,"entityTypeId",0)!==BX.CrmEntityType.enumeration.ordershipment){return}if(t&&t.entityData&&this._productList){this._productList.setFormData(t.entityData)}};BX.Crm.EntityEditorOrderShipmentController.prototype.onDeliveryExtraServiceValueChange=function(){this.onDataChanged()};BX.Crm.EntityEditorOrderShipmentController.prototype.onDeliveryPriceRecalculateClicked=function(){this.onDataChanged({},{showLoader:true})};BX.Crm.EntityEditorOrderShipmentController.prototype.innerCancel=function(){this.ajax("rollback",{},{skipMarkAsChanged:true})};BX.Crm.EntityEditorOrderShipmentController.prototype.onBeforeSubmit=function(){var t=this._editor.getControlById("PRICE_DELIVERY_WITH_CURRENCY");if(t&&t.isChanged()){this.setCustomPriceDelivery()}if(this._productList){var e="["+JSON.stringify(this._productList.getFormData())+"]",r=this._editor.getFormElement(),i=this.getConfigStringParam("productDataFieldName","");if(r.elements[i]){r.elements[i].value=e}else{r.appendChild(BX.create("input",{attrs:{type:"hidden",name:i,value:e}}))}}};BX.Crm.EntityEditorOrderShipmentController.prototype.onChangeDelivery=function(){this.ajax("changeDelivery")};BX.Crm.EntityEditorOrderShipmentController.prototype.setCustomPriceDelivery=function(){var t=this._editor.getFormElement();if(t.elements["CUSTOM_PRICE_DELIVERY"]){t.elements["CUSTOM_PRICE_DELIVERY"].value="Y"}else{t.appendChild(BX.create("input",{attrs:{type:"hidden",name:"CUSTOM_PRICE_DELIVERY",value:"Y"}}))}};BX.Crm.EntityEditorOrderShipmentController.prototype.onProductAdd=function(t){this.ajax("addProduct",{data:{BASKET_ID:t}})};BX.Crm.EntityEditorOrderShipmentController.prototype.onProductDelete=function(t){this.ajax("deleteProduct",{data:{BASKET_CODE:t}})};BX.Crm.EntityEditorOrderShipmentController.prototype.ajax=function(t,e,r){if(!t){throw"action must be defined!"}if(this._isRequesting){return}this._isRequesting=true;e=e||{};r=r||{};if(typeof r.showLoader==="undefined"){r.showLoader=false}if(r.showLoader){this._loaderController.showLoader()}var i={ACTION:t,sessid:BX.bitrix_sessid()};i.FORM_DATA=this.demandFormData();var n=this._editor.getContext();if(n.PRODUCT_COMPONENT_DATA){i["PRODUCT_COMPONENT_DATA"]=n.PRODUCT_COMPONENT_DATA}if(typeof e.data==="object"){for(var o in e.data){if(e.data.hasOwnProperty(o)){i[o]=e.data[o]}}}BX.ajax({url:this.getConfigStringParam("serviceUrl",""),method:"POST",dataType:"json",data:i,onsuccess:e.onsuccess?e.onsuccess:BX.proxy((function(t){this.onSendDataSuccess(t,r)}),this),onfailure:e.onfailure?e.onfailure:BX.delegate(this.onSendDataFailure,this)})};BX.Crm.EntityEditorOrderShipmentController.prototype.demandFormData=function(){var t=this._editor._model.getData(),e=this._editor.getControls(),r,i={DELIVERY_SERVICES_LIST:true,EXTRA_SERVICES_DATA:true,STATUS_CONTROL:true};var n=this._editor.getContext();t["ORDER_ID"]=n.ORDER_ID?n.ORDER_ID:0;for(r=0;r<e.length;r++){var o=this.getControlValue(e[r]);for(var s in o){if(o.hasOwnProperty(s)){if(!i[s]){t[s]=o[s]}}}}var a=this._editor.getFormElement();if(a){var d=BX.ajax.prepareForm(a);if(d&&d.data){for(r in d.data){if(d.data.hasOwnProperty(r)){t[r]=d.data[r]}}}}if(this._productList){t=BX.mergeEx(this._productList.getFormData(),t)}return t};BX.Crm.EntityEditorOrderShipmentController.prototype.getControlValue=function(t){var e=[];if(!t instanceof BX.Crm.EntityEditorControl)return e;var r=[];if(t instanceof BX.UI.EntityEditorSection||t instanceof BX.UI.EntityEditorColumn){var i=t.getChildren();for(var n=0;n<t.getChildCount();n++){r=this.getControlValue(i[n]);for(var o in r){if(r.hasOwnProperty(o)){e[o]=r[o]}}}}else if(t.isChanged()){e[t.getName()]=t.getRuntimeValue()}return e};BX.Crm.EntityEditorOrderShipmentController.prototype.onDataChanged=function(t,e){t=t||{};e=e||{};this.ajax("refreshShipmentData",t,e)};BX.Crm.EntityEditorOrderShipmentController.prototype.markAsChangedItem=function(){this._editor._toolPanel.enableSaveButton();this._editor._toolPanel.clearErrors();this.markAsChanged()};BX.Crm.EntityEditorOrderShipmentController.prototype.onSendDataSuccess=function(t,e){var r=this._editor._toolPanel;var i=e&&e.skipMarkAsChanged||false;this._isRequesting=false;this._loaderController.hideLoader();r.clearErrors();if(t){if(t.ERROR){r.addError(t.ERROR);if(r.isSaveButtonEnabled()){r.disableSaveButton()}this._editor.showToolPanel()}if(t.SHIPMENT_DATA){if(t.SHIPMENT_DATA.CUSTOM_PRICE_DELIVERY==="Y"){this.setCustomPriceDelivery()}this._model.setData(t.SHIPMENT_DATA);if(!i){this.markAsChanged()}if(t.SHIPMENT_DATA.SHIPMENT_PROPERTIES_SCHEME){setTimeout(BX.delegate((function(){BX.onCustomEvent(window,"Crm.ShipmentModel.ChangePropertyScheme",[t.SHIPMENT_DATA.SHIPMENT_PROPERTIES_SCHEME])}),this),0)}if(this._productList!==null){this._productList.setFormData(t)}if(t.SHIPMENT_DATA.DELIVERY_LOGO!=="undefined"){var n=this._editor.getControlById("DELIVERY_LOGO");if(n){n.refreshLayout()}}if(!r.isSaveButtonEnabled()){r.enableSaveButton()}}}};BX.Crm.EntityEditorOrderShipmentController.prototype.onSendDataFailure=function(t,e){this._isRequesting=false;this._loaderController.hideLoader();BX.debug(e.message)};BX.Crm.EntityEditorOrderShipmentController.create=function(t,e){var r=new BX.Crm.EntityEditorOrderShipmentController;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorDocumentOrderShipmentController==="undefined"){BX.Crm.EntityEditorDocumentOrderShipmentController=function(){BX.Crm.EntityEditorDocumentOrderShipmentController.superclass.constructor.apply(this);this._loaderController=BX.Crm.EntityEditorOrderLoaderController.create();this._productList=null;this._isRequesting=false};BX.extend(BX.Crm.EntityEditorDocumentOrderShipmentController,BX.Crm.EntityEditorOrderShipmentController);BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.doInitialize=function(){BX.onCustomEvent(window,"onEntityEditorDocumentOrderShipmentControllerInit",[this]);BX.addCustomEvent(window,"onDeliveryExtraServiceValueChange",BX.delegate(this.onDeliveryExtraServiceValueChange,this));BX.addCustomEvent(window,"onDeliveryPriceRecalculateClicked",BX.delegate(this.onDeliveryPriceRecalculateClicked,this));window["EntityEditorDocumentOrderShipmentController"]=this;BX.addCustomEvent(window,"onDocumentProductChange",BX.delegate(this.onDocumentProductChange,this));BX.addCustomEvent(window,"DocumentProductListController",BX.delegate(this.setProductList,this));if(this.isLockCurrency()){this.lockCurrency()}};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.isLockCurrency=function(){return true};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.lockCurrency=function(){this._model.lockField("CURRENCY")};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onAfterCreate=function(t){};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onAfterUpdate=function(t){};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onDeliveryExtraServiceValueChange=function(){this.onDataChanged()};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onDeliveryPriceRecalculateClicked=function(){this.onDataChanged({},{showLoader:true})};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.innerCancel=function(){this.ajax("rollback",{},{skipMarkAsChanged:true})};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onBeforeSubmit=function(){var t=this._editor.getControlById("PRICE_DELIVERY_WITH_CURRENCY");if(t&&t.isChanged()){this.setCustomPriceDelivery()}var e=this.getConfigStringParam("productDataFieldName","");this.setFormField(e,"");this.setFormField(e,"["+JSON.stringify(this.demandFormData())+"]")};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.setFormField=function(t,e){var r=this._editor.getFormElement();if(r.elements[t]){r.elements[t].value=e}else{r.appendChild(BX.create("input",{attrs:{type:"hidden",name:t,value:e}}))}};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onChangeDelivery=function(){this.ajax("changeDelivery")};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.setCustomPriceDelivery=function(){var t=this._editor.getFormElement();if(t.elements["CUSTOM_PRICE_DELIVERY"]){t.elements["CUSTOM_PRICE_DELIVERY"].value="Y"}else{t.appendChild(BX.create("input",{attrs:{type:"hidden",name:"CUSTOM_PRICE_DELIVERY",value:"Y"}}))}};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onProductAdd=function(t){};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onProductDelete=function(t){};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.ajax=function(t,e,r){if(!t){throw"action must be defined!"}if(this._isRequesting){return}this._isRequesting=true;e=e||{};r=r||{};if(typeof r.showLoader==="undefined"){r.showLoader=false}if(r.showLoader){this._loaderController.showLoader()}var i={ACTION:t,sessid:BX.bitrix_sessid()};i.FORM_DATA=this.demandFormData();if(typeof e.data==="object"){for(var n in e.data){if(e.data.hasOwnProperty(n)){i[n]=e.data[n]}}}BX.ajax({url:this.getConfigStringParam("serviceUrl",""),method:"POST",dataType:"json",data:i,onsuccess:e.onsuccess?e.onsuccess:BX.proxy((function(t){this.onSendDataSuccess(t,r)}),this),onfailure:e.onfailure?e.onfailure:BX.delegate(this.onSendDataFailure,this)})};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.demandFormData=function(){var t=this._editor._model.getData(),e=this._editor.getControls(),r,i={DELIVERY_SERVICES_LIST:true,EXTRA_SERVICES_DATA:true,STATUS_CONTROL:true};var n=this._editor.getContext();t["ID"]=n.ID?n.ID:0;t["ORDER_ID"]=n.ORDER_ID?n.ORDER_ID:0;for(r=0;r<e.length;r++){var o=this.getControlValue(e[r]);for(var s in o){if(o.hasOwnProperty(s)){if(!i[s]){t[s]=o[s]}}}}var a=this._editor.getFormElement();if(a){var d=BX.ajax.prepareForm(a);if(d&&d.data){for(r in d.data){if(d.data.hasOwnProperty(r)){t[r]=d.data[r]}}}}if(this._productList){t.PRODUCT=this._productList.getProductsFields()}return t};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.getControlValue=function(t){var e=[];if(!t instanceof BX.Crm.EntityEditorControl)return e;var r=[];if(t instanceof BX.UI.EntityEditorSection||t instanceof BX.UI.EntityEditorColumn){var i=t.getChildren();for(var n=0;n<t.getChildCount();n++){r=this.getControlValue(i[n]);for(var o in r){if(r.hasOwnProperty(o)){e[o]=r[o]}}}}else if(t.isChanged()){e[t.getName()]=t.getRuntimeValue()}return e};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onDataChanged=function(t,e){t=t||{};e=e||{};this.ajax("refreshShipmentData",t,e)};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.markAsChangedItem=function(){this._editor._toolPanel.enableSaveButton();this._editor._toolPanel.clearErrors();this.markAsChanged()};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onDocumentProductChange=function(t){var e={data:{PRODUCT:t}};this.ajax("changeProduct",e)};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.setProductList=function(t){this._productList=t.getData()[0];this._editor.getFormElement().appendChild(BX.create("input",{props:{type:"hidden",name:"IS_PRODUCT_LIST_LOADED",value:"Y"}}))};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onSendDataSuccess=function(t,e){var r=this._editor._toolPanel;var i=e&&e.skipMarkAsChanged||false;this._isRequesting=false;this._loaderController.hideLoader();r.clearErrors();if(t){if(t.ERROR){r.addError(t.ERROR);if(r.isSaveButtonEnabled()){r.disableSaveButton()}this._editor.showToolPanel()}if(t.SHIPMENT_DATA){if(t.SHIPMENT_DATA.CUSTOM_PRICE_DELIVERY==="Y"){this.setCustomPriceDelivery()}this._model.setData(t.SHIPMENT_DATA);if(!i){this.markAsChanged()}if(t.SHIPMENT_DATA.SHIPMENT_PROPERTIES_SCHEME){setTimeout(BX.delegate((function(){BX.onCustomEvent(window,"Crm.ShipmentModel.ChangePropertyScheme",[t.SHIPMENT_DATA.SHIPMENT_PROPERTIES_SCHEME])}),this),0)}if(!r.isSaveButtonEnabled()){r.enableSaveButton()}}}};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onSendDataFailure=function(t,e){this._isRequesting=false;this._loaderController.hideLoader()};BX.Crm.EntityEditorDocumentOrderShipmentController.prototype.onAfterSave=function(){BX.Crm.EntityEditorDocumentOrderShipmentController.superclass.onAfterSave.apply(this);var t=BX.Crm.Store.DocumentCard.Document.Instance;if(t){t.setViewModeButtons(this._editor)}window.top.BX.onCustomEvent("onEntityEditorDocumentOrderShipmentControllerDocumentSave")};BX.Crm.EntityEditorDocumentOrderShipmentController.create=function(t,e){var r=new BX.Crm.EntityEditorDocumentOrderShipmentController;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderExtraServicesWrapper==="undefined"){var mode="";BX.Crm.EntityEditorOrderExtraServicesWrapper=function(t){mode=t.mode};BX.Crm.EntityEditorOrderExtraServicesWrapper.prototype.wrapItem=function(t){var e=mode==="view"?t.VIEW_HTML:t.EDIT_HTML;return this.wrapDomNode(t.NAME,createDomNodeFromHtml(e),t.PRICE,t.COST).childNodes};BX.Crm.EntityEditorOrderExtraServicesWrapper.prototype.wrapDomNode=function(t,e,r,i){e=wrap(e,r,i,mode);if(t){e=addName(t,e)}return e};var addName=function(t,e){var r=e.querySelector(".crm-entity-widget-content-block");if(r){r.insertBefore(BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:t})]}),r.children[0])}return e};var createDomNodeFromHtml=function(t){return BX.create("div",{html:t})};var wrap=function(t,e,r,i){if(i==="edit"){t.querySelectorAll("input[type=checkbox]").forEach((function(t,i,n){wrapCheckbox(t,e,r)}),this);t.querySelectorAll("input[type=text]").forEach((function(t,i,n){wrapTextInput(t,e,r)}),this);t.querySelectorAll("select").forEach((function(t,i,n){wrapSelect(t,e,r)}),this)}else{var n,o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,false);while(n=o.nextNode()){var s=n.data,a=BX.create("span",{html:s});n.parentNode.replaceChild(getWrappedText(a,e,r),n)}}return t};var getWrappedText=function(t,e,r){var i=null;if(t){i=BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-text"},children:[t.innerHTML+(e&&r?" ("+r+") ":"")]})]})]})}return i};var wrapCheckbox=function(t,e,r){if(!t){return}t.className="crm-entity-widget-content-checkbox";e=e||" ";t.parentNode.replaceChild(BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-checkbox"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("label",{props:{className:"crm-entity-widget-content-block-checkbox-label"},children:[t.cloneNode(true),BX.create("span",{props:{className:"crm-entity-widget-content-block-checkbox-description"},html:e})]})]})]}),t)};var wrapTextInput=function(t,e,r){if(!t){return}t.className="crm-entity-widget-content-input";t.parentNode.replaceChild(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner crm-entity-widget-content-block-colums-input"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-input-wrapper"},children:[t.cloneNode(true),BX.create("span",{props:{className:"crm-entity-widget-content-block-checkbox-description"},html:"X "+e})]})]})]}),t)};var wrapSelect=function(t,e,r){if(!t){return}t.className="crm-entity-widget-content-input";t.parentNode.replaceChild(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner crm-entity-widget-content-block-colums-input"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-input-wrapper"},children:[t.cloneNode(true)]})]})]}),t)}}if(typeof BX.Crm.EntityEditorOrderPaymentController==="undefined"){BX.Crm.EntityEditorOrderPaymentController=function(){BX.Crm.EntityEditorOrderPaymentController.superclass.constructor.apply(this);this._isRequesting=false};BX.extend(BX.Crm.EntityEditorOrderPaymentController,BX.UI.EntityEditorController);BX.Crm.EntityEditorOrderPaymentController.prototype.doInitialize=function(){BX.onCustomEvent(window,"onEntityEditorOrderPaymentControllerInit",[this]);window["EntityEditorOrderPaymentController"]=this;this._model.lockField("CURRENCY")};BX.Crm.EntityEditorOrderPaymentController.prototype.ajax=function(t,e,r){if(!t){throw"action must be defined!"}if(this._isRequesting){return}this._isRequesting=true;e=e||{};r=r||{};var i={ACTION:t,sessid:BX.bitrix_sessid()};i.FORM_DATA=this.demandFormData();if(typeof e.data==="object"){for(var n in e.data){if(e.data.hasOwnProperty(n)){i[n]=e.data[n]}}}BX.ajax({url:this.getConfigStringParam("serviceUrl",""),method:"POST",dataType:"json",data:i,onsuccess:e.onsuccess?e.onsuccess:BX.proxy((function(t){this.onSendDataSuccess(t,r)}),this),onfailure:e.onfailure?e.onfailure:BX.delegate(this.onSendDataFailure,this)});this._isRequesting=false};BX.Crm.EntityEditorOrderPaymentController.prototype.onDataChanged=function(){this.ajax("refreshPaymentData")};BX.Crm.EntityEditorOrderPaymentController.prototype.demandFormData=function(){var t=this._editor._model.getData(),e=this._editor.getControls(),r;var i=this._editor.getContext();t["ORDER_ID"]=i.ORDER_ID?i.ORDER_ID:0;for(r=0;r<e.length;r++){var n=this.getControlValue(e[r]);for(var o in n){if(n.hasOwnProperty(o)){t[o]=n[o]}}}return t};BX.Crm.EntityEditorOrderPaymentController.prototype.getControlValue=function(t){var e=[];if(!t instanceof BX.Crm.EntityEditorControl)return e;var r=[];if(t instanceof BX.Crm.EntityEditorSection||t instanceof BX.UI.EntityEditorColumn){var i=t.getChildren();for(var n=0;n<t.getChildCount();n++){r=this.getControlValue(i[n]);for(var o in r){if(r.hasOwnProperty(o)){e[o]=r[o]}}}}else if(t.isChanged()){e[t.getName()]=t.getRuntimeValue()}return e};BX.Crm.EntityEditorOrderPaymentController.prototype.onBeforeSubmit=function(){var t="["+JSON.stringify(this.demandFormData())+"]",e=this._editor.getFormElement(),r=this.getConfigStringParam("dataFieldName","");e.appendChild(BX.create("input",{attrs:{type:"hidden",name:r,value:t}}))};BX.Crm.EntityEditorOrderPaymentController.prototype.innerCancel=function(){this.ajax("rollback",{},{skipMarkAsChanged:this._isChanged})};BX.Crm.EntityEditorOrderPaymentController.prototype.onSendDataSuccess=function(t,e){var r=e&&e.skipMarkAsChanged||false;var i=e&&e.sendUpdateEvent||false;this._isRequesting=false;this._editor._toolPanel.clearErrors();if(t){if(t.ERROR){this._editor._toolPanel.addError(t.ERROR)}if(t.PAYMENT_DATA){this._model.setData(t.PAYMENT_DATA);if(!r){this.markAsChanged()}if(i){window.top.BX.SidePanel.Instance.postMessage(window,"CrmOrderPayment::Update",{field:t.PAYMENT_DATA,entityTypeId:BX.CrmEntityType.enumeration.orderpayment})}}}};BX.Crm.EntityEditorOrderPaymentController.prototype.onSendDataFailure=function(t,e){this._isRequesting=false;BX.debug(e.message)};BX.Crm.EntityEditorOrderPaymentController.create=function(t,e){var r=new BX.Crm.EntityEditorOrderPaymentController;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderProductController==="undefined"){BX.Crm.EntityEditorOrderProductController=function(){BX.Crm.EntityEditorOrderProductController.superclass.constructor.apply(this);this._isRequesting=false};BX.extend(BX.Crm.EntityEditorOrderProductController,BX.UI.EntityEditorController);BX.Crm.EntityEditorOrderProductController.prototype.doInitialize=function(){this._model.lockField("CURRENCY");this._model.setField("CUSTOM_PRICE","Y")};BX.Crm.EntityEditorOrderProductController.create=function(t,e){var r=new BX.Crm.EntityEditorOrderProductController;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorPayment==="undefined"){BX.Crm.EntityEditorPayment=function(){BX.Crm.EntityEditorPayment.superclass.constructor.apply(this);this._view=null;this._isPaidButtonMenuOpened={};this._paySystemInputs={};this._sumInput={};this._isReturn={};this._logoImg={};this._paidInput={};this._datePaid={};this._currency={};this._paidButtons={};this._documentLinks={};this._documentInnerData={};this._paymentBlocks={};this._documentType={voucher:1,return:2};this._isCreateMode=false;this._customPaymentSumm={};this._paySystemName={};this._sumFormatted={};this._orderController=null};BX.extend(BX.Crm.EntityEditorPayment,BX.Crm.EntityEditorField);if(typeof BX.Crm.EntityEditorPayment.messages==="undefined"){BX.Crm.EntityEditorPayment.messages={}}BX.Crm.EntityEditorPayment.prototype.getItemField=function(t,e){var r=this._model.getField(this.getName()),i="";if(r&&r[t]&&typeof r[t][e]!=="undefined"){i=r[t][e]}return i};BX.Crm.EntityEditorPayment.prototype.setItemField=function(t,e,r){var i=this._model.getField(this.getName());if(i&&i[t]){i[t][e]=r;this._model.setField(this.getName(),i,{originator:this})}};BX.Crm.EntityEditorPayment.prototype.onPaySystemSelect=function(t){this.setItemField(t,"PAY_SYSTEM_ID",this._paySystemInputs[t].value);this.markAsChanged();this.getOrderController().onDataChanged()};BX.Crm.EntityEditorPayment.prototype.getOrderController=function(){if(this._orderController===null){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderController){this._orderController=this._editor._controllers[t];break}}}return this._orderController};BX.Crm.EntityEditorPayment.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorPayment.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorPayment.prototype.doInitialize=function(){BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onExternalChange,this));BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onPaymentVoucherUpdate,this));BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onPaymentVoucherInited,this));this._isCreateMode=this._model.getField("ID","n0").charAt(0)==="n"};BX.Crm.EntityEditorPayment.prototype.createPaymentContent=function(t,e){if(this._mode===BX.UI.EntityEditorMode.edit){return this.createPaymentContentEdit(t,e)}else{return this.createPaymentContentView(t,e)}};BX.Crm.EntityEditorPayment.prototype.processErrors=function(t){if(t.length){var e="";for(var r=0,i=t.length-1;r<=i;r++){e+=t[r]+"\n"}if(e){this.showError(e);this._editor._toolPanel.addError(e)}}};BX.Crm.EntityEditorPayment.prototype.createPaySystemList=function(t,e){var r=this,i=BX.create("select",{props:{name:"PAYMENT["+t+"][PAY_SYSTEM_ID]"},events:{change:function(){r.onPaySystemSelect(t,this[this.selectedIndex].value,e)}}});for(var n in e.PAY_SYSTEMS_LIST){if(!e.PAY_SYSTEMS_LIST.hasOwnProperty(n)){continue}var o=e.PAY_SYSTEM_ID===e.PAY_SYSTEMS_LIST[n].ID;var s=new Option(e.PAY_SYSTEMS_LIST[n].NAME,e.PAY_SYSTEMS_LIST[n].ID,o,o);i.options.add(s)}return i};BX.Crm.EntityEditorPayment.prototype.createLogo=function(t,e){return BX.create("img",{props:{className:"crm-entity-widget-content-block-inner-order-logo",id:"crm_entity_editor_payment_logotip_"+t,src:e.PAY_SYSTEM_LOGO_PATH,alt:e.PAY_SYSTEM_NAME}})};BX.Crm.EntityEditorPayment.prototype.createSumInput=function(t,e){return BX.create("input",{props:{className:"crm-entity-widget-content-input",name:"PAYMENT["+t+"][SUM]",id:"crm_entity_editor_is_payment_sum_"+t,type:"text",value:e.FORMATTED_SUM,size:40},events:{change:BX.delegate((function(e){this.onPaymentSumChanged(e,t)}),this),input:BX.delegate(this.onPaymentSumInput,this)}})};BX.Crm.EntityEditorPayment.prototype.createPaidInput=function(t,e){return BX.create("input",{props:{name:"PAYMENT["+t+"][PAID]",id:"crm_entity_editor_is_payment_paid_input_"+t,type:"hidden",value:e.PAID}})};BX.Crm.EntityEditorPayment.prototype.createIsReturnInput=function(t,e){return BX.create("input",{props:{name:"PAYMENT["+t+"][IS_RETURN]",id:"crm_entity_editor_is_payment_paid_is_return_"+t,type:"hidden",value:e.IS_RETURN}})};BX.Crm.EntityEditorPayment.prototype.createCurrency=function(t,e){return BX.create("span",{props:{className:"crm-entity-widget-content-block-wallet"},html:e.CURRENCY_NAME})};BX.Crm.EntityEditorPayment.prototype.creatDatePaid=function(t,e){return BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls-text"},html:e.DATE_PAID})};BX.Crm.EntityEditorPayment.prototype.createPaymentContentEdit=function(t,e){var r=this.getItemField(t,"PAID")==="Y";this._isPaidButtonMenuOpened[t]=false;this._paidButtons[t]=this.createPaymentButton(t,r);this._paySystemInputs[t]=this.createPaySystemList(t,e);this._logoImg[t]=this.createLogo(t,e);this._sumInput[t]=this.createSumInput(t,e);this._paidInput[t]=this.createPaidInput(t,e);this._isReturn[t]=this.createIsReturnInput(t,e);this._currency[t]=this.createCurrency(t,e);this._datePaid[t]=this.creatDatePaid(t,e);var i=BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title"},children:[BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{width:"100%"},children:[BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._paySystemInputs[t]]})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-container"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-left"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-logo-container"},children:[this._logoImg[t]]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-right"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-money"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:this.getMessage("sum")})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner crm-entity-widget-content-block-colums-input"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-input-wrapper"},children:[this._sumInput[t],this._currency[t]]})]})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-custom"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls-row"},children:[this._paidButtons[t],this._datePaid[t],this._paidInput[t],this._isReturn[t]]})]})]})]})]})]})]})]})]});if(BX.type.isNotEmptyString(e.VOUCHER_INFO)){text=this.getMessage("documentTitle")+": "+e.VOUCHER_INFO}else{text=this.getMessage("addDocument")}this._documentLinks[e.ID]=BX.create("a",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:text,events:{click:BX.delegate((function(t){this.onAddDocumentClick(t,e.ID,r)}),this)}});if(BX.prop.getNumber(e,"ID",0)===0){this._documentInnerData[e.ID]={index:t,values:{PAY_VOUCHER_NUM:BX.prop.getString(e,"PAY_VOUCHER_NUM",""),PAY_VOUCHER_DATE:BX.prop.getString(e,"PAY_VOUCHER_DATE","")}}}i.appendChild(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this._documentLinks[e.ID]]}));return i};BX.Crm.EntityEditorPayment.prototype.onPaymentSumChanged=function(t,e){t=t||window.event;var r=t.target||t.srcElement,i=this;this._customPaymentSumm[e]=true;var n=r.value.split(" ").join("");i.setItemField(e,"SUM",n);this._editor.formatMoney(n,this.getModel().getField("CURRENCY",""),(function(t){if(t.FORMATTED_SUM){i.setItemField(e,"FORMATTED_SUM",t.FORMATTED_SUM)}if(t.FORMATTED_SUM_WITH_CURRENCY){i.setItemField(e,"FORMATTED_SUM_WITH_CURRENCY",t.FORMATTED_SUM_WITH_CURRENCY)}}))};BX.Crm.EntityEditorPayment.prototype.onPaymentSumInput=function(t){t.target.value=BX.Currency.Editor.getFormattedValue(t.target.value,this.getModel().getField("CURRENCY",""))};BX.Crm.EntityEditorPayment.prototype.createPaySystemName=function(t,e){return BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title-text"},html:e.PAY_SYSTEM_NAME}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title-desc"},children:[BX.create("a",{style:{cursor:"pointer"},html:e.NUMBER_AND_DATE,events:{click:BX.proxy((function(){this.getOrderController().openDetailSlider("/shop/orders/payment/details/"+parseInt(e.ID)+"/")}),this)}})]})]})};BX.Crm.EntityEditorPayment.prototype.openPaymentDetail=function(t){if(this._editor.isChanged()){BX.UI.EditorAuxiliaryDialog.create("order_save_confirmation",{title:this.getMessage("saveChanges"),content:this.getMessage("saveConfirm"),buttons:[{id:"save",type:BX.Crm.DialogButtonType.accept,text:this.getMessage("save"),callback:BX.proxy((function(e){this._editor.saveChanged();BX.Crm.Page.openSlider("/shop/orders/payment/details/"+parseInt(t)+"/");e.getDialog().close()}),this)},{id:"cancel",type:BX.Crm.DialogButtonType.cancel,text:this.getMessage("notSave"),callback:function(e){BX.Crm.Page.openSlider("/shop/orders/payment/details/"+parseInt(t)+"/");e.getDialog().close()}}]}).open()}else{BX.Crm.Page.openSlider("/shop/orders/payment/details/"+parseInt(t)+"/")}};BX.Crm.EntityEditorPayment.prototype.createSumFormatted=function(t,e){return BX.create("span",{props:{className:"crm-entity-widget-content-block-colums-right"},html:e.FORMATTED_SUM_WITH_CURRENCY})};BX.Crm.EntityEditorPayment.prototype.createPaymentContentView=function(t,e){var r=e.PAID==="Y";this._isPaidButtonMenuOpened[t]=false;this._paidButtons[t]=this.createPaymentButton(t,r);this._paySystemName[t]=this.createPaySystemName(t,e);this._logoImg[t]=this.createLogo(t,e);this._sumFormatted[t]=this.createSumFormatted(t,e);this._paidInput[t]=this.createPaidInput(t,e);this._isReturn[t]=this.createIsReturnInput(t,e);this._datePaid[t]=this.creatDatePaid(t,e);var i=BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box"},children:[this._paySystemName[t],BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-container"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-left"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-logo-container"},children:[this._logoImg[t]]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-right"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-money"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:this.getMessage("sum")})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-colums-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-wallet"},children:[this._sumFormatted[t]]})]})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-custom"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls-row"},children:[this._paidButtons[t],this._datePaid[t],this._paidInput[t],this._isReturn[t]]})]})]})]})]})]})]})]})]});if(BX.type.isNotEmptyString(e.VOUCHER_INFO)){text=this.getMessage("documentTitle")+": "+e.VOUCHER_INFO}else{text=this.getMessage("addDocument")}this._documentLinks[e.ID]=BX.create("a",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:text,events:{click:BX.delegate((function(t){this.onAddDocumentClick(t,e.ID,r)}),this)}});i.appendChild(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this._documentLinks[e.ID]]}));return i};BX.Crm.EntityEditorPayment.prototype.createPaymentButton=function(t,e){var r=BX.create("div",{attrs:{style:"margin-top: 10px;"},props:{className:"ui-btn-split ui-btn-sm "+(e?"ui-btn-success-light":"ui-btn-danger-light"),id:"crm_entity_editor_is_payment_paid_button_"+t},children:[BX.create("button",{props:{className:"ui-btn-main",id:"crm_entity_editor_is_payment_paid_button_main_"+t},html:e?this.getMessage("paymentWasPaid"):this.getMessage("paymentWasNotPaid")}),BX.create("button",{props:{className:"ui-btn-extra"}})]});BX.bind(r,"click",BX.delegate((function(e){this.onPaidButtonClick(e,t)}),this));return r};BX.Crm.EntityEditorPayment.prototype.layout=function(t){if(this._hasLayout){return}var e=this.getValue();this._wrapper=BX.create("div");this._view=null;var r=this.isDragEnabled();if(r){this._wrapper.appendChild(this.createDragButton())}var i=this.isContextMenuEnabled();if(this.checkIfNotEmpty(e)){this._view=BX.create("div");if(e&&e.length){for(var n=0,o=e.length;n<o;n++){this._paymentBlocks[n]=this.createPaymentContent(n,e[n]);this._view.appendChild(this._paymentBlocks[n])}}this._wrapper.appendChild(this._view)}if(i){this._wrapper.appendChild(this.createContextMenuButton())}if(r){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorPayment.prototype.setPaidStatus=function(t,e,r){this.setItemField(r,"PAID",t);this.setItemField(r,"IS_RETURN",e)};BX.Crm.EntityEditorPayment.prototype.onPaidButtonClick=function(t,e){this.togglePaidButtonMenu(e);t.preventDefault()};BX.Crm.EntityEditorPayment.prototype.onAddDocumentClick=function(t,e,r){var i=this._schemeElement.getDataStringParam("addPaymentDocumentUrl","");var n={paymentId:e,paymentType:this._documentType.voucher};if(BX.type.isNotEmptyObject(this._documentInnerData[e])){var o=this._documentInnerData[e].values;for(var s in o){if(o.hasOwnProperty(s)){n["ENTITY_DATA["+s+"]"]=o[s]}}}i=BX.util.add_url_param(i,n);BX.Crm.Page.openSlider(i,{width:500})};BX.Crm.EntityEditorPayment.prototype.getPaymentIndexById=function(t){if(BX.type.isNotEmptyObject(this.getModel().getField("PAYMENT"))){var e=this.getModel().getField("PAYMENT");for(var r in e){if(e.hasOwnProperty(r)&&e[r]["ID"]==t){return r}}}return false};BX.Crm.EntityEditorPayment.prototype.onPaymentVoucherUpdate=function(t){if(t.getEventId()==="CrmOrderPaymentVoucher::Update"){var e=t.getData();var r=BX.prop.getString(e,"entityId",0);var i=this.getPaymentIndexById(r);if(i===false){return}if(BX.prop.getInteger(e,"entityTypeId",0)!==BX.CrmEntityType.enumeration.orderpayment){return}if(BX.prop.getString(e,"source","")!=="ORDER_PAYMENT"){return}if(BX.type.isDomNode(this._documentLinks[r])){var n=BX.prop.getString(e,"PAY_VOUCHER_NUM","");var o=BX.prop.getString(e,"PAY_VOUCHER_DATE","");var s="";if(BX.type.isNotEmptyString(n)){var a=BX.util.htmlspecialchars(n);if(BX.type.isNotEmptyString(o)){a+=" "+BX.util.htmlspecialchars(o)}s=this.getMessage("documentTitle")+": "+a}else{s=this.getMessage("addDocument")}this._documentLinks[r].innerHTML=s;if(BX.type.isNotEmptyObject(this._documentInnerData[r])){this._documentInnerData[r]["values"]["PAY_VOUCHER_NUM"]=n;this._documentInnerData[r]["values"]["PAY_VOUCHER_DATE"]=o}}for(var d in e){if(d==="entityId"||d==="entityTypeId"){continue}if(e.hasOwnProperty(d)){this.setItemField(i,d,BX.prop.getString(e,d,""))}}if(!this._isCreateMode){if(this._editor.isChanged()){this.markAsChanged();this.getOrderController().onDataChanged()}else{var l=e;l["PAYMENT_ID"]=r;var c="setPaymentPaidField";if(l["IS_RETURN"]){c="setPaymentReturnField"}this.getOrderController().ajax(c,{data:{FIELDS:l}},{skipMarkAsChanged:true,needProductComponentParams:this.getOrderController().isProductListLoaded()})}}}};BX.Crm.EntityEditorPayment.prototype.onPaymentVoucherInited=function(t){if(t.getEventId()==="CrmOrderPaymentVoucher::Initialized"){var e=t.getData(),r=BX.prop.getString(e,"entityId",0),i=this.getPaymentIndexById(r);if(BX.prop.getInteger(e,"entityTypeId",0)!==BX.CrmEntityType.enumeration.orderpayment||!e.voucherObject){return}var n=e.voucherObject;n.setField("PAY_VOUCHER_NUM",this.getItemField(i,"PAY_VOUCHER_NUM"));n.setField("PAY_VOUCHER_DATE",this.getItemField(i,"PAY_VOUCHER_DATE"));n.setField("PAY_RETURN_NUM",this.getItemField(i,"PAY_RETURN_NUM"));n.setField("PAY_RETURN_DATE",this.getItemField(i,"PAY_RETURN_DATE"));n.setField("PAY_RETURN_COMMENT",this.getItemField(i,"PAY_RETURN_COMMENT"));n.setField("PAID",this.getItemField(i,"PAID"));n.setField("source","ORDER_PAYMENT");if(this.getItemField(i,"PAID")==="N"){var o=this.getItemField(i,"IS_RETURN");if(o==="Y"||o==="P"){n.setField("IS_RETURN",o)}}}};BX.Crm.EntityEditorPayment.prototype.onExternalChange=function(t){i=false;if(t.getEventId()==="CrmOrderPayment::Update"){var e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.orderpayment){var r=this.getValue();var i=false;for(var n=0;n<r.length;n++){if(r[n].ID==e.field.ID){if(BX.type.isNotEmptyString(e.field.PAID)){r[n].PAID=e.field.PAID==="Y"?"Y":"N"}if(BX.type.isNotEmptyString(e.field.FORMATTED_SUM_WITH_CURRENCY)){r[n].FORMATTED_SUM_WITH_CURRENCY=BX.util.htmlspecialchars(e.field.FORMATTED_SUM_WITH_CURRENCY)}if(BX.type.isNotEmptyString(e.field.FORMATTED_SUM)){r[n].FORMATTED_SUM=BX.util.htmlspecialchars(e.field.FORMATTED_SUM)}if(BX.type.isNotEmptyString(e.field.PAY_SYSTEM_NAME)){r[n].PAY_SYSTEM_NAME=BX.util.htmlspecialchars(e.field.PAY_SYSTEM_NAME)}if(BX.type.isNotEmptyString(e.field.PAY_SYSTEM_LOGO)){r[n].PAY_SYSTEM_LOGO_PATH=e.field.PAY_SYSTEM_LOGO}if(BX.type.isNotEmptyString(e.field.FORMATED_TITLE_WITH_DATE_BILL)){r[n].NUMBER_AND_DATE=BX.util.htmlspecialchars(e.field.FORMATED_TITLE_WITH_DATE_BILL)}i=true}}}}else if(t.getEventId()==="CrmOrderPayment::Create"){r=this.getValue();e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.orderpayment&&BX.type.isNotEmptyString(e.field.ID)){var o={ID:e.field.ID,PAID:e.field.PAID==="Y"?"Y":"N",NUMBER_AND_DATE:BX.util.htmlspecialchars(e.field.FORMATED_TITLE_WITH_DATE_BILL)||"",PAY_SYSTEM_LOGO_PATH:BX.util.htmlspecialchars(e.field.PAY_SYSTEM_LOGO)||"",PAY_SYSTEM_NAME:BX.util.htmlspecialchars(e.field.PAY_SYSTEM_NAME)||"",FORMATTED_SUM_WITH_CURRENCY:BX.util.htmlspecialchars(e.field.FORMATTED_SUM_WITH_CURRENCY)||"",FORMATTED_SUM:BX.util.htmlspecialchars(e.field.FORMATTED_SUM)||""};r.push(o);i=true;this._paymentBlocks[r.length-1]=this.createPaymentContent(r.length-1,o);this._view.appendChild(this._paymentBlocks[r.length-1])}}else if(t.getEventId()==="CrmOrderPayment::Delete"){r=this.getValue();e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.orderpayment&&parseInt(e.ID)>0){for(var n in r){if(r[n].ID==e.ID){r.splice(n,1);this._view.removeChild(this._paymentBlocks[n]);break}}i=true}}if(i){this._model.setField(this.getName(),r,{originator:this});this.refreshLayout();var s={entityData:this._model.getData()};BX.onCustomEvent(window,BX.Crm.EntityEvent.names.update,[s])}};BX.Crm.EntityEditorPayment.prototype.togglePaidButtonMenu=function(t){if(this._isPaidButtonMenuOpened[t]){this.closePaidButtonMenu(t)}else{this.openPaidButtonMenu(t)}};BX.Crm.EntityEditorPayment.prototype.closePaidButtonMenu=function(t){if(!this._isPaidButtonMenuOpened[t]){return}var e=BX.PopupMenu.getMenuById(this._id);if(e){e.popupWindow.close()}this._isPaidButtonMenuOpened[t]=false};BX.Crm.EntityEditorPayment.prototype.setPaidButtonView=function(t,e){var r=BX("crm_entity_editor_is_payment_paid_button_"+t),i=BX("crm_entity_editor_is_payment_paid_button_main_"+t);if(e){BX.removeClass(r,"ui-btn-danger-light");BX.addClass(r,"ui-btn-success-light");i.innerHTML=this.getMessage("paymentWasPaid")}else{BX.removeClass(r,"ui-btn-success-light");BX.addClass(r,"ui-btn-danger-light");i.innerHTML=this.getMessage("paymentWasNotPaid")}};BX.Crm.EntityEditorPayment.prototype.openPaidButtonMenu=function(t){var e=this,r=BX("crm_entity_editor_is_payment_paid_input_"+t),i=BX("crm_entity_editor_is_payment_paid_is_return_"+t);var n=function(n,o){var s=BX.prop.getString(o,"value");if(s==="CANCEL"||s==="RETURN"){if(s==="RETURN"){i.value="Y";if(!e._isCreateMode){BX.Crm.Page.openSlider(e.getItemField(t,"PAY_RETURN_URL"),{width:500})}}else{r.value="N";if(!e._isCreateMode){BX.Crm.Page.openSlider(e.getItemField(t,"PAY_CANCEL_URL"),{width:500})}}}else if(s==="SET_PAID"){r.value="Y";i.value="N";if(!e._isCreateMode){if(e._editor.isChanged()){e.setPaidStatus(r.value,i.value,t);e.markAsChanged();e.getOrderController().onDataChanged()}else{e.getOrderController().ajax("setPaymentPaidField",{data:{FIELDS:{PAID:"Y",PAYMENT_ID:e.getItemField(t,"ID")}}},{skipMarkAsChanged:true,needProductComponentParams:e.getOrderController().isProductListLoaded()})}}}e.closePaidButtonMenu(t);e.setPaidStatus(r.value,i.value,t);e.setPaidButtonView(t,r.value==="Y")};if(r.value==="Y"){if(this._isCreateMode){var o=[{value:"CANCEL",text:this.getMessage("paymentWasNotPaid"),onclick:n}]}else{o=[{value:"CANCEL",text:this.getMessage("paymentCancel"),onclick:n},{value:"RETURN",text:this.getMessage("paymentReturn"),onclick:n}]}}else{o=[{value:"SET_PAID",text:this.getMessage("paymentWasPaid"),onclick:n}]}BX.PopupMenu.show(this._id,this._paidButtons[t],o,{angle:false,events:{onPopupShow:BX.proxy((function(){this.onMenuShow(t)}),this),onPopupClose:BX.delegate(this.onMenuClose,this)}})};BX.Crm.EntityEditorPayment.prototype.onMenuShow=function(t){this._isPaidButtonMenuOpened[t]=true};BX.Crm.EntityEditorPayment.prototype.onMenuClose=function(){BX.PopupMenu.destroy(this._id)};BX.Crm.EntityEditorPayment.prototype.refreshLayout=function(){if(!this._hasLayout){return}var t=this._model.getField(this.getName()),e;this.clearError();if(this._mode===BX.UI.EntityEditorMode.view){for(var r in t){if(t.hasOwnProperty(r)){e=this.createPaymentContent(r,t[r]);this._paymentBlocks[r].parentNode.replaceChild(e,this._paymentBlocks[r]);this._paymentBlocks[r]=e;this._paidInput[r].value=t[r].PAID;this._sumFormatted[r]=this.createSumFormatted(r,t[r]);if(t[r].ERRORS){this.processErrors(t[r].ERRORS)}}}}else{for(r in t){if(t.hasOwnProperty(r)){if(typeof t[r].FORMATTED_SUM!=="undefined"){this._sumInput[r].value=t[r].FORMATTED_SUM}if(typeof t[r].CURRENCY_NAME!=="undefined"){var i=this.createCurrency(r,t[r]);this._currency[r].parentNode.replaceChild(i,this._currency[r]);this._currency[r]=i}e=this.createPaymentContent(r,t[r]);this._paymentBlocks[r].parentNode.replaceChild(e,this._paymentBlocks[r]);this._paymentBlocks[r]=e;this.setPaySystem(r,t[r]);this._logoImg[r].src=t[r].PAY_SYSTEM_LOGO_PATH;this._datePaid[r].value=t[r].DATE_PAID;this._isReturn[r].value=t[r].IS_RETURN;this._paidInput[r].value=t[r].PAID;this.setPaidButtonView(r,t[r].PAID==="Y");if(t[r].ERRORS){this.processErrors(t[r].ERRORS)}}}}};BX.Crm.EntityEditorPayment.prototype.setCurrency=function(t,e){if(this._mode===BX.UI.EntityEditorMode.edit){this._paySystemInputs[t].value=e.PAY_SYSTEM_ID}else{this._paySystemName[t]=this.createPaySystemName(t,e)}};BX.Crm.EntityEditorPayment.prototype.setPaySystem=function(t,e){if(this._mode===BX.UI.EntityEditorMode.edit){this._paySystemInputs[t].value=parseInt(e.PAY_SYSTEM_ID)>0?e.PAY_SYSTEM_ID:0}else{this._paySystemName[t]=this.createPaySystemName(t,e)}};BX.Crm.EntityEditorPayment.prototype.getRuntimeValue=function(){return this.getModel().getField(this.getName())};BX.Crm.EntityEditorPayment.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}if(this._isCreateMode){var e=0;if(!this._customPaymentSumm[e]){var r=this._editor._model;this.setItemField(e,"SUM",r.getField("PRICE"));this.setItemField(e,"FORMATTED_SUM_WITH_CURRENCY",r.getField("FORMATTED_PRICE_WITH_CURRENCY"));this.setItemField(e,"FORMATTED_SUM",r.getField("FORMATTED_PRICE"));this.setItemField(e,"CURRENCY",r.getField("CURRENCY"))}}this.refreshLayout()};BX.Crm.EntityEditorPayment.create=function(t,e){var r=new BX.Crm.EntityEditorPayment;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorShipment==="undefined"){BX.Crm.EntityEditorShipment=function(){BX.Crm.EntityEditorShipment.superclass.constructor.apply(this);this._view=null;this._isCreateMode=false;this._documentLinks={};this._documentInnerData={};this._deliverySelectors={};this._profileSelectors={};this._deliveryInputs={};this._storeSelectors={};this._inputStores={};this._priceDeliveryInputs={};this._logoImg={};this._currency={};this._headBlocks={};this._shipmentBlocks={};this._extraServices={};this._discounts={};this._isDeliveryAllowedCheckboxes={};this._isDeductedCheckboxes={};this._orderController=null};BX.extend(BX.Crm.EntityEditorShipment,BX.Crm.EntityEditorField);if(typeof BX.Crm.EntityEditorShipment.messages==="undefined"){BX.Crm.EntityEditorShipment.messages={}}BX.Crm.EntityEditorShipment.prototype.doInitialize=function(){BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onExternalChange,this));this._isCreateMode=this._model.getField("ID",0)<=0};BX.Crm.EntityEditorShipment.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorShipment.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorShipment.prototype.getItemField=function(t,e){var r=this._model.getField(this.getName()),i="";if(r[t]&&r[t]&&r[t][e]){i=r[t][e]}return i};BX.Crm.EntityEditorShipment.prototype.setItemField=function(t,e,r){var i=this._model.getField(this.getName());if(i[t]){i[t][e]=r;this._model.setField(this.getName(),i,{originator:this})}};BX.Crm.EntityEditorShipment.prototype.getOrderController=function(){if(this._orderController===null){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderController){this._orderController=this._editor._controllers[t];break}}}return this._orderController};BX.Crm.EntityEditorShipment.prototype.createDeliverySelector=function(t){return BX.create("select",{events:{change:BX.proxy((function(){this.onSelectorChange(t,"delivery")}),this)}})};BX.Crm.EntityEditorShipment.prototype.createProfileSelector=function(t){return BX.create("select",{events:{change:BX.proxy((function(){this.onSelectorChange(t,"profile")}),this)}})};BX.Crm.EntityEditorShipment.prototype.setOptionsList=function(t,e,r){return BX.Crm.EntityEditorDeliverySelector.prototype.setOptionsList(t,e,r)};BX.Crm.EntityEditorShipment.prototype.obtainValueFromSelectors=function(t,e,r,i){return BX.Crm.EntityEditorDeliverySelector.prototype.obtainValueFromSelectors(t,e,r,i)};BX.Crm.EntityEditorShipment.prototype.onSelectorChange=function(t,e){this._deliveryInputs[t].value=this.obtainValueFromSelectors(e,this._deliverySelectors[t],this._profileSelectors[t],this._mode);this.setItemField(t,"DELIVERY_ID",this._deliveryInputs[t].value);this.markAsChanged();this.getOrderController().onChangeDelivery(t)};BX.Crm.EntityEditorShipment.prototype.getHeadBlock=function(t){var e=null;if(this._isCreateMode){this._deliverySelectors[t]=this.createDeliverySelector(t);this.setOptionsList(this._deliverySelectors[t],this.getItemField(t,"DELIVERY_SERVICES_LIST"),this.getItemField(t,"DELIVERY_SELECTOR_DELIVERY_ID"));var r=this.getItemField(t,"DELIVERY_PROFILES_LIST");if(BX.type.isNotEmptyObject(r)){this._profileSelectors[t]=this.createProfileSelector(t);this.setOptionsList(this._profileSelectors[t],r,this.getItemField(t,"DELIVERY_SELECTOR_PROFILE_ID"))}else{delete this._profileSelectors[t]}this._deliveryInputs[t]=BX.create("input",{props:{type:"hidden",name:"SHIPMENT["+t+"][DELIVERY_ID]",value:this.getItemField(t,"DELIVERY_ID")}});var i=this.getItemField(t,"DELIVERY_STORES_LIST");if(BX.type.isNotEmptyObject(i)){this._storeSelectors[t]=this.createStoreSelector(t);this.setOptionsList(this._storeSelectors[t],i,this.getItemField(t,"DELIVERY_STORE_ID"));this.createInputStore(t)}else{delete this._storeSelectors[t]}e=BX.create("div",{style:{width:"100%"},children:[BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{width:"100%"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},style:{marginTop:"-6px"},children:[BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:this.getMessage("deliveryService")})]}),BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._deliverySelectors[t],this._deliveryInputs[t]]})]})]});if(this._profileSelectors[t]){e.appendChild(BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{width:"100%"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},style:{marginTop:"3px"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},text:this.getMessage("profile")})]}),BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._profileSelectors[t]]})]}))}if(this._storeSelectors[t]){e.appendChild(BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{marginTop:"20px"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},style:{marginTop:"-16px"},children:[BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:this.getMessage("deliveryStore")})]}),BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._storeSelectors[t],this.getInputStore(t)]})]}),e)}e=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title"},children:[e]})}else{e=this.createDeliveryServiceName(t)}return e};BX.Crm.EntityEditorShipment.prototype.createDeliveryServiceName=function(t){return BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title-text"},html:this.getItemField(t,"DELIVERY_SERVICE_NAME")}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title-desc"},children:[BX.create("a",{style:{cursor:"pointer"},html:this.getItemField(t,"NUMBER_AND_DATE"),events:{click:BX.proxy((function(){this.getOrderController().openDetailSlider("/shop/orders/shipment/details/"+parseInt(this.getItemField(t,"ID"))+"/")}),this)}})]})]})};BX.Crm.EntityEditorShipment.prototype.getInputStore=function(t){if(!this._inputStores[t]){this.createInputStore(t)}return this._inputStores[t]};BX.Crm.EntityEditorShipment.prototype.createInputStore=function(t){if(this._inputStores[t]){return}this._inputStores[t]=BX.create("input",{props:{type:"hidden",name:"SHIPMENT["+t+"][DELIVERY_STORE_ID]",value:this.getItemField(t,"DELIVERY_STORE_ID")}})};BX.Crm.EntityEditorShipment.prototype.createStoreSelector=function(t){return BX.create("select",{events:{change:BX.proxy((function(){this.onStoreChange(t)}),this)}})};BX.Crm.EntityEditorShipment.prototype.onStoreChange=function(t){this.getInputStore(t).value=this._storeSelectors[t].value;this.setItemField(t,"DELIVERY_STORE_ID",this._storeSelectors[t].value);this.markAsChanged()};BX.Crm.EntityEditorShipment.prototype.processErrors=function(t){if(t.length){var e="";for(var r=0,i=t.length-1;r<=i;r++){e+=t[r]+"\n"}if(e){this.showError(e)}}};BX.Crm.EntityEditorShipment.prototype.onPriceDeliveryChange=function(t,e){e=e.split(" ").join("");this.setItemField(t,"PRICE_DELIVERY",e);this.setItemField(t,"CUSTOM_PRICE_DELIVERY","Y");this.getOrderController().onDataChanged()};BX.Crm.EntityEditorShipment.prototype.onPriceDeliveryInput=function(t){t.target.value=BX.Currency.Editor.getFormattedValue(t.target.value,this.getModel().getField("CURRENCY",""))};BX.Crm.EntityEditorShipment.prototype.createCurrency=function(t,e){return BX.create("span",{props:{className:"crm-entity-widget-content-block-wallet"},html:e.CURRENCY_NAME})};BX.Crm.EntityEditorShipment.prototype.createPriceContent=function(t,e){var r=null,i=this;this._priceDeliveryInputs[t]=BX.create("input",{attrs:{className:"crm-entity-widget-content-input",name:"SHIPMENT["+t+"][PRICE_DELIVERY]",id:"crm_entity_editor_delivery_price_"+t,type:"text",value:e.FORMATTED_PRICE_DELIVERY,size:40},events:{change:function(){i.onPriceDeliveryChange(t,this.value)},input:BX.delegate(i.onPriceDeliveryInput,i)}});if(this._isCreateMode){this._currency[t]=this.createCurrency(t,e);r=BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-money"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:this.getMessage("price")})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner crm-entity-widget-content-block-colums-input"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-input-wrapper"},children:[this._priceDeliveryInputs[t],this._currency[t]]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-title price-calculated"},style:{display:"none"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},children:[BX.create("span",{html:this.getMessage("deliveryPriceCalculated")+" "}),BX.create("span",{html:"",props:{id:"crm-order-delivery-calculated-price-"+t,title:this.getMessage("deliveryPriceCalculatedHint")},style:{borderBottom:"1px dashed",cursor:"pointer"},events:{click:BX.proxy((function(){this.setItemField(t,"PRICE_DELIVERY",this.getItemField(t,"PRICE_DELIVERY_CALCULATED"));this._priceDeliveryInputs[t].value=this.getItemField(t,"FORMATTED_PRICE_DELIVERY_CALCULATED");this.setItemField(t,"CUSTOM_PRICE_DELIVERY","N");this.getOrderController().onDataChanged()}),this)}})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("div",{props:{className:"ui-btn ui-btn-light-border"},style:{marginTop:"10px"},events:{click:function(){i.getOrderController().onDataChanged()}},html:this.getMessage("refresh")})]})]})}else{r=BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-money"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:this.getMessage("price")})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-colums-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-wallet"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-colums-right",id:"crm-order-delivery-price-"+t},html:e.FORMATTED_PRICE_DELIVERY_WITH_CURRENCY})]})]})]})]})}return r};BX.Crm.EntityEditorShipment.prototype.createExtraServicesContent=function(t,e){var r=[],i=this._isCreateMode?"edit":"view",n=new BX.Crm.EntityEditorOrderExtraServicesWrapper({mode:i});if(e.EXTRA_SERVICES_DATA&&e.EXTRA_SERVICES_DATA.length){for(var o=0,s=e.EXTRA_SERVICES_DATA.length-1;o<=s;o++){n.wrapItem(e.EXTRA_SERVICES_DATA[o]).forEach((function(t,e,i){r.push(t)}))}}return r};BX.Crm.EntityEditorShipment.prototype.createDiscountsContent=function(t,e){var r=[],i=this;if(e.DISCOUNTS&&e.DISCOUNTS.length){for(var n=0,o=e.DISCOUNTS.length-1;n<=o;n++){var s=e.DISCOUNTS[n],a=BX.create("input",{props:{type:"checkbox",name:"DISCOUNTS[DELIVERY]["+s.DISCOUNT_ID+"]",value:"Y",checked:s.APPLY==="Y"},attrs:{"data-discount-id":s.DISCOUNT_ID,"data-coupon-id":s.COUPON_ID?s.COUPON_ID:"-"},events:{click:function(){i.onDiscountClick(this)}}});BX.addCustomEvent("crmOrderProductListDiscountToggle",function(t){return function(e){if(t.getAttribute("data-discount-id")==e.discountId){t.checked=e.isSet}}}(a));var d=BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-checkbox"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("label",{props:{className:"crm-entity-widget-content-block-checkbox-label"},children:[BX.create("input",{props:{type:"hidden",name:"DISCOUNTS[DELIVERY]["+s.DISCOUNT_ID+"]",value:"N"}}),a,BX.create("span",{props:{className:"crm-entity-widget-content-block-checkbox-description"},html:s.DESCR})]})]})]});r.push(d)}}return BX.create("div",{children:r})};BX.Crm.EntityEditorShipment.prototype.onDiscountClick=function(t){BX.onCustomEvent("crmOrderDetailDiscountToggle",[{discountId:t.getAttribute("data-discount-id"),isSet:t.checked}]);this.getOrderController().onDataChanged()};BX.Crm.EntityEditorShipment.prototype.createShipmentContent=function(t,e){var r=e.STATUS_CONTROL,i=BX.processHTML(r),n=null;this._isDeliveryAllowedCheckboxes[t]=BX.create("input",{props:{className:"crm-entity-widget-content-checkbox",name:"SHIPMENT["+t+"][ALLOW_DELIVERY]",value:"Y",checked:e.ALLOW_DELIVERY==="Y",type:"checkbox"}});this._isDeductedCheckboxes[t]=BX.create("input",{props:{className:"crm-entity-widget-content-checkbox",name:"SHIPMENT["+t+"][DEDUCTED]",value:"Y",checked:e.DEDUCTED==="Y",type:"checkbox"}});this._logoImg[t]=BX.create("img",{props:{className:"crm-entity-widget-content-block-inner-order-logo",id:"crm_entity_editor_delivery_logotip_"+t,src:e.DELIVERY_LOGO?e.DELIVERY_LOGO:"",alt:e.DELIVERY_SERVICE_NAME}});if(!e.DELIVERY_LOGO){this._logoImg[t].style.display="none"}this._headBlocks[t]=this.getHeadBlock(t,e);if(this._isCreateMode){BX.bind(this._isDeliveryAllowedCheckboxes[t],"change",BX.delegate((function(r){this.setItemField(t,"ALLOW_DELIVERY",r.target.checked?"Y":"N",e.ID)}),this));BX.bind(this._isDeductedCheckboxes[t],"change",BX.delegate((function(r){this.setItemField(t,"DEDUCTED",r.target.checked?"Y":"N",e.ID)}),this));this._extraServices[t]=this.createExtraServicesContent(t,e);n=BX.create("div",{props:{id:"crm-order-shipment-extra-services-"+t,className:"crm-order-shipment-extra-services-"+t},style:{background:"#f9f9f9",marginLeft:"15px",padding:"10px 0"},children:this._extraServices[t]})}else{BX.bind(this._isDeliveryAllowedCheckboxes[t],"change",BX.delegate((function(r){this.setField("ALLOW_DELIVERY",r.target.checked?"Y":"N",e.ID,t)}),this));BX.bind(this._isDeductedCheckboxes[t],"change",BX.delegate((function(r){this.setField("DEDUCTED",r.target.checked?"Y":"N",e.ID,t)}),this))}this._discounts[t]=this.createDiscountsContent(t,e);discounts=BX.create("div",{props:{id:"crm-order-shipment-discounts-"+t},style:{background:"#f9f9f9",marginLeft:"15px",width:"100%",marginTop:"20px"},children:[this._discounts[t]]});var o=BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box"},children:[this._headBlocks[t],BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-container"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-left"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-logo-container"},children:[this._logoImg[t]]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-content-right"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls"},children:[this.createPriceContent(t,e),BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-checkbox"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("label",{props:{className:"crm-entity-widget-content-block-checkbox-label"},children:[this._isDeliveryAllowedCheckboxes[t],BX.create("span",{props:{className:"crm-entity-widget-content-block-checkbox-description"},html:this.getMessage("deliveryAllowed")}),BX.create("input",{props:{type:"hidden",name:"SHIPMENT["+t+"][ALLOW_DELIVERY]",value:"N"}})]})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-checkbox"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("label",{props:{className:"crm-entity-widget-content-block-checkbox-label"},children:[this._isDeductedCheckboxes[t],BX.create("span",{props:{className:"crm-entity-widget-content-block-checkbox-description"},html:this.getMessage("deducted")}),BX.create("input",{props:{type:"hidden",name:"SHIPMENT["+t+"][DEDUCTED]",value:"N"}})]})]})]}),BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-progress"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},html:i["HTML"]})]}),n,discounts]})]})]})]})]})]});setTimeout((function(){for(var t in i["SCRIPT"]){if(!i["SCRIPT"].hasOwnProperty(t))continue;BX.evalGlobal(i["SCRIPT"][t]["JS"]);delete i["SCRIPT"][t]}}),1);if(BX.type.isNotEmptyString(e.DOCUMENT_INFO)){text=this.getMessage("documentTitle")+": "+e.DOCUMENT_INFO}else if(BX.type.isNotEmptyString(e.TRACKING_NUMBER)){text=this.getMessage("trackingNumberTitle")+": "+e.TRACKING_NUMBER}else{text=this.getMessage("addDocument")}this._documentLinks[e.ID]=BX.create("a",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:text,events:{click:BX.delegate((function(t){this.onAddDocumentClick(t,e.ID)}),this)}});if(BX.prop.getNumber(e,"ID",0)===0){this._documentInnerData[e.ID]={index:t,values:{TRACKING_NUMBER:BX.prop.getString(e,"TRACKING_NUMBER",""),DELIVERY_DOC_NUM:BX.prop.getString(e,"DELIVERY_DOC_NUM",""),DELIVERY_DOC_DATE:BX.prop.getString(e,"DELIVERY_DOC_DATE","")}}}o.appendChild(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this._documentLinks[e.ID]]}));return o};BX.Crm.EntityEditorShipment.prototype.onAddDocumentClick=function(t,e){var r=this._schemeElement.getDataStringParam("addShipmentDocumentUrl","");var i={shipment_id:e};if(BX.type.isNotEmptyObject(this._documentInnerData[e])){var n=this._documentInnerData[e].values;for(var o in n){if(n.hasOwnProperty(o)){i["ENTITY_DATA["+o+"]"]=n[o]}}}r=BX.util.add_url_param(r,i);BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onDocumentUpdate,this));BX.Crm.Page.openSlider(r,{width:500})};BX.Crm.EntityEditorShipment.prototype.getRuntimeValue=function(){return this.getModel().getField(this.getName())};BX.Crm.EntityEditorShipment.prototype.onDocumentUpdate=function(t){if(t.getEventId()==="CrmOrderShipmentDocument::Update"){var e=t.getData();var r=BX.prop.getString(e,"entityId",0);if(BX.prop.getInteger(e,"entityTypeId",0)!==BX.CrmEntityType.enumeration.ordershipment||!BX.type.isDomNode(this._documentLinks[r])){return}var i=BX.prop.getString(e,"deliveryDocNum","");var n=BX.prop.getString(e,"trackingNumber","");var o=BX.prop.getString(e,"deliveryDocDate","");var s="";if(BX.type.isNotEmptyString(i)){var a=BX.util.htmlspecialchars(i);if(BX.type.isNotEmptyString(o)){a+=" "+BX.util.htmlspecialchars(o)}s=this.getMessage("documentTitle")+": "+a}else{if(BX.type.isNotEmptyString(n)){s=this.getMessage("trackingNumberTitle")+": "+n}else{s=this.getMessage("addDocument")}}this._documentLinks[r].innerHTML=s;if(BX.type.isNotEmptyObject(this._documentInnerData[r])){this._documentInnerData[r]["values"]["TRACKING_NUMBER"]=n;this._documentInnerData[r]["values"]["DELIVERY_DOC_NUM"]=i;this._documentInnerData[r]["values"]["DELIVERY_DOC_DATE"]=o;var d=this._documentInnerData[r]["index"];var l=this._model.getField(this.getName());if(BX.type.isNotEmptyObject(l[d])){l[d]["TRACKING_NUMBER"]=n;l[d]["DELIVERY_DOC_NUM"]=i;l[d]["DELIVERY_DOC_DATE"]=o;this._model.setField(this.getName(),l)}}}};BX.Crm.EntityEditorShipment.prototype.layout=function(t){if(this._hasLayout){return}var e=this.getValue();this._wrapper=BX.create("div");this._view=null;var r=this.isDragEnabled();if(r){this._wrapper.appendChild(this.createDragButton())}var i=this.isContextMenuEnabled();if(this.checkIfNotEmpty(e)){this._view=BX.create("div");if(e&&e.length){for(var n=0,o=e.length;n<o;n++){this._shipmentBlocks[n]=this.createShipmentContent(n,e[n]);this._view.appendChild(this._shipmentBlocks[n])}}this._wrapper.appendChild(this._view)}if(i){this._wrapper.appendChild(this.createContextMenuButton())}if(r){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorShipment.prototype.setField=function(t,e,r,i){if(this._editor.isChanged()){this.setItemField(i,t,e);this.markAsChanged();this.getOrderController().onDataChanged()}else{this.getOrderController().ajax("setShipmentField",{data:{SHIPMENT_ID:r,FIELD_NAME:t,FIELD_VALUE:e}},{skipMarkAsChanged:true,needProductComponentParams:this.getOrderController().isProductListLoaded()})}};BX.Crm.EntityEditorShipment.prototype.setCalculatedPrice=function(t,e,r){var i=BX("crm-order-delivery-calculated-price-"+t);if(!i){return}if(r){i.innerHTML=r}i.parentNode.parentNode.style.display=e?"":"none"};BX.Crm.EntityEditorShipment.prototype.refreshLayout=function(){if(!this._hasLayout){return}var t=this._model.getField(this.getName());this.clearError();for(var e in t){if(t.hasOwnProperty(e)){var r=this.getHeadBlock(e);this._headBlocks[e].parentNode.replaceChild(r,this._headBlocks[e]);this._headBlocks[e]=r;this._isDeliveryAllowedCheckboxes[e].checked=t[e].ALLOW_DELIVERY==="Y";this._isDeductedCheckboxes[e].checked=t[e].DEDUCTED==="Y";if(t[e].DELIVERY_LOGO){this._logoImg[e].src=t[e].DELIVERY_LOGO;this._logoImg[e].style.display=""}else{this._logoImg[e].style.display="none";this._logoImg[e].src=""}if(this._isCreateMode){this._priceDeliveryInputs[e].value=t[e].FORMATTED_PRICE_DELIVERY;if(t[e].CUSTOM_PRICE_DELIVERY==="Y"&&parseFloat(t[e].PRICE_DELIVERY_CALCULATED)!==parseFloat(t[e].PRICE_DELIVERY)){this.setCalculatedPrice(e,true,t[e].FORMATTED_PRICE_DELIVERY_CALCULATED_WITH_CURRENCY)}else{this.setCalculatedPrice(e,false)}var i=this.createCurrency(e,t[e]);this._currency[e].parentNode.replaceChild(i,this._currency[e]);this._currency[e]=i;this._extraServices[e]=this.createExtraServicesContent(e,t[e]);this.insertExtraServicestoContainer(e,this._extraServices[e])}else{BX("crm-order-delivery-price-"+e).innerHTML=t[e].FORMATTED_PRICE_DELIVERY_WITH_CURRENCY}this._discounts[e]=this.createDiscountsContent(e,t[e]);this.insertDiscountsToContainer(e,this._discounts[e]);if(t[e].ERRORS){this.processErrors(t[e].ERRORS)}}}};BX.Crm.EntityEditorShipment.prototype.insertExtraServicestoContainer=function(t,e){var r=BX("crm-order-shipment-extra-services-"+t);if(r){r.innerHTML="";if(e){e.forEach((function(t,e,i){r.appendChild(t)}))}}};BX.Crm.EntityEditorShipment.prototype.insertDiscountsToContainer=function(t,e){var r=BX("crm-order-shipment-discounts-"+t);if(!r||!e){return}if(r.childNodes[0]){r.replaceChild(e,r.childNodes[0])}else{r.appendChild(e)}};BX.Crm.EntityEditorShipment.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}this.refreshLayout()};BX.Crm.EntityEditorShipment.prototype.onExternalChange=function(t){n=false;if(t.getEventId()==="CrmOrderShipment::Update"){var e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.ordershipment){var r=["DEDUCTED","ALLOW_DELIVERY","FORMATTED_PRICE_DELIVERY_WITH_CURRENCY","DELIVERY_SERVICE_NAME","DELIVERY_SERVICES_LIST","DELIVERY_PROFILES_LIST","STATUS_CONTROL","DELIVERY_LOGO","DELIVERY_SELECTOR_DELIVERY_ID","DELIVERY_SELECTOR_PROFILE_ID","DELIVERY_ID","PRICE_DELIVERY","BASE_PRICE_DELIVERY","EXTRA_SERVICES_DATA","TRACKING_NUMBER","COMMENTS"],i=this.getValue(),n=false;for(var o=0;o<i.length;o++){if(i[o].ID==e.field.ID){for(var s=r.length-1;s>=0;s--){if(typeof e.field[r[s]]!=="undefined"){i[o][r[s]]=e.field[r[s]]}}n=true}}}}else if(t.getEventId()==="CrmOrderShipment::Create"){i=this.getValue();e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.ordershipment&&BX.type.isNotEmptyString(e.field.ID)){var a=e.field;i.push(a);this._shipmentBlocks[i.length-1]=this.createShipmentContent(i.length-1,a);this._view.appendChild(this._shipmentBlocks[i.length-1]);n=true}}else if(t.getEventId()==="CrmOrderShipment::Delete"){i=this.getValue();e=t.getData();if(e.entityTypeId==BX.CrmEntityType.enumeration.ordershipment&&parseInt(e.ID)>0){for(var o in i){if(i[o].ID==e.ID){i.splice(o,1);this._view.removeChild(this._shipmentBlocks[o]);break}}n=true}}if(n){this._model.setField(this.getName(),i);this.refreshLayout();var d={entityData:this._model.getData()};BX.onCustomEvent(window,BX.Crm.EntityEvent.names.update,[d])}};BX.Crm.EntityEditorShipment.create=function(t,e){var r=new BX.Crm.EntityEditorShipment;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorPaymentStatus==="undefined"){BX.Crm.EntityEditorPaymentStatus=function(){BX.Crm.EntityEditorPaymentStatus.superclass.constructor.apply(this);this._view=null;this._isPaidButtonMenuOpened={};this._isCreateMode=false;this._paidButtons={};this._paymentController=null};BX.extend(BX.Crm.EntityEditorPaymentStatus,BX.Crm.EntityEditorField);BX.Crm.EntityEditorPaymentStatus.prototype.layout=function(t){if(this._hasLayout){return}var e=this.getValue();this.ensureWrapperCreated({classNames:["crm-entity-widget-content-block-field-select"]});this.adjustWrapper();this._view=null;var r=this.isDragEnabled();if(r){this._wrapper.appendChild(this.createDragButton())}var i=this.isContextMenuEnabled();this._view=BX.create("div");var n=e.isPaid==="Y",o=0;var s=this.getTitle();this._wrapper.appendChild(this.createTitleNode(s));this._paidButtons[o]=this.createPaymentButton(o,n);var a=BX.create("div",{props:{className:"crm-entity-widget-content-block crm-entity-widget-content-block-field-custom"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls-row"},children:[this._paidButtons[o],BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-order-controls-text"},html:e.DATE_PAID})]})]})]})]});this._view.appendChild(a);this._wrapper.appendChild(this._view);if(i){this._wrapper.appendChild(this.createContextMenuButton())}if(r){this.initializeDragDropAbilities()}t["preservePosition"]=false;this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorPaymentStatus.prototype.getDragObjectType=function(){return BX.UI.EditorDragObjectType.field};BX.Crm.EntityEditorPaymentStatus.prototype.createPaymentButton=function(t,e){var r=BX.create("div",{props:{className:"ui-btn-split ui-btn-sm "+(e?"ui-btn-success-light":"ui-btn-danger-light"),id:"crm_entity_editor_is_payment_paid_button_"+t},children:[BX.create("button",{props:{className:"ui-btn-main",id:"crm_entity_editor_is_payment_paid_button_main_"+t},html:e?this.getMessage("paymentWasPaid"):this.getMessage("paymentWasNotPaid")}),BX.create("button",{props:{className:"ui-btn-extra"}})]});BX.bind(r,"click",BX.delegate((function(e){this.onPaidButtonClick(e,t)}),this));return r};BX.Crm.EntityEditorPaymentStatus.prototype.doInitialize=function(){BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterUpdate,this));BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onPaymentVoucherUpdate,this));BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onPaymentVoucherInited,this));this._isCreateMode=!this._model._data.ID};BX.Crm.EntityEditorPaymentStatus.prototype.onAfterUpdate=function(t){if(t.entityData){if(this._model._data.hasOwnProperty("STATUS")&&BX.type.isPlainObject(this._model._data["STATUS"])){if(t.entityData.PAID){this._model._data["STATUS"].isPaid=t.entityData.PAID}if(t.entityData.DATE_PAID){this._model._data["STATUS"].datePaid=t.entityData.DATE_PAID}}}};BX.Crm.EntityEditorPaymentStatus.prototype.onPaymentVoucherUpdate=function(t){if(t.getEventId()==="CrmOrderPaymentVoucher::Update"){var e=t.getData(),r;if(BX.prop.getInteger(e,"entityTypeId",0)!==BX.CrmEntityType.enumeration.orderpayment){return}if(BX.prop.getString(e,"source","")!=="PAYMENT"){return}for(var i in e){if(i==="entityId"||i==="entityTypeId"){continue}if(e.hasOwnProperty(i)){this.getModel().setField(i,BX.prop.getString(e,i,""));if(r=this.getEditor().getControlByIdRecursive("field")){r.onModelChange()}}}if(!this._isCreateMode){if(this._editor.isChanged()){this.markAsChanged();this.getPaymentController().onDataChanged()}else{var n=e;n["PAYMENT_ID"]=BX.prop.getString(e,"entityId",0);var o="setPaymentPaidField";if(n["IS_RETURN"]){o="setPaymentReturnField"}this.getPaymentController().ajax(o,{data:{FIELDS:n}},{skipMarkAsChanged:true,sendUpdateEvent:true})}}}};BX.Crm.EntityEditorPaymentStatus.prototype.onPaymentVoucherInited=function(t){if(t.getEventId()==="CrmOrderPaymentVoucher::Initialized"){var e=t.getData();if(BX.prop.getInteger(e,"entityTypeId",0)!==BX.CrmEntityType.enumeration.orderpayment||!e.voucherObject){return}var r=e.voucherObject;r.setField("PAY_VOUCHER_NUM",this.getModel().getField("PAY_VOUCHER_NUM"));r.setField("PAY_VOUCHER_DATE",this.getModel().getField("PAY_VOUCHER_DATE"));r.setField("PAY_RETURN_NUM",this.getModel().getField("PAY_RETURN_NUM"));r.setField("PAY_RETURN_DATE",this.getModel().getField("PAY_RETURN_DATE"));r.setField("PAY_RETURN_COMMENT",this.getModel().getField("PAY_RETURN_COMMENT"));r.setField("PAID",this.getModel().getField("PAID"));r.setField("source","PAYMENT");if(this.getModel().getField("PAID")==="N"){var i=this.getModel().getField("IS_RETURN");if(i==="Y"||i==="P"){r.setField("IS_RETURN",i)}}}};BX.Crm.EntityEditorPaymentStatus.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorPaymentStatus.messages;return e.hasOwnProperty(t)?e[t]:BX.Crm.EntityEditorPaymentStatus.superclass.getMessage.apply(this,arguments)};BX.Crm.EntityEditorPaymentStatus.prototype.onPaidButtonClick=function(t,e){this.togglePaidButtonMenu(e);t.preventDefault()};BX.Crm.EntityEditorPaymentStatus.prototype.togglePaidButtonMenu=function(t){if(this._isPaidButtonMenuOpened[t]){this.closePaidButtonMenu(t)}else{this.openPaidButtonMenu(t)}};BX.Crm.EntityEditorPaymentStatus.prototype.closePaidButtonMenu=function(t){var e=BX.PopupMenu.getMenuById(this._id);if(e){e.popupWindow.close()}this._isPaidButtonMenuOpened[t]=false};BX.Crm.EntityEditorPaymentStatus.prototype.setValue=function(t){if(!this._model){return""}return this._model.setField(this.getName(),t)};BX.Crm.EntityEditorPaymentStatus.prototype.setPaidButtonView=function(t,e){var r=BX("crm_entity_editor_is_payment_paid_button_"+t),i=BX("crm_entity_editor_is_payment_paid_button_main_"+t);if(!r||!i){return}if(e){BX.removeClass(r,"ui-btn-danger-light");BX.addClass(r,"ui-btn-success-light");i.innerHTML=this.getMessage("paymentWasPaid")}else{BX.removeClass(r,"ui-btn-success-light");BX.addClass(r,"ui-btn-danger-light");i.innerHTML=this.getMessage("paymentWasNotPaid")}};BX.Crm.EntityEditorPaymentStatus.prototype.openPaidButtonMenu=function(t){var e=this,r;var i=function(r,i){var n=BX.prop.getString(i,"value");if(n==="CANCEL"||n==="RETURN"){e.getModel().setField("PAID","N");if(n==="RETURN"){e.getModel().setField("IS_RETURN","Y");if(!e._isCreateMode){BX.Crm.Page.openSlider(e.getModel().getStringField("PAY_RETURN_URL"),{width:500})}}else{e.setValue({isPaid:"N",datePaid:e.getValue().datePaid});if(!e._isCreateMode){BX.Crm.Page.openSlider(e.getModel().getStringField("PAY_CANCEL_URL"),{width:500})}}}else if(n==="SET_PAID"){e.setValue({isPaid:"Y",datePaid:e.getValue().datePaid});e.getModel().setField("PAID","Y");e.getModel().setField("IS_RETURN","N");if(!e._isCreateMode){if(e._editor.isChanged()){e.markAsChanged();e.getPaymentController().markAsChanged();e.getPaymentController().onDataChanged()}else{e.getPaymentController().ajax("setPaymentPaidField",{data:{FIELDS:{PAID:"Y",PAYMENT_ID:e.getModel().getField("ID")}}},{skipMarkAsChanged:true,sendUpdateEvent:true})}}}e.closePaidButtonMenu(t);e.setPaidButtonView(t,e.getModel().getField("PAID")==="Y")};var n=this.getValue();if(n.isPaid==="Y"){if(this._isCreateMode){r=[{value:"CANCEL",text:this.getMessage("paymentWasNotPaid"),onclick:i}]}else{r=[{value:"CANCEL",text:this.getMessage("paymentCancel"),onclick:i},{value:"RETURN",text:this.getMessage("paymentReturn"),onclick:i}]}}else{r=[{value:"SET_PAID",text:this.getMessage("paymentWasPaid"),onclick:i}]}BX.PopupMenu.show(this._id,this._paidButtons[t],r,{angle:false,events:{onPopupShow:BX.proxy((function(){this.onMenuShow(t)}),this),onPopupClose:BX.delegate(this.onMenuClose,this)}})};BX.Crm.EntityEditorPaymentStatus.prototype.onMenuShow=function(t){this._isPaidButtonMenuOpened[t]=true};BX.Crm.EntityEditorPaymentStatus.prototype.onMenuClose=function(){BX.PopupMenu.destroy(this._id)};BX.Crm.EntityEditorPaymentStatus.prototype.getPaymentController=function(){if(this._paymentController===null){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderPaymentController){this._paymentController=this._editor._controllers[t];break}}}return this._paymentController};BX.Crm.EntityEditorPaymentStatus.prototype.checkIfNotEmpty=function(t){return BX.util.trim(t)!==""};BX.Crm.EntityEditorPaymentStatus.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}this.setPaidButtonView(0,this.getModel().getField("PAID")==="Y")};BX.Crm.EntityEditorPaymentStatus.prototype.doClearLayout=function(t){if(!this._hasLayout){return}this._hasLayout=false;this._wrapper=null;this._input=null;this._view=null;this._isPaidButtonMenuOpened={};this._paidButtons={}};BX.Crm.EntityEditorPaymentStatus.prototype.ensureWrapperCreated=function(t){if(!this._wrapper){this._wrapper=BX.create("div",{props:{className:"ui-entity-editor-content-block"}})}var e=BX.prop.getArray(t,"classNames",[]);for(var r=0,i=e.length;r<i;r++){BX.addClass(this._wrapper,e[r])}return this._wrapper};BX.Crm.EntityEditorPaymentStatus.prototype.adjustWrapper=function(){if(!this._wrapper){return}if(this.isInEditMode()&&(this.checkModeOption(BX.UI.EntityEditorModeOptions.exclusive)||this.checkModeOption(BX.UI.EntityEditorModeOptions.individual))){BX.addClass(this._wrapper,"crm-entity-widget-content-block-edit")}else{BX.removeClass(this._wrapper,"crm-entity-widget-content-block-edit")}if(this._layoutAttributes){for(var t in this._layoutAttributes){if(this._layoutAttributes.hasOwnProperty(t)){this._wrapper.setAttribute("data-"+t,this._layoutAttributes[t])}}this._layoutAttributes=null}};BX.Crm.EntityEditorPaymentStatus.prototype.createTitleNode=function(t){this._titleWrapper=BX.create("div",{attrs:{className:"crm-entity-widget-content-block-title"}});this.prepareTitleLayout(BX.type.isNotEmptyString(t)?t:this.getTitle());return this._titleWrapper};BX.Crm.EntityEditorPaymentStatus.prototype.prepareTitleLayout=function(t){if(!this._titleWrapper){return}this._titleWrapper.appendChild(BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:t}));var e=this.createTitleMarker();if(e){this._titleWrapper.appendChild(e)}};BX.Crm.EntityEditorPaymentStatus.prototype.createTitleMarker=function(){if(this._mode===BX.UI.EntityEditorMode.view){return null}if(this.isRequired()){return BX.create("span",{style:{color:"#f00"},text:"*"})}else if(this.isRequiredConditionally()){return BX.create("span",{text:"*"})}return null};BX.Crm.EntityEditorPaymentStatus.prototype.initializeDragDropAbilities=function(){if(this._dragItem){return}this._dragItem=BX.UI.EditorDragItemController.create("field_"+this.getId(),{charge:BX.UI.EditorFieldDragItem.create({control:this,contextId:this._draggableContextId}),node:this.createDragButton(),showControlInDragMode:false,ghostOffset:{x:0,y:0}})};BX.Crm.EntityEditorPaymentStatus.prototype.onSetPaidFieldFailure=function(t){this.showError(t)};BX.Crm.EntityEditorPaymentStatus.prototype.showError=function(t,e){BX.Crm.EntityEditorPaymentStatus.superclass.showError.apply(this,arguments);if(this._input){BX.addClass(this._input,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorPaymentStatus.prototype.clearError=function(){BX.Crm.EntityEditorPaymentStatus.superclass.clearError.apply(this);if(this._input){BX.removeClass(this._input,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorPaymentStatus.create=function(t,e){var r=new BX.Crm.EntityEditorPaymentStatus;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorPaymentCheck==="undefined"){BX.Crm.EntityEditorPaymentCheck=function(){BX.Crm.EntityEditorPaymentCheck.superclass.constructor.apply(this);this._loader=null};BX.extend(BX.Crm.EntityEditorPaymentCheck,BX.Crm.EntityEditorField);BX.Crm.EntityEditorPaymentCheck.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorPaymentCheck.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorPaymentCheck.prototype.layout=function(t){if(this._hasLayout){return}var e=this.getValue();if(!BX.type.isPlainObject(e)){return}var r=BX.prop.getArray(e,"items",[]);this._totalCount=BX.prop.getInteger(e,"count",0);this._wrapper=BX.create("div",{props:{className:"ui-entity-editor-content-block"}});var i=this._itemCount=r.length;var n=[];for(var o=0;o<i;o++){n.push(this.addCheckRow(r[o],-1))}if(n.length===0){var s=BX.create("div",{props:{className:"crm-entity-widget-content-nothing-selected-text"},text:this.getMessage("emptyCheckList")});n.push(s)}this._wrapper.appendChild(BX.create("div",{props:{className:"crm-entity-widget-content-block-products"},children:n}));this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorPaymentCheck.prototype.addCheckRow=function(t){if(parseInt(t["ID"])<=0){return}var e=[];var r=BX.create("div",{props:{className:"crm-entity-widget-content-check-title"},children:[BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:BX.type.isNotEmptyString(t["TITLE"])?t["TITLE"]:""}),BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:BX.type.isNotEmptyString(t["DATE_CREATE"])?t["DATE_CREATE"]:""})]});var i=[];i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box-title-text"},html:t["TITLE"]})]}));i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this.createTitleNode(this.getMessage("titleFieldSum")),BX.create("span",{props:{className:"crm-entity-widget-content-block-colums-right"},html:t["SUM_WITH_CURRENCY"]})]})]})]}));i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this.createTitleNode(this.getMessage("titleFieldDateCreate")),BX.create("span",{html:t["DATE_CREATE"]})]})]})]}));i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this.createTitleNode(this.getMessage("titleFieldType")),BX.create("span",{html:t["CHECK_TYPE"]})]})]})]}));if(BX.type.isNotEmptyString(t["CASHBOX_NAME"])){i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this.createTitleNode(this.getMessage("titleFieldCashBoxName")),BX.create("span",{html:t["CASHBOX_NAME"]})]})]})]}))}i.push(BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[this.createTitleNode(this.getMessage("titleFieldStatus")),BX.create("span",{html:t["STATUS_NAME"]})]})]})]}));var n=BX.create("div",{props:{className:"crm-entity-widget-content-block"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-inner-box"},children:i})]})]});e.push(n);return BX.create("div",{props:{className:"crm-entity-widget-content-nothing-selected-text"},children:e})};BX.Crm.EntityEditorPaymentCheck.prototype.clearLayout=function(){if(!this._hasLayout){return}this._table=null;this._moreButton=null;this._moreButtonRow=null;this._wrapper=BX.remove(this._wrapper);this._hasLayout=false};if(typeof BX.Crm.EntityEditorPaymentCheck.messages==="undefined"){BX.Crm.EntityEditorPaymentCheck.messages={}}BX.Crm.EntityEditorPaymentCheck.create=function(t,e){var r=new BX.Crm.EntityEditorPaymentCheck;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderPropertyWrapper==="undefined"){BX.Crm.EntityEditorOrderPropertyWrapper=function(){BX.Crm.EntityEditorOrderPropertyWrapper.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderPropertyWrapper,BX.Crm.EntityEditorSubsection);BX.Crm.EntityEditorOrderPropertyWrapper.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderPropertyWrapper.superclass.initialize.call(this,t,e);this.setPersonType();this._disabledFieldsBlock=null;this._entityType=BX.prop.getString(this._schemeElement.getData(),"entityType");this._elementsData=BX.prop.getObject(this._schemeElement._settings,"sortedElements",{});this._elementData={active:BX.prop.getArray(this._elementsData,"active",{}),hidden:BX.prop.getArray(this._elementsData,"hidden",{})};this._childrenScheme={active:[],hidden:[]};this._childrenScheme.active=this.setChildrenScheme(this._elementData.active);this._childrenScheme.hidden=this.setChildrenScheme(this._elementData.hidden);this.addChildren();BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterSubmit,this));BX.addCustomEvent("SidePanel.Slider:onMessage",BX.delegate(this.onPropertySave,this));if(this._entityType==="order"){BX.addCustomEvent(window,"Crm.OrderModel.ChangePropertyScheme",BX.delegate(this.onSchemeChange,this))}else if(this._entityType==="shipment"){BX.addCustomEvent(window,"Crm.ShipmentModel.ChangePropertyScheme",BX.delegate(this.onSchemeChange,this))}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.setPersonType=function(){this._personTypeId=BX.prop.getInteger(this._model.getData(),"PERSON_TYPE_ID")};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.setChildrenScheme=function(t){var e=[];for(var r=0,i=t.length;r<i;r++){e.push(BX.UI.EntitySchemeElement.create(t[r]))}return e};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.addChildren=function(){var t=BX.UI.EntitySchemeElement.create({name:this._id+"_ACTIVE",type:"order_property_subsection",entityType:this._entityType,transferable:false,editable:true,isDragEnabled:BX.prop.getBoolean(this._schemeElement._settings,"isDragEnabled",false),elements:[],data:this._schemeElement.getData()});this._activeElementsBlock=this._editor.createControl(t.getType(),t.getName(),{schemeElement:t,model:this._model,parent:this,mode:this._mode});if(this._activeElementsBlock){this.addChild(this._activeElementsBlock,{enableSaving:false});if(this._editor._config){this._editor._config._isChanged=false}}t=BX.UI.EntitySchemeElement.create({name:this._id+"_DISABLED",type:"order_property_subsection",transferable:false,title:this.getMessage("disabledBlockTitle"),editable:true,isDragEnabled:false,elements:[]});this._disabledFieldsBlock=this._editor.createControl(t.getType(),t.getName(),{schemeElement:t,model:this._model,parent:this,mode:this._mode});this._disabledFieldsBlock._showFieldLink=false;if(this._disabledFieldsBlock){this.addChild(this._disabledFieldsBlock,{enableSaving:false});if(this._editor._config){this._editor._config._isChanged=false}}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.layout=function(){this.setChildrenFields();BX.Crm.EntityEditorOrderPropertyWrapper.superclass.layout.call(this);var t=this.getParent();if(t instanceof BX.Crm.EntityEditorSection&&BX.type.isDomNode(t.getWrapper())){t.getWrapper().classList.add("crm-entity-card-widget-order-properties")}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.setChildrenFields=function(){this._activeElementsBlock._fields=[];this._disabledFieldsBlock._fields=[];var t=this._childrenScheme.active;for(var e=0;e<t.length;e++){var r=null;var i=t[e];if(this._personTypeId===i.getDataIntegerParam("personTypeId")){r=this._activeElementsBlock;i._isContextMenuEnabled=true}else{var n=BX.prop.getString(this._model.getData(),i.getName());if(!BX.type.isNotEmptyString(n)){continue}i._isContextMenuEnabled=false;r=this._disabledFieldsBlock}var o=this._editor.createControl(i.getType(),i.getName(),{schemeElement:i,model:this._model,parent:r,mode:this._mode});if(this._mode!==BX.UI.EntityEditorMode.edit||this._personTypeId!==i.getDataIntegerParam("personTypeId")){o.setDragObjectType(BX.UI.EditorDragObjectType.intermediate)}r.addChild(o,{enableSaving:false});if(this._editor._config){this._editor._config._isChanged=false}}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.initializeFromModel=function(){this._fields=[]};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.createButtonPanel=function(){this._buttonPanelWrapper=BX.create("div",{props:{className:"ui-entity-editor-content-block"}});if(this.isCreationEnabled()){if(this.getEditorUrlTemplate()){this._createChildButton=BX.create("span",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:this.getMessage("createField"),events:{click:BX.delegate(this.onCreateUserFieldBtnClick,this)}});this._buttonPanelWrapper.appendChild(this._createChildButton)}if(this.getManagerUrlTemplate()){this._insertChildButton=BX.create("span",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:this.getMessage("insertField"),events:{click:BX.delegate(this.onInsertPropertyBtnClick,this)}});this._buttonPanelWrapper.appendChild(this._insertChildButton)}}this._addChildButton=BX.create("span",{props:{className:"crm-entity-widget-content-block-edit-action-btn"},text:this.getMessage("selectField"),events:{click:BX.delegate(this.onAddChildBtnClick,this)}});this.toggleChildButton();this._buttonPanelWrapper.appendChild(this._addChildButton)};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.isCreationEnabled=function(){return true};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.toggleChildButton=function(){if(!BX.type.isDomNode(this._addChildButton)){return}var t=false;for(var e=0;e<this._childrenScheme.hidden.length;e++){if(this._personTypeId===this._childrenScheme.hidden[e].getDataIntegerParam("personTypeId")){t=true;break}}if(t){this._addChildButton.style.display="inline-block"}else{this._addChildButton.style.display="none"}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onSchemeChange=function(t){this._elementData={active:BX.prop.getArray(t,"ACTIVE",{}),hidden:BX.prop.getArray(t,"HIDDEN",{})};var e=BX.prop.getNumber(t,"PERSON_TYPE_ID",0);if(e>0){this._personTypeId=e;if(this._activeElementsBlock){this._activeElementsBlock._personTypeId=e}}this._childrenScheme.active=this.setChildrenScheme(this._elementData.active);this._childrenScheme.hidden=this.setChildrenScheme(this._elementData.hidden);this.toggleChildButton();this.refreshLayout()};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onPropertySave=function(t){if(t.getEventId()==="OrderPropertyEdit::onSave"){var e=t.getData();var r=BX.prop.getNumber(e.property,"ID");if(!BX.type.isNotEmptyObject(e.property)||!r){return}var i=e.property;var n="PROPERTY_"+r;for(var o=0;o<this._editor._activeControls.length;o++){if(this._editor._activeControls[o].getId()===n){this._editor._activeControls.splice(o,1)}}this.addActiveField(n,i)}else if(t.getEventId()==="OrderForm::onSave"){this.getOrderController().ajax("getPropertiesScheme",{data:{ORDER_ID:this._editor.getEntityId()},onsuccess:BX.delegate(this.refreshChildren,this)})}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.addActiveField=function(t,e){var r=this._activeElementsBlock.getChildById(t);if(r){r._schemeElement._isRequired=e.REQUIRED==="Y";if(e.TYPE==="STRING"){r._schemeElement._data.lineCount=e.MULTILINE==="Y"?e.ROWS:"1"}r._schemeElement.setTitle(BX.util.htmlspecialchars(e.NAME));if(r instanceof BX.UI.EntityEditorList||r instanceof BX.UI.EntityEditorMultiList){if(!BX.type.isArray(e.VARIANTS)){property.VARIANTS=[]}var i=[];for(var n=0;n<e.VARIANTS.length;n++){var o=e.VARIANTS[n].VALUE;if(!BX.type.isNotEmptyString(o)){continue}var s=BX.type.isNotEmptyString(e.VARIANTS[n].NAME)?BX.util.htmlspecialchars(e.VARIANTS[n].NAME):o;i.push({VALUE:o,NAME:s})}r._items=i}this.refreshLayout()}else{this.getOrderController().ajax("preparePropertyScheme",{data:{PROPERTY:e},onsuccess:BX.delegate(this.createProperty,this)})}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.getOrderController=function(){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderController){return this._editor._controllers[t]}}return null};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.createProperty=function(t){this.getOrderController().unlockSending();this.getOrderController().hideLoader();var e=BX.prop.getObject(t,"FIELD",null);if(!e){return}var r=BX.UI.EntitySchemeElement.create(e);this._model.setField(r.getName(),"");this._childrenScheme.active.push(r);var i=this._editor.createControl(r.getType(),r.getName(),{schemeElement:r,model:this._model,parent:this,mode:this._mode});var n=this._editor.getOption("show_always","Y")==="Y";if(n!==i.checkOptionFlag(BX.UI.EntityEditorControlOptions.showAlways)){i.toggleOptionFlag(BX.UI.EntityEditorControlOptions.showAlways)}if(i instanceof BX.UI.EntityEditorCustom){this.getOrderController().onDataChanged()}else{this._activeElementsBlock.addChild(i)}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.refreshChildren=function(t){this.getOrderController().unlockSending();this.getOrderController().hideLoader();if(parseInt(t.ORDER_ID)!==parseInt(this._editor.getEntityId())||!BX.type.isNotEmptyObject(t.PROPERTIES)){return}if(BX.type.isArray(t.PROPERTIES.ACTIVE)){this._childrenScheme.active=this.setChildrenScheme(BX.prop.getArray(t.PROPERTIES,"ACTIVE",[]))}if(BX.type.isArray(t.PROPERTIES.HIDDEN)){this._childrenScheme.hidden=this.setChildrenScheme(BX.prop.getArray(t.PROPERTIES,"HIDDEN",[]))}this.refreshLayout()};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.removeChild=function(t){this._childrenScheme.hidden.push(t.getSchemeElement());var e=t.getId();for(var r=0;r<this._childrenScheme.active.length;r++){if(e===this._childrenScheme.active[r].getName()){this._childrenScheme.active.splice(r,1);break}}this.toggleChildButton()};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.openAddChildMenu=function(){var t=[];for(var e=0;e<this._childrenScheme.hidden.length;e++){if(this._personTypeId===this._childrenScheme.hidden[e].getDataIntegerParam("personTypeId")){t.push(this._childrenScheme.hidden[e])}}var r=t.length;if(r===0){return}var i=[];for(e=0;e<r;e++){var n=t[e];i.push({text:n.getTitle(),value:n.getName()})}if(this._childSelectMenu){this._childSelectMenu.setupItems(i)}else{this._childSelectMenu=BX.CmrSelectorMenu.create(this._id,{items:i});this._childSelectMenu.addOnSelectListener(BX.delegate(this.onChildSelect,this))}this._childSelectMenu.open(this._addChildButton)};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onChildSelect=function(t,e){var r=e.getValue();if(r==="ACTION.TRANSFER"){this.openTransferDialog();return}for(var i=0;i<this._childrenScheme.hidden.length;i++){if(this._childrenScheme.hidden[i].getName()===r){element=this._childrenScheme.hidden[i];this._childrenScheme.hidden=BX.util.deleteFromArray(this._childrenScheme.hidden,i);this.toggleChildButton();break}}if(!element){return}var n=element.getDataStringParam("propertyId");var o={SETTINGS:{IS_HIDDEN:"N"}};this._activeElementsBlock.savePropertyConfig(n,o);var s=this._editor.createControl(element.getType(),element.getName(),{schemeElement:element,model:this._model,parent:this,mode:this._mode});if(s){this._activeElementsBlock.addChild(s);this._childrenScheme.active.push(element)}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onAfterSubmit=function(t){var e=BX.prop.getObject(t,"entityData",null);if(e){var r=BX.prop.getArray(e,"USER_PROFILE_LIST");this.refreshProfilesList(r);var i=BX.prop.getNumber(e,"PERSON_TYPE_ID");if(this._personTypeId!==i){this.refreshLayout()}}if(this._activeElementsBlock.isSchemeChanged()){var n=[];var o=[];var s=this._activeElementsBlock._fields;for(var a=0;a<s.length;a++){var d=s[a];var l=d._schemeElement.getDataStringParam("propertyId");if(BX.type.isNotEmptyString(l)){n.push(d._schemeElement.getDataStringParam("propertyId"));o.push(d._schemeElement)}}if(n.length>0){BX.ajax.post(BX.prop.getString(this._settings,"serviceUrl",""),{PROPERTIES:n,ACTION:"sortProperties"})}for(a=0;a<this._childrenScheme.active.length;a++){var c=this._childrenScheme.active[a].getDataStringParam("propertyId");if(!BX.util.in_array(c,n)){o.push(this._childrenScheme.active[a])}}this._childrenScheme.active=o}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.refreshProfilesList=function(t){if(BX.type.isArray(t)){var e=this._editor.getControls();for(var r=0;r<e.length;r++){var i=e[r].getChildById("USER_PROFILE");if(i){i._items=null;i._schemeElement.setData({items:t});i.refreshLayout();return}}}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.setDraggableContextId=function(t){};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.showPropertyEditor=function(t){t=parseInt(t);var e=this.getEditorUrlTemplate();if(e){var r=e.replace("#property_id#",t).replace("#person_type_id#",this._personTypeId);BX.SidePanel.Instance.open(r,{loader:"crm-webform-view-loader",cacheable:false})}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.showManagerSlider=function(t){var e=this.getManagerUrlTemplate();if(e){var r=e.replace("#person_type_id#",this._personTypeId);BX.SidePanel.Instance.open(r,{loader:"crm-webform-view-loader"})}};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.getManagerUrlTemplate=function(t){var e=this._schemeElement.getData();if(!BX.type.isNotEmptyString(e.managerUrl)){return null}return e.managerUrl};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.getEditorUrlTemplate=function(t){var e=this._schemeElement.getData();if(!BX.type.isNotEmptyString(e.editorUrl)){return null}return e.editorUrl};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onCreateUserFieldBtnClick=function(t){this.showPropertyEditor(0)};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.onInsertPropertyBtnClick=function(t){this.showManagerSlider()};BX.Crm.EntityEditorOrderPropertyWrapper.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorOrderPropertyWrapper.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorOrderPropertyWrapper.create=function(t,e){var r=new BX.Crm.EntityEditorOrderPropertyWrapper;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderPropertySubsection==="undefined"){BX.Crm.EntityEditorOrderPropertySubsection=function(){BX.Crm.EntityEditorOrderPropertySubsection.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderPropertySubsection,BX.Crm.EntityEditorSubsection);BX.Crm.EntityEditorOrderPropertySubsection.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderPropertySubsection.superclass.initialize.call(this,t,e);this._personTypeId=BX.prop.getInteger(this._model.getData(),"PERSON_TYPE_ID");this._showFieldLink=true;if(this.getChildDragScope()===BX.UI.EditorDragScope.parent){this._draggableContextId+="_"+this.getId()}BX.addCustomEvent(window,"CrmOrderPropertySetCustom",BX.delegate(this.onChangeCustomProperty,this))};BX.Crm.EntityEditorOrderPropertySubsection.prototype.getEditPriority=function(){return BX.UI.EntityEditorPriority.high};BX.Crm.EntityEditorOrderPropertySubsection.prototype.layoutChild=function(t){BX.Crm.EntityEditorOrderPropertySubsection.superclass.layoutChild.call(this,t);var e=BX.prop.getString(t._schemeElement._settings,"linked");if(this._mode!==BX.UI.EntityEditorMode.view&&t.isContextMenuEnabled()&&BX.type.isNotEmptyString(e)&&this._showFieldLink){BX.addClass(t._wrapper,"crm-entity-widget-content-block-linked");if(BX.type.isDomNode(t._titleWrapper)){t._titleWrapper.setAttribute("title",e)}}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.layoutTitle=function(){if(BX.type.isNotEmptyString(this._schemeElement.getTitle())&&this.getChildCount()>0){var t=BX.create("div",{attrs:{className:"crm-entity-card-widget-title"},text:this._schemeElement.getTitle()});if(BX.type.isDomNode(this._contentContainer)){BX.addClass(this._contentContainer,"crm-entity-widget-content")}this._wrapper.appendChild(t)}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.onFieldConfigurationSave=function(t,e){if(t!==this._fieldConfigurator){return}var r=BX.prop.get(e,"field",null);if(!r){throw"EntityEditorSection. Could not find target field."}var i=BX.prop.getString(e,"label","");var n=BX.prop.getBoolean(e,"showAlways",null);if(i===""&&n===null){this.removeFieldConfigurator();return}this._fieldConfigurator.setLocked(true);r.setTitle(i);if(n!==null&&n!==r.checkOptionFlag(BX.UI.EntityEditorControlOptions.showAlways)){r.toggleOptionFlag(BX.UI.EntityEditorControlOptions.showAlways)}var o={NAME:i,SETTINGS:{SHOW_ALWAYS:n?"Y":"N"}};var s=r._schemeElement.getDataStringParam("propertyId");this.savePropertyConfig(s,o).then(BX.delegate((function(){this.removeFieldConfigurator()}),this))};BX.Crm.EntityEditorOrderPropertySubsection.prototype.getOrderController=function(){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderController){return this._editor._controllers[t]}}return null};BX.Crm.EntityEditorOrderPropertySubsection.prototype.processChildControlSchemeChange=function(t){var e=t._schemeElement.getDataStringParam("propertyId");var r={SETTINGS:{SHOW_ALWAYS:t.checkOptionFlag(BX.UI.EntityEditorControlOptions.showAlways)?"Y":"N"}};this.savePropertyConfig(e,r)};BX.Crm.EntityEditorOrderPropertySubsection.prototype.processDraggedItemDrop=function(t,e){var r=t.getCharge();if(!(r instanceof BX.UI.EditorFieldDragContainer&&r.getSection()===this)){return}var i=e.getContextData();var n=BX.type.isNotEmptyString(i["contextId"])?i["contextId"]:"";if(n!==this.getDraggableContextId()){return}var o=typeof i["charge"]!=="undefined"?i["charge"]:null;if(!(o instanceof BX.UI.EditorFieldDragItem)){return}var s=o.getControl();if(!s){return}var a=this.getChildIndex(s);if(a<0){return}var d=this.getPlaceHolder();var l=d?d.getIndex():-1;if(l<0){return}var c=l<=a?l:l-1;if(c!==a){this.moveChild(s,c)}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.onChangeCustomProperty=function(t){if(BX.type.isNotEmptyString(t)){var e=this.getChildById(t);if(e){var r=e.getWrapper();if(!BX.type.isDomNode(r))return;var i=e._schemeElement.getDataStringParam("type");if(i==="LOCATION"||i==="ADDRESS"){var n=r.querySelector("input[name="+t+"]");if(BX.type.isDomNode(n)){var o=BX.prop.getString(this._model.getData(),t);if(n.value!==o){e.setRuntimeValue(n.value);e.markAsChanged()}}}else if(i==="FILE"){var s=BX.prop.getString(this._model.getData(),t);e.setRuntimeValue(s);e.markAsChanged()}else{var s=BX.prop.getString(this._model.getData(),t);e.setRuntimeValue(s);e.markAsChanged()}}}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.editChildConfiguration=function(t){if(BX.prop.getString(this._schemeElement.getData(),"entityType")==="order"){this.showPropertyEditor(t._schemeElement.getDataStringParam("propertyId"))}else{BX.Crm.EntityEditorOrderPropertySubsection.superclass.editChildConfiguration.apply(this,[t])}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.removeChild=function(t,e){if(!BX.type.isPlainObject(e)){e={}}var r=this.getChildIndex(t);if(r<0){return}if(t.isActive()){t.setActive(false)}this._fields.splice(r,1);var i=t.hasScheme();if(i){t.getSchemeElement().setParent(null);if(this._parent){this._parent.removeChild(t)}}if(this._hasLayout){t.clearLayout();t.setContainer(null);t.setDraggableContextId("")}if(i){var n=t._schemeElement.getDataStringParam("propertyId");var o={SETTINGS:{IS_HIDDEN:"Y"}};this.savePropertyConfig(n,o)}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.savePropertyConfig=function(t,e){var r=new BX.Promise;var i={PROPERTY_ID:t,ACTION:"savePropertyConfig",CONFIG:e};BX.ajax.post(BX.prop.getString(this._settings,"serviceUrl",""),i,(function(){r.fulfill()}));this._isChanged=false;return r};BX.Crm.EntityEditorOrderPropertySubsection.prototype.isDragEnabled=function(){return this._mode===BX.UI.EntityEditorMode.edit&&BX.prop.getBoolean(this._schemeElement._settings,"isDragEnabled",false)};BX.Crm.EntityEditorOrderPropertySubsection.prototype.refreshProfilesList=function(t){if(BX.type.isArray(t)){var e=this._editor.getControls();for(var r=0;r<e.length;r++){var i=e[r].getChildById("USER_PROFILE");if(i){i._items=null;i._schemeElement.setData({items:t});i.refreshLayout();return}}}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.moveChild=function(t,e){var r=this.getChildCount();var i=r-1;if(e<0||e>r){e=i}var n=this.getChildIndex(t);if(n<0||n===e){return false}if(this._hasLayout){t.clearLayout()}this._fields.splice(n,1);r--;var o=null;if(this._hasLayout){o=e<r?this._fields[e].getWrapper():this._buttonPanelWrapper}if(e<r){this._fields.splice(e,0,t)}else{this._fields.push(t)}if(this._hasLayout){if(o){t.layout({anchor:o})}else{t.layout()}}this.markSchemeAsChanged();this.markAsChanged();return true};BX.Crm.EntityEditorOrderPropertySubsection.prototype.hasAdditionalMenu=function(t){return true};BX.Crm.EntityEditorOrderPropertySubsection.prototype.getAdditionalMenu=function(t){return!!this.getManagerUrl()?[{value:"linkToSettings",text:this.getMessage("linkToSettings")}]:[]};BX.Crm.EntityEditorOrderPropertySubsection.prototype.showPropertyEditor=function(t){t=parseInt(t);var e=this._schemeElement.getData();if(BX.type.isNotEmptyString(e.editorUrl)){var r=e.editorUrl.replace("#property_id#",t).replace("#person_type_id#",this._personTypeId);BX.SidePanel.Instance.open(r,{loader:"crm-webform-view-loader"})}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.showManagerSlider=function(t){var e=this.getManagerUrl();if(e){BX.SidePanel.Instance.open(e,{loader:"crm-webform-view-loader"})}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.getManagerUrl=function(t){var e=this._schemeElement.getData();if(!BX.type.isNotEmptyString(e.managerUrl)){return null}return e.managerUrl.replace("#person_type_id#",this._personTypeId)};BX.Crm.EntityEditorOrderPropertySubsection.prototype.processChildAdditionalMenuCommand=function(t,e){if(e==="linkToSettings"){this.showManagerSlider()}};BX.Crm.EntityEditorOrderPropertySubsection.prototype.onCreateUserFieldBtnClick=function(t){this.showPropertyEditor(0)};BX.Crm.EntityEditorOrderPropertySubsection.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorOrderPropertySubsection.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorOrderPropertySubsection.create=function(t,e){var r=new BX.Crm.EntityEditorOrderPropertySubsection;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderProductProperty==="undefined"){BX.Crm.EntityEditorOrderProductProperty=function(){BX.Crm.EntityEditorOrderProductProperty.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderProductProperty,BX.Crm.EntityEditorField);BX.Crm.EntityEditorOrderProductProperty.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderProductProperty.superclass.initialize.call(this,t,e);this._addPropertyLink=null;this._innerWrapper=null;this._index=0};BX.Crm.EntityEditorOrderProductProperty.prototype.layout=function(t){if(this._hasLayout){return}this.ensureWrapperCreated({classNames:["crm-entity-widget-content-block-field-text"]});this.adjustWrapper();if(!this.isNeedToDisplay()){this.registerLayout(t);this._hasLayout=true;return}this._innerWrapper=BX.create("div");this._wrapper.appendChild(this._innerWrapper);var e=BX.prop.get(this._model.getData(),this.getName(),[]);for(var r in e){if(e.hasOwnProperty(r)){this.layoutProperty(e[r])}}this._addPropertyLink=BX.create("span",{attrs:{className:"crm-entity-widget-content-block-edit-action-btn"},text:this.getMessage("addProductProperty"),events:{click:BX.delegate(this.layoutProperty,this)}});this._wrapper.appendChild(this._addPropertyLink);this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorOrderProductProperty.prototype.layoutProperty=function(t){var t=t||{};if(!BX.type.isDomNode(this._innerWrapper))return;this._index++;var e=this.getMessage("fieldBlockTitle");e=e.replace("#INDEX#",this._index);var r=BX.create("div",{attrs:{className:"crm-entity-card-widget"},children:[BX.create("div",{attrs:{className:"crm-entity-card-widget-title"},text:e})]});this._innerWrapper.appendChild(r);var i=["Name","Value","Code","Sort"];for(var n=0;n<i.length;n++){var o={name:"PROPERTY["+this._index+"]["+i[n].toUpperCase()+"]",className:"crm-entity-widget-content-input",type:"text"};var s=BX.prop.getString(t,i[n].toUpperCase());if(s!==undefined){o.value=s}else if(i[n]==="Sort"){o.value=100}var a=BX.create("div",{attrs:{className:"crm-entity-widget-content-block-inner"},children:[this.createTitleNode(this.getMessage("fieldTitle"+i[n])),BX.create("input",{attrs:o})]});this._innerWrapper.appendChild(a)}if(BX.type.isDomNode(this._addPropertyLink)&&!BX.hasClass(this._addPropertyLink,"crm-entity-widget-content-block-edit-action-btn-added")){BX.addClass(this._addPropertyLink,"crm-entity-widget-content-block-edit-action-btn-added")}this.markAsChanged()};BX.Crm.EntityEditorOrderProductProperty.prototype.save=function(t){if(BX.type.isDomNode(this._wrapper)){var e={};var r=this._wrapper.querySelectorAll("input");for(var i=0;i<r.length;i++){e[r[i].name]=r[i].value}this._model.setField(this.getName(),e,{originator:this})}};BX.Crm.EntityEditorOrderProductProperty.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorOrderProductProperty.messages;return e.hasOwnProperty(t)?e[t]:t};BX.Crm.EntityEditorOrderProductProperty.create=function(t,e){var r=new BX.Crm.EntityEditorOrderProductProperty;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderTradingPlatform==="undefined"){BX.Crm.EntityEditorOrderTradingPlatform=function(){BX.Crm.EntityEditorOrderTradingPlatform.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderTradingPlatform,BX.UI.EntityEditorList);BX.Crm.EntityEditorOrderTradingPlatform.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderTradingPlatform.superclass.initialize.call(this,t,e);BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterUpdate,this));this._baseValue=this.getValue()};BX.Crm.EntityEditorOrderTradingPlatform.prototype.onItemSelect=function(t,e){if(this._selectedValue!==e.value){BX.Crm.EntityEditorOrderTradingPlatform.superclass.onItemSelect.apply(this,[t,e]);for(var r=0,i=this._editor._controllers.length;r<i;r++){if(this._editor._controllers[r]instanceof BX.Crm.EntityEditorOrderController){this._editor._controllers[r].onDataChanged()}}}else{this.closeMenu();BX.PopupMenu.destroy(this._id)}};BX.Crm.EntityEditorOrderTradingPlatform.prototype.getDragObjectType=function(){return BX.UI.EditorDragObjectType.intermediate};BX.Crm.EntityEditorOrderTradingPlatform.prototype.onAfterUpdate=function(t,e){if(this.isChanged()){this._baseValue=this.getValue()}};BX.Crm.EntityEditorOrderTradingPlatform.create=function(t,e){var r=new BX.Crm.EntityEditorOrderTradingPlatform;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderPersonType==="undefined"){BX.Crm.EntityEditorOrderPersonType=function(){BX.Crm.EntityEditorOrderPersonType.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderPersonType,BX.UI.EntityEditorList);BX.Crm.EntityEditorOrderPersonType.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderPersonType.superclass.initialize.call(this,t,e);BX.addCustomEvent(window,BX.Crm.EntityEvent.names.update,BX.delegate(this.onAfterUpdate,this));this._baseValue=this.getValue()};BX.Crm.EntityEditorOrderPersonType.prototype.onItemSelect=function(t,e){if(this._selectedValue!==e.value){BX.Crm.EntityEditorOrderPersonType.superclass.onItemSelect.apply(this,[t,e]);for(var r=0,i=this._editor._controllers.length;r<i;r++){if(this._editor._controllers[r]instanceof BX.Crm.EntityEditorOrderController&&this._selectedValue!=="NEW"){this._editor._controllers[r].onDataChanged()}}}else{this.closeMenu();BX.PopupMenu.destroy(this._id)}};BX.Crm.EntityEditorOrderPersonType.prototype.getDragObjectType=function(){return BX.UI.EditorDragObjectType.intermediate};BX.Crm.EntityEditorOrderPersonType.prototype.onAfterUpdate=function(t,e){if(this.isChanged()){this._baseValue=this.getValue()}};BX.Crm.EntityEditorOrderPersonType.create=function(t,e){var r=new BX.Crm.EntityEditorOrderPersonType;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderUser==="undefined"){BX.Crm.EntityEditorOrderUser=function(){BX.Crm.EntityEditorOrderUser.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderUser,BX.Crm.EntityEditorClientLight);BX.Crm.EntityEditorOrderUser.prototype.doInitialize=function(){BX.Crm.EntityEditorOrderUser.superclass.doInitialize.apply(this);this._selectedValue=null;this._searchBox=null};BX.Crm.EntityEditorOrderUser.prototype.addContact=function(t){if(t instanceof BX.CrmEntityInfo){this._contactInfos.add(t)}};BX.Crm.EntityEditorOrderUser.prototype.removeContact=function(t){if(t instanceof BX.CrmEntityInfo){this._contactInfos.remove(t)}};BX.Crm.EntityEditorOrderUser.prototype.setContacts=function(t){this._contactInfos.removeAll();for(var e=0,r=t.length;e<r;e++){var i=t[e];if(i instanceof BX.CrmEntityInfo){this._contactInfos.add(i)}}};BX.Crm.EntityEditorOrderUser.prototype.hasContentToDisplay=function(){return this._companyInfo!==null||this._contactInfos!==null&&this._contactInfos.length()>0};BX.Crm.EntityEditorOrderUser.prototype.getContentWrapper=function(){return this._innerWrapper};BX.Crm.EntityEditorOrderUser.prototype.getModeSwitchType=function(t){var e=BX.UI.EntityEditorModeSwitchType.common;if(t===BX.UI.EntityEditorMode.edit){e|=BX.UI.EntityEditorModeSwitchType.button|BX.UI.EntityEditorModeSwitchType.content}return e};BX.Crm.EntityEditorOrderUser.prototype.rollback=function(){};BX.Crm.EntityEditorOrderUser.prototype.doPrepareContextMenuItems=function(t){};BX.Crm.EntityEditorOrderUser.prototype.layout=function(t){if(this._hasLayout){return}this.ensureWrapperCreated();this.adjustWrapper();if(!this.isNeedToDisplay()){this.registerLayout(t);this._hasLayout=true;return}if(this.isDragEnabled()){this._wrapper.appendChild(this.createDragButton())}this._wrapper.appendChild(this.createTitleNode(this.getTitle()));if(this.isInViewMode()){var e=this._model.getSchemeField(this._schemeElement,"formated","");var r=this._model.getSchemeField(this._schemeElement,"position","");var i=this._model.getSchemeField(this._schemeElement,"showUrl","","");var n=this._model.getSchemeField(this._schemeElement,"photoUrl","");this._photoElement=BX.create("a",{props:{className:"crm-widget-employee-avatar-container",target:"_blank"},style:{backgroundImage:n!==""?"url('"+n+"')":"",backgroundSize:n!==""?"30px":""}});this._nameElement=BX.create("a",{props:{className:"crm-widget-employee-name",target:"_blank"},text:e});if(i!==""){this._photoElement.href=i;this._nameElement.href=i}this._positionElement=BX.create("SPAN",{props:{className:"crm-widget-employee-position"},text:r});if(this.isInEditMode()){this._wrapper.appendChild(this.createDragButton())}var o=BX.create("div",{props:{className:"crm-widget-employee-container"}});if(this.isEditable()){this._editButton=BX.create("span",{props:{className:"crm-widget-employee-change"},text:this.getMessage("change")});BX.bind(this._editButton,"click",BX.delegate(this.onEditButtonClick,this));o.appendChild(this._editButton)}o.appendChild(this._photoElement);o.appendChild(BX.create("span",{props:{className:"crm-widget-employee-info"},children:[this._nameElement,this._positionElement]}));this._searchBox=null;this._wrapper.appendChild(BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[o]}))}else{this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"}});this._wrapper.appendChild(this._innerWrapper);BX.addClass(this._innerWrapper,"crm-entity-widget-content-inner");var s=BX.create("div",{props:{className:"crm-entity-widget-content-block-field-container"}});this._innerWrapper.appendChild(s);this._innerContainer=BX.create("div",{props:{className:"crm-entity-widget-content-block-field-container-inner"}});s.appendChild(this._innerContainer);var a=this._schemeElement.getName();this._selectedValue=this._model.getField(a);this._contactSearchBoxes=[];this._searchBox=this.addSearchBox(this.createSearchBox())}if(this.isContextMenuEnabled()){this._wrapper.appendChild(this.createContextMenuButton())}if(this.isDragEnabled()){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorOrderUser.prototype.onEditButtonClick=function(t){this.switchToSingleEditMode(t.target)};BX.Crm.EntityEditorOrderUser.prototype.isSingleEditEnabled=function(){return true};BX.Crm.EntityEditorOrderUser.prototype.hasContentToDisplay=function(){return this.hasValue()};BX.Crm.EntityEditorOrderUser.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}if(BX.prop.getBoolean(t,"forAll",false)&&this._searchBox){var e=this._model.getSchemeField(this._schemeElement,"defaultUserList",[]);this._searchBox._searchControl.setItems(e)}var r=this._schemeElement.getName();if(this._selectedValue!=this._model.getField(r)){this.refreshLayout()}};BX.Crm.EntityEditorOrderUser.prototype.addSearchBox=function(t){this._contactSearchBoxes.push(t);var e={};if(this._addContactButton){e["anchor"]=this._addContactButton}t.layout(e);return t};BX.Crm.EntityEditorOrderUser.prototype.createSearchBox=function(t){var e=this._schemeElement.getName();var r=this._model.getField(e);var i=BX.CrmEntityInfo.create({title:this._model.getSchemeField(this._schemeElement,"formated",""),entityId:r});if(i!==null&&!(i instanceof BX.CrmEntityInfo)){i=null}return BX.Crm.EntityEditorOrderClientSearchBox.create(this._id,{entityInfo:i,enableCreation:false,loaderConfig:this._primaryLoaderConfig,lastEntityInfos:this._model.getSchemeField(this._schemeElement,"defaultUserList",[]),container:this._innerContainer,enableDeletion:true,placeholder:this.getMessage("searchPlaceholder"),parentField:this})};BX.Crm.EntityEditorOrderUser.prototype.save=function(){if(!this.isEditable()){return}this._model.setField(this.getName(),this._selectedValue)};BX.Crm.EntityEditorOrderUser.prototype.onContactAddButtonClick=function(t){};BX.Crm.EntityEditorOrderUser.prototype.onCompanyReset=function(t,e){};BX.Crm.EntityEditorOrderUser.prototype.onCompanyChange=function(t,e,r){};BX.Crm.EntityEditorOrderUser.prototype.onContactInfosLoad=function(t,e){};BX.Crm.EntityEditorOrderUser.prototype.getRuntimeValue=function(){if(this._mode===BX.UI.EntityEditorMode.edit&&this._selectedValue){return this._selectedValue}return""};BX.Crm.EntityEditorOrderUser.prototype.onRequisiteChange=function(t,e){};BX.Crm.EntityEditorOrderUser.prototype.onBeforeSubmit=function(){};BX.Crm.EntityEditorOrderUser.prototype.processItemSelect=function(t){var e=this._mode===BX.UI.EntityEditorMode.view;var r=this.isEditInViewEnabled();var n=BX.prop.getInteger(t,"id",0);if(e&&!r){return}this._selectedValue=n;if(!e){this.markAsChanged()}else{this._editor.saveControl(this)}if(!e){for(i=0,length=this._editor._controllers.length;i<length;i++){if(this._editor._controllers[i]instanceof BX.Crm.EntityEditorOrderController){this._editor._controllers[i].onDataChanged()}}}};BX.Crm.EntityEditorOrderUser.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorOrderUser.messages;return e.hasOwnProperty(t)?e[t]:BX.Crm.EntityEditorOrderUser.superclass.getMessage.apply(this,arguments)};BX.Crm.EntityEditorOrderUser.create=function(t,e){var r=new BX.Crm.EntityEditorOrderUser;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderClientSearchBox==="undefined"){BX.Crm.EntityEditorOrderClientSearchBox=function(){this._id="";this._settings={};this._container=null;this._wrapper=null;this._resetButton=null;this._parentField=null;this._entityInfo=null;this._searchInput=null;this._searchControl=null;this._loaderConfig=null;this._resetButtonHandler=BX.delegate(this.onResetButtonClick,this);this._hasLayout=false};BX.Crm.EntityEditorOrderClientSearchBox.prototype.initialize=function(t,e){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=e?e:{};this._parentField=BX.prop.get(this._settings,"parentField",null);this._container=BX.prop.getElementNode(this._settings,"container",null);var r=BX.prop.get(this._settings,"entityInfo",null);if(r){this._entityInfo=r}this._loaderConfig=BX.prop.get(this._settings,"loaderConfig",null)};BX.Crm.EntityEditorOrderClientSearchBox.prototype.layout=function(t){if(this._hasLayout){return}if(!BX.type.isPlainObject(t)){t={}}this._wrapper=BX.create("div",{props:{className:"crm-entity-widget-content-search-row"}});this.innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-search-inner"}});var e=BX.prop.getElementNode(t,"anchor",null);if(e){this._container.insertBefore(this._wrapper,e)}else{this._container.appendChild(this._wrapper)}this._wrapper.appendChild(this.innerWrapper);var r=BX.create("div",{props:{className:"crm-entity-widget-content-search-box"}});this.innerWrapper.appendChild(r);var i=BX.create("div",{props:{className:"crm-entity-widget-img-box crm-entity-widget-img-contact"}});r.appendChild(i);this._searchInput=BX.create("input",{props:{type:"text",placeholder:BX.prop.getString(this._settings,"placeholder",""),className:"crm-entity-widget-content-input crm-entity-widget-content-search-input",autocomplete:"off"}});r.appendChild(this._searchInput);BX.bind(this._searchInput,"focus",this._inputFocusHandler);BX.bind(this._searchInput,"blur",this._inputBlurHandler);this._resetButton=BX.create("div",{props:{className:"crm-entity-widget-btn-close"}});this.innerWrapper.appendChild(this._resetButton);BX.bind(this._resetButton,"click",this._resetButtonHandler);if(this._entityInfo){this._searchInput.value=this._entityInfo.getTitle()}this._searchControl=new BX.UI.Dropdown({searchAction:"crm.api.orderbuyer.search",searchOptions:{emptyItem:{subtitle:this.getMessage("notFound"),title:""}},searchResultRenderer:null,targetElement:this._searchInput,items:BX.prop.getArray(this._settings,"lastEntityInfos",[]),enableCreation:false,showEmptyContainer:true,messages:{notFound:this.getMessage("notFound")},events:{onSelect:this.onEntitySelect.bind(this)}});this._hasLayout=true};BX.Crm.EntityEditorOrderClientSearchBox.prototype.validate=function(t){return true};BX.Crm.EntityEditorOrderClientSearchBox.prototype.release=function(){return true};BX.Crm.EntityEditorOrderClientSearchBox.prototype.onEntitySelect=function(t,e){var r=BX.prop.getInteger(e,"id",0);var i=BX.prop.getString(e,"title","");if(r<=0){return}this._searchInput.value=i;if(this._parentField instanceof BX.Crm.EntityEditorOrderUser){this._parentField.processItemSelect(e)}this._searchControl.alertEmptyContainer=null;this._searchControl.destroyPopupWindow()};BX.Crm.EntityEditorOrderClientSearchBox.prototype.onResetButtonClick=function(t){this._searchInput.value="";if(this._parentField instanceof BX.Crm.EntityEditorOrderUser){this._parentField.processItemSelect({item:null})}};BX.Crm.EntityEditorOrderClientSearchBox.prototype.getMessage=function(t){return BX.prop.getString(BX.Crm.EntityEditorOrderClientSearchBox.messages,t)};if(typeof BX.Crm.EntityEditorOrderClientSearchBox.messages==="undefined"){BX.Crm.EntityEditorOrderClientSearchBox.messages={}}BX.Crm.EntityEditorOrderClientSearchBox.create=function(t,e){var r=new BX.Crm.EntityEditorOrderClientSearchBox;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderClient==="undefined"){BX.Crm.EntityEditorOrderClient=function(){BX.Crm.EntityEditorOrderClient.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderClient,BX.Crm.EntityEditorClientLight);BX.Crm.EntityEditorOrderClient.prototype.save=function(){BX.Crm.EntityEditorOrderClient.superclass.save.apply(this);if(this._item&&this._item._requisitePanel){this._model.setField("REQUISITE_BINDING",this._item._requisitePanel.getRuntimeValue())}};BX.Crm.EntityEditorOrderClient.prototype.getRuntimeValue=function(){var t={};var e=BX.prop.getString(this._map,"companyId","");if(e!==""&&this._companyInfos&&this._companyInfos.length()>0){var r=this._companyInfos.get(0);t[e]=r.getId()}var i=[];var n,o;if(this._contactInfos!==null){var s=this._contactInfos.getItems();for(n=0,o=s.length;n<o;n++){var a=s[n];i.push(a.getId())}}e=BX.prop.getString(this._map,"contactIds","");if(e!==""){t[e]=i}if(this._item&&this._item._requisitePanel){t["REQUISITE_BINDING"]=this._item._requisitePanel.getRuntimeValue()}return t};BX.Crm.EntityEditorOrderClient.prototype.onCompanyChange=function(t,e,r){BX.Crm.EntityEditorOrderClient.superclass.onCompanyChange.call(this,t,e,r);if(e.getId()>0){for(var i=0,n=this._editor._controllers.length;i<n;i++){if(this._editor._controllers[i]instanceof BX.Crm.EntityEditorOrderController||this._editor._controllers[i]instanceof BX.Crm.EntityEditorDocumentOrderShipmentController){this._editor._controllers[i].onDataChanged();this._editor._controllers[i].unlockSending();return}}}};BX.Crm.EntityEditorOrderClient.prototype.onContactChange=function(t,e,r){BX.Crm.EntityEditorOrderClient.superclass.onContactChange.call(this,t,e,r);for(var i=0,n=this._editor._controllers.length;i<n;i++){if(this._editor._controllers[i]instanceof BX.Crm.EntityEditorOrderController||this._editor._controllers[i]instanceof BX.Crm.EntityEditorDocumentOrderShipmentController){this._editor._controllers[i].onDataChanged();this._editor._controllers[i].unlockSending();return}}};BX.Crm.EntityEditorOrderClient.prototype.onContactInfosLoad=function(t,e){BX.Crm.EntityEditorOrderClient.superclass.onContactInfosLoad.call(this,t,e);for(var r=0,i=this._editor._controllers.length;r<i;r++){if(this._editor._controllers[r]instanceof BX.Crm.EntityEditorOrderController||this._editor._controllers[r]instanceof BX.Crm.EntityEditorDocumentOrderShipmentController){this._editor._controllers[r].onDataChanged();this._editor._controllers[r].unlockSending();return}}};BX.Crm.EntityEditorOrderClient.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}if(BX.prop.getBoolean(t,"forAll",false)&&this._companySearchBox){var e=this._model.getSchemeField(this._schemeElement,"lastCompanyInfos",[]);if(BX.type.isNotEmptyObject(e)){this._companySearchBox._searchControl.setItems(e);this._companySearchBox._searchControl.setDefaultItems(e)}}var r=this._model.getSchemeField(this._schemeElement,"lastContactInfos",[]);if(BX.prop.getBoolean(t,"forAll",false)&&BX.type.isArray(this._contactSearchBoxes)&&this._contactSearchBoxes.length>0&&BX.type.isNotEmptyObject(r)){for(var i=0;i<this._contactSearchBoxes.length;i++){this._contactSearchBoxes[i]._searchControl.setItems(r);this._contactSearchBoxes[i]._searchControl.setDefaultItems(r)}}};BX.Crm.EntityEditorOrderClient.create=function(t,e){var r=new BX.Crm.EntityEditorOrderClient;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorMultiList==="undefined"){BX.Crm.EntityEditorMultiList=BX.UI.EntityEditorMultiList}if(typeof BX.Crm.EntityEditorOrderQuantity==="undefined"){BX.Crm.EntityEditorOrderQuantity=function(){BX.Crm.EntityEditorOrderQuantity.superclass.constructor.apply(this);this._amountInput=null;this._measureInput=null;this._sumElement=null;this._selectContainer=null;this._inputWrapper=null;this._innerWrapper=null;this._selectedMeasureValue="";this._selectorClickHandler=BX.delegate(this.onSelectorClick,this);this._isMesureMenuOpened=false};BX.extend(BX.Crm.EntityEditorOrderQuantity,BX.Crm.EntityEditorField);BX.Crm.EntityEditorOrderQuantity.prototype.getModeSwitchType=function(t){var e=BX.UI.EntityEditorModeSwitchType.common;if(t===BX.UI.EntityEditorMode.edit){e|=BX.UI.EntityEditorModeSwitchType.button|BX.UI.EntityEditorModeSwitchType.content}return e};BX.Crm.EntityEditorOrderQuantity.prototype.getContentWrapper=function(){return this._innerWrapper};BX.Crm.EntityEditorOrderQuantity.prototype.focus=function(){if(this._amountInput){BX.focus(this._amountInput);BX.Crm.EditorTextHelper.getCurrent().selectAll(this._amountInput)}};BX.Crm.EntityEditorOrderQuantity.prototype.getValue=function(t){if(!this._model){return""}return this._model.getStringField(this.getAmountFieldName(),t!==undefined?t:"")};BX.Crm.EntityEditorOrderQuantity.prototype.layout=function(t){if(this._hasLayout){return}this.ensureWrapperCreated({classNames:["crm-entity-widget-content-block-field-order-quantity"]});this.adjustWrapper();if(!this.isNeedToDisplay()){this.registerLayout(t);this._hasLayout=true;return}var e=this.getTitle();var r=this.getData();var i=BX.prop.getString(r,"amount");var n=BX.prop.getString(BX.prop.getObject(r,"measure"),"name");this._selectedMeasureValue=this._model.getStringField(BX.prop.getString(BX.prop.getObject(r,"measure"),"name",""));var o=BX.prop.getArray(BX.prop.getObject(r,"measure"),"items");var s="";if(!this._selectedMeasureValue){var a=o.length>0?o[0]:null;if(a){this._selectedMeasureValue=a["VALUE"];s=a["NAME"]}}else{s=this._editor.findOption(this._selectedMeasureValue,o)}var d=this.getAmountFieldName();var l=this._model.getField(BX.prop.getString(r,"formatted"),"");this._amountInput=null;this._measureInput=null;this._selectContainer=null;this._innerWrapper=null;this._sumElement=null;if(this.isDragEnabled()){this._wrapper.appendChild(this.createDragButton())}if(this._mode===BX.UI.EntityEditorMode.edit){this._wrapper.appendChild(this.createTitleNode(e));this._amountInput=BX.create("input",{attrs:{className:"crm-entity-widget-content-input",name:i,type:"text",value:l}});BX.bind(this._amountInput,"input",this._changeHandler);if(this._model.isFieldLocked(d)){this._amountInput.disabled=true}this._measureInput=BX.create("input",{attrs:{name:n,type:"hidden",value:this._selectedMeasureValue}});this._selectContainer=BX.create("div",{props:{className:"crm-entity-widget-content-select"},text:s});BX.bind(this._selectContainer,"click",this._selectorClickHandler);this._inputWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-input-wrapper"},children:[this._amountInput,this._measureInput,BX.create("div",{props:{className:"crm-entity-widget-content-block-select"},children:[this._selectContainer]})]});this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner crm-entity-widget-content-block-colums-input"},children:[this._inputWrapper]})}else{this._wrapper.appendChild(this.createTitleNode(e));if(this.hasContentToDisplay()){var c=BX.prop.getString(this._schemeElement.getDataObjectParam("formattedWithCurrency",{}),"name","");this._sumElement=BX.create("span",{attrs:{className:"crm-entity-widget-content-block-wallet"}});this._sumElement.innerHTML=this._model.getField(c,"");this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-colums-block"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-colums"},children:[this._sumElement]})]})]})}else{this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},text:this.getMessage("isEmpty")})}}this._wrapper.appendChild(this._innerWrapper);if(this.isContextMenuEnabled()){this._wrapper.appendChild(this.createContextMenuButton())}if(this.isDragEnabled()){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorOrderQuantity.prototype.doClearLayout=function(t){BX.PopupMenu.destroy(this._id);this._amountInput=null;this._measureInput=null;this._sumElement=null;this._selectContainer=null;this._inputWrapper=null;this._innerWrapper=null};BX.Crm.EntityEditorOrderQuantity.prototype.getAmountFieldName=function(){return this._schemeElement.getDataStringParam("amount","")};BX.Crm.EntityEditorOrderQuantity.prototype.getMeasureFieldName=function(){return BX.prop.getString(this._schemeElement.getDataObjectParam("measure",{}),"name","")};BX.Crm.EntityEditorOrderQuantity.prototype.onSelectorClick=function(t){this.openMeasureMenu()};BX.Crm.EntityEditorOrderQuantity.prototype.openMeasureMenu=function(){if(this._isMesureMenuOpened){return}var t=this._schemeElement.getData();var e=BX.prop.getArray(BX.prop.getObject(t,"measure"),"items");var r=0;var i=[];while(r<e.length){i.push({text:e[r]["NAME"],value:e[r]["VALUE"],onclick:BX.delegate(this.onMeasureSelect,this)});r++}BX.PopupMenu.show(this._id,this._selectContainer,i,{angle:false,width:this._selectContainer.offsetWidth+"px",events:{onPopupShow:BX.delegate(this.onMeasureMenuOpen,this),onPopupClose:BX.delegate(this.onMeasureMenuClose,this)}});BX.PopupMenu.currentItem.popupWindow.setWidth(BX.pos(this._selectContainer)["width"])};BX.Crm.EntityEditorOrderQuantity.prototype.closeMeasureMenu=function(){if(!this._isMesureMenuOpened){return}var t=BX.PopupMenu.getMenuById(this._id);if(t){t.popupWindow.close()}};BX.Crm.EntityEditorOrderQuantity.prototype.onMeasureMenuOpen=function(){BX.addClass(this._selectContainer,"active");this._isMesureMenuOpened=true};BX.Crm.EntityEditorOrderQuantity.prototype.onMeasureMenuClose=function(){BX.PopupMenu.destroy(this._id);BX.removeClass(this._selectContainer,"active");this._isMesureMenuOpened=false};BX.Crm.EntityEditorOrderQuantity.prototype.onMeasureSelect=function(t,e){this.closeMeasureMenu();this._selectedMeasureValue=this._measureInput.value=e.value;this._selectContainer.innerHTML=BX.util.htmlspecialchars(e.text);this.markAsChanged({fieldName:this.getMeasureFieldName(),fieldValue:this._selectedMeasureValue})};BX.Crm.EntityEditorOrderQuantity.prototype.processModelLock=function(t){var e=BX.prop.getString(t,"name","");if(this.getAmountFieldName()===e){this.refreshLayout()}};BX.Crm.EntityEditorOrderQuantity.prototype.validate=function(t){if(!(this._mode===BX.UI.EntityEditorMode.edit&&this._amountInput)){throw"BX.Crm.EntityEditorOrderQuantity. Invalid validation context"}this.clearError();if(this.hasValidators()){return this.executeValidators(t)}var e=!this.isRequired()||BX.util.trim(this._amountInput.value)!=="";if(!e){t.addError(BX.Crm.EntityValidationError.create({field:this}));this.showRequiredFieldError(this._inputWrapper)}return e};BX.Crm.EntityEditorOrderQuantity.prototype.showError=function(t,e){BX.Crm.EntityEditorOrderQuantity.superclass.showError.apply(this,arguments);if(this._amountInput){BX.addClass(this._amountInput,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorOrderQuantity.prototype.clearError=function(){BX.Crm.EntityEditorOrderQuantity.superclass.clearError.apply(this);if(this._amountInput){BX.removeClass(this._amountInput,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorOrderQuantity.prototype.getRuntimeValue=function(){var t=[];if(this._mode===BX.UI.EntityEditorMode.edit){if(this._amountInput){t[BX.prop.getString(t,"amount")]=this._amountInput.value}t[BX.prop.getString(t,"measure")]=this._selectedMeasureValue;return t}return""};BX.Crm.EntityEditorOrderQuantity.prototype.save=function(){var t=this._schemeElement.getData();this._model.setField(BX.prop.getString(BX.prop.getObject(t,"measure"),"name"),this._selectedMeasureValue);if(this._amountInput){this._model.setField(BX.prop.getString(t,"amount"),this._amountInput.value);this._model.setField(BX.prop.getString(t,"formatted"),this._amountInput.value)}};BX.Crm.EntityEditorOrderQuantity.create=function(t,e){var r=new BX.Crm.EntityEditorOrderQuantity;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderPropertyFile==="undefined"){BX.Crm.EntityEditorOrderPropertyFile=function(){BX.Crm.EntityEditorOrderPropertyFile.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderPropertyFile,BX.UI.EntityEditorCustom);BX.Crm.EntityEditorOrderPropertyFile.prototype.layout=function(t){BX.Crm.EntityEditorOrderPropertyFile.superclass.layout.apply(this,arguments);if(this._mode===BX.UI.EntityEditorMode.edit){setTimeout(BX.delegate((function(){var t=this._innerWrapper.querySelectorAll('input[type="checkbox"]');for(var e=0;e<t.length;e++){BX.bind(t[e],"change",BX.delegate((function(){BX.onCustomEvent("CrmOrderPropertySetCustom",[this.getName()])}),this))}}),this),10)}};BX.Crm.EntityEditorOrderPropertyFile.create=function(t,e){var r=new BX.Crm.EntityEditorOrderPropertyFile;r.initialize(t,e);return r}}if(typeof BX.Crm.OrderModel==="undefined"){BX.Crm.OrderModel=function(){BX.Crm.OrderModel.superclass.constructor.apply(this)};BX.extend(BX.Crm.OrderModel,BX.Crm.EntityModel);BX.Crm.OrderModel.prototype.doInitialize=function(){BX.addCustomEvent(window,"Crm.EntityProgress.Change",BX.delegate(this.onEntityProgressChange,this))};BX.Crm.OrderModel.prototype.onEntityProgressChange=function(t,e){if(BX.prop.getInteger(e,"entityTypeId",0)!==this.getEntityTypeId()||BX.prop.getInteger(e,"entityId",0)!==this.getEntityId()){return}var r=BX.prop.getString(e,"currentStepId","");if(r!==this.getField("STATUS_ID","")){this.setField("STATUS_ID",r)}};BX.Crm.OrderModel.prototype.getEntityTypeId=function(){return BX.CrmEntityType.enumeration.order};BX.Crm.OrderModel.prototype.isCaptionEditable=function(){return false};BX.Crm.OrderModel.prototype.getCaption=function(){var t=this.getField("TITLE");return BX.type.isString(t)?t:""};BX.Crm.OrderModel.prototype.setCaption=function(t){this.setField("TITLE",t)};BX.Crm.OrderModel.prototype.prepareCaptionData=function(t){t["TITLE"]=this.getField("TITLE","")};BX.Crm.OrderModel.create=function(t,e){var r=new BX.Crm.OrderModel;r.initialize(t,e);return r}}if(typeof BX.Crm.OrderShipmentModel==="undefined"){BX.Crm.OrderShipmentModel=function(){BX.Crm.OrderShipmentModel.superclass.constructor.apply(this)};BX.extend(BX.Crm.OrderShipmentModel,BX.Crm.EntityModel);BX.Crm.OrderShipmentModel.prototype.doInitialize=function(){BX.addCustomEvent(window,"Crm.EntityProgress.Change",BX.delegate(this.onEntityProgressChange,this))};BX.Crm.OrderShipmentModel.prototype.onEntityProgressChange=function(t,e){if(BX.prop.getInteger(e,"entityTypeId",0)!==this.getEntityTypeId()||BX.prop.getInteger(e,"entityId",0)!==this.getEntityId()){return}var r=BX.prop.getString(e,"currentStepId","");if(r!==this.getField("STATUS_ID","")){this.setField("STATUS_ID",r)}};BX.Crm.OrderShipmentModel.prototype.isCaptionEditable=function(){return false};BX.Crm.OrderShipmentModel.prototype.getEntityTypeId=function(){return BX.CrmEntityType.enumeration.ordershipment};BX.Crm.OrderShipmentModel.prototype.getCaption=function(){return this.getField("TITLE","")};BX.Crm.OrderShipmentModel.create=function(t,e){var r=new BX.Crm.OrderShipmentModel;r.initialize(t,e);return r}}if(typeof BX.Crm.OrderPaymentModel==="undefined"){BX.Crm.OrderPaymentModel=function(){BX.Crm.OrderPaymentModel.superclass.constructor.apply(this)};BX.extend(BX.Crm.OrderPaymentModel,BX.Crm.EntityModel);BX.Crm.OrderPaymentModel.prototype.isCaptionEditable=function(){return false};BX.Crm.OrderPaymentModel.prototype.getEntityTypeId=function(){return BX.CrmEntityType.enumeration.orderpayment};BX.Crm.OrderPaymentModel.prototype.getCaption=function(){return this.getField("TITLE","")};BX.Crm.OrderPaymentModel.create=function(t,e){var r=new BX.Crm.OrderPaymentModel;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderUserSelector==="undefined"){BX.Crm.EntityEditorOrderUserSelector=function(){BX.Crm.EntityEditorOrderUserSelector.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorOrderUserSelector,BX.UI.EntityEditorUserSelector);BX.Crm.EntityEditorOrderUserSelector.prototype.initialize=function(t,e){BX.Crm.EntityEditorOrderUserSelector.superclass.initialize.call(this,t,e);this._editor=BX.prop.get(e,"editor");this._url=BX.prop.getString(e,"url");for(var r=0,i=this._editor._controllers.length;r<i;r++){if(this._editor._controllers[r]instanceof BX.Crm.EntityEditorOrderController){this._controller=this._editor._controllers[r];break}}};BX.Crm.EntityEditorOrderUserSelector.prototype.open=function(t){if(!(BX.type.isDomNode(this._editor._formElement)&&BX.type.isNotEmptyString(this._url))){BX.Crm.EntityEditorOrderUserSelector.superclass.open.call(this,t);return}window.open(this._url,"","scrollbars=yes,resizable=yes,width=840,height=500,top="+Math.floor((screen.height-840)/2-14)+",left="+Math.floor((screen.width-760)/2-5));BX.bind(this._editor._formElement[this._id],"change",BX.delegate((function(){this.onChangeUserId(this._editor._formElement[this._id].value)}),this))};BX.Crm.EntityEditorOrderUserSelector.prototype.onChangeUserId=function(t){if(this._controller){this._controller.ajax("loadUserInfo",{data:{USER_ID:t,ENTITY_ID:this._editor.getEntityId()},onsuccess:BX.delegate(this.onLoadUserInfo,this)})}};BX.Crm.EntityEditorOrderUserSelector.prototype.onLoadUserInfo=function(t){if(this._controller){this._controller._isRequesting=false;this._controller.hideLoader()}if(t.ERROR){return}this.onSelect(t.USER_DATA,"users")};BX.Crm.EntityEditorOrderUserSelector.items={};BX.Crm.EntityEditorOrderUserSelector.create=function(t,e){var r=new BX.Crm.EntityEditorOrderUserSelector(t,e);r.initialize(t,e);this.items[r.getId()]=r;return r}}if(typeof BX.Crm.EntityEditorDeliverySelector==="undefined"){BX.Crm.EntityEditorDeliverySelector=function(){BX.Crm.EntityEditorDeliverySelector.superclass.constructor.apply(this);this._innerWrapper=null;this._deliverySelector=null;this._profileSelector=null;this._storeSelector=null;this._input=null;this._inputStore=null};BX.extend(BX.Crm.EntityEditorDeliverySelector,BX.Crm.EntityEditorField);BX.Crm.EntityEditorDeliverySelector.prototype.getModeSwitchType=function(t){var e=BX.UI.EntityEditorModeSwitchType.common;if(t===BX.UI.EntityEditorMode.edit){e|=BX.UI.EntityEditorModeSwitchType.button|BX.UI.EntityEditorModeSwitchType.content}return e};BX.Crm.EntityEditorDeliverySelector.prototype.getContentWrapper=function(){return this._innerWrapper};BX.Crm.EntityEditorDeliverySelector.prototype.layout=function(t){if(this._hasLayout){return}this.ensureWrapperCreated();this.adjustWrapper();if(!this.isNeedToDisplay()){this.registerLayout(t);this._hasLayout=true;return}var e=this.getTitle();if(this.isDragEnabled()){this._wrapper.appendChild(this.createDragButton())}this._wrapper.appendChild(this.createTitleNode(e));if(this._mode===BX.UI.EntityEditorMode.edit){this._deliverySelector=BX.create("select",{events:{change:BX.proxy((function(){this.onSelectorChange("delivery")}),this)}});this.setOptionsList(this._deliverySelector,this.getModel().getField("DELIVERY_SERVICES_LIST"),this.getModel().getIntegerField("DELIVERY_SELECTOR_DELIVERY_ID"));var r=this.getModel().getField("DELIVERY_PROFILES_LIST");if(BX.type.isNotEmptyObject(r)){this._profileSelector=this.createProfileSelector();this.setOptionsList(this._profileSelector,r,this.getModel().getIntegerField("DELIVERY_SELECTOR_PROFILE_ID"))}this._input=BX.create("input",{props:{type:"hidden",name:this.getName(),value:this.getValue()}});var i=this.getModel().getField("DELIVERY_STORES_LIST");if(BX.type.isNotEmptyObject(i)){this._storeSelector=this.createStoreSelector();this.setOptionsList(this._storeSelector,i,this.getModel().getIntegerField("DELIVERY_STORE_ID"));this.createInputStore()}this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("span",{props:{className:"fields enumeration field-wrap"},children:[BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._deliverySelector,this._input]})]})]});if(this._profileSelector!==null){this.insertProfileSelector()}if(this.getModel().getField("ERRORS")){this.processErrors(this.getModel().getField("ERRORS"))}else{this.clearError()}this._wrapper.appendChild(this._innerWrapper);if(this._storeSelector!==null){this.insertStoreSelector()}}else{var n=this.getModel().getStringField("DELIVERY_SERVICE_NAME")||this.getMessage("notSelected");this.setDeliveryServiceName(n);this._wrapper.appendChild(this._innerWrapper);if(parseInt(this.getModel().getField("DELIVERY_STORE_ID"))>0){this.setDeliveryStore()}}if(this.isContextMenuEnabled()){this._wrapper.appendChild(this.createContextMenuButton())}if(this.isDragEnabled()){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorDeliverySelector.prototype.createInputStore=function(){if(this._inputStore){return}this._inputStore=BX.create("input",{props:{type:"hidden",name:"DELIVERY_STORE_ID",value:this.getModel().getIntegerField("DELIVERY_STORE_ID")}})};BX.Crm.EntityEditorDeliverySelector.prototype.getInputStore=function(){if(!this._inputStore){this.createInputStore()}return this._inputStore};BX.Crm.EntityEditorDeliverySelector.prototype.setDeliveryServiceName=function(t){this._innerWrapper=BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},html:t})};BX.Crm.EntityEditorDeliverySelector.prototype.setDeliveryStore=function(){this._innerWrapper.parentNode.insertBefore(BX.create("div",{props:{className:"crm-entity-widget-content-block-inner"},children:[BX.create("div",{html:this.getModel().getField("DELIVERY_STORE_TITLE")}),BX.create("div",{html:this.getModel().getField("DELIVERY_STORE_ADDRESS"),style:{fontStyle:"italic",fontSize:"12px"}})]}),this._innerWrapper.nextSibling);this._innerWrapper.parentNode.insertBefore(BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},children:[BX.create("span",{props:{className:"crm-entity-widget-content-block-title-text"},html:this.getMessage("deliveryStore")})]}),this._innerWrapper.nextSibling)};BX.Crm.EntityEditorDeliverySelector.prototype.getController=function(){for(var t=0,e=this._editor._controllers.length;t<e;t++){if(this._editor._controllers[t]instanceof BX.Crm.EntityEditorOrderShipmentController){return this._editor._controllers[t]}}return null};if(typeof BX.Crm.EntityEditorDeliverySelector.messages==="undefined"){BX.Crm.EntityEditorDeliverySelector.messages={}}BX.Crm.EntityEditorDeliverySelector.prototype.onSelectorChange=function(t){this._input.value=this.obtainValueFromSelectors(t,this._deliverySelector,this._profileSelector,this._mode);this.markAsChanged();this.getController().onChangeDelivery()};BX.Crm.EntityEditorDeliverySelector.prototype.onStoreChange=function(){this.getInputStore().value=this._storeSelector.value;this.getModel().setField("DELIVERY_STORE_ID",this._storeSelector.value);this.markAsChanged()};BX.Crm.EntityEditorDeliverySelector.prototype.setOptionsList=function(t,e,r){if(t.childNodes.length>0){for(var i=t.childNodes.length-1;i>=0;i--){t.removeChild(t.childNodes[i])}}for(i in e){if(!e.hasOwnProperty(i)){continue}if(typeof e[i].ITEMS!=="undefined"){t.appendChild(this.createOptionsGroup(e[i],r))}else{var n=parseInt(r)===parseInt(e[i].ID);var o=new Option(e[i].NAME||e[i].TITLE,e[i].ID,n,n);t.options.add(o)}}return t};BX.Crm.EntityEditorDeliverySelector.prototype.createOptionsGroup=function(t,e){var r=BX.create("optgroup",{props:{label:t.NAME}});for(var i in t.ITEMS){if(!t.ITEMS.hasOwnProperty(i)){continue}r.appendChild(BX.create("option",{props:{value:t.ITEMS[i].ID,selected:e==t.ITEMS[i].ID},html:t.ITEMS[i].NAME}))}return r};BX.Crm.EntityEditorDeliverySelector.prototype.createProfileSelector=function(){return BX.create("select",{events:{change:BX.proxy((function(){this.onSelectorChange("profile")}),this)}})};BX.Crm.EntityEditorDeliverySelector.prototype.createStoreSelector=function(){return BX.create("select",{events:{change:BX.proxy((function(){this.onStoreChange()}),this)}})};BX.Crm.EntityEditorDeliverySelector.prototype.insertStoreSelector=function(){if(!this._innerWrapper){return}if(!this._storeSelector){return}this._innerWrapper.appendChild(BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{marginTop:"20px"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},style:{marginTop:"-16px"},children:[BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:this.getMessage("deliveryStore")})]}),BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._storeSelector,this.getInputStore()]})]}),this._innerWrapper)};BX.Crm.EntityEditorDeliverySelector.prototype.insertProfileSelector=function(){if(!this._innerWrapper){return}if(!this._profileSelector){return}this._innerWrapper.appendChild(BX.create("span",{props:{className:"fields enumeration field-wrap"},style:{marginTop:"20px"},children:[BX.create("div",{props:{className:"crm-entity-widget-content-block-title"},style:{marginTop:"-16px"},children:[BX.create("span",{attrs:{className:"crm-entity-widget-content-block-title-text"},text:this.getMessage("deliveryProfile")})]}),BX.create("span",{props:{className:"fields enumeration field-item"},children:[this._profileSelector]})]}),this._innerWrapper)};BX.Crm.EntityEditorDeliverySelector.prototype.removeProfileSelector=function(){if(!this._profileSelector){return}this._profileSelector.parentNode.parentNode.parentNode.removeChild(this._profileSelector.parentNode.parentNode);this._profileSelector=null};BX.Crm.EntityEditorDeliverySelector.prototype.removeStoreSelector=function(){if(!this._storeSelector){return}this._storeSelector.parentNode.parentNode.parentNode.removeChild(this._storeSelector.parentNode.parentNode);this._storeSelector=null};BX.Crm.EntityEditorDeliverySelector.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorDeliverySelector.messages;return e.hasOwnProperty(t)?e[t]:BX.Crm.EntityEditorDeliverySelector.superclass.getMessage.apply(this,arguments)};BX.Crm.EntityEditorDeliverySelector.prototype.doClearLayout=function(t){this._deliverySelector=null;this._profileSelector=null;this._storeSelector=null;this._innerWrapper=null;this._input=null;this._inputStore=null};BX.Crm.EntityEditorDeliverySelector.prototype.refreshLayout=function(t){if(!this._hasLayout){return}if(!this._isValidLayout){BX.Crm.EntityEditorDeliverySelector.superclass.refreshLayout.apply(this,arguments);return}if(this._mode===BX.UI.EntityEditorMode.edit){if(!this._deliverySelector){return}this.setOptionsList(this._deliverySelector,this.getModel().getField("DELIVERY_SERVICES_LIST"),this.getModel().getField("DELIVERY_SELECTOR_DELIVERY_ID"));if(!this._profileSelector&&BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_PROFILES_LIST"))){this._profileSelector=this.createProfileSelector();this.insertProfileSelector()}else if(this._profileSelector&&!BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_PROFILES_LIST"))){this.removeProfileSelector()}if(this._profileSelector&&BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_PROFILES_LIST"))){this.setOptionsList(this._profileSelector,this.getModel().getField("DELIVERY_PROFILES_LIST"),this.getModel().getField("DELIVERY_SELECTOR_PROFILE_ID"))}if(!this._storeSelector&&BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_STORES_LIST"))){this._storeSelector=this.createStoreSelector();this.insertStoreSelector()}else if(this._storeSelector&&!BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_STORES_LIST"))){this.removeStoreSelector()}if(this._storeSelector&&BX.type.isNotEmptyObject(this.getModel().getField("DELIVERY_STORES_LIST"))){this.setOptionsList(this._storeSelector,this.getModel().getField("DELIVERY_STORES_LIST"),this.getModel().getField("DELIVERY_STORE_ID"))}if(this.getModel().getField("ERRORS")){this.processErrors(this.getModel().getField("ERRORS"))}else{this.clearError()}this._input.value=this.getValue()}else{this.setDeliveryServiceName(this.getModel().getField("DELIVERY_SERVICE_NAME"));if(parseInt(this.getModel().getField("DELIVERY_STORE_ID"))>0){this.setDeliveryStore()}}};BX.Crm.EntityEditorDeliverySelector.prototype.processErrors=function(t){this.clearError();if(t.length){this.showError(t.join(", "))}};BX.Crm.EntityEditorDeliverySelector.prototype.processModelChange=function(t){if(BX.prop.get(t,"originator",null)===this){return}if(!BX.prop.getBoolean(t,"forAll",false)&&BX.prop.getString(t,"name","")!==this.getName()){return}this.refreshLayout()};BX.Crm.EntityEditorDeliverySelector.prototype.showError=function(t,e){BX.Crm.EntityEditorDeliverySelector.superclass.showError.apply(this,arguments);if(this._innerWrapper){BX.addClass(this._innerWrapper,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorDeliverySelector.prototype.clearError=function(){BX.Crm.EntityEditorDeliverySelector.superclass.clearError.apply(this);if(this._innerWrapper){BX.removeClass(this._innerWrapper,"crm-entity-widget-content-error")}};BX.Crm.EntityEditorDeliverySelector.prototype.getRuntimeValue=function(){return this._mode===BX.UI.EntityEditorMode.edit&&this._input?BX.util.trim(this._input.value):""};BX.Crm.EntityEditorDeliverySelector.prototype.obtainValueFromSelectors=function(t,e,r,i){var n="";if(i===BX.UI.EntityEditorMode.edit){if(r&&t!=="delivery"){var o=r.value}if(o>0){n=o}else{var s=e.value;if(s>0){n=s}}}return n};BX.Crm.EntityEditorDeliverySelector.prototype.save=function(){if(this._input){this.getModel().setField(this.getName(),this._input.value,{originator:this})}};BX.Crm.EntityEditorDeliverySelector.create=function(t,e){var r=new BX.Crm.EntityEditorDeliverySelector;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorShipmentExtraServices==="undefined"){BX.Crm.EntityEditorShipmentExtraServices=function(){BX.Crm.EntityEditorDeliverySelector.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorShipmentExtraServices,BX.UI.EntityEditorCustom);BX.Crm.EntityEditorShipmentExtraServices.prototype.getHtmlContent=function(){var t=[],e=this.isInEditMode()?"edit":"view",r=new BX.Crm.EntityEditorOrderExtraServicesWrapper({mode:e}),i=this._model.getField("EXTRA_SERVICES_DATA");if(i&&i.length){for(var n=0,o=i.length-1;n<=o;n++){r.wrapItem(i[n]).forEach((function(e,r,i){t.push(e)}))}}return BX.create("div",{style:{marginLeft:"15px",width:"100%",marginTop:"20px"},children:t}).outerHTML};BX.Crm.EntityEditorShipmentExtraServices.create=function(t,e){var r=new BX.Crm.EntityEditorShipmentExtraServices;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorCalculatedDeliveryPrice==="undefined"){BX.Crm.EntityEditorCalculatedDeliveryPrice=function(){BX.Crm.EntityEditorCalculatedDeliveryPrice.superclass.constructor.apply(this);this._refreshButton=null};BX.extend(BX.Crm.EntityEditorCalculatedDeliveryPrice,BX.Crm.EntityEditorMoney);BX.Crm.EntityEditorCalculatedDeliveryPrice.prototype.layout=function(t){BX.Crm.EntityEditorCalculatedDeliveryPrice.superclass.layout.apply(this,arguments);if(this.getParent().getMode()===BX.UI.EntityEditorMode.edit){this._refreshButton=BX.create("div",{props:{className:"ui-btn ui-btn-light-border"},style:{marginLeft:"10px",marginBottom:"3px"},events:{click:function(){BX.onCustomEvent("onDeliveryPriceRecalculateClicked")}},html:this.getMessage("refresh")});if(BX.Type.isElementNode(this._innerWrapper.firstChild)){this._innerWrapper.firstChild.appendChild(this._refreshButton)}else{BX.Dom.clean(this._innerWrapper);this._innerWrapper.appendChild(this._refreshButton)}}};BX.Crm.EntityEditorCalculatedDeliveryPrice.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorCalculatedDeliveryPrice.messages;return e.hasOwnProperty(t)?e[t]:BX.Crm.EntityEditorCalculatedDeliveryPrice.superclass.getMessage.apply(this,arguments)};BX.Crm.EntityEditorCalculatedDeliveryPrice.create=function(t,e){var r=new BX.Crm.EntityEditorCalculatedDeliveryPrice;r.initialize(t,e);return r}}if(typeof BX.Crm.EntityEditorOrderLoaderController==="undefined"){BX.Crm.EntityEditorOrderLoaderController=function(){this._loader=null};BX.Crm.EntityEditorOrderLoaderController.prototype.isLoaderExists=function(){return this._loader!==null};BX.Crm.EntityEditorOrderLoaderController.prototype.showLoader=function(){document.body.appendChild(this.getLoader())};BX.Crm.EntityEditorOrderLoaderController.prototype.hideLoader=function(){if(this._loader&&this._loader.parentNode===document.body){document.body.removeChild(this._loader)}};BX.Crm.EntityEditorOrderLoaderController.prototype.getLoader=function(){if(!this.isLoaderExists()){this._loader=this.createLoader()}return this._loader};BX.Crm.EntityEditorOrderLoaderController.prototype.createLoader=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","circle"),e=document.createElementNS("http://www.w3.org/2000/svg","circle"),r=document.createElementNS("http://www.w3.org/2000/svg","svg");BX.addClass(t,"crm-entity-order-controller-loader-path");t.setAttributeNS(null,"cx","50");t.setAttributeNS(null,"cy","50");t.setAttributeNS(null,"r","20");t.setAttributeNS(null,"fill","none");t.setAttributeNS(null,"stroke-miterlimit","10");BX.addClass(e,"crm-entity-order-controller-loader-inner-path");e.setAttributeNS(null,"cx","50");e.setAttributeNS(null,"cy","50");e.setAttributeNS(null,"r","20");e.setAttributeNS(null,"fill","none");t.setAttributeNS(null,"stroke-miterlimit","10");BX.addClass(r,"crm-entity-order-controller-loader-circular");r.setAttributeNS(null,"viewBox","25 25 50 50");r.appendChild(t);r.appendChild(e);return BX.create("div",{props:{className:"crm-entity-order-controller-loader-wrap"},children:[BX.create("div",{props:{className:"crm-entity-order-controller-loader-mask"}}),BX.create("div",{props:{className:"crm-entity-order-controller-loader-box"},children:[r]})]})};BX.Crm.EntityEditorOrderLoaderController.create=function(){return new BX.Crm.EntityEditorOrderLoaderController}}if(typeof BX.Crm.EntityEditorPaySystemSelector==="undefined"){BX.Crm.EntityEditorPaySystemSelector=function(){BX.Crm.EntityEditorPaySystemSelector.superclass.constructor.apply(this)};BX.extend(BX.Crm.EntityEditorPaySystemSelector,BX.UI.EntityEditorList);BX.Crm.EntityEditorPaySystemSelector.prototype.layout=function(t){if(this._hasLayout){return}this.ensureWrapperCreated({classNames:["ui-entity-editor-field-select"]});this.adjustWrapper();if(!this.isNeedToDisplay()){this.registerLayout(t);this._hasLayout=true;return}var e=this.getName();var r=this.getTitle();var i=this.getValue();var n=this.getItemByValue(i);var o=this.getDataBooleanParam("isHtml",false);var s={};if(!n){i=this.getMessage("notSelected")}this._selectedValue=i;this._select=null;this._selectIcon=null;this._innerWrapper=null;if(this.isDragEnabled()){this._wrapper.appendChild(this.createDragButton())}if(this._mode===BX.UI.EntityEditorMode.edit){this._wrapper.appendChild(this.createTitleNode(r));this._input=BX.create("input",{attrs:{name:e,type:"hidden",value:i}});this._wrapper.appendChild(this._input);s={props:{className:"ui-ctl-element"}};if(o){s.html=n?n["NAME"]:i}else{s.text=n?n["NAME"]:i}this._select=BX.create("div",s);BX.bind(this._select,"click",this._selectorClickHandler);this._selectIcon=BX.create("div",{attrs:{className:"ui-ctl-after ui-ctl-icon-angle"}});this._selectContainer=BX.create("div",{props:{className:"ui-ctl crm-ctl-paysystem-field ui-ctl-after-icon ui-ctl-dropdown ui-ctl-w100"},children:[this._select,this._selectIcon]});this._innerWrapper=BX.create("div",{props:{className:"ui-entity-editor-content-block"},children:[this._selectContainer]})}else{this._wrapper.appendChild(this.createTitleNode(r));var a="";if(!this.hasContentToDisplay()){a=BX.message("UI_ENTITY_EDITOR_FIELD_EMPTY")}else if(n){a=n["NAME"]}else{a=i}s={props:{className:"ui-entity-editor-content-block-text"}};if(o){s.html=a}else{s.text=a}this._innerWrapper=BX.create("div",{props:{className:"ui-entity-editor-content-block crm-ctl-paysystem-field"},children:[BX.create("div",s)]})}this._wrapper.appendChild(this._innerWrapper);if(this.isContextMenuEnabled()){this._wrapper.appendChild(this.createContextMenuButton())}if(this.isDragEnabled()){this.initializeDragDropAbilities()}this.registerLayout(t);this._hasLayout=true};BX.Crm.EntityEditorPaySystemSelector.create=function(t,e){var r=new BX.Crm.EntityEditorPaySystemSelector;r.initialize(t,e);return r};BX.Crm.EntityEditorPaySystemSelector.prototype.getMessage=function(t){var e=BX.Crm.EntityEditorPaySystemSelector.messages;return e.hasOwnProperty(t)?e[t]:BX.Crm.EntityEditorPaySystemSelector.superclass.getMessage.apply(this,arguments)}} //# sourceMappingURL=order.map.js