var _submitRequest = function() { var oForm = document.forms.frm_submitRequest; if( ! oForm ) { return; } if( ! oForm.elements.wizardAction ) { return; } Fse.FormManager.submit( oForm, true ); } var _stepClicked = function( sStep ) { var oForm = document.getElementById( "wizardFormAutoSave" ); if( oForm ) { if( Fse.FormManager.submit( oForm, false )) { var sURL = Fse.Util.updateURL( oForm.getAttribute( "action" ), { nextStep : sStep } ); oForm.setAttribute( "action", sURL ); Fse.Ajax.sendForm( oForm ); // oForm.submit(); Fse.Ajax.updateSocket( 'agreementWizardSocket', null, { step : sStep }, true ); } } else { // change navigation only Fse.Ajax.updateSocket( 'agreementWizardSocket', null, { step : sStep }, true ); } }; var _saveWizard = function() { var oForm = document.getElementById( "wizardFormAutoSave" ); if( ! oForm ) return; if( Fse.FormManager.submit( oForm, false )) { // var sURL = Fse.Util.updateURL( oForm.getAttribute( "action" ), { nextStep : sStep } ); Fse.Ajax.sendForm( oForm ); Fse.Ajax.updateSocket( 'agreementWizardSocket', null ); } } var fnPartnerPicked = function( oRequest ) { var oForm = document.forms.frm_setBeneficiary; // the pick box sends the data back like this var _partnerId = Fse.Ajax.getResponseHeader( oRequest, "x-fse-fnd-partnerid" ); var _partnerType = Fse.Ajax.getResponseHeader( oRequest, "x-fse-fnd-partnertype" ); var _partnerName = Fse.Ajax.getResponseHeader( oRequest, "x-fse-fnd-partnername" ); var _partnerId2; var _partnerName2; // the add box sends the data back like this if( _partnerType != "OPR" && _partnerType != "CDR" ) { var _partnerId2 = Fse.Ajax.getResponseHeader( oRequest, "X-FSE-OperatorId" ); var _partnerName2 = Fse.Ajax.getResponseHeader( oRequest, "X-FSE-OperatorName" ); } if( "OPR" == _partnerType || "CDR" == _partnerType ) { oForm.elements.partnerId.value = _partnerId; oForm.elements.partnerName.value = _partnerName; } else { oForm.elements.partnerId.value = _partnerId2; oForm.elements.partnerName.value = _partnerName2; } oForm.submit(); }; var _directShipChanged = function() { if( $("#wizardFormAutoSave input[name='directShip']").get()[0].checked ) { $("#distributorFields").addClass( "fse-hidden" ); } else { $("#distributorFields").removeClass( "fse-hidden" ); } } var _addDistributor = function( oRequest ) { var oResponse = Fse.Util.parseJSON( oRequest.responseText ); if( oResponse.PARTNERID ) { var oForm = document.getElementById( "wizardFormAutoSave" ); if( oForm ) { oInput = document.createElement( "input" ); oInput.setAttribute( "type", "hidden" ); oInput.setAttribute( "name", "cdr_recordId" ); oInput.setAttribute( "value", oResponse.PARTNERID ); oForm.appendChild( oInput ); _saveWizard(); } } } var _addItems = function( sCloseAction ) { bSelectAll = false; var sSocketId = "agreementWizard-items-table"; var oForm = document.forms.frm_pickItems; /* var nTradeRequestId = 0; if( oForm.elements.requestId ) { nTradeRequestId = oForm.elements.requestId.value; } */ var aCatalogKeys = []; var oCatalogKey = oForm.elements.skuId; if( oCatalogKey ) { if( oCatalogKey.length ) { for( var x = 0; x < oCatalogKey.length; x++ ) { aCatalogKeys[aCatalogKeys.length] = oCatalogKey[x].value; } } else { aCatalogKeys[aCatalogKeys.length] = oCatalogKey.value; } } var fnAddRow = function( oRequest ) { Fse.UI.addTableRowFromContent ( document.getElementById( sSocketId ), oRequest.responseText, true ); // Fse.TPM.recalculateRequest( document.forms.frm_directEntry ); //_directEntryUpdateCalculatedFields( ); }; nLevel = 1; var oFndOptions = { closeAction : sCloseAction, onSuccess : fnAddRow, pickLevel : nLevel, enableCheckAll: bSelectAll, selectMode : "multiple", additionalFields : { currentCatalogKeys : aCatalogKeys.join(','), wizardAction : 'finderItemsPicked' }, // additionalFields : { currentCatalogKeys : '', tradeRequestId : nTradeRequestId }, autoFind : true, prepare : function() { var oFndForm = document.forms.frm_fndProductLookup; if( oFndForm && oFndForm.elements.currentCatalogKeys ) { oFndForm.elements.currentCatalogKeys.value = aCatalogKeys.join(','); } } }; if( oForm.elements.fndScope ) { oFndOptions.scope = oForm.elements.fndScope.value + ",global"; } var oLastUOMField = document.getElementById( "_lastUOM" ); if( oLastUOMField ) { oFndOptions.additionalFields.UOM = oLastUOMField.value; } Fse.FND.showProductLookup( oFndOptions ); }; var _agreementWizardDeleteProductRow = function( oCell ) { var oTable = document.getElementById( "agreementWizard-items-table" ); if( ! oTable ) return; var bDeleted = false; for( var x = 0; x < oTable.rows.length; x++ ) { var oTr = oTable.rows[x]; if( oTr == oCell.parentNode ) { oTable.deleteRow(x); bDeleted = true; break; } } if( bDeleted ) { _saveWizard(); } }