diff --git a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts index e38e5f79b..2404c6f6e 100755 --- a/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts +++ b/ng6-seed/src/app/personal-discussion/manage-pd/list-pd/start-pd/forms/other-income/other-income.component.ts @@ -26,6 +26,9 @@ import { ActivatedRoute, Router } from '@angular/router'; import { RentalVerificationComponent } from './../rental-verification/rental-verification.component'; +/**sweet alert */ +import Swal from 'sweetalert2'; + @Component({ selector: 'app-other-income', templateUrl: './other-income.component.html', @@ -58,7 +61,6 @@ export class OtherIncomeComponent implements OnInit { mergeCompanyApplicant: any = []; isIncomeEarnedBy: any = []; // stringArr = []; - constructor(notifier: NotifierService, private fb: FormBuilder, private route: ActivatedRoute, @@ -301,6 +303,10 @@ export class OtherIncomeComponent implements OnInit { } let records: any = {}; + let rentOptionCount: number = 0; + let validateFlag: number = 0; + // let zeroEntries + records.parent_pdid = this.parent_pdid; records.pdid = this.pdid; records.formid = this.form_id; @@ -308,45 +314,68 @@ export class OtherIncomeComponent implements OnInit { records.other_income = this.otherIncomeForm.controls['other_income'].value; records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value; - - if (this.otherIncomeForm.controls['other_income'].value == 'Yes') { records.income_details = this.otherIncomeForm.controls['income_details'].value; - - let s: number = 0; - let rentOptionCount: number = 0; - records.income_details.forEach(option => { - console.log(option); - console.log(option.source); - if (+option.source == 5) { - rentOptionCount++; - console.log(option.source); - let params: any = {}; - params.parent_pdid = this.parent_pdid; - params.pd_id = this.pdid; - params.pd_form_id = this.rental_form_id; - this._pd.retriveForm(params).subscribe(data => { - data.dataStatus == false ? s = 1 : s = 0; - console.log(s); - if(s == 1){ - this.notifier.notify('warning', "You have choose "+ rentOptionCount +" rent option but you didn't fill the rental verification form please fill it"); - s = 0; - rentOptionCount = 0; - return; - } - - }); - } + if (+option.source == 5) { + rentOptionCount++; + validateFlag = 1; + } }); - if(s == 1){ - this.notifier.notify('warning', "You have choose "+ rentOptionCount +" rent option but you didn't fill the rental verification form please fill it"); - s = 0; - rentOptionCount = 0; - return; + + if(validateFlag == 1){ + let params: any = {}; + let textMessage : any; + params.parent_pdid = this.parent_pdid; + params.pd_id = this.pdid; + params.pd_form_id = this.rental_form_id; + this._pd.retriveForm(params).subscribe(data => { + if(!data.dataStatus){ + let text : any = rentOptionCount > 1 ? rentOptionCount + ' properties' : rentOptionCount + ' property' ; + // this.notifier.notify('warning', "You have chosen "+ rentOptionCount +" properties as rental income, but rental verification form is not filled"); + textMessage = '