DistributorPurchasing = function( data ) {
this.data = $.extend( true, {}, data );
this.rootElement = null;
}
DistributorPurchasing.prototype.constructor = DistributorPurchasing
DistributorPurchasing.prototype.element = function() {
let instance = this;
let data = instance.data;
let analyerOptions = {}
instance.rootElement = $("
").addClass( "DistributorPurchasing" ).css( "height" , "100%" );
let isMfr = Fse.Portal.appConfiguration.STP.ownerType == "MFR" ? true : false ;
let mfrView = isMfr ? 'skuFull' : ['MFRAbbrev_Name','skuFull'];
switch ( data.dstcompanytype ) {
case "B" :
analyerOptions.displayColumns = mfrView;
analyerOptions.cdr_recordId = data.distributorId;
//
analyerOptions.quickViews = { brand : true, sku : true, product : true, budgetCategory : true, manufacturer : mfrView };
analyerOptions.distributorVoidsOption = true;
console.log(analyerOptions);
break;
case "P" :
analyerOptions.parent_cdr_recordId = data.distributorId;
analyerOptions.invoiceHistoryOption = false;
analyerOptions.quickViews = { brand : true, sku : true, product : true, budgetCategory : true, distributor : true, territory : true, manufacturer : mfrView };
console.log(analyerOptions);
break;
case "R" :
analyerOptions.cdr_recordId = data.distributorId;
analyerOptions.displayColumns = 'skuFull';
analyerOptions.distributionAnalyzerOption = false;
analyerOptions.combinedPurchasingOption = false;
analyerOptions.invoiceHistoryOption = false;
analyerOptions.quickViews = { brand : true, sku : true, product : true, budgetCategory : true, distributor : true, territory : true, manufacturer : mfrView };
console.log(analyerOptions);
break;
default:
analyerOptions.cdr_recordId = data.distributorId;
analyerOptions.displayColumns = 'skuFull';
analyerOptions.distributionAnalyzerOption = false;
analyerOptions.combinedPurchasingOption = false;
analyerOptions.invoiceHistoryOption = false;
analyerOptions.quickViews = { brand : true, sku : true, product : true, budgetCategory : true, distributor : true, territory : true, manufacturer : mfrView };
console.log(analyerOptions);
break;
}
//let distributorPurchasing = new DistributorPurchasing( data );
analyerOptions.height = 600;
instance.salesAnalyzer = new SalesAnalyzer( analyerOptions );
instance.salesAnalyzer.element().appendTo( instance.rootElement );
// let resized = false;
// const resizeObserver = new ResizeObserver( function( entries, observer ) {
// if( resized ) return;
// console.log( "Entries", entries );
// for (let entry of entries) {
// resized = true;
// const width = entry.contentRect.width;
// const height = entry.contentRect.height;
// // Perform actions based on the new size
// console.log(`Element size changed: width=${width}px, height=${height}px`);
// instance.salesAnalyzer.setContentHeight( height );
// break;
// }
// }
// );
// resizeObserver.observe( instance.rootElement[0] );
return instance.rootElement;
}