\n";a=setTimeout(function(){c(h,l,q)},100);if(q){q.asynchUpdaterTimeoutId=a}}else{j="There's no longer any status being reported, so it looks like we're done!";enableDialogButtons()}b.innerHTML=j}}catch(k){}}function asynchUpdateWithProcessStatus(c,b,a){jsrsExecute(rsCallbackGetStatus,"Admin_GetStatus",[escape(c)],enableDialogButtons,{processKey:c,strStatusSectionId:b,fnAsynchUpdate:asynchUpdateWithProcessStatus,objAsynchUpdaterTimeoutHolder:a})}function showChangePasswordDialog(){var b="frmChangePW",a=new ClientDialogBuilder({formId:b,formTitle:"Change Password",okButtonDisplayText:"Save",focusFieldName:"txtOldPW",focusFieldOnMobile:1,fnSubmit:submitChangePassword});a.addTextFieldRow("txtOldPW",{rawLabel:"Old Password",isPasswordField:1,maxLength:80});a.addTextFieldRow("txtNewPW",{rawLabel:"New Password",isPasswordField:1,maxLength:80});a.addTextFieldRow("txtConfirmPW",{rawLabel:"Confirm Password",isPasswordField:1,maxLength:80});a.addTextFieldRow("txtUserName",{fieldValue:g_username,hideRow:1});a.showClientDialog()}function submitEditOrAddTaxRate(){var d="frmNewTaxRate",e=getObj(d),b=mjtElemData(e,"taxRateId"),a=new FormValidator(),c={taxRateId:b||"",taxRateName:e.txtName.value,taxRatePercent:trim(e.txtRate.value),state:trim(e.txtState.value)};if(!a.CSValidateRequiredField(e.txtName,"Please enter a Name")){return}if(!a.CSValidateNumberField(e.txtRate,"Rate",false)){return}jsrsExecuteWithErrorP(b?"Admin2_UpdateTaxRate2":"Admin2_CreateTaxRate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,b?"Creating Tax Rate":"Updating Tax Rate",c)}function carefullyDisplayEventLog(b,a){hideDialogP({callback:function(){window.location=pageEventLog+b+"/"+a}})}function carefullyDisplayTaxRateEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotTaxRate,a)}function carefullyDisplayStateTaxAgencyEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotStateTaxAgency,a)}function carefullyDisplayEmailTemplateEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotEmailTemplate,a)}function carefullyDisplayProductEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotProduct,a)}function carefullyDisplayPricingStructureEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotPricingStructure,a)}function carefullyDisplayDatabasePricingStructureEventLog(a){carefullyDisplayEventLog(EventObjectType_Enum.eotDatabasePricingStructure,a)}function carefullyDisplayUserEventLog(a){hideDialogP({callback:function(){window.location=pageUserEventLog+a}})}function showTaxRateDialog(f,b,e,a){var g="frmNewTaxRate",h,c=jtcrmHasAccess(JTCRMSecuredObject_Enum.soTaxRates,AccessRight_Enum.mjtARDelete),d=new ClientDialogBuilder({formId:g,formTitle:f?"Edit Tax Rate":"New Tax Rate",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitEditOrAddTaxRate()"}),fnSubmit:submitEditOrAddTaxRate,arrExtraHeaderButtons:f?[c?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmDeleteTaxRate("+f+",unescape('"+escape(b)+"'))",doubleQuoteEncodedTitle:"Delete Tax Rate"}):"",c?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayTaxRateEventLog("+f+")"})]:0});d.addTextFieldRow("txtName",{rawLabel:"Name",mnemonicChar:"n",fieldValue:b||"",maxLength:80});d.addTextFieldRow("txtRate",{rawLabel:"Rate",mnemonicChar:"r",fieldValue:""+(e||0),maxLength:8,isNumber:1});d.addTextFieldRow("txtState",{rawLabel:"State",mnemonicChar:"t",fieldValue:a||"",maxLength:80});h=d.showClientDialog();if(h){mjtElemData(h,"taxRateId",f)}}function showNewTaxRateDialog(){showTaxRateDialog()}function doDeleteStateTaxAgency(a){jsrsExecuteWithErrorP("Admin2_DeleteStateTaxAgency",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting State Tax Agency",{stateTaxAgencyId:a.stateTaxAgencyId})}function confirmDeleteStateTaxAgency(b,a){hideDialog();displaySimpleConfirmationDialog(doDeleteStateTaxAgency,'Are you sure you want to delete "'+htmlEncode(a)+'"',"Delete State Tax Agency",{stateTaxAgencyId:b,stateTaxAgencyName:a})}function submitEditOrAddStateTaxAgency(){var g="frmAgency",h=getObj(g),a=mjtElemData(h,"stateTaxAgencyId"),b=new FormValidator(),f=h.cboState,e=trim(f.value),d={stateTaxAgencyId:a||"",stateTaxAgencyName:trim(h.txtName.value),state:e},c=b.CSValidateRequiredField(h.txtName,"Please enter a Name");if(!c){return}if(!e){showInfoDialog('
Please select a state
',"Missing State",1,f.name);return}jsrsExecuteWithErrorP(a?"Admin2_UpdateStateTaxAgency":"Admin2_CreateStateTaxAgency",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,a?"Creating State Tax Agency":"Updating State Tax Agency",d)}function rsCallbackGetStatesForStateTaxAgencyDialog(h,b){var g=b.originalOptions,j=g.params||{},f=h.arrStateNames,m=f.map(function(n){return{cboValue:n,rawContent:n}}),k="frmAgency",i,d=j.id,c=j.name,a=j.state,e=jtcrmHasAccess(JTCRMSecuredObject_Enum.soTaxRates,AccessRight_Enum.mjtARDelete),l=new ClientDialogBuilder({formId:k,formTitle:d?"Edit State Tax Agency":"New State Tax Agency",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitEditOrAddStateTaxAgency()"}),fnSubmit:submitEditOrAddStateTaxAgency,arrExtraHeaderButtons:d?[e?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmDeleteStateTaxAgency("+d+",unescape('"+escape(c)+"'))",doubleQuoteEncodedTitle:"Delete Tax Rate"}):"",e?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayStateTaxAgencyEventLog("+d+")"})]:0});l.addTextFieldRow("txtName",{rawLabel:"Agency Name",mnemonicChar:"n",fieldValue:c||"",maxLength:80});if(!d){m.unshift({cboValue:"",rawContent:"-Select State-"})}l.addDropdown({fieldName:"cboState",rawLabel:"State",arrAvailableOptions:m,objSelectedValue:a?{cboValue:a,rawContent:a}:null});i=l.showClientDialog();if(i){mjtElemData(i,"stateTaxAgencyId",d)}}function showStateTaxAgencyDialog(a){jsrsExecuteWithErrorP("Admin2_GetStatesWithTaxRates",rsCallbackHandleStandardJSONResponse,"Retrieving New Product Info",{excludeStatesWithAssignedStateTaxAgency:1},{fnOnSuccess:rsCallbackGetStatesForStateTaxAgencyDialog,params:a})}function submitTaxJarTransReportOptions(){var i="frmOptions",e=getObj(i),a=new FormValidator(),f=pageTaxJarTransReport,g=e.dtFrom,h=e.dtTo,d=e.txtPageSize,b=trim(d.value),c=a.CSValidateIntegerFieldP({field:d,label:"Page Size",isNullable:true,minValue:1,maxValue:2000})&&a.CSValidateDateFieldP({field:g,label:"From"})&&a.CSValidateDateFieldP({field:h,label:"To"});if(!c){return}if(b){f+="&pageSize="+b}f+="&from="+trim(getDateForUrlParam(g.value));f+="&to="+trim(getDateForUrlParam(h.value));hideDialog();window.location=f;displayTimedMessage("Reloading page...")}function showTaxJarTransReportOptions(a){var c="frmOptions",b=new ClientDialogBuilder({formId:c,formTitle:"Tax Jar Transactions Report Options",focusFieldName:"dtFrom",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaxJarTransReportOptions()"}),fnSubmit:submitTaxJarTransReportOptions});b.addDatePickerRow(c,"dtFrom",{rawLabel:"From",strValue:a.fromDate,autofocus:1});b.addDatePickerRow(c,"dtTo",{rawLabel:"To",strValue:a.toDate});b.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+a.pageSize,mnemonicChar:"r",maxLength:10,styleWidth:"7em",isNumber:1});b.showClientDialog()}function submitEditOrAddProduct(){var m="frmNewProduct",l=getObj(m),b=new FormValidator(),e=l.cboEdition.options[l.cboEdition.selectedIndex].value,a=e!=="",o=l.cboTerm.options[l.cboTerm.selectedIndex].value,d=l.cboPricingStructure.options[l.cboPricingStructure.selectedIndex].value,n=d!==""?parseInt(d,10):null,f=l.priceGenerations.options[l.priceGenerations.selectedIndex].value,i=f!==""?parseInt(f,10):null,k=(i===g_flexPricingProductGenerationId),p=l.productTypes.options[l.productTypes.selectedIndex].value,q=p!==""?parseInt(p,10):null,h=q===CRMProductType_Enum.crmptCounterGo,g=q===CRMProductType_Enum.crmptNVInventory,c=mjtElemData(l,"productId"),j={productId:c||"",productName:l.txtName.value,jtUserCount:trim(l.txtJTCount.value),cgUserCount:trim(l.txtCGCount.value),nvUserCount:trim(l.txtNVCount.value),fileSize:trim(l.txtFileSize.value),editionId:e,term:o,price:trim(l.txtPrice.value),notes:cdGetExpandingTextFieldValue("txtNotes"),isDiscountable:l.chkDiscountable.checked?1:0,isJobTrackerSubscription:l.chkJTSubscription.checked?1:0,displayedProductGroupId:l.cboDisplayGroup.options[l.cboDisplayGroup.selectedIndex].value,priceGenerations:i,pricingStructureId:n,productType:q,isDeprecated:(l.chkDeprecated&&l.chkDeprecated.checked)?1:0};if(!b.CSValidateRequiredField(l.txtName,"Please enter a Name")){return}if(!b.CSValidateNumberField(l.txtJTCount,"Job Tracker User Count",false)){return}if(!b.CSValidateNumberField(l.txtCGCount,"CounterGo User Count",false)){return}if(!b.CSValidateNumberField(l.txtNVCount,"Inventory User Count",false)){return}if(!b.CSValidateNumberField(l.txtFileSize,"File Size",false)){return}if(k){if(!n&&(h||g||a)){showInfoDialog("Please select a pricing structure.","Select Pricing Structure",true,"cboPricingStructure");return}}else{if(!b.CSValidateNumberField(l.txtPrice,"Price",false)){return}}jsrsExecuteWithErrorP(c?"Admin2_UpdateProduct2":"Admin2_CreateProduct2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,c?"Creating Product":"Updating Product",j)}function buildAnOption(c,d,e,f,b){var a=(f||e==c);if(a&&b){b.didSelect=1}return'"}function buildDropdownContent(j){var a=j.name,c=j.valueLookup,g=j.textLookup,l=j.selectedValue,e=j.arrValues,b=j.onChangeCode?' onchange="'+j.onChangeCode+'"':"",k=j.disabled?" disabled":"",d,f="";for(d=0;d"+f+""}function buildDropdownRow(a){return cdBuildReadOnlyFieldRowP({labelHTML:a.label,valueHTML:buildDropdownContent({name:a.name,valueLookup:a.valueLookup,textLookup:a.textLookup,selectedValue:a.selectedValue,arrValues:a.values,onChangeCode:a.onChangeCode,disabled:a.disabled}),rowId:a.rowId,valueCellId:a.valueCellId})}var MAX_VALUE_PRICING_STRUCTURE_MIN_USERS=99,MIN_VALUE_PRICING_STRUCTURE_MIN_USERS=2;function submitPricingStructureDialog(){var f="frmPricingStructure",t=getObj(f),o=mjtElemData(t,"pricingStructureId"),e=new FormValidator(),j=t.cboProductType.options[t.cboProductType.selectedIndex].value,g=j?parseInt(j,10):null,a=t.cboEdition.options[t.cboEdition.selectedIndex].value,m=a?parseInt(a,10):null,b=t.chkIsInactive&&t.chkIsInactive.checked?1:0,d=trim(t.txtTier2StartUserCount.value),k=d!==""?parseInt(d,10):null,c=trim(t.txtTier2PerUserPrice.value),n=c!==""?parseFloat(c):null,l=trim(t.txtMinUserCount.value),r=l?parseInt(l,10):null,p=g===CRMProductType_Enum.crmptCounterGo,q=g===CRMProductType_Enum.crmptNVInventory,s={pricingStructureId:o,isInactive:b,productTypeId:g,editionId:m,editionPrice:t.txtEditionPrice.value,additionalUserPrice:t.txtAdditionalUserPrice.value,tier2StartUserCount:k,tier2PerUserPrice:n,minUserCount:r||""},i={minValue:0,maxDecimalPlaces:2},u=[{field:t.txtAdditionalUserPrice,label:"Additional User Price"},{field:t.txtTier2PerUserPrice,label:"Tier 2 Per-User Price",isNullable:true},{field:t.txtTier2StartUserCount,label:"Tier 2 Start",isNullable:true,maxDecimalPlaces:0},{field:t.txtMinUserCount,label:"Minimum # of Users",isNullable:true,maxDecimalPlaces:0,minValue:MIN_VALUE_PRICING_STRUCTURE_MIN_USERS,maxValue:MAX_VALUE_PRICING_STRUCTURE_MIN_USERS}];if(!g){showInfoDialog("Please select your product type.","Select Product Type",true,"cboProductType");return}for(var h in u){Object.assign(i,u[h]);if(!e.CSValidateNumberFieldP(i)){return}}if(n&&!k){showInfoDialog('
Please set the Tier 2 Start User # or clear the Tier 2 Per-User Price
"}}}else{if(a>0){c=htmlEncode(v[0].name)+''}else{c='(No Tax Required)'}}d.addFlexibleFieldRow({rawLabel:"Tax Rate",valueHTML:c});if(l){d.addFlexibleFieldRow({valueHTML:'Tax Rate Lookup'})}d.addSectionHeaderRow({rawTitle:"Order Products"});d.addFlexibleFieldRow({rawLabel:"CounterGo",valueHTML:''});d.addFlexibleFieldRow({rawLabel:"Inventory",valueHTML:''});d.addFlexibleFieldRow({rawLabel:"Systemize",valueHTML:'"});o=d.showClientDialog();if(o){mjtElemData(o,"address",r)}}function submitNewDatabaseFromHubspot(){var b="frmNewDBFromHubspot",e=getObj(b),d=e.txtCustomerId,a=e.txtHubspotCompanyId,c=!a.value;if(c){return false}jsrsExecuteWithErrorP("Admin2_GetHubspotCompanyInfo",rsCallbackGetHubspotInfoForNewDB,"Getting Hubspot Info",{hubspotCompanyId:trim(a.value),customerId:d?d.value:"",createMissingTaxCodeIfPossible:1})}function showNewDatabaseFromHubspotDialog(a,d){var c="frmNewDBFromHubspot",b=new ClientDialogBuilder({formId:c,formTitle:"New Database (Hubspot)",focusFieldName:"txtHubspotCompanyId",okButtonDisplayText:"Get Hubspot Company Info",fnSubmit:submitNewDatabaseFromHubspot});if(d&&a){b.addFlexibleFieldRow({rawLabel:"Customer",valueHTML:htmlEncode(d)+''})}b.addTextFieldRow("txtHubspotCompanyId",{rawLabel:"Hubspot Company Id"});b.showClientDialog()}function submitAssignDBToCustomer(a,d){var c=a.cboCustomer,b=c.options[c.selectedIndex].value;hideDialog();jsrsExecuteWithErrorP("Admin2_AssignDatabaseToCustomer2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Assigning Database to Customer",{databaseId:d.databaseId,customerId:b})}function rsCallbackCustomerNamesForDB(e,a,d){enableDialogButtons();if(checkResponseForError(e)){var c=JSON.parse(e),g=c.arrCustomers,f="",b,h;if(!g.length){showInfoDialog("There are no customers defined","No Customers");return}for(b=0;b"+htmlEncode(g[b].name)+""}showDialogP(cdBuildReadOnlyFieldRowP({rawLabel:"Customer",valueHTML:'"}),"frmAssignDBToCustomer",{formTitle:"Assign Database To Customer",focusFieldName:"cboCustomer",okButtonDisplayText:"Save",contextDetailOrFnSubmit:{fnSubmit:submitAssignDBToCustomer,callbackData:d}})}}function showAssignDBToCustomerDialog(b,a){if(isDialogShowing()){return}jsrsExecute(rsCallbackCustomerNamesForDB,"Admin_GetCustomerNames",[],enableDialogButtons,{databaseId:b,customerId:a});displayTimedMessage("Retrieving list of customers...");disableDialogButtons()}function submitAddOrUpdateDBProduct(m){var d=m.cboQty,f=m.cboProduct,l=f?f.options[f.selectedIndex].value:"",k=l?JSON.parse(unescape(l)):0,i=cdGetExpandingTextFieldValue("txtNotes"),c=new FormValidator(),e,j=mjtElemData(m,"databaseProductId"),n=mjtElemData(m,"databaseId"),h,b,a=null,g=(!j||!m.txtPrice||c.CSValidateNumberFieldP({field:m.txtPrice,label:"Price"}))&&c.CSValidateDateFieldP({field:m.dtStartDate,label:"Start Date",isNullable:true})&&c.CSValidateDateFieldP({field:m.dtEndDate,label:"End Date",isNullable:true});if(!g){return}if(m.priceGenerations){a=m.priceGenerations.options[m.priceGenerations.selectedIndex].value}else{if(k&&k.priceGenerationId){a=k.priceGenerationId}}h=getDateForUrlParam(m.dtStartDate.value);b=getDateForUrlParam(m.dtEndDate.value);if(h&&b&&parseDateString(b)'+h+""});p.addDialogInteriorRows(buildQuantityComboboxRow());p.addDatePickerRow(m,"dtStartDate",{rawLabel:"Start Date",strValue:k,suppressAutocomplete:1});p.addDatePickerRow(m,"dtEndDate",{rawLabel:"End Date",suppressAutocomplete:1});p.addExpandingTextFieldRows("txtNotes",{rawLabel:"Notes",suppressAutocomplete:1});g=p.showClientDialog();if(g){mjtElemData(g,"databaseId",c.originalPayload.databaseId)}}function createOrAddToErrorInfo(a,c,b){if(!a){a={errorMessageHTML:"",onDismissFocusFieldName:b}}else{a.errorMessageHTML+=" "}a.errorMessageHTML+=c;return a}var g_mapCRMProductTypeToInfix;function getMapCRMProductTypeToInfix(){if(!g_mapCRMProductTypeToInfix){g_mapCRMProductTypeToInfix=new MJTDictionary();g_mapCRMProductTypeToInfix.add(CRMProductType_Enum.crmptCounterGo,"CG");g_mapCRMProductTypeToInfix.add(CRMProductType_Enum.crmptNVInventory,"NV");g_mapCRMProductTypeToInfix.add(CRMProductType_Enum.crmptJobTracker,"JT");g_mapCRMProductTypeToInfix.add(CRMProductType_Enum.crmptSystemize,"Sys")}return g_mapCRMProductTypeToInfix}function maxUsersToCancelFromDate(b,e){var d=0;for(var c=0;c0||c>0;d.style.display=l?"":"none";if(l){i+=j;if(g||e){i+=" = ";if(b){i+=b}if(g){if(b){i+=" + "}i+=g+" on order"}if(e){if(b+g){if(k){i+=" - "}else{i+=" + "}}if(k){i+=(-e)+" cancelled users"}else{i+=e+" new users"}}}h.innerHTML=i}}function calculateAdditionalUserCost(j,i,e){var c=0,l=parseFloat(j.getAttribute("data-pricePer")),g=j.getAttribute("data-tier2StartUserCount"),a=j.getAttribute("data-tier2PerUserPrice");if(g&&a){var h=parseInt(g,10),d=parseFloat(a),f=e+i;if(f=(h-1)){d=c*e}else{if(i0;j.style.display=q?"":"none";a.innerHTML=""+r;k.setAttribute("max",r);if(isNaN(o)||o<0){k.className="invalidTextField";t=createOrAddToErrorInfo(t,'Invalid User Count "'+htmlEncode(y)+'"',k.name)}else{if(o>r){k.className="invalidTextField";t=createOrAddToErrorInfo(t,"You have exceeded the max number of users ("+r+") available to be cancelled.",k.name)}else{k.className="";if(o){s=v.item(l);c=getOriginalTotalUserCount({userCountInfoForAddUsers:A,productTypeInfix:s});B+=calculateCancelledUserValue(u,c,o);w={productTypeId:l,userCount:o};n.push(w);f[s]=w}}}if(q&&m){m=0;var z=k;setTimeout(function(){setFocus(z)},0)}getObj("spnCostReduction").innerHTML=padAndPrefixSignedDollars((B),1);getObj("spnNewTotalCost").innerHTML=padAndPrefixSignedDollars((g-B),1)}updateAddRemoveUserDlgUserCountCell(A,f,"CG",1);updateAddRemoveUserDlgUserCountCell(A,f,"NV",1);updateAddRemoveUserDlgUserCountCell(A,f,"JT",1);updateAddRemoveUserDlgUserCountCell(A,f,"Sys",1);if(h&&t){showInfoDialog(t.errorMessageHTML,"Invalid User Count",1,t.onDismissFocusFieldName);return}return n}function submitCancelUsers(){var c=new FormValidator(),f=updateCancelUserDialogForCount(1),d="frmCancelUsers",e=getObj(d),b=getCallbackDataOfDialog(e),a=e.changeUserDate;if(!f){return}if(!f.length){showInfoDialog("You haven't indicated how many users to cancel.","No Cancelled Users",1,"txtAddUserCount.0");return}if(!c.CSValidateDateField(a,"Cancel Date",false,a.name)){return}jsrsExecuteWithErrorP("Admin2_CancelUsers",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Cancelling Users",{databaseId:b.databaseId,cancelDate:getDateForUrlParam(a.value),productTypeCounts:f})}var FORM_ID_CHANGE_USER="changeUserForm";function createUndersubscibedUserCountError(c){var g=c.existingErrorInfo,f=c.newTotalUserCount,b=c.minUserCount,e=c.productTypeName,h=c.focusFieldName,d=" Too few "+e+" users.\n\n(A minimum of "+b+" are required, but the total is only "+f+" )",a='
'+htmlEncode(d)+"
";return createOrAddToErrorInfo(g,a,h)}function updateAddUserDialogForCount(f){var z=0,k=0,s=getObj(FORM_ID_CHANGE_USER),l=getObj("spnNewTotalCost"),y=mjtElemData(s,"userCountInfoForAddRemoveUsers"),i=parseFloat(l.getAttribute("data-totalCurrentCost"))||0,h=[],r,b={},o=getMapCRMProductTypeToInfix(),n;while(true){var q=getObj("txtAddUserCount."+z);if(!q){break}var p=getObj("spnUserCountAddendum."+z),x=q.value||"0",j=parseInt(x,10);if(isNaN(j)||j<0||x.indexOf(".")>-1){q.className="invalidTextField";n=createOrAddToErrorInfo(n,'Invalid User Count "'+htmlEncode(x)+'"',q.name)}else{q.className="";if(j){var g=parseInt(p.getAttribute("data-productTypeId"),10),t=parseInt(p.getAttribute("data-minUserCount"),10),m=o.item(g),a=getOriginalTotalUserCount({userCountInfoForAddUsers:y,productTypeInfix:m}),v=a+j,e=t&&v&&v1){showInfoDialog("You can only select a single product when "+(b?"upgrading":"rolling back")+".",b?"Upgrade":"Rollback",1);return}return c[0]}function submitUpgradeProduct(){var b="upgradeForm",c=getObj(b),a=getSelectedProductForUpgradeOrRollback(c,1);if(!a){return}hideDialog();jsrsExecuteWithErrorP("Admin2_UpgradeProduct",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Upgrading Products",{productId:a.productId,databaseId:mjtElemData(c,"databaseId"),effectiveDate:c.upgradeDate.value,pricingStructureId:a.pricingStructureId})}function onSelectProduct(a){if(a.checked){a.parentNode.parentNode.style.backgroundColor="rgb(255, 255, 204)"}else{a.parentNode.parentNode.style.backgroundColor=null}}function getJobTrackerSystemizeEditionIncludedUserCount(a){return parseInt(a.includedUsers!==undefined?a.includedUsers:a.jtUserCount,10)}function getAdditionalUserCount(b){var a=parseInt(b.editionUsers?b.editionUsers.length:b.requiredAdditionalUsers,10);a=isNaN(a)?0:a;return a}function priceFromPriceGeneration(c){var a;if(c&&c.length>1){var b=c.indexOf("/");if(b>0){a=c.substring(1,b)}}return parseFloat(a)}function writeProductTable(h){var c=new MWClientTable({noDataMessage:"No products"}),f,d=0,b=h.arrProducts,e=h.includeCheckboxColumn,i=h.databaseId,a=h.selectedPricingStructure,g=h.pricingStructureProductId;b=b.filter(function(k,l,j){return !!k});c.addColumn(new MWColumn({columnName:"Name",fnCustomRenderCellContents:function(m,l,k,j){return htmlEncode(m.productName)}}));if(e){c.setCheckboxFunction(function(l,j,k){return{value:escape(JSON.stringify({databaseProductId:l.databaseProductId,productId:l.productId,disabled:l.disabled,pricingStructureId:l.productId===g?a.pricingStructureId:l.pricingStructureId})),checked:l.productId===g}})}c.addColumn(new MWColumn({columnName:"Base Price",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(n,m,l,k){var o,j=n.productTypeId!==undefined?n.productTypeId:n.productType;if(j===CRMProductType_Enum.crmptCounterGo||j===CRMProductType_Enum.crmptNVInventory){return""}if(n.isFlexPricing){if(a&&g===n.productId){o=a.editionPrice}else{o=n.editionPrice}}else{o=n.databaseProductPrice!==undefined?n.databaseProductPrice:n.price}return padAndPrefixSignedDollars(o,1)}}));c.addColumn(new MWColumn({columnName:"Included Users",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(n,m,l,k){var j=n.productTypeId!==undefined?n.productTypeId:n.productType;if(j===CRMProductType_Enum.crmptCounterGo||j===CRMProductType_Enum.crmptNVInventory){return""}return getJobTrackerSystemizeEditionIncludedUserCount(n)}}));c.addColumn(new MWColumn({columnName:"Additional Users",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(m,l,k,j){return getAdditionalUserCount(m)}}));c.addColumn(new MWColumn({columnName:"Price Per Additional User",fnCustomRenderCellContents:function(q,n,m,k){var l,j=q.tier2StartUserCount,p=q.tier2PerUserPrice;if(q.isFlexPricing){if(a&&g===parseInt(q.productId,10)){j=a.tier2StartUserCount;p=a.tier2PerUserPrice;l=parseFloat(a.additionalUserPrice)}else{l=parseFloat(q.additionalUserPrice)}}else{if(q.legacyProductPerUserPrice!==undefined){l=parseFloat(q.legacyProductPerUserPrice)}else{l=priceFromPriceGeneration(q.priceGenerationName)}}var o=isNaN(l)?"N/A":(padAndPrefixSignedDollars(l,1)+"/"+q.termName+"/User");if(j){o+=", "+padAndPrefixSignedDollars(p,1)+" for users "+j+"+"}return o}}));c.addColumn(new MWColumn({columnName:"Cost",fnCustomRenderCellContents:function(n,l,k,j){var m=n.totalCost;d+=m;return padAndPrefixSignedDollars(m,1)+" "+n.termName}}));if(e){c.addColumn(new MWColumn({columnName:"",fnCustomRenderCellContents:function(o,n,m,l){var k="";if(o.isFlexPricing){var j={databaseId:i,productId:o.productId,productTypeName:o.productTypeName,productTypeId:o.productTypeId,editionName:o.editionName,editionId:o.editionId};k=cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiUSD,doubleQuoteEncodedTitle:"Change Pricing",doubleQuoteEncodedOnClickJS:"doSelectPricingStructureDialog(JSON.parse(unescape('"+escape(JSON.stringify(j))+"')))"})}return k}}))}f=c.buildTableForArray(b);if((!e)&&b.length>1){f+='
Warning - Active user count from instance manager is '+D+" but current active edition users are "+(K.includedUsers+K.editionUsers.length)+(t>0?(", external users are "+t):"")+(e>0?(", shop users are "+e):"")+". Upgrading will result in billing for "+(D+t+e)+" users.
"})}}else{w.addFlexibleRow({rawValue:'There are no active "Edition" products to be upgraded.',additionalCellClasses:"dlgErrorPanel"})}G=w.showClientDialog();if(G){mjtElemData(G,"databaseId",j)}}function showUpgradeDialog(a){jsrsExecuteWithErrorP("Admin2_GetProductsForUpgrade",rsCallbackHandleStandardJSONResponse,"Getting upgrade information...",{databaseId:a.databaseId,pricingStructureProductId:a.pricingStructureProductId,pricingStructureId:a.pricingStructureId,upgradeEffectiveDate:a.upgradeEffectiveDate},{fnOnSuccess:rsCallbackGetProductsForDBForUpgradeProducts})}function enableDisableOpenOrderDialog(b){var c=getObj("frmOpenOrder"),a=c?c.parentNode:0;if(a){if(b){enableDialogButtonsOfDialog(a)}else{disableDialogButtonsOfDialog(a)}}}function disableOpenOrderDialog(){enableDisableOpenOrderDialog(0)}function enableOpenOrderDialog(){enableDisableOpenOrderDialog(1)}function doCancelOrder(a){jsrsExecuteWithErrorP("Admin2_CancelProductOrder2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Cancelling Order",{productOrderId:a.productOrderId});disableOpenOrderDialog()}function showCancelUserDialog(b,d,c,a){jsrsExecuteWithErrorP("Admin2_GetProductsForCancelUser",rsCallbackGetProductsForCancelUsers,"Getting cancel user information...",{databaseId:b},{defaultJTUserCount:d,defaultCGUserCount:c,defaultNVUserCount:a})}function showAddUserDialog(a){jsrsExecuteWithErrorP("Admin2_GetProductsForAddUser",rsCallbackHandleStandardJSONResponse,"Getting add user information...",{databaseId:a},{fnOnSuccess:rsCallbackGetProductsForAddUser})}function submitAddAdditionalUsersToDB(){var b="frmAddAdditionalUsersToDB",c=getObj(b),a=mjtElemData(c,"addAdditionalUserInfo");hideDialog();jsrsExecuteWithErrorP("Admin2_AddAdditionalUsersToDB",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Adding and invoicing Additional Users",a)}function buildAddUserTotalRow(b){var c=b.cdBuilder,e=b.userTypeName,f=b.initialCount,d=b.additionalCount,a;if(f+d){if(d){a=''+(f+d)+" = "+f+" + "+d+" New User"+(d===1?"":"s")}else{a=""+f}c.addFlexibleFieldRow({rawLabel:e+" Users",valueHTML:a})}}function rsCallbackGetInfoForAddAdditionalUsersToDB(k,c){var b=c.originalOptions,l=b.suppressAutoAddBillingUsers,h="frmAddAdditionalUsersToDB",v,a=k.productOrderId,r={productOrderId:a},g=new ClientDialogBuilder({formId:h,formTitle:"Add Additional Users",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Create Invoice",mnemonicChar:"c",mnemonicActionJS:"submitAddAdditionalUsersToDB()"}),fnSubmit:submitAddAdditionalUsersToDB,fnCancelOrClose:function(){doCancelOrder(r)}}),n=k.additionalJTUserCount,t=k.additionalCGUserCount,x=k.additionalNVUserCount,e=k.currentBillingCGUserCount,i=k.currentBillingNVUserCount,p=k.currentBillingJTSysUserCount,u=k.arrAdditionalUsers,j=k.initialProrateTotalTaxedAmountDetail,o=k.ongoingTotalTaxedAmountDetail,f=k.zeroOutProrate,d=k.zeroOutProrateMessage,s,w=new MWClientTable({arrColumns:[new MWColumn({columnName:"Quantity",simpleDisplayColumnPropertyName:"quantity",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Product",simpleDisplayColumnPropertyName:"productName"}),new MWColumn({columnName:"Prorated Unit Price",simpleDisplayColumnPropertyName:"proratedUnitPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Initial Term Total Price",simpleDisplayColumnPropertyName:"initialTermTotalPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Unit Price",simpleDisplayColumnPropertyName:"unitPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Total Price",simpleDisplayColumnPropertyName:"totalPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Notes",simpleDisplayColumnPropertyName:"notes",simpleDisplayColumnNeedsMultilineEncoding:1})]}),q=[];g.addFlexibleFieldRow({rawLabel:"Database",rawValue:k.subdomainName});g.addFlexibleFieldRow({rawLabel:"Order Start Date",rawValue:k.orderStartDate,additionalCellClasses:"clsNarrowField"});g.addFlexibleFieldRow({rawLabel:"First Term End Date",rawValue:k.firstTermEndDate});if(l){g.addBubbleMessageRow({rawMessage:'This Database has been marked "Don\'t Automatically Add Additional Users To Billing"',isError:1})}if(u){for(s in u){var m=u[s];q.push({quantity:m.quantity,productName:m.productName,unitPrice:padAndPrefixSignedDollars(m.unitPrice,1),totalPrice:padAndPrefixSignedDollars(m.totalPrice,1),proratedUnitPrice:padAndPrefixSignedDollars(m.proratedUnitPrice,1),initialTermTotalPrice:padAndPrefixSignedDollars(m.initialTermTotalPrice,1),notes:m.notes})}}g.addSectionHeaderRow({rawTitle:t+x+n==1?"Additional User":"Additional Users"});g.addFlexibleRow({valueHTML:w.buildTableForArray(q)});g.addSectionHeaderRow({rawTitle:"New Totals"});if(f){g.addBubbleMessageRow({rawMessage:htmlEncode(d)})}g.addFlexibleFieldRow({rawLabel:"Initial Prorated Total",valueHTML:htmlEncode(j.formattedTotalString)+(j.supplementalTaxBreakdownHint?' '+htmlEncode(j.supplementalTaxBreakdownHint)+"":""),additionalCellClasses:"topAlign"});g.addFlexibleFieldRow({rawLabel:"Ongoing Additional Monthly Amount",valueHTML:htmlEncode(o.formattedTotalString)+(o.supplementalTaxBreakdownHint?' '+htmlEncode(o.supplementalTaxBreakdownHint)+"":""),additionalCellClasses:"topAlign"});buildAddUserTotalRow({cdBuilder:g,userTypeName:"CounterGo",initialCount:e,additionalCount:t});buildAddUserTotalRow({cdBuilder:g,userTypeName:"Inventory",initialCount:i,additionalCount:x});buildAddUserTotalRow({cdBuilder:g,userTypeName:"Systemize",initialCount:p,additionalCount:n});v=g.showClientDialog();if(v){mjtElemData(v,"addAdditionalUserInfo",{productOrderId:a})}}function showAddAdditionalUsersToDBDialog(a){jsrsExecuteWithErrorP("Admin2_GetInfoForAddAdditionalUsersToDB",rsCallbackHandleStandardJSONResponse,"Getting Additional User Info...",{databaseId:a.databaseId||"",metricBatchId:a.metricBatchId,additionalCGUserCount:a.additionalCGUserCount||0,additionalNVUserCount:a.additionalNVUserCount||0,additionalJTUserCount:a.additionalJTUserCount||0,expectedActiveCGUserCount:a.activeCGUserCount,expectedActiveNVUserCount:a.activeNVUserCount,expectedActiveJTUserCount:a.activeJTUserCount,expectedBillingCGUserCount:a.billingCGUserCount,expectedBillingNVUserCount:a.billingNVUserCount,expectedBillingJTUserCount:a.billingJTUserCount},{fnOnSuccess:rsCallbackGetInfoForAddAdditionalUsersToDB,suppressAutoAddBillingUsers:a.suppressAutoAddBillingUsers,systemizeOrJobTracker:a.systemizeOrJobTracker})}function submitAddAdditionalStorageToDB(){var b="frmAddAdditionalStorageToDB",c=getObj(b),a=mjtElemData(c,"addAdditionalStorageInfo");hideDialog();jsrsExecuteWithErrorP("Admin2_CompleteOrder2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Adding and invoicing Additional Storage",a)}function rsCallbackGetInfoForAddAdditionalStorageToDB(d,b){var g="frmAddAdditionalStorageToDB",e=d.productOrderId,h={productOrderId:e},a=d.initialProrateTotalTaxedAmountDetail,f=d.ongoingTotalTaxedAmountDetail,i=new ClientDialogBuilder({formId:g,formTitle:"Add Additional Storage",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Create Invoice",mnemonicChar:"c",mnemonicActionJS:"submitAddAdditionalStorageToDB()"}),fnSubmit:submitAddAdditionalStorageToDB,fnCancelOrClose:function(){doCancelOrder(h)}}),k=new MWClientTable({arrColumns:[new MWColumn({columnName:"Quantity",simpleDisplayColumnPropertyName:"quantity",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Product",simpleDisplayColumnPropertyName:"productName"}),new MWColumn({columnName:"Prorated Unit Price",simpleDisplayColumnPropertyName:"proratedUnitPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Initial Term Total Price",simpleDisplayColumnPropertyName:"initialTermTotalPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Unit Price",simpleDisplayColumnPropertyName:"unitPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Total Price",simpleDisplayColumnPropertyName:"totalPrice",additionalCellClasses:"rightAlign"}),new MWColumn({columnName:"Notes",simpleDisplayColumnPropertyName:"notes",simpleDisplayColumnNeedsMultilineEncoding:1})]}),j=[];if(d.order){var c=d.order;j.push({quantity:c.quantity,productName:c.productName,unitPrice:padAndPrefixSignedDollars(c.unitPrice,1),totalPrice:padAndPrefixSignedDollars(c.totalPrice,1),proratedUnitPrice:padAndPrefixSignedDollars(c.initialTermUnitPrice,1),initialTermTotalPrice:padAndPrefixSignedDollars(c.initialTermTotalPrice,1),notes:c.notes})}i.addFlexibleFieldRow({rawLabel:"Database",rawValue:d.subdomainName});i.addFlexibleFieldRow({rawLabel:"Order Start Date",rawValue:d.formattedOrderStartDate,additionalCellClasses:"clsNarrowField"});i.addFlexibleFieldRow({rawLabel:"First Term End Date",rawValue:d.formattedFirstTermEndDate});i.addSectionHeaderRow({rawTitle:"Additional Storage"});i.addFlexibleRow({valueHTML:k.buildTableForArray(j)});i.addSectionHeaderRow({rawTitle:"New Totals"});i.addFlexibleFieldRow({rawLabel:"Initial Prorated Total",valueHTML:htmlEncode(a.formattedTotalString)+(a.supplementalTaxBreakdownHint?' '+htmlEncode(a.supplementalTaxBreakdownHint)+"":""),additionalCellClasses:"topAlign"});i.addFlexibleFieldRow({rawLabel:"Ongoing Additional Monthly Amount",valueHTML:htmlEncode(f.formattedTotalString)+(f.supplementalTaxBreakdownHint?' '+htmlEncode(f.supplementalTaxBreakdownHint)+"":""),additionalCellClasses:"topAlign"});i.showClientDialog({formElemData:{addAdditionalStorageInfo:{productOrderId:e}}})}function showAddAdditionalStorageToDBDialog(a){jsrsExecuteWithErrorP("Admin2_CreateProductOrderToAddAdditionalStorage",rsCallbackHandleStandardJSONResponse,"Getting Additional Storage Info...",{databaseId:a.databaseId||"",additionalStorageInMb:a.additionalStorageInMb,totalProductFileSizeInMb:a.totalProductFileSizeInMb},{fnOnSuccess:rsCallbackGetInfoForAddAdditionalStorageToDB})}function rsCallbackDisplayAddStorageToInstancesResults(f){hideDialog();var g=f.results||[],b=g.length,c=f.instancesWithProductOrders,i=f.instancesWithInvoices,h="frmShowResultsOfAddingStorageToInstances",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:h,formTitle:"Add Storage to Instances",fnCancelOrClose:function(){hideDialog();refreshPageAndScrollPos()}}),e=new MWClientTable({});a.addFlexibleFieldRow({rawLabel:"Instances",rawValue:""+b});a.addFlexibleFieldRow({rawLabel:"Product Orders (Created)",rawValue:""+c});a.addFlexibleFieldRow({rawLabel:"Invoices (Created)",rawValue:""+i});a.addSectionHeaderRow({rawTitle:"Instances"});e.addColumn(new MWColumn({columnName:"Customer",fnCustomRenderCellContents:function(m,l,k,j){return htmlEncode(m.instance.customerName)}}));e.addColumn(new MWColumn({columnName:"Database",fnCustomRenderCellContents:function(m,l,k,j){return htmlEncode(m.instance.subdomain)},fnBuildCellLinkDetail:function(m,k,j,l){return mwBuildSimpleLink(pageDatabaseDetail+m.instance.databaseId,1)}}));e.addColumn(new MWColumn({columnName:"Product Order Prorated Total",fnCustomRenderCellContents:function(m,l,k,j){return padAndPrefixSignedDollarsP({dollarValue:m.productOrderProratedTotal,forceDecimalsWhenNone:1})}}));e.addColumn(new MWColumn({columnName:"Status",fnCustomRenderCellContents:function(n,l,k,j){var m="Could not create Product Order";if(n.createdInvoices){m="Success"}else{if(n.createdProductOrders){m="Product Order Created but not Invoiced"}}return m}}));e.addColumn(new MWColumn({columnName:"Status Message",simpleDisplayColumnPropertyName:"statusMessage",simpleDisplayColumnNeedsMultilineEncoding:true}));var d=e.buildTableForArray(g);a.addFlexibleRow({valueHTML:d});a.showClientDialog()}function confirmedAddStorageToSpecificInstances(a,b){var e=getListOfCheckedRowValuesWithParams({form:a,buildRCArray:1,minSelected:1,tooFewWarning:"Please select an Instance",clientDlgParams:{subdialogDismisalFocusFieldName:"chkCheckAllRows",subdialog:1},unescapeValues:1,fnTransformValueForArray:function(f){return JSON.parse(f)}}),c=e.arrValues,d=e.selectedCount;if(!d){return}jsrsExecuteWithErrorP("Admin2_AddAdditionalStorageToInstances",rsCallbackHandleStandardJSONResponse,"Adding Additional Storage to Selected Instances",{arrInstancesWithStorageOverage:c},{fnOnSuccess:rsCallbackDisplayAddStorageToInstancesResults})}function rsCallbackGetInstancesWithStorageOverages(e){var i=e.instances||[],b=i.length,h="frmPromptAddStorageToInstances",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:h,formTitle:"Add Storage to Instances",focusFieldName:"btnOk",okButtonDisplayText:"Create Invoices",fnSubmit:confirmedAddStorageToSpecificInstances}),d=new MWClientTable({fnGetCheckDetailsForRow:function(l,j,k){return{value:htmlEncode(JSON.stringify(l))}}});if(!b){showInfoDialog("There are currently no instances with storage overages.","No Instances To Be Updated");return}a.addFlexibleFieldRow({rawLabel:"Instances with overages",rawValue:""+b});a.addSectionHeaderRow({rawTitle:"Instances To Update"});d.addColumn(new MWColumn({columnName:"Customer",simpleDisplayColumnPropertyName:"customerName"}));d.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomain",fnBuildCellLinkDetail:function(m,k,j,l){return mwBuildSimpleLink(pageDatabaseDetail+m.databaseId,1)}}));d.addColumn(new MWColumn({columnName:"Next Invoice Date",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(n,l,k,j){var m=new Date(n.nextInvoiceDate);return getLocalDateString(m)}}));var g=d.addColumn(new MWColumn({columnName:"Attached Files",additionalHeaderClasses:"centerAlign"}));g.addSubColumn(new MWColumn({columnName:"Overage",simpleDisplayColumnPropertyName:"formattedExcessAttachedFileAmount",additionalCellClasses:"rightAlign"}));g.addSubColumn(new MWColumn({columnName:"Monthly Usage",simpleDisplayColumnPropertyName:"formattedLastMonthsUploadAmount",additionalCellClasses:"rightAlign"}));var c=d.buildTableForArray(i);a.addFlexibleRow({valueHTML:c});var f=a.showClientDialog();if(f){f.chkCheckAllRows.checked=true;checkAllRows(f.chkCheckAllRows)}}function addStorageToJTInstances(){jsrsExecuteWithErrorP("Admin2_GetInstancesWithStorageOverages",rsCallbackGetInstancesWithStorageOverages,"Getting Instances With Storage Overages")}function showAddProductToDB(a){jsrsExecuteWithErrorP("Admin2_GetDatabaseProductOptions2",rsCallbackHandleStandardJSONResponse,"Getting database product to edit",{databaseId:a.databaseId},{fnOnSuccess:rsCallbackGetDatabaseProductOptions})}function doDeleteDBProduct(a){var b="Deleting Database Product";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteDatabaseProduct",[a.databaseProductId],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+b},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function rsCallbackImportExpenses(a){hideDialog();if(checkResponseForError(a)){var c=JSON.parse(a),b=new ClientDialogBuilder({formTitle:"Import Completed"}),d=new MWClientTable({arrColumns:[new MWColumn({columnName:"User",simpleDisplayColumnPropertyName:"cardMember"}),new MWColumn({columnName:"Description",simpleDisplayColumnPropertyName:"description"}),new MWColumn({columnName:"Amount",simpleDisplayColumnPropertyName:"amount",additionalCellClasses:"rightAlign"})]});b.addFlexibleFieldRow({rawLabel:"Expenses Retrieved From Amex",rawValue:""+c.expensesRetrievedFromAmex,additionalCellClasses:"clsNarrowField"});b.addFlexibleFieldRow({rawLabel:"New Expenses Added",rawValue:""+c.expensesAdded});b.addFlexibleFieldRow({rawLabel:"Expenses Filtered By Blocklist",rawValue:""+c.filteredOut.length});if(c.filteredOut.length>0){b.addFlexibleFieldRow({});b.addSectionHeaderRow({rawTitle:"Filtered Expenses"});b.addFlexibleRow({valueHTML:d.buildTableForArray(c.filteredOut)})}b.showClientDialog()}}function doImportExpenses(){var a="Importing Expenses...";jsrsExecute(rsCallbackImportExpenses,"Admin_ImportExpenses",[],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+a},0,1);displayTimedMessage(a+"...");disableDialogButtons()}function confirmImportExpensesDialog(){displaySimpleConfirmationDialog(doImportExpenses,"Are you sure you want to import expenses?","Import Expenses",{})}function confirmDeleteDatabaseProduct(b,a,c){displaySimpleConfirmationDialog(doDeleteDBProduct,'Are you sure you want to delete "'+htmlEncode(c)+'"?',"Delete Database Product",{databaseProductId:a,productName:c})}function hideDialogAndEnableOpenOrderDialog(){hideDialog();enableOpenOrderDialog()}function rsCallbackGetOrderedProducts(d,g){enableOpenOrderDialog();var f=d,a=f.arrOrderedProducts,e=a?a.length:0,c=g.originalPayload,b={productOrderId:c.productOrderId};if(e){displaySimpleConfirmationDialog(doCancelOrder,"Are you sure you want to cancel this entire order for "+e+" product"+(e===1?"":"s")+"? ","Cancel Order",b,0,0,"Cancel Order",hideDialogAndEnableOpenOrderDialog);disableOpenOrderDialog()}else{doCancelOrder(b)}}function confirmCancelOrder(a){jsrsExecuteWithErrorP("Admin2_GetOrderedProducts2",rsCallbackHandleStandardJSONResponse,"Checking contents of order",{productOrderId:a},{fnOnSuccess:rsCallbackGetOrderedProducts});disableOpenOrderDialog()}function doCompleteOrder(a){jsrsExecuteWithErrorP("Admin2_CompleteOrder2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Completing Order",{productOrderId:a.productOrderId});disableOpenOrderDialog()}function completeOrder(b,c){var a="Are you sure you want to complete this order?
Doing so will convert these orders into subscribed products and an invoice.";displaySimpleConfirmationDialog(doCompleteOrder,a,"Complete Order",{productOrderId:c},0,0,"Complete Order",hideDialogAndEnableOpenOrderDialog);disableOpenOrderDialog()}function doZeroInitialProrate(a){jsrsExecuteWithErrorP("Admin2_ZeroOutProrate",refreshPageAndScrollPos,"Zeroing Out Prorate",{databaseId:a.databaseId})}function confirmZeroOutInitialProrate(b,a){displaySimpleConfirmationDialogP(doZeroInitialProrate,'Are you sure you want to zero out the Initial Prorated Total of "'+padAndPrefixSignedDollars(a)+'"?',{formTitle:"Zero Out Prorate",okButtonDisplayText:"Zero Prorate",contextDetail:{databaseId:b}})}function submitEditProductOrderItem(){var g=getObj("frmProductOrderItemDetails"),c=mjtElemData(g,"productOrderItemId"),a=new FormValidator(),f=g.txtPrice,d=cdGetExpandingTextFieldValue("txtNotes"),b=g.txtFirstPrice,e=(!f||a.CSValidateNumberField(f,"Price",false))&&a.CSValidateNumberField(b,"First Term Invoiced Price",false);if(!e){return}jsrsExecuteWithErrorP("Admin2_UpdateProductOrderItemDetails2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Item Details",{productOrderItemId:c,price:trim(f?f.value:""),notes:d,firstTermPrice:trim(b.value)})}function rsCallbackGetProductOrderItemDetailsForEdit(f){var j=f,i="frmProductOrderItemDetails",g,d=j.productName,a=j.id,n=j.basePrice,h=j.isFlexPricing,k="firstTermInvoicedPrice",m=j.hasOwnProperty(k),b=m?j[k]:"",e=j.notes,c=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),l=new ClientDialogBuilder({formId:i,formTitle:"Edit Order",focusFieldName:"txtFirstPrice",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitEditProductOrderItem()"}),arrExtraHeaderButtons:[c?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Order For '"+htmlEncode(d)+"'",doubleQuoteEncodedOnClickJS:"hideDialog();confirmDeleteProductOrderItem("+a+",unescape('"+escape(d)+"'))"}):null],fnSubmit:submitEditProductOrderItem});l.addFlexibleFieldRow({rawLabel:"Product",rawValue:d});l.addTextFieldRow("txtFirstPrice",{rawLabel:"First Term Invoiced Price ($)",fieldValue:padDollars(""+b),maxLength:8});if(!h){l.addTextFieldRow("txtPrice",{rawLabel:"Base Price ($)",fieldValue:padDollars(""+n),maxLength:8})}l.addExpandingTextFieldRows("txtNotes",{rawLabel:"Notes",value:e});g=l.showClientDialog();if(g){mjtElemData(g,"productOrderItemId",a)}}function showEditDBProductProductOrderItemDialog(a,b){jsrsExecuteWithErrorP("Admin2_GetProductOrderItemDetails2",rsCallbackHandleStandardJSONResponse,"Getting Order Item Details",{productOrderItemId:b},{fnOnSuccess:rsCallbackGetProductOrderItemDetailsForEdit})}function doDeleteProductOrderItem(a){jsrsExecuteWithErrorP("Admin2_DeleteProductOrderItem2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting order for "+a.productName,{productOrderItemId:a.productOrderItemId})}function confirmDeleteProductOrderItem(b,a){displaySimpleConfirmationDialog(doDeleteProductOrderItem,'Are you sure you want to delete the order for "'+htmlEncode(a)+'"?',"Delete Order",{productOrderItemId:b,productName:a})}function addSpecificProductAndQtyToOrder(b,a){jsrsExecuteWithErrorP("Admin2_AddProductToProductOrder2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Adding product to order",{productOrderId:b.productOrderId,productId:b.productId,pricingStructureId:b.pricingStructureId,quantity:a})}function submitAddSpecificProduct(){var d=getObj("frmAddProduct"),c=getCallbackDataOfDialog(d),b=d.cboQty,a=parseInt(b.options[b.selectedIndex].value,10);addSpecificProductAndQtyToOrder(c,a)}function rsCallbackGetProductDetailsForAddSpecificProduct(g,c){var d=c.originalPayload,e=g.arrProducts,b=e[0],h="frmAddProduct",f=b.termName,j=b.price,a=b.productTypeId===CRMProductType_Enum.crmptCounterGo?"":"$"+padDollars(j)+" "+htmlEncode(f),i=new ClientDialogBuilder({formId:h,formTitle:"Add Product",focusFieldName:"cboQty",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitAddSpecificProduct()"}),focusFieldOnMobile:1,fnSubmit:submitAddSpecificProduct,callbackData:{productOrderId:d.productOrderId,productId:d.productId}});i.addFlexibleFieldRow({rawLabel:"Product",rawValue:b.name});if(b.editionName){i.addFlexibleFieldRow({rawLabel:"Edition",rawValue:b.editionName})}i.addFlexibleFieldRow({rawLabel:"Base Price",rawValue:a});i.addFlexibleRow({valueHTML:""});i.addDialogInteriorRows(buildQuantityComboboxRow());i.showClientDialog()}function showAddSpecificProductToOrder(a){jsrsExecuteWithErrorP("Admin2_GetProductDetailsForAddToOrder2",rsCallbackHandleStandardJSONResponse,'Retrieving info for product, "'+a.productName,{productOrderId:a.productOrderId,productId:a.productId},{fnOnSuccess:rsCallbackGetProductDetailsForAddSpecificProduct})}function showAddSpecificProductCountSubmenu(d,c){var a=new ContextMenu(),b;a.AddMenuItemP({rawText:'Custom Quantity of "'+c.productName+'"',inactive:1,isHeader:1});for(b=2;b<=10;++b){a.AddMenuItemP({rawText:""+b,leadItemIconId:FontIconId_Enum.fiiPlusInCircle,doubleQuoteReadyScript:"addSpecificProductAndQtyToOrder("+htmlEncode(JSON.stringify(c))+","+b+")"})}a.AddSeparatorIfNecessary();a.AddMenuItemP({rawText:"...",doubleQuoteReadyScript:"showAddSpecificProductToOrder("+htmlEncode(JSON.stringify(c))+")"});a.ShowSubmenu(d)}function buildPricingInfoText(e){var i=e.price,d=e.editionPrice,b=e.additionalUserPrice,f=e.tier2PerUserPrice,g=e.tier2StartUserCount,h=e.minUserCount,a=[];if(d){a.push("$"+padDollars(d)+" Base")}if(b){var c=d?" per Additional User":" per User";a.push("$"+padDollars(b)+c)}if(g&&f){a.push("$"+padDollars(f)+" for Users "+g+"+")}if(h){a.push("Minimum "+h+" Users")}if(a.length===0&&i){a.push("$"+padDollars(i))}return a.join(", ")}function buildProductPricingSuffix(b){var a=buildPricingInfoText(b),c="";if(a){c=" ("+a+")"}else{if(b.priceGenerationName){c=" - "+b.priceGenerationName}}return c}function buildRestartProductItemsForMenu(h){var b=h.restartProducts,e=h.productOrderId,j=[];for(var d=0;d",o=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),n=h.notes;if(l){q=b}else{q=b+' '}r=cdBuildReadOnlyFieldRowP({rawLabel:"Invoice Number",valueHTML:q})+cdBuildDatePickerRow(e,"dtInvoiceDate","Invoice Date",cdCarefullyLocalizeDateValue(h.invoiceDate?h.invoiceDate:p),k)+cdBuildDatePickerRow(e,"dtStartDate","Start Date",cdCarefullyLocalizeDateValue(c),k)+cdBuildDatePickerRow(e,"dtEndDate","End Date",cdCarefullyLocalizeDateValue(j),k);if(a){r+=cdBuildReadOnlyFieldRowP({rawLabel:"Tax Rate To Use",valueHTML:'"})+cdBuildReadOnlyFieldRowP({rawLabel:"",valueHTML:'(Invoice and Database Tax Rates Differ)'})+""}r+=cdBuildExpandingTextFieldRowsP("txtNotes","Notes",{value:n||""});showDialogP(r,e,{formTitle:l?"Edit Invoice":"New Invoice",focusFieldName:l?"txtInvoiceNumber":"dtInvoiceDate",arrExtraHeaderButtons:l&&o?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Invoice",doubleQuoteEncodedOnClickJS:"hideDialog();confirmDeleteInvoice(event,"+l+",unescape('"+escape(g)+"'))"})]:0,contextDetailOrFnSubmit:{fnSubmit:submitCreateOrUpdateInvoice,callbackData:{id:h.id,databaseId:h.databaseId,optionalAlternateTaxInfo:a}}});changedInvSpecType()}function rsCallbackGetInvoiceForEdit2(a){showInvoiceDialog(a.invoiceInfo,a.invoiceTaxRateDiffersFromDB?{dbTaxRateName:a.dbTaxRateName,dbTaxRateAmount:a.dbTaxRateAmount}:undefined)}function showCreateInvoiceDialog(b,a){jsrsExecuteWithErrorP("Admin2_GetDefaultInvoiceInfo2",rsCallbackGetInvoiceForEdit2,"Retrieving Database Info For New Invoice...",{databaseId:a})}function showEditInvoiceDialog(b,a){jsrsExecuteWithErrorP("Admin2_GetInvoiceInfo",rsCallbackGetInvoiceForEdit2,"Retrieving Invoice Info...",{invoiceId:a})}function doToggleShowOnHomepage(a){jsrsExecuteWithErrorP("Admin2_ToggleHideUnpaidInvoiceOnHomepage",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Toggling display on Homepage",{invoiceId:a.invoiceId,showOnHomepage:a.showOnHomepage})}function confirmToggleShowOnHomepage(a){hideDialogP({callback:function(){var b=a.showOnHomepage?"Show ":"Hide";displaySimpleConfirmationDialogP(function(){doToggleShowOnHomepage(a)},"Are you sure you want to "+b.toLowerCase()+" this invoice on the Homepage?",{formTitle:b+" Invoice On Homepage",okButtonDisplayText:b+" Invoice"})}})}function submitEmailInvoice(a,d){var b=d.invoice,c=new FormValidator();if(!c.CSValidateRequiredField(a.txtEmailFrom,'Please enter a sender name in the "From" field.')){return}if(!c.CSValidateRequiredField(a.txtEmailTo,'Please enter a recipient in the "To" field.')){return}if(!c.CSValidateRequiredField(a.txtEmailSubject,"Please enter a Subject.")){return}if(!c.CSValidateRequiredField(a.txtBillTo,"Please enter a Bill To value.")){return}jsrsExecuteWithErrorP("Admin2_EmailInvoiceToCustomer",refreshPageAndScrollPos,"Retrieving Invoice Info",{invoiceId:b.id,emailFromName:a.txtEmailFrom.value,customerEmailAddress:a.txtEmailTo.value,subject:a.txtEmailSubject.value,billTo:a.txtBillTo.value})}var g_invoiceChangeTimeout=null;function rsCallbackUpdateInvoicePreview(a){var b=getObj("cnrEmailInvoicePreview");if(b){b.innerHTML=a.preview}}function updateInvoicePreview(a){var c=getObj("frmEmailInvoice"),b=c?c.txtBillTo:null;g_invoiceChangeTimeout=null;if(b){jsrsExecuteWithErrorP("Admin2_GetEmailInvoiceInfo2",rsCallbackHandleStandardJSONResponse,"",{invoiceId:a,billTo:b.value,useDefaultBillTo:0},{fnOnSuccess:rsCallbackUpdateInvoicePreview,skipDisableDialogButtons:1,skipInfoMessage:1})}}function onChangeInvoicePreview(a){if(g_invoiceChangeTimeout){window.clearTimeout(g_invoiceChangeTimeout)}g_invoiceChangeTimeout=window.setTimeout(function(){updateInvoicePreview(a)},250)}function getInvoiceDateFormat(c){if(!c){return""}var b=c.getFullYear(),d=c.getMonth()+1,a=c.getDate();return b+"-"+(d<10?"0":"")+d+"-"+(a<10?"0":"")+a}function getInvDateRangeFromDates(a,e){var d=parseDateString(a),b=parseDateString(e),c=getInvoiceDateFormat(d)+" - "+getInvoiceDateFormat(b);return c}function showInvoicePreviewDialog(a){var e=a.invoice.id,d="frmEmailInvoice",b=getInvDateRangeFromDates(a.invoice.startDate,a.invoice.endDate),c=cdBuildTextFieldRowP("txtEmailFrom","Email From Name",{fieldValue:"Moraware Support"})+cdBuildTextFieldRowP("txtEmailTo","Email Invoice to",{fieldValue:a.customer.email||"",isEmail:1})+cdBuildTextFieldRowP("txtEmailSubject","Subject",{fieldValue:"Moraware Invoice for "+b,isEmail:1})+cdBuildTextAreaFieldRowP("txtBillTo","Bill To",{unencodedText:a.defaultBillTo,fieldId:"txtLicense",onChangeDoubleQuotedContent:"onChangeInvoicePreview("+e+")"})+'Preview:'+a.preview+"";showDialogP(c,d,{formTitle:"Email Invoice",focusFieldName:"txtEmailTo",okButtonDisplayText:"Send Email",contextDetailOrFnSubmit:{fnSubmit:submitEmailInvoice,callbackData:a}})}function rsCallbackGetInvoiceForEmail(a){showInvoicePreviewDialog(a)}function showEmailInvoiceDialog(b,a){if(isDialogShowing()){return}jsrsExecuteWithErrorP("Admin2_GetEmailInvoiceInfo2",rsCallbackHandleStandardJSONResponse,"Retrieving Invoice Info",{invoiceId:a,billTo:"",useDefaultBillTo:1},{fnOnSuccess:rsCallbackGetInvoiceForEmail})}function rsCallbackDeleteInvoice(c){var a=c.databaseId,b=c.subdomainName;if(a){displayTimedMessage("Loading Database"+(b?(' "'+htmlEncode(b)+'"'):""));window.location=pageDatabaseDetail+a}else{refreshPageShowingMessage()}}function doDeleteInvoice(a){jsrsExecuteWithErrorP("Admin2_DeleteInvoice",rsCallbackDeleteInvoice,"Deleting Invoice",{invoiceId:a.invoiceId})}function confirmDeleteInvoice(c,b,a){displaySimpleConfirmationDialog(doDeleteInvoice,"Are you sure you want to delete Invoice #"+a+"?","Delete Invoice",{invoiceId:b,invoiceNumber:a})}function doGenerateInvoices(){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_GenerateInvoices",[],enableDialogButtons);showInfoDialog("Generating invoices...","Generating Invoices");disableDialogButtons();displayTimedMessage("Generating Invoices...")}function submitGenerateNextInvoice(){var c="frmGenerateNextInvoice",d=getObj(c),b=mjtElemData(d,"databaseId"),a=mjtElemData(d,"nextInvoiceDate");hideDialog();jsrsExecuteWithErrorP("Admin2_GenerateNextInvoice2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Generating Next Invoice",{databaseId:b,nextInvoiceDate:a})}function rsCallbackGetNextInvoiceInfo(b){enableDialogButtons();var d="frmGenerateNextInvoice",a=b.displayedNextInvoiceDate,c=new ClientDialogBuilder({formId:d,formTitle:"Generate Next Invoice",focusFieldName:"btnOk",focusFieldOnMobile:1,fnSubmit:submitGenerateNextInvoice}),e;c.addFlexibleRow({rawValue:"This will generate invoices for the "+b.termName+" subscription up to and\nincluding the Next Invoice Date of "+a+".\n\nAre you sure you want to generate the next invoice?"});e=c.showClientDialog();if(e){mjtElemData(e,"databaseId",b.databaseId);mjtElemData(e,"nextInvoiceDate",b.nextInvoiceDate)}}function showGenerateNextInvoiceDialog(a){if(isDialogShowing()){return}jsrsExecuteWithErrorP("Admin2_GetNextInvoiceInfoForDB",rsCallbackGetNextInvoiceInfo,"Getting Next Invoice Info for Subscription",{databaseId:a})}function showSubscriptionExtraMenu(e){var c=e.arrMenuInfos,a,d,b=new ContextMenu();for(d=0;d'+a+""});h.addDatePickerRow(f,"dtNextInvoiceDate",{rawLabel:"Next Invoice Date",strValue:cdCarefullyLocalizeDateValue(e||"")});h.addTextFieldRow("txtQBId",{rawLabel:"QuickBooks Id",fieldValue:(g.qbId||"")+"",maxLength:209,hideRow:!i});c=h.showClientDialog();if(c){mjtElemData(c,"databaseId",i)}}function showEditSubscriptionDialog(a){jsrsExecuteWithErrorP("Admin2_GetSubscription",rsCallbackHandleStandardJSONResponse,"Retrieving Subscription For Edit",{databaseId:a},{fnOnSuccess:rsCallbackGetSubscriptionForEdit})}function rsCallbackGetSubscriptionForCreateOrder(b){var f=b,e="frmCreateOrder",d=new Date(),a=getDateAsDisplayString(d),c=new ClientDialogBuilder({formId:e,formTitle:"New Order",okButtonDisplayText:"Create",focusFieldName:"dtStartDate",focusFieldOnMobile:1,fnSubmit:submitCreateOrder}),g;c.addDatePickerRow(e,"dtStartDate",{rawLabel:"StartDate",strValue:a});c.addFlexibleFieldRow({rawLabel:"Billing Term",rawValue:f.termName});g=c.showClientDialog();if(g){mjtElemData(g,"subscription",f)}}function showCreateOrderDialog(a){jsrsExecuteWithErrorP("Admin2_GetSubscription",rsCallbackHandleStandardJSONResponse,"Retrieving Subscriptions",{databaseId:a},{fnOnSuccess:rsCallbackGetSubscriptionForCreateOrder,databaseId:a})}function rsCallbackCreatedPayment(a){hideDialog();window.location=pagePaymentDetail+a.paymentId}function getPaymentTransactionLabel(){var c=getObj("frmPayment"),a=c.cboPaymentMethod,b=a&&(a.options[a.selectedIndex].value==="Check");return b?"Check #":"Transaction Id"}function postTransIdValidationSubmitEditOrAddPayment(a){if(a.paymentId){jsrsExecuteWithErrorP("Admin2_UpdatePayment2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Payment",a)}else{jsrsExecuteWithErrorP("Admin2_CreatePayment2",rsCallbackCreatedPayment,"Creating Payment",a)}}function submitEditOrAddPayment(u,A){var h=new FormValidator(),v=A.id,t=A.forceDiscount,d=A.isChargeback,x=u.txtAmount,s=u.cboPaymentMethod,l=t?"Discount":s.options[s.selectedIndex].value,p=l==="Discount",g=A.creditMemoId||"",q=u.txtProcessor,B=v?q.value:"",n=u.txtTransactionId,k=p?"":trim(n.value),y=u.txtBillingProcessorCustomerId,C=(v||d)?y.value:"",f=u.cboPaymentType,i=d?PaymentType_Enum.ptCredit:(v?f.options[f.selectedIndex].value:(""+PaymentType_Enum.ptSale)),c=v?getDateForUrlParam(u.dtCardExpirationDate.value):"",r=v?u.txtCardDigits.value:"",b=cdGetExpandingTextFieldValue("txtComment1"),a=cdGetExpandingTextFieldValue("txtComment2"),j=l==="Check",z=l==="Wire Transfer",e=j?"Check #":"Transaction Id",D=!(p||j||z||d),m=(!k)&&((A.wasTransactionId||!v)&&(j||z||d)),w={};if(!h.CSValidateNumberFieldP({field:x,label:"Amount",isNullable:false,resultValueHolder:w})){return}if(!trim(l)){showInfoDialog("Please select a payment method.","Missing Payment Method",1,"cboPaymentMethod");return}if(v&&!h.CSValidateRequiredField(q,"Please enter a Payment Processor")){return}if(D&&!h.CSValidateRequiredField(n,"Please enter a "+getPaymentTransactionLabel())){return}var o={paymentId:v||"",amount:w.rc,paymentMethod:l,paymentProcessor:B,transactionId:k,billingProcessorCustomerId:C,paymentType:i,comment1:b,comment2:a,ccExpiration:c,ccDigits:r,creditMemoId:g,invoiceId:(g?"":A.invoiceId)||""};if(m){displaySimpleConfirmationDialog(postTransIdValidationSubmitEditOrAddPayment,"Are you sure you don't want to enter a "+e+"?","Omit "+e,o,1,"txtTransactionId");return}postTransIdValidationSubmitEditOrAddPayment(o)}function buildDBSelector(e,a){var d='"}function buildPaymentTypeDropdownRow(c){var b={},a='";return cdBuildReadOnlyFieldRowP({rawLabel:"Payment Type",valueHTML:a})}function updatePaymentTransactionLabel(){var a=getObj("spnPaymentTransactionLabel");if(a){a.innerHTML=getPaymentTransactionLabel()}}function buildPaymentMethodDropdownRow(c,b){var d={},a='";return cdBuildReadOnlyFieldRowP({rawLabel:"Payment Method",valueHTML:a})}function showPaymentDialog(o){var l=o.isDiscount,t=o.id,e="frmPayment",p=o.processor?o.processor:(t?"":"Manual"),m=o.subdomain,s=o.customerName,n=o.databaseId,q=o.invoiceNumber,f=o.invoiceTotalDue,a=o.invoiceTotalPaid,h=o.creditMemoTotalWithTax,j=o.creditMemoTotalCredited,c=o.invoiceDate,g=o.creditMemoDate,k=o.creditMemoNumber,d=o.isChargeback,i=(o.transactionId&&!l)?(""+o.transactionId):"",r=(t?"Edit":"New")+(l?" Discount":" Payment"),b=new ClientDialogBuilder({formId:e,formTitle:r,fnSubmit:submitEditOrAddPayment,focusFieldName:"txtAmount",arrExtraHeaderButtons:[(t&&!l)?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Payment",doubleQuoteEncodedOnClickJS:"confirmDeletePayment("+t+")"}):null],callbackData:{id:t,databaseId:n,invoiceId:o.invoiceId,creditMemoId:o.creditMemoId,forceDiscount:l?1:0,wasTransactionId:i?1:0,isChargeback:d?1:0}});if(d&&!t){b.addDialogInteriorRows('WARNING: If you are not entering a Chargeback, you do not want this dialog!(This is NOT how you issue a credit!)')}if(s){b.addFlexibleFieldRow({rawLabel:"Customer",rawValue:s});if(n){b.addFlexibleFieldRow({rawLabel:"Database",rawValue:m||"-No Subdomain-"})}}if(d&&!t&&k){b.addFlexibleFieldRow({rawLabel:"Credit Memo #",rawValue:""+k});b.addFlexibleFieldRow({rawLabel:"Credit Memo Date",rawValue:""+g});b.addFlexibleFieldRow({rawLabel:"Invoice #",rawValue:""+q});b.addFlexibleFieldRow({rawLabel:"Total Refund Amount",rawValue:"$"+padDollars(h,1)});b.addFlexibleFieldRow({rawLabel:"Total Credited",rawValue:"$"+padDollars(j,1)})}else{if(q){b.addFlexibleFieldRow({rawLabel:"Invoice #",rawValue:""+q});b.addFlexibleFieldRow({rawLabel:"Invoice Date",rawValue:cdCarefullyLocalizeDateValue(c)});b.addFlexibleFieldRow({rawLabel:"Total Due",rawValue:"$"+padDollars(f,1,1)});b.addFlexibleFieldRow({rawLabel:"Total Paid",rawValue:"$"+padDollars(a,1,1)});b.addFlexibleFieldRow({rawLabel:"Total Outstanding",rawValue:"$"+padDollars(f-a,1,1)})}}if(s||q){b.addDialogInteriorRows('')}b.addTextFieldRow("txtAmount",{labelHTML:"Amount ($)",fieldValue:""+(o.amount?o.amount:""),maxLength:10});if(!l){b.addDialogInteriorRows(buildPaymentMethodDropdownRow((d?"":o.method),d))}if(t){b.addTextFieldRow("txtProcessor",{labelHTML:"Payment Processor",fieldValue:p,maxLength:20})}if(!l){b.addTextFieldRow("txtTransactionId",{labelHTML:'Transaction Id',fieldValue:i,maxLength:20})}if(t||d){b.addTextFieldRow("txtBillingProcessorCustomerId",{labelHTML:"Billing Id",fieldValue:o.billingProcessorCustomerId||"",maxLength:12})}if(t){b.addDialogInteriorRows(buildPaymentTypeDropdownRow(o.paymentTypeId)+cdBuildDatePickerRow(e,"dtCardExpirationDate","Card Expires",cdCarefullyLocalizeDateValue(o.ccExpiration||"")));b.addTextFieldRow("txtCardDigits",{labelHTML:"Last 4 Digits of CC",fieldValue:o.ccDigits,maxLength:4})}b.addDialogInteriorRows(cdBuildExpandingTextFieldRowsP("txtComment1","Comments",{value:o.comment1||""})+cdBuildExpandingTextFieldRowsP("txtComment2","Comments 2",{value:o.comment2||"",hideRow:!t}));if(t){b.addFlexibleFieldRow({rawLabel:"Bulk Import",rawValue:o.bulkImport?"Yes":"No"})}b.showClientDialog();updatePaymentTransactionLabel()}function submitAddProductsToInvoice(){var c="frmInvoiceProduct",d=getObj(c),b=getListOfCheckedRowValuesWithParams({form:d,buildRCArray:1,minSelected:1,tooFewWarning:"Please select a DB Product",clientDlgParams:{subdialogDismisalFocusFieldName:"chkCheckAllRows",subdialog:1}}),a=b.arrValues;if(!a.length){return}jsrsExecuteWithErrorP("Admin2_AssignMultipleProductsToInvoice",refreshPageAndScrollPos,"Adding Invoiced Products",{invoiceId:mjtElemData(d,"invoiceId"),arrDBProducts:a.map(function(e){return JSON.parse(e)})})}function showAddProductsToInvoiceDialog(c){var a="Add Product To Invoice",f="frmInvoiceProduct",e=c.arrProducts,b=new MWClientTable({fnGetCheckDetailsForRow:function(j,h,i){return{value:htmlEncode(JSON.stringify({databaseProductId:j.id,price:j.price}))}}}),d=new ClientDialogBuilder({formId:f,formTitle:a,okButtonDisplayText:"Add",focusFieldName:"chkCheckAllRows",focusFieldOnMobile:1,fnSubmit:submitAddProductsToInvoice}),g;if(!e.length){showInfoDialog("There are no Products available to be added.","No Products");return}b.addColumn(new MWColumn({columnName:"Product",simpleDisplayColumnPropertyName:"productName"}));b.addColumn(new MWColumn({columnName:"Price",fnCustomRenderCellContents:function(k,j,i,h){return padAndPrefixSignedDollars(k.price)},additionalCellClasses:"rightAlign"}));b.addColumn(new MWColumn({columnName:"DB Product Id",simpleDisplayColumnPropertyName:"id",additionalCellClasses:"rightAlign"}));d.addFlexibleRow({valueHTML:b.buildTableForArray(e)});g=d.showClientDialog();if(g){consoleLog("Trying to set invoice id...params_=\n"+JSON.stringify(c,null,2));mjtElemData(g,"invoiceId",c.invoiceId)}}function submitUpdateInvoiceProduct(a,d){var c=new FormValidator(),e=cdGetExpandingTextFieldValue("txtNotes"),b=c.CSValidateNumberField(a.txtPrice,"Price",false);if(!b){return}jsrsExecuteWithErrorP("Admin2_UpdateInvoiceProduct2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Invoiced Product",{invoiceId:d.invoiceId,databaseProductId:d.databaseProductId,price:trim(a.txtPrice.value),notes:e})}function showEditInvoiceProductDialogForObj(c){var a=c.databaseProductId,f="frmInvoiceProduct",e=""+(c.price||""),b=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),d=new ClientDialogBuilder({formId:f,formTitle:"Update Invoiced Product Price",okButtonDisplayText:"Save",focusFieldName:"txtPrice",focusFieldOnMobile:1,arrExtraHeaderButtons:[b?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Invoice Product",doubleQuoteEncodedOnClickJS:"hideDialog();confirmDeleteInvoiceProduct("+a+","+c.invoiceId+",unescape('"+escape(c.productName)+"'))"}):null],fnSubmit:submitUpdateInvoiceProduct,callbackData:c});d.addFlexibleFieldRow({rawLabel:"Product",rawValue:c.productName});d.addTextFieldRow("txtPrice",{rawLabel:"Price ($)",fieldValue:e,maxLength:8});d.addExpandingTextFieldRows("txtNotes",{rawLabel:"Notes",value:c.invoiceDBProductNotes});d.showClientDialog()}function rsCallbackGetProductsForInvoiceProductDialog(d,b,c){enableDialogButtons();if(checkResponseForError(d)){var a=JSON.parse(d),e=a.arrProducts;c.arrProducts=e?e:0;showAddProductsToInvoiceDialog(c)}}function getProductsForInvoiceProductDialog(a){jsrsExecute(rsCallbackGetProductsForInvoiceProductDialog,"Admin_GetDatabaseProducts",[a.databaseId,a.invoiceId],enableDialogButtons,a);displayTimedMessage("Getting products for the invoice");disableDialogButtons()}function showAddProductToInvoice(c,b,a){if(isDialogShowing()){return}getProductsForInvoiceProductDialog({databaseId:b?b:0,invoiceId:a?a:0})}function rsCallbackGetInvoiceProductForEdit(d,b,c){enableDialogButtons();if(checkResponseForError(d)){var a=JSON.parse(d);showEditInvoiceProductDialogForObj(a)}}function showEditInvoiceProductDialog(b,a){jsrsExecute(rsCallbackGetInvoiceProductForEdit,"Admin_GetInvoiceProduct",[a,b],enableDialogButtons,{});displayTimedMessage("Getting invoice product to edit...");disableDialogButtons()}function doDeleteInvoiceProduct(a){jsrsExecuteWithErrorP("Admin2_DeleteInvoiceProduct2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting product from invoice",{invoiceId:a.invoiceId,databaseProductId:a.databaseProductId})}function confirmDeleteInvoiceProduct(b,a,c){displaySimpleConfirmationDialog(doDeleteInvoiceProduct,'Are you sure you want to delete "'+htmlEncode(c)+'" from the invoice?',"Delete Product",{invoiceId:a,databaseProductId:b})}function rsCallbackGetInvoiceInfoForNewPayment(b){var c=b.database,a=b.invoice;showPaymentDialog({databaseId:c.id,subdomain:c.subdomain,customerName:c.customerName,invoiceId:a.id,invoiceNumber:a.invoiceNumber,invoiceTotalDue:a.totalDue,invoiceTotalPaid:a.totalPaid,invoiceDate:a.invoiceDate})}function showCreatePaymentDialog(a){jsrsExecuteWithErrorP("Admin2_GetInvoiceInfoForNewPayment2",rsCallbackGetInvoiceInfoForNewPayment,"Getting Invoice Info For New Payment",{invoiceId:a})}function rsCallbackGetCreditMemoInfoForNewPayment(a){var c=a.database,b=a.creditMemo;showPaymentDialog({databaseId:c.id,subdomain:c.subdomain,customerName:c.customerName,invoiceNumber:b.invoiceNumber,isChargeback:1,comment1:"This is a chargeback.",creditMemoId:b.id,creditMemoNumber:b.creditMemoNumber,creditMemoDate:b.creditMemoDate,creditMemoTotalDue:b.totalBeforeTax,creditMemoTotalCredited:b.totalCredited,creditMemoTotalWithTax:b.totalWithTax,amount:b.totalWithTax-b.totalCredited,billingProcessorCustomerId:a.billingProcessorCustomerId,processor:"Manual"})}function showCreateCreditMemoChargebackPaymentDialog(a){jsrsExecuteWithErrorP("Admin2_GetCreditMemoInfoForNewPayment2",rsCallbackHandleStandardJSONResponse,"Getting Credit Memo Info For New Payment",{creditMemoId:a},{fnOnSuccess:rsCallbackGetCreditMemoInfoForNewPayment})}function rsCallbackGetPaymentInfoForEdit(a){showPaymentDialog(a)}function showEditPaymentDialog(a){jsrsExecuteWithErrorP("Admin2_GetPaymentInfo",rsCallbackHandleStandardJSONResponse,"Retrieving Payment",{paymentId:a},{fnOnSuccess:rsCallbackGetPaymentInfoForEdit})}function doDeletePayment(a){jsrsExecuteWithErrorP("Admin2_DeletePayment2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting Payment",{paymentId:a.paymentId})}function confirmDeletePayment(a){hideDialogP({callback:function(){displaySimpleConfirmationDialog(doDeletePayment,"Are you sure you want to delete the payment?","Delete Payment",{paymentId:a})}})}function submitApplyPaymentToDB(k,j){var c=0,d,a,e,g,h,f=j.isCredit,b=j.applyCreditToPayment;while(!e){d=getObj("rbPaymentTarget"+c);if(d.checked){a=d.value;e=JSON.parse(unescape(a))}++c}if(b){g="Admin2_ApplyCreditToPayment2";h={creditId:j.payment.id,paymentId:e.id}}else{if(f){g="Admin2_ApplyPaymentToCreditMemo2";h={paymentId:j.payment.id,creditMemoId:e.id}}else{g="Admin2_ApplyPaymentToInvoice2";h={paymentId:j.payment.id,invoiceId:e.id}}}jsrsExecuteWithErrorP(g,rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Applying Payment",h)}function buildCreditMemoSelectionRow(c,b){var a=new MWClientTable({noDataMessage:"No Credit Memos!"});a.addColumn(new MWColumn({columnName:"Credit Memo #",fnCustomRenderCellContents:function(h,g,f,e){var i={id:h.id,totalUncredited:h.totalUncredited},d="rbPaymentTarget"+e;return''+htmlEncode(" "+h.creditMemoNumber)+""}}));if(b){a.addColumn(new MWColumn({columnName:"Customer Name",simpleDisplayColumnPropertyName:"customerName"}));a.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomain"}))}a.addColumn(new MWColumn({columnName:"Total Due To Be Credited",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(g,f,e,d){return"$"+padDollars(g.totalDueToBeCredited,1,1)}}));a.addColumn(new MWColumn({columnName:"Total Uncredited",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(g,f,e,d){return"$"+padDollars(g.totalUncredited,1,1)}}));return''+a.buildTableForArray(c)+""}function asynchRefreshRBRowHighlights(){var f,b,d,c,g,a,e;for(f=0;true;++f){b=getObj("rbPaymentTarget"+f);if(!b){break}e=b.parentNode;while(e&&e.nodeName!="TR"){e=e.parentNode}if(e){c=e.className;g=c.indexOf(" highlightRow")>-1;if(b.checked&&!g){e.className=c+" highlightRow"}else{if(g&&!b.checked){e.className=c.replace(" highlightRow","")}}}}}var g_refreshRBRowsTimerId;function refreshRBRowHighlights(a){if(g_refreshRBRowsTimerId){clearTimeout(g_refreshRBRowsTimerId);g_refreshRBRowsTimerId=0}if(a){asynchRefreshRBRowHighlights()}else{g_refreshRBRowsTimerId=setTimeout(asynchRefreshRBRowHighlights,100)}}function buildUnmatchedPaymentSelectionRow(a){var b=new MWClientTable({noDataMessage:"No Payments!"});b.addColumn(new MWColumn({columnName:"Billing - Transaction Id",fnCustomRenderCellContents:function(h,g,f,e){var d={id:h.id,totalUncredited:h.totalUncredited},c="rbPaymentTarget"+e;return'"}}));b.addColumn(new MWColumn({columnName:"Comment1",simpleDisplayColumnPropertyName:"comment1"}));b.addColumn(new MWColumn({columnName:"Amount",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(f,e,d,c){return"$"+padDollars(f.amount,1,1)}}));b.addColumn(new MWColumn({columnName:"Unmatched Amount",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(f,e,d,c){return"$"+padDollars(f.unmatchedAmount,1)}}));return''+b.buildTableForArray(a)+""}function buildInvoiceSelectionRow(b,c){var a=new MWClientTable({noDataMessage:"No Invoices!"});a.addColumn(new MWColumn({columnName:"Invoice #",fnCustomRenderCellContents:function(i,g,f,e){var d="rbPaymentTarget"+e,h={id:i.id,totalUnpaid:i.totalUnpaid};return'"}}));if(c){a.addColumn(new MWColumn({columnName:"Customer Name",simpleDisplayColumnPropertyName:"customerName"}));a.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomain"}))}a.addColumn(new MWColumn({columnName:"Total Due",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(g,f,e,d){return"$"+padDollars(g.totalDue,1,1)}}));a.addColumn(new MWColumn({columnName:"Total Unpaid",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(g,f,e,d){return"$"+padDollars(g.totalUnpaid,1,1)}}));return''+a.buildTableForArray(b)+""}function rsCallbackGetInfoForApplyPayment(g,d){var k=g.payment,f=d.originalPayload,b=k.paymentTypeId,j=b==PaymentType_Enum.ptCredit,e=b==PaymentType_Enum.ptSale,i=g.arrUnpaidInvoices,n=g.arrUncreditedCreditMemos,h=g.arrUnmatchedSalePayments,m=k.availableAmount,c=f.applyCreditToPayment,l="frmApply",a=cdBuildReadOnlyFieldRowP({rawLabel:"Timestamp",rawValue:k.timestamp})+cdBuildReadOnlyFieldRowP({rawLabel:"Billing Id",rawValue:k.billingProcessorCustomerId})+cdBuildReadOnlyFieldRowP({rawLabel:"Payment Amount",rawValue:"$"+padDollars(k.amount,0,1)})+cdBuildReadOnlyFieldRowP({rawLabel:"Available Amount",rawValue:"$"+padDollars(m,0,1)});if(k.comment1){a+=cdBuildReadOnlyFieldRowP({rawLabel:"Comment 1",valueHTML:htmlMultilineEncode(k.comment1)})}if(k.comment2){a+=cdBuildReadOnlyFieldRowP({rawLabel:"Comment 2",valueHTML:htmlMultilineEncode(k.comment2)})}if(c){a+=buildUnmatchedPaymentSelectionRow(h)}else{if(e){a+=buildInvoiceSelectionRow(i,!f.databaseId)}else{if(j){a+=buildCreditMemoSelectionRow(n,!f.databaseId)}}}showDialogP(a,l,{formTitle:"Apply Payment",focusFieldName:"btnOk",okButtonDisplayText:"Save",contextDetailOrFnSubmit:{fnSubmit:submitApplyPaymentToDB,callbackData:{payment:k,isCredit:j?1:0,isSale:e?1:0,applyCreditToPayment:c}}});refreshRBRowHighlights()}function showApplyPaymentDialog(b,c,a){jsrsExecuteWithErrorP("Admin2_GetInfoForApplyPayment2",rsCallbackGetInfoForApplyPayment,"Retrieving Payment Info",{paymentId:b,databaseId:c||"",applyCreditToPayment:a?1:0})}function submitUpdatePaymentTimestamp(a,c){var d=a.dtTimestamp,b=new FormValidator();if(!b.CSValidateDateField(d,"Timestamp",false,"dtTimestamp")){return}jsrsExecuteWithErrorP("Admin2_UpdatePaymentTimestamp",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Payment Timestamp",{paymentId:c.paymentId,timeStamp:getDateForUrlParam(d.value)})}function rsCallbackGetInfoForEditPaymentTimestamp(b){var f="frmEditPaymentTS",a=b.timestamp,d=a.split(" ")[0],e=b.id,c=new ClientDialogBuilder({formId:f,formTitle:"Update Payment Timestamp",focusFieldName:"dtTimestamp",okButtonDisplayText:"Save",fnSubmit:submitUpdatePaymentTimestamp,callbackData:{paymentId:e}});c.addFlexibleFieldRow({rawLabel:"Original Timestamp",rawValue:b.timestamp});c.addDatePickerRow(f,"dtTimestamp",{rawLabel:"Timestamp",strValue:d});c.showClientDialog()}function showEditPaymentTimestampDialog(a){jsrsExecuteWithErrorP("Admin2_GetPaymentTimestamp2",rsCallbackHandleStandardJSONResponse,"Retrieving Payment Info",{paymentId:a},{fnOnSuccess:rsCallbackGetInfoForEditPaymentTimestamp})}function doDeletePaymentRefund(a){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeletePaymentRefund",[a.paymentRefundId],enableDialogButtons);displayTimedMessage("Deleting Refund...");disableDialogButtons()}function confirmDeletePaymentRefund(b,a,c){displaySimpleConfirmationDialog(doDeletePaymentRefund,"Are you sure you want to delete this "+padAndPrefixSignedDollars(c,1)+" refund?","Delete Refund",{paymentRefundId:a})}function buildDialogRow(b,a,c){var d="";if(c){d=' style="text-align:'+c+'"'}return""+b+"
"+a+""}function buildDialogDoubleColumnRow(b,a){return"'+b+""}function buildDialogSeparatorRow(){return''}function rsCallbackImportFromPaymentProcessors(l,d){var i=d.originalOptions||{},m=l.arrNewOrUpdatedPayments,p=m.length,b=l.reportRecordCount,e=l.newSucessfulImportCount,k=l.newFailureCount,h=l.changedCount,j=l.unchangedCount,o=l.ignoredRecordCount,c=k+e+h+j+o,n="frmInfo",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:n,formTitle:"Payments Imported",fnCancelOrClose:function(){hideDialog();if(p||i.forceRefresh){refreshPageShowingMessage()}}});if(c){if(b!==c){a.addFlexibleRow({rawValue:'# of records in the Report doesn\'t match the # of payments found!'});a.addFlexibleFieldRow({rawLabel:"Total Records In Report",rawValue:""+l.reportRecordCount});a.addFlexibleRow({rawValue:""});if(e){a.addFlexibleFieldRow({rawLabel:"Successful",rawValue:""+e})}if(h){a.addFlexibleFieldRow({rawLabel:"Updated",rawValue:""+h})}if(j){a.addFlexibleFieldRow({rawLabel:"Unchanged",rawValue:""+j})}if(k){a.addFlexibleFieldRow({rawLabel:"Failed",rawValue:""+k})}if(o){a.addFlexibleFieldRow({rawLabel:"Ignored",rawValue:""+o})}a.addFlexibleFieldRow({rawLabel:"Total Payments Found",rawValue:""+c});a.addFlexibleRow({rawValue:""})}else{if(j===c){a.addFlexibleFieldRow({rawLabel:"Total Payments",rawValue:""+c+(j===c?" (Unchanged)":"")})}}if(e||k){if(e){a.addFlexibleFieldRow({rawLabel:"New (Successful) Imports",rawValue:""+e})}if(k){a.addFlexibleFieldRow({rawLabel:"New (Failed) Imports",rawValue:""+k})}}if(h){a.addFlexibleFieldRow({rawLabel:"Updated",rawValue:""+h})}if(o){a.addFlexibleFieldRow({rawLabel:"Imports Ignored Due To Result Code",rawValue:""+o})}if(p){a.addSectionHeaderRow({rawTitle:"New/Updated Payments"});var g=new MWClientTable({});g.addColumn(new MWColumn({columnName:"Transaction",simpleDisplayColumnPropertyName:"transactionId"}));g.addColumn(new MWColumn({columnName:"Timestamp",simpleDisplayColumnPropertyName:"timestamp"}));if(h){g.addColumn(new MWColumn({columnName:"Change/Discrepancy Description",simpleDisplayColumnPropertyName:"changeDescription",simpleDisplayColumnNeedsMultilineEncoding:1}))}g.addColumn(new MWColumn({columnName:"Amount",simpleDisplayColumnPropertyName:"amount",additionalCellClasses:"rightAlign",additionalHeaderClasses:"rightAlign"}));var f=g.addColumn(new MWColumn({columnName:"Credit Card",additionalHeaderClasses:"centerAlign"}));f.addSubColumn(new MWColumn({columnName:"Expires",simpleDisplayColumnPropertyName:"ccExp",additionalCellClasses:"rightAlign",additionalHeaderClasses:"rightAlign"}));f.addSubColumn(new MWColumn({columnName:"Digits",simpleDisplayColumnPropertyName:"ccDigits",additionalCellClasses:"rightAlign",additionalHeaderClasses:"rightAlign"}));g.addColumn(new MWColumn({columnName:"Method",simpleDisplayColumnPropertyName:"method",additionalCellClasses:"centerAlign",additionalHeaderClasses:"centerAlign"}));g.addColumn(new MWColumn({columnName:"Type",simpleDisplayColumnPropertyName:"type",additionalCellClasses:"centerAlign",additionalHeaderClasses:"centerAlign"}));g.addColumn(new MWColumn({columnName:"Result",simpleDisplayColumnPropertyName:"resultMessage",additionalCellClasses:"centerAlign",additionalHeaderClasses:"centerAlign",fnAdditionalCellClasses:function(t,r,q,s){if(t.resultCode){return"errorText"}return""}}));g.addColumn(new MWColumn({columnName:"Comment",simpleDisplayColumnPropertyName:"comment1",simpleDisplayColumnNeedsMultilineEncoding:1}));a.addFlexibleRow({valueHTML:g.buildTableForArray(m)})}}else{a.addFlexibleRow({rawValue:"No payments"})}hideDialog();a.showClientDialog()}function submitImportPaymentProcessorPayments(a,c){hideDialog();c=c||{};var b=new FormValidator(),f,e=c.useSpecificDate,d="";if(a&&e){f=a.dtDate;if(!b.CSValidateDateField(f,"Date",false,"dtDate")){return}d=getDateForUrlParam(f.value)}jsrsExecuteWithErrorP("Admin2_ImportFromPaymentProcessors",rsCallbackHandleStandardJSONResponse,"Importing Payments",{transactionDate:d},{fnOnSuccess:rsCallbackImportFromPaymentProcessors,forceRefresh:c.forceRefreshOnCancel})}function rsCallbackGeneratePaymentDates(a){if(!a.count){showInfoDialog("No payment dates were generated","Generate Payment Dates",0,null);return}var b=new ClientDialogBuilder({formId:"generatePaymentDates",formTitle:"Generate Payment Dates",focusFieldOnMobile:1,suppressDialogConfirmer:1,fnCancelOrClose:refreshPageAndScrollPos});b.addFlexibleFieldRow({rawLabel:"# of Generated Automated Payment Status Records",rawValue:""+a.count});b.showClientDialog()}function showGeneratePaymentDatesDialog(){displaySimpleConfirmationDialog(function(){hideDialog();jsrsExecuteWithErrorP("Admin_GeneratePaymentDates",refreshPageAndScrollPos,"Generate Payment Dates",{})},"Are you sure you want to generate payment dates?
NOTE: This action can't be undone.","Generate Payment Dates",{})}function promptPayInvoicesForPaymentDates(){var a=new ClientDialogBuilder({formTitle:"Run Automated Payments",okButtonDisplayText:"Run",focusFieldName:"btnOk",fnSubmit:function(){hideDialog();jsrsExecuteWithErrorP("Admin2_RunAutomatedPayments",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Run Automated Payments")}});a.addFlexibleRow({valueHTML:"Are you sure you want to run automated payments?
(Payments will only be applied up through the Last Bulk Invoice Generation Date)
"});a.showClientDialog()}function promptGenerateInvoices(){var a=new ClientDialogBuilder({formTitle:"Generate Invoices",okButtonDisplayText:"Generate",focusFieldName:"btnOk",fnSubmit:function(){hideDialog();doGenerateInvoices()}});a.addFlexibleRow({valueHTML:"Are you sure you want to Generate Invoices?"});a.showClientDialog()}function rsCallbackSimulateGeneratePaymentDates(g){var e=g.initialValues,d=g.generationDates||"",b=g.arrAutopayStatusCounts,h=g.arrUpdatedDBDates,i=b?b.length:0,a,f,j=new ClientDialogBuilder({formTitle:"Simulated Payment Date Generation"}),c=new MWClientTable({fnAdditionalRowAttrs:function(k){return"data-rowData='"+escape(JSON.stringify(k))+"'"}});delete g.initialValues;delete g.generationDates;delete g.arrAutopayStatusCounts;delete g.arrUpdatedDBDates;c.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomainName",additionalHeaderClasses:"centerAlign",sortInfo:{},fnBuildCellLinkDetail:function(k){if(k.databaseId){return new MWCellLinkDetail({simpleLink:pageDatabaseDetail+k.databaseId,dialogLink:1})}return null}}));c.addColumn(new MWColumn({columnName:"Autopay Date",simpleDisplayColumnPropertyName:"oldDate",additionalHeaderClasses:"centerAlign",arrSubColumns:[new MWColumn({columnName:"Old",simpleDisplayColumnPropertyName:"oldDate",additionalHeaderClasses:"centerAlign",sortInfo:{}}),new MWColumn({columnName:"New",simpleDisplayColumnPropertyName:"newDate",additionalHeaderClasses:"centerAlign",sortInfo:{}})]}));c.addColumn(new MWColumn({columnName:"Autopay Status",additionalHeaderClasses:"centerAlign",arrSubColumns:[new MWColumn({columnName:"Old",simpleDisplayColumnPropertyName:"oldStateHtml",simpleDisplayColumnIsAlreadyEncoded:true,additionalHeaderClasses:"centerAlign",sortInfo:{}}),new MWColumn({columnName:"New",simpleDisplayColumnPropertyName:"newStateHtml",simpleDisplayColumnIsAlreadyEncoded:true,additionalHeaderClasses:"centerAlign",sortInfo:{}})]}));j.addSectionHeaderRow({rawTitle:"Generated Payment Dates"});j.addFlexibleRow({valueHTML:c.buildTableForArray(h)});j.addSectionHeaderRow({rawTitle:"Factors Considered During Generation"});j.addFlexibleFieldRow({rawLabel:"Min Minutes Between Autopay Attempts",rawValue:""+e.minMinutesBetweenAutopayAttempts,additionalCellClasses:"clsNarrowField"});j.addFlexibleFieldRow({rawLabel:"Last Invoice Generation",rawValue:e.lastInvoiceGenerationDate});j.addFlexibleFieldRow({rawLabel:"First Payment Date To Generate",rawValue:e.firstPaymentDateToGenerate});j.addFlexibleFieldRow({rawLabel:"Latest Date To Generate Payments For",rawValue:e.latestDateToGeneratePaymentsFor});j.addFlexibleFieldRow({rawLabel:"Old Last Generated Payment Date",rawValue:e.oldLastGeneratedPaymentDate});for(a=0;a(Import all payments posted on a single, specific date) '});a.addDatePickerRow(e,"dtDate",{rawLabel:"Payment Transaction Date",strValue:c});a.addFlexibleRow({valueHTML:'
CAUTION:
If you proceed to import payments occurring on this specific date, you will no longer be able to automatically import payments from an earlier date!
Unless you have good reason to do otherwise, you should always choose to simply <Import Payments> instead.
'});a.showClientDialog()}else{submitImportPaymentProcessorPayments(null,{forceRefreshOnCancel:d})}}function submitUpdateTaxes(){var e="frmUpdateTaxes",f=getObj(e),d=mjtElemData(f,"arrChanged"),c=[],a,b;for(b=0;b(The following rates will remain unchanged)':'
(None of the existing tax rates have changed)
',additionalCellClasses:"leftAlign"});n.addFlexibleRow({valueHTML:h.buildTableForArray(b)})}e=n.showClientDialog();if(e){mjtElemData(e,"arrChanged",g)}}function screenTaxesForUpdate(){var d="frmUpdateTaxesStep1",q=getObj(d),g=mjtElemData(q,"state"),k=q.txtTaxes.value,a=String.fromCharCode(9),m=k.split("\n"),n="",o,e,b=[],p,t,s,h,r,f,j,l,c=1;if(g==="Utah"){j="UT-";r=1;f=0;l=null}else{if(g==="Washington"){j="WA-";r=3;f=0;l=null;c=100}else{if(g==="Ohio"){j="OH-";r=2;f=0;l=1}}}for(o=0;o1){t=p[f];s=trim(p[r]);if(t){t=j+t.replace("-","");if(null!==l){t+="-";t+=parseInt(p[l],10).toString()}if(s.length&&s.substring(s.length-1)==="%"){s=trim(s.substring(0,s.length-1))}h=parseFloat(s)*c;b[b.length]={name:t,rate:h}}else{n="\n"+e}}else{n="\n"+e}}}if(!b.length){if(n){showInfoDialog("There was no valid data found. The following text could not be parsed (Is it tab-delimited?):
"+htmlMultilineEncode(n),"No Usable Data",1,"txtTaxes")}else{showInfoDialog("There is nothing to submit!","No Data",1,"txtTaxes")}return}jsrsExecuteWithErrorP("Admin2_CheckBatchTaxesForUpdate2",rsCallbackHandleStandardJSONResponse,"Checking to see which taxes need updating",{arrNewRates:b},{fnOnSuccess:rsCallbackCheckBatchTaxesForUpdate})}function showUpdateTaxesDialog(a){var d="";if(a==="Utah"){d='
Enter two, tab-delimitted columns with the County/City Code and the Tax Rate (%)
'}}}var c="frmUpdateTaxesStep1",e,b=new ClientDialogBuilder({formId:c,formTitle:"Update "+a+" Tax Rates",focusFieldName:"txtTaxes",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"screenTaxesForUpdate()"}),fnSubmit:screenTaxesForUpdate});b.addFlexibleRow({valueHTML:d});b.addTextAreaFieldRow("txtTaxes",{rawLabel:"Taxes",mnemonicChar:"t",labelAbove:1,rowCount:18,autofocus:1});e=b.showClientDialog();if(e){mjtElemData(e,"state",a)}}function showUserEventLog(d,c,b,f,a){var e="";if(c){e+="pageSize="+c}if(b){e+="&from="+trim(getDateForUrlParam(b))}if(f){e+="&to="+trim(getDateForUrlParam(f))}if(a){e+="&dateCount="+trim(a)}window.location=pageUserEventLog+d+(e?"?":"")+e}function submitChangeLogOptions(){var l="frmChangeLogOptions",n=getObj(l),m=n.cboUsers,g=m.options[m.selectedIndex].value,a=new FormValidator(),e=n.pageSize,b=getObj("rbDateRange"),c=b&&b.checked,k=n.dtFrom,f=n.dtTo,d=n.txtDateCount,j="",i="",h="";if(!a.CSValidateIntegerField(e,"Page Size",true,1,2000)){return}if(c){if(!a.CSValidateDateField(k,"From",true)){return}if(!a.CSValidateDateField(f,"To",true)){return}if((!trim(k.value))&&(!trim(f.value))){showInfoDialog("Please specify a Range of Dates.","Missing Date Range",1,"dtFrom");return}j=k.value;i=f.value}else{if(!a.CSValidateIntegerField(d,"Number of Days",false,1,9999)){return}h=d.value}hideDialog();showUserEventLog(g,parseInt(trim(e.value),10),j,i,h)}function elDateRangeChanged(){var c=getObj("frmChangeLogOptions"),a=getObj("rbDateRange"),b=a&&a.checked;if(c){c.dtFrom.disabled=!b;c.dtTo.disabled=!b;c.txtDateCount.disabled=b}}function rsCallbackGetUsersForOptions(p,j,r){enableDialogButtons();if(checkResponseForError(p)){var b=r.userId,u=r.pageSize,g="frmChangeLogOptions",n=" onkeypress=\"return submitClientDialogOnEnter('"+g+"',event);\"",m="",q,d=JSON.parse(p),h=d.arrUsers,k,w,t=cdBuildDatePickerField(g,"dtFrom",r.dateFrom,n,""),l=cdBuildDatePickerField(g,"dtTo",r.dateTo,n,""),e,o,c=r.dateCount,v="Last "+buildTextField("txtDateCount",""+(c?c:7),n,4,"4em")+" Days",a=!c,f=new ClientDialogBuilder({formId:g,formTitle:"Change Log Options",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"alert('Hello')"}),focusFieldName:"cboUsers",focusFieldOnMobile:1,fnSubmit:submitChangeLogOptions}),s;for(q=0;q"+htmlEncode(k.email)+""}e="elDateRangeChanged()";o='
From:
'+t+'
To:
'+l+"
";f.addFlexibleFieldRow({rawLabel:"User",valueHTML:'"});f.addFlexibleFieldRow({labelHTML:cdBuildRBP("rbDateType","rbDateRange","Range of Dates ",{checked:a,onClickCode:e,forceLabelOnTheLeft:1}),valueHTML:o,suppressLabelColon:1});f.addFlexibleFieldRow({labelHTML:cdBuildRBP("rbDateType","rbDateCount","Number of Days ",{checked:!a,onClickCode:e,forceLabelOnTheLeft:1}),valueHTML:v,suppressLabelColon:1});f.addTextFieldRow("pageSize",{rawLabel:"Events/Page",fieldValue:""+u,isNumber:1,maxValue:2000});f.showClientDialog();elDateRangeChanged()}}function showChangeLogOptions(d,f,b,c,a,e){jsrsExecute(rsCallbackGetUsersForOptions,"Admin_GetUsers",[],enableDialogButtons,{userId:f?f:0,pageSize:b,dateCount:c,dateFrom:a,dateTo:e})}function eventLogObjectMenu(d,c,f,a){var b=new ContextMenu(),e;if(g_isDoubleClickEvent){window.location=pageEventLog+c+"/"+f;return}if(c==EventObjectType_Enum.eotUser){e='View changes to "'+a+'"'}else{e='View Change Log for "'+a+'"'}b.AddLinkItem(e,pageEventLog+c+"/"+f,"",1);switch(c){case EventObjectType_Enum.eotInvoice:b.AddSeparatorIfNecessary();b.AddLinkItem('View Invoice "'+a+'"',pageInvoiceDetail+f);break;case EventObjectType_Enum.eotCreditMemo:b.AddSeparatorIfNecessary();b.AddLinkItem('View Credit Memo "'+a+'"',pageCreditMemoDetail+f);break;case EventObjectType_Enum.eotPayment:b.AddSeparatorIfNecessary();b.AddLinkItem('View Payment "'+a+'"',pagePaymentDetail+f);break;case EventObjectType_Enum.eotDatabase:b.AddSeparatorIfNecessary();b.AddLinkItem('View Database "'+a+'"',pageDatabaseDetail+f);break;case EventObjectType_Enum.eotCustomer:b.AddSeparatorIfNecessary();b.AddLinkItem('View Customer "'+a+'"',pageCustomerDetail+f);break;case EventObjectType_Enum.eotProduct:b.AddSeparatorIfNecessary();b.AddLinkItem("View Products",pageSystemSettingsProducts);break;case EventObjectType_Enum.eotUser:b.AddSeparatorIfNecessary();b.AddLinkItem("View changes made by "+htmlEncode(a),pageUserEventLog+f);break;case EventObjectType_Enum.eotDatabaseProduct:break;case EventObjectType_Enum.eotSalesperson:case EventObjectType_Enum.eotOnboarder:break}b.Show(d)}function systemEventLogMenu(b){var a=new ContextMenu();if(g_isDoubleClickEvent){window.location=pageSystemEventLog;return}a.AddLinkItem("View changes made by the system",pageSystemEventLog,"",1);a.Show(b)}function jtUserEventLogMenu(d,f,b,c,e){var a=new ContextMenu();if(g_isDoubleClickEvent){window.location=pageJTUserEventLog+c+"/"+f;return}a.AddLinkItem("View changes made by "+b+" of DB "+e,pageJTUserEventLog+c+"/"+f,"",1);a.Show(d)}function userEventLogMenu(b,c,d){var a=new ContextMenu();if(g_isDoubleClickEvent){showUserEventLog(c);return}a.AddLinkItem("View changes made by "+d,pageUserEventLog+c,"",1);a.AddSeparatorIfNecessary();a.AddLinkItem("View changes to "+d,pageEventLog+EventObjectType_Enum.eotUser+"/"+c);a.Show(b)}function submitUpdateJTIManLKInfo(){var b="frmUpdateLK",c=getObj(b),a=getCallbackDataOfDialog(c);jsrsExecuteWithErrorP("Admin2_UpdateJTIManLKInfo2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating License",{databaseId:a.databaseId,newLicense:a.license})}function rsCallbackTestUpdateJTIManLKInfo(f,b){var c=b.originalPayload,j=f.arrDiffs,h=j.length>0,d=f.userCountWarnings,a="",e,k,i="frmUpdateLK",g=new ClientDialogBuilder({formId:i,formTitle:"Update License Key",fnSubmit:submitUpdateJTIManLKInfo,callbackData:{license:c.newLicense,databaseId:c.databaseId},okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Update License Key",mnemonicChar:"u",mnemonicActionJS:"submitUpdateJTIManLKInfo()"})});g.addFlexibleRow({rawValue:"Instance Name: "+f.instanceName});g.addSectionHeaderRow();if(d){g.addBubbleMessageRow({rawMessage:d})}if(h){a='';for(k=0;k"}a+="
";g.addFlexibleRow({valueHTML:'Updating the license key will result in the following changes:
'+a+"
"})}else{g.addFlexibleRow({rawValue:"Updating the license key will result in no changes.\n\n"})}g.addFlexibleRow({rawValue:"Are you sure you want to update the license key?"});g.showClientDialog()}function testUpdateJTIManLKInfo(){var e=getObj("frmLicense"),a=getCallbackDataOfDialog(e),d=e.txtLicense,c=trim(d.value),b=new FormValidator();if(!b.CSValidateRequiredField(d,"Please enter a License")){return}jsrsExecuteWithErrorP("Admin2_TestUpdateJTIManLKInfo2",rsCallbackHandleStandardJSONResponse,"Checking For Differences In The Proposed License",{databaseId:a.databaseId,newLicense:c},{fnOnSuccess:rsCallbackTestUpdateJTIManLKInfo})}function rsCallbackGenerateLicenseForDB(c,g){var b=g.originalPayload,e=c.licenseText,a=c.instanceName,f="frmLicense",d=new ClientDialogBuilder({formId:f,formTitle:"Update License Key",focusFieldName:"btnOk",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Analyze Changes",mnemonicChar:"a",mnemonicActionJS:"testUpdateJTIManLKInfo()"}),fnSubmit:testUpdateJTIManLKInfo,callbackData:{databaseId:b.databaseId}});if(a){d.addFlexibleRow({rawValue:"Instance Name: "+a});d.addSectionHeaderRow()}d.addTextAreaFieldRow("txtBody",{rawLabel:"License",unencodedText:e,fieldId:"txtLicense",emWidth:"30",labelAbove:1});d.showClientDialog()}function generateLicense(b,a){jsrsExecuteWithErrorP("Admin2_GenerateLicenseForDB2",rsCallbackHandleStandardJSONResponse,"Generating License",{databaseId:b,productExpirationDate:a?a:""},{fnOnSuccess:rsCallbackGenerateLicenseForDB})}function submitGenerateExpiringLicense(a,d){var c=new FormValidator(),e=a.dtExpiration,g,f=new Date(),b;f=new Date(f.getFullYear(),f.getMonth(),f.getDate());if(!c.CSValidateDateField(e,"Expiration Date",false,e.name)){return}g=getDateForUrlParam(e.value);b=parseDateString(g);if(f>b){showInfoDialog("You can't push out an expired license.","Invalid Expiration Date",1,"dtExpiration");return}generateLicense(d.databaseId,g)}function buildDefaultExpirationDate(){var d=new Date(),c=new Date(d.getFullYear(),d.getMonth(),d.getDate()+16),e=0,b=6,a=0;switch(c.getDay()){case b:a=2;break;case e:a=1;break}if(a){c=c=new Date(c.getFullYear(),c.getMonth(),c.getDate()+a)}return getLocalDateString(c)}function generateExpiringLicense(c){var b="dtExpiration",d="frmGenLicense",a=new ClientDialogBuilder({formId:d,formTitle:"Generate Expiring License",focusFieldName:b,fnSubmit:submitGenerateExpiringLicense,callbackData:{databaseId:c}});a.addDatePickerRow(d,b,{rawLabel:"Expiration Date",strValue:buildDefaultExpirationDate()});a.showClientDialog()}function showHomepage(){window.location=pageWelcome}function showPaypalInNewWindow(a){window.open("https://manager.paypal.com/viewProfile.do?selectedProfileId="+a+"&subaction=viewRbProfile","_blank")}function showJTJobInNewWindow(a){window.open("https://internal.moraware.net/sys/job/"+a,"_blank")}function submitPaymentOptions(){var g=pagePayments,f=getObj("frmPaymentOptions"),i=f.chkIncFailed.checked,m=f.chkIncSuccess.checked,b=getObj("rbSingleDate"),h=b.checked,c=getObj("rbDateRange"),d=c.checked,o=f.cboMethod,n=o.options[o.selectedIndex].value,a=new FormValidator(),k="",e="";if(i){g+="&incFail=1"}if(!m){g+="&incSuccess=0"}if(n){g+="&methods="+escape(n)}if(!(i||m)){showInfoDialog('Select at least one of "Include Successful" or "Include Failed",
Task: '+htmlEncode(unescape(c))+"","Set task status",{taskId:d,status:a})};if(f){hideDialogP({callback:e})}else{e()}}function submitTaskReportOptions(){var h="frmOptions",f=getObj(h),a=new FormValidator(),g=pageTaskReport,e=f.txtPageSize,b=trim(e.value),c=mjtElemData(f,"defaultStatusFilter"),i=parseInt(f.cboTaskStatusFilter.value,10),d=a.CSValidateIntegerFieldP({field:e,label:"Page Size",isNullable:true,minValue:1,maxValue:2000});if(!d){return}if(b){g+="&pageSize="+b}if(i!==c){g+="&status="+i}hideDialog();window.location=g;displayTimedMessage("Reloading page...")}function showTaskReportOptions(a){consoleLogBlockOpen("showTaskReportOptions()");consoleLog(JSON.stringify({params_:a},null,2));var c="frmOptions",d,b=new ClientDialogBuilder({formId:c,formTitle:"Task Report Options",focusFieldName:"cboTaskStatusFilter",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaskReportOptions()"}),fnSubmit:submitTaskReportOptions});b.addDropdown({rawLabel:"Task Status",fieldName:"cboTaskStatusFilter",arrAvailableOptions:[{cboValue:TaskStatusFilter_Enum.tsfActiveOnly,rawContent:"Active Only"},{cboValue:TaskStatusFilter_Enum.tsfCompleteOnly,rawContent:"Complete Only"},{cboValue:TaskStatusFilter_Enum.tsfActiveOrComplete,rawContent:"Any"}],objSelectedValue:{cboValue:a.taskStatusFilter}});b.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+a.pageSize,mnemonicChar:"r",maxLength:10,styleWidth:"7em",isNumber:1});d=b.showClientDialog();if(d){mjtElemData(d,"defaultStatusFilter",a.defaultStatusFilter)}consoleLogBlockClose()}function doDeleteEmailTemplate(a){jsrsExecuteWithErrorP("Admin2_DeleteEmailTemplate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting Email Template",{emailTemplateId:a.emailTemplateId})}function confirmDeleteEmailTemplate(b,a,c){if(c){hideDialog()}displaySimpleConfirmationDialog(doDeleteEmailTemplate,'Are you sure you want to delete "'+htmlEncode(a)+'"',"Delete Email Template",{emailTemplateName:a,emailTemplateId:b})}function rsCallbackCreatedEmailTemplate(){}function validateCommonEmail(d,a,f){var e=a.txtSubject,c=a.txtBody,b=c.value;if(!d.CSValidateRequiredField(e,"Please enter a Subject")){return}if(!d.CSValidateRequiredField(c,"Please enter a Body")){return}f.subject=trim(e.value);f.body=b;return 1}function submitCreateOrEditEmailTemplate(){var f="frmEmailTemplate",g=getObj(f),a=mjtElemData(g,"emailTemplateId"),b=new FormValidator(),e=g.txtFromName,d=g.chkDunning.checked,c={};if(!b.CSValidateRequiredField(g.txtName,"Please enter a Name for the Email Template")){return}if(!b.CSValidateRequiredField(e,"Please enter a From Name")){return}if(!validateCommonEmail(b,g,c)){return}jsrsExecuteWithErrorP("Admin2_CreateOrUpdateEmailTemplate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Submitting Email Template",{emailTemplateId:a||"",emailTemplateName:g.txtName.value,fromName:e.value,messageSubject:c.subject,messageBody:c.body,isDunningEmail:d?1:0},{postMessageFocusFieldName:"txtBody"})}function insertTextIntoTextField(c,b){var a=getObj(c);insertAtCursor(a,b)}function showTextSubstitutionOptions(a,b){show_staticTextInsertPicker(getObj("btnInsertSubstitutionString"),null,false,"insertTextIntoTextField",b,{arrValueNameDescription:[[g_emailSubstStrDigits,"Credit Card #","The last for digits of the credit card used with the last payment."],[g_emailSubstStrCCType,"Card Type","The type of credit card used for the last payment."],[g_emailSubstStrInvAmount,"Invoice Amount","Amount of invoice."],[g_emailSubstStrInvDate,"Invoice Date","Date of the invoice."],[g_emailSubstStrBillingURL,"Billing URL","Link to the billing page for this instance."]],strHelpHTML:"The following values will be replaced when you compose an email off of an invoice."})}function rsCallbackGetInfoForCreateOrEditEmailTemplate(c,g){var e="frmEmailTemplate",f,b=c.id,a=jtcrmHasAccess(JTCRMSecuredObject_Enum.soEmailTemplates,AccessRight_Enum.mjtARDelete),d=new ClientDialogBuilder({formId:e,formTitle:b?"Edit Email Template":"Create Email Template",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitCreateOrEditEmailTemplate()"}),fnSubmit:submitCreateOrEditEmailTemplate,arrExtraHeaderButtons:b?[a?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Email Template",doubleQuoteEncodedOnClickJS:"confirmDeleteEmailTemplate("+b+",unescape('"+escape(c.name)+"'),1)"}):"",a?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayEmailTemplateEventLog("+b+")"})]:0});d.addTextFieldRow("txtName",{rawLabel:"Template Name",mnemonicChar:"n",fieldValue:c.name});d.addFlexibleFieldRow({labelHTML:"From Email",rawValue:c.fromEmailAddress});d.addTextFieldRow("txtFromName",{labelHTML:"From Name",fieldValue:c.fromName});d.addTextFieldRow("txtSubject",{rawLabel:"Subject",mnemonicChar:"j",fieldValue:c.subject});d.addTextAreaFieldRow("txtBody",{rawLabel:"Body",mnemonicChar:"b",unencodedText:c.body,fieldId:"txtBody",textAreaClasses:"largeTextArea"});d.addFlexibleFieldRow({valueHTML:'"});d.addCheckboxRow("chkDunning",{rawLabel:"Dunning Email",mnemonicChar:"l",checked:c.dunning});f=d.showClientDialog();if(f){mjtElemData(f,"emailTemplateId",b)}}function showCreateOrEditEmailTemplateDialog(a){jsrsExecuteWithErrorP("Admin2_GetInfoForCreateOrEditEmailTemplate",rsCallbackGetInfoForCreateOrEditEmailTemplate,"Getting info for Email Template",{emailTemplateId:a.emailTemplateId?a.emailTemplateId:""},a)}function showNewEmailTemplateDialog(){showCreateOrEditEmailTemplateDialog({})}function showEditEmailTemplateDialog(b,a){showCreateOrEditEmailTemplateDialog({emailTemplateId:b,emailTemplateName:a})}function submitReorderEmailTemplatesDialog(a){submitReorderP({arrReorderedIds:a,reorderCommandName:"Admin2_ReorderEmailTemplates2",reorderObjectName:"Email Templates",reorderIdsPropertyName:"emailTemplateIds"})}function showReorderEmailTemplatesDialog(a){jsrsExecuteWithErrorP("Admin2_GetEmailTemplatesForReorder",rsCallbackGetObjectsForReorder,"Getting list of Email Templates for re-order",{},{arrayAttrName:"arrEmailTemplates",fnSubmit:submitReorderEmailTemplatesDialog,strReorderWhat:"Email Templates",highlightedId:a})}function getEmailTemplateSelectionOption(a){var f=a?a.cboTemplates:0,c=f.options[f.selectedIndex].value,e=!!c,b=e?JSON.parse(unescape(c)):{subject:"",fromName:"",body:""},d={isTemplateSelected:e,objET:b};return d}function submitEmail(g,f){var a=new FormValidator(),b=getEmailTemplateSelectionOption(g),c=b.objET,i=g.txtMessageRecipient,e=g.txtFromName,d=g.txtSubject,h=g.txtBody;if(!b.isTemplateSelected){showInfoDialog("Please select an email template","No Email Template Selected",1,"cboTemplate");return}if(!a.CSValidateRequiredField(e,'Please enter a sender name in the "From" field.')){return}if(!a.CSValidateRequiredField(i,'Please enter a recipient in the "To" field.')){return}if(!a.CSValidateRequiredField(d,"Please enter a Subject.")){return}if(!a.CSValidateRequiredField(h,"Please enter a message body.")){return}jsrsExecuteWithErrorP("Admin2_SendInvoiceEmail2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Sending email",{invoiceId:f.invoiceId,emailTemplateId:c.id,fromName:e.value,recipient:i.value,subject:d.value,body:h.value})}function updateEmailForTemplate(){var b=getObj("frmEmail"),a=getEmailTemplateSelectionOption(b);if(b){b.txtSubject.value=a.objET.subject;b.txtFromName.value=a.objET.fromName;b.txtBody.value=a.objET.body}}function rsCallbackGetInfoToCreateInvoiceEmail(g,c){var f=c.originalOptions,m=g.arrEmailTemplates,j=m.length,d,k="frmEmail",h="",e,b=g.defaultEmailTemplateId,a="",l;for(e=0;e"+htmlEncode(d.name)+""}l="";if(!j){h+='';l=' selected="selected"'}a+=cdBuildReadOnlyFieldRowP({rawLabel:"Customer",rawValue:g.customerName})+cdBuildReadOnlyFieldRowP({rawLabel:"Database",rawValue:g.subdomain})+cdBuildReadOnlyFieldRowP({rawLabel:"Invoice #",rawValue:""+g.invoiceNumber});if(g.resultMessage){a+=cdBuildReadOnlyFieldRowP({rawLabel:"Last Payment Result",rawValue:g.resultMessage+" (Code="+g.resultCode+")"})}a+=cdBuildReadOnlyFieldRowP({rawLabel:"Templates",valueHTML:'"})+''+cdBuildTextFieldRowP("txtFromName","From")+cdBuildTextFieldRowP("txtMessageRecipient","To",{isEmail:1,fieldValue:f.toEmailAddress||""})+cdBuildTextFieldRowP("txtSubject","Subject")+cdBuildTextAreaFieldRowP("txtBody","Body",{textAreaClasses:"largeTextArea"});showDialogP(a,k,{formTitle:"Email",focusFieldName:"txtMessageRecipient",okButtonDisplayText:"Send",contextDetailOrFnSubmit:{fnSubmit:submitEmail,callbackData:{invoiceId:f.invoiceId}}});updateEmailForTemplate();forceRescanDialogForNewNodes(k)}function showComposeEmailForInvoiceDialog(c,b,a){jsrsExecuteWithErrorP("Admin2_GetInfoToCreateInvoiceEmail2",rsCallbackHandleStandardJSONResponse,"Retrieving Info to email about Invoice #"+b+"...",{invoiceId:c},{fnOnSuccess:rsCallbackGetInfoToCreateInvoiceEmail,invoiceId:c,toEmailAddress:a})}function buildBouncedEmailDetailRows(a){var b=a.length,d="",e;if(b==1){e=a[0];d='Email Address:'+htmlEncode(e.emailAddress)+'Bounce Type:'+htmlEncode(e.bounceType)+'Details:'+htmlEncode(e.details)+""}else{if(b>1){d='';for(var c=0;c\n"}d+="
"}function getExternalLinkCellHtml(b){var d=b.hubspotCompanyId,a=b.hubspotCompanyLinkPrefix,c=''+d+"";return c}function getDatabaseDifferencesCellHtml(a){var c=a.databaseInfo,b="";b+="";if(c.deploymentServerDiffers){b+=buildChangeEntry("Hosted Server",c.crmListedDeploymentServer,c.actualDeploymentServer)}if(c.billingLinkDiffers){b+=buildChangeEntry("Billing Link",c.crmListedBillingLink,c.actualBillingLink)}if(c.cgUserCountDiffers){b+=buildChangeEntry("CG User Count",c.crmListedCGUserCount,c.actualCGUserCount)}if(c.nvUserCountDiffers){b+=buildChangeEntry("Inv User Count",c.crmListedNVUserCount,c.actualNVUserCount)}if(c.sysUserCountDiffers){b+=buildChangeEntry("Sys User Count",c.crmListedSysUserCount,c.actualSysUserCount)}if(c.requiresUpdateDueToEdition){b+=buildChangeEntry("Edition",c.crmListedEditionName+" (Id="+c.crmListedEditionId+")",c.actualEditionName+" (Id="+c.actualEditionId+")")}if(c.serverDatabaseLinkDiffers){b+=buildChangeEntry("Server Database Link",c.crmListedServerDatabaseLink,c.actualServerDatabaseLink)}if(c.counterGoActivity.activityStatesDiffer){b+=buildChangeEntry("CG Activity Status",c.counterGoActivity.crmActivityStatusFieldText,c.counterGoActivity.actualActivityStatusText)}if(c.nvInventoryActivity.activityStatesDiffer){b+=buildChangeEntry("Inv Activity Status",c.nvInventoryActivity.crmActivityStatusFieldText,c.nvInventoryActivity.actualActivityStatusText)}if(c.systemizeActivity.activityStatesDiffer){b+=buildChangeEntry("Sys Activity Status",c.systemizeActivity.crmActivityStatusFieldText,c.systemizeActivity.actualActivityStatusText)}if(c.customerStatusDiffers){b+=buildChangeEntry("Lifecycle",c.crmCompanyStatus,c.actualCustomerStatus)}b+="";return b}function rsCallbackGetAllDatabasesRequiringSynch(h){var f=h.databasesWithChanges,q=h.hubspotCompanyLinkPrefix,c=f.arrDatabasesWithChanges,p=c.length,m="frmPromptUpdateJTFields",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:m,formTitle:"Synch Database Fields",focusFieldName:"btnOk",fnSubmit:confirmedUpdateSpecificJTJobs}),n="",e,g,i=[["Billing Link",f.billingLinkMismatchTally],["Deployment Server",f.deploymentServerMismatchTally],["CG User Count",f.cgUserCountMismatchTally],["Inv User Count",f.nvUserCountMismatchTally],["Sys User Count",f.sysUserCountMismatchTally],["Edition",f.editionMismatchTally],["Address",f.addressMismatchCount],["Server Database Link",f.serverDatabaseLinkMismatchCount],["CG Activity Status",f.cgActivityStatusMismatchTally],["Inv Activity Status",f.nvActivityStatusMismatchTally],["Sys Activity Status",f.sysActivityStatusMismatchTally]],d,l;if(!p){showInfoDialog("There are currently no databases that require an update.","No Databases To Be Updated");return}a.addFlexibleFieldRow({rawLabel:"Databases Requiring An Update",rawValue:""+p});a.addSectionHeaderRow({rawTitle:"# of Mismatches"});for(d=0;d
Subdomain
Hubspot Id
Changes to Hubspot
Changes to JTCRM/Billing
" ;for(g="0;g
';var k=e.subdomainName,o=e.jtListedEditionName,b=e;n+=''+htmlEncode(k)+"";n+=getExternalLinkCellHtml({isHubspotChange:e.isHubspotChange,hubspotCompanyId:e.hubspotCompanyId,hubspotCompanyLinkPrefix:q,jobId:e.jobId});if(e.isHubspotCompanyValid){n+=getDatabaseDifferencesCellHtml({databaseInfo:e})}else{n+="Hubpost Company is no longer present by Id"}n+="";if(e.addressesDiffer&&e.isHubspotCompanyValid){n+=buildChangeEntry("Database Address",e.actualAddressDisplayString,e.crmAddressDisplayString)}else{if(!e.isHubspotCompanyValid){n+="Marking Hubspot Company Id as Invalid (update manually to fix)"}}n+="";n+=""}n+="";n+="";a.addFlexibleRow({valueHTML:n});a.showClientDialog();var j=getObj("chkCheckAllRows");if(j){checkAllRows(j)}}function synchHubspotPreview(){jsrsExecuteWithErrorP("Admin2_GetAllDatabasesRequiringSynch",rsCallbackGetAllDatabasesRequiringSynch,"Getting Databases Requiring An Update")}function rsCallbackDisplayAddUsersToInstancesResults(f){hideDialog();var g=f.results||[],b=g.length,c=f.instancesWithProductOrders,i=f.instancesWithInvoices,j=f.instancesWithChargedInvoices,h="frmShowResultsOfAddingUsersToInstances",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:h,formTitle:"Add Users to Instances",fnCancelOrClose:function(){hideDialog();refreshPageAndScrollPos()}}),e=new MWClientTable({});a.addFlexibleFieldRow({rawLabel:"Instances",rawValue:""+b});a.addFlexibleFieldRow({rawLabel:"Product Orders (Created)",rawValue:""+c});a.addFlexibleFieldRow({rawLabel:"Invoices (Created)",rawValue:""+i});a.addFlexibleFieldRow({rawLabel:"Invoices (Charged)",rawValue:""+j});a.addSectionHeaderRow({rawTitle:"Instances"});e.addColumn(new MWColumn({columnName:"Customer",fnCustomRenderCellContents:function(n,m,l,k){return htmlEncode(n.instance.customerName)}}));e.addColumn(new MWColumn({columnName:"Database",fnCustomRenderCellContents:function(n,m,l,k){return htmlEncode(n.instance.subdomain)},fnBuildCellLinkDetail:function(n,l,k,m){return mwBuildSimpleLink(pageDatabaseDetail+n.instance.databaseId,1)}}));e.addColumn(new MWColumn({columnName:"Product Order Prorated Total",fnCustomRenderCellContents:function(n,m,l,k){return padAndPrefixSignedDollarsP({dollarValue:n.productOrderProratedTotal,forceDecimalsWhenNone:1})}}));e.addColumn(new MWColumn({columnName:"Unpaid Invoices Total",fnCustomRenderCellContents:function(n,m,l,k){return padAndPrefixSignedDollarsP({dollarValue:n.unpaidInvoicesTotal,forceDecimalsWhenNone:1})}}));e.addColumn(new MWColumn({columnName:"Status",fnCustomRenderCellContents:function(o,m,l,k){var n="Could not create Product Order";if(o.chargedInvoices){n="Success"}else{if(o.createdInvoices){n="Invoices Created but not Charged"}else{if(o.createdProductOrders){n="Product Order Created but not Invoiced"}}}return n}}));e.addColumn(new MWColumn({columnName:"Status Message",simpleDisplayColumnPropertyName:"statusMessage",simpleDisplayColumnNeedsMultilineEncoding:true}));var d=e.buildTableForArray(g);a.addFlexibleRow({valueHTML:d});a.showClientDialog()}function confirmedAddUsersToSpecificInstances(a,b){var e=getListOfCheckedRowValuesWithParams({form:a,buildRCArray:1,minSelected:1,tooFewWarning:"Please select an Instance",clientDlgParams:{subdialogDismisalFocusFieldName:"chkCheckAllRows",subdialog:1},unescapeValues:1,fnTransformValueForArray:function(f){return JSON.parse(f)}}),c=e.arrValues,d=e.selectedCount;if(!d){return}jsrsExecuteWithErrorP("Admin2_AddAdditionalUsersToInstances",rsCallbackHandleStandardJSONResponse,"Adding Additional Users to Selected Instances",{arrInstancesWithAddedUsers:c},{fnOnSuccess:rsCallbackDisplayAddUsersToInstancesResults})}function rsCallbackGetInstancesWithAdditionalUsers(f){var c=f.instances||[],k=c.length,h=f.nextInvoiceDate,i="frmPromptAddUsersToInstances",a=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:i,formTitle:"Add Users to Instances",focusFieldName:"btnOk",okButtonDisplayText:"Create & Pay Invoices",fnSubmit:confirmedAddUsersToSpecificInstances}),d=new MWClientTable({fnGetCheckDetailsForRow:function(n,l,m){return{value:htmlEncode(JSON.stringify(n))}}});if(!k){showInfoDialog("There are currently no instances with additional users added outside the time period.","No Instances To Be Updated");return}a.addFlexibleFieldRow({rawLabel:"Instances with additional users",rawValue:""+k});if(h){a.addFlexibleFieldRow({rawLabel:"Filtered to Next Invoice Date",rawValue:getLocalDateString(new Date(h))})}a.addSectionHeaderRow({rawTitle:"Instances To Update"});d.addColumn(new MWColumn({columnName:"Customer",simpleDisplayColumnPropertyName:"customerName"}));d.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomain",fnBuildCellLinkDetail:function(o,m,l,n){return mwBuildSimpleLink(pageDatabaseDetail+o.databaseId,1)}}));var e=d.addColumn(new MWColumn({columnName:"Additional Users",additionalHeaderClasses:"centerAlign"}));e.addSubColumn(new MWColumn({columnName:"CounterGo",simpleDisplayColumnPropertyName:"additionalCounterGoUserCount"}));e.addSubColumn(new MWColumn({columnName:"Inventory",simpleDisplayColumnPropertyName:"additionalNVInventoryUserCount"}));e.addSubColumn(new MWColumn({columnName:"Systemize",simpleDisplayColumnPropertyName:"additionalSystemizeUserCount"}));var j=d.addColumn(new MWColumn({columnName:"Last Change",additionalHeaderClasses:"centerAlign"}));j.addSubColumn(new MWColumn({columnName:"Time",fnCustomRenderCellContents:function(p,n,m,l){var o=new Date(p.lastChangeTime);return getLocalDateString(o)+" - "+getLocalTimeString(o)}}));j.addSubColumn(new MWColumn({columnName:"Hours",simpleDisplayColumnPropertyName:"stableAgeInHours"}));d.addColumn(new MWColumn({columnName:"Next Invoice Date",fnCustomRenderCellContents:function(p,n,m,l){var o=new Date(p.nextInvoiceDate);return getLocalDateString(o)}}));var b=d.buildTableForArray(c);a.addFlexibleRow({valueHTML:b});a.showClientDialog();var g=getObj(i);if(g){g.chkCheckAllRows.checked=true;checkAllRows(g.chkCheckAllRows)}}function addUsersToJTInstances(b){b=b||{};var a=b.requireNextInvoiceDateBeTomorrow;jsrsExecuteWithErrorP("Admin2_GetInstancesWithAdditionalUsers",rsCallbackGetInstancesWithAdditionalUsers,"Getting Instances With Additional Users",{requireNextInvoiceDateBeTomorrow:a})}var InvoicePaymentOption_Enum={ipoOverall:1,ipoSingleInvoice:2};function submitMakePaymentOnInvoices(){var e="frmMakePaymentOnInvoices",h=getObj(e),b=parseInt(getSelectedRBValue(h,"rbPaymentOption"),10),g=b===InvoicePaymentOption_Enum.ipoOverall,c=getCallbackDataOfDialog(h),a=c.amountOutstanding,f=c.databaseBalanceInfo,d=c.invoiceId;hideDialog();jsrsExecuteWithErrorP("Admin2_MakePaymentOnInvoices",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Making Payment",{billingProcessorCustomerId:c.billingProcessorCustomerId,databaseId:c.databaseId,amount:g?f.databaseBalance:a,arrInvoiceAmounts:g?f.arrInvoiceAmounts:[{invoiceId:d,amount:a}],paymentProviderType:PaymentProcessorType_Enum.pptBraintree})}function doPromptMakePaymentOnInvoices(g,e){enableDialogButtons();var f=e.originalPayload.invoiceId,d=g.databaseBalanceInfo,c=g.billingProcessorCustomerId,b=g.invoiceNumber,j=g.databaseId,i="frmMakePaymentOnInvoices",h=g.amountOutstanding,a=new ClientDialogBuilder({formId:i,formTitle:"Make Payment",focusFieldName:d?"rbPaymentOption_Overall":"",focusFieldOnMobile:1,suppressDialogConfirmer:1,okButtonDisplayText:"Make Payment",fnSubmit:submitMakePaymentOnInvoices,callbackData:{billingProcessorCustomerId:c,databaseId:j,invoiceId:f,amountOutstanding:h,databaseBalanceInfo:d}});a.addFlexibleFieldRow({rawLabel:"Braintree Id",rawValue:c});a.addFlexibleFieldRow({rawLabel:"Invoice #",rawValue:""+b});a.addFlexibleFieldRow({rawLabel:"Invoice Total",rawValue:"$"+padDollars(g.invoiceTotal,1,0)});if(g.amountPaid){a.addFlexibleFieldRow({rawLabel:"Amount Paid",rawValue:"$"+padDollars(g.amountPaid,1,0)});a.addFlexibleFieldRow({rawLabel:"Amount Outstanding",rawValue:"$"+padDollars(g.amountOutstanding,1,0)})}a.addSectionHeaderRow();if(d){a.addRadioButtonRow({rawRowLabel:"Payment Amount:",labelHTML:'Total Balance: $'+padDollars(d.databaseBalance,1,1)+"",fieldName:"rbPaymentOption",fieldId:"rbPaymentOption_Overall",fieldValue:""+InvoicePaymentOption_Enum.ipoOverall,checked:true});a.addRadioButtonRow({labelHTML:'Just this invoice: $'+padDollars(h,1,1)+"",fieldName:"rbPaymentOption",fieldId:"rbPaymentOption_Invoice",fieldValue:""+InvoicePaymentOption_Enum.ipoSingleInvoice})}else{a.addFlexibleFieldRow({rawLabel:"Payment Amount",rawValue:"$"+padDollars(h,1,1),additionalRowClasses:"bold"})}a.showClientDialog()}function promptMakePaymentOnInvoices(a){jsrsExecuteWithErrorP("Admin2_GetInfoToPayInvoice",doPromptMakePaymentOnInvoices,"Retrieving Invoice Info To Make Payment",{invoiceId:a})}function toggleExpandAddressExtras(){var a=getObj("imgAddressExtrasExpander.expand"),b=!a.style.display;a.style.display=b?"none":"";getObj("imgAddressExtrasExpander.collapse").style.display=b?"":"none";getObj("divAddressExtras").style.display=b?"":"none"}function rsCallbackInitSession(c,a,b){enableDialogButtons();if(checkResponseForError(c)){window.open(b.url,"_blank")}}function rsCallbackOpenedCustomerPortal(g,c,k){enableDialogButtons();if(checkResponseForError(g)){var e=JSON.parse(g),a=e.error;if(a){var d=a.errorMessage,h=a.errorTitle,l=a.requiresRefresh;showInfoDialogWithConsequenceP({formTitle:h,rawValue:d,fnConsequence:l?rsCallbackRefreshPageAndScrollPos:0})}else{var b=e.userId,f=e.url,j=e.sessionId,i="Initializing Session";jsrsExecute(rsCallbackInitSession,"Portal_InitSession",[b,escape(j)],rsErrorCallbackShowErrorDialogAndRefresh,{url:f,errorDialogTitle:"Error "+i},0,1,f);displayTimedMessage(i+"...");disableDialogButtons()}}}function launchCustomerPortal(b){var a="Connecting to Customer Portal...";jsrsExecute(rsCallbackOpenedCustomerPortal,"Admin_OpenCustomerPortal",[b],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+a},0,1);displayTimedMessage(a+"...");disableDialogButtons()}function showPortalUsageReportOptions(){showInfoDialog("Options?
We don't need no stinkin' options!","TODO: showPortalUsageReportOptions()")}function rsCallbackShowDBsWithUngeneratedNonMonthlyTotals(d,b,c){enableDialogButtons();if(checkResponseForError(d)){var e=JSON.parse(d),a=new MWClientTable({noDataMessage:"No Databases With Ungenerated Invoices"});a.addColumn(new MWColumn({columnName:"Customer",fnCustomRenderCellContents:function(i,h,g,f){return htmlEncode(i.database[0].gdCustomerName)}}));a.addColumn(new MWColumn({columnName:"Database",fnCustomRenderCellContents:function(j,i,h,g){var f=j.database[0].gdSubdomainName;if(!f){f="Non-Hosted DB (Id="+j.database[0].gdDatabaseId+")"}return htmlEncode(f)},fnBuildCellLinkDetail:function(i,g,f,h){return mwBuildSimpleLink(pageDatabaseDetail+i.database[0].gdDatabaseId,1)}}));a.addColumn(new MWColumn({columnName:"Invoice Amount",fnCustomRenderCellContents:function(i,h,g,f){return padAndPrefixSignedDollars(i.amount,1)}}));a.addColumn(new MWColumn({columnName:"Invoice Date",fnCustomRenderCellContents:function(i,h,g,f){return getDateAsDisplayString(new Date(e[0].date))}}));a.addColumn(new MWColumn({columnName:"Term",fnCustomRenderCellContents:function(i,h,g,f){return c.Term}}));showInfoDialog(a.buildTableForArray(e),"Databases With Ungenerated Invoices");scrollDialogIfNecessary("frmTmpMessage",1,1)}}function showDBsWithUngeneratedNonMonthlyTotals(b,a){var c="Finding databases...";jsrsExecute(rsCallbackShowDBsWithUngeneratedNonMonthlyTotals,"Admin_GetDatabasesWithUngeneratedTotals",[b,a],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+c,DayOfMonth:a,Term:b},0,1);displayTimedMessage(c+"...");disableDialogButtons()}function registerChartPlugins(){Chart.plugins.register({afterDatasetsDraw:function(b,c){if(!b.data.showPointLabels){return}var a=b.chart.ctx;b.data.datasets.forEach(function(f,d){var e=b.getDatasetMeta(d);if(!e.hidden){e.data.forEach(function(j,i){a.fillStyle="rgb(0, 0, 0)";var l=12;var n="normal";var h="arial, helvetica, sans-serif";a.font=Chart.helpers.fontString(l,n,h);var k=f.data[i].toString();a.textAlign="center";a.textBaseline="middle";var m=5;var g=j.tooltipPosition();a.fillText(k,g.x,g.y-(l/2)-m)})}})}})}function submitVoidPayment(a,b){jsrsExecuteWithErrorP("Admin2_PerformVoidPayment",refreshPageAndScrollPos,"Retrieving Payment Info for Void Payment...",{paymentId:b.paymentId,amount:b.amount})}function rsCallbackGetInfoForVoidPayment(c,e){var b=e.originalPayload,d="frmConfirmVoidPayment",a=new ClientDialogBuilder({formId:d,formTitle:"Void Payment",okButtonDisplayText:"Void Payment",fnSubmit:submitVoidPayment,callbackData:c});a.addFlexibleFieldRow({rawLabel:"Payment Timestamp",rawValue:c.strPaymentTS});a.addFlexibleFieldRow({rawLabel:"Transaction Id",rawValue:c.transactionId});a.addFlexibleFieldRow({rawLabel:"Amount",valueHTML:padAndPrefixSignedDollars(c.amount,1)});a.showClientDialog()}function showCreateVoidingPaymentDialog(a){jsrsExecuteWithErrorP("Admin2_GetInfoForVoidPayment",rsCallbackGetInfoForVoidPayment,"Retrieving Payment Info for Void Payment...",{paymentId:a})}function submitRefundPayment(a,b){jsrsExecuteWithErrorP("Admin2_PerformRefundPayment",refreshPageAndScrollPos,"Retrieving Payment Info for Refund Payment...",{paymentId:b.paymentId,amount:b.amount})}function rsCallbackGetInfoForRefundPayment(b,e){var d=b.amount,c="frmConfirmRefundPayment",a=new ClientDialogBuilder({formId:c,formTitle:"Refund Payment",okButtonDisplayText:"Refund Payment",fnSubmit:submitRefundPayment,callbackData:b});a.addFlexibleFieldRow({rawLabel:"Payment Timestamp",rawValue:b.strPaymentTS});a.addFlexibleFieldRow({rawLabel:"Transaction Id",rawValue:b.transactionId});a.addFlexibleFieldRow({rawLabel:"Amount",valueHTML:padAndPrefixSignedDollars(d,1)});a.showClientDialog()}function showCreateRefundPaymentDialog(a){jsrsExecuteWithErrorP("Admin2_GetInfoForRefundPayment",rsCallbackGetInfoForRefundPayment,"Retrieving Payment Info for Refund Payment...",{paymentId:a})}function submitCreateCreditMemoRefund(){var g="frmRefund",e=getObj(g),b=getCallbackDataOfDialog(e),d=b.creditMemoId,c=getSelectedRB(e,"rbPayment"),f=c.getAttribute("data-paymentId"),i=e.txtRefundAmount,h={},a=new FormValidator();if(!a.CSValidateNumberFieldP({field:i,label:"Refund Amount",resultValueHolder:h})){return}jsrsExecuteWithErrorP("Admin2_ProcessCreditMemoCredit",refreshPageAndScrollPos,"Processing Refund",{paymentId:f,creditMemoId:d,amount:h.rc})}function rsCallbackGetPaymentsForCreditMemoRefund(i,d){var e=d.originalPayload,b=i.creditMemoAmount,a=i.amountCredited,l=i.remainingAmount,m=i.arrPayments,h=m?m.length:0,g=h?m[0]:0,c=h?Math.min(l,g.amount):l,k="frmRefund",f=new MWClientTable({noDataMessage:"No Payments"}),j=new ClientDialogBuilder({formId:k,formTitle:"New Refund",focusFieldName:h?"txtRefundAmount":"",okButtonDisplayText:"Process Refund",fnSubmit:submitCreateCreditMemoRefund,callbackData:{creditMemoId:e.creditMemoId}});if(!h){showInfoDialog("No payments available","No Payments");return}f.addColumn(new MWColumn({columnName:"Transaction Id",fnCustomRenderCellContents:function(q,p,o,n){return'"}}));f.addColumn(new MWColumn({columnName:"Timestamp",simpleDisplayColumnPropertyName:"paymentTS"}));f.addColumn(new MWColumn({columnName:"Amount",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(q,p,o,n){return padAndPrefixSignedDollars(q.amount,1)}}));j.addFlexibleFieldRow({rawLabel:"Credit Memo Amount",rawValue:padAndPrefixSignedDollars(b,1)});if(a){j.addFlexibleFieldRow({rawLabel:"Amount Credited",rawValue:padAndPrefixSignedDollars(a,1)})}j.addSectionHeaderRow({rawTitle:"Payment"});j.addFlexibleRow({valueHTML:f.buildTableForArray(m),hideRow:h==1});if(h==1){j.addFlexibleFieldRow({rawLabel:"Payment Transaction Id",rawValue:g.transactionId});j.addFlexibleFieldRow({rawLabel:"Timestamp",rawValue:g.paymentTS});j.addFlexibleFieldRow({rawLabel:"Amount",rawValue:padAndPrefixSignedDollars(g.amount,1)})}j.addTextFieldRow("txtRefundAmount",{rawLabel:"Refund Amount ($)",fieldValue:padDollars(c,1)});j.showClientDialog()}function showCreateRefundDialog(a){jsrsExecuteWithErrorP("Admin2_GetPaymentsForCreditMemoRefund",rsCallbackGetPaymentsForCreditMemoRefund,"Getting Payments available for a refund",{creditMemoId:a})}function buildTaxStateSelectionDropdown(a,c,b){return'"}function doBuildTaxRateBatch(){var c=getObj("frmBuildTaxRateBatch"),a=c.cboState,b=a.value;if(!b){showInfoDialog("Please select a state","No State Selected",1,a.name);return}jsrsExecuteWithErrorP("Admin2_BuildTaxRateBatch",refreshPageAndScrollPos,"Building Tax Rate Batch",{state:b})}function buildTaxRateBatch(a){var b="cboState",c=new ClientDialogBuilder({formId:"frmBuildTaxRateBatch",formTitle:"Build Tax Rate Batch",suppressDialogConfirmer:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Build Batch",mnemonicChar:"b",mnemonicActionJS:"doBuildTaxRateBatch()"}),fnSubmit:doBuildTaxRateBatch,focusFieldName:b});c.addFlexibleFieldRow({rawLabel:"State",valueHTML:buildTaxStateSelectionDropdown(a,b,"-Select a State-")});c.showClientDialog()}function submitTaxRateReconciliationReportOptions(){var e="frmOptions",g=getObj(e),a=new FormValidator(),c=g.txtPageSize,b=trim(c.value),d=trim(g.cboState.value),f="";if(!a.CSValidateIntegerField(c,"Page Size",true,1,2000)){return}if(b){f+="&pageSize="+b}if(d){f+="&state="+d}if(g.chkIncludeValidRows.checked){f+="&includeValidRows=1"}if(f){f=f.substring(1)}hideDialog();window.location=pageTaxRateReconciliationReport+f}function showTaxRateReconciliationReportOptions(b){var d="frmOptions",a="cboState",c=new ClientDialogBuilder({formId:d,formTitle:"Report Options",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaxRateReconciliationReportOptions()"}),focusFieldName:a,focusFieldOnMobile:1,fnSubmit:submitTaxRateReconciliationReportOptions});c.addFlexibleFieldRow({rawLabel:"State",valueHTML:buildTaxStateSelectionDropdown(b.state,a,"-Any-")});c.addFlexibleFieldRow({valueHTML:cdBuildCheckboxAndLabel("chkIncludeValidRows","chkIncludeValidRows","Include Valid Rows",b.includeValidRows)});c.addSectionHeaderRow();c.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+(b.pageSize||""),maxLength:10,isNumber:1,suppressAutocomplete:1});c.showClientDialog()}function submitEditAttachedFile(){var e=getObj("editAttachFile"),d=null,a=e.objectId.value,b=e.fileId.value,c="Updating File";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_UpdateAttachedFile",[a,b,escape(d)],enableDialogButtons);displayTimedMessage(c+"...");disableDialogButtons()}function confirmDeleteAttachedFile(b,a,c){promptConfirmDeleteFile(b,a,null,c,"Admin_DeleteAttachedFile",true)}function submitAttachFile(){if(g_arrFileDragDropFileInfos.length){doUploadFiles(getObj("attachFile"))}else{hideDialog()}}function showAttachFile(b,c,d,a){var f="attachFile",e=new ClientDialogBuilder({formId:f,formTitle:"Attach File",formAction:pageUploadAttachedFile,focusFieldName:"fileName",isSubdialog:a?1:0,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Attach",mnemonicChar:"a",mnemonicActionJS:a?a:"submitAttachFile()"}),fnSubmit:a?a:submitAttachFile});e.addFileUploadRow({fileLimit:1,fileType:d,objectId:c,acceptContentTypeHint:"image/*, .pdf",uploadLabel:"Drag or paste file here"});e.showClientDialog()}function deleteExpenseQuickbooksCustomer(a){var b="Deleting Quickbooks Vendor...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseQuickbooksCustomer",[a.expenseQuickbooksCustomerId],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function deleteExpenseVendor(a){var b="Deleting Expense Vendor...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseVendor",[a.expenseVendorId],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function deleteExpenseReport(a){jsrsExecuteWithErrorP("Admin2_DeleteExpenseReport",function(b){hideDialog();window.location=pageExpenses},"Deleting Expense Report...",{expenseReportId:a.expenseReportId})}function deleteImporBlocklist(a){var b="Deleting from Import Blocklist...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseImportBlocklist",[a.expenseImportBlocklistId],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function confirmDeleteExpenseReport(a){displaySimpleConfirmationDialogP(deleteExpenseReport,'Are you sure you want to delete this Expense Report"?',{formTitle:"Delete Expense Report",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{expenseReportId:a}})}function confirmDeleteExpenseImportBlocklist(a,b){displaySimpleConfirmationDialogP(deleteImporBlocklist,'Are you sure you want to delete Import Blocklist entry "'+b+'"?',{formTitle:"Delete From Expense Import Blocklist",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{expenseImportBlocklistId:a}})}function confirmDeleteQuickbooksCustomer(a,b){displaySimpleConfirmationDialogP(deleteExpenseQuickbooksCustomer,'Are you sure you want to delete the Quickbooks Vendor "'+htmlEncode(b)+'"?',{formTitle:"Delete Quickbooks Vendor",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{expenseQuickbooksCustomerId:a}})}function confirmDeleteExpenseVendor(a,b){displaySimpleConfirmationDialogP(deleteExpenseVendor,'Are you sure you want to delete Vendor "'+htmlEncode(b)+'"?',{formTitle:"Delete Expense Vendor",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{expenseVendorId:a}})}function confirmDeleteExpenseReportDetail(b){var a=getObj("txtSummary");if(a){a=a.innerHTML}displaySimpleConfirmationDialogP(function(){var c="Deleting Expense Report Detail...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseReportDetail",[b],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(c+"...");disableDialogButtons()},'Are you sure you want to delete the Expense Report Detail "'+a+'"?',{formTitle:"Delete Expense Report Detail",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{expenseReportDetailId:b}})}function deleteExpenseType(a){var b="Deleting Expense Type...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseType",[a.typeId],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function confirmDeleteExpenseType(a,b){displaySimpleConfirmationDialogP(deleteExpenseType,'Are you sure you want to delete the type "'+b+'"?',{formTitle:"Delete Expense Type",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{typeId:a}})}function deleteExpenseTrip(a){var b="Deleting Expense Trip...";jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseTrip",[a.tripId],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(b+"...");disableDialogButtons()}function confirmDeleteExpenseTrip(b,a){displaySimpleConfirmationDialogP(deleteExpenseTrip,'Are you sure you want to delete the trip "'+htmlEncode(a)+'" trip?',{formTitle:"Delete Expense Trip",okButtonDisplayText:"Delete",isSubdialog:true,contextDetail:{tripId:b}})}function submitaddOrUpdateExpenseTrip(){var f=getObj("addOrUpdateExpenseTrip"),b=f.txtLocation.value,d=f.year.value,h=f.cboMonth[f.cboMonth.selectedIndex].value,g=parseInt(d,10),e=f.tripId.value,a=f.chkIsDisabled.checked,c="Adding Trip...";if(""===b){showInfoDialog("Location is required","Missing Field",1,"txtLocation");return}if(isNaN(g)||g<=2017){showInfoDialog("Year must be a whole number greater than 2017","Missing Field",1,"year");return}jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseTrip",[e,d,h,escape(b),a?1:0],enableDialogButtons);displayTimedMessage(c+"...");disableDialogButtons()}function getMonthOptionElements(d){var b="";var c=new Date();var a="en-us";for(var e=0;e<12;e++){b+=buildOptionHTML((new Date(2018,e)).toLocaleString(a,{month:"long"}),e,d)}return b}function addOrUpdateExpenseTrip(d,b,h,g,c,a){var f="addOrUpdateExpenseTrip",e=new ClientDialogBuilder({formId:f,formTitle:d?"Edit Trip":"Add Trip",focusFieldName:"year",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:d?"Save":"Add",mnemonicChar:d?"s":"a",mnemonicActionJS:"submitaddOrUpdateExpenseTrip()"}),fnSubmit:submitaddOrUpdateExpenseTrip,arrExtraHeaderButtons:d?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseTrip("+d+", unescape('"+escape(c)+"'))"})]:null});e.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});e.addFlexibleFieldRow({additionalValueCellClasses:"clsNarrowField",rawLabel:"Year",valueHTML:''});e.addFlexibleFieldRow({rawLabel:"Month",valueHTML:'"});e.addTextFieldRow("txtLocation",{rawLabel:"Name & Location",maxLength:80,fieldValue:g,additionalFieldCellClasses:"tripNameAndLocation"});e.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:a,hideRow:d?false:true});e.showClientDialog()}function submitAddOrUpdateExpenseType(){var e=getObj("addOrUpdateExpenseType"),c=e.txtName.value,d=e.txtAccountingId.value,a=e.typeId.value,b=e.chkIsDisabled.checked;if(""===c){showInfoDialog("Name is required","Missing Field",1,"name");return}if(""===d){showInfoDialog("Quickbooks Id is required","Missing Field",1,"txtAccountingId");return}jsrsExecuteWithErrorP("Admin2_AddOrUpdateExpenseType2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,a?"Updating Expense Type":"Adding Expense Type",{expenseTypeId:a,expenseTypeName:c,quickbooksId:d,isDisabled:b?1:0})}function addOrUpdateExpenseType(b,c,d,a){var f="addOrUpdateExpenseType",e=new ClientDialogBuilder({formId:f,formTitle:b?"Edit Expense Type":"Add Expense Type",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:b?"Save":"Add",mnemonicChar:b?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseType()"}),fnSubmit:submitAddOrUpdateExpenseType,arrExtraHeaderButtons:b?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseType("+b+", unescape('"+escape(c)+"'))"})]:null});e.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});e.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:c});e.addTextFieldRow("txtAccountingId",{rawLabel:"Quickbooks Id",maxLength:80,fieldValue:d});e.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:a,hideRow:b?false:true});e.showClientDialog()}function submitAddOrUpdateExpenseVendor(k,f,c){var b=getObj("frmExpenseVendor"),m=b.expenseVendorId.value,r=b.txtName.value,n=b.quickbooksCustomerId.value,j=b.txtQuickbooksCustomer.value,p=b.txtReason.value,a=b.cboAmexDescriptionMatchType[b.cboAmexDescriptionMatchType.selectedIndex].value,e=b.cboAmexAppearsOnStatementAsMatchType[b.cboAmexAppearsOnStatementAsMatchType.selectedIndex].value,l=b.txtAmexAppearsOnStatementAs.value,o=b.txtAmexDescription.value,d=b.cboType[b.cboType.selectedIndex].value,i=b.chkIsDisabled.checked,g=b.chkIsGeneric.checked,h=b.chkIncludeOnMemo.checked,q=m?"Updating Expense Vendor...":"Adding Expense Vendor...";if(!n&&c){n=c}if(!n){if(""===j){showInfoDialog("Quickbooks Vendor is required","Missing Field",1,"year");return}if(f){displaySimpleConfirmationDialog(function(){jsrsExecute(function(s){if(checkResponseForError(s)){var t=JSON.parse(s);submitAddOrUpdateExpenseVendor(k,true,t.quickbooksCustomerId);return}},"Admin_AddOrUpdateExpenseQuickbooksCustomer",[null,j,0],rsErrorCallbackShowErrorDialog,{},0,1)},'The Quickbooks Vendor "'+htmlEncode(j)+'" does not exist. Do you want to create a new Quickbooks Vendor with this name?',"Create Quickbooks Vendor",{},1,null,"Create Quickbooks Vendor");return}else{jsrsExecute(function(s){if(checkResponseForError(s)){var t=JSON.parse(s);n=t.quickbooksCustomerId}submitAddOrUpdateExpenseVendor(k,true,n)},"Admin_GetQuickbooksVendorByName",[escape(j)],function(){});return}}if(""===r){showInfoDialog("Name is required","Missing Field",1,"year");return}if(""!==l&&""===e){showInfoDialog("You must specify a match type for Amex Appears on statement as","Missing Field",1,"year");return}if(""!==o&&""===a){showInfoDialog("You must specify a match type for Amex Description","Missing Field",1,"year");return}if(e!==""&&l===""){e=""}if(a!==""&&o===""){a=""}jsrsExecute(function(w,u,t){var x=getObj("frmApproveExpense");if(isDialogShowing()&&x){var z=JSON.parse(w),y=z.expenseVendorId,s=z.expenseVendorName;var v=document.createElement("option");v.value=y;v.innerHTML=s;v.selected=true;x.cboVendor.appendChild(v);hideTimedMessage();hideSubdialog();enableDialogButtons()}else{rsCallbackRefreshPageAndScrollPos(w)}},"Admin_AddOrUpdateExpenseVendor",[m,r,n,a,escape(o),e,escape(l),d,p,h?1:0,i?1:0,g?1:0],enableDialogButtons);displayTimedMessage(q+"...");disableDialogButtons()}function submitAddOrUpdateQuickbooksCustomer(){var d=getObj("addOrUpdateQuickbooksCustomer"),e=d.expenseQuickbooksCustomerId.value,b=d.txtName.value,a=d.chkIsDisabled.checked,c=e?"Updating Quickbooks Vendor...":"Adding Quickbooks Vendor...";if(""===b){showInfoDialog("Name is required","Missing Field",1,"year");return}jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseQuickbooksCustomer",[e,b,a?1:0],rsErrorCallbackShowErrorDialog,{},0,1);displayTimedMessage(c+"...");disableDialogButtons()}function addOrUpdateQuickbooksCustomer(b,c,a){var e="addOrUpdateQuickbooksCustomer",d=new ClientDialogBuilder({formId:e,formTitle:b?"Edit Quickbooks Vendor":"Add Quickbooks Vendor",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:b?"Save":"Add",mnemonicChar:b?"s":"a",mnemonicActionJS:"submitAddOrUpdateQuickbooksCustomer()"}),fnSubmit:submitAddOrUpdateQuickbooksCustomer,arrExtraHeaderButtons:b?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteQuickbooksCustomer("+b+", unescape('"+escape(c)+"'))"})]:null});d.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});d.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:c});d.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:a,hideRow:b?false:true});d.showClientDialog()}function editExpenseReport(b){var f="exitExpenseReport",e=new ClientDialogBuilder({formId:f,formTitle:"Edit Expense Report",focusFieldName:"null",arrExtraHeaderButtons:b.expenseReportId?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseReport("+b.expenseReportId+")"})]:null,fnSubmit:function(g){var h=g.cboPayableTo[g.cboPayableTo.selectedIndex].value;jsrsExecuteWithErrorP("Admin2_UpdateExpenseReport",function(i){hideDialog();refreshPageAndScrollPos()},"Updating Expense Report...",{expenseReportId:b.expenseReportId,payableToVendor:parseInt(h,10),vendorId:null})}}),d=b.vendorName||"Vendor",a=b.payableToVendor?1:0,c=buildOptionHTML(htmlEncode(b.userName),0,a)+buildOptionHTML(htmlEncode(d),1,a);e.addFlexibleFieldRow({rawLabel:"Payable To",valueHTML:'",additionalCellClasses:"clsVeryNarrowField"});e.showClientDialog()}function showAddOrUpdateExpenseVendor(q){var l=q.expenseVendorId,b=q.arrExpenseTypes,c=q.expenseVendorName,p=q.quickbooksCustomerName,r=q.quickbooksCustomerId,k=q.amexDescriptionMatchType,g=q.amexDescription,m=q.amexAppearsOnStatementAsMatchType,i=q.amexAppearsOnStatementAs,n=q.expenseType,e=q.reason,j=q.includeOnMemo,o=q.isDisabled,a=q.isGeneric,h="frmExpenseVendor",d=new ClientDialogBuilder({formId:h,formTitle:l?"Edit Expense Vendor":"Add Expense Vendor",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:l?"Save":"Add",mnemonicChar:l?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseVendor()"}),fnSubmit:submitAddOrUpdateExpenseVendor,arrExtraHeaderButtons:l?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseVendor("+l+", unescape('"+escape(c)+"'))"})]:null});d.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});var f={formId:h,idFieldName:"quickbooksCustomerId",handlingEnter:1,initialValue:r,stringifiedParams:'{ textFieldName: "txtQuickbooksCustomer", formId: "'+h+'", idFieldName: "quickbooksCustomerId", fnGetTypeAheadData: quickBooksCustomerGetTypeAheadData, fnHandleExplicitSelection: function(){}}'};d.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:c});d.addDialogInteriorRows(cdBuildTextFieldRowP("txtQuickbooksCustomer","Quickbooks Vendor",{fieldValue:p,typeaheadInfo:f,autofocus:1,suppressAutocomplete:1}));d.addCheckboxRow("chkIncludeOnMemo",{labelHTML:"Include Amex Vendor On Memo",checked:j});d.addCheckboxRow("chkIsGeneric",{labelHTML:"Generic",checked:a});d.addCheckboxRow("chkIsDisabled",{hideRow:l?false:true,labelHTML:"Disabled",checked:o});d.addSectionHeaderRow();JTCRMExpense.addExpenseTypeDropdown({cdBuilder:d,rawLabelOverride:"Default Type",mnemonicForLabelOverride:"t",arrExpenseTypes:b});d.addTextFieldRow("txtReason",{rawLabel:"Default Reason",maxLength:80,fieldValue:e});d.addFlexibleFieldRow({labelHTML:"Amex Description",valueHTML:' '});d.addFlexibleFieldRow({labelHTML:"Amex Appears On Statement As",valueHTML:' '});d.showClientDialog()}function showEditExpenseVendorDialog(a){jsrsExecuteWithErrorP("Admin2_GetExpenseVendorInfo",rsCallbackHandleStandardJSONResponse,"Retrieving Vendor Info",{expenseVendorId:a,includeExpenseTypes:1},{fnOnSuccess:showAddOrUpdateExpenseVendor})}function getUseTaxYearBoundaries(){return{useTaxYearMinimum:2018,useTaxYearMaximum:(new Date()).getYear()+1900}}function submitCreateExpenseReport(){jsrsExecuteWithErrorP("Admin_CreateExpenseReport",function(a){var b=a.id;window.location=pageExpenseReportDetail+b},"Creating Expense Report...",{})}function doDeleteExpenseReportImage(a){jsrsExecuteWithErrorP("Admin2_DeleteExpenseReportDetailImage",function(){getObj("receiptFileId").value="";getObj("receiptRemoved").value=1;getObj("removeReceiptRow").style.display="none";getObj("addReceiptRow").style.display=""},"Deleting Expense Report Detail image...",{fileId:a.fileId,expenseReportDetailId:a.expenseReportDetailId})}function confirmDeleteExpenseReportDetailReceiptImage(a){var c=a.fileId,d=a.fileName,b=a.expenseReportDetailId;displaySimpleConfirmationDialog(doDeleteExpenseReportImage,'Are you sure you want to remove the receipt "'+d+'" from this Expense Report Detail?',"Delete Expense Report Detail Image",{fileId:c,expenseReportDetailId:b},1)}function submitReordeExpenseTypesDialog(a){submitReorderP({arrReorderedIds:a,reorderCommandName:"Admin2_ReorderExpenseTypes2",reorderIdsPropertyName:"expenseTypeIds",reorderObjectName:"Expense Types"})}function showReorderExpenseTypesDialog(a,b){rsCallbackGetObjectsForReorder({types:b},{originalOptions:{arrayAttrName:"types",fnSubmit:submitReordeExpenseTypesDialog,strReorderWhat:"Expense Types",highlightedId:a}})}function submitExpenseOptions(){var g="frmOptions",h=getObj(g),f=pageExpenses,c=h.cboExpenseViewOptions[h.cboExpenseViewOptions.selectedIndex].value,a="sort",e=h.cboAmexDescriptionMatchType[h.cboAmexDescriptionMatchType.selectedIndex].value,b=h.txtAmexDescription.value,d=getUrlParamValueIfThere(""+window.location,a);if(d){f+="&"+a+"="+d}f+="&expenseViewType="+c;if(c===(""+ExpensesSummaryViews_Enum.esvAll)){f+="&daysBack="+h.txtDaysBack.value}if(b&&b.length>0&&e>=0){f+="&amexVendor="+escape(b);f+="&amexVendorFilterType="+e}hideDialog();window.location=f;displayTimedMessage("Reloading page...")}function onExpenseViewTypeChanged(){var b=getObj("frmOptions");if(b){var a=b.cboExpenseViewOptions[b.cboExpenseViewOptions.selectedIndex].value;if(a===(""+ExpensesSummaryViews_Enum.esvAll)){b.txtDaysBack.parentNode.parentNode.style.display=""}else{b.txtDaysBack.parentNode.parentNode.style.display="none"}}}function submitUseTaxOptions(){var i="frmOptions",d=getObj(i),a=new FormValidator(),e,f=parseInt(d.cboUseTaxTimePeriod.value,10),j=d.cboUseTaxMonth.value,c=d.cboUseTaxQuarter.value,h=d.txtUseTaxYear.value,g=getUseTaxYearBoundaries(),b=a.CSValidateNumberFieldP({field:d.txtUseTaxYear,label:"Year",isNullable:false,minValue:g.useTaxYearMinimum,maxValue:g.useTaxYearMaximum});if(!b){return}e=pageExpenseSettingsUseTax+"timePeriod="+f+"&year="+h;switch(f){case TimePeriodTypeFilter_Enum.tptfMonth:e+="&month="+j;break;case TimePeriodTypeFilter_Enum.tptfQuarter:e+="&quarter="+c;break}hideDialog();window.location=e;displayTimedMessage("Reloading page...")}function changeUseTaxTimePeriod(){var d="frmOptions",e=getObj(d),b=parseInt(e.cboUseTaxTimePeriod.value,10),c=b===TimePeriodTypeFilter_Enum.tptfMonth,a=b===TimePeriodTypeFilter_Enum.tptfQuarter;getObj("useTaxMonth").style.display=c?"":"none";getObj("useTaxQuarter").style.display=a?"":"none"}function showUseTaxOptionsDialog(c){var a=c.timePeriodType,b=c.year,f="frmOptions",e=new ClientDialogBuilder({formId:f,formTitle:"Use Tax - Options",focusFieldName:"cboUseTaxTimePeriod",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitUseTaxOptions()"}),fnSubmit:submitUseTaxOptions,arrExtraHeaderButtons:null}),d=getUseTaxYearBoundaries();e.addDropdown({fieldName:"cboUseTaxTimePeriod",rawLabel:"Time Period",mnemonicChar:"t",additionalCellClasses:"clsNarrowField",arrAvailableOptions:[{rawContent:"Month",cboValue:TimePeriodTypeFilter_Enum.tptfMonth},{rawContent:"Quarter",cboValue:TimePeriodTypeFilter_Enum.tptfQuarter},{rawContent:"Year",cboValue:TimePeriodTypeFilter_Enum.tptfYear}].map(function(g){g.isSelectedOption=g.cboValue===a;return g}),onClickChangeJS:"changeUseTaxTimePeriod()"});e.addTextFieldRow("txtUseTaxYear",{rawLabel:"Year",mnemonicChar:"y",fieldValue:""+b,isNumber:1,step:1,minValue:d.useTaxYearMinimum,maxValue:d.useTaxYearMaximum});e.addDropdown({fieldName:"cboUseTaxMonth",rawLabel:"Month",mnemonicChar:"m",arrAvailableOptions:[{rawContent:"January",cboValue:1},{rawContent:"February",cboValue:2},{rawContent:"March",cboValue:3},{rawContent:"April",cboValue:4},{rawContent:"May",cboValue:5},{rawContent:"June",cboValue:6},{rawContent:"July",cboValue:7},{rawContent:"August",cboValue:8},{rawContent:"September",cboValue:9},{rawContent:"October",cboValue:10},{rawContent:"November",cboValue:11},{rawContent:"December",cboValue:12}].map(function(g){g.isSelectedOption=g.cboValue===c.month;return g}),hideRow:1,rowId:"useTaxMonth"});e.addDropdown({fieldName:"cboUseTaxQuarter",rawLabel:"Quarter",mnemonicChar:"q",arrAvailableOptions:[{rawContent:"Q1",cboValue:TimePeriodQuarters_Enum.tpqFirst},{rawContent:"Q2",cboValue:TimePeriodQuarters_Enum.tpqSecond},{rawContent:"Q3",cboValue:TimePeriodQuarters_Enum.tpqThird},{rawContent:"Q4",cboValue:TimePeriodQuarters_Enum.tpqFourth}].map(function(g){g.isSelectedOption=g.cboValue===c.quarter;return g}),hideRow:1,rowId:"useTaxQuarter"});if(e.showClientDialog()){changeUseTaxTimePeriod()}}function showExpensesOptionsDialog(d,b,a){var h="frmOptions",c=getUrlParamValueIfThere(window.location,"expenseViewType"),g=parseInt(c,10);if(isNaN(g)||g<0||g>3){g=ExpensesSummaryViews_Enum.esvRequiresInput}var f=new ClientDialogBuilder({formId:h,formTitle:"Expenses View Options",focusFieldName:"cboExpenseViewOptions",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"A",mnemonicActionJS:"submitExpenseOptions()"}),fnSubmit:submitExpenseOptions,arrExtraHeaderButtons:null});var e=buildOptionHTML("Require User Input",ExpensesSummaryViews_Enum.esvRequiresInput,g);e+=buildOptionHTML("All Expenses",ExpensesSummaryViews_Enum.esvAll,g);f.addFlexibleFieldRow({rawLabel:"Filter Expenses",valueHTML:'"});f.addTextFieldRow("txtDaysBack",{rawLabel:"Days Back",fieldValue:d,isNumber:1,hideRow:g!==ExpensesSummaryViews_Enum.esvAll});f.addFlexibleFieldRow({labelHTML:"Amex Vendor",valueHTML:''});f.showClientDialog()}function toggleExpandExpenseInfoExtras(){var b=getObj("imgExpenseInfoExtrasExpander.expand"),c=getObj("imgExpenseInfoExtrasExpander.collapse"),a=document.querySelectorAll(".expense-details");if(c.style.display==="none"){b.style.display="none";c.style.display="inline";a.forEach(function(g,d,f){g.style.display="table-cell"})}else{b.style.display="inline";c.style.display="none";a.forEach(function(g,d,f){g.style.display="none"})}}function doSubmitExpenseForApproval(b){var a="Submitting for approval...";jsrsExecute(function(){hideDialog();window.location=pageExpenses},"Admin_SubmitExpenseOrExpenseReportForApproval",[b.expenseId,b.expenseType],rsErrorCallbackShowErrorDialogAndRefresh,null,null,true);displayTimedMessage(a+"...");disableDialogButtons()}function expenseTypeNameFromId(a){return a===EventObjectType_Enum.eotExpense?"Expense":"Expense Report"}function confirmSubmitExpenseForApproval(a,b){displaySimpleConfirmationDialog(doSubmitExpenseForApproval,"Are you sure you want to submit this "+expenseTypeNameFromId(b)+" for approval?
Once submitted for approval you will not be able to make further changes.","Submit "+expenseTypeNameFromId(b)+" For Approval",{expenseId:a,expenseType:b})}function submitUpdateExpenseOrExpenseReport(c,b,a,f,e,d){jsrsExecuteWithErrorP("Admin2_UpdateApprovalState",d,"Updating Approval Status",{id:c,type:b,status:a,reason:f,vendor:e})}function submitRejectExpense(){var b=getObj("rejectExpense"),d=b.id.value,a=b.type.value,c=b.txtRejectionReason.value;if(""===c){showInfoDialog("A reason must be supplied when rejecting an expense","Missing Field",1,"txtRejectionReason");return}submitUpdateExpenseOrExpenseReport(d,a,Expense_Approval_Status_Enum.easRejected,c,null,function(){hideDialog();window.location=pageExpenseApprovals})}function submitApproveExpenseReport(b,a){submitUpdateExpenseOrExpenseReport(b,a,Expense_Approval_Status_Enum.easApproved,null,null,function(){hideDialog();window.location=pageExpenseApprovals})}function submitApproveExpense(){var b=getObj("frmApproveExpense"),d=b.id.value,a=b.type.value,c=b.cboVendor?b.cboVendor[b.cboVendor.selectedIndex].value:null;if(""===c&&b.cboVendor){showInfoDialog("A vendor must be supplied when approving an expense","Missing Field",1,"txtRejectionReason");return}submitUpdateExpenseOrExpenseReport(d,a,Expense_Approval_Status_Enum.easApproved,"",c,function(){hideDialog();window.location=pageExpenseApprovals})}function submitUnapproveExpense(a){submitUpdateExpenseOrExpenseReport(a.id,a.type,Expense_Approval_Status_Enum.easWaitingForApproval,"",null,function(){hideDialog();window.location=pageExpenseApprovals})}function unapproveExpense(b,a){displaySimpleConfirmationDialogP(submitUnapproveExpense,"Are you certain you want to unapprove this expense? If unapproved it will no longer be eligible to be exported until it is re-approved",{formTitle:"Unapprove Expense",okButtonDisplayText:"Unapprove",contextDetail:{id:b,type:a}})}function rejectExpense(b,a){var d="rejectExpense",c=new ClientDialogBuilder({formId:d,formTitle:"Reject Expense",focusFieldName:"txtRejectionReason",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitRejectExpense()"}),fnSubmit:submitRejectExpense,arrExtraHeaderButtons:null});c.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});c.addTextFieldRow("txtRejectionReason",{rawLabel:"Rejection Reason",maxLength:256,fieldValue:""});c.showClientDialog()}function promptApproveExpenseReport(a,b){displaySimpleConfirmationDialogP(function(){hideDialog();submitApproveExpenseReport(a,b)},"Are you sure you want to approve the Expense Report?",{formTitle:"Approve Expense Report",okButtonDisplayText:"Approve"})}function approveExpense(c){if(c.expenseType===EventObjectType_Enum.eotExpenseReport&&!c.payableToVendor){promptApproveExpenseReport(c.id,c.expenseType);return}var e="frmApproveExpense",f={arrExpenseTypes:JSON.parse(c.types),expenseVendorName:c.description,amexDescriptionMatchType:0,amexDescription:c.description,amexAppearsOnStatementAsMatchType:0,amexAppearsOnStatementAs:c.appearsOnStatementAs,expenseType:c.defaultVendorTypeId,reason:c.defaultReason},d=new ClientDialogBuilder({formId:e,formTitle:"Approve Expense",focusFieldName:"cboVendor",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitApproveExpense()"}),fnSubmit:submitApproveExpense,arrExtraHeaderButtons:[cdBuildFAFontIconButton({additionalButtonClasses:"textDialogButton",htmlContent:"Add Vendor",fontId:FontIconId_Enum.fiiPlusInCircle,doubleQuoteEncodedTitle:"Add Vendor",doubleQuoteEncodedOnClickJS:"showAddOrUpdateExpenseVendor("+htmlEncode(JSON.stringify(f))+")"})]});d.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});var a=buildOptionHTML("","",false);for(var b=0;b'+a+""});d.showClientDialog()}function rsCallbackResolveApprovalError(c,a,b){if(checkResponseForError(c)){hideDialog();window.location=pageExpenses}}function submitResolveApprovalError(a){var b="Resolving Expense Issue...";jsrsExecute(rsCallbackResolveApprovalError,"Admin_ResolveExpenseError",[a.id,a.type],rsErrorCallbackShowErrorDialogAndRefresh,null,null,true);displayTimedMessage(b+"...");disableDialogButtons()}function resolveApprovalError(b,a){displaySimpleConfirmationDialog(submitResolveApprovalError,"Do you want to resolve the issue with this "+expenseTypeNameFromId(a)+"?
Resolving will re-submit the "+expenseTypeNameFromId(a)+" for approval.","Resolve Expense Error",{id:b,type:a})}function submitAddOrUpdateExpenseImportBlocklist(){var f=getObj("addOrUpdateExpenseImportBlocklist"),h=f.expenseImportBlocklistId.value,c=f.txtName.value,b=f.cboAmexDescriptionMatchType[f.cboAmexDescriptionMatchType.selectedIndex].value,a=f.cboAmexAppearsOnStatementAsMatchType[f.cboAmexAppearsOnStatementAsMatchType.selectedIndex].value,g=f.txtAmexAppearsOnStatementAs.value,e=f.txtAmexDescription.value,d=h?"Updating Expense Import Blocklist...":"Adding To Expense Import Blocklist...";if(""===c){showInfoDialog("Name is required","Missing Field",1,"year");return}if(""!==g&&""===a){showInfoDialog("You must specify a match type for Amex Appears on statement as","Missing Field",1,"year");return}if(""!==a&&g===""){showInfoDialog("You must specify a value for Appears On Statement As","Invalid Value",1,"year");return}if(""!==e&&""===b){showInfoDialog("You must specify a match type for Amex Description","Missing Field",1,"year");return}if(""!==b&&""===e){showInfoDialog("You must specify a match type for Amex Description","Missing Field",1,"year");return}jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseImportBlocklist",[h,c,b,escape(e),a,escape(g)],enableDialogButtons);displayTimedMessage(d+"...");disableDialogButtons()}function addOrUpdateExpenseImportBlocklist(d,f,b,e,a,c){var h="addOrUpdateExpenseImportBlocklist",g=new ClientDialogBuilder({formId:h,formTitle:d?"Edit Expense Import Blocklist":"Add To Expense Import Blocklist",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:d?"Save":"Add",mnemonicChar:d?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseImportBlocklist()"}),fnSubmit:submitAddOrUpdateExpenseImportBlocklist,arrExtraHeaderButtons:d?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseImportBlocklist("+d+", unescape('"+escape(f)+"'))"})]:null});g.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''});g.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:f});g.addFlexibleFieldRow({labelHTML:"Amex Description",valueHTML:''});g.addFlexibleFieldRow({labelHTML:"Amex Appears On Statement As",valueHTML:''});g.showClientDialog()}function setDatabaseCompanyAddressAsNeedsConfirmation(a){jsrsExecuteWithErrorP("Admin2_SetDatabaseCompanyAddressAsNeedsConfirmation",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating company address to require confirmation",{databaseId:a})}function confirmSetDatabaseCompanyAddressAsNeedsConfirmation(a){displaySimpleConfirmationDialog(setDatabaseCompanyAddressAsNeedsConfirmation,"Are you sure you want to prompt the user to review their company address?","Prompt User to Review Company Address",a,null,null,"Yes")}function setDatabaseContactAsNeedsConfirmation(a){jsrsExecuteWithErrorP("Admin2_SetDatabaseContactAsNeedsConfirmation",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating contact to require confirmation",{databaseContactId:a})}function confirmSetDatabaseContactAsNeedsConfirmation(a){displaySimpleConfirmationDialog(setDatabaseContactAsNeedsConfirmation,"Are you sure you want to prompt the user to review this contact?","Prompt User to Review Contact",a,null,null,"Yes")}function rsCallbackSentDunningEmails(d){var c=d.arrFailures,a=d.arrHandledInvoices,f=a?a.length:0,g=c?c.length:0,e=new ClientDialogBuilder({formTitle:"Sent Dunning Emails",fnCancelOrClose:function(){hideDialog();saveScrollPos();refreshPageShowingMessage()}}),b;if(f){e.addSectionHeaderRow({rawTitle:f===1?"Processed 1 Invoice":("Processed "+f+" Invoice")});b=new MWClientTable({additionalTableClasses:"unsetTableWidth100"});b.addColumn(new MWColumn({columnName:"Subdomain",simpleDisplayColumnPropertyName:"subDomainName"}));b.addColumn(new MWColumn({columnName:"Invoice #",simpleDisplayColumnPropertyName:"invoiceNumber"}));b.addColumn(new MWColumn({columnName:"Email Address",simpleDisplayColumnPropertyName:"targetEmailAddress"}));b.addColumn(new MWColumn({columnName:"DB Id",simpleDisplayColumnPropertyName:"databaseId"}));e.addFlexibleRow({valueHTML:b.buildTableForArray(a)})}if(g){e.addSectionHeaderRow({rawTitle:g===1?"1 Failure":(g+" Failures")});b=new MWClientTable({additionalTableClasses:"unsetTableWidth100"});b.addColumn(new MWColumn({columnName:"Error",simpleDisplayColumnPropertyName:"errorMessage",simpleDisplayColumnNeedsMultilineEncoding:1,additionalCellClasses:"errorText"}));b.addColumn(new MWColumn({columnName:"Subdomain",simpleDisplayColumnPropertyName:"subDomainName"}));b.addColumn(new MWColumn({columnName:"Invoice #",simpleDisplayColumnPropertyName:"invoiceNumber",additionalCellClasses:"rightAlign"}));b.addColumn(new MWColumn({columnName:"Email Address",simpleDisplayColumnPropertyName:"targetEmailAddress"}));b.addColumn(new MWColumn({columnName:"DB Id",simpleDisplayColumnPropertyName:"databaseId",additionalCellClasses:"rightAlign"}));e.addFlexibleRow({valueHTML:b.buildTableForArray(c)})}e.addSectionHeaderRow({titleHTML:"Raw Results "+cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiRightChevron,terseFontIcon:1,doubleQuoteEncodedTitle:"Display Raw Results",doubleQuoteEncodedOnClickJS:"getObj('rowRawResults').style.display='';getObj('btnDisplayRawResults').style.display='none'",buttonId:"btnDisplayRawResults"})});e.addFlexibleRow({valueHTML:htmlEncode(JSON.stringify(d,null,2)),additionalCellClasses:"JSONViewer",rowId:"rowRawResults",hideRow:1});e.showClientDialog()}function sendDunningEmails(){hideDialog();jsrsExecuteWithErrorP("Admin2_SendDunningEmails",rsCallbackHandleStandardJSONResponse,"Sending Dunning Emails",{},{fnOnSuccess:rsCallbackSentDunningEmails})}function promptSendDunningEmails(a){var b=new ClientDialogBuilder({formTitle:"Send Dunning Emails",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Send Emails",mnemonicChar:"s",mnemonicActionJS:"sendDunningEmails()"}),fnSubmit:sendDunningEmails});b.addFlexibleRow({rawValue:"Are you sure you want to send the Dunning Emails?"});b.showClientDialog()}function submitSalesByStateOptions(){var f="frmOptions",h=getObj(f),e=pageSalesByState,c=parseInt(h.cboTimeSelection.value,10),d,g,b=h.txtPageSize,a=new FormValidator();if(!a.CSValidateDateFieldP({field:h.dtStartDate,label:"Start Date",isNullable:false})){return}if(!a.CSValidateDateFieldP({field:h.dtEndDate,label:"End Date",isNullable:false})){return}d=getDateForUrlParam(h.dtStartDate.value);g=getDateForUrlParam(h.dtEndDate.value);if(d&&g&&parseDateString(g)1?"AutopayStatusName":"AutopayStatusSelect",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitAutopayReportOptions()"}),fnSubmit:submitAutopayReportOptions});c.addCompoundSelectionFieldRowP({fieldNameBase:"AutopayStatus",whatSingular:"Autopay Status",whatPlural:"Autopay Statuses",arrSelectedIds:a,objectArrayName:"arrAutopayStatuses",autofocus:1,fnRSCallSubstitute:function(){return{arrAutopayStatuses:d}},arrObjects:d});c.addDropdown({fieldName:"cboActiveStatusFilter",rawLabel:"Product Status",mnemonicChar:"p",mnemonicFocusFieldName:"cboActiveStatusFilter",autofocus:1,arrAvailableOptions:[{cboValue:ActiveStatusFilter_Enum.asfAny,rawContent:"Any"},{cboValue:ActiveStatusFilter_Enum.asfActiveOnly,rawContent:"Active Products Only"},{cboValue:ActiveStatusFilter_Enum.asfInactiveOnly,rawContent:"No Active Products"}],objSelectedValue:{cboValue:b.activeStatusFilter||ActiveStatusFilter_Enum.asfActiveOnly}});c.addTextFieldRow("txtNextInvoiceDayOfMonth",{rawLabel:"Next Invoice Day of Month",fieldValue:b.nextInvoiceDayOfMonth?""+b.nextInvoiceDayOfMonth:"",mnemonicChar:"n",maxLength:2,styleWidth:"7em",isNumber:1});c.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+b.pageSize,mnemonicChar:"r",maxLength:10,styleWidth:"7em",isNumber:1});c.showClientDialog()}function submitCustomerPortalReportOptions(){var k="frmOptions",h=getObj(k),b=new FormValidator(),i=pagePortalUsageReport,g=h.txtPageSize,e=trim(g.value),j=h.txtMaxDaysOld,f=trim(j.value),a="PUsageListsort",d=getUrlParamValueIfThere(""+window.location,a),c=h.cboUserType.value;if(!b.CSValidateIntegerField(g,"Page Size",true,1,2000)){return}if(!b.CSValidateIntegerField(j,"Max Days Old",true,1,2000)){return}if(d){i+="&"+a+"="+d}if(e){i+="&pageSize="+e}if(f){i+="&maxDaysOld="+f}if(c!==""+FilteredVUserType_Enum.fvutJTOnly){i+="&userType="+c}hideDialog();window.location=i;displayTimedMessage("Reloading page...")}function showCustomerPortalReportOptionsDialog(a){var c="frmOptions",b=new ClientDialogBuilder({formId:c,formTitle:"Customer Portal Report Options",focusFieldName:"cboUserType",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitCustomerPortalReportOptions()"}),fnSubmit:submitCustomerPortalReportOptions});b.addDropdown({fieldName:"cboUserType",rawLabel:"User Type",autofocus:1,arrAvailableOptions:[{cboValue:FilteredVUserType_Enum.fvutAny,rawContent:"Any"},{cboValue:FilteredVUserType_Enum.fvutJTOnly,rawContent:"JobTracker Users Only"},{cboValue:FilteredVUserType_Enum.fvutBillingOnly,rawContent:"Billing Users Only"}],objSelectedValue:{cboValue:a.filteredVUserType||FilteredVUserType_Enum.fvutAny}});b.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+a.pageSize,maxLength:10,styleWidth:"7em",isNumber:1});b.addTextFieldRow("txtMaxDaysOld",{rawLabel:"Show Last",fieldValue:""+a.maxDaysOld,maxLength:10,styleWidth:"7em",isNumber:1,strPostFieldHTML:" Days"});b.showClientDialog()}function submitLegacyPricingReportOptions(){var e="frmOptions",f=getObj(e),d=pageLegacyPricingReport,a="legacyPricingReportTablesort",c=getUrlParamValueIfThere(""+window.location,a),b=f.cboNewPriceTarget.value;if(c){d+="&"+a+"="+c}if(b!==""+NewPriceTargetFilterOption_Enum.nptfoAll){d+="&newPriceTarget="+b}hideDialog();window.location=d;displayTimedMessage("Reloading page...")}function showLegacyPricingReportOptionsDialog(a){var c="frmOptions",b=new ClientDialogBuilder({formId:c,formTitle:"Report Options",focusFieldName:"cboNewPriceTarget",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitLegacyPricingReportOptions()"}),fnSubmit:submitLegacyPricingReportOptions});b.addDropdown({fieldName:"cboNewPriceTarget",rawLabel:"New Price Target",autofocus:1,arrAvailableOptions:[{cboValue:NewPriceTargetFilterOption_Enum.nptfoAll,rawContent:"CG/JT/Sys"},{cboValue:NewPriceTargetFilterOption_Enum.nptfoCGOnly,rawContent:"CG Only"},{cboValue:NewPriceTargetFilterOption_Enum.nptfoJTSysOnly,rawContent:"JT/Sys Only"}],objSelectedValue:{cboValue:a.newPriceTarget||NewPriceTargetFilterOption_Enum.nptfoAll}});b.showClientDialog()}function toggleDisplayImportDisbursementResults(){var c=getObj("icoExpand"),a=c.style.display==="none",b=!a;c.style.display=b?"none":"";getObj("icoCollapse").style.display=b?"":"none";getObj("rowImportDisbursementResultsJson").style.display=b?"":"none"}function rsCallbackImportDisbursements(f){hideDialog();var h="frmImportDisbursementResults",k=new ClientDialogBuilder({formId:h,formTitle:"Import Disbursements",fnCancelOrClose:function(){refreshPageAndScrollPos()}}),b=f.arrImportInfos,e=b?b.length:0,d,i,c,g,j,a;for(c=0;c
'+cdBuildFontIconElem({fontId:FontIconId_Enum.fiiRightChevron,terseFontIcon:1,fontIconElemId:"icoExpand"})+cdBuildFontIconElem({fontId:FontIconId_Enum.fiiDownChevron,terseFontIcon:1,fontIconElemId:"icoCollapse",hideIcon:1})+" Raw JSON
"});k.addFlexibleRow({valueHTML:htmlEncode(JSON.stringify(f,null,2)),additionalCellClasses:"JSONViewer",rowId:"rowImportDisbursementResultsJson",hideRow:1});k.showClientDialog()}function submitImportBTDisbursements(){var d="frmImport",e=getObj(d),c=e.dtDate,a=new FormValidator(),b;if(!a.CSValidateDateField(c,"Date",true,"dtDate")){return}b=getDateForUrlParam(c.value);jsrsExecuteWithErrorP("Admin2_ImportDisbursements",rsCallbackHandleStandardJSONResponse,"Importing Disbursements",{disbursementDate:b},{fnOnSuccess:rsCallbackImportDisbursements})}function promptImportDisbursements(){var b="frmImport",a=new ClientDialogBuilder({formId:b,formTitle:"Import Disbursements",focusFieldName:"dtDate",fnSubmit:submitImportBTDisbursements,okButtonDisplayText:"Import"});a.addDatePickerRow(b,"dtDate",{rawLabel:"Payment Transaction Date"});a.showClientDialog()}function submitUpdateDisbursementDate(){var c="frmEditDisbursementDate",d=getObj(c),b=d.dtDate,a=new FormValidator();if(!a.CSValidateDateField(b,"Deposit Date",false,"dtDate")){return}jsrsExecuteWithErrorP("Admin2_UpdateBTDisbursementDate",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Disbursement Date",{disbursementDate:mjtElemData(d,"disbursementDate"),depositDate:getDateForUrlParam(b.value)})}function showEditDisbursementDateDialog(c){var d="frmEditDisbursementDate",e,b=c.disbursementDate,a=new ClientDialogBuilder({formId:d,formTitle:"Update Disbursement Date",focusFieldName:"dtDate",fnSubmit:submitUpdateDisbursementDate});a.addFlexibleFieldRow({rawLabel:"Disbursement Date",rawValue:b});a.addDatePickerRow(d,"dtDate",{rawLabel:"Deposit Date",strValue:c.depositDate||""});e=a.showClientDialog();if(e){mjtElemData(e,"disbursementDate",b)}}function submitUpdateDBTaxRate(){var c="frmLookupTaxRate",d=getObj(c),b=mjtElemData(d,"databaseId"),a=mjtElemData(d,"matchingTaxCodeId");jsrsExecuteWithErrorP("Admin2_UpdateDBTaxInfo",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Tax Info",{databaseId:b,taxRateId:a})}function buildRawAddressFromAddrObject(f){var h=f.street||"",d=trim(f.city||""),g=trim(f.state||""),c=trim(f.zip||""),b=trim(f.country||""),a=d&&g?d+", "+g:(d+g),e=trim(a+" "+c);return h+"\n"+(e&&b?e+"\n"+b:e+b)}function rsCallbackGetDBTaxInfo(i){hideDialog();var e="frmLookupTaxRate",q,o=i.currentAddress||{},l=i.newDBTaxOptions,p=i.arrAPIMultiMatchMinInfos,c=p?p.length:0,n=i.currentTaxOptions,h=n?n.taxRateId||0:0,j=l.singleMatchedTaxCode,r=j?j.nameMatchingTaxCodeId:0,k=r&&(r!==h),f=l.taxWarningMessage,d=new ClientDialogBuilder({formId:e,formTitle:"Lookup Tax Rate",focusFieldName:"txtStreet",arrExtraHeaderButtons:[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiEdit,doubleQuoteEncodedOnClickJS:"promptToUpdateTaxLookupAddress()",doubleQuoteEncodedTitle:"Change Lookup Address"})],okButtonDisplayText:k?cdBuildMnemonicLabelHTML({rawLabel:"Update Tax Rate",mnemonicChar:"u",mnemonicActionJS:"submitUpdateDBTaxRate()"}):null,fnSubmit:k?submitUpdateDBTaxRate:null});d.addFlexibleFieldRow({rawLabel:"Lookup Address",valueHTML:htmlMultilineEncode(buildRawAddressFromAddrObject(o)),valueCellId:"cellLookupAddress",additionalCellClasses:"topAlign"});d.addSectionHeaderRow({rawTitle:"Tax Info"});if(n){var a='-None-';if(n.taxRateId){a=htmlEncode(n.taxRateName)+" ("+n.taxRatePercent+"%)"}d.addFlexibleFieldRow({rawLabel:"Current Tax Rate",valueHTML:a})}if(f){d.addFlexibleFieldRow({rawLabel:"",valueHTML:htmlMultilineEncode(f),additionalValueCellClasses:"errorText"})}if(c){d.addFlexibleFieldRow({rawLabel:"Multiple Matches",valueHTML:htmlEncode(JSON.stringify(p,null,2)),additionalValueCellClasses:"JSONViewer errorText",additionalCellClasses:"topAlign"})}if(r){var b=k?cdBuildFontIconElem({fontId:FontIconId_Enum.fiiExclamationInFilledTriangle,terseFontIcon:1,additionalFontIconClasses:"warningIcon"}):cdBuildFontIconElem({fontId:FontIconId_Enum.fiiCheck,terseFontIcon:1,additionalFontIconClasses:"goodNewsIcon"}),g=k?'The tax rate will be updated':"There is no need to update the Tax Rate",m=htmlEncode(j.taxCodeName)+" ("+j.taxRatePercent+"%)";if(k){m=''+m+""}d.addFlexibleFieldRow({rawLabel:"New Tax Rate",valueHTML:b+" "+m+' ('+g+")",additionalCellClasses:"topAlign"})}q=d.showClientDialog();if(q){mjtElemData(q,"databaseId",i.databaseId);mjtElemData(q,"matchingTaxCodeId",r);mjtElemData(q,"lookupAddress",o)}}function promptLookupTaxRate(a){jsrsExecuteWithErrorP("Admin2_GetDBTaxInfo",rsCallbackHandleStandardJSONResponse,"Looking up Tax Info",{databaseId:a.databaseId},{fnOnSuccess:rsCallbackGetDBTaxInfo})}function submitUpdateTaxLookupAddress(){var d="frmAddress",e=getObj(d),a="frmLookupTaxRate",c=getObj(a),b=mjtElemData(c,"databaseId");jsrsExecuteWithErrorP("Admin2_GetDBTaxInfo",rsCallbackHandleStandardJSONResponse,"Looking up Tax Info",{databaseId:b,overrideAddress:1,street:trim(e.txtStreet.value),city:trim(e.txtCity.value),zip:trim(e.txtZip.value),state:trim(e.txtState.value),country:trim(e.txtCountry.value)},{fnOnSuccess:rsCallbackGetDBTaxInfo})}function promptToUpdateTaxLookupAddress(){var e="frmAddress",a="frmLookupTaxRate",d=getObj(a),c=mjtElemData(d,"lookupAddress"),b=new ClientDialogBuilder({formId:e,formTitle:"Update Lookup Address",focusFieldName:"txtStreet",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Lookup Address",mnemonicChar:"l",mnemonicActionJS:"submitUpdateTaxLookupAddress()"}),fnSubmit:submitUpdateTaxLookupAddress});b.addTextFieldRow("txtStreet",{rawLabel:"Street",fieldValue:c.street||""});b.addTextFieldRow("txtCity",{rawLabel:"City",fieldValue:c.city||""});b.addTextFieldRow("txtState",{rawLabel:"State",fieldValue:c.state||""});b.addTextFieldRow("txtZip",{rawLabel:"Zip",fieldValue:c.zip||""});b.addTextFieldRow("txtCountry",{rawLabel:"Country",fieldValue:c.country||""});b.showClientDialog()}function submitStopRetryingPayments(){var b="frmCeaseRetry",c=getObj(b),a=mjtElemData(c,"databaseId");hideDialog();jsrsExecuteWithErrorP("Admin2_SetAutomatedPaymentStatusPermanentFailure",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Marking Permanent Failure",{databaseId:a})}function showUpdateCustomerPaymentDate(a){var c="frmCeaseRetry",d,b=new ClientDialogBuilder({formId:c,formTitle:"Temporarily Stop Retrying",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Stop Retrying",mnemonicChar:"s",mnemonicActionJS:"submitStopRetryingPayments()"}),fnSubmit:submitStopRetryingPayments});b.addFlexibleRow({valueHTML:"Are you sure you want to stop retrying payments until the next pay period?"});d=b.showClientDialog();if(d){mjtElemData(d,"databaseId",a)}}function submitReconcileBTProfile(){var a="frmReconcile",c=getObj(a),b=mjtElemData(c,"billingProcessorCustomerId");hideDialog();jsrsExecuteWithErrorP("Admin2_ReconcileBTBillingProfile",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Reconciling Braintree Profile",{billingProcessorCustomerId:b})}function reconcileBTProfile(a){var c="frmReconcile",d,b=new ClientDialogBuilder({formId:c,formTitle:"Reconcile Braintree Profile",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Reconcile",mnemonicChar:"r",mnemonicActionJS:"submitReconcileBTProfile()"}),fnSubmit:submitReconcileBTProfile});b.addFlexibleRow({rawValue:'Are you sure you want to reconcile billing id "'+a.billingProcessorCustomerId+'"?'});d=b.showClientDialog();if(d){mjtElemData(d,"billingProcessorCustomerId",a.billingProcessorCustomerId)}}function submitUpdateDatabasePricingStructureDialog(){var f="frmUpdateDatabasePricingStructure",h=getObj(f),c=new FormValidator(),a=getDateForUrlParam(h.dtEffectiveDate.value),b,e=new Date(),g=mjtElemData(h,"databasePricingStructureId"),d;if(!c.CSValidateDateFieldP({field:h.dtEffectiveDate,label:"Effective Date"})){return}e=new Date(e.getFullYear(),e.getMonth(),e.getDate());b=parseDateString(a);if(b'+htmlEncode(a.pricingStructureName)+" "+htmlEncode(a.productTypeName)+" Effective "+cdCarefullyLocalizeDateValue(a.effectiveDate)+"","Remove Database Pricing Structure",{databasePricingStructureId:a.databasePricingStructureId})}function doShowUpdateDatabasePricingStructureDialog(i,b){var f="frmUpdateDatabasePricingStructure",q,g=i.pricingStructure,d=i.nextInvoiceInfo,n=g.databasePricingStructureId,r=g.effectiveDate,p=g.productTypeName,c=g.pricingStructureName,l=b.originalPayload.subdomain,m=cdCarefullyLocalizeDateValue(d.nextInvoiceDate),j="dtEffectiveDate",h={nextInvoiceDate:m,formId:f,dateFieldId:j},a=getNextInvoiceDateLink(h),k={subdomain:l,pricingStructureName:c,productTypeName:p,effectiveDate:r,databasePricingStructureId:n},o=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),e=new ClientDialogBuilder({formId:f,formTitle:"Change Pricing Structure Effective Date",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Update",mnemonicChar:"u",mnemonicActionJS:"submitUpdateDatabasePricingStructureDialog()"}),fnSubmit:submitUpdateDatabasePricingStructureDialog,arrExtraHeaderButtons:[o?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmRemoveDatabasePricingStructure(JSON.parse(unescape('"+escape(JSON.stringify(k))+"')))",doubleQuoteEncodedTitle:"Remove Database Pricing Structure"}):null,o?'':null,cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayDatabasePricingStructureEventLog("+n+")"})]});e.addFlexibleFieldRow({rawLabel:"Product Type",rawValue:p});e.addFlexibleFieldRow({rawLabel:"Pricing Structure",rawValue:c});e.addDatePickerRow(f,j,{rawLabel:"Effective Date",strValue:cdCarefullyLocalizeDateValue(r),strPostPickerHTML:a});q=e.showClientDialog();if(q){mjtElemData(q,"databasePricingStructureId",n)}}function showUpdateDatabasePricingStructureDialog(a){jsrsExecuteWithErrorP("Admin2_GetDatabasePricingStructure",doShowUpdateDatabasePricingStructureDialog,"Getting Database Pricing Structure",a)}function submitMissingPricingStructureSelectionDialog(){var h="frmApplyPricingStructure",g=getObj(h),a=new FormValidator(),d=mjtElemData(g,"databaseId"),b=g.cboPricingStructure.options[g.cboPricingStructure.selectedIndex].value,i=b!==""?parseInt(b,10):null,c=getDateForUrlParam(g.dtEffectiveDate.value),e=parseDateString(c),f={databaseId:d,pricingStructureId:i,effectiveDate:e};if(!i){showInfoDialog("Please select a pricing structure.","Select Pricing Structure",true,"cboPricingStructure");return}if(!a.CSValidateDateFieldP({field:g.dtEffectiveDate,label:"Effective Date"})){return}jsrsExecuteWithErrorP("Admin2_ApplyDatabasePricingStructure",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Applying Database Pricing Structure",f)}function doShowMissingPricingStructureSelectionDialog(g,c){var k="frmApplyPricingStructure",i,o=g.arrPricingStructures,f=c.originalPayload.productName,d=c.originalPayload.databaseId,n=c.originalPayload.productTypeId,p=parseInt(n,10),l=c.originalPayload.editionId,j=l?parseInt(l,10):null,b="cboPricingStructure",e="tdPricingStructure",a=buildDropdownRow({name:b,label:"Pricing Structure",valueLookup:"pricingStructureId",textLookup:"pricingStructureName",values:o,valueCellId:e}),m=new ClientDialogBuilder({formId:k,formTitle:"Select Pricing Structure",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitMissingPricingStructureSelectionDialog()"}),fnSubmit:submitMissingPricingStructureSelectionDialog});m.addFlexibleFieldRow({rawLabel:"Product",rawValue:f});m.addDialogInteriorRows(a);m.addDatePickerRow(k,"dtEffectiveDate",{rawLabel:"Effective Date"});i=m.showClientDialog();if(i){mjtElemData(i,"databaseId",d);var h={strFormId:k,selectedProductTypeId:p,selectedEditionId:j,arrPricingStructures:o,pricingStructureValueCellId:e,pricingStructureSelectorName:b};refreshPricingStructureSelector(h)}}function showMissingPricingStructureSelectionDialog(a){jsrsExecuteWithErrorP("Admin2_GetPricingStructures",doShowMissingPricingStructureSelectionDialog,"Retrieving Pricing Structures",a)}function submitApplyDatabasePricingStructureSelectionDialog(){var i="frmApplyPricingStructure",h=getObj(i),e=mjtElemData(h,"databaseId"),b=new FormValidator(),d=getDateForUrlParam(h.dtEffectiveDate.value),f,a=new Date(),c=h.cboPricingStructure.options[h.cboPricingStructure.selectedIndex].value,g;if(!c){showInfoDialog("Please select a pricing structure.","Select Pricing Structure",true,"cboPricingStructure");return}if(!b.CSValidateDateFieldP({field:h.dtEffectiveDate,label:"Effective Date"})){return}a=new Date(a.getFullYear(),a.getMonth(),a.getDate());f=parseDateString(d);if(f";for(var d in e){var a=e[d];if(a.isDeprecated){continue}if(b!==a.productName){if(b!==undefined){c+=""}c+='"}return'"}function doShowApplyDatabasePricingStructureSelectionDialog(f,a){var j="frmApplyPricingStructure",h,m=f.arrPricingStructures,c=a.originalPayload.databaseId,k=f.nextInvoiceInfo,i=cdCarefullyLocalizeDateValue(k.nextInvoiceDate),b="dtEffectiveDate",d={nextInvoiceDate:i,formId:j,dateFieldId:b},e=getNextInvoiceDateLink(d),g=createPricingStructureSelector(m),l=new ClientDialogBuilder({formId:j,formTitle:"Select Pricing Structure",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitApplyDatabasePricingStructureSelectionDialog()"}),fnSubmit:submitApplyDatabasePricingStructureSelectionDialog});l.addFlexibleFieldRow({rawLabel:"Pricing Structure",valueHTML:g});l.addDatePickerRow(j,b,{rawLabel:"Effective Date",strPostPickerHTML:e});h=l.showClientDialog();if(h){mjtElemData(h,"databaseId",c)}}function showApplyDatabasePricingStructureSelectionDialog(a){jsrsExecuteWithErrorP("Admin2_GetPricingStructuresForSelection",doShowApplyDatabasePricingStructureSelectionDialog,"Retrieving Available Pricing Structures",a)}var JTCRMUtils=function(){function x(){SummaryOptionsFilter.setRSCommandToUse({commandId:FilterFrameworkRemoteScriptingCommands_Enum.ffrscGetFilterControlInfoForPage,rsCommandString:"Admin2_GetFilterControlInfoForPage"});SummaryOptionsFilter.setRSCommandToUse({commandId:FilterFrameworkRemoteScriptingCommands_Enum.ffrscGetFilterPropertyOptionsForPage,rsCommandString:"Admin2_GetFilterPropertyOptionsForPage"})}function a(ac){var aa=ac.product,ae=ac.arrProductMenuItems,Y=ac.productOrderId,W=ac.lastDisplayedProductGroupIdHolder,V=aa.name,Z=aa.id,ab=buildProductPricingSuffix(aa),S=aa.displayedProductGroupName,ad=aa.displayedProductGroupId,T=!!aa.editionId,X={productOrderId:Y},U=htmlEncode(V)+htmlEncode(ab);if(ad!=W.lastDisplayedProductGroupId){W.lastDisplayedProductGroupId=ad;ae.push({rawText:S,inactive:1,isHeader:1})}X.productId=Z;X.productName=V;X.pricingStructureId=aa.pricingStructureId;var R=htmlEncode(JSON.stringify(X));ae.push({itemHTML:U,leadItemIconId:FontIconId_Enum.fiiPlusInCircle,altSubmenu:T?0:{fontId:FontIconId_Enum.fiiRightChevron,doubleQuoteEncodedTitle:"Custom Quantity",doubleQuoteEncodedOnClickJS:"showAddSpecificProductCountSubmenu(event,"+R+");cancelEvent(event);return false;"},doubleQuoteReadyScript:"addSpecificProductAndQtyToOrder("+R+",1)"})}function i(ae,R){var Z=ae.upgradeDowngradeInfo,ac=ae.arrProducts,af=ae.arrRestartProducts||[],Y=R.originalPayload,V=(Z||{}).arrProducts,aa=V||[],X=aa.length,ak=Y.productOrderId,al,U,aj=[],ah,an=new ContextMenu();if(X){var ao=0,ad=0,ai=0,ab=Z.existingProductName,am={productOrderId:ak,originalProductName:ab};for(al=0;al"+ab+""}if(T===S){Y.AddMenuItemP({itemHTML:'