import { Component, OnInit, ViewChild } from "@angular/core"; import { Router, ActivatedRoute } from "@angular/router"; import { JwtHelper } from 'angular2-jwt'; import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; import { ReCaptchaComponent } from 'angular2-recaptcha/lib/captcha.component'; import { Subscription } from 'rxjs'; import { IApplication } from '../data/application.interface'; import { Constants } from '../../common/constants'; import { ICountry } from '../data/api/signupInfo/country.interface'; import { IDemographicAge } from '../data/demographicAge.interface'; import { IDemographicEducation } from '../data/demographicEducation.interface'; import { IDemographicRace } from '../data/demographicRace.interface'; import { IDollarVolume } from '../data/dollarVolume.interface'; import { IFrequencyTotalInfo } from '../data/api/signupInfo/frequencyTotalInfo.interface'; import { IInvoiceItemInfo } from '../data/api/signupInfo/invoiceItemInfo.interface'; import { IPrimaryActivity } from '../data/primaryActivity.interface'; import { ISecondaryActivity } from '../data/secondaryActivity.interface'; import { ISignupInfo } from '../data/api/signupInfo/signupInfo.interface'; import { IState } from '../data/api/signupInfo/state.interface'; import { ISubscriptionInvoiceInfo } from '../data/api/signupInfo/subscriptionInvoiceInfo.interface'; import { ISubscriptionRequest } from '../data/api/subscriptionRequest.interface'; import { ISubscriptionResponse } from '../data/api/subscriptionResponse.interface'; import { DemographicAgeService } from '../services/demographicAge.service'; import { DemographicEducationService } from '../services/demographicEducation.service'; import { DemographicRaceService } from '../services/demographicRace.service'; import { DollarVolumeService } from '../services/dollarVolume.service'; import { LocalStorageService } from 'angular-2-local-storage'; import { PaymentComponent } from '../../shared/components/payment.component'; import { PrimaryActivityService } from '../services/primaryActivity.service'; import { SecondaryActivityService } from '../services/secondaryActivity.service'; import { SignupInfoService } from '../services/api/signupInfo.service'; import { SubscriptionRequestService } from '../services/subscriptionRequest.service'; import { TitleService } from '../services/title.service'; import { ITitle } from '../data/title.interface'; @Component({ template: require('./template1.component.html'), styles: [require('./template1.component.css')] }) export class Template1Component implements OnInit { cardLogo @ViewChild(ReCaptchaComponent) captcha: ReCaptchaComponent; rxjsSubscription: Subscription; isBusy: boolean = false; isPrintPreview: boolean = false; constants = new Constants(); postUrl: string; jwtHelper: JwtHelper = new JwtHelper(); errorMessage: string; confirmApplicantLastName: string; confirmApplicantFirstName: string; submitResultSuccess: boolean = false; submittedForm: boolean = false; hideLineItems: string; groupName: string; groupTerms: string; primaryGroupEmail: string; primaryGroupPhone: string; header1: string; header2: string; logoUrl: string; signupTypeId: number; renewalSubscriptionLineageBroken: boolean; renewalSubscriptionInvoiceId: number; renewalSubscriptionLineageId: number; renewalSubscriptionOverride: boolean; clientSubscriberId: string; subscriptionTypeName: string; subscriptionInvoices: Array = new Array(); subscriptionResponse: ISubscriptionResponse; frequencyTotals: Array = new Array(); invoiceItems: Array = new Array(); applicantCountries: ICountry[]; applicantStates: IState[]; cardholderCountries: ICountry[]; cardholderStates: IState[]; companycountries: ICountry[]; companyStates: IState[]; demographicAges: IDemographicAge[]; demographicEducations: IDemographicEducation[]; demographicRaces: IDemographicRace[]; demographic_showOtherRaceOption: boolean = false; dollarVolumes: IDollarVolume[]; primaryActivities: IPrimaryActivity[]; secondaryActivities1: ISecondaryActivity[]; secondaryActivities2: ISecondaryActivity[]; signupInfo: ISignupInfo; signupForm: FormGroup; subscrptionAmount_annualTotal: number; subscrptionAmount_quarterlyTotal: number; subscrptionAmount_monthlyTotal: number; titles: ITitle[]; constructor( private _activatedRoute: ActivatedRoute, private _fb: FormBuilder, private _demographicAgeService: DemographicAgeService, private _demographicEducationService: DemographicEducationService, private _demographicRaceService: DemographicRaceService, private _dollareVolumeService: DollarVolumeService, private _localStorageService: LocalStorageService, private _primaryActivityService: PrimaryActivityService, private _secondaryActivityService: SecondaryActivityService, private _subscriptionRequestService: SubscriptionRequestService, private _signupInfoService: SignupInfoService, private _titleService: TitleService ) { } ngOnInit() { this.signupForm = this._fb.group({ hasAgreedToTerms: [false, Validators.pattern('true')], subscriptionInvoiceId: ['', [Validators.required]], frequencyId: ['', [Validators.required]], subscriptionTypeId: ['', [Validators.required]], firstName: ['', [Validators.required, Validators.maxLength(50)]], middleName: '', lastName: ['', [Validators.required, Validators.maxLength(50)]], email: ['', [Validators.required, Validators.maxLength(100), Validators.pattern(this.constants.emailRegex)]], fax: ['', [Validators.maxLength(100), Validators.pattern(this.constants.phoneRegex)]], phone: ['', [Validators.maxLength(12), Validators.pattern(this.constants.phoneRegex)]], suffix: '', title: '', titleOther: '', sponsoringName: '', sponsoringPin: '', sponsoringEmail: '', addressType: 'business', applicant_address1: ['', [Validators.required]], applicant_address2: '', applicant_country: ['USA', [Validators.required]], applicant_city: ['', [Validators.required]], applicant_state: ['', [Validators.required]], applicant_postalCode: ['', [Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]], companyName: ['', [Validators.required, Validators.maxLength(100)]], companyWebsite: '', company_country: ['USA', [Validators.required]], company_address1: ['', [Validators.required]], company_address2: '', company_city: ['', [Validators.required]], company_state: ['', [Validators.required]], company_postalCode: ['', [Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]], primaryActivity: ['', [Validators.required]], primaryActivity_other: '', secondaryActivity1: '', secondaryActivity1_other: '', secondaryActivity2: '', secondaryActivity2_other: '', demographic_singleFamilyUnits: '', demographic_multiFamilyUnits: '', demographic_dollarVolume: '', demographic_constructionEmployees: '', demographic_nonConstructionEmployees: '', demographic_age: '', demographic_race: [], demographic_ethnicity: '', demographic_gender: '', demographic_education: '', autoRenew: '', reCaptcha: ['', [Validators.required]], paymentMethod: this.initPaymentMethodFormGroup() }); this.rxjsSubscription = this._activatedRoute.queryParams.subscribe( (param: any) => { let ssc = param["Jwt"]; this._localStorageService.set('ssc', ssc); let decodedToken = this.jwtHelper.decodeToken(ssc); let subscriptionInvoiceLineageId: number = decodedToken.subscriptionlineageid; let isprintview: string = decodedToken.isprintview; if (isprintview && isprintview === "true") { this.isPrintPreview = true; } if (subscriptionInvoiceLineageId && subscriptionInvoiceLineageId > 0) { this.signupTypeId = 2; this.clientSubscriberId = decodedToken.clientsubscriberid; this.renewalSubscriptionLineageId = subscriptionInvoiceLineageId; } else { this.signupTypeId = 1; this.clientSubscriberId = null; this.renewalSubscriptionLineageId = null; } this._localStorageService.set('groupinfouri', decodedToken.groupinfouri); } ); //get data this.demographicAges = this._demographicAgeService.getAges(); this.demographicEducations = this._demographicEducationService.getEducations(); this.demographicRaces = this._demographicRaceService.getRaces(); this.dollarVolumes = this._dollareVolumeService.getDollarVolumes(); this.primaryActivities = this._primaryActivityService.getPrimaryActivities(); this.secondaryActivities1 = this._secondaryActivityService.getSecondaryActivities(); this.secondaryActivities2 = this._secondaryActivityService.getSecondaryActivities(); this._signupInfoService.get().subscribe( info => { this.signupInfo = info.SignupInfo; this.applicantCountries = this.signupInfo.BrandingInfo.Countries; this.applicantStates = this.signupInfo.BrandingInfo.States; this.cardholderCountries = this.signupInfo.BrandingInfo.Countries; this.cardholderStates = this.signupInfo.BrandingInfo.States; this.companycountries = this.signupInfo.BrandingInfo.Countries; this.companyStates = this.signupInfo.BrandingInfo.States; this.logoUrl = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "LogoUri")[0].Value; this.groupName = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "GroupName")[0].Value; this.groupTerms = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "GroupTerms")[0].Value; this.header1 = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "Heading1")[0].Value; this.header2 = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "Heading2")[0].Value; this.primaryGroupEmail = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "PrimaryEmail")[0].Value; this.primaryGroupPhone = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "PrimaryPhone")[0].Value; this.hideLineItems = this.signupInfo.BrandingInfo.Items.filter(item => item.Name === "HideLineItems")[0].Value; this.postUrl = info.Links.filter(item => item.Rel === "Subscription")[0].Url; let unsortedSubscriptionInvoices: Array = new Array(); for (let subscription of this.signupInfo.Subscriptions) { for (let invoice of subscription.SubscriptionInvoices) { unsortedSubscriptionInvoices.push(invoice); } } this.subscriptionInvoices = unsortedSubscriptionInvoices.sort((x1, x2) => { if (x1.Description.toLowerCase() < x2.Description.toLowerCase()) return -1; if (x1.Description.toLowerCase() > x2.Description.toLowerCase()) return 1; return 0; }); // Perform lookup to find current active subscription invoice revision // based on the supplied lineage this.renewalSubscriptionInvoiceId = this.getCurrentSubscriptionInvoiceIdFromLineage(this.renewalSubscriptionLineageId); // If a current active subscriptionInvoiceID is not found (meaning the lineage was removed // then the renewal cannot happen so change to a new membership if (this.renewalSubscriptionInvoiceId === 0 && this.signupTypeId === 2) { this.signupTypeId = 1; this.clientSubscriberId = null; this.renewalSubscriptionLineageId = null; this.renewalSubscriptionLineageBroken = true; } // default countries to USA this.applicant_countryOnSelect(this.signupForm.controls['applicant_country'].value); this.company_countryOnSelect(this.signupForm.controls['company_country'].value); const pmCtrl = (this.signupForm).controls.paymentMethod; const cardCtrl = pmCtrl.controls.card; this.cardholder_countryOnSelect(cardCtrl.controls['cardholderCountry'].value); if (this.signupTypeId === 2) {//renewal this.populateRenewalData(); this.populateFormData(); } else { this.populateFormData(); } }, error => this.errorMessage = error); this.titles = this._titleService.getTitles(); // subscrbe this.subscribePaymentTypeChanges(); this.setPaymentMethodType(this.constants.PaymentMethodType.Bank); } initPaymentMethodFormGroup() { const group = this._fb.group({ type: [''], card: this._fb.group(this.initPaymentMethodCardModel()), bank: this._fb.group(this.inititPaymentMethodBankModel()) }) return group; } initPaymentMethodCardModel() { const model = { cardNo: ['', [Validators.required, Validators.pattern(this.constants.cardNumberRegex)]], expiryMonth: ['', [Validators.required, Validators.pattern(this.constants.expiryMonth)]], expiryYear: ['', [Validators.required, Validators.pattern(this.constants.expiryYear)]], securityCode: ['', [Validators.required, Validators.pattern(this.constants.securityCode)]], cardholderName: ['', [Validators.required, Validators.pattern(this.constants.allCantBeNumbers)]], cardholderBillingAddress1: ['', [Validators.required, Validators.pattern(this.constants.allCantBeNumbers)]], cardholderBillingAddress2: '', cardholderCity: ['', [Validators.required, Validators.pattern(this.constants.allCantBeNumbers)]], cardholderState: ['', [Validators.required]], cardholderCountry: ['USA', [Validators.required]], cardholderPostalCode: ['', [Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]], }; return model; } inititPaymentMethodBankModel() { const model = { accountNo: ['', Validators.required], accountType: ['', Validators.required], accountHolderName: ['', [Validators.required, Validators.maxLength(200)]], checkNumber: '', routingNo: ['', Validators.required] }; return model; } // subscribed events subscribePaymentTypeChanges() { const pmCtrl = (this.signupForm).controls.paymentMethod; const bankCtrl = pmCtrl.controls.bank; const cardCtrl = pmCtrl.controls.card; const changes$ = pmCtrl.controls.type.valueChanges; changes$.subscribe(paymentMethodType => { if (paymentMethodType === this.constants.PaymentMethodType.Bank) { Object.keys(bankCtrl.controls).forEach(key => { bankCtrl.controls[key].setValidators(this.inititPaymentMethodBankModel()[key][1]); bankCtrl.controls[key].updateValueAndValidity(); }); Object.keys(cardCtrl.controls).forEach(key => { cardCtrl.controls[key].setValidators(null); cardCtrl.controls[key].updateValueAndValidity(); }); } if (paymentMethodType == this.constants.PaymentMethodType.Card) { Object.keys(cardCtrl.controls).forEach(key => { cardCtrl.controls[key].setValidators(this.initPaymentMethodCardModel()[key][1]); cardCtrl.controls[key].updateValueAndValidity(); }); Object.keys(bankCtrl.controls).forEach(key => { bankCtrl.controls[key].setValidators(null); bankCtrl.controls[key].updateValueAndValidity(); }); } }) } // ui events applicant_countryOnSelect(abbreviation: string): void { if (this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0] && this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID) { let countryId: number = this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID; this.applicantStates = this.signupInfo.BrandingInfo.States.filter(item => item.CountryID == countryId); this.signupForm.patchValue({ applicant_state: '' }); // set validations for postal code if (abbreviation == 'USA') { this.signupForm.controls['applicant_postalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]); } else if (abbreviation == 'CAN') { this.signupForm.controls['applicant_postalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.canPostalCodeRegex)]); } else { this.signupForm.controls['applicant_postalCode'].setValidators([Validators.required, Validators.maxLength(20)]); } } } cardholder_countryOnSelect(abbreviation: string): void { if (this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0] && this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID) { let countryId: number = this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID; this.cardholderStates = this.signupInfo.BrandingInfo.States.filter(item => item.CountryID == countryId); const pmCtrl = (this.signupForm).controls.paymentMethod; const cardCtrl = pmCtrl.controls.card; cardCtrl.patchValue({ cardholderState: '' }); // set validations for postal code if (abbreviation == 'USA' && pmCtrl.controls.type.value === this.constants.PaymentMethodType.Card) { cardCtrl.controls['cardholderPostalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]); } else if (abbreviation == 'CAN' && pmCtrl.controls.type.value === this.constants.PaymentMethodType.Card) { cardCtrl.controls['cardholderPostalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.canPostalCodeRegex)]); } else { cardCtrl.controls['cardholderPostalCode'].setValidators(null); } } } company_countryOnSelect(abbreviation: string): void { if (this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0] && this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID) { let countryId: number = this.signupInfo.BrandingInfo.Countries.filter(item => item.Abbr == abbreviation)[0].CountryID; this.companyStates = this.signupInfo.BrandingInfo.States.filter(item => item.CountryID == countryId); this.signupForm.patchValue({ company_state: '' }); // set validation for postal code if (abbreviation == 'USA') { this.signupForm.controls['company_postalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.usPostalCodeRegex)]); } else if (abbreviation == 'CAN') { this.signupForm.controls['company_postalCode'].setValidators([Validators.required, Validators.maxLength(20), Validators.pattern(this.constants.canPostalCodeRegex)]); } else { this.signupForm.controls['company_postalCode'].setValidators([Validators.required, Validators.maxLength(20)]); } } } companyAddress_copyClicked(): void { this.signupForm.patchValue({ company_address1: this.signupForm.controls['applicant_address1'].value }); this.signupForm.patchValue({ company_address2: this.signupForm.controls['applicant_address2'].value }); this.signupForm.patchValue({ company_country: this.signupForm.controls['applicant_country'].value }); this.signupForm.patchValue({ company_city: this.signupForm.controls['applicant_city'].value }); this.company_countryOnSelect(this.signupForm.controls['applicant_country'].value); this.signupForm.patchValue({ company_postalCode: this.signupForm.controls['applicant_postalCode'].value }); this.signupForm.patchValue({ company_state: this.signupForm.controls['applicant_state'].value }); } paymentMethod_applicant_copyClicked(): void { const pmCtrl = (this.signupForm).controls.paymentMethod; const cardCtrl = pmCtrl.controls.card; cardCtrl.patchValue({ cardholderBillingAddress1: this.signupForm.controls['applicant_address1'].value }); cardCtrl.patchValue({ cardholderBillingAddress2: this.signupForm.controls['applicant_address2'].value }); cardCtrl.patchValue({ cardholderCountry: this.signupForm.controls['applicant_country'].value }); cardCtrl.patchValue({ cardholderCity: this.signupForm.controls['applicant_city'].value }); this.cardholder_countryOnSelect(this.signupForm.controls['applicant_country'].value); cardCtrl.patchValue({ cardholderPostalCode: this.signupForm.controls['applicant_postalCode'].value }); cardCtrl.patchValue({ cardholderState: this.signupForm.controls['applicant_state'].value }); } paymentMethod_company_copyClicked(): void { const pmCtrl = (this.signupForm).controls.paymentMethod; const cardCtrl = pmCtrl.controls.card; cardCtrl.patchValue({ cardholderBillingAddress1: this.signupForm.controls['company_address1'].value }); cardCtrl.patchValue({ cardholderBillingAddress2: this.signupForm.controls['company_address2'].value }); cardCtrl.patchValue({ cardholderCountry: this.signupForm.controls['company_country'].value }); cardCtrl.patchValue({ cardholderCity: this.signupForm.controls['company_city'].value }); this.cardholder_countryOnSelect(this.signupForm.controls['company_country'].value); cardCtrl.patchValue({ cardholderPostalCode: this.signupForm.controls['company_postalCode'].value }); cardCtrl.patchValue({ cardholderState: this.signupForm.controls['company_state'].value }); } demographic_raceOnSelect(selection) { // todo. find a better way to display the other race input box this.demographic_showOtherRaceOption = false if (selection[0] == 6) { this.demographic_showOtherRaceOption = true; } } membershipTypeOverride(): void { this.renewalSubscriptionOverride = !this.renewalSubscriptionOverride; if (this.renewalSubscriptionOverride) { this.signupForm.get('subscriptionInvoiceId').enable(); this.signupTypeId = 1; } else { this.signupForm.patchValue({ subscriptionInvoiceId: this.renewalSubscriptionInvoiceId }); this.signupForm.get('subscriptionInvoiceId').disable(); this.membershipTypeOnSelect(this.renewalSubscriptionInvoiceId); this.signupTypeId = 2; } } membershipTypeOnSelect(id: number): void { this.frequencyTotals = this.subscriptionInvoices.filter(item => item.ID == id)[0].FrequencyTotals; this.invoiceItems = this.subscriptionInvoices.filter(item => item.ID == id)[0].InvoiceItems; // load the correct activites (primary and secondary) for the selected membership type (builder, assoc, affiliate) let typeId: number = this.subscriptionInvoices.filter(item => item.ID == id)[0].TypeID; this.signupForm.patchValue({ subscriptionTypeId: typeId }); this.subscriptionTypeName = this.signupInfo.Subscriptions.filter(item => item.ID === typeId)[0].Name; if (this.subscriptionTypeName == 'Builder' || this.subscriptionTypeName == 'Associate') { this.signupForm.controls['primaryActivity'].setValidators([Validators.required]); this.signupForm.patchValue({ primaryActivity: '' }); this.primaryActivities = this._primaryActivityService.getPrimaryActivities().filter(item => item.typeName === this.subscriptionTypeName); this.signupForm.patchValue({ secondaryActivity1: '' }); this.secondaryActivities1 = this._secondaryActivityService.getSecondaryActivities().filter(item => item.subscriptionTypeId === this.subscriptionTypeName); this.signupForm.patchValue({ secondaryActivity2: '' }); this.secondaryActivities2 = this._secondaryActivityService.getSecondaryActivities().filter(item => item.subscriptionTypeId === this.subscriptionTypeName); } else { this.signupForm.controls['primaryActivity'].setValidators(null); this.signupForm.patchValue({ primaryActivity: '' }); } } frequencyOnSelect(id: number): void { this.signupForm.patchValue({ frequencyId: id }); } setPaymentMethodType(type: string) { const ctrl: FormControl = (this.signupForm).controls.paymentMethod.controls.type; ctrl.setValue(type); } handleCorrectCaptcha(response) { this.signupForm.patchValue({ reCaptcha: response }); } // save save(model: IApplication, isValid: boolean) { this.isBusy = !this.isBusy; // map application to a subscription request in prep to make the call; const pmCtrl = (this.signupForm).controls.paymentMethod; if (!model.subscriptionInvoiceId) { model.subscriptionInvoiceId = this.signupForm.controls['subscriptionInvoiceId'].value; } let request = this._subscriptionRequestService.getRequest(model, this.signupTypeId, 1, pmCtrl.controls['type'].value, this.clientSubscriberId); this._signupInfoService.submit(this.postUrl, request).subscribe( info => { this.isBusy = false; this.confirmApplicantFirstName = model.firstName; this.confirmApplicantLastName = model.lastName; this.subscriptionResponse = info; this.submitResultSuccess = true; this.submittedForm = true; this.captcha.reset(); this.signupForm.reset(); }, error => { this.errorMessage = error; this.submitResultSuccess = false; this.isBusy = false; this.submittedForm = true; this.captcha.reset(); } ); } populateFormData() { let nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantSuffix")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ suffix: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantFirstName")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ firstName: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantLastName")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ lastName: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantTitleId")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ title: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantTitleOther")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ titleOther: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantTitleOther")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ titleOther: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "SponsoringMemberName")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ sponsoringName: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "SponsoringMemberPIN")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ sponsoringPin: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "SponsoringMemberPIN")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ sponsoringPin: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "SponsoringMemberEmail")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ sponsoringEmail: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddressType")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ addressType: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddress2")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_address2: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddressCountry")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_country: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddressCity")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_city: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddressState")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_state: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddressPostalCode")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_postalCode: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyName")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ companyName: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddress1")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_address1: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddress2")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_address2: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddressCountry")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_country: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddressCity")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_city: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddressState")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_state: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyAddressPostalCode")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ company_postalCode: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessPrimaryActivity")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ primaryActivity: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessSecondaryActivity1")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ secondaryActivity1: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessSecondaryActivity2")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ secondaryActivity2: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessPrimaryActivityOther")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ primaryActivity_other: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessSecondaryActivity1Other")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ secondaryActivity1_other: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "BusinessSecondaryActivity2Other")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ secondaryActivity2_other: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "Demographic_SingleFamilyUnits")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_singleFamilyUnits: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "Demographic_MultiFamilyUnits")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_multiFamilyUnits: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "Demographic_DollarVolume")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_dollarVolume: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "Demographic_ConstructionEmployees")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_constructionEmployees: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "Demographic_NonConstructionEmployees")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_nonConstructionEmployees: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "RenewalAge")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_age: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "RenewalRace")[0]; if (nameValue && nameValue.Value) { let raceArray: Array = nameValue.Value.split(','); if (raceArray) this.signupForm.patchValue({ demographic_race: raceArray }); } nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "RenewalEthnicity")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_ethnicity: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "RenewalGender")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_gender: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "RenewalEducation")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ demographic_education: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantAddress1")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ applicant_address1: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantEmail")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ email: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantMiddle")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ middleName: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantFax")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ fax: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantPhone")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ phone: nameValue.Value }); nameValue = this.signupInfo.FormInfo.Fields.filter(x => x.Name === "ApplicantCompanyWebsite")[0]; if (nameValue && nameValue.Value) this.signupForm.patchValue({ companyWebsite: nameValue.Value }); } populateRenewalData() { this.signupForm.patchValue({ subscriptionInvoiceId: this.renewalSubscriptionInvoiceId }); this.signupForm.get('subscriptionInvoiceId').disable(); this.membershipTypeOnSelect(this.renewalSubscriptionInvoiceId); } getCurrentSubscriptionInvoiceIdFromLineage(lineage: number) : number { let itemArray = this.subscriptionInvoices.filter(item => item.LineageID == lineage); if (itemArray && itemArray.length > 0) { let subInvId: number = itemArray[0].ID; if (subInvId > 0) { return subInvId; } } return 0; } }