validation msg : ps
This commit is contained in:
parent
bf73ca220c
commit
2610ba397b
@ -26,6 +26,9 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
|
|
||||||
import { RentalVerificationComponent } from './../rental-verification/rental-verification.component';
|
import { RentalVerificationComponent } from './../rental-verification/rental-verification.component';
|
||||||
|
|
||||||
|
/**sweet alert */
|
||||||
|
import Swal from 'sweetalert2';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-other-income',
|
selector: 'app-other-income',
|
||||||
templateUrl: './other-income.component.html',
|
templateUrl: './other-income.component.html',
|
||||||
@ -58,7 +61,6 @@ export class OtherIncomeComponent implements OnInit {
|
|||||||
mergeCompanyApplicant: any = [];
|
mergeCompanyApplicant: any = [];
|
||||||
isIncomeEarnedBy: any = [];
|
isIncomeEarnedBy: any = [];
|
||||||
// stringArr = [];
|
// stringArr = [];
|
||||||
|
|
||||||
constructor(notifier: NotifierService,
|
constructor(notifier: NotifierService,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -301,6 +303,10 @@ export class OtherIncomeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let records: any = {};
|
let records: any = {};
|
||||||
|
let rentOptionCount: number = 0;
|
||||||
|
let validateFlag: number = 0;
|
||||||
|
// let zeroEntries
|
||||||
|
|
||||||
records.parent_pdid = this.parent_pdid;
|
records.parent_pdid = this.parent_pdid;
|
||||||
records.pdid = this.pdid;
|
records.pdid = this.pdid;
|
||||||
records.formid = this.form_id;
|
records.formid = this.form_id;
|
||||||
@ -308,45 +314,68 @@ export class OtherIncomeComponent implements OnInit {
|
|||||||
records.other_income = this.otherIncomeForm.controls['other_income'].value;
|
records.other_income = this.otherIncomeForm.controls['other_income'].value;
|
||||||
records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value;
|
records.otherincome_remarks = this.otherIncomeForm.controls['otherincome_remarks'].value;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (this.otherIncomeForm.controls['other_income'].value == 'Yes') {
|
if (this.otherIncomeForm.controls['other_income'].value == 'Yes') {
|
||||||
records.income_details = this.otherIncomeForm.controls['income_details'].value;
|
records.income_details = this.otherIncomeForm.controls['income_details'].value;
|
||||||
|
|
||||||
let s: number = 0;
|
|
||||||
let rentOptionCount: number = 0;
|
|
||||||
|
|
||||||
records.income_details.forEach(option => {
|
records.income_details.forEach(option => {
|
||||||
console.log(option);
|
if (+option.source == 5) {
|
||||||
console.log(option.source);
|
rentOptionCount++;
|
||||||
if (+option.source == 5) {
|
validateFlag = 1;
|
||||||
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(s == 1){
|
|
||||||
this.notifier.notify('warning', "You have choose "+ rentOptionCount +" rent option but you didn't fill the rental verification form please fill it");
|
if(validateFlag == 1){
|
||||||
s = 0;
|
let params: any = {};
|
||||||
rentOptionCount = 0;
|
let textMessage : any;
|
||||||
return;
|
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 = '<center> You have chosen '+ text +' as rental income, but rental verification form is not filled </center>';
|
||||||
|
Swal({
|
||||||
|
title: 'Please Confirm',
|
||||||
|
type: 'info',
|
||||||
|
html: textMessage,
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
cancelButtonColor: '#d33',
|
||||||
|
confirmButtonText: 'Confirm',
|
||||||
|
// cancelButtonText:'Cancel And Correct',
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.value) {
|
||||||
|
console.log('rental data status is true',validateFlag);
|
||||||
|
this.saveAPI(records);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('rental data status is true',validateFlag);
|
||||||
|
// rentOptionCount = 0;
|
||||||
|
// validateFlag = 0 ;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
rentOptionCount = 0;
|
||||||
|
validateFlag = 0 ;
|
||||||
|
}
|
||||||
|
else if(data.dataStatus){
|
||||||
|
console.log('rental data status is true',validateFlag);
|
||||||
|
this.saveAPI(records);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log('now flag is zero',validateFlag);
|
||||||
|
this.saveAPI(records);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
console.log('now option is no',validateFlag);
|
||||||
|
this.saveAPI(records);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveAPI(records){
|
||||||
this._pd.saveForm(records).subscribe(data => {
|
this._pd.saveForm(records).subscribe(data => {
|
||||||
if (data.status == 200) {
|
if (data.status == 200) {
|
||||||
this.notifier.notify('success', 'Saved Successfully.');
|
this.notifier.notify('success', 'Saved Successfully.');
|
||||||
@ -361,7 +390,6 @@ export class OtherIncomeComponent implements OnInit {
|
|||||||
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!' + '-' + error.error_text + ' occur');
|
this.notifier.notify('warning', 'Something Wents Wrong Try Again.!' + '-' + error.error_text + ' occur');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
validateAllFormFields(formGroup: any) {
|
validateAllFormFields(formGroup: any) {
|
||||||
Object.keys(formGroup.controls).forEach(field => {
|
Object.keys(formGroup.controls).forEach(field => {
|
||||||
const control = formGroup.get(field);
|
const control = formGroup.get(field);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user