OperatorPurchasing = function( operatorData, options ) { this.rootElement = null; this.tabPanel = null; this.operatorData = operatorData; this._isDirty = false; const optionDefaults = { showNewCall : true, showSaveButton : true, gridHeight : "100%" // 550 } this.options = $.extend( true, {}, optionDefaults, options ? options : {} ); console.log( "OperatorPurchasingOptions", this.options ); this.confirmedTabEnabled = true; this.confirmedTabEnabled = operatorData.cho_id ? true : false; // if( ! Fse.Portal.checkPermission( "OperatorAnalyzer" ) ) { // this.confirmedTabEnabled = false; // } this.includeInactiveManufacturers = false; } OperatorPurchasing.prototype.constructor = OperatorPurchasing; OperatorPurchasing.prototype.element = function() { let instance = this; if( ! instance.rootElement ) { instance.rootElement = $("
").addClass( "OperatorPurchasing" ).css( { "height" : "100%" }); if( instance.confirmedTabEnabled ) { let tabItems = [ { title : "Unconfirmed", template : function() { return $("
").css( { "padding" : "5px", "height" : "100%" } ).append( instance.unconfirmedTabTemplate( instance.operatorData )); }}, { title : "Confirmed", template : function() { return $("
").css( { "padding" : "5px", "height" : "100%" }).append( instance.confirmedTabTemplate( instance.operatorData ) ); }} ] instance.tabPanel = $("
").dxTabPanel ( { height : "100%", items : tabItems } ).dxTabPanel( "instance" ); instance.rootElement.append( instance.tabPanel.element() ) } else { instance.rootElement.append( $("
").css( { "padding-top": "5px", "height" : "100%" } ).append( instance.unconfirmedTabTemplate( instance.operatorData ) )) } } return instance.rootElement; } OperatorPurchasing.prototype.confirmedTabTemplate = function( data ) { let instance = this; let operatorAnalyzerOptions = { perspectivesEnabled : false, helpTopic : "confirmedPurchases", container : $("
"), choId : data.cho_id, operatorId : data.operatorId, filter : { enabled : true, skuIdFilterEnabled : true, brandIdFilterEnabled : true, prodIdFilterEnabled : true, budgetCategoryIdFilterEnabled : true, prodline_IdFilterEnabled : true, categoryIdFilterEnabled : true, classificationIdFilterEnabled : true, segmentIdFilterEnabled : true, territoryIdFilterEnabled : true, agreementOwnerChoIdFilterEnabled : false, choIdFilterEnabled : false, operatorTypeFilterEnabled : false, keywordFilterEnabled : true, statesFilterEnabled : true, distributorKeyIdFilterEnabled : true, businessOwnerUserIdFilterEnabled : true, inferredPurchasersFilterEnabled : false, agreementOwnersFilterEnabled : false } }; instance.operatorAnalyzer = new OperatorAnalyzer( operatorAnalyzerOptions ); return instance.operatorAnalyzer.element(); } OperatorPurchasing.prototype.unconfirmedTabTemplate = function( data ) { let instance = this; instance.productStatusForm = {}; instance.purchasingStatusDataSource = new DevExpress.data.DataSource( { store : { type : "array", data : [ { text : "Buying", value : "B" }, { text : "Not Buying", value : "N" }, { text : "No Application", value : "W" } ], key : "value" } }); instance.volumeTimeDataSource = new DevExpress.data.DataSource( { store : { type : "array", data : [ { text : "per Week", value : "W"}, { text : "per Month", value : "M"}, { text : "per Year", value : "Y"} ], key : "value" } }); instance.sourceTypeDataSource = new DevExpress.data.DataSource( { store : { type : "array", data : [ { value : "?", text : "Unknown" }, { value : "C", text : "Competitor" }, { value : "I", text : "Fresh/Scratch" }, { value : "O", text : "Other"} ], key : "value" } }); instance.dataReady = $.Deferred(); instance.loadPanel = $("
").dxLoadPanel( { message : "Loading...", onHidden : function( e ) { e.component.element().remove(); } }).appendTo( "body" ).dxLoadPanel( "instance" ); /* moved to load instance.dataSource = Fse.Data.newDataSource( { object : "OPR.productStatus", keyField : "productStatusId", paginate : false, objectParams : { operatorId : data.operatorId } } ); */ instance.productStatusList = instance.createGridView(); let toolbarItems = []; let allowNewCall = Fse.Portal.checkPermission( "BCRMCallTracking" ) && instance.options.showNewCall; if( allowNewCall ) { instance.newCallButton = $("
").dxButton( { disabled : true, text : "New Call", icon : "tel", hint : "Start new call from selected entries", onClick : function( e ) { instance.manageInteractions( instance.gridView.getSelectedRowsData() ); } }).dxButton( "instance"); } instance.deleteSelectedButton = $("
").dxButton( { disabled : true, text : "Delete", icon : "trash", hint : "Delete selected entries?", onClick : function( e ) { if( confirm( "Delete selected entries?" ) ) { instance.deleteProductStatus( instance.gridView.getSelectedRowsData() ); } } }).dxButton( "instance"); let addItemEnabled = Fse.Portal.getConfiguration( "OPR.purchasingProfile.addItemEnabled" ) == "true" ? true : false; let addCategoryEnabled = Fse.Portal.getConfiguration( "OPR.purchasingProfile.addCategoryEnabled" ) == "true" ? true : false; // addItemEnabled = true; // addCategoryEnabled = true; if( addCategoryEnabled ) { toolbarItems.push( { location : "before", widget : "dxButton", options : { text : "Add Product", onClick : function( e ) { instance.addProductStatus( "PRD" ); } } } ); } if( addItemEnabled ) { toolbarItems.push( { location : "before", widget : "dxButton", options : { text : "Add SKU", onClick : function( e ) { instance.addProductStatus( "SKU" ); } } } ); } if( allowNewCall ) { toolbarItems.push( { location: "before", template : function() { return instance.newCallButton.element() } } ); }; toolbarItems.push( { location: "before", template : function() { return instance.deleteSelectedButton.element() } } ) if( Fse.Portal.appConfiguration.STP.ownerType != "MFR" ) { toolbarItems.push( { location : "after", template : function() { return $("
") .append( $("