\n",o=setTimeout(function(){u(l,s,d)},100),d&&(d.asynchUpdaterTimeoutId=o)}else p="There's no longer any status being reported, so it looks like we're done!",enableDialogButtons();r.innerHTML=p}}catch(b){}}function asynchUpdateWithProcessStatus(e,t,a){jsrsExecute(rsCallbackGetStatus,"Admin_GetStatus",[escape(e)],enableDialogButtons,{processKey:e,strStatusSectionId:t,fnAsynchUpdate:asynchUpdateWithProcessStatus,objAsynchUpdaterTimeoutHolder:a})}function showChangePasswordDialog(){var e=new ClientDialogBuilder({formId:"frmChangePW",formTitle:"Change Password",okButtonDisplayText:"Save",focusFieldName:"txtOldPW",focusFieldOnMobile:1,fnSubmit:submitChangePassword});e.addTextFieldRow("txtOldPW",{rawLabel:"Old Password",isPasswordField:1,maxLength:80}),e.addTextFieldRow("txtNewPW",{rawLabel:"New Password",isPasswordField:1,maxLength:80}),e.addTextFieldRow("txtConfirmPW",{rawLabel:"Confirm Password",isPasswordField:1,maxLength:80}),e.addTextFieldRow("txtUserName",{fieldValue:g_username,hideRow:1}),e.showClientDialog()}function submitEditOrAddTaxRate(){var e=getObj("frmNewTaxRate"),t=mjtElemData(e,"taxRateId"),a=new FormValidator,o={taxRateId:t||"",taxRateName:e.txtName.value,taxRatePercent:trim(e.txtRate.value),state:trim(e.txtState.value)};a.CSValidateRequiredField(e.txtName,"Please enter a Name")&&a.CSValidateNumberField(e.txtRate,"Rate",!1)&&jsrsExecuteWithErrorP(t?"Admin2_UpdateTaxRate2":"Admin2_CreateTaxRate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,t?"Creating Tax Rate":"Updating Tax Rate",o)}function carefullyDisplayEventLog(e,t){hideDialogP({callback:function(){window.location=pageEventLog+e+"/"+t}})}function carefullyDisplayTaxRateEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotTaxRate,e)}function carefullyDisplayStateTaxAgencyEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotStateTaxAgency,e)}function carefullyDisplayEmailTemplateEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotEmailTemplate,e)}function carefullyDisplayProductEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotProduct,e)}function carefullyDisplayPricingStructureEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotPricingStructure,e)}function carefullyDisplayDatabasePricingStructureEventLog(e){carefullyDisplayEventLog(EventObjectType_Enum.eotDatabasePricingStructure,e)}function carefullyDisplayUserEventLog(e){hideDialogP({callback:function(){window.location=pageUserEventLog+e}})}function showTaxRateDialog(e,t,a,o){var n=jtcrmHasAccess(JTCRMSecuredObject_Enum.soTaxRates,AccessRight_Enum.mjtARDelete),n=new ClientDialogBuilder({formId:"frmNewTaxRate",formTitle:e?"Edit Tax Rate":"New Tax Rate",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitEditOrAddTaxRate()"}),fnSubmit:submitEditOrAddTaxRate,arrExtraHeaderButtons:e?[n?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmDeleteTaxRate("+e+",unescape('"+escape(t)+"'))",doubleQuoteEncodedTitle:"Delete Tax Rate"}):"",n?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayTaxRateEventLog("+e+")"})]:0});n.addTextFieldRow("txtName",{rawLabel:"Name",mnemonicChar:"n",fieldValue:t||"",maxLength:80}),n.addTextFieldRow("txtRate",{rawLabel:"Rate",mnemonicChar:"r",fieldValue:""+(a||0),maxLength:8,isNumber:1}),n.addTextFieldRow("txtState",{rawLabel:"State",mnemonicChar:"t",fieldValue:o||"",maxLength:80}),(t=n.showClientDialog())&&mjtElemData(t,"taxRateId",e)}function showNewTaxRateDialog(){showTaxRateDialog()}function doDeleteStateTaxAgency(e){jsrsExecuteWithErrorP("Admin2_DeleteStateTaxAgency",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting State Tax Agency",{stateTaxAgencyId:e.stateTaxAgencyId})}function confirmDeleteStateTaxAgency(e,t){hideDialog(),displaySimpleConfirmationDialog(doDeleteStateTaxAgency,'Are you sure you want to delete "'+htmlEncode(t)+'"',"Delete State Tax Agency",{stateTaxAgencyId:e,stateTaxAgencyName:t})}function submitEditOrAddStateTaxAgency(){var e=getObj("frmAgency"),t=mjtElemData(e,"stateTaxAgencyId"),a=new FormValidator,o=e.cboState,n=trim(o.value),i={stateTaxAgencyId:t||"",stateTaxAgencyName:trim(e.txtName.value),state:n};a.CSValidateRequiredField(e.txtName,"Please enter a Name")&&(n?jsrsExecuteWithErrorP(t?"Admin2_UpdateStateTaxAgency":"Admin2_CreateStateTaxAgency",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,t?"Creating State Tax Agency":"Updating State Tax Agency",i):showInfoDialog('
Please select a state
',"Missing State",1,o.name))}function rsCallbackGetStatesForStateTaxAgencyDialog(e,t){var t=t.originalOptions.params||{},e=e.arrStateNames.map(function(e){return{cboValue:e,rawContent:e}}),a=t.id,o=t.name,t=t.state,n=jtcrmHasAccess(JTCRMSecuredObject_Enum.soTaxRates,AccessRight_Enum.mjtARDelete),n=new ClientDialogBuilder({formId:"frmAgency",formTitle:a?"Edit State Tax Agency":"New State Tax Agency",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitEditOrAddStateTaxAgency()"}),fnSubmit:submitEditOrAddStateTaxAgency,arrExtraHeaderButtons:a?[n?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmDeleteStateTaxAgency("+a+",unescape('"+escape(o)+"'))",doubleQuoteEncodedTitle:"Delete Tax Rate"}):"",n?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayStateTaxAgencyEventLog("+a+")"})]:0});n.addTextFieldRow("txtName",{rawLabel:"Agency Name",mnemonicChar:"n",fieldValue:o||"",maxLength:80}),a||e.unshift({cboValue:"",rawContent:"-Select State-"}),n.addDropdown({fieldName:"cboState",rawLabel:"State",arrAvailableOptions:e,objSelectedValue:t?{cboValue:t,rawContent:t}:null}),(o=n.showClientDialog())&&mjtElemData(o,"stateTaxAgencyId",a)}function showStateTaxAgencyDialog(e){jsrsExecuteWithErrorP("Admin2_GetStatesWithTaxRates",rsCallbackHandleStandardJSONResponse,"Retrieving New Product Info",{excludeStatesWithAssignedStateTaxAgency:1},{fnOnSuccess:rsCallbackGetStatesForStateTaxAgencyDialog,params:e})}function submitTaxJarTransReportOptions(){var e=getObj("frmOptions"),t=new FormValidator,a=pageTaxJarTransReport,o=e.dtFrom,n=e.dtTo,e=e.txtPageSize,i=trim(e.value);t.CSValidateIntegerFieldP({field:e,label:"Page Size",isNullable:!0,minValue:1,maxValue:2e3})&&t.CSValidateDateFieldP({field:o,label:"From"})&&t.CSValidateDateFieldP({field:n,label:"To"})&&(i&&(a+="&pageSize="+i),a=(a+="&from="+trim(getDateForUrlParam(o.value)))+"&to="+trim(getDateForUrlParam(n.value)),hideDialog(),window.location=a,displayTimedMessage("Reloading page..."))}function showTaxJarTransReportOptions(e){var t="frmOptions",a=new ClientDialogBuilder({formId:t,formTitle:"Tax Jar Transactions Report Options",focusFieldName:"dtFrom",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaxJarTransReportOptions()"}),fnSubmit:submitTaxJarTransReportOptions});a.addDatePickerRow(t,"dtFrom",{rawLabel:"From",strValue:e.fromDate,autofocus:1}),a.addDatePickerRow(t,"dtTo",{rawLabel:"To",strValue:e.toDate}),a.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+e.pageSize,mnemonicChar:"r",maxLength:10,styleWidth:"7em",isNumber:1}),a.showClientDialog()}function submitEditOrAddProduct(){var e=getObj("frmNewProduct"),t=new FormValidator,a=e.cboEdition.options[e.cboEdition.selectedIndex].value,o=""!==a,n=e.cboTerm.options[e.cboTerm.selectedIndex].value,i=e.cboPricingStructure.options[e.cboPricingStructure.selectedIndex].value,i=""!==i?parseInt(i,10):null,r=e.priceGenerations.options[e.priceGenerations.selectedIndex].value,r=""!==r?parseInt(r,10):null,l=r===g_flexPricingProductGenerationId,d=e.productTypes.options[e.productTypes.selectedIndex].value,d=""!==d?parseInt(d,10):null,s=d===CRMProductType_Enum.crmptCounterGo,u=d===CRMProductType_Enum.crmptNVInventory,c=mjtElemData(e,"productId"),a={productId:c||"",productName:e.txtName.value,jtUserCount:trim(e.txtJTCount.value),cgUserCount:trim(e.txtCGCount.value),nvUserCount:trim(e.txtNVCount.value),fileSize:trim(e.txtFileSize.value),editionId:a,term:n,price:trim(e.txtPrice.value),notes:cdGetExpandingTextFieldValue("txtNotes"),isDiscountable:e.chkDiscountable.checked?1:0,isJobTrackerSubscription:e.chkJTSubscription.checked?1:0,displayedProductGroupId:e.cboDisplayGroup.options[e.cboDisplayGroup.selectedIndex].value,priceGenerations:r,pricingStructureId:i,productType:d,isDeprecated:e.chkDeprecated&&e.chkDeprecated.checked?1:0};if(t.CSValidateRequiredField(e.txtName,"Please enter a Name")&&t.CSValidateNumberField(e.txtJTCount,"Job Tracker User Count",!1)&&t.CSValidateNumberField(e.txtCGCount,"CounterGo User Count",!1)&&t.CSValidateNumberField(e.txtNVCount,"Inventory User Count",!1)&&t.CSValidateNumberField(e.txtFileSize,"File Size",!1)){if(l){if(!i&&(s||u||o))return void showInfoDialog("Please select a pricing structure.","Select Pricing Structure",!0,"cboPricingStructure")}else if(!t.CSValidateNumberField(e.txtPrice,"Price",!1))return;jsrsExecuteWithErrorP(c?"Admin2_UpdateProduct2":"Admin2_CreateProduct2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,c?"Creating Product":"Updating Product",a)}}function buildAnOption(e,t,a,o,n){o=o||a==e;return o&&n&&(n.didSelect=1),'"}function buildDropdownContent(e){for(var t=e.name,a=e.valueLookup,o=e.textLookup,n=e.selectedValue,i=e.arrValues,r=e.onChangeCode?' onchange="'+e.onChangeCode+'"':"",e=e.disabled?" disabled":"",l="",d=0;d"+l+""}function buildDropdownRow(e){return cdBuildReadOnlyFieldRowP({labelHTML:e.label,valueHTML:buildDropdownContent({name:e.name,valueLookup:e.valueLookup,textLookup:e.textLookup,selectedValue:e.selectedValue,arrValues:e.values,onChangeCode:e.onChangeCode,disabled:e.disabled}),rowId:e.rowId,valueCellId:e.valueCellId})}var MAX_VALUE_PRICING_STRUCTURE_MIN_USERS=99,MIN_VALUE_PRICING_STRUCTURE_MIN_USERS=2;function submitPricingStructureDialog(){var e=getObj("frmPricingStructure"),t=mjtElemData(e,"pricingStructureId"),a=new FormValidator,o=e.cboProductType.options[e.cboProductType.selectedIndex].value,o=o?parseInt(o,10):null,n=e.cboEdition.options[e.cboEdition.selectedIndex].value,n=n?parseInt(n,10):null,i=e.chkIsInactive&&e.chkIsInactive.checked?1:0,r=trim(e.txtTier2StartUserCount.value),r=""!==r?parseInt(r,10):null,l=trim(e.txtTier2PerUserPrice.value),l=""!==l?parseFloat(l):null,d=trim(e.txtMinUserCount.value),d=d?parseInt(d,10):null,i=(CRMProductType_Enum.crmptCounterGo,{pricingStructureId:t,isInactive:i,productTypeId:o,editionId:n,editionPrice:e.txtEditionPrice.value,additionalUserPrice:e.txtAdditionalUserPrice.value,tier2StartUserCount:r,tier2PerUserPrice:l,minUserCount:d||""}),s={minValue:0,maxDecimalPlaces:2},u=[{field:e.txtAdditionalUserPrice,label:"Additional User Price"},{field:e.txtTier2PerUserPrice,label:"Tier 2 Per-User Price",isNullable:!0},{field:e.txtTier2StartUserCount,label:"Tier 2 Start",isNullable:!0,maxDecimalPlaces:0},{field:e.txtMinUserCount,label:"Minimum # of Users",isNullable:!0,maxDecimalPlaces:0,minValue:MIN_VALUE_PRICING_STRUCTURE_MIN_USERS,maxValue:MAX_VALUE_PRICING_STRUCTURE_MIN_USERS}];if(o){for(var c in u)if(Object.assign(s,u[c]),!a.CSValidateNumberFieldP(s))return;l&&!r?showInfoDialog('
Please set the Tier 2 Start User # or clear the Tier 2 Per-User Price
',additionalCellClasses:"leftAlign"}),a.addFlexibleRow({valueHTML:e.buildTableForArray(n)})),(d=a.showClientDialog())&&mjtElemData(d,"arrChanged",i)}function screenTaxesForUpdate(){var e,t,a,o,n,i,r,l,d,s=getObj("frmUpdateTaxesStep1"),u=mjtElemData(s,"state"),s=s.txtTaxes.value,c=String.fromCharCode(9),m=s.split("\n"),p="",b=[],g=1;for("Utah"===u?(l="UT-",i=1,r=0,d=null):"Washington"===u?(l="WA-",i=3,r=0,d=null,g=100):"Ohio"===u&&(l="OH-",i=2,r=0,d=1),e=0;eThe following text could not be parsed (Is it tab-delimited?):
"+htmlMultilineEncode(p),"No Usable Data",1,"txtTaxes"):showInfoDialog("There is nothing to submit!","No Data",1,"txtTaxes")}function showUpdateTaxesDialog(e){var t="",a=("Utah"===e?t='
Enter two, tab-delimitted columns with the County/City Code and the Tax Rate (%)
'),new ClientDialogBuilder({formId:"frmUpdateTaxesStep1",formTitle:"Update "+e+" Tax Rates",focusFieldName:"txtTaxes",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"screenTaxesForUpdate()"}),fnSubmit:screenTaxesForUpdate}));a.addFlexibleRow({valueHTML:t}),a.addTextAreaFieldRow("txtTaxes",{rawLabel:"Taxes",mnemonicChar:"t",labelAbove:1,rowCount:18,autofocus:1}),(t=a.showClientDialog())&&mjtElemData(t,"state",e)}function showUserEventLog(e,t,a,o,n){var i="";t&&(i+="pageSize="+t),a&&(i+="&from="+trim(getDateForUrlParam(a))),o&&(i+="&to="+trim(getDateForUrlParam(o))),n&&(i+="&dateCount="+trim(n)),window.location=pageUserEventLog+e+(i?"?":"")+i}function submitChangeLogOptions(){var e=getObj("frmChangeLogOptions"),t=e.cboUsers,t=t.options[t.selectedIndex].value,a=new FormValidator,o=e.pageSize,n=getObj("rbDateRange"),n=n&&n.checked,i=e.dtFrom,r=e.dtTo,e=e.txtDateCount,l="",d="",s="";if(a.CSValidateIntegerField(o,"Page Size",!0,1,2e3)){if(n){if(!a.CSValidateDateField(i,"From",!0))return;if(!a.CSValidateDateField(r,"To",!0))return;if(!trim(i.value)&&!trim(r.value))return void showInfoDialog("Please specify a Range of Dates.","Missing Date Range",1,"dtFrom");l=i.value,d=r.value}else{if(!a.CSValidateIntegerField(e,"Number of Days",!1,1,9999))return;s=e.value}hideDialog(),showUserEventLog(t,parseInt(trim(o.value),10),l,d,s)}}function elDateRangeChanged(){var e=getObj("frmChangeLogOptions"),t=getObj("rbDateRange"),t=t&&t.checked;e&&(e.dtFrom.disabled=!t,e.dtTo.disabled=!t,e.txtDateCount.disabled=t)}function rsCallbackGetUsersForOptions(e,t,a){if(enableDialogButtons(),checkResponseForError(e)){for(var o,n,i,r=a.userId,l=a.pageSize,d="frmChangeLogOptions",s=" onkeypress=\"return submitClientDialogOnEnter('"+d+"',event);\"",u="",c=JSON.parse(e).arrUsers,e=cdBuildDatePickerField(d,"dtFrom",a.dateFrom,s,""),m=cdBuildDatePickerField(d,"dtTo",a.dateTo,s,""),a=a.dateCount,s="Last "+buildTextField("txtDateCount",""+(a||7),s,4,"4em")+" Days",a=!a,d=new ClientDialogBuilder({formId:d,formTitle:"Change Log Options",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"alert('Hello')"}),focusFieldName:"cboUsers",focusFieldOnMobile:1,fnSubmit:submitChangeLogOptions}),p=0;p"+htmlEncode(o.email)+"";i="elDateRangeChanged()",e='
From:
'+e+'
To:
'+m+"
",d.addFlexibleFieldRow({rawLabel:"User",valueHTML:'"}),d.addFlexibleFieldRow({labelHTML:cdBuildRBP("rbDateType","rbDateRange","Range of Dates ",{checked:a,onClickCode:i,forceLabelOnTheLeft:1}),valueHTML:e,suppressLabelColon:1}),d.addFlexibleFieldRow({labelHTML:cdBuildRBP("rbDateType","rbDateCount","Number of Days ",{checked:!a,onClickCode:i,forceLabelOnTheLeft:1}),valueHTML:s,suppressLabelColon:1}),d.addTextFieldRow("pageSize",{rawLabel:"Events/Page",fieldValue:""+l,isNumber:1,maxValue:2e3}),d.showClientDialog(),elDateRangeChanged()}}function showChangeLogOptions(e,t,a,o,n,i){jsrsExecute(rsCallbackGetUsersForOptions,"Admin_GetUsers",[],enableDialogButtons,{userId:t||0,pageSize:a,dateCount:o,dateFrom:n,dateTo:i})}function eventLogObjectMenu(e,t,a,o){var n,i=new ContextMenu;if(g_isDoubleClickEvent)window.location=pageEventLog+t+"/"+a;else{switch(n=t==EventObjectType_Enum.eotUser?'View changes to "'+o+'"':'View Change Log for "'+o+'"',i.AddLinkItem(n,pageEventLog+t+"/"+a,"",1),t){case EventObjectType_Enum.eotInvoice:i.AddSeparatorIfNecessary(),i.AddLinkItem('View Invoice "'+o+'"',pageInvoiceDetail+a);break;case EventObjectType_Enum.eotCreditMemo:i.AddSeparatorIfNecessary(),i.AddLinkItem('View Credit Memo "'+o+'"',pageCreditMemoDetail+a);break;case EventObjectType_Enum.eotPayment:i.AddSeparatorIfNecessary(),i.AddLinkItem('View Payment "'+o+'"',pagePaymentDetail+a);break;case EventObjectType_Enum.eotDatabase:i.AddSeparatorIfNecessary(),i.AddLinkItem('View Database "'+o+'"',pageDatabaseDetail+a);break;case EventObjectType_Enum.eotCustomer:i.AddSeparatorIfNecessary(),i.AddLinkItem('View Customer "'+o+'"',pageCustomerDetail+a);break;case EventObjectType_Enum.eotProduct:i.AddSeparatorIfNecessary(),i.AddLinkItem("View Products",pageSystemSettingsProducts);break;case EventObjectType_Enum.eotUser:i.AddSeparatorIfNecessary(),i.AddLinkItem("View changes made by "+htmlEncode(o),pageUserEventLog+a)}i.Show(e)}}function systemEventLogMenu(e){var t=new ContextMenu;g_isDoubleClickEvent?window.location=pageSystemEventLog:(t.AddLinkItem("View changes made by the system",pageSystemEventLog,"",1),t.Show(e))}function jtUserEventLogMenu(e,t,a,o,n){var i=new ContextMenu;g_isDoubleClickEvent?window.location=pageJTUserEventLog+o+"/"+t:(i.AddLinkItem("View changes made by "+a+" of DB "+n,pageJTUserEventLog+o+"/"+t,"",1),i.Show(e))}function userEventLogMenu(e,t,a){var o=new ContextMenu;g_isDoubleClickEvent?showUserEventLog(t):(o.AddLinkItem("View changes made by "+a,pageUserEventLog+t,"",1),o.AddSeparatorIfNecessary(),o.AddLinkItem("View changes to "+a,pageEventLog+EventObjectType_Enum.eotUser+"/"+t),o.Show(e))}function submitUpdateJTIManLKInfo(){var e=getObj("frmUpdateLK"),e=getCallbackDataOfDialog(e);jsrsExecuteWithErrorP("Admin2_UpdateJTIManLKInfo2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating License",{databaseId:e.databaseId,newLicense:e.license})}function rsCallbackTestUpdateJTIManLKInfo(e,t){var a,o,t=t.originalPayload,n=e.arrDiffs,i=0',o=0;o
";t.addFlexibleRow({valueHTML:'Updating the license key will result in the following changes:
'+(l+="
")+""})}else t.addFlexibleRow({rawValue:"Updating the license key will result in no changes.\n\n"});t.addFlexibleRow({rawValue:"Are you sure you want to update the license key?"}),t.showClientDialog()}function testUpdateJTIManLKInfo(){var e=getObj("frmLicense"),t=getCallbackDataOfDialog(e),e=e.txtLicense,a=trim(e.value);(new FormValidator).CSValidateRequiredField(e,"Please enter a License")&&jsrsExecuteWithErrorP("Admin2_TestUpdateJTIManLKInfo2",rsCallbackHandleStandardJSONResponse,"Checking For Differences In The Proposed License",{databaseId:t.databaseId,newLicense:a},{fnOnSuccess:rsCallbackTestUpdateJTIManLKInfo})}function rsCallbackGenerateLicenseForDB(e,t){var t=t.originalPayload,a=e.licenseText,e=e.instanceName,t=new ClientDialogBuilder({formId:"frmLicense",formTitle:"Update License Key",focusFieldName:"btnOk",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Analyze Changes",mnemonicChar:"a",mnemonicActionJS:"testUpdateJTIManLKInfo()"}),fnSubmit:testUpdateJTIManLKInfo,callbackData:{databaseId:t.databaseId}});e&&(t.addFlexibleRow({rawValue:"Instance Name: "+e}),t.addSectionHeaderRow()),t.addTextAreaFieldRow("txtBody",{rawLabel:"License",unencodedText:a,fieldId:"txtLicense",emWidth:"30",labelAbove:1}),t.showClientDialog()}function generateLicense(e,t){jsrsExecuteWithErrorP("Admin2_GenerateLicenseForDB2",rsCallbackHandleStandardJSONResponse,"Generating License",{databaseId:e,productExpirationDate:t||""},{fnOnSuccess:rsCallbackGenerateLicenseForDB})}function submitGenerateExpiringLicense(e,t){var a=new FormValidator,e=e.dtExpiration,o=new Date,o=new Date(o.getFullYear(),o.getMonth(),o.getDate());a.CSValidateDateField(e,"Expiration Date",!1,e.name)&&(a=getDateForUrlParam(e.value),parseDateString(a) Otherwise no records will be shown.',"All Records Filtered Out",1)}function toggledFailedPaymentOption(e){var t=getObj("chkIncArch");e.checked||(t.checked=!1)}function updatePaymentTimeframe(){getObj("rbToday");var e=getObj("rbSingleDate"),t=getObj("rbDateRange"),a=getObj("secSingleDate"),o=getObj("secDateRange");t.checked;a.style.visibility=e.checked||t&&t.checked?"":"hidden",o&&(o.style.visibility=t.checked?"":"hidden")}function rsCallbackGetPaymentMethods(e,t,a){if(enableDialogButtons(),checkResponseForError(e)){for(var o,n=a.strPaymentMethods,i=JSON.parse(e).arrPaymentMethods,r={},l=buildAnOption("","[Any]",n,0,r),d=0;d'+l+""}),p=getDateAsDisplayString(new Date),b=a.dispDate,a=a.dispDateTo,g=a||p,p=''+cdBuildDatePickerField(e,"dtFrom",b||p,m)+' - '+cdBuildDatePickerField(e,"dtTo",g,m)+"";u+=cdBuildRBRowP("rbDateRange","rbSingleDate","Single Date",{rawRowLabel:"Timeframe:",checked:b&&!a,onClickCode:c})+'
":r="No Data!",showInfoDialog(r,'"'+o+'" Details For '+n),getObj("divChurnDetailTable")),r=getObj("frmTmpMessage");t&&(t.onclick=doClick,r.databases=e,r.revenueCategoryText=o,r.periodTypeId=i,a)&&a.objClientTable.linkTableObjectsToElement(t),scrollDialogIfNecessary("frmTmpMessage",1,1)}function drillIntoChurnReportCell(e){var t=e.periodTitle,a=e.startDate,o=e.endDate,n=e.revenueCategoryId,i=e.periodTypeId,e=e.productTypeId,r=getRevenueCategoryText({revenueCategoryId:n});jsrsExecuteWithErrorP("Admin2_GetChurnReportDetails",rsCallbackHandleStandardJSONResponse,'Retrieving "'+r+'" details for '+t,{startDate:a,endDate:o,productTypeId:e,revenueCategoryId:n},{fnOnSuccess:rsCallbackGetChurnReportDetails,revenueCategoryText:r,periodTitle:t,periodTypeId:i,revenueCategoryId:n,productTypeId:e})}function getPeriodText(e){var t=e.periodType;switch(t){case ChurnReportPeriodType_Enum.crptMonth:return"Month";case ChurnReportPeriodType_Enum.crptQuarter:return"Quarter";case ChurnReportPeriodType_Enum.crptYear:return"Year";default:return"Unknown - "+t}}function submitChangeChurnReportOptions(e,t){var a=e.txtPeriodCount,o=new FormValidator,n=trim(a.value),i=parseInt(e.cboPeriodType.value,10),r=(getPeriodText({periodType:i})||"Month")+"s",e=e.cboProductType.value;o.CSValidateIntegerField(a,"Number of "+r,!1,1,120)&&(hideDialog(),showWorking("Reloading..."),window.location=pageChurnReport+"&periodCount="+n+"&periodType="+i+"&productType="+e)}function setChurnReportPeriodTypeLabels(e){e=(getPeriodText({periodType:e.periodType})||"Month")+"s";getObj("churnReportPeriodLabel").innerHTML=e}function churnReportPeriodTypeChanged(){var e=getObj("churnReportPeriodType");setChurnReportPeriodTypeLabels({periodType:parseInt(e.value,10)})}function showChurnReportOptions(e,t){var a=t.periodCount,o=t.periodType,t=t.productType,n="txtPeriodCount",i=new ClientDialogBuilder({formId:"frmOptions",formTitle:"Churn Report Options",okButtonDisplayText:"Apply",focusFieldName:n,focusFieldOnMobile:1,fnSubmit:submitChangeChurnReportOptions});i.addDropdown({fieldName:"cboProductType",rawLabel:"Product",arrAvailableOptions:[{cboValue:CRMProductType_Enum.crmptCounterGo,rawContent:"CounterGo"},{cboValue:CRMProductType_Enum.crmptNVInventory,rawContent:"Inventory"},{cboValue:CRMProductType_Enum.crmptSystemize,rawContent:"Systemize"}],objNoneOption:{cboValue:"",rawContent:"-All-"},objSelectedValue:{cboValue:t},additionalCellClasses:"clsNarrowField"}),i.addDropdown({fieldName:"cboPeriodType",fieldId:"churnReportPeriodType",onClickChangeJS:"churnReportPeriodTypeChanged()",rawLabel:"Period",arrAvailableOptions:[{cboValue:ChurnReportPeriodType_Enum.crptMonth,rawContent:"Month"},{cboValue:ChurnReportPeriodType_Enum.crptQuarter,rawContent:"Quarter"},{cboValue:ChurnReportPeriodType_Enum.crptYear,rawContent:"Year"}],objSelectedValue:{cboValue:o},additionalCellClasses:"clsNarrowField"}),i.addTextFieldRow(n,{rawLabel:"Show Last",fieldValue:""+a,isNumber:1,maxLength:4,autofocus:1,strPostFieldHTML:' ',additionalCellClasses:"clsNarrowField"}),i.showClientDialog(),setChurnReportPeriodTypeLabels({periodType:o})}function submitCohortReportOptions(e,t){var a=e.txtMaxMonths,e=e.cboProductType.value;(new FormValidator).CSValidateIntegerField(a,"Max # of Months to Report",!1,1,CommonConstants_Enum.ccMAX_REPORTING_MONTHS_COUNT)&&(hideDialog(),window.location=pageCohortAnalysisReport+"maxMonths="+trim(a.value)+"&productType="+e,displayTimedMessage("Reloading page..."))}function showCohortReportOptions(e,t){var a=t.maxMonths,t=t.productType,o="txtMaxMonths",n=new ClientDialogBuilder({formId:"frmOptions",formTitle:"Cohort Analysis Report Options",okButtonDisplayText:"Apply",focusFieldName:o,focusFieldOnMobile:1,fnSubmit:submitCohortReportOptions});n.addTextFieldRow(o,{rawLabel:"Max # of Months to Report",fieldValue:""+a,isNumber:1,maxLength:10,autofocus:1,additionalCellClasses:"clsNarrowField"}),n.addDropdown({fieldName:"cboProductType",rawLabel:"Product",arrAvailableOptions:[{cboValue:CRMProductType_Enum.crmptCounterGo,rawContent:"CounterGo"},{cboValue:CRMProductType_Enum.crmptNVInventory,rawContent:"Inventory"},{cboValue:CRMProductType_Enum.crmptSystemize,rawContent:"Systemize"}],objNoneOption:{cboValue:"",rawContent:"-All-"},objSelectedValue:{cboValue:t},additionalCellClasses:"clsNarrowField"}),n.showClientDialog()}function submitLicenseReconciliationReportOptions(){var e=getObj("frmOptions"),t=getCallbackDataOfDialog(e).strSortAddendum,a=new FormValidator,o=e.cboBatch,o=o.options[o.selectedIndex].value,e=e.txtPageSize;a.CSValidateIntegerField(e,"Page Size",!0,1,2e3)&&(hideDialog(),window.location=pageLicenseReconciliationReport+(o?"&batchId="+o:"")+"&pageSize="+e.value+t,displayTimedMessage("Reloading page..."))}function rsCallbackGetServerMetricBatches(e,t,a){if(enableDialogButtons(),checkResponseForError(e)){for(var o,n,i=JSON.parse(e).arrBatches,e=a.strSortAddendum,r='',l=a.batchId,a=a.pageSize,e=new ClientDialogBuilder({formId:"frmOptions",formTitle:"License Reconciliation Report Options",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitLicenseReconciliationReportOptions()"}),focusFieldName:"cboBatch",focusFieldOnMobile:1,suppressDialogConfirmer:1,callbackData:{strSortAddendum:e},fnSubmit:submitLicenseReconciliationReportOptions}),d=0;d'+htmlEncode(o.timestamp)+"";e.addFlexibleFieldRow({rawLabel:"Batch",valueHTML:'"}),e.addTextFieldRow("txtPageSize",{rawLabel:"Rows/Page",fieldValue:""+(a||30),maxLength:4,isNumber:1}),e.showClientDialog()}}function showLicenseReconciliationReportOptions(e,t,a,o){jsrsExecute(rsCallbackGetServerMetricBatches,"Admin_GetServerMetricBatches",[],enableDialogButtons,{batchId:t,strSortAddendum:o,pageSize:a}),displayTimedMessage("Getting Available Batches..."),disableDialogButtons()}function toggleExpandServerMetricInfo(){var e=getObj("imgServerMetricsExpander.expand"),t=!e.style.display;e.style.display=t?"none":"",getObj("imgServerMetricsExpander.collapse").style.display=t?"":"none",getObj("divServerMetrics").style.display=t?"":"none"}function toggleExpandTaskSection(){saveScrollPos();var e=!getObj("imgTaskSectionExpander.expand").style.display,e=addRemoveOrReplaceURLParameter(window.location,"expandTasks",e?"1":"");window.location=e}function submitServerMetricReportOptions(){var e=getObj("frmOptions"),t=new FormValidator,a=e.cboBatch,a=a.options[a.selectedIndex].value,o=e.txtPageSize,n=parseInt(e.cboUsage.value,10),i=parseInt(e.cboBillingDBStatus.value,10),e=parseInt(e.cboExpirationStatus.value,10),r=pageServerMetricReport+"&pageSize="+o.value;t.CSValidateIntegerField(o,"Page Size",!0,1,2e3)&&(hideDialog(),a&&(r+="&batchId="+a),n!==SMREditionUsage_Enum.seuAll&&(r+="&smro="+n),e!==SMRExpirationStatus_Enum.sesAll&&(r+="&estat="+e),i!==SMRBillingDBStatus_Enum.bdbsAll&&(r+="&bdbs="+i),window.location=r,displayTimedMessage("Reloading page..."))}function rsCallbackGetServerMetricBatchesForServerMetricReport(e,t){var t=t.originalOptions,a=t.serverMetricReportOption,o=t.expirationStatus,n=t.billingDBStatus,i=t.pageSize,r=new ClientDialogBuilder({formId:"frmOptions",formTitle:"Server Metric Report Options",focusFieldName:"cboBatch",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitServerMetricReportOptions()"}),fnSubmit:submitServerMetricReportOptions});r.addDropdown({arrAvailableOptions:e.arrBatches.map(function(e){return{cboValue:e.id,rawContent:e.timestamp}}),rawLabel:"Bulk-Batch",fieldName:"cboBatch",objNoneOption:{cboValue:"",rawContent:"-Latest-"},objSelectedValue:{cboValue:t.batchId||""}}),r.addDropdown({fieldName:"cboUsage",rawLabel:"Usage",arrAvailableOptions:[{cboValue:SMREditionUsage_Enum.seuAll,rawContent:"All"},{cboValue:SMREditionUsage_Enum.seuCGUsage,rawContent:"CounterGo"},{cboValue:SMREditionUsage_Enum.seuJTUsage,rawContent:"Systemize"}],objSelectedValue:{cboValue:a}}),r.addDropdown({fieldName:"cboBillingDBStatus",rawLabel:"Billing DB Status",arrAvailableOptions:[{cboValue:SMRBillingDBStatus_Enum.bdbsAll,rawContent:"All"},{cboValue:SMRBillingDBStatus_Enum.bdbsHasBillingDB,rawContent:"Has Billing DB"},{cboValue:SMRBillingDBStatus_Enum.bdbsNoBillingDB,rawContent:"No Billing DB"}],objSelectedValue:{cboValue:n}}),r.addDropdown({fieldName:"cboExpirationStatus",rawLabel:"Expiration Status",arrAvailableOptions:[{cboValue:SMRExpirationStatus_Enum.sesAll,rawContent:"All"},{cboValue:SMRExpirationStatus_Enum.sesNotExpired,rawContent:"Not Expired"},{cboValue:SMRExpirationStatus_Enum.sesExpired,rawContent:"Expired"}],objSelectedValue:{cboValue:o}}),r.addTextFieldRow("txtPageSize",{rawLabel:"Rows/Page",fieldValue:""+(i||30),maxLength:4,isNumber:1}),r.showClientDialog()}function showServerMetricReportOptions(e){e.fnOnSuccess=rsCallbackGetServerMetricBatchesForServerMetricReport,jsrsExecuteWithErrorP("Admin2_GetServerMetricBatches2",rsCallbackHandleStandardJSONResponse,"Getting Available Batches",{},e)}function getNewProcessKey(){var e=new Date;return Math.random()+">..<"+e.getTime()}function rsCallbackGenerateServerMetrics(e,t,a){checkResponseForError(e)&&(e=getObj(a.statusSectionId),a=a.asynchUpdaterTimeoutId,e&&(e.innerHTML="Completed Server Metrics"),a&&clearTimeout(a),refreshPageAndScrollPos())}function rsErrorCallbackBuildServerMetrics(e,t,a){var o=getObj(a.statusSectionId);a.requestContextId==t&&o&&(o.innerHTML='
Encountered the following error generating server metrics:
'+htmlMultilineEncode(e)+"
"+o.innerHTML,a.asynchUpdaterTimeoutId&&clearTimeout(a.asynchUpdaterTimeoutId),a.refreshOnClose=1)}function doBuildServerMetrics(e){hideDialog();var t=getNewProcessKey(),a="serverMetricsStatus",o={statusSectionId:a},n=new ClientDialogBuilder({formId:"frmServerMetricsProgress",formTitle:"Generating Server Metrics",fnCancelOrClose:function(){if(!o.refreshOnClose)return 1;refreshPageAndScrollPos(),hideDialog()}});n.addFlexibleRow({cellId:a}),n.showClientDialog(),o.requestContextId=jsrsExecute(rsCallbackGenerateServerMetrics,"Admin_GenerateServerMetrics",[escape(t)],rsErrorCallbackBuildServerMetrics,o,0,1),o.asynchUpdaterTimeoutId=setTimeout(function(){asynchUpdateWithProcessStatus(t,a,o)},125)}function confirmBuildServerMetricsDialog(e){var t=new ClientDialogBuilder({formTitle:"Server Metrics",okButtonDisplayText:"Generate",focusFieldName:"btnOk",fnSubmit:doBuildServerMetrics});t.addFlexibleRow({rawValue:"Are you sure you want to generate server metrics?"}),t.showClientDialog()}function showLicenseText(e,t,a){showInfoDialog(cdBuildTextAreaFieldRowP("txtNotes","License",{unencodedText:unescape(t),labelAbove:1}),(a?"Expected":"Actual")+' License for Instance "'+htmlEncode(e)+'"',isDialogShowing())}function showLicenseDifferences(e,t,a,o,n){var t=t?t.arrDifferences:0,t=t?t.map(function(e){return{rawRowHeader:e[0],rawDeployedValue:e[1],rawBillingValue:e[2]}}):0,i=new MWClientTable({noDataMessage:"There Are No Differences",arrColumns:[new MWColumn({columnName:"",additionalCellClasses:"deltaItemPropertyHeader",simpleDisplayColumnPropertyName:"rawRowHeader"}),new MWColumn({columnName:"Deployed Value",simpleDisplayColumnPropertyName:"rawDeployedValue"}),new MWColumn({columnName:"Billing Value",simpleDisplayColumnPropertyName:"rawBillingValue"})]}),r=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formTitle:"Actual Vs. Expected License"}),l=htmlEncode(unescape(e));n&&(l=''+l+""),r.addFlexibleFieldRow({rawLabel:"Instance",valueHTML:l}),a&&r.addFlexibleFieldRow({valueHTML:'Expected License..."}),o&&r.addFlexibleFieldRow({valueHTML:'Actual License..."}),r.addFlexibleRow({valueHTML:i.buildTableForArray(t)}),r.showClientDialog()}function showLicenseMenu(e){var t=e.databaseId,a=escape(e.instanceName),o=e.actualLicenseText,e=e.expectedLicenseText,n=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARRead),i=new ContextMenu;i.AddScriptItem("Show actual license...","showLicenseText('"+a+"','"+escape(o)+"',0);"),i.AddScriptItem("Show expected license...","showLicenseText('"+a+"','"+escape(e)+"',1);"),t&&n&&(i.AddSeparatorIfNecessary(),i.AddLinkItem("View Database",pageDatabaseDetail+t)),i.Show(event)}function submitAddOrUpdateTask(){var e=getObj("frmAddTask"),t=new FormValidator,a=mjtElemData(e,"taskId"),o=cdGetExpandingTextFieldValue("txtNotes"),n=mjtElemData(e,"databaseId");t.CSValidateRequiredField(e.txtName,"Please enter a Name")&&t.CSValidateDateField(e.dtDeadline,"Deadline",!1,"dtDeadline")&&jsrsExecuteWithErrorP(a?"Admin2_UpdateTask2":"Admin2_CreateTask2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,a?"Updating Task":"Creating Task",{taskId:a||"",databaseId:n||"",taskName:trim(e.txtName.value),taskNotes:trim(o),taskDeadline:getDateForUrlParam(e.dtDeadline.value)})}function showAddOrUpdateTask(e){var t=e.id,a=e.statusId,o="frmAddTask",n="txtName",i=e.name,r=e.notes,l=e.subdomain,a=t?a===TaskStatus_Enum.tsComplete?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiLightningBolt,doubleQuoteEncodedTitle:"Re-Activate Task",doubleQuoteEncodedOnClickJS:"carefullyActivateTask("+t+")"}):a===TaskStatus_Enum.tsActive?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiCheck,doubleQuoteEncodedTitle:"Mark Task Complete",doubleQuoteEncodedOnClickJS:"confirmSetTaskStatus("+t+","+TaskStatus_Enum.tsComplete+",'Complete',unescape('"+escape(i)+"'),1)"}):"":"",d=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),d=new ClientDialogBuilder({formId:o,formTitle:t?"Update Task":"Add Task To Database",focusFieldName:n,focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitAddOrUpdateTask()"}),arrExtraHeaderButtons:t?[d?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Task",doubleQuoteEncodedOnClickJS:"confirmDeleteTask("+t+",unescape('"+escape(i)+"'),1)"})+'':"",a,buildHeaderChangeLogAnchorButton({eventObjectTypeId:EventObjectType_Enum.eotTask,eventObjectId:t})]:0,fnSubmit:submitAddOrUpdateTask});l&&d.addFlexibleFieldRow({rawLabel:"Subdomain",rawValue:l}),d.addTextFieldRow(n,{rawLabel:"Name",mnemonicChar:"n",fieldValue:i,autofocus:1,maxLength:80}),d.addDatePickerRow(o,"dtDeadline",{rawLabel:"Task Deadline",mnemonicChar:"t",strValue:cdCarefullyLocalizeDateValue(e.deadline)}),d.addExpandingTextFieldRows("txtNotes",{rawLabel:"Description",value:r||""}),(a=d.showClientDialog())&&(mjtElemData(a,"databaseId",e.databaseId),mjtElemData(a,"taskId",e.id))}function showAddTaskToDatabase(e,t,a){showAddOrUpdateTask({databaseId:t,subdomain:a})}function rsCallbackGetTaskDetails(e){showAddOrUpdateTask(e)}function showEditTaskDialog(e,t){jsrsExecuteWithErrorP("Admin2_GetTaskDetails2",rsCallbackHandleStandardJSONResponse,'Retrieving info for task, "'+t+'"',{taskId:e},{fnOnSuccess:rsCallbackGetTaskDetails})}function doDeleteTask(e){jsrsExecuteWithErrorP("Admin2_DeleteTask2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting Task",{taskId:e.taskId})}function confirmDeleteTask(e,t,a){a&&hideDialog(),displaySimpleConfirmationDialog(doDeleteTask,'Are you sure you want to delete "'+htmlEncode(t)+'"',"Delete Task",{taskId:e,taskName:t})}function setTaskStatus(e){jsrsExecuteWithErrorP("Admin2_SetTaskStatus2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Task Status",{taskId:e.taskId,taskStatus:e.status})}function carefullyActivateTask(e){hideDialogP({callback:function(){setTaskStatus({taskId:e,status:TaskStatus_Enum.tsActive})}})}function confirmSetTaskStatus(e,t,a,o,n){var i=function(){displaySimpleConfirmationDialog(setTaskStatus,"Are you sure you want to mark the task "+htmlEncode(a)+'?
Task: '+htmlEncode(unescape(o))+"","Set task status",{taskId:e,status:t})};n?hideDialogP({callback:i}):i()}function submitTaskReportOptions(){var e=getObj("frmOptions"),t=new FormValidator,a=pageTaskReport,o=e.txtPageSize,n=trim(o.value),i=mjtElemData(e,"defaultStatusFilter"),e=parseInt(e.cboTaskStatusFilter.value,10);t.CSValidateIntegerFieldP({field:o,label:"Page Size",isNullable:!0,minValue:1,maxValue:2e3})&&(n&&(a+="&pageSize="+n),e!==i&&(a+="&status="+e),hideDialog(),window.location=a,displayTimedMessage("Reloading page..."))}function showTaskReportOptions(e){consoleLogBlockOpen("showTaskReportOptions()"),consoleLog(JSON.stringify({params_:e},null,2));var t=new ClientDialogBuilder({formId:"frmOptions",formTitle:"Task Report Options",focusFieldName:"cboTaskStatusFilter",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaskReportOptions()"}),fnSubmit:submitTaskReportOptions});t.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:e.taskStatusFilter}}),t.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+e.pageSize,mnemonicChar:"r",maxLength:10,styleWidth:"7em",isNumber:1}),(t=t.showClientDialog())&&mjtElemData(t,"defaultStatusFilter",e.defaultStatusFilter),consoleLogBlockClose()}function doDeleteEmailTemplate(e){jsrsExecuteWithErrorP("Admin2_DeleteEmailTemplate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Deleting Email Template",{emailTemplateId:e.emailTemplateId})}function confirmDeleteEmailTemplate(e,t,a){a&&hideDialog(),displaySimpleConfirmationDialog(doDeleteEmailTemplate,'Are you sure you want to delete "'+htmlEncode(t)+'"',"Delete Email Template",{emailTemplateName:t,emailTemplateId:e})}function rsCallbackCreatedEmailTemplate(){}function validateCommonEmail(e,t,a){var o=t.txtSubject,t=t.txtBody,n=t.value;if(e.CSValidateRequiredField(o,"Please enter a Subject")&&e.CSValidateRequiredField(t,"Please enter a Body"))return a.subject=trim(o.value),a.body=n,1}function submitCreateOrEditEmailTemplate(){var e=getObj("frmEmailTemplate"),t=mjtElemData(e,"emailTemplateId"),a=new FormValidator,o=e.txtFromName,n=e.chkDunning.checked,i={};a.CSValidateRequiredField(e.txtName,"Please enter a Name for the Email Template")&&a.CSValidateRequiredField(o,"Please enter a From Name")&&validateCommonEmail(a,e,i)&&jsrsExecuteWithErrorP("Admin2_CreateOrUpdateEmailTemplate2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Submitting Email Template",{emailTemplateId:t||"",emailTemplateName:e.txtName.value,fromName:o.value,messageSubject:i.subject,messageBody:i.body,isDunningEmail:n?1:0},{postMessageFocusFieldName:"txtBody"})}function insertTextIntoTextField(e,t){e=getObj(e);insertAtCursor(e,t)}function showTextSubstitutionOptions(e,t){show_staticTextInsertPicker(getObj("btnInsertSubstitutionString"),null,!1,"insertTextIntoTextField",t,{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(e,t){var a=e.id,o=jtcrmHasAccess(JTCRMSecuredObject_Enum.soEmailTemplates,AccessRight_Enum.mjtARDelete),o=new ClientDialogBuilder({formId:"frmEmailTemplate",formTitle:a?"Edit Email Template":"Create Email Template",focusFieldName:"txtName",focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitCreateOrEditEmailTemplate()"}),fnSubmit:submitCreateOrEditEmailTemplate,arrExtraHeaderButtons:a?[o?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Email Template",doubleQuoteEncodedOnClickJS:"confirmDeleteEmailTemplate("+a+",unescape('"+escape(e.name)+"'),1)"}):"",o?'':"",cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayEmailTemplateEventLog("+a+")"})]:0});o.addTextFieldRow("txtName",{rawLabel:"Template Name",mnemonicChar:"n",fieldValue:e.name}),o.addFlexibleFieldRow({labelHTML:"From Email",rawValue:e.fromEmailAddress}),o.addTextFieldRow("txtFromName",{labelHTML:"From Name",fieldValue:e.fromName}),o.addTextFieldRow("txtSubject",{rawLabel:"Subject",mnemonicChar:"j",fieldValue:e.subject}),o.addTextAreaFieldRow("txtBody",{rawLabel:"Body",mnemonicChar:"b",unencodedText:e.body,fieldId:"txtBody",textAreaClasses:"largeTextArea"}),o.addFlexibleFieldRow({valueHTML:'"}),o.addCheckboxRow("chkDunning",{rawLabel:"Dunning Email",mnemonicChar:"l",checked:e.dunning}),(e=o.showClientDialog())&&mjtElemData(e,"emailTemplateId",a)}function showCreateOrEditEmailTemplateDialog(e){jsrsExecuteWithErrorP("Admin2_GetInfoForCreateOrEditEmailTemplate",rsCallbackGetInfoForCreateOrEditEmailTemplate,"Getting info for Email Template",{emailTemplateId:e.emailTemplateId||""},e)}function showNewEmailTemplateDialog(){showCreateOrEditEmailTemplateDialog({})}function showEditEmailTemplateDialog(e,t){showCreateOrEditEmailTemplateDialog({emailTemplateId:e,emailTemplateName:t})}function submitReorderEmailTemplatesDialog(e){submitReorderP({arrReorderedIds:e,reorderCommandName:"Admin2_ReorderEmailTemplates2",reorderObjectName:"Email Templates",reorderIdsPropertyName:"emailTemplateIds"})}function showReorderEmailTemplatesDialog(e){jsrsExecuteWithErrorP("Admin2_GetEmailTemplatesForReorder",rsCallbackGetObjectsForReorder,"Getting list of Email Templates for re-order",{},{arrayAttrName:"arrEmailTemplates",fnSubmit:submitReorderEmailTemplatesDialog,strReorderWhat:"Email Templates",highlightedId:e})}function getEmailTemplateSelectionOption(e){var e=e?e.cboTemplates:0,e=e.options[e.selectedIndex].value,t=!!e;return{isTemplateSelected:t,objET:t?JSON.parse(unescape(e)):{subject:"",fromName:"",body:""}}}function submitEmail(e,t){var a=new FormValidator,o=getEmailTemplateSelectionOption(e),n=o.objET,i=e.txtMessageRecipient,r=e.txtFromName,l=e.txtSubject,e=e.txtBody;o.isTemplateSelected?a.CSValidateRequiredField(r,'Please enter a sender name in the "From" field.')&&a.CSValidateRequiredField(i,'Please enter a recipient in the "To" field.')&&a.CSValidateRequiredField(l,"Please enter a Subject.")&&a.CSValidateRequiredField(e,"Please enter a message body.")&&jsrsExecuteWithErrorP("Admin2_SendInvoiceEmail2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Sending email",{invoiceId:t.invoiceId,emailTemplateId:n.id,fromName:r.value,recipient:i.value,subject:l.value,body:e.value}):showInfoDialog("Please select an email template","No Email Template Selected",1,"cboTemplate")}function updateEmailForTemplate(){var e=getObj("frmEmail"),t=getEmailTemplateSelectionOption(e);e&&(e.txtSubject.value=t.objET.subject,e.txtFromName.value=t.objET.fromName,e.txtBody.value=t.objET.body)}function rsCallbackGetInfoToCreateInvoiceEmail(e,t){for(var a,o,t=t.originalOptions,n=e.arrEmailTemplates,i=n.length,r="frmEmail",l="",d=e.defaultEmailTemplateId,s="",u=0;u"+htmlEncode(a.name)+"";o="",i||(l+='',o=' selected="selected"'),s+=cdBuildReadOnlyFieldRowP({rawLabel:"Customer",rawValue:e.customerName})+cdBuildReadOnlyFieldRowP({rawLabel:"Database",rawValue:e.subdomain})+cdBuildReadOnlyFieldRowP({rawLabel:"Invoice #",rawValue:""+e.invoiceNumber}),e.resultMessage&&(s+=cdBuildReadOnlyFieldRowP({rawLabel:"Last Payment Result",rawValue:e.resultMessage+" (Code="+e.resultCode+")"})),s+=cdBuildReadOnlyFieldRowP({rawLabel:"Templates",valueHTML:'"})+'
'+cdBuildTextFieldRowP("txtFromName","From")+cdBuildTextFieldRowP("txtMessageRecipient","To",{isEmail:1,fieldValue:t.toEmailAddress||""})+cdBuildTextFieldRowP("txtSubject","Subject")+cdBuildTextAreaFieldRowP("txtBody","Body",{textAreaClasses:"largeTextArea"}),showDialogP(s,r,{formTitle:"Email",focusFieldName:"txtMessageRecipient",okButtonDisplayText:"Send",contextDetailOrFnSubmit:{fnSubmit:submitEmail,callbackData:{invoiceId:t.invoiceId}}}),updateEmailForTemplate(),forceRescanDialogForNewNodes(r)}function showComposeEmailForInvoiceDialog(e,t,a){jsrsExecuteWithErrorP("Admin2_GetInfoToCreateInvoiceEmail2",rsCallbackHandleStandardJSONResponse,"Retrieving Info to email about Invoice #"+t+"...",{invoiceId:e},{fnOnSuccess:rsCallbackGetInfoToCreateInvoiceEmail,invoiceId:e,toEmailAddress:a})}function buildBouncedEmailDetailRows(e){var t,a=e.length,o="";if(1==a)t=e[0],o='
")),showDialogP(l,"frmEmailDetails",{formTitle:"Sent Email Details",hideOkButton:1,dialogRowsTableClasses:"limitedFieldWidthDialog"}))}function showSentEmailDialog(e){jsrsExecute(rsCallbackDisplaySentEmailDialog,"Admin_GetSentEmailInfo",[e],hideTimedMessage),displayTimedMessage("Looking up sent email...")}function checkForBouncedEmails(){jsrsExecuteWithErrorP("Admin2_CheckForBouncedEmails",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Checking for bounced emails")}function jtcrmViewDatabaseDetails(e){g_bSkipNavWarning=!0,hidePicker(),disableDialogButtons(),displayTimedMessage("Loading Database..."),window.location=pageDatabaseDetail+e}function jtcrmViewAccountDetails(e){g_bSkipNavWarning=!0,hidePicker(),disableDialogButtons(),displayTimedMessage("Loading Account..."),window.location=pageCustomerDetail+e}function jtcrmViewInvoiceDetails(e){g_bSkipNavWarning=!0,hidePicker(),disableDialogButtons(),displayTimedMessage("Loading Invoice..."),window.location=pageInvoiceDetail+e}function jtcrmViewCreditMemoDetails(e){g_bSkipNavWarning=!0,hidePicker(),disableDialogButtons(),displayTimedMessage("Loading Credit Memo..."),window.location=pageCreditMemoDetail+e}function jtcrmViewPaymentDetails(e){g_bSkipNavWarning=!0,hidePicker(),disableDialogButtons(),displayTimedMessage("Loading Payment..."),window.location=pagePaymentDetail+e}function submitSearch(e){var t=new FormValidator,a=e.txtSearchText,o=a.value,e=e.cboSearchTarget,e=e?e.options[e.selectedIndex].value:"",e=pageSearch+"&target="+e+"&search="+mjt_EncodeURIComponent(escape(o));t.CSValidateRequiredField(a,"Please enter a value to search for.")&&(disableDialogButtons(),displayTimedMessage("Searching..."),g_bSkipNavWarning=!0,window.location=e)}function submitSearchFromDialog(){submitSearch(getObj("frmSearchDlg"))}function submitV2JTCRMSearchOnEnter(e,t){var a;if(window.event)a=window.event.keyCode;else{if(!e)return!0;a=e.which}return 13!=a||(submitSearch(getObj(t)),!1)}function quickBooksCustomerGetTypeAheadData(e,t){var a={expectedContextId:null,extraHTMLColumnIndex:2,isInactiveColumnIndex:3,inactiveMeansCompleteColumnIndex:4};a.expectedContextId=jsrsExecute(rsCallbackGetTypeAheadSearchText,"Admin_GetTopQuickbooksCustomerInfosGivenPrefix",[escape(t)],hideTimedMessage,a)}function searchGetTypeAheadData(e,t){var e=e.cboSearchTarget,a={expectedContextId:null,extraHTMLColumnIndex:2,isInactiveColumnIndex:3,inactiveMeansCompleteColumnIndex:4},e=e?e.options[e.selectedIndex].value:"";a.expectedContextId=jsrsExecuteWithErrorP("Admin2_GetTopSearchInfosGivenPrefix2",rsCallbackGetTypeAheadSearchTextJSON,"Retrieving Search Typeahead Info",{searchText:t,searchTargets:e},{idHolder:a,arrayPropertyName:"arrSearchResults",extraHTMLPropertyName:"extraHTML",skipDisableDialogButtons:1})}function searchHandleExplicitSelection(e,t){selectedSearchItemInTypeAhead(e,t)}function buildSearchAreaOption(e,t,a){return'"}function buildSecuredSearchOptions(e){var t="";return jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARRead)&&(t+=buildSearchAreaOption("Database",SearchSubjectAreas_Enum.ssjDatabase,e)+buildSearchAreaOption("Customer",SearchSubjectAreas_Enum.ssjCustomer,e)+buildSearchAreaOption("Invoice",SearchSubjectAreas_Enum.ssjInvoice,e)+buildSearchAreaOption("Braintree Customer Id",SearchSubjectAreas_Enum.ssjBillingCustomerProcessorId,e)),t}function showCRMSearchDialog(e,t){var a,o,n;isDialogShowing()||(n="frmSearchDlg",t='",o={formId:n,idFieldName:o=(a="txtSearchText")+".id",handlingEnter:1,stringifiedParams:'{ textFieldName: "'+a+'", formId: "'+n+'", idFieldName: "'+o+'", fnGetTypeAheadData: searchGetTypeAheadData, fnHandleExplicitSelection: searchHandleExplicitSelection}'},(n=new ClientDialogBuilder({formId:n,formTitle:"Search",focusFieldName:a,focusFieldOnMobile:1,suppressDialogConfirmer:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Search",mnemonicChar:"s",mnemonicActionJS:"submitSearchFromDialog()"}),fnSubmit:submitSearchFromDialog})).addTextFieldRow(a,{rawLabel:"Search For",fieldValue:e,typeaheadInfo:o,autofocus:1,suppressAutocomplete:1}),n.addFlexibleFieldRow({rawLabel:"Search In",valueHTML:t}),n.showClientDialog())}function showV2SearchDialog(){showCRMSearchDialog("","")}function fnAppOverrideDoKeyDown(e){if(g_lastUserActivityTime=new Date,g_enableKeyboardShortcuts){var t,a=!1;try{window.event?!window.event.altKey||window.event.ctrlKey||window.event.shiftKey?window.event.altKey||window.event.ctrlKey||window.event.shiftKey||27!=window.event.keyCode||(a=!0):t=window.event.keyCode:e&&(!e.altKey||e.ctrlKey||e.shiftKey?e.altKey||e.ctrlKey||e.shiftKey||27!=e.which||(a=!0):t=e.which)}catch(r){return}if(a&&"function"==typeof fnHandleEscapeKey)fnHandleEscapeKey();else if(t||a&&isDialogShowing()){var o=!0;if(isDialogShowing())if(a)g_clientDialogStack&&0p.length)return void showInfoDialog("Cannot specify more instances than there are datbase product ids. "+c+" instances specified but only "+p.length+" instance(s) on the invoice","Too Many Instances",1,"btnOk");for(var b=0;b"+padAndPrefixSignedDollars(d)+" and the invoice is for "+padAndPrefixSignedDollars(n)+". Are you sure this is what you want?","Confirm Create Credit Memo",{},!0,null,"Create Credit Memo"):r.length?jsrsExecuteWithErrorP("Admin2_CreateCreditMemo2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Creating Credit Memo",{invoiceId:t,creditMemoNumber:i,creditMemoDate:getDateForUrlParam(e.dtCreditMemoDate.value),notes:cdGetExpandingTextFieldValue("txtNotes"),refundsJSON:JSON.stringify({arrRefunds:r})}):showInfoDialog("Please select a Product to refund","No Products Selected",1,"btnOk")}}else showInfoDialog("Please enter a Credit Memo Number","Missing Credit Memo Number",1,"txtCreditMemoNumber")}function updateNewBulkCreditMemoTotal(){for(var e=getObj("cellCreditMemoTotal"),t=0,a=0;o=getObj("chkRow"+t);){highlightOneCheckedRow(o);var o,n,i,r,l,d,s="chkRow"+t;o.checked&&(o=getObj(s+"-data-instances"),n=parseInt(o.value.trim(),10),i=getObj(s+"-data-amount"),r=getObj(s+"-database-product-ids").value.split(","),l=parseFloat(i.value.trim().substring(0)),s=getObj(s+"-data-total"),(!isNaN(n)&&!isNaN(l)||n<0||l<0)&&(d=l*n,s.innerHTML=padAndPrefixSignedDollars(""+d,1),a+=d,i.style.border="none",o.style.border="none"),(isNaN(l)||l<0)&&(i.style.border="solid 3px #FF0000",s.innerHTML=padAndPrefixSignedDollars("0",1)),isNaN(n)||n>r.length||n<0)&&(o.style.border="solid 3px #FF0000",s.innerHTML=padAndPrefixSignedDollars("0",1)),++t}e.innerHTML=padAndPrefixSignedDollars(a,1),e.setAttribute("data-total",a)}function updateNewCreditMemoTotal(){for(var e,t,a=getObj("cellCreditMemoTotal"),o=0,n=0;e=getObj("chkRow"+o);)highlightOneCheckedRow(e),e.checked&&(e=getObj("chkRow"+o+"data-amount"),t=parseFloat(e.value),!isNaN(t)||t<0?(n+=t,e.style.border="none"):e.style.border="solid 3px #ff0000"),++o;a.innerHTML=padAndPrefixSignedDollars(n,1),a.setAttribute("data-total",n)}function writeInvoiceProduct(e,t,a){var o=t.refundedAmount?"":' checked="checked"',n=t.refundedAmount?" disabled ":"",i="chkRow"+a,r=t.refundedAmount||t.productInvoicedPrice,l=t.refundedAmount?"disabledItem":a%2?"oddRow":"evenRow";return e+='
",t.addressesDiffer&&t.isHubspotCompanyValid?u+=buildChangeEntry("Database Address",t.actualAddressDisplayString,t.crmAddressDisplayString):t.isHubspotCompanyValid||(u+="Marking Hubspot Company Id as Invalid (update manually to fix)"),u=u+"
"+""}s.addFlexibleRow({valueHTML:u=u+"
"+""}),s.showClientDialog();e=getObj("chkCheckAllRows");e&&checkAllRows(e)}else showInfoDialog("There are currently no databases that require an update.","No Databases To Be Updated")}function synchHubspotPreview(){jsrsExecuteWithErrorP("Admin2_GetAllDatabasesRequiringSynch",rsCallbackGetAllDatabasesRequiringSynch,"Getting Databases Requiring An Update")}function rsCallbackDisplayAddUsersToInstancesResults(e){hideDialog();var t=e.results||[],a=t.length,o=e.instancesWithProductOrders,n=e.instancesWithInvoices,e=e.instancesWithChargedInvoices,i=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:"frmShowResultsOfAddingUsersToInstances",formTitle:"Add Users to Instances",fnCancelOrClose:function(){hideDialog(),refreshPageAndScrollPos()}}),r=new MWClientTable({}),a=(i.addFlexibleFieldRow({rawLabel:"Instances",rawValue:""+a}),i.addFlexibleFieldRow({rawLabel:"Product Orders (Created)",rawValue:""+o}),i.addFlexibleFieldRow({rawLabel:"Invoices (Created)",rawValue:""+n}),i.addFlexibleFieldRow({rawLabel:"Invoices (Charged)",rawValue:""+e}),i.addSectionHeaderRow({rawTitle:"Instances"}),r.addColumn(new MWColumn({columnName:"Customer",fnCustomRenderCellContents:function(e,t,a,o){return htmlEncode(e.instance.customerName)}})),r.addColumn(new MWColumn({columnName:"Database",fnCustomRenderCellContents:function(e,t,a,o){return htmlEncode(e.instance.subdomain)},fnBuildCellLinkDetail:function(e,t,a,o){return mwBuildSimpleLink(pageDatabaseDetail+e.instance.databaseId,1)}})),r.addColumn(new MWColumn({columnName:"Product Order Prorated Total",fnCustomRenderCellContents:function(e,t,a,o){return padAndPrefixSignedDollarsP({dollarValue:e.productOrderProratedTotal,forceDecimalsWhenNone:1})}})),r.addColumn(new MWColumn({columnName:"Unpaid Invoices Total",fnCustomRenderCellContents:function(e,t,a,o){return padAndPrefixSignedDollarsP({dollarValue:e.unpaidInvoicesTotal,forceDecimalsWhenNone:1})}})),r.addColumn(new MWColumn({columnName:"Status",fnCustomRenderCellContents:function(e,t,a,o){var n="Could not create Product Order";return e.chargedInvoices?n="Success":e.createdInvoices?n="Invoices Created but not Charged":e.createdProductOrders&&(n="Product Order Created but not Invoiced"),n}})),r.addColumn(new MWColumn({columnName:"Status Message",simpleDisplayColumnPropertyName:"statusMessage",simpleDisplayColumnNeedsMultilineEncoding:!0})),r.buildTableForArray(t));i.addFlexibleRow({valueHTML:a}),i.showClientDialog()}function confirmedAddUsersToSpecificInstances(e,t){var e=getListOfCheckedRowValuesWithParams({form:e,buildRCArray:1,minSelected:1,tooFewWarning:"Please select an Instance",clientDlgParams:{subdialogDismisalFocusFieldName:"chkCheckAllRows",subdialog:1},unescapeValues:1,fnTransformValueForArray:function(e){return JSON.parse(e)}}),a=e.arrValues;e.selectedCount&&jsrsExecuteWithErrorP("Admin2_AddAdditionalUsersToInstances",rsCallbackHandleStandardJSONResponse,"Adding Additional Users to Selected Instances",{arrInstancesWithAddedUsers:a},{fnOnSuccess:rsCallbackDisplayAddUsersToInstancesResults})}function rsCallbackGetInstancesWithAdditionalUsers(e){var t=e.instances||[],a=t.length,e=e.nextInvoiceDate,o="frmPromptAddUsersToInstances",n=new ClientDialogBuilder({dialogRowsTableClasses:"limitedFieldWidthDialog",formId:o,formTitle:"Add Users to Instances",focusFieldName:"btnOk",okButtonDisplayText:"Create & Pay Invoices",fnSubmit:confirmedAddUsersToSpecificInstances}),i=new MWClientTable({fnGetCheckDetailsForRow:function(e,t,a){return{value:htmlEncode(JSON.stringify(e))}}});a?(n.addFlexibleFieldRow({rawLabel:"Instances with additional users",rawValue:""+a}),e&&n.addFlexibleFieldRow({rawLabel:"Filtered to Next Invoice Date",rawValue:getLocalDateString(new Date(e))}),n.addSectionHeaderRow({rawTitle:"Instances To Update"}),i.addColumn(new MWColumn({columnName:"Customer",simpleDisplayColumnPropertyName:"customerName"})),i.addColumn(new MWColumn({columnName:"Database",simpleDisplayColumnPropertyName:"subdomain",fnBuildCellLinkDetail:function(e,t,a,o){return mwBuildSimpleLink(pageDatabaseDetail+e.databaseId,1)}})),(a=i.addColumn(new MWColumn({columnName:"Additional Users",additionalHeaderClasses:"centerAlign"}))).addSubColumn(new MWColumn({columnName:"CounterGo",simpleDisplayColumnPropertyName:"additionalCounterGoUserCount"})),a.addSubColumn(new MWColumn({columnName:"Inventory",simpleDisplayColumnPropertyName:"additionalNVInventoryUserCount"})),a.addSubColumn(new MWColumn({columnName:"Systemize",simpleDisplayColumnPropertyName:"additionalSystemizeUserCount"})),(e=i.addColumn(new MWColumn({columnName:"Last Change",additionalHeaderClasses:"centerAlign"}))).addSubColumn(new MWColumn({columnName:"Time",fnCustomRenderCellContents:function(e,t,a,o){e=new Date(e.lastChangeTime);return getLocalDateString(e)+" - "+getLocalTimeString(e)}})),e.addSubColumn(new MWColumn({columnName:"Hours",simpleDisplayColumnPropertyName:"stableAgeInHours"})),i.addColumn(new MWColumn({columnName:"Next Invoice Date",fnCustomRenderCellContents:function(e,t,a,o){e=new Date(e.nextInvoiceDate);return getLocalDateString(e)}})),a=i.buildTableForArray(t),n.addFlexibleRow({valueHTML:a}),n.showClientDialog(),(e=getObj(o))&&(e.chkCheckAllRows.checked=!0,checkAllRows(e.chkCheckAllRows))):showInfoDialog("There are currently no instances with additional users added outside the time period.","No Instances To Be Updated")}function addUsersToJTInstances(e){e=(e=e||{}).requireNextInvoiceDateBeTomorrow;jsrsExecuteWithErrorP("Admin2_GetInstancesWithAdditionalUsers",rsCallbackGetInstancesWithAdditionalUsers,"Getting Instances With Additional Users",{requireNextInvoiceDateBeTomorrow:e})}var InvoicePaymentOption_Enum={ipoOverall:1,ipoSingleInvoice:2};function submitMakePaymentOnInvoices(){var e=getObj("frmMakePaymentOnInvoices"),t=parseInt(getSelectedRBValue(e,"rbPaymentOption"),10)===InvoicePaymentOption_Enum.ipoOverall,e=getCallbackDataOfDialog(e),a=e.amountOutstanding,o=e.databaseBalanceInfo,n=e.invoiceId;hideDialog(),jsrsExecuteWithErrorP("Admin2_MakePaymentOnInvoices",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Making Payment",{billingProcessorCustomerId:e.billingProcessorCustomerId,databaseId:e.databaseId,amount:t?o.databaseBalance:a,arrInvoiceAmounts:t?o.arrInvoiceAmounts:[{invoiceId:n,amount:a}],paymentProviderType:PaymentProcessorType_Enum.pptBraintree})}function doPromptMakePaymentOnInvoices(e,t){enableDialogButtons();var t=t.originalPayload.invoiceId,a=e.databaseBalanceInfo,o=e.billingProcessorCustomerId,n=e.invoiceNumber,i=e.amountOutstanding,t=new ClientDialogBuilder({formId:"frmMakePaymentOnInvoices",formTitle:"Make Payment",focusFieldName:a?"rbPaymentOption_Overall":"",focusFieldOnMobile:1,suppressDialogConfirmer:1,okButtonDisplayText:"Make Payment",fnSubmit:submitMakePaymentOnInvoices,callbackData:{billingProcessorCustomerId:o,databaseId:e.databaseId,invoiceId:t,amountOutstanding:i,databaseBalanceInfo:a}});t.addFlexibleFieldRow({rawLabel:"Braintree Id",rawValue:o}),t.addFlexibleFieldRow({rawLabel:"Invoice #",rawValue:""+n}),t.addFlexibleFieldRow({rawLabel:"Invoice Total",rawValue:"$"+padDollars(e.invoiceTotal,1,0)}),e.amountPaid&&(t.addFlexibleFieldRow({rawLabel:"Amount Paid",rawValue:"$"+padDollars(e.amountPaid,1,0)}),t.addFlexibleFieldRow({rawLabel:"Amount Outstanding",rawValue:"$"+padDollars(e.amountOutstanding,1,0)})),t.addSectionHeaderRow(),a?(t.addRadioButtonRow({rawRowLabel:"Payment Amount:",labelHTML:'Total Balance: $'+padDollars(a.databaseBalance,1,1)+"",fieldName:"rbPaymentOption",fieldId:"rbPaymentOption_Overall",fieldValue:""+InvoicePaymentOption_Enum.ipoOverall,checked:!0}),t.addRadioButtonRow({labelHTML:'Just this invoice: $'+padDollars(i,1,1)+"",fieldName:"rbPaymentOption",fieldId:"rbPaymentOption_Invoice",fieldValue:""+InvoicePaymentOption_Enum.ipoSingleInvoice})):t.addFlexibleFieldRow({rawLabel:"Payment Amount",rawValue:"$"+padDollars(i,1,1),additionalRowClasses:"bold"}),t.showClientDialog()}function promptMakePaymentOnInvoices(e){jsrsExecuteWithErrorP("Admin2_GetInfoToPayInvoice",doPromptMakePaymentOnInvoices,"Retrieving Invoice Info To Make Payment",{invoiceId:e})}function toggleExpandAddressExtras(){var e=getObj("imgAddressExtrasExpander.expand"),t=!e.style.display;e.style.display=t?"none":"",getObj("imgAddressExtrasExpander.collapse").style.display=t?"":"none",getObj("divAddressExtras").style.display=t?"":"none"}function rsCallbackInitSession(e,t,a){enableDialogButtons(),checkResponseForError(e)&&window.open(a.url,"_blank")}function rsCallbackOpenedCustomerPortal(e,t,a){var o,n,i;enableDialogButtons(),checkResponseForError(e)&&((i=(e=JSON.parse(e)).error)?(n=i.errorMessage,o=i.errorTitle,i=i.requiresRefresh,showInfoDialogWithConsequenceP({formTitle:o,rawValue:n,fnConsequence:i?rsCallbackRefreshPageAndScrollPos:0})):(o=e.userId,n=e.url,i=e.sessionId,e="Initializing Session",jsrsExecute(rsCallbackInitSession,"Portal_InitSession",[o,escape(i)],rsErrorCallbackShowErrorDialogAndRefresh,{url:n,errorDialogTitle:"Error "+e},0,1,n),displayTimedMessage(e+"..."),disableDialogButtons()))}function launchCustomerPortal(e){var t="Connecting to Customer Portal...";jsrsExecute(rsCallbackOpenedCustomerPortal,"Admin_OpenCustomerPortal",[e],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+t},0,1),displayTimedMessage(t+"..."),disableDialogButtons()}function showPortalUsageReportOptions(){showInfoDialog("Options?
We don't need no stinkin' options!","TODO: showPortalUsageReportOptions()")}function rsCallbackShowDBsWithUngeneratedNonMonthlyTotals(e,t,n){var i;enableDialogButtons(),checkResponseForError(e)&&(i=JSON.parse(e),(e=new MWClientTable({noDataMessage:"No Databases With Ungenerated Invoices"})).addColumn(new MWColumn({columnName:"Customer",fnCustomRenderCellContents:function(e,t,a,o){return htmlEncode(e.database[0].gdCustomerName)}})),e.addColumn(new MWColumn({columnName:"Database",fnCustomRenderCellContents:function(e,t,a,o){var n=(n=e.database[0].gdSubdomainName)||"Non-Hosted DB (Id="+e.database[0].gdDatabaseId+")";return htmlEncode(n)},fnBuildCellLinkDetail:function(e,t,a,o){return mwBuildSimpleLink(pageDatabaseDetail+e.database[0].gdDatabaseId,1)}})),e.addColumn(new MWColumn({columnName:"Invoice Amount",fnCustomRenderCellContents:function(e,t,a,o){return padAndPrefixSignedDollars(e.amount,1)}})),e.addColumn(new MWColumn({columnName:"Invoice Date",fnCustomRenderCellContents:function(e,t,a,o){return getDateAsDisplayString(new Date(i[0].date))}})),e.addColumn(new MWColumn({columnName:"Term",fnCustomRenderCellContents:function(e,t,a,o){return n.Term}})),showInfoDialog(e.buildTableForArray(i),"Databases With Ungenerated Invoices"),scrollDialogIfNecessary("frmTmpMessage",1,1))}function showDBsWithUngeneratedNonMonthlyTotals(e,t){var a="Finding databases...";jsrsExecute(rsCallbackShowDBsWithUngeneratedNonMonthlyTotals,"Admin_GetDatabasesWithUngeneratedTotals",[e,t],rsErrorCallbackShowErrorDialogAndRefresh,{errorDialogTitle:"Error "+a,DayOfMonth:t,Term:e},0,1),displayTimedMessage(a+"..."),disableDialogButtons()}function registerChartPlugins(){Chart.plugins.register({afterDatasetsDraw:function(t,e){var o;t.data.showPointLabels&&(o=t.chart.ctx,t.data.datasets.forEach(function(a,e){e=t.getDatasetMeta(e);e.hidden||e.data.forEach(function(e,t){o.fillStyle="rgb(0, 0, 0)";o.font=Chart.helpers.fontString(12,"normal","arial, helvetica, sans-serif");t=a.data[t].toString(),o.textAlign="center",o.textBaseline="middle",e=e.tooltipPosition();o.fillText(t,e.x,e.y-6-5)})}))}})}function submitVoidPayment(e,t){jsrsExecuteWithErrorP("Admin2_PerformVoidPayment",refreshPageAndScrollPos,"Retrieving Payment Info for Void Payment...",{paymentId:t.paymentId,amount:t.amount})}function rsCallbackGetInfoForVoidPayment(e,t){t.originalPayload;t=new ClientDialogBuilder({formId:"frmConfirmVoidPayment",formTitle:"Void Payment",okButtonDisplayText:"Void Payment",fnSubmit:submitVoidPayment,callbackData:e});t.addFlexibleFieldRow({rawLabel:"Payment Timestamp",rawValue:e.strPaymentTS}),t.addFlexibleFieldRow({rawLabel:"Transaction Id",rawValue:e.transactionId}),t.addFlexibleFieldRow({rawLabel:"Amount",valueHTML:padAndPrefixSignedDollars(e.amount,1)}),t.showClientDialog()}function showCreateVoidingPaymentDialog(e){jsrsExecuteWithErrorP("Admin2_GetInfoForVoidPayment",rsCallbackGetInfoForVoidPayment,"Retrieving Payment Info for Void Payment...",{paymentId:e})}function submitRefundPayment(e,t){jsrsExecuteWithErrorP("Admin2_PerformRefundPayment",refreshPageAndScrollPos,"Retrieving Payment Info for Refund Payment...",{paymentId:t.paymentId,amount:t.amount})}function rsCallbackGetInfoForRefundPayment(e,t){var a=e.amount,o=new ClientDialogBuilder({formId:"frmConfirmRefundPayment",formTitle:"Refund Payment",okButtonDisplayText:"Refund Payment",fnSubmit:submitRefundPayment,callbackData:e});o.addFlexibleFieldRow({rawLabel:"Payment Timestamp",rawValue:e.strPaymentTS}),o.addFlexibleFieldRow({rawLabel:"Transaction Id",rawValue:e.transactionId}),o.addFlexibleFieldRow({rawLabel:"Amount",valueHTML:padAndPrefixSignedDollars(a,1)}),o.showClientDialog()}function showCreateRefundPaymentDialog(e){jsrsExecuteWithErrorP("Admin2_GetInfoForRefundPayment",rsCallbackGetInfoForRefundPayment,"Retrieving Payment Info for Refund Payment...",{paymentId:e})}function submitCreateCreditMemoRefund(){var e=getObj("frmRefund"),t=getCallbackDataOfDialog(e).creditMemoId,a=getSelectedRB(e,"rbPayment").getAttribute("data-paymentId"),e=e.txtRefundAmount,o={};(new FormValidator).CSValidateNumberFieldP({field:e,label:"Refund Amount",resultValueHolder:o})&&jsrsExecuteWithErrorP("Admin2_ProcessCreditMemoCredit",refreshPageAndScrollPos,"Processing Refund",{paymentId:a,creditMemoId:t,amount:o.rc})}function rsCallbackGetPaymentsForCreditMemoRefund(e,t){var t=t.originalPayload,a=e.creditMemoAmount,o=e.amountCredited,n=e.remainingAmount,e=e.arrPayments,i=e?e.length:0,r=i?e[0]:0,n=i?Math.min(n,r.amount):n,l=new MWClientTable({noDataMessage:"No Payments"}),t=new ClientDialogBuilder({formId:"frmRefund",formTitle:"New Refund",focusFieldName:i?"txtRefundAmount":"",okButtonDisplayText:"Process Refund",fnSubmit:submitCreateCreditMemoRefund,callbackData:{creditMemoId:t.creditMemoId}});i?(l.addColumn(new MWColumn({columnName:"Transaction Id",fnCustomRenderCellContents:function(e,t,a,o){return'"}})),l.addColumn(new MWColumn({columnName:"Timestamp",simpleDisplayColumnPropertyName:"paymentTS"})),l.addColumn(new MWColumn({columnName:"Amount",additionalCellClasses:"rightAlign",fnCustomRenderCellContents:function(e,t,a,o){return padAndPrefixSignedDollars(e.amount,1)}})),t.addFlexibleFieldRow({rawLabel:"Credit Memo Amount",rawValue:padAndPrefixSignedDollars(a,1)}),o&&t.addFlexibleFieldRow({rawLabel:"Amount Credited",rawValue:padAndPrefixSignedDollars(o,1)}),t.addSectionHeaderRow({rawTitle:"Payment"}),t.addFlexibleRow({valueHTML:l.buildTableForArray(e),hideRow:1==i}),1==i&&(t.addFlexibleFieldRow({rawLabel:"Payment Transaction Id",rawValue:r.transactionId}),t.addFlexibleFieldRow({rawLabel:"Timestamp",rawValue:r.paymentTS}),t.addFlexibleFieldRow({rawLabel:"Amount",rawValue:padAndPrefixSignedDollars(r.amount,1)})),t.addTextFieldRow("txtRefundAmount",{rawLabel:"Refund Amount ($)",fieldValue:padDollars(n,1)}),t.showClientDialog()):showInfoDialog("No payments available","No Payments")}function showCreateRefundDialog(e){jsrsExecuteWithErrorP("Admin2_GetPaymentsForCreditMemoRefund",rsCallbackGetPaymentsForCreditMemoRefund,"Getting Payments available for a refund",{creditMemoId:e})}function buildTaxStateSelectionDropdown(e,t,a){return'"}function doBuildTaxRateBatch(){var e=getObj("frmBuildTaxRateBatch").cboState,t=e.value;t?jsrsExecuteWithErrorP("Admin2_BuildTaxRateBatch",refreshPageAndScrollPos,"Building Tax Rate Batch",{state:t}):showInfoDialog("Please select a state","No State Selected",1,e.name)}function buildTaxRateBatch(e){var t="cboState",a=new ClientDialogBuilder({formId:"frmBuildTaxRateBatch",formTitle:"Build Tax Rate Batch",suppressDialogConfirmer:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Build Batch",mnemonicChar:"b",mnemonicActionJS:"doBuildTaxRateBatch()"}),fnSubmit:doBuildTaxRateBatch,focusFieldName:t});a.addFlexibleFieldRow({rawLabel:"State",valueHTML:buildTaxStateSelectionDropdown(e,t,"-Select a State-")}),a.showClientDialog()}function submitTaxRateReconciliationReportOptions(){var e=getObj("frmOptions"),t=new FormValidator,a=e.txtPageSize,o=trim(a.value),n=trim(e.cboState.value),i="";t.CSValidateIntegerField(a,"Page Size",!0,1,2e3)&&(o&&(i+="&pageSize="+o),n&&(i+="&state="+n),e.chkIncludeValidRows.checked&&(i+="&includeValidRows=1"),i=i&&i.substring(1),hideDialog(),window.location=pageTaxRateReconciliationReport+i)}function showTaxRateReconciliationReportOptions(e){var t="cboState",a=new ClientDialogBuilder({formId:"frmOptions",formTitle:"Report Options",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitTaxRateReconciliationReportOptions()"}),focusFieldName:t,focusFieldOnMobile:1,fnSubmit:submitTaxRateReconciliationReportOptions});a.addFlexibleFieldRow({rawLabel:"State",valueHTML:buildTaxStateSelectionDropdown(e.state,t,"-Any-")}),a.addFlexibleFieldRow({valueHTML:cdBuildCheckboxAndLabel("chkIncludeValidRows","chkIncludeValidRows","Include Valid Rows",e.includeValidRows)}),a.addSectionHeaderRow(),a.addTextFieldRow("txtPageSize",{rawLabel:"Rows per Page",fieldValue:""+(e.pageSize||""),maxLength:10,isNumber:1,suppressAutocomplete:1}),a.showClientDialog()}function submitEditAttachedFile(){var e=getObj("editAttachFile"),t=e.objectId.value,e=e.fileId.value;jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_UpdateAttachedFile",[t,e,escape(null)],enableDialogButtons),displayTimedMessage("Updating File..."),disableDialogButtons()}function confirmDeleteAttachedFile(e,t,a){promptConfirmDeleteFile(e,t,null,a,"Admin_DeleteAttachedFile",!0)}function submitAttachFile(){g_arrFileDragDropFileInfos.length?doUploadFiles(getObj("attachFile")):hideDialog()}function showAttachFile(e,t,a,o){o=new ClientDialogBuilder({formId:"attachFile",formTitle:"Attach File",formAction:pageUploadAttachedFile,focusFieldName:"fileName",isSubdialog:o?1:0,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Attach",mnemonicChar:"a",mnemonicActionJS:o||"submitAttachFile()"}),fnSubmit:o||submitAttachFile});o.addFileUploadRow({fileLimit:1,fileType:a,objectId:t,acceptContentTypeHint:"image/*, .pdf",uploadLabel:"Drag or paste file here"}),o.showClientDialog()}function deleteExpenseQuickbooksCustomer(e){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseQuickbooksCustomer",[e.expenseQuickbooksCustomerId],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting Quickbooks Vendor......"),disableDialogButtons()}function deleteExpenseVendor(e){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseVendor",[e.expenseVendorId],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting Expense Vendor......"),disableDialogButtons()}function deleteExpenseReport(e){jsrsExecuteWithErrorP("Admin2_DeleteExpenseReport",function(e){hideDialog(),window.location=pageExpenses},"Deleting Expense Report...",{expenseReportId:e.expenseReportId})}function deleteImporBlocklist(e){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseImportBlocklist",[e.expenseImportBlocklistId],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting from Import Blocklist......"),disableDialogButtons()}function confirmDeleteExpenseReport(e){displaySimpleConfirmationDialogP(deleteExpenseReport,'Are you sure you want to delete this Expense Report"?',{formTitle:"Delete Expense Report",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{expenseReportId:e}})}function confirmDeleteExpenseImportBlocklist(e,t){displaySimpleConfirmationDialogP(deleteImporBlocklist,'Are you sure you want to delete Import Blocklist entry "'+t+'"?',{formTitle:"Delete From Expense Import Blocklist",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{expenseImportBlocklistId:e}})}function confirmDeleteQuickbooksCustomer(e,t){displaySimpleConfirmationDialogP(deleteExpenseQuickbooksCustomer,'Are you sure you want to delete the Quickbooks Vendor "'+htmlEncode(t)+'"?',{formTitle:"Delete Quickbooks Vendor",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{expenseQuickbooksCustomerId:e}})}function confirmDeleteExpenseVendor(e,t){displaySimpleConfirmationDialogP(deleteExpenseVendor,'Are you sure you want to delete Vendor "'+htmlEncode(t)+'"?',{formTitle:"Delete Expense Vendor",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{expenseVendorId:e}})}function confirmDeleteExpenseReportDetail(e){var t=(t=getObj("txtSummary"))&&t.innerHTML;displaySimpleConfirmationDialogP(function(){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseReportDetail",[e],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting Expense Report Detail......"),disableDialogButtons()},'Are you sure you want to delete the Expense Report Detail "'+t+'"?',{formTitle:"Delete Expense Report Detail",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{expenseReportDetailId:e}})}function deleteExpenseType(e){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseType",[e.typeId],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting Expense Type......"),disableDialogButtons()}function confirmDeleteExpenseType(e,t){displaySimpleConfirmationDialogP(deleteExpenseType,'Are you sure you want to delete the type "'+t+'"?',{formTitle:"Delete Expense Type",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{typeId:e}})}function deleteExpenseTrip(e){jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_DeleteExpenseTrip",[e.tripId],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage("Deleting Expense Trip......"),disableDialogButtons()}function confirmDeleteExpenseTrip(e,t){displaySimpleConfirmationDialogP(deleteExpenseTrip,'Are you sure you want to delete the trip "'+htmlEncode(t)+'" trip?',{formTitle:"Delete Expense Trip",okButtonDisplayText:"Delete",isSubdialog:!0,contextDetail:{tripId:e}})}function submitaddOrUpdateExpenseTrip(){var e=getObj("addOrUpdateExpenseTrip"),t=e.txtLocation.value,a=e.year.value,o=e.cboMonth[e.cboMonth.selectedIndex].value,n=parseInt(a,10),i=e.tripId.value,e=e.chkIsDisabled.checked;""===t?showInfoDialog("Location is required","Missing Field",1,"txtLocation"):isNaN(n)||n<=2017?showInfoDialog("Year must be a whole number greater than 2017","Missing Field",1,"year"):(jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseTrip",[i,a,o,escape(t),e?1:0],enableDialogButtons),displayTimedMessage("Adding Trip......"),disableDialogButtons())}function getMonthOptionElements(e){for(var t="",a=(new Date,0);a<12;a++)t+=buildOptionHTML(new Date(2018,a).toLocaleString("en-us",{month:"long"}),a,e);return t}function addOrUpdateExpenseTrip(e,t,a,o,n,i){n=new ClientDialogBuilder({formId:"addOrUpdateExpenseTrip",formTitle:e?"Edit Trip":"Add Trip",focusFieldName:"year",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:e?"Save":"Add",mnemonicChar:e?"s":"a",mnemonicActionJS:"submitaddOrUpdateExpenseTrip()"}),fnSubmit:submitaddOrUpdateExpenseTrip,arrExtraHeaderButtons:e?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseTrip("+e+", unescape('"+escape(n)+"'))"})]:null});n.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),n.addFlexibleFieldRow({additionalValueCellClasses:"clsNarrowField",rawLabel:"Year",valueHTML:''}),n.addFlexibleFieldRow({rawLabel:"Month",valueHTML:'"}),n.addTextFieldRow("txtLocation",{rawLabel:"Name & Location",maxLength:80,fieldValue:o,additionalFieldCellClasses:"tripNameAndLocation"}),n.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:i,hideRow:!e}),n.showClientDialog()}function submitAddOrUpdateExpenseType(){var e=getObj("addOrUpdateExpenseType"),t=e.txtName.value,a=e.txtAccountingId.value,o=e.typeId.value,e=e.chkIsDisabled.checked;""===t?showInfoDialog("Name is required","Missing Field",1,"name"):""===a?showInfoDialog("Quickbooks Id is required","Missing Field",1,"txtAccountingId"):jsrsExecuteWithErrorP("Admin2_AddOrUpdateExpenseType2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,o?"Updating Expense Type":"Adding Expense Type",{expenseTypeId:o,expenseTypeName:t,quickbooksId:a,isDisabled:e?1:0})}function addOrUpdateExpenseType(e,t,a,o){var n=new ClientDialogBuilder({formId:"addOrUpdateExpenseType",formTitle:e?"Edit Expense Type":"Add Expense Type",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:e?"Save":"Add",mnemonicChar:e?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseType()"}),fnSubmit:submitAddOrUpdateExpenseType,arrExtraHeaderButtons:e?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseType("+e+", unescape('"+escape(t)+"'))"})]:null});n.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),n.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:t}),n.addTextFieldRow("txtAccountingId",{rawLabel:"Quickbooks Id",maxLength:80,fieldValue:a}),n.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:o,hideRow:!e}),n.showClientDialog()}function submitAddOrUpdateExpenseVendor(t,e,a){var o=getObj("frmExpenseVendor"),n=o.expenseVendorId.value,i=o.txtName.value,r=o.quickbooksCustomerId.value,l=o.txtQuickbooksCustomer.value,d=o.txtReason.value,s=o.cboAmexDescriptionMatchType[o.cboAmexDescriptionMatchType.selectedIndex].value,u=o.cboAmexAppearsOnStatementAsMatchType[o.cboAmexAppearsOnStatementAsMatchType.selectedIndex].value,c=o.txtAmexAppearsOnStatementAs.value,m=o.txtAmexDescription.value,p=o.cboType[o.cboType.selectedIndex].value,b=o.chkIsDisabled.checked,g=o.chkIsGeneric.checked,o=o.chkIncludeOnMemo.checked,C=n?"Updating Expense Vendor...":"Adding Expense Vendor...";if(!(r=!r&&a?a:r))return""===l?void showInfoDialog("Quickbooks Vendor is required","Missing Field",1,"year"):e?void displaySimpleConfirmationDialog(function(){jsrsExecute(function(e){checkResponseForError(e)&&(e=JSON.parse(e),submitAddOrUpdateExpenseVendor(t,!0,e.quickbooksCustomerId))},"Admin_AddOrUpdateExpenseQuickbooksCustomer",[null,l,0],rsErrorCallbackShowErrorDialog,{},0,1)},'The Quickbooks Vendor "'+htmlEncode(l)+'" does not exist. Do you want to create a new Quickbooks Vendor with this name?',"Create Quickbooks Vendor",{},1,null,"Create Quickbooks Vendor"):void jsrsExecute(function(e){checkResponseForError(e)&&(e=JSON.parse(e),r=e.quickbooksCustomerId),submitAddOrUpdateExpenseVendor(t,!0,r)},"Admin_GetQuickbooksVendorByName",[escape(l)],function(){});""===i?showInfoDialog("Name is required","Missing Field",1,"year"):""!==c&&""===u?showInfoDialog("You must specify a match type for Amex Appears on statement as","Missing Field",1,"year"):""!==m&&""===s?showInfoDialog("You must specify a match type for Amex Description","Missing Field",1,"year"):(""!==u&&""===c&&(u=""),""!==s&&""===m&&(s=""),jsrsExecute(function(e,t,a){var o,n,i,r=getObj("frmApproveExpense");isDialogShowing()&&r?(o=(n=JSON.parse(e)).expenseVendorId,n=n.expenseVendorName,(i=document.createElement("option")).value=o,i.innerHTML=n,i.selected=!0,r.cboVendor.appendChild(i),hideTimedMessage(),hideSubdialog(),enableDialogButtons()):rsCallbackRefreshPageAndScrollPos(e)},"Admin_AddOrUpdateExpenseVendor",[n,i,r,s,escape(m),u,escape(c),p,d,o?1:0,b?1:0,g?1:0],enableDialogButtons),displayTimedMessage(C+"..."),disableDialogButtons())}function submitAddOrUpdateQuickbooksCustomer(){var e=getObj("addOrUpdateQuickbooksCustomer"),t=e.expenseQuickbooksCustomerId.value,a=e.txtName.value,e=e.chkIsDisabled.checked,o=t?"Updating Quickbooks Vendor...":"Adding Quickbooks Vendor...";""===a?showInfoDialog("Name is required","Missing Field",1,"year"):(jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseQuickbooksCustomer",[t,a,e?1:0],rsErrorCallbackShowErrorDialog,{},0,1),displayTimedMessage(o+"..."),disableDialogButtons())}function addOrUpdateQuickbooksCustomer(e,t,a){var o=new ClientDialogBuilder({formId:"addOrUpdateQuickbooksCustomer",formTitle:e?"Edit Quickbooks Vendor":"Add Quickbooks Vendor",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:e?"Save":"Add",mnemonicChar:e?"s":"a",mnemonicActionJS:"submitAddOrUpdateQuickbooksCustomer()"}),fnSubmit:submitAddOrUpdateQuickbooksCustomer,arrExtraHeaderButtons:e?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteQuickbooksCustomer("+e+", unescape('"+escape(t)+"'))"})]:null});o.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),o.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:t}),o.addCheckboxRow("chkIsDisabled",{labelHTML:"Disabled",checked:a,hideRow:!e}),o.showClientDialog()}function editExpenseReport(t){var e=new ClientDialogBuilder({formId:"exitExpenseReport",formTitle:"Edit Expense Report",focusFieldName:"null",arrExtraHeaderButtons:t.expenseReportId?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseReport("+t.expenseReportId+")"})]:null,fnSubmit:function(e){e=e.cboPayableTo[e.cboPayableTo.selectedIndex].value;jsrsExecuteWithErrorP("Admin2_UpdateExpenseReport",function(e){hideDialog(),refreshPageAndScrollPos()},"Updating Expense Report...",{expenseReportId:t.expenseReportId,payableToVendor:parseInt(e,10),vendorId:null})}}),a=t.vendorName||"Vendor",o=t.payableToVendor?1:0,a=buildOptionHTML(htmlEncode(t.userName),0,o)+buildOptionHTML(htmlEncode(a),1,o);e.addFlexibleFieldRow({rawLabel:"Payable To",valueHTML:'",additionalCellClasses:"clsVeryNarrowField"}),e.showClientDialog()}function showAddOrUpdateExpenseVendor(e){var t=e.expenseVendorId,a=e.arrExpenseTypes,o=e.expenseVendorName,n=e.quickbooksCustomerName,i=e.quickbooksCustomerId,r=e.amexDescriptionMatchType,l=e.amexDescription,d=e.amexAppearsOnStatementAsMatchType,s=e.amexAppearsOnStatementAs,u=e.reason,c=e.includeOnMemo,m=e.isDisabled,e=e.isGeneric,p="frmExpenseVendor",b=new ClientDialogBuilder({formId:p,formTitle:t?"Edit Expense Vendor":"Add Expense Vendor",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:t?"Save":"Add",mnemonicChar:t?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseVendor()"}),fnSubmit:submitAddOrUpdateExpenseVendor,arrExtraHeaderButtons:t?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseVendor("+t+", unescape('"+escape(o)+"'))"})]:null}),i=(b.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),{formId:p,idFieldName:"quickbooksCustomerId",handlingEnter:1,initialValue:i,stringifiedParams:'{ textFieldName: "txtQuickbooksCustomer", formId: "'+p+'", idFieldName: "quickbooksCustomerId", fnGetTypeAheadData: quickBooksCustomerGetTypeAheadData, fnHandleExplicitSelection: function(){}}'});b.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:o}),b.addDialogInteriorRows(cdBuildTextFieldRowP("txtQuickbooksCustomer","Quickbooks Vendor",{fieldValue:n,typeaheadInfo:i,autofocus:1,suppressAutocomplete:1})),b.addCheckboxRow("chkIncludeOnMemo",{labelHTML:"Include Amex Vendor On Memo",checked:c}),b.addCheckboxRow("chkIsGeneric",{labelHTML:"Generic",checked:e}),b.addCheckboxRow("chkIsDisabled",{hideRow:!t,labelHTML:"Disabled",checked:m}),b.addSectionHeaderRow(),JTCRMExpense.addExpenseTypeDropdown({cdBuilder:b,rawLabelOverride:"Default Type",mnemonicForLabelOverride:"t",arrExpenseTypes:a}),b.addTextFieldRow("txtReason",{rawLabel:"Default Reason",maxLength:80,fieldValue:u}),b.addFlexibleFieldRow({labelHTML:"Amex Description",valueHTML:' '}),b.addFlexibleFieldRow({labelHTML:"Amex Appears On Statement As",valueHTML:' '}),b.showClientDialog()}function showEditExpenseVendorDialog(e){jsrsExecuteWithErrorP("Admin2_GetExpenseVendorInfo",rsCallbackHandleStandardJSONResponse,"Retrieving Vendor Info",{expenseVendorId:e,includeExpenseTypes:1},{fnOnSuccess:showAddOrUpdateExpenseVendor})}function getUseTaxYearBoundaries(){return{useTaxYearMinimum:2018,useTaxYearMaximum:(new Date).getYear()+1900}}function submitCreateExpenseReport(){jsrsExecuteWithErrorP("Admin_CreateExpenseReport",function(e){e=e.id;window.location=pageExpenseReportDetail+e},"Creating Expense Report...",{})}function doDeleteExpenseReportImage(e){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:e.fileId,expenseReportDetailId:e.expenseReportDetailId})}function confirmDeleteExpenseReportDetailReceiptImage(e){var t=e.fileId;displaySimpleConfirmationDialog(doDeleteExpenseReportImage,'Are you sure you want to remove the receipt "'+e.fileName+'" from this Expense Report Detail?',"Delete Expense Report Detail Image",{fileId:t,expenseReportDetailId:e.expenseReportDetailId},1)}function submitReordeExpenseTypesDialog(e){submitReorderP({arrReorderedIds:e,reorderCommandName:"Admin2_ReorderExpenseTypes2",reorderIdsPropertyName:"expenseTypeIds",reorderObjectName:"Expense Types"})}function showReorderExpenseTypesDialog(e,t){rsCallbackGetObjectsForReorder({types:t},{originalOptions:{arrayAttrName:"types",fnSubmit:submitReordeExpenseTypesDialog,strReorderWhat:"Expense Types",highlightedId:e}})}function submitExpenseOptions(){var e=getObj("frmOptions"),t=pageExpenses,a=e.cboExpenseViewOptions[e.cboExpenseViewOptions.selectedIndex].value,o=e.cboAmexDescriptionMatchType[e.cboAmexDescriptionMatchType.selectedIndex].value,n=e.txtAmexDescription.value,i=getUrlParamValueIfThere(""+window.location,"sort");i&&(t+="&sort="+i),t+="&expenseViewType="+a,a===""+ExpensesSummaryViews_Enum.esvAll&&(t+="&daysBack="+e.txtDaysBack.value),n&&0'+i+""}),n.addTextFieldRow("txtDaysBack",{rawLabel:"Days Back",fieldValue:e,isNumber:1,hideRow:o!==ExpensesSummaryViews_Enum.esvAll}),n.addFlexibleFieldRow({labelHTML:"Amex Vendor",valueHTML:''}),n.showClientDialog()}function toggleExpandExpenseInfoExtras(){var e=getObj("imgExpenseInfoExtrasExpander.expand"),t=getObj("imgExpenseInfoExtrasExpander.collapse"),a=document.querySelectorAll(".expense-details");"none"===t.style.display?(e.style.display="none",t.style.display="inline",a.forEach(function(e,t,a){e.style.display="table-cell"})):(e.style.display="inline",t.style.display="none",a.forEach(function(e,t,a){e.style.display="none"}))}function doSubmitExpenseForApproval(e){jsrsExecute(function(){hideDialog(),window.location=pageExpenses},"Admin_SubmitExpenseOrExpenseReportForApproval",[e.expenseId,e.expenseType],rsErrorCallbackShowErrorDialogAndRefresh,null,null,!0),displayTimedMessage("Submitting for approval......"),disableDialogButtons()}function expenseTypeNameFromId(e){return e===EventObjectType_Enum.eotExpense?"Expense":"Expense Report"}function confirmSubmitExpenseForApproval(e,t){displaySimpleConfirmationDialog(doSubmitExpenseForApproval,"Are you sure you want to submit this "+expenseTypeNameFromId(t)+" for approval?
Once submitted for approval you will not be able to make further changes.","Submit "+expenseTypeNameFromId(t)+" For Approval",{expenseId:e,expenseType:t})}function submitUpdateExpenseOrExpenseReport(e,t,a,o,n,i){jsrsExecuteWithErrorP("Admin2_UpdateApprovalState",i,"Updating Approval Status",{id:e,type:t,status:a,reason:o,vendor:n})}function submitRejectExpense(){var e=getObj("rejectExpense"),t=e.id.value,a=e.type.value,e=e.txtRejectionReason.value;""===e?showInfoDialog("A reason must be supplied when rejecting an expense","Missing Field",1,"txtRejectionReason"):submitUpdateExpenseOrExpenseReport(t,a,Expense_Approval_Status_Enum.easRejected,e,null,function(){hideDialog(),window.location=pageExpenseApprovals})}function submitApproveExpenseReport(e,t){submitUpdateExpenseOrExpenseReport(e,t,Expense_Approval_Status_Enum.easApproved,null,null,function(){hideDialog(),window.location=pageExpenseApprovals})}function submitApproveExpense(){var e=getObj("frmApproveExpense"),t=e.id.value,a=e.type.value,o=e.cboVendor?e.cboVendor[e.cboVendor.selectedIndex].value:null;""===o&&e.cboVendor?showInfoDialog("A vendor must be supplied when approving an expense","Missing Field",1,"txtRejectionReason"):submitUpdateExpenseOrExpenseReport(t,a,Expense_Approval_Status_Enum.easApproved,"",o,function(){hideDialog(),window.location=pageExpenseApprovals})}function submitUnapproveExpense(e){submitUpdateExpenseOrExpenseReport(e.id,e.type,Expense_Approval_Status_Enum.easWaitingForApproval,"",null,function(){hideDialog(),window.location=pageExpenseApprovals})}function unapproveExpense(e,t){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:e,type:t}})}function rejectExpense(e,t){var a=new ClientDialogBuilder({formId:"rejectExpense",formTitle:"Reject Expense",focusFieldName:"txtRejectionReason",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"submitRejectExpense()"}),fnSubmit:submitRejectExpense,arrExtraHeaderButtons:null});a.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),a.addTextFieldRow("txtRejectionReason",{rawLabel:"Rejection Reason",maxLength:256,fieldValue:""}),a.showClientDialog()}function promptApproveExpenseReport(e,t){displaySimpleConfirmationDialogP(function(){hideDialog(),submitApproveExpenseReport(e,t)},"Are you sure you want to approve the Expense Report?",{formTitle:"Approve Expense Report",okButtonDisplayText:"Approve"})}function approveExpense(e){if(e.expenseType!==EventObjectType_Enum.eotExpenseReport||e.payableToVendor){for(var t={arrExpenseTypes:JSON.parse(e.types),expenseVendorName:e.description,amexDescriptionMatchType:0,amexDescription:e.description,amexAppearsOnStatementAsMatchType:0,amexAppearsOnStatementAs:e.appearsOnStatementAs,expenseType:e.defaultVendorTypeId,reason:e.defaultReason},t=new ClientDialogBuilder({formId:"frmApproveExpense",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(t))+")"})]}),a=(t.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),buildOptionHTML("","",!1)),o=0;o'+a+""}),t.showClientDialog()}else promptApproveExpenseReport(e.id,e.expenseType)}function rsCallbackResolveApprovalError(e,t,a){checkResponseForError(e)&&(hideDialog(),window.location=pageExpenses)}function submitResolveApprovalError(e){jsrsExecute(rsCallbackResolveApprovalError,"Admin_ResolveExpenseError",[e.id,e.type],rsErrorCallbackShowErrorDialogAndRefresh,null,null,!0),displayTimedMessage("Resolving Expense Issue......"),disableDialogButtons()}function resolveApprovalError(e,t){displaySimpleConfirmationDialog(submitResolveApprovalError,"Do you want to resolve the issue with this "+expenseTypeNameFromId(t)+"?
Resolving will re-submit the "+expenseTypeNameFromId(t)+" for approval.","Resolve Expense Error",{id:e,type:t})}function submitAddOrUpdateExpenseImportBlocklist(){var e=getObj("addOrUpdateExpenseImportBlocklist"),t=e.expenseImportBlocklistId.value,a=e.txtName.value,o=e.cboAmexDescriptionMatchType[e.cboAmexDescriptionMatchType.selectedIndex].value,n=e.cboAmexAppearsOnStatementAsMatchType[e.cboAmexAppearsOnStatementAsMatchType.selectedIndex].value,i=e.txtAmexAppearsOnStatementAs.value,e=e.txtAmexDescription.value,r=t?"Updating Expense Import Blocklist...":"Adding To Expense Import Blocklist...";""===a?showInfoDialog("Name is required","Missing Field",1,"year"):""!==i&&""===n?showInfoDialog("You must specify a match type for Amex Appears on statement as","Missing Field",1,"year"):""!==n&&""===i?showInfoDialog("You must specify a value for Appears On Statement As","Invalid Value",1,"year"):""!==e&&""===o||""!==o&&""===e?showInfoDialog("You must specify a match type for Amex Description","Missing Field",1,"year"):(jsrsExecute(rsCallbackRefreshPageAndScrollPos,"Admin_AddOrUpdateExpenseImportBlocklist",[t,a,o,escape(e),n,escape(i)],enableDialogButtons),displayTimedMessage(r+"..."),disableDialogButtons())}function addOrUpdateExpenseImportBlocklist(e,t,a,o,n,i){var r=new ClientDialogBuilder({formId:"addOrUpdateExpenseImportBlocklist",formTitle:e?"Edit Expense Import Blocklist":"Add To Expense Import Blocklist",focusFieldName:"txtName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:e?"Save":"Add",mnemonicChar:e?"s":"a",mnemonicActionJS:"submitAddOrUpdateExpenseImportBlocklist()"}),fnSubmit:submitAddOrUpdateExpenseImportBlocklist,arrExtraHeaderButtons:e?[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseImportBlocklist("+e+", unescape('"+escape(t)+"'))"})]:null});r.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),r.addTextFieldRow("txtName",{rawLabel:"Name",maxLength:80,fieldValue:t}),r.addFlexibleFieldRow({labelHTML:"Amex Description",valueHTML:''}),r.addFlexibleFieldRow({labelHTML:"Amex Appears On Statement As",valueHTML:''}),r.showClientDialog()}function setDatabaseCompanyAddressAsNeedsConfirmation(e){jsrsExecuteWithErrorP("Admin2_SetDatabaseCompanyAddressAsNeedsConfirmation",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating company address to require confirmation",{databaseId:e})}function confirmSetDatabaseCompanyAddressAsNeedsConfirmation(e){displaySimpleConfirmationDialog(setDatabaseCompanyAddressAsNeedsConfirmation,"Are you sure you want to prompt the user to review their company address?","Prompt User to Review Company Address",e,null,null,"Yes")}function setDatabaseContactAsNeedsConfirmation(e){jsrsExecuteWithErrorP("Admin2_SetDatabaseContactAsNeedsConfirmation",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating contact to require confirmation",{databaseContactId:e})}function confirmSetDatabaseContactAsNeedsConfirmation(e){displaySimpleConfirmationDialog(setDatabaseContactAsNeedsConfirmation,"Are you sure you want to prompt the user to review this contact?","Prompt User to Review Contact",e,null,null,"Yes")}function rsCallbackSentDunningEmails(e){var t,a=e.arrFailures,o=e.arrHandledInvoices,n=o?o.length:0,i=a?a.length:0,r=new ClientDialogBuilder({formTitle:"Sent Dunning Emails",fnCancelOrClose:function(){hideDialog(),saveScrollPos(),refreshPageShowingMessage()}});n&&(r.addSectionHeaderRow({rawTitle:1===n?"Processed 1 Invoice":"Processed "+n+" Invoice"}),(t=new MWClientTable({additionalTableClasses:"unsetTableWidth100"})).addColumn(new MWColumn({columnName:"Subdomain",simpleDisplayColumnPropertyName:"subDomainName"})),t.addColumn(new MWColumn({columnName:"Invoice #",simpleDisplayColumnPropertyName:"invoiceNumber"})),t.addColumn(new MWColumn({columnName:"Email Address",simpleDisplayColumnPropertyName:"targetEmailAddress"})),t.addColumn(new MWColumn({columnName:"DB Id",simpleDisplayColumnPropertyName:"databaseId"})),r.addFlexibleRow({valueHTML:t.buildTableForArray(o)})),i&&(r.addSectionHeaderRow({rawTitle:1===i?"1 Failure":i+" Failures"}),(t=new MWClientTable({additionalTableClasses:"unsetTableWidth100"})).addColumn(new MWColumn({columnName:"Error",simpleDisplayColumnPropertyName:"errorMessage",simpleDisplayColumnNeedsMultilineEncoding:1,additionalCellClasses:"errorText"})),t.addColumn(new MWColumn({columnName:"Subdomain",simpleDisplayColumnPropertyName:"subDomainName"})),t.addColumn(new MWColumn({columnName:"Invoice #",simpleDisplayColumnPropertyName:"invoiceNumber",additionalCellClasses:"rightAlign"})),t.addColumn(new MWColumn({columnName:"Email Address",simpleDisplayColumnPropertyName:"targetEmailAddress"})),t.addColumn(new MWColumn({columnName:"DB Id",simpleDisplayColumnPropertyName:"databaseId",additionalCellClasses:"rightAlign"})),r.addFlexibleRow({valueHTML:t.buildTableForArray(a)})),r.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"})}),r.addFlexibleRow({valueHTML:htmlEncode(JSON.stringify(e,null,2)),additionalCellClasses:"JSONViewer",rowId:"rowRawResults",hideRow:1}),r.showClientDialog()}function sendDunningEmails(){hideDialog(),jsrsExecuteWithErrorP("Admin2_SendDunningEmails",rsCallbackHandleStandardJSONResponse,"Sending Dunning Emails",{},{fnOnSuccess:rsCallbackSentDunningEmails})}function promptSendDunningEmails(e){var t=new ClientDialogBuilder({formTitle:"Send Dunning Emails",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Send Emails",mnemonicChar:"s",mnemonicActionJS:"sendDunningEmails()"}),fnSubmit:sendDunningEmails});t.addFlexibleRow({rawValue:"Are you sure you want to send the Dunning Emails?"}),t.showClientDialog()}function submitSalesByStateOptions(){var e,t=getObj("frmOptions"),a=pageSalesByState,o=parseInt(t.cboTimeSelection.value,10),n=t.txtPageSize,i=new FormValidator;i.CSValidateDateFieldP({field:t.dtStartDate,label:"Start Date",isNullable:!1})&&i.CSValidateDateFieldP({field:t.dtEndDate,label:"End Date",isNullable:!1})&&(e=getDateForUrlParam(t.dtStartDate.value),t=getDateForUrlParam(t.dtEndDate.value),e&&t&&parseDateString(t)
'+cdBuildFontIconElem({fontId:FontIconId_Enum.fiiRightChevron,terseFontIcon:1,fontIconElemId:"icoExpand"})+cdBuildFontIconElem({fontId:FontIconId_Enum.fiiDownChevron,terseFontIcon:1,fontIconElemId:"icoCollapse",hideIcon:1})+" Raw JSON
"}),i.addFlexibleRow({valueHTML:htmlEncode(JSON.stringify(e,null,2)),additionalCellClasses:"JSONViewer",rowId:"rowImportDisbursementResultsJson",hideRow:1}),i.showClientDialog()}function submitImportBTDisbursements(){var e=getObj("frmImport").dtDate;(new FormValidator).CSValidateDateField(e,"Date",!0,"dtDate")&&(e=getDateForUrlParam(e.value),jsrsExecuteWithErrorP("Admin2_ImportDisbursements",rsCallbackHandleStandardJSONResponse,"Importing Disbursements",{disbursementDate:e},{fnOnSuccess:rsCallbackImportDisbursements}))}function promptImportDisbursements(){var e="frmImport",t=new ClientDialogBuilder({formId:e,formTitle:"Import Disbursements",focusFieldName:"dtDate",fnSubmit:submitImportBTDisbursements,okButtonDisplayText:"Import"});t.addDatePickerRow(e,"dtDate",{rawLabel:"Payment Transaction Date"}),t.showClientDialog()}function submitUpdateDisbursementDate(){var e=getObj("frmEditDisbursementDate"),t=e.dtDate;(new FormValidator).CSValidateDateField(t,"Deposit Date",!1,"dtDate")&&jsrsExecuteWithErrorP("Admin2_UpdateBTDisbursementDate",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Disbursement Date",{disbursementDate:mjtElemData(e,"disbursementDate"),depositDate:getDateForUrlParam(t.value)})}function showEditDisbursementDateDialog(e){var t="frmEditDisbursementDate",a=e.disbursementDate,o=new ClientDialogBuilder({formId:t,formTitle:"Update Disbursement Date",focusFieldName:"dtDate",fnSubmit:submitUpdateDisbursementDate});o.addFlexibleFieldRow({rawLabel:"Disbursement Date",rawValue:a}),o.addDatePickerRow(t,"dtDate",{rawLabel:"Deposit Date",strValue:e.depositDate||""}),(t=o.showClientDialog())&&mjtElemData(t,"disbursementDate",a)}function submitUpdateDBTaxRate(){var e=getObj("frmLookupTaxRate"),t=mjtElemData(e,"databaseId"),e=mjtElemData(e,"matchingTaxCodeId");jsrsExecuteWithErrorP("Admin2_UpdateDBTaxInfo",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Updating Tax Info",{databaseId:t,taxRateId:e})}function buildRawAddressFromAddrObject(e){var t=e.street||"",a=trim(e.city||""),o=trim(e.state||""),n=trim(e.zip||""),e=trim(e.country||""),a=trim((a&&o?a+", "+o:a+o)+" "+n);return t+"\n"+(a&&e?a+"\n"+e:a+e)}function rsCallbackGetDBTaxInfo(e){hideDialog();var t,a=e.currentAddress||{},o=e.newDBTaxOptions,n=e.arrAPIMultiMatchMinInfos,i=n?n.length:0,r=e.currentTaxOptions,l=r&&r.taxRateId||0,d=o.singleMatchedTaxCode,s=d?d.nameMatchingTaxCodeId:0,l=s&&s!==l,o=o.taxWarningMessage,u=new ClientDialogBuilder({formId:"frmLookupTaxRate",formTitle:"Lookup Tax Rate",focusFieldName:"txtStreet",arrExtraHeaderButtons:[cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiEdit,doubleQuoteEncodedOnClickJS:"promptToUpdateTaxLookupAddress()",doubleQuoteEncodedTitle:"Change Lookup Address"})],okButtonDisplayText:l?cdBuildMnemonicLabelHTML({rawLabel:"Update Tax Rate",mnemonicChar:"u",mnemonicActionJS:"submitUpdateDBTaxRate()"}):null,fnSubmit:l?submitUpdateDBTaxRate:null});u.addFlexibleFieldRow({rawLabel:"Lookup Address",valueHTML:htmlMultilineEncode(buildRawAddressFromAddrObject(a)),valueCellId:"cellLookupAddress",additionalCellClasses:"topAlign"}),u.addSectionHeaderRow({rawTitle:"Tax Info"}),r&&(t='-None-',r.taxRateId&&(t=htmlEncode(r.taxRateName)+" ("+r.taxRatePercent+"%)"),u.addFlexibleFieldRow({rawLabel:"Current Tax Rate",valueHTML:t})),o&&u.addFlexibleFieldRow({rawLabel:"",valueHTML:htmlMultilineEncode(o),additionalValueCellClasses:"errorText"}),i&&u.addFlexibleFieldRow({rawLabel:"Multiple Matches",valueHTML:htmlEncode(JSON.stringify(n,null,2)),additionalValueCellClasses:"JSONViewer errorText",additionalCellClasses:"topAlign"}),s&&(r=l?cdBuildFontIconElem({fontId:FontIconId_Enum.fiiExclamationInFilledTriangle,terseFontIcon:1,additionalFontIconClasses:"warningIcon"}):cdBuildFontIconElem({fontId:FontIconId_Enum.fiiCheck,terseFontIcon:1,additionalFontIconClasses:"goodNewsIcon"}),t=l?'The tax rate will be updated':"There is no need to update the Tax Rate",o=htmlEncode(d.taxCodeName)+" ("+d.taxRatePercent+"%)",u.addFlexibleFieldRow({rawLabel:"New Tax Rate",valueHTML:r+" "+(o=l?''+o+"":o)+' ('+t+")",additionalCellClasses:"topAlign"})),(i=u.showClientDialog())&&(mjtElemData(i,"databaseId",e.databaseId),mjtElemData(i,"matchingTaxCodeId",s),mjtElemData(i,"lookupAddress",a))}function submitUpdateTaxLookupAddress(){var e=getObj("frmAddress"),t=getObj("frmLookupTaxRate"),t=mjtElemData(t,"databaseId");jsrsExecuteWithErrorP("Admin2_GetDBTaxInfo",rsCallbackHandleStandardJSONResponse,"Looking up Tax Info",{databaseId:t,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=getObj("frmLookupTaxRate"),e=mjtElemData(e,"lookupAddress"),t=new ClientDialogBuilder({formId:"frmAddress",formTitle:"Update Lookup Address",focusFieldName:"txtStreet",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Lookup Address",mnemonicChar:"l",mnemonicActionJS:"submitUpdateTaxLookupAddress()"}),fnSubmit:submitUpdateTaxLookupAddress});t.addTextFieldRow("txtStreet",{rawLabel:"Street",fieldValue:e.street||""}),t.addTextFieldRow("txtCity",{rawLabel:"City",fieldValue:e.city||""}),t.addTextFieldRow("txtState",{rawLabel:"State",fieldValue:e.state||""}),t.addTextFieldRow("txtZip",{rawLabel:"Zip",fieldValue:e.zip||""}),t.addTextFieldRow("txtCountry",{rawLabel:"Country",fieldValue:e.country||""}),t.showClientDialog()}function submitStopRetryingPayments(){var e=getObj("frmCeaseRetry"),e=mjtElemData(e,"databaseId");hideDialog(),jsrsExecuteWithErrorP("Admin2_SetAutomatedPaymentStatusPermanentFailure",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Marking Permanent Failure",{databaseId:e})}function showUpdateCustomerPaymentDate(e){var t=new ClientDialogBuilder({formId:"frmCeaseRetry",formTitle:"Temporarily Stop Retrying",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Stop Retrying",mnemonicChar:"s",mnemonicActionJS:"submitStopRetryingPayments()"}),fnSubmit:submitStopRetryingPayments});t.addFlexibleRow({valueHTML:"Are you sure you want to stop retrying payments until the next pay period?"}),(t=t.showClientDialog())&&mjtElemData(t,"databaseId",e)}function submitReconcileBTProfile(){var e=getObj("frmReconcile"),e=mjtElemData(e,"billingProcessorCustomerId");hideDialog(),jsrsExecuteWithErrorP("Admin2_ReconcileBTBillingProfile",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Reconciling Braintree Profile",{billingProcessorCustomerId:e})}function reconcileBTProfile(e){var t=new ClientDialogBuilder({formId:"frmReconcile",formTitle:"Reconcile Braintree Profile",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Reconcile",mnemonicChar:"r",mnemonicActionJS:"submitReconcileBTProfile()"}),fnSubmit:submitReconcileBTProfile});t.addFlexibleRow({rawValue:'Are you sure you want to reconcile billing id "'+e.billingProcessorCustomerId+'"?'}),(t=t.showClientDialog())&&mjtElemData(t,"billingProcessorCustomerId",e.billingProcessorCustomerId)}function submitUpdateDatabasePricingStructureDialog(){var e=getObj("frmUpdateDatabasePricingStructure"),t=new FormValidator,a=getDateForUrlParam(e.dtEffectiveDate.value),o=new Date,n=mjtElemData(e,"databasePricingStructureId");t.CSValidateDateFieldP({field:e.dtEffectiveDate,label:"Effective Date"})&&(o=new Date(o.getFullYear(),o.getMonth(),o.getDate()),(e=parseDateString(a))'+htmlEncode(e.pricingStructureName)+" "+htmlEncode(e.productTypeName)+" Effective "+cdCarefullyLocalizeDateValue(e.effectiveDate)+"","Remove Database Pricing Structure",{databasePricingStructureId:e.databasePricingStructureId})}function doShowUpdateDatabasePricingStructureDialog(e,t){var a="frmUpdateDatabasePricingStructure",o=e.pricingStructure,n=o.databasePricingStructureId,i=o.effectiveDate,r=o.productTypeName,o=o.pricingStructureName,t=t.originalPayload.subdomain,l="dtEffectiveDate",e=getNextInvoiceDateLink({nextInvoiceDate:cdCarefullyLocalizeDateValue(e.nextInvoiceInfo.nextInvoiceDate),formId:a,dateFieldId:l}),t={subdomain:t,pricingStructureName:o,productTypeName:r,effectiveDate:i,databasePricingStructureId:n},d=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),t=new ClientDialogBuilder({formId:a,formTitle:"Change Pricing Structure Effective Date",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Update",mnemonicChar:"u",mnemonicActionJS:"submitUpdateDatabasePricingStructureDialog()"}),fnSubmit:submitUpdateDatabasePricingStructureDialog,arrExtraHeaderButtons:[d?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedOnClickJS:"confirmRemoveDatabasePricingStructure(JSON.parse(unescape('"+escape(JSON.stringify(t))+"')))",doubleQuoteEncodedTitle:"Remove Database Pricing Structure"}):null,d?'':null,cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiBook,doubleQuoteEncodedTitle:"View Change Log",doubleQuoteEncodedOnClickJS:"carefullyDisplayDatabasePricingStructureEventLog("+n+")"})]});t.addFlexibleFieldRow({rawLabel:"Product Type",rawValue:r}),t.addFlexibleFieldRow({rawLabel:"Pricing Structure",rawValue:o}),t.addDatePickerRow(a,l,{rawLabel:"Effective Date",strValue:cdCarefullyLocalizeDateValue(i),strPostPickerHTML:e}),(d=t.showClientDialog())&&mjtElemData(d,"databasePricingStructureId",n)}function showUpdateDatabasePricingStructureDialog(e){jsrsExecuteWithErrorP("Admin2_GetDatabasePricingStructure",doShowUpdateDatabasePricingStructureDialog,"Getting Database Pricing Structure",e)}function submitMissingPricingStructureSelectionDialog(){var e=getObj("frmApplyPricingStructure"),t=new FormValidator,a=mjtElemData(e,"databaseId"),o=e.cboPricingStructure.options[e.cboPricingStructure.selectedIndex].value,o=""!==o?parseInt(o,10):null,n=getDateForUrlParam(e.dtEffectiveDate.value),a={databaseId:a,pricingStructureId:o,effectiveDate:parseDateString(n)};o?t.CSValidateDateFieldP({field:e.dtEffectiveDate,label:"Effective Date"})&&jsrsExecuteWithErrorP("Admin2_ApplyDatabasePricingStructure",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Applying Database Pricing Structure",a):showInfoDialog("Please select a pricing structure.","Select Pricing Structure",!0,"cboPricingStructure")}function doShowMissingPricingStructureSelectionDialog(e,t){var a="frmApplyPricingStructure",e=e.arrPricingStructures,o=t.originalPayload.productName,n=t.originalPayload.databaseId,i=t.originalPayload.productTypeId,i=parseInt(i,10),t=t.originalPayload.editionId,t=t?parseInt(t,10):null,r="cboPricingStructure",l="tdPricingStructure",d=buildDropdownRow({name:r,label:"Pricing Structure",valueLookup:"pricingStructureId",textLookup:"pricingStructureName",values:e,valueCellId:l}),s=new ClientDialogBuilder({formId:a,formTitle:"Select Pricing Structure",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitMissingPricingStructureSelectionDialog()"}),fnSubmit:submitMissingPricingStructureSelectionDialog});s.addFlexibleFieldRow({rawLabel:"Product",rawValue:o}),s.addDialogInteriorRows(d),s.addDatePickerRow(a,"dtEffectiveDate",{rawLabel:"Effective Date"}),(o=s.showClientDialog())&&(mjtElemData(o,"databaseId",n),refreshPricingStructureSelector({strFormId:a,selectedProductTypeId:i,selectedEditionId:t,arrPricingStructures:e,pricingStructureValueCellId:l,pricingStructureSelectorName:r}))}function showMissingPricingStructureSelectionDialog(e){jsrsExecuteWithErrorP("Admin2_GetPricingStructures",doShowMissingPricingStructureSelectionDialog,"Retrieving Pricing Structures",e)}function submitApplyDatabasePricingStructureSelectionDialog(){var e=getObj("frmApplyPricingStructure"),t=mjtElemData(e,"databaseId"),a=new FormValidator,o=getDateForUrlParam(e.dtEffectiveDate.value),n=new Date,i=e.cboPricingStructure.options[e.cboPricingStructure.selectedIndex].value;i?a.CSValidateDateFieldP({field:e.dtEffectiveDate,label:"Effective Date"})&&(n=new Date(n.getFullYear(),n.getMonth(),n.getDate()),(e=parseDateString(o))";for(t in e){var n=e[t];n.isDeprecated||(a!==n.productName&&(a!==undefined&&(o+=""),o+='"),'"}function doShowApplyDatabasePricingStructureSelectionDialog(e,t){var a="frmApplyPricingStructure",o=e.arrPricingStructures,t=t.originalPayload.databaseId,n="dtEffectiveDate",e=getNextInvoiceDateLink({nextInvoiceDate:cdCarefullyLocalizeDateValue(e.nextInvoiceInfo.nextInvoiceDate),formId:a,dateFieldId:n}),o=createPricingStructureSelector(o),i=new ClientDialogBuilder({formId:a,formTitle:"Select Pricing Structure",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"submitApplyDatabasePricingStructureSelectionDialog()"}),fnSubmit:submitApplyDatabasePricingStructureSelectionDialog});i.addFlexibleFieldRow({rawLabel:"Pricing Structure",valueHTML:o}),i.addDatePickerRow(a,n,{rawLabel:"Effective Date",strPostPickerHTML:e}),(o=i.showClientDialog())&&mjtElemData(o,"databaseId",t)}function showApplyDatabasePricingStructureSelectionDialog(e){jsrsExecuteWithErrorP("Admin2_GetPricingStructuresForSelection",doShowApplyDatabasePricingStructureSelectionDialog,"Retrieving Available Pricing Structures",e)}var JTCRMUtils=function(){function a(e,t){var a,o,n=e.upgradeDowngradeInfo,i=e.arrProducts,e=e.arrRestartProducts||[],t=t.originalPayload,r=(n||{}).arrProducts||[],l=r.length,d=t.productOrderId,s=[],u=new ContextMenu;if(l)for(var c,m=0,p=0,b={productOrderId:d,originalProductName:n.existingProductName},g=0;gIn what state is the use tax owed? ',rowId:i})}function R(e){var a=e.arrAllIdNames,t=e.arrSelectedIds||[];return a.filter(function(a){var e=!0;return e=a.isInactive?t.find(function(e){return""+a.id==""+e}):e}).map(function(e){return{id:e.id,name:e.name+(e.isInactive?" (Inactive)":"")}})}function I(){var e,a,t,i,n,o,l,d,s=getObj("addOrUpdateExpenseReportDetailOrBusinessReason"),r=getObj("txtSummary");r&&(s?(d=l=o=n="",e=[],s&&(a=s[u],t=s.cboTrip,i=s.cboType,n=(a||{}).value||"",o=t?t[t.selectedIndex].text:"",l=i?i[i.selectedIndex].text:"",d=ClientDialogModule.getCompoundSelectionDisplayValueForBase({form:s,fieldNameBase:b}),p()),l&&e.push(htmlEncode(l)),d&&e.push("("+htmlEncode(d)+")"),n&&e.push(htmlEncode(n)),""!==o&&e.push("for "+htmlEncode(o)),r.innerHTML=e.join(" ")):r.innerHTML="")}function C(e){var a=e.cdBuilder,e=e.selectedTripId,t=R({arrAllIdNames:g_arrTrips,arrSelectedIds:e?[e]:[]}),i=""+e,e=t.map(function(e){var a=""+e.id;return{cboValue:e.id,rawContent:e.name,isSelectedOption:a==i}}),t=ClientDialogModule.insertDropdownOption({arrOptions:e});a.addDropdown({fieldName:o,rawLabel:"Trip",onChangeJS:"JTCRMExpense.PROTECTED.formatSummary()",arrAvailableOptions:t})}function h(e){var a=e.cdBuilder,t=e.onChangeJS,i=R({arrAllIdNames:g_arrExpenseTypes,arrSelectedIds:e.selectedExpenseType?[e.selectedExpenseType]:[]}),n=e.rawLabelOverride,o=n||"Type",n=n?e.mnemonicForLabelOverride:"t",l=""+e.selectedExpenseType,e=i.map(function(e){var a=""+e.id;return{cboValue:e.id,rawContent:e.name,isSelectedOption:a==l}}),i=ClientDialogModule.insertDropdownOption({arrOptions:e});a.addDropdown({fieldName:x,rawLabel:o,mnemonicChar:n,onChangeJS:t,arrAvailableOptions:i})}function E(e){var a=e.form,e=e.resultValueHolder,a=ClientDialogModule.getCompoundSelectionValueForBase({form:a,fieldNameBase:b}),t=!!a;return e.participantIds=a,t||ClientDialogModule.showErrorMessageAndFocus({formTitle:"Missing Field",messageText:'At least one "Participant" is required',subdialogDismisalFocusFieldName:"participantSelect"}),t}function w(e){var a=e.form,e=e.resultValueHolder,t=a[u].value,i=t.length,a=a[o],a=a[a.selectedIndex].value,n=1;return e.tripId=a,e.reason=t,a||t?dMath.abs(f)&&(g='"Amount" must be less than the remaining expense amount of $'+Math.abs(f)):fAdd Trip",fontId:FontIconId_Enum.fiiPlusInCircle,doubleQuoteEncodedTitle:"Add Trip",doubleQuoteEncodedOnClickJS:"hideDialog(0, 0, 0, function() { window.location=pageExpenseTrips; });"})];t&&x.push(DialogHeaderDeleteButton.buildDialogHeaderDeleteButton({remoteScriptingFunctionName:"Admin2_DeleteBusinessReason2",deletePayload:{businessReasonId:e.expenseDetailId},rawButtonTitle:"Delete Business Reason",rawConfirmationMessageText:'Are you sure you want to delete the Business Reason,\n"'+m+'"?',displayNameOfObjectToDelete:"Business Reason",additionalButtonClasses:"textDialogButton"})),(e=new ClientDialogBuilder({formId:g,formTitle:t?"Edit Business Reason":"Add Business Reason",focusFieldName:"amount",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:t?"Save":"Add",mnemonicChar:t?"s":"a",mnemonicActionJS:"JTCRMExpense.PROTECTED.submitAddOrUpdateBusinessReason()"}),fnSubmit:v,arrExtraHeaderButtons:x})).addFlexibleFieldRow({rawLabel:"Amex Vendor",rawValue:u}),e.addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),m=(Math.abs(n||i)||"").toString(),e.addTextFieldRow("amount",{rawLabel:"Amount",mnemonicChar:"u",isNumber:1,fieldValue:m}),h({cdBuilder:e,onChangeJS:"JTCRMExpense.PROTECTED.formatSummary()",selectedExpenseType:o}),e.addCompoundSelectionFieldRowP({fieldNameBase:b,onChangeCode:"JTCRMExpense.PROTECTED.formatSummary()",whatSingular:"Participant",arrSelectedIds:d,arrObjects:f,fnRSCallSubstitute:function(){return{arrUsers:f}},objectArrayName:"arrUsers",simpleIdPropertyName:"id",simpleNameDisplayPropertyName:"name"}),A({cdBuilder:e,reason:s}),C({cdBuilder:e,selectedTripId:l}),D({objCDBuilder:e,salesTaxNotPaid:r,selectedState:c}),e.addSectionHeaderRow({rawTitle:"Summary"}),e.addFlexibleRow({valueHTML:''}),e.showClientDialog()&&setTimeout(function(){I()},0)},addOrUpdateExpenseReportDetail:function(e){var a=e.selectedType,t=e.amount,i=e.salesTaxNotPaid,n=e.state,o=e.selectedCategory,l=e.selectedUsers,d=R({arrAllIdNames:g_arrUsers,arrSelectedIds:l}),s=(t||"").toString(),r=[cdBuildFAFontIconButton({additionalButtonClasses:"textDialogButton",htmlContent:"Add Trip",fontId:FontIconId_Enum.fiiPlusInCircle,doubleQuoteEncodedTitle:"Add Trip",doubleQuoteEncodedOnClickJS:"hideDialog(0, 0, 0, function() { window.location=pageExpenseTrips; });"})];e.expenseReportDetailId&&r.push(cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,additionalButtonClasses:"textDialogButton",doubleQuoteEncodedTitle:"Delete",doubleQuoteEncodedOnClickJS:"confirmDeleteExpenseReportDetail("+e.expenseReportDetailId+")"})),(r=new ClientDialogBuilder({formId:"addOrUpdateExpenseReportDetailOrBusinessReason",formAction:pageUploadAttachedFile,formTitle:e.expenseReportDetailId?"Edit Expense Report Detail":"Add Expense Report Detail",focusFieldName:"Date",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:e.expenseReportDetailId?"Save":"Add",mnemonicChar:e.expenseReportDetailId?"s":"a",mnemonicActionJS:"JTCRMExpense.PROTECTED.submitAddOrUpdateExpenseReportDetail()"}),fnSubmit:c,fnCancelOrClose:function(){var e=0;"1"===getObj("receiptRemoved").value&&(e=1),hideDialogP({callback:function(){e&&refreshPageAndScrollPos()}})},arrExtraHeaderButtons:r})).addFlexibleFieldRow({rawLabel:"",hideRow:1,valueHTML:''}),r.addDatePickerRow(r.getFormId(),"Date",{rawLabel:"Expense Date",strValue:e.date}),r.addFlexibleFieldRow({rawLabel:"Amount",valueHTML:' IRS Mileage rates'}),h({cdBuilder:r,onChangeJS:"JTCRMExpense.PROTECTED.formatSummary();JTCRMExpense.PROTECTED.updateIRSMilageLink();",selectedExpenseType:a}),r.addCompoundSelectionFieldRowP({fieldNameBase:b,onChangeCode:"JTCRMExpense.PROTECTED.formatSummary()",whatSingular:"Participant",arrSelectedIds:l,arrObjects:d,fnRSCallSubstitute:function(){return{arrUsers:d}},objectArrayName:"arrUsers",simpleIdPropertyName:"id",simpleNameDisplayPropertyName:"name"}),A({cdBuilder:r,reason:e.reason}),C({cdBuilder:r,selectedTripId:o}),D({objCDBuilder:r,salesTaxNotPaid:i,selectedState:n}),s=(t={cdBuilder:r,fileId:e.fileId,fileAltText:e.fileAltText,fileIcon:e.fileIcon,fileName:e.fileName,expenseReportDetailId:e.expenseReportDetailId}).cdBuilder,a=t.fileId,l=t.fileName,o=t.expenseReportDetailId,t=' '+cdBuildFontIconElem({fontId:t.fileIcon})+"",o=ClientDialogModule.encodeFunction({functionName:"confirmDeleteExpenseReportDetailReceiptImage",functionParams:{fileId:a,fileName:l,expenseReportDetailId:o}}),s.addFlexibleFieldRow({labelHTML:"Receipt",rowId:"removeReceiptRow",hideRow:a?0:1,valueHTML:''+t+''+l+""+cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiHollowTrash,doubleQuoteEncodedTitle:"Delete Receipt Image",doubleQuoteEncodedOnClickJS:o})}),r.addFileUploadRow({fileLimit:1,fileType:15,objectId:e.expenseReportDetailId||-1,customLabel:"Receipt",rowId:"addReceiptRow",customAlign:"middleAlign",hideRow:e.fileId?1:0,acceptContentTypeHint:"image/*, .pdf"}),r.addSectionHeaderRow({rawTitle:"Summary"}),r.addFlexibleRow({valueHTML:''}),r.showClientDialog(),setTimeout(function(){I()},0)},addExpenseTypeDropdown:h,PROTECTED:{submitAddOrUpdateBusinessReason:v,toggleUseTaxStateCB:function(){var e=getObj(n),a=getObj(l),t=!e.checked;e.checked=t,p(),t&&setFocusIfFocusable(a)},formatSummary:I,updateIRSMilageLink:function(){var e,a=getObj("addOrUpdateExpenseReportDetailOrBusinessReason");a&&(e=getObj("irsMileageRatesLink"))&&(a=a.cboType?a.cboType[a.cboType.selectedIndex].text:"",e.style.display="Mileage"===a?"":"none")},submitAddOrUpdateExpenseReportDetail:c,submitAddOrUpdateExpenseReportDetailP:e,submitAddOrUpdateExpenseReportDetailWithoutReceiptCheck:g}}}();
function convertJobInfoToUpdateJobAndDBInfo(t){return{databaseId:t.databaseId,updateDeploymentServer:t.deploymentServerDiffers,updateBillingLink:t.billingLinkDiffers,updateServerDatabaseLink:t.serverDatabaseLinkDiffers,updateCGUserCount:t.cgUserCountDiffers,updateNVUserCount:t.nvUserCountDiffers,updateSysUserCount:t.sysUserCountDiffers,updateDatabaseAddress:t.addressesDiffer,requiresUpdateDueToEdition:t.requiresUpdateDueToEdition,actualCGUserCount:t.actualCGUserCount,actualNVUserCount:t.actualNVUserCount,actualSysUserCount:t.actualSysUserCount,actualEditionId:t.actualEditionId,jtListedJobAddress:t.CRMAddressDisplayString,jtAddress:t.addressesDiffer?t.jtAddress:0,updateCGActivityStatus:t.counterGoActivity.activityStatesDiffer,updateNVActivityStatus:t.nvInventoryActivity.activityStatesDiffer,updateSysActivityStatus:t.systemizeActivity.activityStatesDiffer,actualCGActivityStatusText:t.counterGoActivity.actualActivityStatusText,actualNVActivityStatusText:t.nvInventoryActivity.actualActivityStatusText,actualSysActivityStatusText:t.systemizeActivity.actualActivityStatusText}}
var JTCRMDatabase=function(){var s="frmDatabasesOptions",l="frmAssignDBToCustomer",i="cboCustomer",w="Subdomain Name",a=63,n="[^a-zA-Z0-9\\-]+",e="a-zA-Z0-9",r="^["+e+"].*["+e+"]$",f="frmEditDatabase";function t(e){var a,e=e.subdomainNameField,t=trim(e.value),o=new RegExp(n,"g"),o=t.match(o)||[],l=function(e){for(var a,t,o={},l=[],i=0;i'+e+"":e}).join(""),l=1===l.length?"character":"characters",d="";return o.length?d="Invalid "+l+' "'+i+'" in '+w+".":new RegExp(r,"g").test(t)||(d=w+" must start and end with an alpha-numeric character (a-z or 0-9)."),d?ClientDialogModule.showDialogWithConsequence({formTitle:"Invalid "+w,simpleRowContentHtml:'
'+d+"
",subdialogDismisalFocusFieldName:e.name,subdialogDismisalFocusFieldId:e.id}):a=1,a}function c(e){e=e.subdomainNameField;return(new FormValidator).ValidateTextField({textFieldElem:e,isRequiredField:1,maxTextLength:a,fieldDisplayName:w})&&t({subdomainNameField:e})}function d(){var e=getObj(s),a=new FormValidator,t=pageDatabases,o=e.txtPageSize,l="databaseListsort",i=getUrlParamValueIfThere(""+window.location,l),d={},n={},e=SummaryOptionsFilter.validateFilterDefinitionUrlParamValueFromForm({formId:e.id,resultValueHolder:n})&&a.CSValidateNumberFieldP({field:o,label:"Page Size",isNullable:1,maxDecimalPlaces:0,maxValue:2e3,resultValueHolder:d}),o=n.filterUrlParam;e&&(i&&(t+="&"+l+"="+i),o&&(t+="&"+SummaryOptionsFilter.combineUrlComponentsIntoFilterParam({fullyComposedUrlComponents:o})),d.rc&&(t+="&pagesize="+d.rc),hideDialog(),window.location=t,displayTimedMessage("Reloading page..."))}function b(e){hideDialog(),window.location=pageDatabaseDetail+e.id}function g(){var e=getObj("frmNewDB"),a=new FormValidator,t=e.txtCustomerName,o=e.txtCustomerId,o=o?o.value:"",l=e.txtSubdomainName,i=e.taxRateIdSelect,d=e.taxRateId,n=mjtElemData(e,"address"),d=d?d.value:i?i.value:"",s=e.cboSystemize.value,r="1"===e.cboCounterGo.value,u="1"===e.cboNVInventory.value,m=e.txtJobId?trim(e.txtJobId.value):"",e=e.txtHubspotCompanyId?trim(e.txtHubspotCompanyId.value):"";t&&!a.CSValidateRequiredField(t,"Please enter a Customer Name")||c({subdomainNameField:l})&&(i&&!d?showInfoDialog("Please select a tax rate.","Select Tax Rate",1,"taxRateIdSelect"):("0"===d&&(d=""),jsrsExecuteWithErrorP("Admin2_CreateCustomerAndDatabase",rsCallbackHandleStandardJSONResponse,"Creating Database",{customerId:o,customerName:trim(t?t.value:""),subdomain:trim(l.value),address:n,jobId:m,hubspotCompanyId:e,taxRateId:d,includeCGProduct:r?1:0,includeNVProduct:u?1:0,sysEditionId:s},{fnOnSuccess:b})))}function o(e){var a,e=e.hubspotInfo||[],t=e.displayAddress,o=e.address,l=e.customerId,i=e.customerName,d=e.newDBTaxOptions,n=e.hubspotCompanyId,s=e.email,e=JSON.parse(e.validationResults||"[]"),r=d.taxWarningMessage,u=d.webLinkToDetermineTaxRate,m=d.availableTaxRates,c=m?m.length:0,d=d.singleMatchedTaxCode,b=d?d.nameMatchingTaxCodeId:0,p="";if(e.isValid){var x,C,D=new ClientDialogBuilder({formId:"frmNewDB",formTitle:"New Database",focusFieldName:l?"txtSubdomainName":"txtCustomerName",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"JTCRMDatabase.PROTECTED.submitNewDatabase()"}),fnSubmit:g});if(D.addFlexibleFieldRow({rawLabel:"Hubspot Company Id",valueHTML:n+''}),D.addFlexibleFieldRow({rawLabel:"Address",valueHTML:htmlMultilineEncode(t||"")}),D.addFlexibleFieldRow({rawLabel:"Email",rawValue:s}),l?D.addFlexibleFieldRow({rawLabel:"Customer Name",valueHTML:htmlEncode(i)+''}):D.addTextFieldRow("txtCustomerName",{rawLabel:"Customer Name",fieldValue:i}),D.addTextFieldRow("txtSubdomainName",{rawLabel:w,fieldValue:void 0,strPreFieldHTML:"https://",strPostFieldHTML:".moraware.net"}),r&&D.addFlexibleFieldRow({rawLabel:"",valueHTML:htmlMultilineEncode(r),additionalValueCellClasses:"errorText"}),1',a=0;a"+htmlEncode(m[a].name)+""}p+="",d&&(p+=b?'
On lookup, found matching tax code "'+htmlEncode(d.taxCodeName)+'" with Rate='+d.taxRatePercent+"%
")}else p=0':'(No Tax Required)';D.addFlexibleFieldRow({rawLabel:"Tax Rate",valueHTML:p}),u&&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:'"}),(n=D.showClientDialog())&&mjtElemData(n,"address",o)}else x=(s={validationResults:e,displayAddress:t}).validationResults,C=htmlMultilineEncode(s.displayAddress||""),ClientDialogModule.showDialogWithConsequence({formTitle:"The Hubspot address is invalid",fnConstructDialog:function(e){e=e.cdBuilder;e.addFlexibleFieldRow({rawLabel:"Address",valueHTML:C,additionalCellClasses:"clsNarrowField"}),e.addFlexibleFieldRow({rawLabel:"Issue",rawValue:x.description,additionalCellClasses:"clsNarrowField"}),e.addFlexibleFieldRow({rawLabel:"Details",valueHTML:x.detailHtml}),e.addFlexibleFieldRow({rawLabel:x.tableLabel,valueHTML:x.tableHtml})}})}function u(){var e=getObj("frmNewDBFromHubspot"),a=e.txtCustomerId,e=e.txtHubspotCompanyId;if(!e.value)return!1;jsrsExecuteWithErrorP("Admin2_GetHubspotCompanyInfo",o,"Getting Hubspot Info",{hubspotCompanyId:trim(e.value),customerId:a?a.value:"",createMissingTaxCodeIfPossible:1})}function m(){var e=getObj(l),a=mjtElemData(e,"databaseId"),e=e[i],e=e.options[e.selectedIndex].value;hideDialog(),jsrsExecuteWithErrorP("Admin2_AssignDatabaseToCustomer2",rsCallbackHandleStandardJSONResponseWithHideAndRefresh,"Assigning Database to Customer",{databaseId:a,customerId:e})}function p(e,a){var e=e.arrCustomers,a=a.originalOptions,t=a.databaseId,o=a.customerId;e.length?(a={formElemData:{databaseId:t}},t=e.map(function(e){return{rawContent:e.name,cboValue:e.id,isSelectedOption:e.id===o}}),(e=new ClientDialogBuilder({formId:l,formTitle:"Assign Database To Customer",focusFieldName:i,focusFieldOnMobile:1,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"JTCRMDatabase.PROTECTED.submitAssignDBToCustomer()"}),fnSubmit:m})).addDropdown({fieldName:i,rawLabel:"Customer",mnemonicChar:"c",arrAvailableOptions:t,additionalCellClasses:"clsVeryNarrowField"}),e.showClientDialog(a)):showInfoDialog("There are no customers defined","No Customers")}function I(){var e=getObj(f),a=new FormValidator,t=(t=(t=e.cboTaxRate).options[t.selectedIndex].value)?JSON.parse(t):0,o=mjtElemData(e,"databaseId"),l=cdGetExpandingTextFieldValue("txtNotes"),t=t?t.id:"",i=e.txtDiscountPct,d=e.txtJobId,n=e.txtHubspotCompanyId,n=n?trim(n.value):null,s=c({subdomainNameField:e.txtSubdomain}),r=s&&a.CSValidateIntegerFieldP({field:d,label:"Job Id",isNullable:!1,minValue:1,suppressErrorMessage:!0});if(s){if(!r&&!n)return showErrorMessageAndFocus("Job Id and Hubspot Company Id cannot both be empty","Error saving database",d,{subdialog:1}),!1;i&&!a.CSValidateNumberField(i,"Discount %",!0)||(s={databaseId:o,subdomain:trim(e.txtSubdomain.value),jobId:trim(d.value),hubspotCompanyId:n,notes:l,discountPercent:i?trim(i.value):"",taxRateId:t,suppressAutoAddBillingUsers:e.chkSuppressAutoAdd.checked?1:0},jsrsExecuteWithErrorP("Admin2_UpdateDatabase",refreshPageAndScrollPos,"Updating Database",s))}}function x(e,a){var t,o,l,i=e.id,d=e.customerId,n=e.discountPct,s=e.taxRateId,r=e.arrTaxRates,u=e.addressState,m=e.taxRateState,c=e.subdomain,a=a.originalPayload.taxLookupAllowedForState,b=d?"txtSubdomain":"txtCustomerName",p=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARDelete),x=jtcrmHasAccess(JTCRMSecuredObject_Enum.soUnexportedDatabaseObjects,AccessRight_Enum.mjtARUpdate),p=[p?DialogHeaderDeleteButton.buildDialogHeaderDeleteButton({remoteScriptingFunctionName:"Admin2_DeleteDatabase",deletePayload:{databaseId:i},rawButtonTitle:"Delete Database",rawConfirmationMessageText:'Are you sure you want to delete the Database, "'+c+'"?',displayNameOfObjectToDelete:"Database",urlOnSuccess:d?pageCustomerDetail+d:pageDatabases}):null,cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiMoveTo,doubleQuoteEncodedTitle:"Assign To Other Customer",doubleQuoteEncodedOnClickJS:"JTCRMDatabase.PROTECTED.promptAssignDBToCustomer()"}),x&&a?cdBuildFAFontIconButton({fontId:FontIconId_Enum.fiiCheck,doubleQuoteEncodedTitle:"Lookup Tax Rate",doubleQuoteEncodedOnClickJS:"hideDialog();JTCRMDatabase.PROTECTED.promptLookupTaxRate("+htmlEncode(JSON.stringify({databaseId:i}))+")",htmlContent:"Tax"}):null],x=new ClientDialogBuilder({formId:f,formTitle:"Edit Database",okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Save",mnemonicChar:"s",mnemonicActionJS:"JTCRMDatabase.PROTECTED.submitEditDatabase()"}),focusFieldName:b,focusFieldOnMobile:1,arrExtraHeaderButtons:p,fnSubmit:I}),a=(d||x.addTextFieldRow("txtCustomerName",{rawLabel:"Customer Name",autofocus:1}),x.addTextFieldRow("txtSubdomain",{rawLabel:w,mnemonicChar:"b",fieldValue:c}),x.addTextFieldRow("txtJobId",{rawLabel:"Job Id",mnemonicChar:"j",fieldValue:(e.internalJobId||"")+"",maxLength:10,isNumber:1}),x.addTextFieldRow("txtHubspotCompanyId",{rawLabel:"Hubspot Company Id",mnemonicChar:"h",fieldValue:(e.hubspotCompanyId||"")+""}),{cdBuilder:x,arrTaxRates:r,selectedTaxRateId:s,taxRateState:m,state:u}),b=a.cdBuilder,C=a.arrTaxRates,D=a.selectedTaxRateId,T="";for(0!==C.length&&0!==D&&a.taxRateState===a.state||(T+=''),t=0;t"+htmlEncode(l.name)+" ("+l.percent+"%)";b.addFlexibleFieldRow({rawLabel:"Tax Rate",mnemonicChar:"t",mnemonicFocusFieldName:"cboTaxRate",valueHTML:'"}),x.addTextFieldRow("txtDiscountPct",{rawLabel:"Discount %",mnemonicChar:"u",fieldValue:""+(n||""),maxLength:10}),x.addCheckboxRow("chkSuppressAutoAdd",{rawLabel:"Don't Automatically Add Additional Users To Billing",checked:e.suppressAutoAddBillingUsers}),x.addExpandingTextFieldRows("txtNotes",{rawLabel:"Notes",mnemonicChar:"n",value:e.notes||""}),(p=x.showClientDialog())&&(mjtElemData(p,"databaseId",i),mjtElemData(p,"customerId",d))}return{showDatabasesOptionsDialog:function(e){var e=e.pageSize,a=s,t=new ClientDialogBuilder({formId:a,formTitle:"Databases Options",fnSubmit:d,focusFieldName:SummaryOptionsFilter.BUTTON_ID_ADD_FILTER,okButtonDisplayText:cdBuildMnemonicLabelHTML({rawLabel:"Apply",mnemonicChar:"a",mnemonicActionJS:"JTCRMUtils.PROTECTED.submitDatabasesOptions()"})}),o={},l={formElemData:o};JTCRMUtils.wireUpClientFilterRSCalls(),SummaryOptionsFilter.addFilterContainerRow({cdBuilder:t,formElemData:o,filterWhat:"Slabs"}),t.addDialogInteriorRows([buildPageSizeRow(e)]),t.showClientDialog(l)&&SummaryOptionsFilter.initializeDisplayedFilters({targetFormId:a})},showNewDatabaseFromHubspotDialog:function(e,a){var t=new ClientDialogBuilder({formId:"frmNewDBFromHubspot",formTitle:"New Database (Hubspot)",focusFieldName:"txtHubspotCompanyId",okButtonDisplayText:"Get Hubspot Company Info",fnSubmit:u});a&&e&&t.addFlexibleFieldRow({rawLabel:"Customer",valueHTML:htmlEncode(a)+''}),t.addTextFieldRow("txtHubspotCompanyId",{rawLabel:"Hubspot Company Id",additionalLabelCellClasses:"clsNarrowField"}),t.showClientDialog()},showEditDatabaseDialog:function(e){jsrsExecuteWithErrorP("Admin2_GetDatabaseInfo2",rsCallbackHandleStandardJSONResponse,"Getting Database Info for Edit",e,{fnOnSuccess:x})},PROTECTED:{submitDatabasesOptions:d,submitNewDatabase:g,submitEditDatabase:I,promptLookupTaxRate:function(e){jsrsExecuteWithErrorP("Admin2_GetDBTaxInfo",rsCallbackHandleStandardJSONResponse,"Looking up Tax Info",{databaseId:e.databaseId},{fnOnSuccess:rsCallbackGetDBTaxInfo})},promptAssignDBToCustomer:function(){var e=getObj(f),a=mjtElemData(e,"databaseId"),t=mjtElemData(e,"customerId");hideDialogP({callback:function(){jsrsExecuteWithErrorP("Admin2_GetCustomerNames2",rsCallbackHandleStandardJSONResponse,"Retrieving list of customers",{},{fnOnSuccess:p,databaseId:a,customerId:t||null})}})},submitAssignDBToCustomer:m}}}();